From 21c1c197ec0dba6da332bf4119c262267dcfb191 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期二, 26 五月 2020 10:29:03 +0800 Subject: [PATCH] 粉丝信息同步调整 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java | 201 ++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 179 insertions(+), 22 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 89ad2ca..7088861 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 @@ -27,6 +27,7 @@ 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.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; @@ -35,6 +36,7 @@ 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.jd.JDGoods; import com.yeshi.fanli.entity.system.ConfigKeyEnum; @@ -55,6 +57,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; @@ -82,6 +85,8 @@ 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 +109,9 @@ @Resource private HongBaoManageService hongBaoManageService; + + @Resource + private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; @Resource private MonitorService monitorService; @@ -242,6 +250,13 @@ createPDDShare(acceptData, uid, goodsId, source, needGoods, out); return; } + + // 鍞搧浼� + if (goodsType == Constant.SOURCE_TYPE_VIP) { + createPDDShare(acceptData, uid, goodsId, source, needGoods, out); + return; + } + } public static String getERCodeContentNew(String template, TaoBaoGoodsBrief goods, String token) { @@ -254,6 +269,13 @@ 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"); + 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; } @@ -492,7 +514,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); } @@ -561,15 +583,14 @@ taoBaoLink.getGoods(), shareInfo.getToken())); } - 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())); - } + // 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())); + // } // 鎻愮ず鍥炬枃鍐呭 String imgs = configService.getByVersion(ConfigKeyEnum.goodsShareNotifyImgs.getKey(), platform, @@ -611,7 +632,11 @@ 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()); @@ -646,8 +671,9 @@ shareInfo.setRecommendText(deleteBlankLine(recommendText)); // 璁剧疆璇勮鏂囨湰閫夐」 - shareInfo.setCommentTextChoiceList(getCommentChoiceList(shareInfo.getCommentText(), null, inviteCode, - TaoBaoUtil.getGoodsHongBaoMoney(taoBaoLink.getGoods(), hongBaoManageService.getVIPFanLiRate()))); + shareInfo.setCommentTextChoiceList( + getCommentChoiceList(shareInfo.getCommentText(), null, inviteCode, TaoBaoUtil.getGoodsHongBaoMoney( + taoBaoLink.getGoods(), hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)))); out.print(JsonUtil.loadTrueResult( JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); @@ -726,8 +752,8 @@ 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) { @@ -816,7 +842,7 @@ // 璁剧疆璇勮鏂囨湰閫夐」 shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getCommentText(), inviteCode, - JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getVIPFanLiRate()))); + JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)))); out.print(JsonUtil.loadTrueResult( JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); @@ -889,7 +915,7 @@ .setGoodsInfo(GoodsDetailVOFactory.convertPDDGoods(goods, new ConfigParamsDTO(hongBaoManageService.getFanLiRate(), hongBaoManageService.getShareRate(), Constant.MAX_REWARD_RATE, - hongBaoManageService.getVIPFanLiRate()))); + hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)))); } // 鍒涘缓鍙d护 @@ -986,7 +1012,7 @@ // 璁剧疆璇勮鏂囨湰閫夐」 shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getCommentText(), inviteCode, - PinDuoDuoUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getVIPFanLiRate()))); + PinDuoDuoUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)))); out.print(JsonUtil.loadTrueResult( JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); @@ -1012,6 +1038,133 @@ if (goodsGalleryUrls != null) { imgList = Arrays.asList(goodsGalleryUrls); } + if (imgList == null) { + imgList = new ArrayList<>(); + } + history.setPictures(JsonUtil.getGson().toJson(imgList)); + shareGoodsService.addShareGoodsHistory(history); + } + }); + } + + /** + * 鎷煎澶氬垎浜� + * + * @param acceptData + * @param uid + * @param goodsId + * @param source + * @param out + */ + 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; + } + + String jumpLink = VipShopApiUtil.convertLink(goodsId + "", VipShopUtil.getShareChanTag(uid)); + + ShareInfoVO shareInfo = new ShareInfoVO(); + shareInfo.setClickUrl(jumpLink); + shareInfo.setWxErCode(jumpLink); + 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); + 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); + + 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); + List<String> imgList = goods.getGoodsDetailPictures(); if (imgList == null) { imgList = new ArrayList<>(); } @@ -1390,8 +1543,12 @@ JSONArray array = new JSONArray(); JSONObject data = new JSONObject(); + + boolean notBackSuVip = false; + if (!VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) + notBackSuVip = true; - List<UserShareGoodsGroup> list = userShareGoodsGroupService.listByRecordId(recordId); + List<UserShareGoodsGroup> list = userShareGoodsGroupService.listByRecordId(recordId, notBackSuVip); if (list == null || list.size() == 0) { data.put("title", "鍒嗕韩鍟嗗搧"); data.put("count", 0); @@ -1424,7 +1581,7 @@ } } - ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(), + ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion()); Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) @@ -1496,7 +1653,7 @@ } GoodsDetailVO goodsDetail = null; - ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(), + ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion()); paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate()); @@ -1531,7 +1688,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