fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserOrderController.java
@@ -403,7 +403,6 @@ } } } } /* 总订单统计 */ fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ConsumerControllerV2.java
@@ -230,7 +230,7 @@ String[] idStr = ids.split(","); for (String id : idStr) { scanHistoryV2Service.deleteByAuctionIdAndDeviceOrUid(uid, acceptData.getDevice(), Long.parseLong(id)); scanHistoryV2Service.deleteByCommonIdAndDeviceOrUid(uid, acceptData.getDevice(), Long.parseLong(id)); } } out.print(JsonUtil.loadTrueResult("")); @@ -296,7 +296,5 @@ out.print(JsonUtil.loadTrueResult(data)); return; } } fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -23,6 +23,7 @@ import com.yeshi.fanli.entity.system.BusinessSystem; import com.yeshi.fanli.entity.system.SystemClientParams; import com.yeshi.fanli.entity.taobao.ClientTBPid; import com.yeshi.fanli.entity.taobao.TLJBuyGoods; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.entity.taobao.TaoBaoShop; import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig; @@ -37,6 +38,7 @@ import com.yeshi.fanli.service.inter.goods.ScanHistoryV2Service; import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService; import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService; import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService; import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService; import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService; @@ -54,6 +56,7 @@ import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TaoBaoConstant; import com.yeshi.fanli.util.ThreadUtil; import com.yeshi.fanli.util.TimeUtil; import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil; import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; import com.yeshi.fanli.util.factory.goods.ShopInfoVOFactory; @@ -68,6 +71,7 @@ import com.yeshi.fanli.vo.goods.OtherInfo; import com.yeshi.fanli.vo.goods.ShareInfoVO; import com.yeshi.fanli.vo.msg.ClientTextStyleVO; import com.yeshi.fanli.vo.tlj.ReduceHongBao; import com.yeshi.fanli.vo.tlj.SpreadHongBao; import net.sf.json.JSONObject; @@ -139,6 +143,10 @@ @Resource private ScanHistoryV2Service scanHistoryV2Service; @Resource private TLJBuyGoodsService tljBuyGoodsService; /** * 获取商品详情 * @@ -174,10 +182,10 @@ return; } } /** * 淘宝商品详情 * * @param acceptData * @param id * @param uid @@ -185,7 +193,11 @@ * @param out */ public void getTaoBaoGoodsDetial(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) { // 系统验证 if (id == null) { out.print(JsonUtil.loadFalseResult(1, "请上传id")); return; } BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages()); if (system == null) { @@ -193,19 +205,35 @@ return; } // 获取淘客参数 GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO(); extraVO.setIsNative(false); // IOS是否正在上线 if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { String version = acceptData.getVersion(); extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version))); } long startTime = java.lang.System.currentTimeMillis(); // 获取淘客参数 ClientTBPid clientTBPid = null; // 用户未登录 if (acceptData.getPlatform().equalsIgnoreCase("android")) { clientTBPid = tbPidService.getAndroidDefault(); } else { clientTBPid = tbPidService.getIOSDefault(); } LogHelper.test("获取PID耗时:" + (java.lang.System.currentTimeMillis() - startTime)); TaoBaoGoodsBrief goods = null; final List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); // 是否在服务端进行转链 boolean convertInServer = configService.isConvertTaoBaoLinkInServer(); TaoBaoGoodsBrief goods = null; if (!convertInServer) { try { goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(id); @@ -216,7 +244,6 @@ app.setPid(TaoBaoConstant.TAOBAO_COMMON_PID); app.setAdzoneId(TaoBaoConstant.TAOBAO_COMMON_PID.split("_")[3]); goods = TaoKeApiUtil.searchGoodsDetail(id, app); final TaoBaoGoodsBrief finalGoods = goods; if (goods != null) { ThreadUtil.run(new Runnable() { @@ -234,10 +261,11 @@ taoBaoGoodsUpdateService.offlineTaoBaoGoods(id); } }); } } else { String clientPid = clientTBPid.getPid(); final String clientPid = clientTBPid.getPid(); String appId = clientPid.split("_")[2]; TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(appId); TaoKeAppInfo app = new TaoKeAppInfo(); @@ -269,41 +297,44 @@ } if (goods == null) { if (goods != null) { goodsList.add(goods); final TaoBaoGoodsBrief newGoods = goods; ThreadUtil.run(new Runnable() { public void run() { try { // 更新商品 LogHelper.test("更新商品详情:" + newGoods.getAuctionId()); taoBaoGoodsUpdateService.updateTaoBaoGoods(newGoods); } catch (TaobaoGoodsUpdateException e) { } } }); } TaoBaoGoodsBrief tb = null; if (goodsList.size() > 0) { tb = goodsList.get(0); } if (tb == null) { out.print(JsonUtil.loadFalseResult(2, "商品不存在")); return; } goods.setState(0); final TaoBaoGoodsBrief newGoods = goods; ThreadUtil.run(new Runnable() { public void run() { try { LogHelper.test("更新商品详情:" + newGoods.getAuctionId()); taoBaoGoodsUpdateService.updateTaoBaoGoods(newGoods); } catch (TaobaoGoodsUpdateException e) { } } }); // 替换白底图 if (!StringUtil.isNullOrEmpty(goods.getPictUrlWhite())) { goods.setPictUrl(goods.getPictUrlWhite()); if (tb.getImgList() == null) { tb.setImgList(new ArrayList<>()); } // 图片;列表处理 List<String> imgList = goods.getImgList(); if (imgList == null) { goods.setImgList(new ArrayList<>()); } imgList.add(0, goods.getPictUrl()); tb.getImgList().add(0, tb.getPictUrl()); // 图片大小限制 List<String> finalImgList = new ArrayList<>(); for (String img : imgList) { for (String img : tb.getImgList()) { finalImgList.add(TbImgUtil.getTBSizeImg(img, 600)); } if (!StringUtil.isNullOrEmpty(tb.getPictUrlWhite())) finalImgList.add(0, tb.getPictUrlWhite()); // 大淘客商品过滤 try { @@ -311,31 +342,24 @@ } catch (Exception e) { LogHelper.errorDetailInfo(e); } BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertTaoBao(newGoods, null, fanLiRate, shareRate); GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertTaoBao(tb, null, fanLiRate, shareRate); // 店铺信息 TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(goods.getAuctionId(), goods.getSellerId()); if (shop != null) { String shopLink = shop.getShopLink(); if (StringUtil.isNullOrEmpty(shopLink)) { shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId())); } goodsDetail.setShopInfo(ShopInfoVOFactory.convertTaoBaoShop(shop)); } // 券信息 // 有券处理 if (goodsDetail.isHasCoupon()) { // CouponInfoVO coupon = goodsDetail.getCouponInfo(); // String token = ""; // if (!StringUtil.isNullOrEmpty(goods.getCouponLink())) { // token = redisManager.getCommonTaoToken(id); // if (StringUtil.isNullOrEmpty(token)) { // token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), goods.getCouponLink()); // redisManager.saveCommonTaoToken(goods.getAuctionId(), token); // } // } // coupon.setToken(token); // goodsInfo.setCouponInfo(coupon); if (!StringUtil.isNullOrEmpty(from)) { if ("miandan".equals(from)) { // 免单商品 MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo(); @@ -344,12 +368,197 @@ } } } extraVO.setTbPidInfo(clientTBPid); extraVO.setDetailUrl("http://apph5.yeshitv.com/apppage/goods_img.html?id=" + id); // 分享赚人提示 MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo(); List<ShamUser> listShareUser = new ArrayList<ShamUser>(); if (moneyInfo != null) { String shareMoney = moneyInfo.getShareMoney(); if (goods.getBiz30day() >= 1000) { listShareUser = shamUserService.listRandShareUser(10, new BigDecimal(shareMoney.replaceAll("¥", "")), 1, 5); } } extraVO.setListShareUser(listShareUser); // 领券人列表 List<ShamUser> listCouponUser = new ArrayList<ShamUser>(); if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && goods.getCouponAmount() != null && goods.getCouponAmount().compareTo(new BigDecimal(0)) > 0) { if (goods.getBiz30day() >= 1000) { listCouponUser = shamUserService.listRandCouponUser(5, 1, 300); } } extraVO.setListCouponUser(listCouponUser); if (uid != null) { // 是否加入收藏 CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id, Constant.SOURCE_TYPE_TAOBAO); extraVO.setCollected(collectionGoods != null ? true : false); // 是否加入选品库 extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_TAOBAO)); } // 测试 SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, "goods_detail_jump_taobao"); if ("1".equalsIgnoreCase((params.getValue() + "").trim())) { extraVO.setIsNative(true); } // 商品链接 String h5Url = String.format("http://%s%s?id=%s&appType=flq", configService.getH5Host(), Constant.systemCommonConfig.getShareGoodsPagePath(), id + ""); try { extraVO.setH5Url(HttpUtil.getShortLink(h5Url)); } catch (Exception e) { extraVO.setH5Url(h5Url); } String helpLink = null; boolean fanliValid = true; boolean shareValid = true; int moneyType = 1; // 推广红包 if (from != null && from.equals("taolijin")) { // 计算推广红包 String warningRate = configTaoLiJinService.getValueByKey("warning_value"); BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods); // 推广红包 不能小于1 if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) { out.print(JsonUtil.loadFalseResult(2, "商品不存在")); return; } // 是否为新用户 boolean isNewUser = userInfoExtraService.isNewUser(uid); if (isNewUser) { // 判定为老用户: 新人只要使用了新人红包,也就是那1块钱,那么,他看到的分享爆款中的商品-就只能分享。 long countRecord = userTaoLiJinRecordService.countRecordByUid(uid); if (countRecord > 0) { isNewUser = false; } } SpreadHongBao spreadHongBao = new SpreadHongBao(); if (isNewUser) { spreadHongBao.setMoney("¥1"); } else { moneyType = 2; fanliValid = false; spreadHongBao.setMoney("¥" + spreadMoney.toString()); ClientTextStyleVO textStyleVO1 = new ClientTextStyleVO(); textStyleVO1.setContent("分享"); textStyleVO1.setColor("#666666"); ClientTextStyleVO textStyleVO2 = new ClientTextStyleVO(); textStyleVO2.setContent("赚奖金"); textStyleVO2.setColor("#F14242"); ClientTextStyleVO textStyleVO3 = new ClientTextStyleVO(); textStyleVO3.setContent(",好友"); textStyleVO3.setColor("#666666"); ClientTextStyleVO textStyleVO4 = new ClientTextStyleVO(); textStyleVO4.setContent("领红包!"); textStyleVO4.setColor("#F14242"); List<ClientTextStyleVO> listText = new ArrayList<ClientTextStyleVO>(); listText.add(textStyleVO1); listText.add(textStyleVO2); listText.add(textStyleVO3); listText.add(textStyleVO4); extraVO.setTip(listText); } spreadHongBao.setName("推广红包 "); spreadHongBao.setTip("当日领取,当日内使用,过期失效"); OtherInfo otherInfo = new OtherInfo(); otherInfo.setSpreadHongBao(spreadHongBao); goodsDetail.setOtherInfo(otherInfo); // 用户淘礼金 UserMoneyExtra userMoneyExtra = userMoneyExtraService.selectByPrimaryKey(uid); if (userMoneyExtra == null || userMoneyExtra.getTlj() == null) { extraVO.setUserTLJ(new BigDecimal(0).setScale(2).toString()); } else { extraVO.setUserTLJ(userMoneyExtra.getTlj().setScale(2).toString()); } helpLink = configTaoLiJinService.getValueByKey("share_goods_help_link"); } else if (from != null && from.equals("taolijin_buy")) { // 查询分享库 TLJBuyGoods buyGoods = tljBuyGoodsService.selectByAuctionIdAndDay(id, TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd")); if (buyGoods == null) { out.print(JsonUtil.loadFalseResult(2, "自购立减红包过期")); return; } moneyType = 2; fanliValid = true; shareValid = false; helpLink = configService.get("zigoulijian_nofanli_help"); String tljHongBao = TaoBaoUtil.getGoodsHongBaoMoney(goods, new BigDecimal(70)).toString(); ReduceHongBao reduceHongBao = new ReduceHongBao(); reduceHongBao.setLeft(buyGoods.getLeftHongBaoCount()); reduceHongBao.setMoney(tljHongBao); reduceHongBao.setName("付款立减 ¥" + tljHongBao); reduceHongBao.setTip("当日领取,当日内使用,过期失效"); reduceHongBao.setTotal(buyGoods.getTotalHongBaoCount()); OtherInfo otherInfo = new OtherInfo(); otherInfo.setReduceHongBao(reduceHongBao); goodsDetail.setOtherInfo(otherInfo); } extraVO.setFanliValid(fanliValid); extraVO.setShareValid(shareValid); MoneyInfoVO goodsMoney = goodsDetail.getMoneyInfo(); if (goodsMoney != null) { goodsMoney.setMoneyType(moneyType); } // 分享路径 if (StringUtil.isNullOrEmpty(helpLink)) { helpLink = configService.get("no_rebate_help_link"); } // 分享路径 String shareUrl = String.format("%s?id=" + id, Constant.systemCommonConfig.getAppShareInfoUrl()); ShareInfoVO shareInfoVO = new ShareInfoVO(); shareInfoVO.setUrl(shareUrl); shareInfoVO.setHelpLink(helpLink); extraVO.setShareInfo(shareInfoVO); JSONObject object = new JSONObject(); object.put("code", 0); object.put("data", JsonUtil.getApiCommonGson().toJson(goodsDetail)); out.print(object.toString()); object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO)); object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail)); out.print(JsonUtil.loadTrueResult(object.toString())); final TaoBaoGoodsBrief goodsInfo = tb; ThreadUtil.run(new Runnable() { public void run() { // 添加浏览记录 try { scanHistoryV2Service.addScanHistory(uid, acceptData.getDevice(), goodsInfo); } catch (Exception e) { e.printStackTrace(); } } }); } /** * 京东商品详情 @@ -383,382 +592,14 @@ BigDecimal shareRate = hongBaoManageService.getShareRate(); GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, null, fanLiRate, shareRate); JSONObject object = new JSONObject(); object.put("code", 0); object.put("data", JsonUtil.getApiCommonGson().toJson(goodsDetail)); out.print(object.toString()); } /** * 京东商品详情 * * @param acceptData * @param id * @param uid * @param from * @param out */ public void getPDDGoodsDetial(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) { // 系统验证 BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages()); if (system == null) { out.print(JsonUtil.loadFalseResult(1, "系统不存在")); return; } PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id); if (pddGoods == null) { out.print(JsonUtil.loadFalseResult(2, "商品不存在")); return; } BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, null, fanLiRate, shareRate); JSONObject object = new JSONObject(); object.put("code", 0); object.put("data", JsonUtil.getApiCommonGson().toJson(goodsDetail)); out.print(object.toString()); } /** * 获取商品详情 * * @param acceptData * @param id * @param source * @param uid * @param from * @param out */ @RequestMapping(value = "getExtraDetail", method = RequestMethod.POST) public void getExtraDetail(AcceptData acceptData, Long id, Integer goodsType, Long uid, String from, PrintWriter out) { if (id == null || goodsType == null) { out.print(JsonUtil.loadFalseResult(1, "商品id和商品平台不能为空")); return; } // 淘宝商品 if (Constant.SOURCE_TYPE_TAOBAO == goodsType) { getTaoBaoExtraDetial(acceptData, id, uid, from, out); return; } // 京东商品 if (Constant.SOURCE_TYPE_JD == goodsType) { getJDExtraDetial(acceptData, id, uid, from, out); return; } // 拼多多商品 if (Constant.SOURCE_TYPE_PDD == goodsType) { getPDDExtraDetial(acceptData, id, uid, from, out); return; } } /** * 淘宝商品额外配置信息 * * @param acceptData * @param id * @param uid * @param from * @param out */ public void getTaoBaoExtraDetial(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) { BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages()); if (system == null) { out.print(JsonUtil.loadFalseResult(1, "系统不存在")); return; } GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO(); extraVO.setIsNative(false); // IOS是否正在上线 if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { String version = acceptData.getVersion(); extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version))); } long startTime = java.lang.System.currentTimeMillis(); // 获取淘客参数 ClientTBPid clientTBPid = null; // 用户未登录 if (acceptData.getPlatform().equalsIgnoreCase("android")) { clientTBPid = tbPidService.getAndroidDefault(); } else { clientTBPid = tbPidService.getIOSDefault(); } extraVO.setTbPidInfo(clientTBPid); LogHelper.test("获取PID耗时:" + (java.lang.System.currentTimeMillis() - startTime)); List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); TaoBaoGoodsBrief goods = null; try { goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(id); if (goods == null) { TaoKeAppInfo app = new TaoKeAppInfo(); app.setAppKey(TaoBaoConstant.TAOBAO_COMMON_APPKEY); app.setAppSecret(TaoBaoConstant.TAOBAO_COMMON_APPSECRET); app.setPid(TaoBaoConstant.TAOBAO_COMMON_PID); app.setAdzoneId(TaoBaoConstant.TAOBAO_COMMON_PID.split("_")[3]); goods = TaoKeApiUtil.searchGoodsDetail(id, app); final TaoBaoGoodsBrief finalGoods = goods; if (goods != null) { ThreadUtil.run(new Runnable() { @Override public void run() { taoBaoGoodsCacheUtil.saveCommonTaoBaoGoodsInfo(finalGoods); } }); } } } catch (TaobaoGoodsDownException e) { // 商品下架 ThreadUtil.run(new Runnable() { public void run() { taoBaoGoodsUpdateService.offlineTaoBaoGoods(id); } }); } if (goods != null) { goodsList.add(goods); final TaoBaoGoodsBrief newGoods = goods; ThreadUtil.run(new Runnable() { public void run() { try { // 更新商品 LogHelper.test("更新商品详情:" + newGoods.getAuctionId()); taoBaoGoodsUpdateService.updateTaoBaoGoods(newGoods); } catch (TaobaoGoodsUpdateException e) { } } }); } TaoBaoGoodsBrief tb = null; if (goodsList.size() > 0) { tb = goodsList.get(0); } if (tb == null) { out.print(JsonUtil.loadFalseResult(2, "商品不存在")); return; } // 大淘客商品过滤 try { goods = daTaoKeGoodsDetailService.filterTaoBaoGoods(goods); } catch (Exception e) { LogHelper.errorDetailInfo(e); } extraVO.setDetailUrl("http://apph5.yeshitv.com/apppage/goods_img.html?id=" + id); // 店铺信息 TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(goods.getAuctionId(), goods.getSellerId()); if (shop != null) { String shopLink = shop.getShopLink(); if (StringUtil.isNullOrEmpty(shopLink)) { shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId())); } extraVO.setShopInfo(ShopInfoVOFactory.convertTaoBaoShop(shop)); } BigDecimal shareMoney = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb); // 分享赚人提示 List<ShamUser> listShareUser = new ArrayList<ShamUser>(); if (tb.getBiz30day() >= 1000) { listShareUser = shamUserService.listRandShareUser(10, shareMoney, 1, 5); } extraVO.setListShareUser(listShareUser); // 领券人列表 List<ShamUser> listCouponUser = new ArrayList<ShamUser>(); if (!StringUtil.isNullOrEmpty(tb.getCouponInfo()) && tb.getCouponAmount() != null && tb.getCouponAmount().compareTo(new BigDecimal(0)) > 0) { if (tb.getBiz30day() >= 1000) { listCouponUser = shamUserService.listRandCouponUser(5, 1, 300); } } extraVO.setListCouponUser(listCouponUser); if (uid != null) { // 是否加入收藏 CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id, Constant.SOURCE_TYPE_TAOBAO); extraVO.setCollected(collectionGoods != null ? true : false); // 是否加入选品库 extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_TAOBAO)); } // 测试 SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, "goods_detail_jump_taobao"); if ("1".equalsIgnoreCase((params.getValue() + "").trim())) { extraVO.setNative(true); } // 商品链接 String h5Url = String.format("http://%s%s?id=%s&appType=flq", configService.getH5Host(), Constant.systemCommonConfig.getShareGoodsPagePath(), tb.getAuctionId() + ""); try { extraVO.setH5Url(HttpUtil.getShortLink(h5Url)); } catch (Exception e) { extraVO.setH5Url(h5Url); } String helpLink = null; // 是否有返利 boolean fanliValid = true; /* 推广红包 */ if (from != null && from.equals("taolijin")) { // 计算推广红包 String warningRate = configTaoLiJinService.getValueByKey("warning_value"); BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods); // 推广红包 不能小于1 if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) { out.print(JsonUtil.loadFalseResult(2, "商品不存在")); return; } // 是否为新用户 boolean isNewUser = userInfoExtraService.isNewUser(uid); if (isNewUser) { // 判定为老用户: 新人只要使用了新人红包,也就是那1块钱,那么,他看到的分享爆款中的商品-就只能分享。 long countRecord = userTaoLiJinRecordService.countRecordByUid(uid); if (countRecord > 0) { isNewUser = false; } } if (!isNewUser) { fanliValid = false; ClientTextStyleVO textStyleVO1 = new ClientTextStyleVO(); textStyleVO1.setContent("分享"); textStyleVO1.setColor("#666666"); ClientTextStyleVO textStyleVO2 = new ClientTextStyleVO(); textStyleVO2.setContent("赚奖金"); textStyleVO2.setColor("#F14242"); ClientTextStyleVO textStyleVO3 = new ClientTextStyleVO(); textStyleVO3.setContent(",好友"); textStyleVO3.setColor("#666666"); ClientTextStyleVO textStyleVO4 = new ClientTextStyleVO(); textStyleVO4.setContent("领红包!"); textStyleVO4.setColor("#F14242"); List<ClientTextStyleVO> listText = new ArrayList<ClientTextStyleVO>(); listText.add(textStyleVO1); listText.add(textStyleVO2); listText.add(textStyleVO3); listText.add(textStyleVO4); extraVO.setTip(listText); } SpreadHongBao spreadHongBao = new SpreadHongBao(); if (isNewUser) { spreadHongBao.setMoney("¥1"); } else { spreadHongBao.setMoney("¥" + spreadMoney.toString()); } spreadHongBao.setName("推广红包 "); spreadHongBao.setTip("当日领取,当日内使用,过期失效"); OtherInfo otherInfo = new OtherInfo(); otherInfo.setSpreadHongBao(spreadHongBao); extraVO.setOtherInfo(otherInfo); // 用户淘礼金 UserMoneyExtra userMoneyExtra = userMoneyExtraService.selectByPrimaryKey(uid); if (userMoneyExtra == null || userMoneyExtra.getTlj() == null) { extraVO.setUserTLJ(new BigDecimal(0).setScale(2).toString()); } else { extraVO.setUserTLJ(userMoneyExtra.getTlj().setScale(2).toString()); } helpLink = configTaoLiJinService.getValueByKey("share_goods_help_link"); } extraVO.setFanliValid(fanliValid); extraVO.setShareValid(true); if (StringUtil.isNullOrEmpty(helpLink)) { helpLink = configService.get("no_rebate_help_link"); } // 分享路径 String shareUrl = String.format("%s?id=" + tb.getAuctionId(), Constant.systemCommonConfig.getAppShareInfoUrl()); ShareInfoVO shareInfoVO = new ShareInfoVO(); shareInfoVO.setUrl(shareUrl); shareInfoVO.setHelpLink(helpLink); extraVO.setShareInfo(shareInfoVO); JSONObject object = new JSONObject(); object.put("code", 0); object.put("data", JsonUtil.getApiCommonGson().toJson(extraVO)); out.print(object.toString()); final TaoBaoGoodsBrief goodsInfo = tb; ThreadUtil.run(new Runnable() { public void run() { // 添加浏览记录 try { scanHistoryV2Service.addScanHistory(uid, acceptData.getDevice(), goodsInfo); } catch (Exception e) { e.printStackTrace(); } } }); } /** * 京东商品额外配置信息 * * @param acceptData * @param id * @param uid * @param from * @param out */ public void getJDExtraDetial(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) { BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages()); if (system == null) { out.print(JsonUtil.loadFalseResult(1, "系统不存在")); return; } GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO(); // IOS是否正在上线 if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { String version = acceptData.getVersion(); extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version))); } JDGoods jdGoods = JDApiUtil.queryGoodsDetail(id); if (jdGoods == null) { jdGoods = JDApiUtil.getGoodsDetail(id); } if (jdGoods == null) { out.print(JsonUtil.loadFalseResult(2, "商品不存在")); return; } BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, null, fanLiRate, shareRate); Long inOrderCount30Days = jdGoods.getInOrderCount30Days(); List<ShamUser> listShareUser = new ArrayList<ShamUser>(); @@ -801,7 +642,7 @@ SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, "goods_detail_jump_taobao"); if ("1".equalsIgnoreCase((params.getValue() + "").trim())) { extraVO.setNative(true); extraVO.setIsNative(true); } // 商品链接 @@ -829,9 +670,9 @@ extraVO.setShareInfo(shareInfoVO); JSONObject object = new JSONObject(); object.put("code", 0); object.put("data", JsonUtil.getApiCommonGson().toJson(extraVO)); out.print(object.toString()); object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO)); object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail)); out.print(JsonUtil.loadTrueResult(object.toString())); final JDGoods goods = jdGoods; ThreadUtil.run(new Runnable() { @@ -839,7 +680,6 @@ // 添加浏览记录 try { scanHistoryV2Service.addJDScanHistory(uid, acceptData.getDevice(), goods); ; } catch (Exception e) { e.printStackTrace(); } @@ -848,7 +688,7 @@ } /** * 京东商品额外配置信息 * 京东商品详情 * * @param acceptData * @param id @@ -856,19 +696,13 @@ * @param from * @param out */ public void getPDDExtraDetial(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) { public void getPDDGoodsDetial(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) { // 系统验证 BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages()); if (system == null) { out.print(JsonUtil.loadFalseResult(1, "系统不存在")); return; } GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO(); // IOS是否正在上线 if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { String version = acceptData.getVersion(); extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version))); } PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id); @@ -881,8 +715,14 @@ BigDecimal shareRate = hongBaoManageService.getShareRate(); GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, null, fanLiRate, shareRate); //店铺信息 extraVO.setShopInfo(ShopInfoVOFactory.convertPDDShop(pddGoods)); GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO(); extraVO.setIsNative(false); // IOS是否正在上线 if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { String version = acceptData.getVersion(); extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version))); } Long inOrderCount30Days = pddGoods.getSoldQuantity(); List<ShamUser> listShareUser = new ArrayList<ShamUser>(); @@ -915,7 +755,7 @@ SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, "goods_detail_jump_taobao"); if ("1".equalsIgnoreCase((params.getValue() + "").trim())) { extraVO.setNative(true); extraVO.setIsNative(true); } // 商品链接 @@ -942,20 +782,20 @@ extraVO.setShareInfo(shareInfoVO); JSONObject object = new JSONObject(); object.put("code", 0); object.put("data", JsonUtil.getApiCommonGson().toJson(extraVO)); out.print(object.toString()); object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO)); object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail)); out.print(JsonUtil.loadTrueResult(object.toString())); ThreadUtil.run(new Runnable() { public void run() { // 添加浏览记录 try { scanHistoryV2Service.addPDDScanHistory(uid, acceptData.getDevice(), pddGoods); ; } catch (Exception e) { e.printStackTrace(); } } }); } } fanli/src/main/java/com/yeshi/fanli/controller/client/v2/HotSellControllerV2.java
@@ -12,14 +12,17 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.yeshi.utils.JsonUtil; import com.yeshi.fanli.dto.dataoke.DaTaoKeGoodsResult; import com.yeshi.fanli.entity.accept.AcceptData; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra; import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.common.JumpDetailV2Service; import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService; import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService; import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsService; import com.yeshi.fanli.util.dataoke.DaTaoKeApiUtil; import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; import com.yeshi.fanli.util.taobao.TaoBaoUtil; import com.yeshi.fanli.vo.goods.GoodsDetailVO; @@ -49,6 +52,8 @@ private DaTaoKeGoodsService daTaoKeGoodsService; /** * 获取动态列表 * @@ -67,13 +72,20 @@ if (subId != null && subId == 0) subId = null; List<DaTaoKeDetail> detailList = null; List<DaTaoKeDetailV2> detailList = null; if (cid == 1) { detailList = daTaoKeGoodsService.getCurrentHotSalesRankGoodsList(); DaTaoKeGoodsResult result = DaTaoKeApiUtil.getRankingList(DaTaoKeApiUtil.RANK_TYPE_HOT, null); if (result != null) detailList = result.getGoodsList(); } else if (cid == 2) { detailList = daTaoKeGoodsService.getCurrentSalesRankGoodsList(subId); DaTaoKeGoodsResult result = DaTaoKeApiUtil.getRankingList(DaTaoKeApiUtil.RANK_TYPE_TIME, subId); if (result != null) detailList = result.getGoodsList(); } else { detailList = daTaoKeGoodsService.getCurrentDaySalesRankGoodsList(subId); DaTaoKeGoodsResult result = DaTaoKeApiUtil.getRankingList(DaTaoKeApiUtil.RANK_TYPE_DAY, subId); if (result != null) detailList = result.getGoodsList(); } if (detailList == null) @@ -84,9 +96,9 @@ List<GoodsDetailVO> list = new ArrayList<GoodsDetailVO>(); if (detailList != null) { BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); for (DaTaoKeDetail detail : detailList) { for (DaTaoKeDetailV2 detail : detailList) { TaoBaoGoodsBrief taoBaoGoodsBrief = TaoBaoUtil.convert(detail); GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate, shareRate); if (cid == 2) @@ -98,7 +110,6 @@ list.add(detailVO); } } LogHelper.test("最终商品数据:" + list.size()); JSONObject data = new JSONObject(); data.put("count", detailList.size()); fanli/src/main/java/com/yeshi/fanli/controller/client/v2/JingDongControllerV2.java
@@ -91,7 +91,7 @@ public void getGoodsInfo(AcceptData acceptData, Integer cid, Integer page, PrintWriter out) { JSONObject root = new JSONObject(); if (cid == 1 && page == 1) { List<SwiperPicture> topPicList = swiperPictureService.getByBannerCard("jd_top"); List<SwiperPicture> topPicList = swiperPictureService.getByBannerCard("jingdong_special_top"); if (topPicList == null) { topPicList = new ArrayList<SwiperPicture>(); } fanli/src/main/java/com/yeshi/fanli/controller/client/v2/PinDuoDuoControllerV2.java
@@ -99,7 +99,7 @@ } root.put("listPic", JsonUtil.getApiCommonGson().toJson(topPicList)); List<Special> listSpecial = specialService.listByPlaceKey("index_block"); List<Special> listSpecial = specialService.listByPlaceKey("pinduoduo_special_top"); if (listSpecial == null) { listSpecial = new ArrayList<Special>(); } fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java
@@ -6,13 +6,18 @@ import java.util.Calendar; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.yeshi.utils.JsonUtil; import org.yeshi.utils.taobao.TbImgUtil; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -20,11 +25,16 @@ import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture; import com.yeshi.fanli.entity.bus.lable.QualityFactory; import com.yeshi.fanli.entity.common.JumpDetailV2; import com.yeshi.fanli.entity.taobao.SearchFilter; import com.yeshi.fanli.entity.taobao.TLJBuyGoods; 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.entity.taobao.dataoke.DaTaoKeDetail; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.common.JumpDetailV2Service; import com.yeshi.fanli.service.inter.config.ConfigService; import com.yeshi.fanli.service.inter.goods.recommend.HomeRecommendGoodsService; import com.yeshi.fanli.service.inter.goods.recommend.RecommendGoodsDeleteHistoryService; import com.yeshi.fanli.service.inter.homemodule.DeviceSexService; import com.yeshi.fanli.service.inter.homemodule.SpecialService; @@ -37,11 +47,17 @@ import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.RedisManager; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TaoBaoConstant; import com.yeshi.fanli.util.Utils; import com.yeshi.fanli.util.VersionUtil; import com.yeshi.fanli.util.factory.MonitorFactory; 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 com.yeshi.fanli.vo.goods.OtherInfo; import com.yeshi.fanli.vo.msg.ClientTextStyleVO; import com.yeshi.fanli.vo.tlj.ReduceHongBao; import net.sf.json.JSONArray; import net.sf.json.JSONObject; @@ -58,6 +74,9 @@ @Resource private RedisManager redisManager; @Resource private HomeRecommendGoodsService homeRecommendGoodsService; @Resource private ConfigService configService; @@ -142,97 +161,6 @@ } } /** * 根据设备信息获取猜你喜欢的内容 * * @param acceptData * @param imei * -Android的IMEI信息 * @param idfa * -IOS的idfa广告标识信息 */ @RequestMapping(value = "guessLikeByDevice") public void guessUserLikeByDevice(AcceptData acceptData, String imei, String idfa, int page, HttpServletRequest request, PrintWriter out) { int pageSize = Constant.PAGE_SIZE; JSONArray array = new JSONArray(); Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); // 从推荐来 if (page <= 1) { array.clear(); BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); if (!StringUtil.isNullOrEmpty(imei) || !StringUtil.isNullOrEmpty(idfa)) { long startTime = java.lang.System.currentTimeMillis(); TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(page, 50, imei, idfa); if (result != null && result.getTaoBaoGoodsBriefs() != null) { // 筛选 List<GoodsDetailVO> goodsList = new ArrayList<GoodsDetailVO>(); List<TaoBaoGoodsBrief> gList = recommendGoodsDeleteHistoryService .filterGoods(acceptData.getDevice(), result.getTaoBaoGoodsBriefs()); // filter try { gList = daTaoKeGoodsDetailService.filterTaoBaoGoods(gList); } catch (Exception e) { } // 设备推荐 if (gList != null) for (TaoBaoGoodsBrief goods : gList) { if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && goods.getCouponAmount() != null && goods.getCouponAmount().compareTo(new BigDecimal("5")) >= 0 && goods.getBiz30day() > 1000 && !StringUtil.isNullOrEmpty(goods.getPictUrlWhite())) { GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(goods, null, fanLiRate, shareRate); detailVO.setRecommend(true); goodsList.add(detailVO); } } try { monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, (int) (java.lang.System.currentTimeMillis() - startTime), "推荐数量:" + goodsList.size())); } catch (Exception e) { e.printStackTrace(); } Collections.shuffle(goodsList); goodsList = goodsList.size() > 20 ? goodsList.subList(0, 20) : goodsList; for (GoodsDetailVO goods : goodsList) { array.add(gson.toJson(goods)); } } else { try { monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, (int) (java.lang.System.currentTimeMillis() - startTime), "无推荐")); } catch (Exception e) { e.printStackTrace(); } } } JSONArray localArray = qualityGoodsService.getRecommendToIndexV2((page - 1) * pageSize, pageSize); array.addAll(localArray); } else {// 从精选库来 array = qualityGoodsService.getRecommendToIndexV2((page - 1) * pageSize, pageSize); if (array == null) { out.print(JsonUtil.loadFalseResult("没有更多了")); return; } } JSONObject data = new JSONObject(); data.put("data", array); data.put("count", 1000); out.print(JsonUtil.loadTrueResult(data)); } /** @@ -286,8 +214,8 @@ nextTime.set(Calendar.MILLISECOND, 0); JSONArray array = null; String timekey = String.format("spikeGoods_hour-%s-%s", acceptData.getPlatform(), acceptData.getVersion()); String cachekey = String.format("spikeGoodsList-%s-%s", acceptData.getPlatform(), acceptData.getVersion()); String timekey = String.format("spikeGoods_hour_new-%s-%s", acceptData.getPlatform(), acceptData.getVersion()); String cachekey = String.format("spikeGoodsList_new-%s-%s", acceptData.getPlatform(), acceptData.getVersion()); String timeValue = redisManager.getCommonString(timekey); if (timeValue == null || !timeValue.equals(hour + "")) { @@ -361,19 +289,341 @@ /** * 京东专题 * 首页底部商品推荐 * @param acceptData * @param out */ @RequestMapping(value = "getJDSpecial") public void getJDSpecial(AcceptData acceptData, PrintWriter out) { JSONObject root = getSpikeGoodsContent(acceptData); @RequestMapping(value = "getGoodList") public void getGoodList(AcceptData acceptData, Integer goodsType, Integer page, HttpServletRequest request, PrintWriter out) { if (goodsType == null || page == null) { out.print(JsonUtil.loadFalseResult("参数信息不正常")); return; } if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { taoBaoGuessUserLikeByDevice(acceptData, page, request, out); return; } if (goodsType == Constant.SOURCE_TYPE_JD) { } if (goodsType == Constant.SOURCE_TYPE_PDD) { } List<QualityFactory> listQuery = qualityGoodsService.listFreeGoods((page - 1) * 20, 20); if (listQuery == null) { listQuery = new ArrayList<QualityFactory>(); } JSONArray array = new JSONArray(); if (listQuery.size() > 0) { Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); for (QualityFactory qualityFactory : listQuery) { TaoBaoGoodsBrief goods = qualityFactory.getTaoBaoGoodsBrief(); if (goods == null) { continue; } array.add(gson.toJson(GoodsDetailVOFactory.convertTaoBao(goods, null, fanLiRate, shareRate))); } } long count = qualityGoodsService.countFreeGoods(); JSONObject root = new JSONObject(); root.put("count", count); root.put("list", array); out.print(JsonUtil.loadTrueResult(root)); } /** * 根据设备信息获取猜你喜欢的内容 * * @param acceptData * @param imei * -Android的IMEI信息 * @param idfa * -IOS的idfa广告标识信息 */ public void taoBaoGuessUserLikeByDevice(AcceptData acceptData, int page, HttpServletRequest request, PrintWriter out) { int pageSize = Constant.PAGE_SIZE; JSONArray array = new JSONArray(); Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); String idfa = acceptData.getIdfa(); String imei = acceptData.getImei(); if (VersionUtil.greaterThan_1_5_70(acceptData.getPlatform(), acceptData.getVersion())) { List<TaoBaoGoodsBrief> goodsList = homeRecommendGoodsService.listGoodsByPage(null, acceptData.getDevice(), imei, idfa, page); BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); for (TaoBaoGoodsBrief goods : goodsList) { GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(goods, null, fanLiRate, shareRate); if (page < 3) detailVO.setRecommend(true); try { array.add(gson.toJson(detailVO)); } catch (Exception e) { e.printStackTrace(); } } if (page == 1) { List<TLJBuyGoods> list = homeRecommendGoodsService.getZiGouLiJianHotGoods(acceptData.getDevice()); if (list != null && list.size() > 0) for (int i = list.size() - 1; i >= 0; i--) { TLJBuyGoods goods = list.get(i); BigDecimal rateBuy = TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE; GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(goods.getGoods(), null, rateBuy, rateBuy); String hongBao = TaoBaoUtil.getGoodsHongBaoInfo(goods.getGoods(),TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE); ReduceHongBao reduceHongBao = new ReduceHongBao(); reduceHongBao.setLeft(goods.getLeftHongBaoCount()); reduceHongBao.setMoney(hongBao); reduceHongBao.setName("付款立减 " + hongBao); reduceHongBao.setTip(""); reduceHongBao.setTotal(goods.getTotalHongBaoCount()); OtherInfo otherInfo = new OtherInfo(); otherInfo.setReduceHongBao(reduceHongBao); detailVO.setOtherInfo(otherInfo); detailVO.setPictureTag(new ClientTextStyleVO("立减TOP" + (i + 1), "#E5005C", "#FCE431", null)); detailVO.setRecommend(true); array.add(0, gson.toJson(detailVO)); } } JSONObject data = new JSONObject(); data.put("list", array); data.put("count", 1000); out.print(JsonUtil.loadTrueResult(data)); return; } // 从推荐来 if (page <= 1) { array.clear(); if (!StringUtil.isNullOrEmpty(imei) || !StringUtil.isNullOrEmpty(idfa)) { long startTime = java.lang.System.currentTimeMillis(); TaoBaoSearchResult result = TaoKeApiUtil.guessDeviceLike(page, 50, imei, idfa); if (result != null && result.getTaoBaoGoodsBriefs() != null) { // 筛选 List<GoodsDetailVO> goodsList = new ArrayList<>(); List<TaoBaoGoodsBrief> gList = recommendGoodsDeleteHistoryService .filterGoods(acceptData.getDevice(), result.getTaoBaoGoodsBriefs()); // filter try { gList = daTaoKeGoodsDetailService.filterTaoBaoGoods(gList); } catch (Exception e) { } // 设备推荐 if (gList != null) { BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); for (TaoBaoGoodsBrief goods : gList) { if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && goods.getCouponAmount() != null && goods.getCouponAmount().compareTo(new BigDecimal("5")) >= 0 && goods.getBiz30day() > 1000 && !StringUtil.isNullOrEmpty(goods.getPictUrlWhite())) { GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(goods, null, fanLiRate, shareRate); detailVO.setRecommend(true); goodsList.add(detailVO); } } } try { monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, (int) (java.lang.System.currentTimeMillis() - startTime), "推荐数量:" + goodsList.size())); } catch (Exception e) { e.printStackTrace(); } Collections.shuffle(goodsList); goodsList = goodsList.size() > 20 ? goodsList.subList(0, 20) : goodsList; for (GoodsDetailVO goods : goodsList) { array.add(gson.toJson(goods)); } } else { try { monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, (int) (java.lang.System.currentTimeMillis() - startTime), "无推荐")); } catch (Exception e) { e.printStackTrace(); } } } JSONArray localArray = qualityGoodsService.getRecommendToIndexV2((page - 1) * pageSize, pageSize); array.addAll(localArray); } else {// 从精选库来 array = qualityGoodsService.getRecommendToIndexV2((page - 1) * pageSize, pageSize); if (array == null) { out.print(JsonUtil.loadFalseResult("没有更多了")); return; } } JSONObject data = new JSONObject(); data.put("list", array); data.put("count", 1000); out.print(JsonUtil.loadTrueResult(data)); } /** * 粘贴板信息推荐 * * @param acceptData * @param url * 商品链接 * @param out */ @RequestMapping(value = "getNewGoodsInfo", method = RequestMethod.POST) public void getNewGoodsInfo(AcceptData acceptData, String text, PrintWriter out) { if (StringUtil.isNullOrEmpty(text)) { out.print(JsonUtil.loadFalseResult("值为空")); return; } if (text.length() > 256) { out.print(JsonUtil.loadFalseResult("值过长")); return; } TaoBaoGoodsBrief tb = null; String URL_REGEX = "(((http|https)://)|(www\\.))[a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6}(:[0-9]{1,4})?(/[a-zA-Z0-9\\&%_\\./-~-]*)?"; Pattern p = Pattern.compile(URL_REGEX); Matcher matcher = p.matcher(text); if (!matcher.find()) {// 不包含链接 // 商品详情 // 发现 // 没有链接,标题过长也不处理 if (text.startsWith("【") && text.contains("】")) { int end = text.indexOf("】"); if (end > 2) text = text.substring(1, end); } LogHelper.test("根据粘贴板推荐:"+text); if (text.length() > 80) { out.print(JsonUtil.loadFalseResult("值过长")); return; } SearchFilter sf = new SearchFilter(); sf.setKey(text); JSONObject root = new JSONObject(); TaoBaoSearchResult result = TaoBaoUtil.search(sf); if (result != null && result.getTaoBaoGoodsBriefs() != null && result.getTaoBaoGoodsBriefs().size() > 0) for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) { // 是属于淘宝联盟商品 if (goods.getTitle().equalsIgnoreCase(text)) { root.put("type", 2); JSONObject data = new JSONObject(); data.put("title", goods.getTitle()); root.put("data", data); out.print(JsonUtil.loadTrueResult(root)); return; } } // 查询大淘客标题 List<DaTaoKeDetail> list = daTaoKeGoodsDetailService.listByDtitle(text); if (list != null && list.size() > 0) { root.put("type", 2); JSONObject data = new JSONObject(); data.put("title", list.get(0).getdTitle()); root.put("data", data); out.print(JsonUtil.loadTrueResult(root)); return; } out.print(JsonUtil.loadFalseResult("暂不支持该类型!")); return; } text = matcher.group(); if (text.contains("ju.taobao.com") || text.contains(".juhuasuan.com")) {// 聚划算 int index = text.indexOf("item_id"); if (index < 0) { out.println(JsonUtil.loadFalseResult("暂未找到该商品,请稍后再试!")); return; } text = text.substring(index); int last = text.indexOf("&"); String id = ""; if (last > 0) id = text.substring(text.indexOf("=") + 1, text.indexOf("&")); else { id = text.substring(text.indexOf("=" + 1)); } tb = TaoBaoUtil.isAlimama(id); if (tb == null) { tb = TaoBaoUtil.parsePhoneTmAndTb(id); } } else if (text.contains("http://zmnxbc.com")) { // 手机端天猫APP分享 tb = TaoBaoUtil.parsePhoneShareUrlByTM(text); } else if (text.contains("h5.m.taobao") || text.contains("detail.m.tmall") || text.contains("item.taobao") || text.contains("detail.tmall")) { // 手机页面和电脑页面 Map<String, String> map = Utils.parseURL(text); String id = ""; id = map.get("id").replace("}", ""); tb = TaoBaoUtil.isAlimama(id); if (tb == null) { tb = TaoBaoUtil.parsePhoneTmAndTb(id); } } else { tb = TaoBaoUtil.parsePhoneShareUrlByTB(text); } if (tb != null) { JSONObject data = new JSONObject(); JSONObject taoBaoGoodsJSON = new JSONObject(); taoBaoGoodsJSON.put("title", tb.getTitle()); taoBaoGoodsJSON.put("zkPrice", tb.getZkPrice()); taoBaoGoodsJSON.put("auctionId", tb.getAuctionId()); taoBaoGoodsJSON.put("url", "http://item.taobao.com/item.htm?id=" + tb.getAuctionId()); data.put("taoBaoGoodsBrief", taoBaoGoodsJSON); if (!StringUtil.isNullOrEmpty(tb.getPictUrl())) { if (tb.getImgList() == null) tb.setImgList(new ArrayList<>()); tb.getImgList().add(0, TbImgUtil.getTBSize220Img(tb.getPictUrl())); } data.put("tbImgs", tb.getImgList()); JSONObject root = new JSONObject(); root.put("type", 1); root.put("data", data); out.print(JsonUtil.loadTrueResult(root)); } out.println(JsonUtil.loadFalseResult("暂未找到该商品,请稍后再试!")); return; } } fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java
@@ -94,7 +94,6 @@ @Resource private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService; /** * 搜索-新版 * @@ -102,9 +101,8 @@ * @param kw * @param page * @param filter * @param order * 销量由高到低:1 、 价格从高到低:2 、 价格从低到高:3 、 推广量高到低:4(综合默认)、返利比高到低:5 * 、返利比低到高:6 、推荐20 * @param order 销量由高到低:1 、 价格从高到低:2 、 价格从低到高:3 、 推广量高到低:4(综合默认)、返利比高到低:5 * 、返利比低到高:6 、推荐20 * @param startprice * @param endprice * @param fastFilter @@ -112,10 +110,11 @@ */ @RequestMapping(value = "searchGoods") public void searchGoods(AcceptData acceptData, String kw, int page, String filter, String order, String startprice, String endprice, Double startTkRate, Double endTkRate, String fastFilter, Integer goodsType, PrintWriter out) { String endprice, Double startTkRate, Double endTkRate, String fastFilter, Integer goodsType, PrintWriter out) { String bid = getHistorySearchBid(acceptData); // 加入搜索历史记录 historySearchService.addHistorySearch(kw, bid); @@ -127,7 +126,7 @@ out.print(JsonUtil.loadTrueResult(data)); return; } if (!StringUtil.isNullOrEmpty(fastFilter)) { if (!StringUtil.isNullOrEmpty(filter)) { JSONArray filterArray = JSONArray.fromObject(filter); @@ -143,20 +142,18 @@ if (goodsType == null) { goodsType = Constant.SOURCE_TYPE_TAOBAO; } // 京东商品 if (goodsType.intValue() == Constant.SOURCE_TYPE_JD) { searchJDGoods(kw, page, filter, order, startprice, endprice, out); return; } if (goodsType.intValue() == Constant.SOURCE_TYPE_PDD) { // 拼多多商品 TODO searchPDDGoods(kw, page, filter, order, startprice, endprice, out); return; } // 是否是推荐 boolean recommend = false; @@ -190,7 +187,7 @@ listRecommendWords = new ArrayList<String>(); } List<TaoBaoShopVO> listShop =taoBaoShopService.getShopByKey(kw); List<TaoBaoShopVO> listShop = taoBaoShopService.getShopByKey(kw); if (listShop != null && listShop.size() > 0 && listShop.get(0).getListGoods() != null && listShop.get(0).getListGoods().size() > 2) { data.put("shop", JsonUtil.getApiCommonGson().toJson(listShop.get(0))); @@ -204,7 +201,6 @@ out.print(JsonUtil.loadTrueResult(data)); } private String getHistorySearchBid(AcceptData acceptData) { StringBuffer sb = new StringBuffer(); String link = "#$$$#"; @@ -215,7 +211,6 @@ return StringUtil.Md5(sb.toString()); } /** * 执行搜索-新版 * @@ -410,7 +405,7 @@ boolean ft = sf.isTmall(); BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); if (fq == 0 && fh == 0 && !ft) { if (result != null && taoBaoGoodsBriefs != null) for (TaoBaoGoodsBrief bf : taoBaoGoodsBriefs) { @@ -422,18 +417,18 @@ list.add(GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate, shareRate)); } } Gson gson2 = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().create(); data.put("result", gson2.toJson(list)); data.put("count", result.getTaoBaoHead().getDocsfound()); return data; } /** * 大淘客商品 * * @param key * @param page * @param filter @@ -510,9 +505,9 @@ } } } /** * 京东 * 京东 * * @param kw * @param page @@ -522,8 +517,8 @@ * @param endprice * @return */ private void searchJDGoods(String kw, int page, String filter, String order, String startprice, String endprice, PrintWriter out) { private void searchJDGoods(String kw, int page, String filter, String order, String startprice, String endprice, PrintWriter out) { JDSearchFilter jdfilter = new JDSearchFilter(); jdfilter.setKey(SearchFilterUtil.filterSearchContent(kw)); jdfilter.setPageNo(page); @@ -536,42 +531,43 @@ if (!StringUtil.isNullOrEmpty(endprice)) { jdfilter.setToPrice(Integer.parseInt(endprice)); } int sort = 1; if (!StringUtil.isNullOrEmpty(order)) { sort = Integer.parseInt(order); } switch (sort) { case 1: // 销量 desc jdfilter.setSort(JDSearchFilter.SORT_DESC); jdfilter.setSortName(JDSearchFilter.SORTNAME_ORDER_COUNT_30DAYS); break; case 2: // 价格—desc jdfilter.setSort(JDSearchFilter.SORT_DESC); jdfilter.setSortName(JDSearchFilter.SORTNAME_PRICE); break; case 3: // 价格—asc jdfilter.setSort(JDSearchFilter.SORT_ASC); jdfilter.setSortName(JDSearchFilter.SORTNAME_PRICE); break; case 5: // 返利比—asc jdfilter.setSort(JDSearchFilter.SORT_DESC); jdfilter.setSortName(JDSearchFilter.SORTNAME_COMMISSION_SHARE); break; default: // 默认:销量 desc jdfilter.setSort(JDSearchFilter.SORT_DESC); jdfilter.setSortName(JDSearchFilter.SORTNAME_ORDER_COUNT_30DAYS); break; case 1: // 销量 desc jdfilter.setSort(JDSearchFilter.SORT_DESC); jdfilter.setSortName(JDSearchFilter.SORTNAME_ORDER_COUNT_30DAYS); break; case 2: // 价格—desc jdfilter.setSort(JDSearchFilter.SORT_DESC); jdfilter.setSortName(JDSearchFilter.SORTNAME_PRICE); break; case 3: // 价格—asc jdfilter.setSort(JDSearchFilter.SORT_ASC); jdfilter.setSortName(JDSearchFilter.SORTNAME_PRICE); break; case 5: // 返利比—DESC jdfilter.setSort(JDSearchFilter.SORT_DESC); jdfilter.setSortName(JDSearchFilter.SORTNAME_COMMISSION_SHARE); break; default: // 默认:销量 desc //jdfilter.setSort(JDSearchFilter.SORT_DESC); //jdfilter.setSortName(JDSearchFilter.SORTNAME_ORDER_COUNT_30DAYS); break; } if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(filter)) { JSONArray array = JSONArray.fromObject(filter); for (int i = 0; i < array.size(); i++) { String ty = array.optJSONObject(i).optString("type"); if ("quantype".equalsIgnoreCase(ty)) { jdfilter.setHasCoupon(1); // 有券 if ("quantype".equalsIgnoreCase(ty)) { jdfilter.setHasCoupon(1); // 有券 } else if ("zy".equalsIgnoreCase(ty)) { jdfilter.setIsZY(1); // 是否自营 } } } @@ -585,28 +581,28 @@ if (pageEntity != null) { count = pageEntity.getTotalCount(); } List<JDGoods> goodsList = result.getGoodsList(); if (goodsList != null && goodsList.size() > 0) { BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); for (JDGoods goods: goodsList) { GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, null, fanLiRate, shareRate); for (JDGoods goods : goodsList) { GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, null, fanLiRate, shareRate); array.add(gson.toJson(goodsDetailVO)); } } } data.put("result", array); data.put("count", count); out.print(JsonUtil.loadTrueResult(data)); } /** * 京东 * 京东 * * @param kw * @param page @@ -616,8 +612,8 @@ * @param endprice * @return */ private void searchPDDGoods(String kw, int page, String filter, String order, String startprice, String endprice, PrintWriter out) { private void searchPDDGoods(String kw, int page, String filter, String order, String startprice, String endprice, PrintWriter out) { PDDSearchFilter pddfilter = new PDDSearchFilter(); pddfilter.setKw(SearchFilterUtil.filterSearchContent(kw)); pddfilter.setPage(page); @@ -627,38 +623,39 @@ if (!StringUtil.isNullOrEmpty(order)) { sort = Integer.parseInt(order); } switch (sort) { case 1: // 销量 desc pddfilter.setSortType(6); break; case 2: // 价格—desc pddfilter.setSortType(4); break; case 3: // 价格—asc pddfilter.setSortType(3); break; case 5: // 返利比—asc pddfilter.setSortType(2); break; case 6: // 返利比—asc pddfilter.setSortType(1); break; case 20: // 综合排序 pddfilter.setSortType(0); break; default: // 默认:销量 desc pddfilter.setSortType(6); break; case 1: // 销量 desc pddfilter.setSortType(6); break; case 2: // 价格—desc pddfilter.setSortType(4); break; case 3: // 价格—asc pddfilter.setSortType(3); break; case 5: // 返利比—asc pddfilter.setSortType(2); break; case 6: // 返利比—asc pddfilter.setSortType(1); break; case 20: // 综合排序 pddfilter.setSortType(0); break; default: // 默认:销量 desc // pddfilter.setSortType(6); break; } if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(filter)) { JSONArray array = JSONArray.fromObject(filter); for (int i = 0; i < array.size(); i++) { String ty = array.optJSONObject(i).optString("type"); if ("quantype".equalsIgnoreCase(ty)) { pddfilter.setHasCoupon(true); // 有券 if ("quantype".equalsIgnoreCase(ty)) { pddfilter.setHasCoupon(true); // 有券 } else if ("brand".equalsIgnoreCase(ty)) { pddfilter.setIsBrand(true); // 是否是品牌 } } } @@ -666,7 +663,7 @@ int count = 0; JSONObject data = new JSONObject(); JSONArray array = new JSONArray(); PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter); if (result != null) { count = result.getTotalCount(); @@ -676,13 +673,14 @@ BigDecimal shareRate = hongBaoManageService.getShareRate(); Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); for (PDDGoodsDetail goods: goodsList) { GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, null, fanLiRate, shareRate); for (PDDGoodsDetail goods : goodsList) { GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, null, fanLiRate, shareRate); array.add(gson.toJson(goodsDetailVO)); } } } data.put("result", array); data.put("count", count); out.print(JsonUtil.loadTrueResult(data)); fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
@@ -268,14 +268,14 @@ * @param out */ @RequestMapping(value = "createShareInfo") public void createShareInfo(AcceptData acceptData, Long uid, Long auctionId, String source, Integer totalNum, public void createShareInfo(AcceptData acceptData, Long uid, Long goodsId, String source, Integer totalNum, Integer goodsType, HttpServletRequest request, PrintWriter out) { if (uid == null || uid <= 0) { out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空")); return; } if (auctionId == null || auctionId <= 0) { if (goodsId == null || goodsId <= 0) { out.print(JsonUtil.loadFalseResult(2, "商品ID不能为空")); return; } @@ -292,11 +292,11 @@ if (goodsType == Constant.SOURCE_TYPE_JD) { // 京东 createJDShare(acceptData, uid, auctionId, source, out); createJDShare(acceptData, uid, goodsId, source, out); return; } else if (goodsType == Constant.SOURCE_TYPE_PDD) { // 拼多多 createPDDShare(acceptData, uid, auctionId, source, out); createPDDShare(acceptData, uid, goodsId, source, out); return; } @@ -308,17 +308,17 @@ relationId = extraInfo.getRelationId(); if (source != null && "taolijin".equals(source)) { createTaoLijin(uid, auctionId, totalNum, relationId, request, out); createTaoLijin(uid, goodsId, totalNum, relationId, request, out); return; } try { TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId); TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, goodsId, relationId); JSONObject data = new JSONObject(); String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(), Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), auctionId + ""); goodsId + ""); String shortLink = HttpUtil.getShortLink(url); if (!StringUtil.isNullOrEmpty(shortLink)) { @@ -327,8 +327,7 @@ data.put("clickUrl", url); data.put("token", taoBaoLink.getTaoToken()); data.put("rule", "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0"); data.put("rule", configService.get("share_rule_link_tb")); data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500)); String shareText = ""; @@ -377,7 +376,7 @@ data.put("shareMoney", "¥" + shareMoney.toString()); try { ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId, Constant.SOURCE_TYPE_TAOBAO); ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId, Constant.SOURCE_TYPE_TAOBAO); data.put("shareId", shareRecord.getRedisKey()); } catch (Exception e) { try { @@ -415,14 +414,14 @@ }); return; } catch (ShareGoodsException e) { LogHelper.errorDetailInfo(e, "分享出错:uid:"+uid+"auctionId:"+auctionId, ""); LogHelper.errorDetailInfo(e, "分享出错:uid:"+uid+"auctionId:"+goodsId, ""); // 分享出错报警 try { monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "分享出错")); } catch (Exception e1) { } out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage())); businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + "")); businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(goodsId + "")); } } @@ -491,8 +490,7 @@ } } data.put("token", taoBaoLink.getTaoToken()); data.put("rule", "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0"); data.put("rule", configService.get("share_rule_link_tb")); data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500)); // 无券 @@ -620,27 +618,27 @@ Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), goodsId + "", Constant.SOURCE_TYPE_JD); // 券短连接 String shortLink = HttpUtil.getShortLink(url); if (!StringUtil.isNullOrEmpty(shortLink)) { url = shortLink; } data.put("clickUrl", url); // 帮助中心-介绍 String rule = "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0"; data.put("rule", rule); data.put("rule", configService.get("share_rule_link_jd")); data.put("pictUrl", jdGoods.getPicUrl()); String shareText = ""; String shopType = "京东价"; // 无券 // 分享模板 JDCouponInfo couponInfo = jdGoods.getCouponInfo(); if (couponInfo == null) { String text = shareGoodsTextTemplateService.getCommonTemplate(uid); if (StringUtil.isNullOrEmpty(text)) if (StringUtil.isNullOrEmpty(text)) { text = configService.get("goods_share_text_nocoupon"); } shareText = text.replace("{标题}", jdGoods.getSkuName()).replace("{商品原价}", MoneyBigDecimalUtil.getWithNoZera(jdGoods.getPrice()) + ""); } else// 有券 @@ -659,6 +657,8 @@ .replace("{月销量}", JDUtil.getSaleCount(jdGoods.getInOrderCount30Days())) .replace("{领券短链}", shortLink).replace("{淘口令}", null); data.put("shareText", shareText); String descText = shareText.replace(jdGoods.getSkuName(), "").trim(); if (descText.startsWith("\\r\\n")) descText = descText.substring(0); @@ -669,7 +669,7 @@ int p = (int) (array.size() * Math.random()); if (p < array.size()) data.put("notifyPicture", array.optString(p)); data.put("notifyDesc", configService.get("goods_share_notify")); data.put("notifyDesc", configService.get("goods_share_notify_jd")); // 添加分享记录 BigDecimal shareRate = hongBaoManageService.getShareRate(); @@ -731,7 +731,6 @@ out.print(JsonUtil.loadFalseResult(1, "该商品已下架")); return; } JSONObject data = new JSONObject(); String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&goodsType=%s", configService.getH5Host(), @@ -745,8 +744,7 @@ data.put("clickUrl", url); // 帮助中心-介绍 String rule = "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0"; data.put("rule", rule); data.put("rule", configService.get("share_rule_link_pdd")); data.put("pictUrl", goods.getGoodsImageUrl()); String shareText = ""; @@ -786,7 +784,8 @@ int p = (int) (array.size() * Math.random()); if (p < array.size()) data.put("notifyPicture", array.optString(p)); data.put("notifyDesc", configService.get("goods_share_notify")); data.put("notifyDesc", configService.get("goods_share_notify_pdd")); // 添加分享记录 BigDecimal shareRate = hongBaoManageService.getShareRate(); fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java
@@ -72,6 +72,7 @@ import com.yeshi.fanli.vo.goods.OtherInfo; import com.yeshi.fanli.vo.goods.taobao.TLJBuyHongBaoVO; import com.yeshi.fanli.vo.msg.ClientTextStyleVO; import com.yeshi.fanli.vo.tlj.ReduceHongBao; import com.yeshi.fanli.vo.tlj.SpreadHongBao; import com.yeshi.fanli.vo.tlj.TaoLiJinDetailVO; import com.yeshi.fanli.vo.user.UserTaoLiJinRecordVO; @@ -738,5 +739,81 @@ } out.print(JsonUtil.loadTrueResult(data)); } /** * 分享爆款商品-限于淘礼金 * * @param acceptData * @param uid * @param out */ @RequestMapping(value = "getBuyGoodsV2", method = RequestMethod.POST) public void getBuyGoodsV2(AcceptData acceptData, int page, PrintWriter out) { String day = TimeUtil.getGernalTime(java.lang.System.currentTimeMillis()); List<TLJBuyGoods> listHot = tljBuyGoodsService.listByDay(day); if (listHot == null) { listHot = new ArrayList<TLJBuyGoods>(); } JSONArray array = new JSONArray(); Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); BigDecimal proportion = TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE; for (TLJBuyGoods hotGoods : listHot) { TaoBaoGoodsBrief taoBaoGoodsBrief = hotGoods.getGoods(); if (taoBaoGoodsBrief == null) { continue; } // 计算推广红包 BigDecimal spreadMoney = TaoBaoUtil.getGoodsHongBaoMoney(taoBaoGoodsBrief, proportion); // 推广红包 不能小于1 if (spreadMoney.compareTo(new BigDecimal(1.0)) < 0) { continue; } GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, proportion, proportion); // 去掉标签 detailVO.setLabels(null); MoneyInfoVO moneyInfo = detailVO.getMoneyInfo(); moneyInfo.setMoneyType(2); detailVO.setMoneyInfo(moneyInfo); String hongBao = spreadMoney.toString(); ReduceHongBao vo = new ReduceHongBao(); vo.setLeft(hotGoods.getLeftHongBaoCount()); vo.setMoney(hongBao); vo.setName("付款立减 ¥" + hongBao); vo.setTip(""); vo.setTotal(hotGoods.getTotalHongBaoCount()); OtherInfo otherInfo = new OtherInfo(); otherInfo.setReduceHongBao(vo); detailVO.setOtherInfo(otherInfo); } if (page > 1) array.clear(); JSONObject data = new JSONObject(); data.put("count", array.size()); data.put("list", array); if (page == 1) { List<SwiperPicture> bannerList = swiperPictureService.getByBannerCard("zigoulijian_banner"); if (bannerList != null && bannerList.size() > 0) data.put("topPicture", bannerList.get(0).getSrc()); else data.put("topPicture", ""); data.put("ruleUrl", configService.get("zigoulijian_rule")); } out.print(JsonUtil.loadTrueResult(data)); } } fanli/src/main/java/com/yeshi/fanli/dto/pdd/PDDSearchFilter.java
@@ -7,6 +7,7 @@ private Integer pageSize;// 页数量 private Integer sortType;// 排序类型 private Boolean hasCoupon;// 是否有券 private Boolean isBrand;// 是否为品牌商品 private Long catId;// 分类ID private Long[] goodsIdList;// 商品列表ID private Integer merchantType;// 卖家类型 @@ -91,4 +92,12 @@ public void setPid(String pid) { this.pid = pid; } public Boolean getIsBrand() { return isBrand; } public void setIsBrand(Boolean isBrand) { this.isBrand = isBrand; } } fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -1170,7 +1170,6 @@ @Override public CommonOrder selectBySourceTypeAndTradeId(int sourceType, String tradeId) { return commonOrderMapper.selectBySourceTypeAndTradeId(sourceType, tradeId); } fanli/src/main/java/com/yeshi/fanli/util/factory/goods/GoodsDetailVOFactory.java
@@ -2,18 +2,20 @@ import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; import org.yeshi.utils.taobao.TbImgUtil; import com.yeshi.fanli.dto.jd.JDCouponInfo; import com.yeshi.fanli.dto.jd.JDShopInfo; import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; import com.yeshi.fanli.entity.goods.CommonGoods; import com.yeshi.fanli.entity.jd.JDGoods; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra; import com.yeshi.fanli.entity.taobao.TaoBaoHongBaoInfo; import com.yeshi.fanli.entity.taobao.TaoBaoQuanInfo; import com.yeshi.fanli.util.CommonGoodsUtil; import com.yeshi.fanli.util.Constant; @@ -116,11 +118,16 @@ goodsInfo.setCouponInfo(coupon); } // 店铺信息 ShopInfoVO shop = new ShopInfoVO(); shop.setShopName(goods.getSellerName()); shop.setId(goods.getSellerId().toString()); goodsInfo.setShopInfo(shop); if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { // 店铺信息 if (!StringUtil.isNullOrEmpty(goods.getSellerName()) && goods.getSellerId() != null) { ShopInfoVO shop = new ShopInfoVO(); shop.setShopName(goods.getSellerName()); shop.setId(goods.getSellerId().toString()); goodsInfo.setShopInfo(shop); } } return goodsInfo; } @@ -156,8 +163,15 @@ // 资金信息 MoneyInfoVO moneyInfoVO = new MoneyInfoVO(); moneyInfoVO.setMoneyType(1); // 默认显示:返 ¥6.6 moneyInfoVO.setFanliMoney(TaoBaoUtil.getGoodsHongBaoInfo(goods, fanLiRate)); moneyInfoVO.setShareMoney(TaoBaoUtil.getGoodsHongBaoInfo(goods, shareRate)); if (goods.getTkRate() == null) { TaoBaoHongBaoInfo taoBaoHongBaoInfo = goods.getTaoBaoHongBaoInfo(); moneyInfoVO.setFanliMoney("¥"+ taoBaoHongBaoInfo.getHongbao()); moneyInfoVO.setShareMoney("¥"+ taoBaoHongBaoInfo.getHongbao()); } else { moneyInfoVO.setFanliMoney(TaoBaoUtil.getGoodsHongBaoInfo(goods, fanLiRate)); moneyInfoVO.setShareMoney(TaoBaoUtil.getGoodsHongBaoInfo(goods, shareRate)); } goodsInfo.setMoneyInfo(moneyInfoVO); TaoBaoQuanInfo taoBaoQuanInfo = goods.getTaoBaoQuanInfo(); @@ -181,21 +195,14 @@ } // 店铺信息 ShopInfoVO shop = null; String shopTitle = goods.getShopTitle(); Long sellerId = goods.getSellerId(); if (!StringUtil.isNullOrEmpty(shopTitle)) { shop = new ShopInfoVO(); if (!StringUtil.isNullOrEmpty(shopTitle) && sellerId != null) { ShopInfoVO shop = new ShopInfoVO(); shop.setShopName(shopTitle); } if (sellerId != null) { if (shop == null) { shop = new ShopInfoVO(); } shop.setId(goods.getSellerId().toString()); goodsInfo.setShopInfo(shop); } goodsInfo.setShopInfo(shop); return goodsInfo; } @@ -216,8 +223,24 @@ goodsInfo.setTitle(goods.getTitle()); goodsInfo.setSalesType(1); // 默认月销量 goodsInfo.setZkPrice(goods.getZkPrice()); goodsInfo.setImgList(goods.getImgList()); goodsInfo.setState(goods.getState()); List<String> imgList = goods.getImgList(); if (imgList != null) { goodsInfo.setImgList(imgList); } else { imgList = new ArrayList<String>(); imgList.add(goods.getPictUrl()); goodsInfo.setImgList(imgList); } Integer state = goods.getState(); if (state == null) { goodsInfo.setState(0); } else { goodsInfo.setState(state); } goodsInfo.setSalesCount(TaoBaoUtil.getSaleCount(goods.getBiz30day())); if (!StringUtil.isNullOrEmpty(goods.getPictUrlWhite())) { @@ -255,8 +278,14 @@ coupon.setAmount(goods.getCouponAmount()); coupon.setLeftCount(goods.getCouponLeftCount()); coupon.setTotalCount(goods.getCouponTotalCount()); coupon.setEndTime(goods.getCouponEffectiveEndTime().replace("-", ".")); coupon.setStartTime(goods.getCouponEffectiveStartTime().replace("-", ".")); if (goods.getCouponEffectiveEndTime() != null) { coupon.setEndTime(goods.getCouponEffectiveEndTime().replace("-", ".")); } if (goods.getCouponEffectiveStartTime() != null) { coupon.setStartTime(goods.getCouponEffectiveStartTime().replace("-", ".")); } coupon.setLink(TaoBaoCouponUtil.getCoupleUrl(goods.getCouponActivityId(), pid, goods.getAuctionId() + "")); coupon.setStartFee(goods.getCouponStartFee()); @@ -265,10 +294,12 @@ } // 店铺信息 ShopInfoVO shop = new ShopInfoVO(); shop.setShopName(goods.getShopTitle()); shop.setId(goods.getSellerId().toString()); goodsInfo.setShopInfo(shop); if (!StringUtil.isNullOrEmpty(goods.getShopTitle()) && goods.getSellerId() != null) { ShopInfoVO shop = new ShopInfoVO(); shop.setShopName(goods.getShopTitle()); shop.setId(goods.getSellerId().toString()); goodsInfo.setShopInfo(shop); } return goodsInfo; } @@ -357,13 +388,13 @@ } // 店铺信息 JDShopInfo shopInfo = goods.getShopInfo(); if (shopInfo != null && !StringUtil.isNullOrEmpty(shopInfo.getShopName())) { ShopInfoVO shop = new ShopInfoVO(); shop.setShopName(shopInfo.getShopName()); shop.setId(shopInfo.getShopId().toString()); goodsInfo.setShopInfo(shop); } // JDShopInfo shopInfo = goods.getShopInfo(); // if (shopInfo != null && !StringUtil.isNullOrEmpty(shopInfo.getShopName())) { // ShopInfoVO shop = new ShopInfoVO(); // shop.setShopName(shopInfo.getShopName()); // shop.setId(shopInfo.getShopId().toString()); // goodsInfo.setShopInfo(shop); // } return goodsInfo; } @@ -459,16 +490,16 @@ } // 店铺信息 String mallName = goods.getMallName(); if (!StringUtil.isMobile(mallName)) { ShopInfoVO shop = new ShopInfoVO(); shop.setShopName(mallName); if (goods.getMallId() != null) { shop.setId(goods.getMallId().toString()); } goodsInfo.setShopInfo(shop); } // String mallName = goods.getMallName(); // if (!StringUtil.isMobile(mallName)) { // ShopInfoVO shop = new ShopInfoVO(); // shop.setShopName(mallName); // // if (goods.getMallId() != null) { // shop.setId(goods.getMallId().toString()); // } // goodsInfo.setShopInfo(shop); // } return goodsInfo; } fanli/src/main/java/com/yeshi/fanli/util/factory/goods/ShopInfoVOFactory.java
@@ -30,6 +30,9 @@ shopInfoVO.setShopLink(shop.getShopLink()); shopInfoVO.setScoreGoods(shop.getScoreGoods()); shopInfoVO.setScoreSeller(shop.getScoreSeller()); shopInfoVO.setScoreLogistics(shop.getScoreLogistics()); shopInfoVO.setScoreGoodsD(shop.getScoreGoodsD()); shopInfoVO.setScoreSellerD(shop.getScoreSellerD()); shopInfoVO.setScoreLogistics(shop.getScoreLogisticsD()); shopInfoVO.setGoodRatePercentage(shop.getGoodRatePercentage()); fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java
@@ -81,6 +81,8 @@ map.put("sort_type", sf.getSortType() + ""); if (sf.getHasCoupon() != null) map.put("with_coupon", sf.getHasCoupon() + ""); if (sf.getIsBrand() != null) map.put("is_brand_goods", sf.getIsBrand() + ""); if (sf.getCatId() != null) map.put("cat_id", sf.getCatId() + ""); if (sf.getKw() != null) fanli/src/main/java/com/yeshi/fanli/vo/goods/GoodsDetailExtraVO.java
@@ -32,7 +32,7 @@ private boolean shareValid; // 是否跳转原生APP @Expose private boolean isNative; private Boolean isNative; // 图文详情链接 @@ -45,7 +45,6 @@ @Expose private List<ClientTextStyleVO> tip; // 淘客参数 @Expose private ClientTBPid tbPidInfo; @@ -62,12 +61,6 @@ // 领取人 @Expose private List<ShamUser> listCouponUser; // 推广红包 @Expose private OtherInfo otherInfo; // 店铺信息 @Expose private ShopInfoVO shopInfo; public ClientTBPid getTbPidInfo() { return tbPidInfo; @@ -117,11 +110,11 @@ this.shareValid = shareValid; } public boolean isNative() { public Boolean getIsNative() { return isNative; } public void setNative(boolean isNative) { public void setIsNative(Boolean isNative) { this.isNative = isNative; } @@ -179,21 +172,5 @@ public void setListCouponUser(List<ShamUser> listCouponUser) { this.listCouponUser = listCouponUser; } public ShopInfoVO getShopInfo() { return shopInfo; } public void setShopInfo(ShopInfoVO shopInfo) { this.shopInfo = shopInfo; } public OtherInfo getOtherInfo() { return otherInfo; } public void setOtherInfo(OtherInfo otherInfo) { this.otherInfo = otherInfo; } } fanli/src/main/java/com/yeshi/fanli/vo/goods/GoodsDetailVO.java
@@ -49,7 +49,7 @@ @Expose private boolean recommend;// 是否推荐 :是否展示右上角叉)true-展示 false-不展示 @Expose private List<ClientTextStyleVO> pictureTag;// 图标 private ClientTextStyleVO pictureTag;// 图标 @Expose private List<ClientTextStyleVO> labels;// 标签 @Expose @@ -171,11 +171,11 @@ this.moneyInfo = moneyInfo; } public List<ClientTextStyleVO> getPictureTag() { public ClientTextStyleVO getPictureTag() { return pictureTag; } public void setPictureTag(List<ClientTextStyleVO> pictureTag) { public void setPictureTag(ClientTextStyleVO pictureTag) { this.pictureTag = pictureTag; } fanli/src/main/java/com/yeshi/fanli/vo/goods/ShopInfoVO.java
@@ -42,6 +42,13 @@ private BigDecimal goodRatePercentage;// 好评率 @Expose private String shopLink; // 店铺链接 @Expose private BigDecimal scoreGoodsD;// 与行业平均分的差值 private BigDecimal scoreSellerD; private BigDecimal scoreLogisticsD; public String getId() { return id; @@ -115,4 +122,31 @@ this.shopLink = shopLink; } public BigDecimal getScoreGoodsD() { return scoreGoodsD; } public void setScoreGoodsD(BigDecimal scoreGoodsD) { this.scoreGoodsD = scoreGoodsD; } public BigDecimal getScoreSellerD() { return scoreSellerD; } public void setScoreSellerD(BigDecimal scoreSellerD) { this.scoreSellerD = scoreSellerD; } public BigDecimal getScoreLogisticsD() { return scoreLogisticsD; } public void setScoreLogisticsD(BigDecimal scoreLogisticsD) { this.scoreLogisticsD = scoreLogisticsD; } public static long getSerialversionuid() { return serialVersionUID; } } fanli/src/main/java/com/yeshi/fanli/vo/tlj/ReduceHongBao.java
@@ -13,23 +13,45 @@ private Integer total; @Expose private Integer left; public String getMoney() { return money; } public void setMoney(String money) { this.money = money; } public String getTip() { return tip; } public void setTip(String tip) { this.tip = tip; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getMoney() { return money; } public void setMoney(String money) { this.money = money; } public String getTip() { return tip; } public void setTip(String tip) { this.tip = tip; } public Integer getTotal() { return total; } public void setTotal(Integer total) { this.total = total; } public Integer getLeft() { return left; } public void setLeft(Integer left) { this.left = left; } }