fanli/.classpath
@@ -24,6 +24,7 @@ <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> <classpathentry kind="lib" path="libs/opush-server-sdk-1.0.3.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_131"/> <classpathentry kind="output" path="target/classes"/> </classpath> fanli/libs/vpush-server-sdk-2.0.jarBinary files differ
fanli/pom.xml
@@ -127,6 +127,14 @@ <systemPath>${basedir}/libs/opush-server-sdk-1.0.3.jar</systemPath> </dependency> <dependency> <groupId>vpush-server-sdk-2.0</groupId> <artifactId>vpush-server-sdk-2.0</artifactId> <version>2.0</version> <scope>system</scope> <systemPath>${basedir}/libs/vpush-server-sdk-2.0.jar</systemPath> </dependency> </dependencies> <build> fanli/src/main/java/com/yeshi/fanli/controller/TestController.java
@@ -45,8 +45,10 @@ import com.yeshi.fanli.entity.dynamic.GoodsPicture; import com.yeshi.fanli.entity.dynamic.InviteMaterial; import com.yeshi.fanli.entity.jd.JDGoods; import com.yeshi.fanli.entity.taobao.SearchFilter; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra; import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult; import com.yeshi.fanli.exception.ActivityException; import com.yeshi.fanli.exception.push.PushException; import com.yeshi.fanli.exception.share.UserShareGoodsRecordException; @@ -68,6 +70,8 @@ import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; import com.yeshi.fanli.util.jd.JDApiUtil; import com.yeshi.fanli.util.push.OPPOPushUtil; import com.yeshi.fanli.util.taobao.TaoBaoUtil; import com.yeshi.fanli.util.taobao.TaoKeApiUtil; import com.yeshi.fanli.vo.goods.GoodsDetailVO; import net.sf.json.JSONArray; @@ -579,8 +583,28 @@ } out.print("success"); } @RequestMapping(value = "testListTLJGoods") public void getGoodsList(String callback,PrintWriter out) { SearchFilter sf = new SearchFilter(); sf.setMaterialId("19450"); sf.setQuan(1); sf.setTmall(true); sf.setStartTkRate(5); sf.setEndPrice(new BigDecimal(1000)); sf.setPage(1); sf.setPage(100); TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiao(sf); Gson gson = new Gson(); JSONArray array=new JSONArray(); for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) { array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, "100", null))); } out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(array))); } /** * 插入邀请素材 @@ -598,4 +622,5 @@ e.printStackTrace(); } } } fanli/src/main/java/com/yeshi/fanli/job/order/taobao/UpdateOrderJob.java
@@ -37,6 +37,7 @@ import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TimeUtil; import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil; import com.yeshi.fanli.util.taobao.TaoKeApiUtil; import com.yeshi.fanli.util.taobao.TaoKeOrderApiUtil; //从淘宝爬去订单更新 @@ -231,7 +232,6 @@ Iterator<String> its = map.keySet().iterator(); while (its.hasNext()) { String key = its.next(); List<TaoBaoOrder> orders = map.get(key); String redisKey = "addorderqueue-" + key; // redis做频率限制 try { @@ -282,7 +282,8 @@ public void doJob6() { if (!Constant.IS_TASK) return; long endTime = System.currentTimeMillis() - 1000 * 60; Date systemDate = TaoKeApiUtil.getTaoBaoSystemTime(); long endTime = systemDate != null ? systemDate.getTime() : System.currentTimeMillis(); updateOrder(endTime - 1000 * 60 * 20L, endTime); } fanli/src/main/java/com/yeshi/fanli/mapping/AccountMessageMapper.xml
@@ -46,6 +46,7 @@ <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_account_message where id = #{id,jdbcType=BIGINT} </delete> <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.AccountMessage" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_account_message fanli/src/main/java/com/yeshi/fanli/service/impl/user/QrCodeServiceImpl.java
@@ -42,7 +42,7 @@ String targetPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + System.currentTimeMillis() + ".jpg"; String erCodeTempPath = FileUtil.getCacheDir() + "/" + uid + "_" + System.currentTimeMillis() + ".jpg"; String erCode = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/" String erCode = ("http://" + Constant.wxGZConfig.getLoginHost() + "/" + Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid); // 生成 try { @@ -91,7 +91,7 @@ String targetPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + System.currentTimeMillis() + ".jpg"; String erCodeTempPath = FileUtil.getCacheDir() + "/" + uid + "_" + System.currentTimeMillis() + ".jpg"; String erCode = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/" String erCode = ("http://" + Constant.wxGZConfig.getLoginHost() + "/" + Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid); // 生成 try { @@ -161,7 +161,7 @@ targetPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + System.currentTimeMillis() + ".jpg"; erCodeTempPath = FileUtil.getCacheDir() + "/" + uid + "_" + System.currentTimeMillis() + ".jpg"; String erCode = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/" String erCode = ("http://" + Constant.wxGZConfig.getLoginHost() + "/" + Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid); // 生成 try { @@ -237,7 +237,7 @@ } else { targetPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + System.currentTimeMillis() + ".jpg"; erCodeTempPath = FileUtil.getCacheDir() + "/" + uid + "_" + System.currentTimeMillis() + ".jpg"; String erCode = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/" String erCode = ("http://" + Constant.wxGZConfig.getLoginHost() + "/" + Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid); // 生成 try { fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
@@ -172,11 +172,10 @@ doJDOrderJob();// 京东订单处理 doPDDOrderJob();// 拼多多订单处理 doImportantTaoBaoGoodsUpdateJob();// 淘宝重要商品的信息更新 doHongBaoRecieveIntegralGetJob();// 返利到账,金币增加 // doPlaceOrderIntegralJob();// 下单赠送金币任务 // doDouYinDeviceActiveJob();// 抖音设备激活广告监测 doHongBaoRecieveIntegralGetJob();// 返利到账,金币增加 // doPlaceOrderIntegralJob();// 下单赠送金币任务 doDouYinDeviceActiveJob();// 抖音设备激活广告监测 } } /** @@ -855,15 +854,15 @@ integralTaskRecordService.firstRebateOrderRewardBoss(boss.getId(), order.getUserInfo().getId(), null); } } boss = threeSaleSerivce.getBoss(boss.getId()); if (boss != null) {// 判断上级的红包 if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) { // 补偿金币2级 integralTaskRecordService.firstRebateOrderRewardBossSuper(boss.getId(), order.getUserInfo().getId(), null); boss = threeSaleSerivce.getBoss(boss.getId()); if (boss != null) {// 判断上级的红包 if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId()) .compareTo(new BigDecimal("0")) <= 0) { // 补偿金币2级 integralTaskRecordService.firstRebateOrderRewardBossSuper(boss.getId(), order.getUserInfo().getId(), null); } } } } fanli/src/main/java/com/yeshi/fanli/util/push/VIVOPushUtil.java
@@ -1,21 +1,19 @@ package com.yeshi.fanli.util.push; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.Iterator; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.StringRequestEntity; import org.yeshi.utils.HttpUtil; import com.yeshi.fanli.exception.push.VIVOPushException; import com.vivo.push.sdk.notofication.Message; import com.vivo.push.sdk.notofication.Result; import com.vivo.push.sdk.notofication.TargetMessage; import com.vivo.push.sdk.server.Sender; import com.yeshi.fanli.dto.push.PushTypeEnum; import com.yeshi.fanli.exception.push.PushException; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.StringUtil; import net.sf.json.JSONObject; /** * VIVO的推送帮助 @@ -25,41 +23,11 @@ */ public class VIVOPushUtil { /** * POST请求 * * @param url * @param body * @param headers * @return */ private static String post(String url, String body, Map<String, String> headers) { HttpClient httpClient = new HttpClient(); PostMethod pm = new PostMethod(url); try { pm.setRequestEntity(new StringRequestEntity(body, "application/json", "UTF-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } if (headers != null) { Iterator<String> its = headers.keySet().iterator(); while (its.hasNext()) { String key = its.next(); pm.setRequestHeader(key, headers.get(key)); } } try { httpClient.executeMethod(pm); return pm.getResponseBodyAsString(); } catch (HttpException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } private static final int APP_ID = 15206; private static final String APP_KEY = "996c07d6-ec2b-41ef-b7c9-abb51ac63abf"; private static final String APP_SECRET = "882548de-8183-4d29-9769-48b2bb4169c8"; static String authToken = null; static long authTokenTime = 0L; /** * 获取授权码 @@ -68,23 +36,232 @@ * @param appKey * @param appSecret * @return * @throws VIVOPushException * @throws Exception */ public static String getAuthToken(String appId, String appKey, String appSecret) throws VIVOPushException { JSONObject params = new JSONObject(); long timestamp = System.currentTimeMillis(); params.put("appId", appId); params.put("appKey", appKey); params.put("timestamp", timestamp); params.put("sign", StringUtil.Md5(appId + appKey + timestamp + appSecret)); String result = post("https://host:port/message/auth", params.toString(), null); JSONObject resultJson = JSONObject.fromObject(result); if (resultJson.optInt("result") != 0) throw new VIVOPushException(resultJson.optInt("result"), resultJson.optString("desc")); return resultJson.optString("authToken"); private static String getAuthToken(int appId, String appKey, String appSecret) throws Exception { Sender sender = new Sender(appSecret);// 实例化Sender sender.initPool(20, 10);// 设置连接池参数,可选项 Result result = sender.getToken(appId, appKey);// 发送鉴权请求 if (result.getResult() == 0) { return result.getAuthToken(); } throw new Exception("token获取失败"); } private static String getAuthToken() { if (StringUtil.isNullOrEmpty(authToken) || (System.currentTimeMillis() - authTokenTime) > 5000 * 60 * 60L) { try { String token = getAuthToken(APP_ID, APP_KEY, APP_SECRET); authToken = token; authTokenTime = System.currentTimeMillis(); } catch (Exception e) { e.printStackTrace(); } } return authToken; } private static Message.Builder getBaseMessageBuidler(String title, String content, Map<String, String> customParams) { Message.Builder buidler = new Message.Builder(); buidler = buidler.title(title).content(content).skipType(4).skipContent("").notifyType(3); buidler = buidler.clientCustomMap(customParams); return buidler; } private static Message.Builder getMessageBuidler(PushTypeEnum type, String title, String content, String activity, String url, String webUrl, Long id) { Map<String, String> data = new HashMap<>(); if (type != null) data.put("type", type.name()); if (activity != null) data.put("activity", activity); if (url != null) data.put("url", url); if (webUrl != null) data.put("webUrl", webUrl); if (id != null) data.put("id", id + ""); return getBaseMessageBuidler(title, content, data); } // 推送所有设备 private static void pushAll(Message.Builder builder) { String authToken = getAuthToken(); if (StringUtil.isNullOrEmpty(authToken)) return; try { Sender sender = new Sender(APP_SECRET); sender.initPool(20, 10);// 设置连接池参数,可选项 sender.setAuthToken(authToken);// 设置推送的必要参数authToken(调用鉴权方法获得) Message allSendMessage = builder.build();// 构建要全量推送的消息体 Result result = sender.sendToAll(allSendMessage); if (result.getResult() == 0)// 成功 { } } catch (Exception e) { } } // 推送部分设备 private static boolean push(List<String> regIdList, Message.Builder builder) { String authToken = getAuthToken(); if (StringUtil.isNullOrEmpty(authToken)) return false; try { Sender sender = new Sender(APP_SECRET); sender.initPool(20, 10);// 设置连接池参数,可选项 sender.setAuthToken(authToken);// 设置推送的必要参数authToken(调用鉴权方法获得) Message saveList = builder.build();// 构建要保存的批量推送消息体 Result result = sender.saveListPayLoad(saveList);// 发送保存群推消息请求 String taskId = result.getTaskId(); Set<String> regIds = new HashSet<>();// 构建批量推送用户群 for (String regId : regIdList) regIds.add(regId); TargetMessage targetMessage = new TargetMessage.Builder().regIds(regIds).taskId(taskId).build();// 构建批量推送的消息体 result = sender.sendToList(targetMessage);// 批量推送给用户 if (result.getResult() == 0)// 成功 { return true; } } catch (Exception e) { } return false; } /** * 推送商品 * * @param registerIds * -最大值1000 * @param title * @param content * @param goodsType * @param goodsId * @throws PushException */ public static void pushGoods(List<String> registerIds, String title, String content, int goodsType, Long goodsId) throws PushException { if (registerIds != null && registerIds.size() > 500) throw new PushException(1, "设备数不能超过500个"); String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() + ".ui.recommend.GoodsBrowserActivity"; Message.Builder builder = getMessageBuidler(PushTypeEnum.goodsdetail, title, content, activity, null, null, goodsId); try { boolean success = push(registerIds, builder); if (!success) throw new PushException(2, "推送失败"); } catch (Exception e) { e.printStackTrace(); } } /** * 网页推送 * * @param registerIds * 最大值1000 * @param title * @param content * @param url * -网页链接 * @throws PushException */ public static void pushUrl(List<String> registerIds, String title, String content, String url) throws PushException { if (registerIds != null && registerIds.size() > 500) throw new PushException(1, "设备数不能超过500个"); String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() + ".ui.invite.ShareBrowserActivity"; Message.Builder builder = getMessageBuidler(PushTypeEnum.url, title, content, activity, null, url, null); try { boolean success = push(registerIds, builder); if (!success) throw new PushException(2, "推送失败"); } catch (Exception e) { e.printStackTrace(); } } /** * 站内信推送 * * @param registerIds * 最大值1000 * @param title * @param content * @param url * -网页链接 * @throws PushException */ public static void pushZNX(List<String> registerIds, String title, String content) throws PushException { if (registerIds != null && registerIds.size() > 500) throw new PushException(1, "设备数不能超过500个"); Message.Builder builder = getMessageBuidler(PushTypeEnum.ZNX, title, content, null, null, null, null); try { boolean success = push(registerIds, builder); if (!success) throw new PushException(2, "推送失败"); } catch (Exception e) { e.printStackTrace(); } } public static void pushWEEX(List<String> registerIds, String title, String content, String weexUrl) throws PushException { String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() + ".ui.mine.weex.WeexApplicationActivity"; Message.Builder builder = getMessageBuidler(PushTypeEnum.weex, title, content, activity, weexUrl, weexUrl, null); try { boolean success = push(registerIds, builder); if (!success) throw new PushException(2, "推送失败"); } catch (Exception e) { e.printStackTrace(); } } public static void pushBaiChuanUrl(List<String> registerIds, String title, String content, String url) throws PushException { Message.Builder builder = getMessageBuidler(PushTypeEnum.baichuan, title, content, null, url, null, null); try { boolean success = push(registerIds, builder); if (!success) throw new PushException(2, "推送失败"); } catch (Exception e) { e.printStackTrace(); } } public static void pushWelfareCenter(List<String> registerIds, String title, String content) throws PushException { String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() + ".ui.mine.WelfareCenterActivity"; Message.Builder builder = getMessageBuidler(PushTypeEnum.welfare, title, content, activity, null, null, null); try { boolean success = push(registerIds, builder); if (!success) throw new PushException(2, "推送失败"); } catch (Exception e) { e.printStackTrace(); } } public static void pushUserSignInNotification(List<String> registerIds, String title, String content) throws PushException { String activity = Constant.systemCommonConfig.getAndroidBaseactivityName() + ".ui.goldtask.GoldTaskActivity"; Message.Builder builder = getMessageBuidler(PushTypeEnum.signin, title, content, activity, null, null, null); try { boolean success = push(registerIds, builder); if (!success) throw new PushException(2, "推送失败"); } catch (Exception e) { e.printStackTrace(); } } } fanli/src/main/webapp/WEB-INF/lib/vpush-server-sdk-2.0.jarBinary files differ
fanli/src/test/java/org/fanli/MyBatisProduce.java
@@ -4,8 +4,7 @@ import org.yeshi.utils.mybatis.ColumnParseUtil; import org.yeshi.utils.mybatis.MyBatisMapperUtil; import com.yeshi.fanli.entity.common.Config; import com.yeshi.fanli.entity.jd.JDOrderItem; import com.yeshi.fanli.entity.push.DeviceActive; //@Ignore public class MyBatisProduce { @@ -13,14 +12,14 @@ @Test public void test3() { // MyBatisMapperUtil.createMapper(JDOrder.class); MyBatisMapperUtil.createMapper(JDOrderItem.class); MyBatisMapperUtil.createMapper(ShortUrl.class); // MyBatisMapperUtil.createMapper(UserMoneyDebtReturnHistory.class); } @Test public void test1() { ColumnParseUtil.parseColumn(Config.class, "D:\\workspace\\fanli\\fanli-server\\fanli\\src\\main\\java\\com\\yeshi\\fanli\\mapping\\ConfigMapper.xml"); ColumnParseUtil.parseColumn(DeviceActive.class, "D:\\workspace\\fanli\\fanli-server\\fanli\\src\\main\\java\\com\\yeshi\\fanli\\mapping\\push\\DeviceActiveMapper.xml"); } } fanli/src/test/java/org/fanli/TaoKeTest.java
@@ -22,15 +22,16 @@ import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.entity.taobao.TaoBaoLink; import com.yeshi.fanli.entity.taobao.TaoBaoOrder; import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult; import com.yeshi.fanli.entity.taobao.TaoKeAppInfo; import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.goods.ShareGoodsService; import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService; import com.yeshi.fanli.service.inter.taobao.TaoBaoBuyRelationMapService; import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService; import com.yeshi.fanli.service.inter.user.TBPidService; import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService; import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService; import com.yeshi.fanli.util.BeanUtil; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TaoBaoConstant; @@ -47,15 +48,8 @@ @Test public void test1() { try { TaoKeAppInfo app = new TaoKeAppInfo("27867727", "781fce83545edbed13af32dc3fa9fc3a", "mm_124933865_865950258_109407350204"); app.setAdzoneId("109407350204"); TaoBaoGoodsBrief goods = TaoKeApiUtil.searchGoodsDetail(596441448615L, app); System.out.println(goods); } catch (TaobaoGoodsDownException e) { e.printStackTrace(); } TaoBaoSearchResult result = TaoKeApiUtil.getMaterialByMaterialId(19450, 1, 100); System.out.println(result); } @Test @@ -75,7 +69,6 @@ System.out.println(goods); // goods = TaoKeApiUtil.searchGoodsDetail(auctionId); } @Test utils/.classpath
@@ -19,10 +19,6 @@ <attribute name="org.eclipse.jst.component.nondependency" value=""/> </attributes> </classpathentry> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> <attributes> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_181"/> <classpathentry kind="output" path="target/classes"/> </classpath> utils/src/main/java/org/yeshi/utils/HttpUtil.java
@@ -59,13 +59,13 @@ } public static String getShortLink(String url) { return url; // String shortLink = getShortLink3(url); // if (StringUtil.isNullOrEmpty(shortLink)) // shortLink = getShortLink1(url); // if (StringUtil.isNullOrEmpty(shortLink)) // shortLink = getShortLink2(url); // return shortLink; // return url; String shortLink = getShortLink3(url); if (StringUtil.isNullOrEmpty(shortLink)) shortLink = getShortLink1(url); if (StringUtil.isNullOrEmpty(shortLink)) shortLink = getShortLink2(url); return shortLink; } private static String getShortLink1(String url) { @@ -101,8 +101,7 @@ private static String getShortLink3(String url) { try { String totalUrl = String.format( "http://h5.flq001.com/short/createShort?url=%s", String totalUrl = String.format("http://h5.flq001.com/short/createShort?url=%s", URLEncoder.encode(url, "UTF-8")); String result = get(totalUrl, null); JSONObject data = JSONObject.fromObject(result);