fanli/.classpath
@@ -24,7 +24,7 @@ <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="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/client/v2/BrandControllerV2.java
@@ -405,7 +405,7 @@ JSONObject data = new JSONObject(); if (page == 1) { // 2、顶部轮播图 List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCard("index_top"); List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCard("brand_picture"); if (oldtopPicList != null && oldtopPicList.size() > 0) topPicList.addAll(oldtopPicList); TaoBaoShop taoBaoShop = taoBaoShopService.selectByPrimaryKey(id); @@ -709,7 +709,7 @@ if (page == 1 && array.size() > 0) { // 2、顶部轮播图 List<SwiperPicture> topPicList = new ArrayList<>(); List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCard("index_top"); List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCard("brand_picture"); if (oldtopPicList != null && oldtopPicList.size() > 0) topPicList.addAll(oldtopPicList); fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java
@@ -7,6 +7,7 @@ import javax.annotation.Resource; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -26,6 +27,7 @@ import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture; import com.yeshi.fanli.entity.jd.JDGoods; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult; import com.yeshi.fanli.service.inter.goods.CommonTemplateContentService; import com.yeshi.fanli.service.inter.goods.JDCommonTemplateContentService; import com.yeshi.fanli.service.inter.goods.PDDCommonTemplateContentService; @@ -36,6 +38,7 @@ import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; 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; @@ -136,15 +139,23 @@ } private void getListTB(AcceptData acceptData, String key, Integer page, String cid, PrintWriter out) { CommonContentResult result = commonTemplateContentService.getContentList(CommonContentTypeEnum.valueOf(key), cid, page, Constant.PAGE_SIZE); // 保留暂时不开启,待后续开启 List<SwiperPicture> bannerList = new ArrayList<>(); CommonContentResult result = null; CommonContentTypeEnum type = CommonContentTypeEnum.valueOf(key); if (type == CommonContentTypeEnum.guessLikeDevice) { // 猜你喜欢 String idfa = acceptData.getIdfa(); String imei = acceptData.getImei(); result = guessLikeDeviceTB(idfa, imei, page); } else { result = commonTemplateContentService.getContentList(type, cid, page, Constant.PAGE_SIZE); } JSONObject root = new JSONObject(); if (page == 1) if (page == 1) { // 保留暂时不开启,待后续开启 List<SwiperPicture> bannerList = new ArrayList<>(); root.put("bannerList", new Gson().toJson(bannerList)); } JSONArray array = new JSONArray(); Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); @@ -154,7 +165,7 @@ for (TaoBaoGoodsBrief taoBaoGoodsBrief : goodsList) { GoodsDetailVO vo = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate, shareRate); if (CommonContentTypeEnum.valueOf(key) == CommonContentTypeEnum.mianDan)// 免单商品 if (type == CommonContentTypeEnum.mianDan)// 免单商品 { vo.getMoneyInfo().setFanliMoney("¥" + TaoBaoUtil.getAfterUseCouplePrice(taoBaoGoodsBrief)); vo.getMoneyInfo().setShareMoney("¥" + TaoBaoUtil.getAfterUseCouplePrice(taoBaoGoodsBrief)); @@ -260,4 +271,24 @@ out.print(JsonUtil.loadTrueResult(data)); } /** * 猜你喜欢-淘宝设备推荐 * @param acceptData * @param page * @return */ @Cacheable(value = "commonContentCache", key = "#idfa+'-'+#imei+'-'+#page") private CommonContentResult guessLikeDeviceTB(String idfa, String imei, Integer page) { TaoBaoSearchResult searchResult = TaoKeApiUtil.guessDeviceLike(page, Constant.PAGE_SIZE, imei, idfa); if (searchResult != null && searchResult.getTaoBaoGoodsBriefs() != null && searchResult.getTaoBaoGoodsBriefs().size() > 0) { CommonContentResult result = new CommonContentResult(); result.setCount(searchResult.getPageEntity().getTotalCount()); result.setGoodsList(searchResult.getTaoBaoGoodsBriefs()); return result; } return null; } } fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java
@@ -181,7 +181,6 @@ } JSONObject root = new JSONObject(); root.put("type", 2); JSONObject data = new JSONObject(); data.put("title", text); @@ -253,8 +252,15 @@ String pddId = PinDuoDuoUtil.getPDDGoodsId(text); if (!StringUtil.isNullOrEmpty(pddId)) { PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(pddId)); if (goods != null) if (goods != null) { commonGoods = CommonGoodsFactory.create(goods); } else { type = 4; goods = PinDuoDuoUtil.getPDDGoodsInfo("26478646158"); commonGoods = new CommonGoods(); commonGoods.setTitle(goods.getGoodsName()); commonGoods.setPicture(goods.getGoodsThumbnailUrl()); } } } } fanli/src/main/java/com/yeshi/fanli/dto/common/CommonContentTypeEnum.java
@@ -4,7 +4,8 @@ _9k9("9.9包邮"), haoQuan("高额好券"), chaoSheng("超级省钱"), muYin("母婴精选"), reMai("潮品热卖"), meiShi("优选美食"), juJia( "居家生活"), chuanYiDaPei("穿衣搭配"), meiZhuangGehu("美妆个护"), jingPinXieBao("精品鞋包"), chaoNanReMai( "潮男热卖"), shuMaShouJi("数码手机"), yunDongKuXie("运动酷鞋"), qiCheHuWai("汽车户外"), chaoPinReMai("新款潮品"),mianDan("免单商品"); "潮男热卖"), shuMaShouJi("数码手机"), yunDongKuXie("运动酷鞋"), qiCheHuWai("汽车户外"), chaoPinReMai("新款潮品"),mianDan("免单商品") ,guessLikeDevice("猜你喜欢"); private final String desc; private CommonContentTypeEnum(String desc) { fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java
@@ -10,6 +10,7 @@ import javax.annotation.Resource; import org.springframework.cache.annotation.Cacheable; import org.springframework.core.task.TaskExecutor; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import org.yeshi.utils.tencentcloud.COSManager; @@ -68,6 +69,10 @@ @Resource private BrandShopCaheService brandShopCaheService; @Resource(name = "taskExecutor") private TaskExecutor executor; @Override public void saveObject(MultipartFile file, BrandInfo record) throws BrandInfoException { String name = record.getName(); @@ -118,6 +123,17 @@ record.setUpdateTime(new Date()); brandInfoMapper.updateByPrimaryKey(record); } if (state == 1) { executor.execute(new Runnable() { @Override public void run() { int goodsTotal = brandGoodsCaheService.addBrandGoods(record); record.setGoodsTotal(goodsTotal); brandInfoMapper.updateByPrimaryKeySelective(record); } }); } } fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
@@ -176,7 +176,6 @@ // doPlaceOrderIntegralJob();// 下单赠送金币任务 doDouYinDeviceActiveJob();// 抖音设备激活广告监测 } } /** @@ -855,18 +854,18 @@ 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) { if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId()) .compareTo(new BigDecimal("0")) <= 0) { // 补偿金币2级 integralTaskRecordService.firstRebateOrderRewardBossSuper(boss.getId(), order.getUserInfo().getId(), null); } } } } PlaceOrderCMQManager.getInstance().deleteQueueMsg(PlaceOrderCMQManager.QUEUE_INTEGRAL, key); } catch (Exception e) { fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoUtil.java
@@ -525,5 +525,58 @@ } return null; } public static PDDGoodsDetail getPDDGoodsInfo(String id) { try { Document doc = Jsoup.connect("http://yangkeduo.com/goods.html?goods_id=" + id) .userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36").get(); Elements els = doc.getElementsByTag("script"); for (int i = 0; i < els.size(); i++) { if (els.get(i).html().contains("window.rawData")) { String dataJS = els.get(i).html().replace("window.", "var "); dataJS += "function getData(){return JSON.stringify(rawData);}"; ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("javascript"); try { engine.eval(dataJS); if (engine instanceof Invocable) { Invocable in = (Invocable) engine; String jsonStr = in.invokeFunction("getData").toString(); JSONObject json = JSONObject.fromObject(jsonStr); JSONObject goods = json.optJSONObject("store").optJSONObject("initDataObj") .optJSONObject("goods"); String imageData = goods.optString("viewImageData"); imageData = imageData.replace("[", "").replace("]", ""); String[] images = imageData.split(","); String image = images[0].trim(); if (image.startsWith("\"")) image =image.substring(1, image.length()-1); if (image.endsWith("\"")) image =image.substring(0, image.length()-2); PDDGoodsDetail goodsDetail = new PDDGoodsDetail(); goodsDetail.setGoodsImageUrl("http:" + image); goodsDetail.setGoodsThumbnailUrl("http:" + image); goodsDetail.setGoodsName(goods.optString("goodsName")); goodsDetail.setGoodsId(goods.optLong("goodsID")); return goodsDetail; } } catch (Exception e) { e.printStackTrace(); } break; } } } catch (Exception e1) { e1.printStackTrace(); } return 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
@@ -2,7 +2,6 @@ import org.junit.Test; import org.yeshi.utils.mybatis.ColumnParseUtil; import org.yeshi.utils.mybatis.MyBatisMapperUtil; import com.yeshi.fanli.entity.push.DeviceActive; @@ -11,9 +10,6 @@ @Test public void test3() { // MyBatisMapperUtil.createMapper(JDOrder.class); MyBatisMapperUtil.createMapper(ShortUrl.class); // MyBatisMapperUtil.createMapper(UserMoneyDebtReturnHistory.class); } @Test fanli/src/test/java/org/fanli/TaoKeTest.java
@@ -48,7 +48,7 @@ @Test public void test1() { TaoBaoSearchResult result = TaoKeApiUtil.getMaterialByMaterialId(19450, 1, 100); TaoBaoSearchResult result = TaoKeApiUtil.getMaterialByMaterialId(16432, 1, 100); System.out.println(result); }