From 626d711cb15896055c13fe344eb7fcc824589715 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期四, 19 十二月 2019 15:38:42 +0800 Subject: [PATCH] 帮助中心 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java | 425 ++++++++++++++++++++++++++++++++-------------------- 1 files changed, 262 insertions(+), 163 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 d6ef71e..46c8c13 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 @@ -21,6 +21,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.yeshi.fanli.dto.ConfigParamsDTO; import com.yeshi.fanli.dto.jd.JDCouponInfo; import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; import com.yeshi.fanli.dto.share.ShareGoodsRecordDTO; @@ -31,14 +32,15 @@ import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinRecord; 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.goods.CommonGoods; import com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate; import com.yeshi.fanli.entity.jd.JDGoods; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.entity.taobao.TaoBaoLink; import com.yeshi.fanli.entity.taobao.TaoKeAppInfo; -import com.yeshi.fanli.exception.ShareGoodsException; import com.yeshi.fanli.exception.goods.ShareGoodsTextTemplateException; +import com.yeshi.fanli.exception.share.ShareGoodsException; import com.yeshi.fanli.exception.taobao.TaoKeApiException; import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; import com.yeshi.fanli.exception.tlj.UserTaoLiJinRecordException; @@ -49,23 +51,24 @@ import com.yeshi.fanli.service.inter.goods.CommonGoodsService; import com.yeshi.fanli.service.inter.goods.ShareGoodsService; import com.yeshi.fanli.service.inter.goods.ShareGoodsTextTemplateService; -import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService; import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service; import com.yeshi.fanli.service.inter.monitor.MonitorService; +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; import com.yeshi.fanli.service.inter.user.SpreadUserImgService; -import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService; import com.yeshi.fanli.service.inter.user.UserInfoExtraService; import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService; import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService; +import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService; import com.yeshi.fanli.util.AESUtil; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.MoneyBigDecimalUtil; import com.yeshi.fanli.util.RedisManager; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TaoBaoConstant; +import com.yeshi.fanli.util.VersionUtil; import com.yeshi.fanli.util.cache.JDGoodsCacheUtil; import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil; import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil; @@ -155,20 +158,35 @@ private UserTaoLiJinRecordService userTaoLiJinRecordService; /** - * 鑾峰彇娣樺疂鐨勫垎浜摼鎺� * * @param acceptData - * @param uid -鐢ㄦ埛ID - * @param auctionId-鍟嗗搧ID + * @param uid + * -鐢ㄦ埛ID + * @param goodsId-鍟嗗搧ID + * @param source + * @param totalNum + * @param goodsType + * @param needGoods + * -鏄惁闇�瑕佸晢鍝佷俊鎭� + * @param request * @param out */ @RequestMapping(value = "createShareInfo") public void createShareInfo(AcceptData acceptData, Long uid, Long goodsId, String source, Integer totalNum, - Integer goodsType, HttpServletRequest request, PrintWriter out) { - + Integer goodsType, Boolean needGoods, HttpServletRequest request, PrintWriter out) { if (uid == null || uid <= 0) { out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛ID涓嶈兘涓虹┖")); return; + } + + if (needGoods == null) + needGoods = false; + try { + // 鏃ュ織璁板綍 + String info = String.format("type=share&uid=%s&goodsId=%s&source=%s&goodsType=%s", uid, goodsId, source, + goodsType); + LogHelper.orderInfo(info); + } catch (Exception e) { } UserInfo user = userInfoService.getUserByIdWithMybatis(uid); @@ -184,21 +202,36 @@ // 娣樺疂 if (goodsType == null || goodsType == Constant.SOURCE_TYPE_TAOBAO) { - createTaoBaoShare(acceptData, uid, goodsId, totalNum, source, request, out); + createTaoBaoShare(acceptData, uid, goodsId, totalNum, source, needGoods, request, out); return; } // 浜笢 if (goodsType == Constant.SOURCE_TYPE_JD) { - createJDShare(acceptData, uid, goodsId, source, out); + createJDShare(acceptData, uid, goodsId, source, needGoods, out); return; } // 鎷煎澶� if (goodsType == Constant.SOURCE_TYPE_PDD) { - createPDDShare(acceptData, uid, goodsId, source, out); + createPDDShare(acceptData, uid, goodsId, source, needGoods, out); return; } + } + + public static String getERCodeContent(TaoBaoGoodsBrief goods, String token) { + String content = String.format("銆�%s銆�%s鍏�", goods.getUserType() == 1 ? "T鐚环" : "T瀹濅环", + MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + ""); + content += "\n\r"; + + if (!StringUtil.isNullOrEmpty(goods.getCouponInfo())) { + content += String.format("銆愬埜鍚庝环銆�%s鍏�", TaoBaoUtil.getAfterUseCouplePrice(goods) + ""); + content += "\n\r"; + } + content += "------------"; + content += "\n\r"; + content += "寰╁埗杩欐潯" + token + "锛岄�插叆Tao瀹濆嵆鍙喘涔�"; + return content; } /** @@ -213,9 +246,20 @@ * @param out */ public void createTaoBaoShare(AcceptData acceptData, Long uid, Long goodsId, Integer totalNum, String source, - HttpServletRequest request, PrintWriter out) { + Boolean needGoods, HttpServletRequest request, PrintWriter out) { + if (needGoods == null) + needGoods = false; UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByUid(uid); + UserInfoExtra userExtraInfo = userInfoExtraService.getUserInfoExtra(uid); + String inviteCode = null; + if (userExtraInfo != null) { + if (!StringUtil.isNullOrEmpty(userExtraInfo.getInviteCodeVip())) { + inviteCode = userExtraInfo.getInviteCodeVip(); + } else { + inviteCode = userExtraInfo.getInviteCode(); + } + } String relationId = null; if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null && extraInfo.getRelationValid() == true) @@ -235,7 +279,16 @@ try { ShareInfoVO shareInfo = new ShareInfoVO(); + // 娴嬭瘯 + TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, goodsId, relationId); + + if (taoBaoLink != null && taoBaoLink.getGoods() != null && needGoods) { + ConfigParamsDTO dto = new ConfigParamsDTO(hongBaoManageService.getFanLiRate(), + hongBaoManageService.getShareRate(), Constant.MAX_REWARD_RATE,hongBaoManageService.getVIPFanLiRate()); + GoodsDetailVO goodsInfo = GoodsDetailVOFactory.convertTaoBao(taoBaoLink.getGoods(), dto); + shareInfo.setGoodsInfo(goodsInfo); + } String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(), Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), @@ -247,13 +300,34 @@ } shareInfo.setClickUrl(url); - shareInfo.setToken(taoBaoLink.getTaoToken()); + shareInfo.setToken(TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); shareInfo.setRule(configService.get("share_single_goods_rule")); shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500)); + String commentTextStr = configService.get("share_single_goods_comment_text"); + List<String> commentTexts = new ArrayList<>(); + if (!StringUtil.isNullOrEmpty(commentTextStr)) { + JSONArray array = JSONArray.fromObject(commentTextStr); + for (int i = 0; i < array.size(); i++) { + if (StringUtil.isNullOrEmpty(inviteCode)) { + if (array.optString(i).contains("[閭�璇风爜]")) { + continue; + } + } + if (StringUtil.isNullOrEmpty(inviteCode)) + commentTexts.add(array.optString(i).replace("[涓嬭浇閾炬帴]", Constant.YINGYONGBAO_LINK) + .replace("[娣樺彛浠", shareInfo.getToken())); + else + commentTexts.add(array.optString(i).replace("[涓嬭浇閾炬帴]", Constant.YINGYONGBAO_LINK) + .replace("[閭�璇风爜]", inviteCode).replace("[娣樺彛浠", shareInfo.getToken())); + } + } + shareInfo.setCommentTexts(commentTexts); + String shareText = ""; // 鏃犲埜 - String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "娣樺疂浠�" : "澶╃尗浠�"; + String shopType = taoBaoLink.getGoods().getUserType() == 0 ? TaoBaoConstant.SHARE_PRICE_TAOBAO + : TaoBaoConstant.SHARE_PRICE_TM; if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { String text = shareGoodsTextTemplateService.getCommonTemplate(uid); @@ -276,7 +350,7 @@ shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType) .replace("{鏈堥攢閲弣", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day())) - .replace("{棰嗗埜鐭摼}", shortLink).replace("{娣樺彛浠", taoBaoLink.getTaoToken()); + .replace("{棰嗗埜鐭摼}", shortLink).replace("{娣樺彛浠", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); shareInfo.setShareText(shareText); @@ -285,6 +359,12 @@ descText = descText.substring(0); } shareInfo.setDescText(descText); + // 娴嬭瘯 + // 2.0.2涔嬪墠 + if (!VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) + shareInfo.setClickUrl(getERCodeContent(taoBaoLink.getGoods(), shareInfo.getToken())); + + shareInfo.setWxErCode(getERCodeContent(taoBaoLink.getGoods(), shareInfo.getToken())); // 鎻愮ず鍥炬枃鍐呭 String imgs = configService.get("goods_share_notify_imgs"); @@ -303,7 +383,7 @@ // 鍒嗕韩id try { ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId, - Constant.SOURCE_TYPE_TAOBAO); + Constant.SOURCE_TYPE_TAOBAO, false); shareInfo.setShareId(shareRecord.getRedisKey()); } catch (Exception e) { try { @@ -326,7 +406,7 @@ history.setHongbao(shareMoney); history.setCreateTime(new Date()); history.setGoodsType(UserShareGoodsHistory.TYPE_TAOBAO); - history.setTkCode(taobaoLink.getTaoToken()); + history.setTkCode(TaoBaoUtil.filterTaoToken(taobaoLink.getTaoToken())); history.setLink(taobaoLink.getClickUrl()); history.setQuanLink(taobaoLink.getCouponLink()); history.setGoodsId(taobaoLink.getGoods().getAuctionId()); @@ -367,14 +447,28 @@ public void createTaoLijin(Long uid, Long auctionId, int totalNum, String relationId, HttpServletRequest request, PrintWriter out) { try { - TaoBaoLink taoBaoLink = shareGoodsService.getTaoLiJinLinkForShare(uid, auctionId, relationId); + TaoBaoGoodsBrief goods = null; + try { + goods = TaoKeApiUtil.searchGoodsDetail(auctionId); + } catch (TaobaoGoodsDownException e2) { + e2.printStackTrace(); + } - TaoBaoGoodsBrief goods = taoBaoLink.getGoods(); + if (goods == null) { + out.print(JsonUtil.loadFalseResult("鍟嗗搧宸蹭笅鏋�")); + return; + } + + if (goods.getTkRate() == null || goods.getTkRate().compareTo(new BigDecimal(0)) <= 0) { + // TaoKeApiUtil.specialConvertCoupon(auctionId, app); + + } // 璁$畻鎺ㄥ箍绾㈠寘 - String warningRate = configTaoLiJinService.getValueByKey("warning_value"); + String warningRate = configTaoLiJinService.getValueByKey("warning_value", new Date()); + LogHelper.error("鎺ㄥ箍绾㈠寘姣斾緥:" + warningRate); BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods); - + LogHelper.error("鎺ㄥ箍绾㈠寘:" + spreadMoney); // 鎺ㄥ箍绾㈠寘 涓嶈兘灏忎簬1 if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) { out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佹窐绀奸噾涓嶈冻")); @@ -406,53 +500,51 @@ } shareInfo.setClickUrl(url); + TaoBaoLink taoBaoLink = new TaoBaoLink(); + taoBaoLink.setCouponLink(taoLiJinLink); + taoBaoLink.setClickUrl(taoLiJinLink); + // 鍒涘缓娣樺彛浠� if (!StringUtil.isNullOrEmpty(taoLiJinLink)) {// 閫氳繃绔嬪嵆鎺ㄥ箍鏂瑰紡鑾峰彇娣樺彛浠ゆ垚鍔� String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), taoLiJinLink); if (!StringUtil.isNullOrEmpty(quanToken)) { taoBaoLink.setTaoToken(quanToken); } - } else if (!StringUtil.isNullOrEmpty(taoBaoLink.getClickUrl())) { - String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), - taoBaoLink.getClickUrl()); - if (!StringUtil.isNullOrEmpty(quanToken)) { - taoBaoLink.setTaoToken(quanToken); - } } - shareInfo.setToken(taoBaoLink.getTaoToken()); + shareInfo.setToken(TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); shareInfo.setRule(configService.get("share_single_goods_rule")); - shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500)); + shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(goods.getPictUrl(), 500)); // 鏃犲埜 - String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "娣樺疂浠�" : "澶╃尗浠�"; + String shopType = goods.getUserType() == 0 ? TaoBaoConstant.SHARE_PRICE_TAOBAO + : TaoBaoConstant.SHARE_PRICE_TM; String shareText = ""; - if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { + if (StringUtil.isNullOrEmpty(goods.getCouponInfo())) { String text = shareGoodsTextTemplateService.getCommonTemplate(uid); if (StringUtil.isNullOrEmpty(text)) text = configService.get("goods_share_text_nocoupon"); - shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle()).replace("{鍟嗗搧鍘熶环}", - MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + ""); + shareText = text.replace("{鏍囬}", goods.getTitle()).replace("{鍟嗗搧鍘熶环}", + MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + ""); } else// 鏈夊埜 { String text = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid); if (StringUtil.isNullOrEmpty(text)) - text = configTaoLiJinService.getValueByKey("goods_share_text"); + text = configTaoLiJinService.getValueByKey("goods_share_text", new Date()); - shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle()) - .replace("{鍟嗗搧鍘熶环}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "") - .replace("{浼樻儬鍒搁潰棰潁", - MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString()) + shareText = text.replace("{鏍囬}", goods.getTitle()) + .replace("{鍟嗗搧鍘熶环}", MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + "") + .replace("{浼樻儬鍒搁潰棰潁", MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()).toString()) .replace("{娣樼ぜ閲戦潰棰潁", MoneyBigDecimalUtil.getWithNoZera(spreadMoney).toString()) - .replace("{浼樻儬鍒镐环}", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + ""); + .replace("{浼樻儬鍒镐环}", TaoBaoUtil.getAfterUseCouplePrice(goods) + ""); } shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType) - .replace("{鏈堥攢閲弣", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day())) - .replace("{棰嗗埜鐭摼}", shortLink).replace("{娣樺彛浠", taoBaoLink.getTaoToken()); + .replace("{鏈堥攢閲弣", TaoBaoUtil.getSaleCount(goods.getBiz30day())).replace("{棰嗗埜鐭摼}", shortLink) + .replace("{娣樺彛浠", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); shareInfo.setShareText(shareText); - String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim(); + String descText = shareText.replace(goods.getTitle(), "").trim(); if (descText.startsWith("\\r\\n")) descText = descText.substring(0); @@ -468,11 +560,11 @@ // 娣诲姞鍒嗕韩璁板綍 BigDecimal rate = hongBaoManageService.getShareRate(); - BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate); + BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(goods, rate); shareInfo.setShareMoney("楼" + shareMoney.toString()); try { ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId, - Constant.SOURCE_TYPE_TAOBAO); + Constant.SOURCE_TYPE_TAOBAO, true); shareInfo.setShareId(shareRecord.getRedisKey()); } catch (Exception e) { try { @@ -484,6 +576,7 @@ out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(shareInfo))); final TaoBaoLink taobaoLink = taoBaoLink; + final TaoBaoGoodsBrief finalGoods = goods; // 寮傛鎿嶄綔 com.yeshi.fanli.util.ThreadUtil.run(new Runnable() { @Override @@ -494,13 +587,13 @@ history.setHongbao(shareMoney); history.setCreateTime(new Date()); history.setGoodsType(UserShareGoodsHistory.TYPE_TAOBAO); - history.setTkCode(taobaoLink.getTaoToken()); + history.setTkCode(TaoBaoUtil.filterTaoToken(taobaoLink.getTaoToken())); history.setLink(taobaoLink.getClickUrl()); history.setQuanLink(taobaoLink.getCouponLink()); - history.setGoodsId(taobaoLink.getGoods().getAuctionId()); - history.setPostPicture(taobaoLink.getGoods().getPictUrl()); + history.setGoodsId(finalGoods.getAuctionId()); + history.setPostPicture(finalGoods.getPictUrl()); - List<String> imgList = taobaoLink.getGoods().getImgList(); + List<String> imgList = finalGoods.getImgList(); if (imgList == null) { imgList = new ArrayList<>(); } @@ -509,14 +602,9 @@ } }); return; - } catch (ShareGoodsException e) { + } catch (Exception e) { LogHelper.errorDetailInfo(e, "鍒嗕韩鍑洪敊:uid:" + uid + "auctionId:" + auctionId, ""); - // 鍒嗕韩鍑洪敊鎶ヨ - try { - monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "鍒嗕韩鍑洪敊")); - } catch (Exception e1) { - } - out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage())); + out.print(JsonUtil.loadFalseResult("鍒涘缓鍒嗕韩鍑洪敊")); businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + "")); } } @@ -532,61 +620,61 @@ * @param request * @param out */ - public void createJDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) { - - JDGoods jdGoods = JDApiUtil.queryGoodsDetail(goodsId); + public void createJDShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods, + PrintWriter out) { + JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId); if (jdGoods == null) { - jdGoods = JDApiUtil.getGoodsDetail(goodsId); - } - - if (jdGoods == null) { - out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佹窐宸蹭笅鏋�")); + out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佸凡涓嬫灦")); return; } - // TODO - ShareInfoVO shareInfo = new ShareInfoVO(); - String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&goodsType=%s", configService.getH5Host(), - Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), - goodsId + "", Constant.SOURCE_TYPE_JD); + // String url = String.format("http://%s%s?uid=%s&id=%s", + // configService.getH5Host(), + // Constant.systemCommonConfig.getShareGoodsPagePathJD(), + // AESUtil.encrypt(uid + "", Constant.UIDAESKEY), + // goodsId + ""); - // 鍒哥煭杩炴帴 - String shortLink = HttpUtil.getShortLink(url); - if (!StringUtil.isNullOrEmpty(shortLink)) { - url = shortLink; + String couponUrl = null; + JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(jdGoods); + if (couponInfo != null) { + couponUrl = couponInfo.getLink(); } + String materialId = "https://item.jd.com/" + goodsId + ".html"; + String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", + uid + ""); - shareInfo.setClickUrl(url); + ShareInfoVO shareInfo = new ShareInfoVO(); + shareInfo.setClickUrl(jumpLink); + shareInfo.setWxErCode(jumpLink); shareInfo.setRule(configService.get("share_rule_link_jd")); shareInfo.setPictUrl(jdGoods.getPicUrl()); + shareInfo.setCommentTexts(new ArrayList<>()); + + if (needGoods) + shareInfo.setGoodsInfo(GoodsDetailVOFactory.convertJDGoods(jdGoods, new ConfigParamsDTO( + hongBaoManageService.getFanLiRate(), hongBaoManageService.getShareRate(), Constant.MAX_REWARD_RATE,hongBaoManageService.getVIPFanLiRate()))); String shareText = ""; - String shopType = "浜笢浠�"; + boolean hasCoupon = false; // 鍒嗕韩妯℃澘 - JDCouponInfo couponInfo = jdGoods.getCouponInfo(); - if (couponInfo == null) { - String text = shareGoodsTextTemplateService.getCommonTemplate(uid); - if (StringUtil.isNullOrEmpty(text)) { - text = configService.get("goods_share_text_nocoupon"); - } - shareText = text.replace("{鏍囬}", jdGoods.getSkuName()).replace("{鍟嗗搧鍘熶环}", - MoneyBigDecimalUtil.getWithNoZera(jdGoods.getPrice()) + ""); - } else// 鏈夊埜 - { - String text = shareGoodsTextTemplateService.geteCouponTemplate(uid); - if (StringUtil.isNullOrEmpty(text)) - text = configService.get("goods_share_text_coupon"); + ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid); + if (couponInfo == null) { // 鏃犲埜妯℃澘 + if (textTemplate != null) + shareText = textTemplate.getShareJDTextTemplate(); - shareText = text.replace("{鏍囬}", jdGoods.getSkuName()) - .replace("{鍟嗗搧鍘熶环}", MoneyBigDecimalUtil.getWithNoZera(jdGoods.getPrice()) + "") - .replace("{浼樻儬鍒搁潰棰潁", MoneyBigDecimalUtil.getWithNoZera(couponInfo.getDiscount()) + "") - .replace("{浼樻儬鍒镐环}", JDUtil.getQuanPrice(jdGoods) + ""); + if (StringUtil.isNullOrEmpty(shareText)) + shareText = configService.get("goods_share_text_nocoupon_jd"); + } else { // 鏈夊埜妯℃澘 + hasCoupon = true; + if (textTemplate != null) + shareText = textTemplate.getShareJDTextTemplateCoupon(); + + if (StringUtil.isNullOrEmpty(shareText)) + shareText = configService.get("goods_share_text_coupon_jd"); } - - shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType) - .replace("{鏈堥攢閲弣", JDUtil.getSaleCount(jdGoods.getInOrderCount30Days())).replace("{棰嗗埜鐭摼}", shortLink) - .replace("{娣樺彛浠", null); + shareText = shareGoodsTextTemplateService.createContentByTemplateJD(shareText, uid, jdGoods, jumpLink, + hasCoupon); shareInfo.setShareText(shareText); String descText = shareText.replace(jdGoods.getSkuName(), "").trim(); @@ -595,7 +683,6 @@ } shareInfo.setDescText(descText); - // String imgs = configService.get("goods_share_notify_imgs"); JSONArray array = JSONArray.fromObject(imgs); int p = (int) (array.size() * Math.random()); @@ -610,7 +697,7 @@ shareInfo.setShareMoney("楼" + shareMoney.toString()); try { ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId, - Constant.SOURCE_TYPE_JD); + Constant.SOURCE_TYPE_JD, false); shareInfo.setShareId(shareRecord.getRedisKey()); } catch (Exception e) { try { @@ -657,56 +744,57 @@ * @param source * @param out */ - public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) { - PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(goodsId); + public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods, + PrintWriter out) { + PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); if (goods == null) { out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佸凡涓嬫灦")); return; } + // String url = String.format("http://%s%s?uid=%s&id=%s", + // configService.getH5Host(), + // Constant.systemCommonConfig.getShareGoodsPagePathPDD(), + // AESUtil.encrypt(uid + "", Constant.UIDAESKEY), + // goodsId + ""); + + String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", uid + ""); + ShareInfoVO shareInfo = new ShareInfoVO(); - - // TODO - String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&goodsType=%s", configService.getH5Host(), - Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), - goodsId + "", Constant.SOURCE_TYPE_PDD); - - String shortLink = HttpUtil.getShortLink(url); - if (!StringUtil.isNullOrEmpty(shortLink)) { - url = shortLink; - } - - shareInfo.setClickUrl(url); + shareInfo.setClickUrl(jumpLink); + shareInfo.setWxErCode(jumpLink); + shareInfo.setCommentTexts(new ArrayList<>()); shareInfo.setRule(configService.get("share_rule_link_pdd")); shareInfo.setPictUrl(goods.getGoodsImageUrl()); - - String shareText = ""; - String shopType = "鎷煎澶氫环"; - - // 鏃犲埜 - if (goods.getHasCoupon() == null || !goods.getHasCoupon()) { - String text = shareGoodsTextTemplateService.getCommonTemplate(uid); - if (StringUtil.isNullOrEmpty(text)) - text = configService.get("goods_share_text_nocoupon"); - shareText = text.replace("{鏍囬}", goods.getGoodsName()).replace("{鍟嗗搧鍘熶环}", - MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMinNormalPrice())) + ""); - } else// 鏈夊埜 - { - String text = shareGoodsTextTemplateService.geteCouponTemplate(uid); - if (StringUtil.isNullOrEmpty(text)) - text = configService.get("goods_share_text_coupon"); - - shareText = text.replace("{鏍囬}", goods.getGoodsName()) - .replace("{鍟嗗搧鍘熶环}", - MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMinNormalPrice())) + "") - .replace("{浼樻儬鍒搁潰棰潁", - MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getCouponDiscount())) + "") - .replace("{浼樻儬鍒镐环}", PinDuoDuoUtil.getQuanPrice(goods) + ""); + if (needGoods) { + shareInfo.setGoodsInfo(GoodsDetailVOFactory.convertPDDGoods(goods, new ConfigParamsDTO( + hongBaoManageService.getFanLiRate(), hongBaoManageService.getShareRate(), Constant.MAX_REWARD_RATE,hongBaoManageService.getVIPFanLiRate()))); } - shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType) - .replace("{鏈堥攢閲弣", goods.getSalesTip()).replace("{棰嗗埜鐭摼}", shortLink) - .replace("{娣樺彛浠", null); + String template = ""; + boolean hasCoupon = false; + ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid); + if (goods.getHasCoupon() == null || !goods.getHasCoupon()) { + if (textTemplate != null) + template = textTemplate.getSharePDDTextTemplate(); + + if (StringUtil.isNullOrEmpty(template)) + template = configService.get("goods_share_text_nocoupon_pdd"); + } else { + hasCoupon = true; + if (textTemplate != null) + template = textTemplate.getSharePDDTextTemplateCoupon(); + + if (StringUtil.isNullOrEmpty(template)) + template = configService.get("goods_share_text_coupon_pdd"); + } + + // 鍒涘缓鍙d护 + String token = PinDuoDuoApiUtil.createGenerate(goodsId); + + // 鐢熸垚鍒嗕韩鍐呭 + String shareText = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, jumpLink, + hasCoupon, token); shareInfo.setShareText(shareText); String descText = shareText.replace(goods.getGoodsName(), "").trim(); @@ -731,7 +819,7 @@ try { ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId, - Constant.SOURCE_TYPE_JD); + Constant.SOURCE_TYPE_PDD, false); shareInfo.setShareId(shareRecord.getRedisKey()); } catch (Exception e) { try { @@ -751,7 +839,7 @@ history.setUser(new UserInfo(uid)); history.setHongbao(shareMoney); history.setCreateTime(new Date()); - history.setGoodsType(Constant.SOURCE_TYPE_JD); + history.setGoodsType(Constant.SOURCE_TYPE_PDD); history.setTkCode(null); history.setLink(null); history.setQuanLink(null); @@ -805,12 +893,12 @@ return; } - if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { + if (goodsType == Constant.SOURCE_TYPE_JD) { createJDViewText(goodsType, uid, template, goodsId, hasCoupon, out); return; } - if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { + if (goodsType == Constant.SOURCE_TYPE_PDD) { createPDDViewText(goodsType, uid, template, goodsId, hasCoupon, out); return; } @@ -959,10 +1047,14 @@ } } - String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(), - Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), - goodsId + ""); - String shortLink = HttpUtil.getShortLink(url); + String couponUrl = null; + JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods); + if (couponInfo != null) { + couponUrl = couponInfo.getLink(); + } + String materialId = "https://item.jd.com/" + goodsId + ".html"; + String shortLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", + uid + ""); String content = shareGoodsTextTemplateService.createContentByTemplateJD(template, uid, goods, shortLink, hasCoupon); @@ -972,7 +1064,7 @@ } /** - * 鍒涘缓浜笢鍒嗕韩妯℃澘 + * 鍒涘缓鎷煎澶氬垎浜ā鏉� * * @param uid * @param template @@ -1014,11 +1106,15 @@ } } - // 鍒涘缓h5杩炴帴 - String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(), - Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), - goodsId + ""); - String shortLink = HttpUtil.getShortLink(url); + // // 鍒涘缓h5杩炴帴 + // String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", + // configService.getH5Host(), + // Constant.systemCommonConfig.getShareGoodsPagePath(), + // AESUtil.encrypt(uid + "", Constant.UIDAESKEY), + // goodsId + ""); + // String shortLink = HttpUtil.getShortLink(url); + + String shortLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", uid + ""); // 鍒涘缓鍙d护 String token = PinDuoDuoApiUtil.createGenerate(goodsId); @@ -1047,7 +1143,7 @@ if (tljId != null) { template = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid); if (StringUtil.isNullOrEmpty(template)) - template = configTaoLiJinService.getValueByKey("goods_share_text"); + template = configTaoLiJinService.getValueByKey("goods_share_text", new Date()); } else { template = shareGoodsTextTemplateService.geteCouponTemplate(uid); if (StringUtil.isNullOrEmpty(template)) @@ -1140,7 +1236,8 @@ if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { if (tljId != null) { - out.print(JsonUtil.loadTrueResult(configTaoLiJinService.getValueByKey("share_goods_rules"))); + out.print( + JsonUtil.loadTrueResult(configTaoLiJinService.getValueByKey("share_goods_rules", new Date()))); } else { out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules"))); } @@ -1221,7 +1318,8 @@ * * @param acceptData * @param uid - * @param hasCoupon -鏄惁鏈夊埜 + * @param hasCoupon + * -鏄惁鏈夊埜 * @param out */ @RequestMapping(value = "resetShareTextTemplate", method = RequestMethod.POST) @@ -1237,7 +1335,7 @@ return; } - if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { + if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { if (hasCoupon) { if (tljId != null) { shareGoodsTextTemplateService.resetTaoLijinTemplate(uid); @@ -1247,21 +1345,20 @@ } else { shareGoodsTextTemplateService.resetCommonTemplate(uid); } - } else if (goodsType == Constant.SOURCE_TYPE_JD) { - if (hasCoupon) { + } else if (goodsType == Constant.SOURCE_TYPE_JD) { + if (hasCoupon) { shareGoodsTextTemplateService.resetCouponTemplateJD(uid); } else { shareGoodsTextTemplateService.resetCommonTemplateJD(uid); } - } else if (goodsType == Constant.SOURCE_TYPE_PDD) { - if (hasCoupon) { + } else if (goodsType == Constant.SOURCE_TYPE_PDD) { + if (hasCoupon) { shareGoodsTextTemplateService.resetCouponTemplatePDD(uid); } else { shareGoodsTextTemplateService.resetCommonTemplatePDD(uid); } - } - - + } + if (goodsId != null) { viewShareTextTemplate(acceptData, uid, null, goodsType, goodsId, tljId, hasCoupon, out); return; @@ -1322,6 +1419,8 @@ BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(); BigDecimal shareRate = hongBaoManageService.getShareRate(); + ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,hongBaoManageService.getVIPFanLiRate()); + Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); @@ -1360,7 +1459,7 @@ dataObject.put("totalOrder", goodsGroup.getTotalOrder()); dataObject.put("totalMoney", "楼" + goodsGroup.getTotalMoney()); - GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, null, fanLiRate, shareRate); + GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, paramsDTO); detailVO.setId(commonGoods.getId()); dataObject.put("goods", gson.toJson(detailVO)); array.add(dataObject); -- Gitblit v1.8.0