From 2a48f2bd979d56ce4114ba9d56efaf49bab705d7 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期日, 31 五月 2020 11:13:07 +0800 Subject: [PATCH] 淘宝分享佣金比例修改 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java | 458 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 392 insertions(+), 66 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java index 0f63cda..56be522 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java @@ -24,8 +24,13 @@ import com.google.gson.GsonBuilder; import com.yeshi.fanli.dto.ConfigParamsDTO; import com.yeshi.fanli.dto.jd.JDCouponInfo; +import com.yeshi.fanli.dto.jd.JDPingouInfo; import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; import com.yeshi.fanli.dto.share.ShareGoodsRecordDTO; +import com.yeshi.fanli.dto.suning.SuningGoodsImg; +import com.yeshi.fanli.dto.suning.SuningGoodsInfo; +import com.yeshi.fanli.dto.vip.VIPConvertResultDTO; +import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo; import com.yeshi.fanli.entity.accept.AcceptData; import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup; import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory; @@ -34,8 +39,8 @@ import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.bus.user.UserInfoExtra; +import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; import com.yeshi.fanli.entity.goods.CommonGoods; -import com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate; import com.yeshi.fanli.entity.jd.JDGoods; import com.yeshi.fanli.entity.system.ConfigKeyEnum; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; @@ -55,6 +60,7 @@ import com.yeshi.fanli.service.inter.goods.ShareGoodsTextTemplateService; import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service; import com.yeshi.fanli.service.inter.monitor.MonitorService; +import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService; import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService; @@ -79,9 +85,13 @@ import com.yeshi.fanli.util.jd.JDUtil; import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil; import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil; +import com.yeshi.fanli.util.suning.SuningApiUtil; +import com.yeshi.fanli.util.suning.SuningUtil; import com.yeshi.fanli.util.taobao.TaoBaoUtil; import com.yeshi.fanli.util.taobao.TaoKeApiUtil; import com.yeshi.fanli.util.taobao.TaoLiJinUtil; +import com.yeshi.fanli.util.vipshop.VipShopApiUtil; +import com.yeshi.fanli.util.vipshop.VipShopUtil; import com.yeshi.fanli.vo.goods.GoodsDetailVO; import com.yeshi.fanli.vo.goods.ShareGoodsCommentChoiceInfo; import com.yeshi.fanli.vo.goods.ShareInfoVO; @@ -104,6 +114,9 @@ @Resource private HongBaoManageService hongBaoManageService; + + @Resource + private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; @Resource private MonitorService monitorService; @@ -177,7 +190,7 @@ "涓嬭浇閾炬帴锛�" + Constant.YINGYONGBAO_LINK, false, true)); list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_FANLI_MONEY, "杩斿埄閲戦", - "杩斿埄閲戦锛毬� " + fanliMoney, false, true)); + String.format("銆愯仈绯绘垜涓嬭浇APP銆戞渶楂樺彲杩旇繕%s鍏�", fanliMoney + ""), false, true)); return list; } @@ -197,7 +210,7 @@ * @param out */ @RequestMapping(value = "createShareInfo") - public void createShareInfo(AcceptData acceptData, Long uid, Long goodsId, String source, Integer totalNum, + public void createShareInfo(AcceptData acceptData, Long uid, String goodsId, String source, Integer totalNum, Integer goodsType, Boolean needGoods, HttpServletRequest request, PrintWriter out) { if (uid == null || uid <= 0) { out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛ID涓嶈兘涓虹┖")); @@ -220,49 +233,64 @@ return; } - if (goodsId == null || goodsId <= 0) { + if (goodsId == null ) { out.print(JsonUtil.loadFalseResult(2, "鍟嗗搧ID涓嶈兘涓虹┖")); return; } // 娣樺疂 if (goodsType == null || goodsType == Constant.SOURCE_TYPE_TAOBAO) { - createTaoBaoShare(acceptData, uid, goodsId, totalNum, source, needGoods, request, out); + createTaoBaoShare(acceptData, uid,Long.parseLong(goodsId), totalNum, source, needGoods, request, out); return; } // 浜笢 if (goodsType == Constant.SOURCE_TYPE_JD) { - createJDShare(acceptData, uid, goodsId, source, needGoods, out); + createJDShare(acceptData, uid, Long.parseLong(goodsId), source, needGoods, out); return; } // 鎷煎澶� if (goodsType == Constant.SOURCE_TYPE_PDD) { - createPDDShare(acceptData, uid, goodsId, source, needGoods, out); + createPDDShare(acceptData, uid, Long.parseLong(goodsId), source, needGoods, out); return; } + + // 鍞搧浼� + if (goodsType == Constant.SOURCE_TYPE_VIP) { + createVIPShare(acceptData, uid, Long.parseLong(goodsId), source, needGoods, out); + return; + } + + // 鑻忓畞 + if (goodsType == Constant.SOURCE_TYPE_SUNING) { + createSuningShare(acceptData, uid, goodsId, source, needGoods, out); + return; + } + } - public static String getERCodeContent(String template, TaoBaoGoodsBrief goods, String token) { - return template.replace("[娣樺彛浠", token); - } - - public static String getERCodeContentNew(String template, TaoBaoGoodsBrief goods, String token) { String commentText = template.replace("[鍘熶环]", goods.getZkPrice().toString()); - commentText = commentText.replace("[鍙d护]", token); + commentText = commentText.replace("[娣樺彛浠", token); if (StringUtil.isNullOrEmpty(goods.getCouponInfo())) { commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘"); commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", ""); } else { commentText = commentText.replace("[鍒稿悗浠穄", TaoBaoUtil.getAfterUseCouplePrice(goods) + ""); } - - commentText =commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n"); + + commentText = commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n"); return commentText; } - + + // 娣樺疂鍒嗕韩娲诲姩 + public static String getTaoBaoActiivtyERCodeContentNew(String template, String token) { + String commentText = template.replace("[娣樺彛浠", token); + commentText = commentText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n"); + return commentText; + } + /** * 鍒涘缓娣樺疂鍒嗕韩淇℃伅 * @@ -497,7 +525,7 @@ TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, goodsId, relationId); if (taoBaoLink != null && taoBaoLink.getGoods() != null && needGoods) { - ConfigParamsDTO dto = hongBaoManageService.getShowComputeRate(platform, version); + ConfigParamsDTO dto = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version); GoodsDetailVO goodsInfo = GoodsDetailVOFactory.convertTaoBao(taoBaoLink.getGoods(), dto); shareInfo.setGoodsInfo(goodsInfo); } @@ -537,41 +565,44 @@ shareInfo.setCommentTexts(commentTexts); TaoBaoGoodsBrief goods = taoBaoLink.getGoods(); - + boolean coupon = false; if (!StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { coupon = true; } - + String template = shareGoodsTextTemplateService.getTextTemplateByTB(uid); - String shareText = shareGoodsTextTemplateService.createContentTB(template, goods, taoBaoLink.getTaoToken(), coupon); + String shareText = shareGoodsTextTemplateService.createContentTB(template, goods, taoBaoLink.getTaoToken(), + coupon); shareInfo.setShareText(shareText); - + String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim(); if (descText.startsWith("\\r\\n")) { descText = descText.substring(0); } shareInfo.setDescText(deleteBlankLine(descText)); - + // 娴嬭瘯 // 2.0.2涔嬪墠 if (VersionUtil.greaterThan_2_0_7(platform, version)) { - shareInfo.setClickUrl(getERCodeContentNew(configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()), - taoBaoLink.getGoods(), shareInfo.getToken())); + shareInfo.setClickUrl( + getERCodeContentNew(configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()), + taoBaoLink.getGoods(), shareInfo.getToken())); } else if (!VersionUtil.greaterThan_2_0_2(platform, version)) { - shareInfo.setClickUrl(getERCodeContent(configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), - taoBaoLink.getGoods(), shareInfo.getToken())); + shareInfo.setClickUrl( + getERCodeContentNew(configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), + taoBaoLink.getGoods(), shareInfo.getToken())); } - if (VersionUtil.greaterThan_2_0_7(platform, version)) { - shareInfo.setWxErCode(getERCodeContentNew(configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()), + // if (VersionUtil.greaterThan_2_0_7(platform, version)) { + // shareInfo.setWxErCode( + // getERCodeContentNew(configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()), + // taoBaoLink.getGoods(), shareInfo.getToken())); + // } else { + shareInfo.setWxErCode(getERCodeContentNew(configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), taoBaoLink.getGoods(), shareInfo.getToken())); - } else { - shareInfo.setWxErCode(getERCodeContent(configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), - taoBaoLink.getGoods(), shareInfo.getToken())); - } - - + // } + // 鎻愮ず鍥炬枃鍐呭 String imgs = configService.getByVersion(ConfigKeyEnum.goodsShareNotifyImgs.getKey(), platform, Integer.parseInt(version)); @@ -603,7 +634,7 @@ e1.printStackTrace(); } } - + String commentText = ""; String recommendText = ""; if (VersionUtil.greaterThan_2_0_7(platform, version)) { @@ -612,9 +643,13 @@ if (!coupon) { recommendText = recommendText.replace("鎺ㄨ崘鐞嗙敱:[鎺ㄨ崘璇璢", ""); } else { - recommendText = recommendText.replace("[鎺ㄨ崘璇璢", goods.getDescription()); + if (!StringUtil.isNullOrEmpty(goods.getDescription())) { + recommendText = recommendText.replace("[鎺ㄨ崘璇璢", goods.getDescription()); + } else { + recommendText = recommendText.replace("鎺ㄨ崘鐞嗙敱:[鎺ㄨ崘璇璢", ""); + } } - + String sales = TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()); if (sales.equals("0")) { recommendText = recommendText.replace("閿�閲�:[閿�閲廬", ""); @@ -624,7 +659,7 @@ String quickCommentText = configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()); commentText = quickCommentText.replace("[鍘熶环]", goods.getZkPrice().toString()); - commentText = commentText.replace("[鍙d护]", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); + commentText = commentText.replace("[娣樺彛浠", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘"); commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", ""); @@ -632,8 +667,7 @@ commentText = commentText.replace("[鍒稿悗浠穄", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + ""); } - - + if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { recommendText = recommendText.replace("浼樻儬鍒�:[鍒搁潰棰漖鍏�", ""); } else { @@ -648,8 +682,9 @@ shareInfo.setRecommendText(deleteBlankLine(recommendText)); // 璁剧疆璇勮鏂囨湰閫夐」 - shareInfo.setCommentTextChoiceList(getCommentChoiceList(shareInfo.getCommentText(), null, inviteCode, - TaoBaoUtil.getGoodsHongBaoMoney(taoBaoLink.getGoods(), hongBaoManageService.getFanLiRate()))); + shareInfo.setCommentTextChoiceList( + getCommentChoiceList(shareInfo.getCommentText(), null, inviteCode, TaoBaoUtil.getGoodsHongBaoMoney( + taoBaoLink.getGoods(), hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP),false))); out.print(JsonUtil.loadTrueResult( JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); @@ -728,14 +763,14 @@ shareInfo.setCommentTexts(new ArrayList<>()); if (needGoods) - shareInfo.setGoodsInfo(GoodsDetailVOFactory.convertJDGoods(jdGoods, - hongBaoManageService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion()))); + shareInfo.setGoodsInfo(GoodsDetailVOFactory.convertJDGoods(jdGoods, orderHongBaoMoneyComputeService + .getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion()))); boolean hasCoupon = false; if (couponInfo != null) { hasCoupon = true; } - + String template = shareGoodsTextTemplateService.getTextTemplateByJD(uid); String shareText = shareGoodsTextTemplateService.createContentJD(template, jdGoods, jumpLink, hasCoupon); shareInfo.setShareText(shareText); @@ -782,15 +817,33 @@ if (VersionUtil.greaterThan_2_0_7(acceptData.getPlatform(), acceptData.getVersion())) { String template2 = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); recommendText = template2.replace("[鍟嗗搧鏍囬]", jdGoods.getSkuName()); - // 鏃犳帹鑽愯 recommendText = recommendText.replace("鎺ㄨ崘鐞嗙敱:[鎺ㄨ崘璇璢", ""); - String sales = JDUtil.getSaleCount(jdGoods.getInOrderCount30Days()); if (sales.equals("0")) { recommendText = recommendText.replace("閿�閲�:[閿�閲廬", ""); } else { recommendText = recommendText.replace("[閿�閲廬", sales.replace("涓�", "w")); } + + BigDecimal price = jdGoods.getPrice(); + JDPingouInfo pinGouInfo = jdGoods.getPinGouInfo(); + if (pinGouInfo != null) { + price = pinGouInfo.getPingouPrice(); + } + + String template3 = configService.get(ConfigKeyEnum.quickShareJDCommentText.getKey()); + commentText = template3.replace("[鍘熶环]", BigDecimalUtil.getWithNoZera(price).toString()); + if (!hasCoupon) { + recommendText = recommendText.replace("浼樻儬鍒�:[鍒搁潰棰漖鍏�", ""); + commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", ""); + commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘"); + } else { + recommendText = recommendText.replace("[鍒搁潰棰漖", + BigDecimalUtil.getWithNoZera(couponInfo.getDiscount()).toString()); + commentText = commentText.replace("[鍒稿悗浠穄", + BigDecimalUtil.getWithNoZera(JDUtil.getQuanPrice(jdGoods)).toString()); + } + commentText = commentText.replace("[閾炬帴]", jumpLink); } else { commentText = shareInfo.getShareText(); recommendText = shareInfo.getDescText(); @@ -800,7 +853,7 @@ // 璁剧疆璇勮鏂囨湰閫夐」 shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getCommentText(), inviteCode, - JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getFanLiRate()))); + JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)))); out.print(JsonUtil.loadTrueResult( JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); @@ -832,12 +885,10 @@ } }); } - - - private String deleteBlankLine(String st){ + + private String deleteBlankLine(String st) { return st.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n"); } - /** * 鎷煎澶氬垎浜� @@ -875,16 +926,16 @@ .setGoodsInfo(GoodsDetailVOFactory.convertPDDGoods(goods, new ConfigParamsDTO(hongBaoManageService.getFanLiRate(), hongBaoManageService.getShareRate(), Constant.MAX_REWARD_RATE, - hongBaoManageService.getVIPFanLiRate()))); + hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)))); } // 鍒涘缓鍙d护 -// String token = PinDuoDuoApiUtil.createGenerate(goodsId); - + // String token = PinDuoDuoApiUtil.createGenerate(goodsId); + boolean hasCoupon = true; if (goods.getHasCoupon() == null || !goods.getHasCoupon()) { hasCoupon = false; - } + } String template = shareGoodsTextTemplateService.getTextTemplateByPDD(uid); String shareText = shareGoodsTextTemplateService.createContentPDD(template, goods, jumpLink, hasCoupon); shareInfo.setShareText(shareText); @@ -971,8 +1022,8 @@ shareInfo.setCommentText(deleteBlankLine(commentText)); // 璁剧疆璇勮鏂囨湰閫夐」 - shareInfo.setCommentTextChoiceList(getCommentChoiceList(null,shareInfo.getCommentText(), inviteCode, - PinDuoDuoUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate()))); + shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getCommentText(), inviteCode, + PinDuoDuoUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)))); out.print(JsonUtil.loadTrueResult( JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); @@ -1000,6 +1051,277 @@ } if (imgList == null) { imgList = new ArrayList<>(); + } + history.setPictures(JsonUtil.getGson().toJson(imgList)); + shareGoodsService.addShareGoodsHistory(history); + } + }); + } + + /** + * 鍞搧浼氬垎浜� + * @Title: createVIPShare + * @Description: + * @param acceptData + * @param uid + * @param goodsId + * @param source + * @param needGoods + * @param out + * void 杩斿洖绫诲瀷 + * @throws + */ + public void createVIPShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods, + PrintWriter out) { + VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(goodsId + ""); + if (goods == null) { + out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佸凡涓嬫灦")); + return; + } + + VIPConvertResultDTO jumpLink = VipShopApiUtil.convertLink(goodsId + "", VipShopUtil.getShareChanTag(uid)); + + ShareInfoVO shareInfo = new ShareInfoVO(); + shareInfo.setClickUrl(jumpLink.getUrl()); + shareInfo.setWxErCode(jumpLink.getUrl()); + shareInfo.setCommentTexts(new ArrayList<>()); + shareInfo.setRule(configService.get(ConfigKeyEnum.shareRuleLinkVIP.getKey())); + shareInfo.setPictUrl(goods.getGoodsThumbUrl()); + if (needGoods) { + shareInfo + .setGoodsInfo(GoodsDetailVOFactory.convertVIPGoods(goods, + new ConfigParamsDTO(hongBaoManageService.getFanLiRate(), + hongBaoManageService.getShareRate(), Constant.MAX_REWARD_RATE, + hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)))); + } + + String template = shareGoodsTextTemplateService.getTextTemplateByVIP(uid); + String shareText = shareGoodsTextTemplateService.createContentVIP(template, goods, jumpLink.getUrl()); + shareInfo.setShareText(shareText); + + String descText = shareText.replace(goods.getGoodsName(), "").trim(); + if (descText.startsWith("\\r\\n")) { + descText = descText.substring(0); + } + shareInfo.setDescText(descText); + + // + String imgs = configService.getByVersion(ConfigKeyEnum.goodsShareNotifyImgs.getKey(), acceptData.getPlatform(), + Integer.parseInt(acceptData.getVersion())); + JSONArray array = JSONArray.fromObject(imgs); + + shareInfo.setNotifyPicture(array.size() > 1 ? array.optString(1) : array.optString(0)); + + // 2.0.7鐗堟湰鍚庣殑鎻愮ず鍥剧墖 + imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs207.getKey()); + array = JSONArray.fromObject(imgs); + shareInfo.setNotifyPictureNew(array.size() > 1 ? array.optString(1) : array.optString(0)); + + shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotifyPDD.getKey())); + + // 娣诲姞鍒嗕韩璁板綍 + BigDecimal shareRate = hongBaoManageService.getShareRate(); + BigDecimal shareMoney = VipShopUtil.getGoodsFanLiMoney(goods, shareRate); + shareInfo.setShareMoney("楼" + shareMoney.toString()); + + try { + ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId, + Constant.SOURCE_TYPE_VIP, false); + shareInfo.setShareId(shareRecord.getRedisKey()); + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + + String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); + + String commentText = ""; + String recommendText = ""; + String qtemplate = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); + recommendText = qtemplate.replace("[鍟嗗搧鏍囬]", goods.getGoodsName()); + + recommendText = recommendText.replace("鎺ㄨ崘鐞嗙敱:[鎺ㄨ崘璇璢", ""); + + String quickCommentText = configService.get(ConfigKeyEnum.quickSharePDDCommentText.getKey()); + commentText = quickCommentText.replace("[鍘熶环]", goods.getMarketPrice()); + commentText = commentText.replace("[閾炬帴]", jumpLink.getUrl()); + + commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘"); + commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", ""); + recommendText = recommendText.replace("浼樻儬鍒�:[鍒搁潰棰漖鍏�", ""); + + shareInfo.setRecommendText(deleteBlankLine(recommendText)); + shareInfo.setCommentText(deleteBlankLine(commentText)); + + // 璁剧疆璇勮鏂囨湰閫夐」 + shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getCommentText(), inviteCode, + VipShopUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)))); + + out.print(JsonUtil.loadTrueResult( + JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); + + // 寮傛鎿嶄綔 + com.yeshi.fanli.util.ThreadUtil.run(new Runnable() { + @Override + public void run() { + // 寮傛鎿嶄綔 娣诲姞鍒嗕韩璁板綍 + UserShareGoodsHistory history = new UserShareGoodsHistory(); + history.setUser(new UserInfo(uid)); + history.setHongbao(shareMoney); + history.setCreateTime(new Date()); + history.setGoodsType(Constant.SOURCE_TYPE_VIP); + history.setTkCode(null); + history.setLink(null); + history.setQuanLink(null); + history.setGoodsId(goodsId); + history.setPostPicture(goods.getGoodsThumbUrl()); + history.setShareImg(jumpLink.getUrl()); + List<String> imgList = goods.getGoodsDetailPictures(); + if (imgList == null) { + imgList = new ArrayList<>(); + } + history.setPictures(JsonUtil.getGson().toJson(imgList)); + shareGoodsService.addShareGoodsHistory(history); + } + }); + } + + /** + * 鑻忓畞鏄撹喘鍒嗕韩 + * @Title: createSuningShare + * @Description: + * @param acceptData + * @param uid + * @param goodsId + * @param source + * @param needGoods + * @param out + * void 杩斿洖绫诲瀷 + * @throws + */ + public void createSuningShare(AcceptData acceptData, Long uid, String goodsId, String source, boolean needGoods, + PrintWriter out) { + String[] sts = SuningUtil.getGoodsIdDetail(goodsId); + SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(sts[1], sts[0]); + if (goods == null) { + out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佸凡涓嬫灦")); + return; + } + + String couponLink = goods.getCouponInfo().getCouponUrl(); + + String jumpLink = SuningApiUtil.convertLink(SuningUtil.getProductUrl(sts[0], sts[1]), + StringUtil.isNullOrEmpty(couponLink) ? null : couponLink, SuningApiUtil.PID_SHARE, uid + ""); + + ShareInfoVO shareInfo = new ShareInfoVO(); + shareInfo.setClickUrl(jumpLink); + shareInfo.setWxErCode(jumpLink); + shareInfo.setCommentTexts(new ArrayList<>()); + shareInfo.setRule(configService.get(ConfigKeyEnum.shareRuleLinkSuning.getKey())); + if (goods.getCommodityInfo().getPictureUrl() != null && goods.getCommodityInfo().getPictureUrl().size() > 0) + shareInfo.setPictUrl(goods.getCommodityInfo().getPictureUrl().get(0).getPicUrl()); + if (needGoods) { + shareInfo + .setGoodsInfo(GoodsDetailVOFactory.convertSuningGoods(goods, + new ConfigParamsDTO(hongBaoManageService.getFanLiRate(), + hongBaoManageService.getShareRate(), Constant.MAX_REWARD_RATE, + hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)))); + } + + String template = shareGoodsTextTemplateService.getTextTemplateByVIP(uid); + String shareText = shareGoodsTextTemplateService.createContentSuning(template, goods, jumpLink); + shareInfo.setShareText(shareText); + + String descText = shareText.replace(goods.getCommodityInfo().getCommodityName(), "").trim(); + if (descText.startsWith("\\r\\n")) { + descText = descText.substring(0); + } + shareInfo.setDescText(descText); + + // + String imgs = configService.getByVersion(ConfigKeyEnum.goodsShareNotifyImgs.getKey(), acceptData.getPlatform(), + Integer.parseInt(acceptData.getVersion())); + JSONArray array = JSONArray.fromObject(imgs); + + shareInfo.setNotifyPicture(array.size() > 1 ? array.optString(1) : array.optString(0)); + + // 2.0.7鐗堟湰鍚庣殑鎻愮ず鍥剧墖 + imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs207.getKey()); + array = JSONArray.fromObject(imgs); + shareInfo.setNotifyPictureNew(array.size() > 1 ? array.optString(1) : array.optString(0)); + + shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotifySuning.getKey())); + + // 娣诲姞鍒嗕韩璁板綍 + BigDecimal shareRate = hongBaoManageService.getShareRate(); + BigDecimal shareMoney = SuningUtil.getGoodsFanLiMoney(goods, shareRate); + shareInfo.setShareMoney("楼" + shareMoney.toString()); + + try { + ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, + Long.parseLong(sts[1]), Constant.SOURCE_TYPE_SUNING, false); + shareInfo.setShareId(shareRecord.getRedisKey()); + } catch (Exception e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + + String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); + + String commentText = ""; + String recommendText = ""; + String qtemplate = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); + recommendText = qtemplate.replace("[鍟嗗搧鏍囬]", goods.getCommodityInfo().getCommodityName()); + + recommendText = recommendText.replace("鎺ㄨ崘鐞嗙敱:[鎺ㄨ崘璇璢", ""); + + String quickCommentText = configService.get(ConfigKeyEnum.quickSharePDDCommentText.getKey()); + commentText = quickCommentText.replace("[鍘熶环]", goods.getCommodityInfo().getCommodityPrice()); + commentText = commentText.replace("[閾炬帴]", jumpLink); + + commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘"); + commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", ""); + recommendText = recommendText.replace("浼樻儬鍒�:[鍒搁潰棰漖鍏�", ""); + + shareInfo.setRecommendText(deleteBlankLine(recommendText)); + shareInfo.setCommentText(deleteBlankLine(commentText)); + + // 璁剧疆璇勮鏂囨湰閫夐」 + shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getCommentText(), inviteCode, + SuningUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)))); + + out.print(JsonUtil.loadTrueResult( + JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); + + // 寮傛鎿嶄綔 + com.yeshi.fanli.util.ThreadUtil.run(new Runnable() { + @Override + public void run() { + // 寮傛鎿嶄綔 娣诲姞鍒嗕韩璁板綍 + UserShareGoodsHistory history = new UserShareGoodsHistory(); + history.setUser(new UserInfo(uid)); + history.setHongbao(shareMoney); + history.setCreateTime(new Date()); + history.setGoodsType(Constant.SOURCE_TYPE_VIP); + history.setTkCode(null); + history.setLink(null); + history.setQuanLink(null); + history.setGoodsId(Long.parseLong(sts[1])); + if (goods.getCommodityInfo().getPictureUrl() != null + && goods.getCommodityInfo().getPictureUrl().size() > 0) + history.setPostPicture(goods.getCommodityInfo().getPictureUrl().get(0).getPicUrl()); + history.setShareImg(jumpLink); + List<SuningGoodsImg> pictureList = goods.getCommodityInfo().getPictureUrl(); + List<String> imgList = new ArrayList<>(); + if (pictureList != null) { + for (SuningGoodsImg gi : pictureList) + imgList.add(gi.getPicUrl()); } history.setPictures(JsonUtil.getGson().toJson(imgList)); shareGoodsService.addShareGoodsHistory(history); @@ -1088,7 +1410,7 @@ out.print(JsonUtil.loadFalseResult(5, e.getMsg())); return; } - + // 鏌ヨ鏄惁鏈夊垎浜� UserShareGoodsHistory userShareHistory = shareGoodsService.getShareGoodsHistory(uid, goods.getAuctionId()); String token = ""; @@ -1108,7 +1430,7 @@ StringUtil.isNullOrEmpty(goodsLink.getCouponLink()) ? goodsLink.getAuctionUrl() : goodsLink.getCouponLink()); } - String content = shareGoodsTextTemplateService.createContentTB(template, goods, token, hasCoupon); + String content = shareGoodsTextTemplateService.createContentTB(template, goods, token, hasCoupon); JSONObject data = new JSONObject(); data.put("content", content); out.print(JsonUtil.loadTrueResult(data)); @@ -1201,8 +1523,8 @@ String shortLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", uid + ""); -// // 鍒涘缓鍙d护 -// String token = PinDuoDuoApiUtil.createGenerate(goodsId); + // // 鍒涘缓鍙d护 + // String token = PinDuoDuoApiUtil.createGenerate(goodsId); // 鐢熸垚鍒嗕韩鍐呭 String content = shareGoodsTextTemplateService.createContentPDD(template, goods, shortLink, hasCoupon); @@ -1377,7 +1699,11 @@ JSONArray array = new JSONArray(); JSONObject data = new JSONObject(); - List<UserShareGoodsGroup> list = userShareGoodsGroupService.listByRecordId(recordId); + boolean notBackSuVip = false; + if (!VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) + notBackSuVip = true; + + List<UserShareGoodsGroup> list = userShareGoodsGroupService.listByRecordId(recordId, notBackSuVip); if (list == null || list.size() == 0) { data.put("title", "鍒嗕韩鍟嗗搧"); data.put("count", 0); @@ -1410,7 +1736,7 @@ } } - ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(), + ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion()); Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) @@ -1482,7 +1808,7 @@ } GoodsDetailVO goodsDetail = null; - ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(), + ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion()); paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate()); @@ -1517,7 +1843,7 @@ String template = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); template = template.replace("[鍟嗗搧鏍囬]", goodsDetail.getTitle()).replace("[閿�閲廬", goodsDetail.getSalesCount()); - if (StringUtil.isNullOrEmpty(goodsDetail.getDescription())) { + if (!StringUtil.isNullOrEmpty(goodsDetail.getDescription())) { template = template.replace("[鎺ㄨ崘璇璢", goodsDetail.getDescription()); } else { template = template.replace("鎺ㄨ崘璇�:[鎺ㄨ崘璇璢", ""); -- Gitblit v1.8.0