From dc5be7d38446f70e6ff86df311119c32b41fe7f8 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 28 十一月 2020 16:37:05 +0800 Subject: [PATCH] 大淘客搜索接口升级 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java | 1106 +++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 665 insertions(+), 441 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 78bf5ab..0e9c4c1 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 @@ -10,22 +10,28 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import org.springframework.core.task.TaskExecutor; +import com.yeshi.fanli.entity.SystemEnum; +import com.yeshi.fanli.exception.taobao.TaoBaoConvertLinkException; +import com.yeshi.fanli.service.manger.goods.TaoBaoLinkManager; +import com.yeshi.fanli.util.*; +import com.yeshi.fanli.util.StringUtil; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import org.yeshi.utils.BigDecimalUtil; -import org.yeshi.utils.DateUtil; -import org.yeshi.utils.HttpUtil; -import org.yeshi.utils.JsonUtil; +import org.yeshi.utils.*; import org.yeshi.utils.taobao.TbImgUtil; 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.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,43 +40,31 @@ 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; +import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.entity.taobao.TaoBaoLink; -import com.yeshi.fanli.entity.taobao.TaoKeAppInfo; +import com.yeshi.common.entity.taobao.TaoKeAppInfo; 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; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.config.ConfigService; -import com.yeshi.fanli.service.inter.config.SystemClientParamsService; -import com.yeshi.fanli.service.inter.dynamic.DynamicInfoService; -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.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; -import com.yeshi.fanli.service.inter.user.SpreadUserImgService; 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; @@ -79,9 +73,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; @@ -92,12 +90,11 @@ @Controller @RequestMapping("api/v2/share") public class ShareControllerV2 { - - @Resource(name = "taskExecutor") - private TaskExecutor executor; - @Resource private ShareGoodsService shareGoodsService; + + @Resource + private TaoBaoLinkManager taoBaoLinkManager; @Resource private ConfigService configService; @@ -106,7 +103,7 @@ private HongBaoManageService hongBaoManageService; @Resource - private MonitorService monitorService; + private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; @Resource private UserShareGoodsRecordService userShareGoodsRecordService; @@ -114,8 +111,6 @@ @Resource private UserShareGoodsGroupService userShareGoodsGroupService; - @Resource - private CommonGoodsService commonGoodsService; @Resource private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; @@ -139,16 +134,7 @@ private ShareGoodsTextTemplateService shareGoodsTextTemplateService; @Resource - private SystemClientParamsService systemClientParamsService; - - @Resource - private DynamicInfoService dynamicInfoService; - - @Resource private UserInfoExtraService userInfoExtraService; - - @Resource - private SpreadUserImgService spreadUserImgService; @Resource private BusinessEmergent110Service businessEmergent110Service; @@ -177,7 +163,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 +183,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 +206,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; + } + /** * 鍒涘缓娣樺疂鍒嗕韩淇℃伅 * @@ -301,11 +302,11 @@ // 娣樼ぜ閲戝垱寤哄垎浜� if (source != null && "taolijin".equals(source)) {// 娣樼ぜ閲戝垎浜垱寤� - createTaoLijin(uid, goodsId, totalNum, relationId, request, out); + createTaoLijin(uid, goodsId, totalNum, relationId,acceptData, request, out); return; } else {// 鏅�氬垎浜垱寤� createCommonTaoBaoShare(acceptData.getPlatform(), acceptData.getVersion(), goodsId, inviteCode, uid, - needGoods, relationId, out); + needGoods, relationId,acceptData, out); return; } @@ -321,7 +322,7 @@ * @param request * @param out */ - public void createTaoLijin(Long uid, Long auctionId, int totalNum, String relationId, HttpServletRequest request, + public void createTaoLijin(Long uid, Long auctionId, int totalNum, String relationId,AcceptData acceptData, HttpServletRequest request, PrintWriter out) { try { TaoBaoGoodsBrief goods = null; @@ -368,7 +369,7 @@ return; } - String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&tid=%s", configService.getH5Host(), + String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&tid=%s", configService.getH5Host(SystemInfoUtil.getSystem(acceptData)), Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), auctionId + "", AESUtil.encrypt(tljId + "", Constant.UIDAESKEY)); String shortLink = HttpUtil.getShortLink(url); @@ -388,8 +389,11 @@ taoBaoLink.setTaoToken(quanToken); } } + + SystemEnum system= SystemInfoUtil.getSystem(acceptData); + shareInfo.setToken(TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); - shareInfo.setRule(configService.get(ConfigKeyEnum.shareSingleGoodsRule.getKey())); + shareInfo.setRule(configService.getValue(ConfigKeyEnum.shareSingleGoodsRule.getKey(),system)); shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(goods.getPictUrl(), 500)); // 鏃犲埜 @@ -400,7 +404,7 @@ if (StringUtil.isNullOrEmpty(goods.getCouponInfo())) { String text = shareGoodsTextTemplateService.getCommonTemplate(uid); if (StringUtil.isNullOrEmpty(text)) - text = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey()); + text = configService.getValue(ConfigKeyEnum.goodsShareTextNoCoupon.getKey(),system); shareText = text.replace("{鏍囬}", goods.getTitle()).replace("{鍟嗗搧鍘熶环}", MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + ""); } else// 鏈夊埜 @@ -427,19 +431,19 @@ shareInfo.setDescText(descText); - String imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey()); + String imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs.getKey(),system); JSONArray array = JSONArray.fromObject(imgs); shareInfo.setNotifyPicture(array.optString(0)); // 2.0.7鐗堟湰鍚庣殑鎻愮ず鍥剧墖 - imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs207.getKey()); + imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs207.getKey(),system); array = JSONArray.fromObject(imgs); shareInfo.setNotifyPictureNew(array.optString(0)); - shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotify.getKey())); + shareInfo.setNotifyDesc(configService.getValue(ConfigKeyEnum.goodsShareNotify.getKey(),system)); // 娣诲姞鍒嗕韩璁板綍 - BigDecimal rate = hongBaoManageService.getShareRate(); + BigDecimal rate = hongBaoManageService.getShareRate(acceptData.getSystem()); BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(goods, rate); shareInfo.setShareMoney("楼" + shareMoney.toString()); try { @@ -485,24 +489,26 @@ } catch (Exception e) { LogHelper.errorDetailInfo(e, "鍒嗕韩鍑洪敊:uid:" + uid + "auctionId:" + auctionId, ""); out.print(JsonUtil.loadFalseResult("鍒涘缓鍒嗕韩鍑洪敊")); - businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + "")); + businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""),SystemInfoUtil.getSystem(acceptData)); } } public void createCommonTaoBaoShare(String platform, String version, Long goodsId, String inviteCode, Long uid, - boolean needGoods, String relationId, PrintWriter out) { + boolean needGoods, String relationId,AcceptData acceptData, PrintWriter out) { + + SystemEnum system=SystemInfoUtil.getSystem(acceptData); try { ShareInfoVO shareInfo = new ShareInfoVO(); - TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, goodsId, relationId); + TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(uid, goodsId, relationId,null); if (taoBaoLink != null && taoBaoLink.getGoods() != null && needGoods) { - ConfigParamsDTO dto = hongBaoManageService.getShowComputeRate(platform, version); + ConfigParamsDTO dto = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version,acceptData.getSystem()); 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(), + String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(SystemInfoUtil.getSystem(acceptData)), Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), goodsId + ""); @@ -513,10 +519,10 @@ shareInfo.setClickUrl(url); shareInfo.setToken(TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); - shareInfo.setRule(configService.get(ConfigKeyEnum.shareSingleGoodsRule.getKey())); + shareInfo.setRule(configService.getValue(ConfigKeyEnum.shareSingleGoodsRule.getKey(),system)); shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500)); - String commentTextStr = configService.get(ConfigKeyEnum.shareSingleGoodsCommentText.getKey()); + String commentTextStr = configService.getValue(ConfigKeyEnum.shareSingleGoodsCommentText.getKey(),system); List<String> commentTexts = new ArrayList<>(); if (!StringUtil.isNullOrEmpty(commentTextStr)) { JSONArray array = JSONArray.fromObject(commentTextStr); @@ -536,78 +542,61 @@ } shareInfo.setCommentTexts(commentTexts); - String shareText = ""; - // 鏃犲埜 - String shopType = taoBaoLink.getGoods().getUserType() == 0 ? TaoBaoConstant.SHARE_PRICE_TAOBAO - : TaoBaoConstant.SHARE_PRICE_TM; + TaoBaoGoodsBrief goods = taoBaoLink.getGoods(); - if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { - String text = shareGoodsTextTemplateService.getCommonTemplate(uid); - if (StringUtil.isNullOrEmpty(text)) - text = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey()); - shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle()).replace("{鍟嗗搧鍘熶环}", - MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + ""); - } else// 鏈夊埜 - { - String text = shareGoodsTextTemplateService.geteCouponTemplate(uid); - if (StringUtil.isNullOrEmpty(text)) - text = configService.get(ConfigKeyEnum.goodsShareTextCoupon.getKey()); - - shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle()) - .replace("{鍟嗗搧鍘熶环}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "") - .replace("{浼樻儬鍒搁潰棰潁", - MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString()) - .replace("{浼樻儬鍒镐环}", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + ""); + boolean coupon = false; + if (!StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { + coupon = true; } - shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType) - .replace("{鏈堥攢閲弣", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day())) - .replace("{棰嗗埜鐭摼}", shortLink).replace("{娣樺彛浠", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken())); - + String template = shareGoodsTextTemplateService.getTextTemplateByTB(uid); + 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(descText); - - + 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.getValue(ConfigKeyEnum.quickShareTBCommentText.getKey(),system), + 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.getValue(ConfigKeyEnum.taobaoShareQrcodeText.getKey(),system), + 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.getValue(ConfigKeyEnum.taobaoShareQrcodeText.getKey(),system), 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)); + Integer.parseInt(version),system); JSONArray array = JSONArray.fromObject(imgs); shareInfo.setNotifyPicture(array.optString(0)); // 2.0.7鐗堟湰鍚庣殑鎻愮ず鍥剧墖 - imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs207.getKey()); + imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs207.getKey(),system); array = JSONArray.fromObject(imgs); shareInfo.setNotifyPictureNew(array.optString(0)); - shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotify.getKey())); + shareInfo.setNotifyDesc(configService.getValue(ConfigKeyEnum.goodsShareNotify.getKey(),system)); // 鍒嗕韩閲戦 - BigDecimal rate = hongBaoManageService.getShareRate(); + BigDecimal rate = hongBaoManageService.getShareRate(acceptData.getSystem()); BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate); shareInfo.setShareMoney("楼" + shareMoney.toString()); @@ -627,15 +616,18 @@ String commentText = ""; String recommendText = ""; if (VersionUtil.greaterThan_2_0_7(platform, version)) { - TaoBaoGoodsBrief goods = taoBaoLink.getGoods(); - String template = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); - recommendText = template.replace("[鍟嗗搧鏍囬]", goods.getTitle()); - if (StringUtil.isNullOrEmpty(goods.getDescription())) { + String template2 = configService.getValue(ConfigKeyEnum.quickShareGoodsText.getKey(),system); + recommendText = template2.replace("[鍟嗗搧鏍囬]", goods.getTitle()); + 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("閿�閲�:[閿�閲廬", ""); @@ -643,29 +635,34 @@ recommendText = recommendText.replace("[閿�閲廬", sales.replace("涓�", "w")); } - String quickCommentText = configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()); + String quickCommentText = configService.getValue(ConfigKeyEnum.quickShareTBCommentText.getKey(),system); 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("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", ""); - recommendText = recommendText.replace("浼樻儬鍒�:[鍒搁潰棰漖鍏�", ""); } else { commentText = commentText.replace("[鍒稿悗浠穄", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + ""); + } + + if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) { + recommendText = recommendText.replace("浼樻儬鍒�:[鍒搁潰棰漖鍏�", ""); + } else { recommendText = recommendText.replace("[鍒搁潰棰漖", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString()); } } else { - recommendText = shareInfo.getDescText(); commentText = shareInfo.getShareText(); + recommendText = shareInfo.getDescText(); } shareInfo.setCommentText(deleteBlankLine(commentText)); 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,acceptData.getSystem()), false))); out.print(JsonUtil.loadTrueResult( JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); @@ -695,10 +692,10 @@ } }); return; - } catch (ShareGoodsException e) { + } catch (TaoBaoConvertLinkException e) { LogHelper.errorDetailInfo(e, "鍒嗕韩鍑洪敊:uid:" + uid + " goodsId:" + goodsId, ""); out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage())); - businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(goodsId + "")); + businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(goodsId + ""),SystemInfoUtil.getSystem(acceptData)); } } @@ -709,8 +706,6 @@ * @param uid * @param goodsId * @param source - * @param goodsType - * @param request * @param out */ public void createJDShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods, @@ -733,41 +728,29 @@ couponUrl = couponInfo.getLink(); } String materialId = "https://item.jd.com/" + goodsId + ".html"; - String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", - uid + ""); + String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_SHARE + "", uid + ""); + if (StringUtil.isNullOrEmpty(jumpLink)) { + jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null,JDApiUtil.POSITION_SHARE + "", uid + ""); + } ShareInfoVO shareInfo = new ShareInfoVO(); shareInfo.setClickUrl(jumpLink); shareInfo.setWxErCode(jumpLink); - shareInfo.setRule(configService.get(ConfigKeyEnum.shareRuleLinkJD.getKey())); + shareInfo.setRule(configService.getValue(ConfigKeyEnum.shareRuleLinkJD.getKey(),SystemInfoUtil.getSystem(acceptData))); shareInfo.setPictUrl(jdGoods.getPicUrl()); 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(),acceptData.getSystem()))); - String shareText = ""; boolean hasCoupon = false; - - // 鍒嗕韩妯℃澘 - ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid); - if (couponInfo == null) { // 鏃犲埜妯℃澘 - if (textTemplate != null) - shareText = textTemplate.getShareJDTextTemplate(); - - if (StringUtil.isNullOrEmpty(shareText)) - shareText = configService.get(ConfigKeyEnum.goodsShareTextNoCouponJD.getKey()); - } else { // 鏈夊埜妯℃澘 + if (couponInfo != null) { hasCoupon = true; - if (textTemplate != null) - shareText = textTemplate.getShareJDTextTemplateCoupon(); - - if (StringUtil.isNullOrEmpty(shareText)) - shareText = configService.get(ConfigKeyEnum.goodsShareTextCouponJD.getKey()); } - shareText = shareGoodsTextTemplateService.createContentByTemplateJD(shareText, uid, jdGoods, jumpLink, - hasCoupon); + + String template = shareGoodsTextTemplateService.getTextTemplateByJD(uid); + String shareText = shareGoodsTextTemplateService.createContentJD(template, jdGoods, jumpLink, hasCoupon); shareInfo.setShareText(shareText); String descText = shareText.replace(jdGoods.getSkuName(), "").trim(); @@ -777,20 +760,20 @@ shareInfo.setDescText(descText); String imgs = configService.getByVersion(ConfigKeyEnum.goodsShareNotifyImgs.getKey(), acceptData.getPlatform(), - Integer.parseInt(acceptData.getVersion())); + Integer.parseInt(acceptData.getVersion()),SystemInfoUtil.getSystem(acceptData)); 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()); + imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs207.getKey(),SystemInfoUtil.getSystem(acceptData)); array = JSONArray.fromObject(imgs); shareInfo.setNotifyPictureNew(array.size() > 1 ? array.optString(1) : array.optString(0)); - shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotifyJD.getKey())); + shareInfo.setNotifyDesc(configService.getValue(ConfigKeyEnum.goodsShareNotifyJD.getKey(),SystemInfoUtil.getSystem(acceptData))); // 娣诲姞鍒嗕韩璁板綍 - BigDecimal shareRate = hongBaoManageService.getShareRate(); + BigDecimal shareRate = hongBaoManageService.getShareRate(acceptData.getSystem()); BigDecimal shareMoney = JDUtil.getGoodsFanLiMoney(jdGoods, shareRate); shareInfo.setShareMoney("楼" + shareMoney.toString()); try { @@ -810,31 +793,35 @@ String commentText = ""; String recommendText = ""; if (VersionUtil.greaterThan_2_0_7(acceptData.getPlatform(), acceptData.getVersion())) { - String template = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); - recommendText = template.replace("[鍟嗗搧鏍囬]", jdGoods.getSkuName()); - // 鏃犳帹鑽愯 + String template2 = configService.getValue(ConfigKeyEnum.quickShareGoodsText.getKey(),SystemInfoUtil.getSystem(acceptData)); + 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")); } - - String quickCommentText = configService.get(ConfigKeyEnum.quickShareJDCommentText.getKey()); - commentText = quickCommentText.replace("[鍘熶环]", jdGoods.getPrice().toString()); - commentText = commentText.replace("[閾炬帴]", jumpLink); - if (couponInfo == null) { - commentText = commentText.replace("棰嗗埜鎶㈣喘", "鎶㈣喘"); - commentText = commentText.replace("銆愬埜鍚庝环銆慬鍒稿悗浠穄鍏�", ""); + + BigDecimal price = jdGoods.getPrice(); + JDPingouInfo pinGouInfo = jdGoods.getPinGouInfo(); + if (pinGouInfo != null) { + price = pinGouInfo.getPingouPrice(); + } + + String template3 = configService.getValue(ConfigKeyEnum.quickShareJDCommentText.getKey(),SystemInfoUtil.getSystem(acceptData)); + 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()); - recommendText = recommendText.replace("[鍒搁潰棰漖", - BigDecimalUtil.getWithNoZera(JDUtil.getShowCouponInfo(jdGoods).getDiscount()).toString()); } + commentText = commentText.replace("[閾炬帴]", jumpLink); } else { commentText = shareInfo.getShareText(); recommendText = shareInfo.getDescText(); @@ -844,11 +831,14 @@ // 璁剧疆璇勮鏂囨湰閫夐」 shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getCommentText(), inviteCode, - JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getFanLiRate()))); + JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem())))); out.print(JsonUtil.loadTrueResult( JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); + + final String jumpLinkNew=jumpLink; + // 寮傛鎿嶄綔 final JDGoods goods = jdGoods; com.yeshi.fanli.util.ThreadUtil.run(new Runnable() { @@ -865,7 +855,7 @@ history.setQuanLink(null); history.setGoodsId(goodsId); history.setPostPicture(goods.getPicUrl()); - history.setShareImg(jumpLink); + history.setShareImg(jumpLinkNew); List<String> imgList = goods.getImageList(); if (imgList == null) { @@ -876,12 +866,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"); } - /** * 鎷煎澶氬垎浜� @@ -908,44 +896,31 @@ String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", uid + ""); + SystemEnum system=SystemInfoUtil.getSystem(acceptData); + ShareInfoVO shareInfo = new ShareInfoVO(); shareInfo.setClickUrl(jumpLink); shareInfo.setWxErCode(jumpLink); shareInfo.setCommentTexts(new ArrayList<>()); - shareInfo.setRule(configService.get(ConfigKeyEnum.shareRuleLinkPDD.getKey())); + shareInfo.setRule(configService.getValue(ConfigKeyEnum.shareRuleLinkPDD.getKey(),SystemInfoUtil.getSystem(acceptData))); shareInfo.setPictUrl(goods.getGoodsImageUrl()); if (needGoods) { shareInfo .setGoodsInfo(GoodsDetailVOFactory.convertPDDGoods(goods, - new ConfigParamsDTO(hongBaoManageService.getFanLiRate(), - hongBaoManageService.getShareRate(), Constant.MAX_REWARD_RATE, - hongBaoManageService.getVIPFanLiRate()))); - } - - 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(ConfigKeyEnum.goodsShareTextNocouponPDD.getKey()); - } else { - hasCoupon = true; - if (textTemplate != null) - template = textTemplate.getSharePDDTextTemplateCoupon(); - - if (StringUtil.isNullOrEmpty(template)) - template = configService.get(ConfigKeyEnum.goodsShareTextCouponPDD.getKey()); + new ConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()), + hongBaoManageService.getShareRate(acceptData.getSystem()), Constant.MAX_REWARD_RATE, + hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem())))); } // 鍒涘缓鍙d护 - String token = PinDuoDuoApiUtil.createGenerate(goodsId); + // String token = PinDuoDuoApiUtil.createGenerate(goodsId); - // 鐢熸垚鍒嗕韩鍐呭 - String shareText = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, jumpLink, - hasCoupon, token); + 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); String descText = shareText.replace(goods.getGoodsName(), "").trim(); @@ -956,20 +931,20 @@ // String imgs = configService.getByVersion(ConfigKeyEnum.goodsShareNotifyImgs.getKey(), acceptData.getPlatform(), - Integer.parseInt(acceptData.getVersion())); + Integer.parseInt(acceptData.getVersion()),system); 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()); + imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs207.getKey(),system); array = JSONArray.fromObject(imgs); shareInfo.setNotifyPictureNew(array.size() > 1 ? array.optString(1) : array.optString(0)); - shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotifyPDD.getKey())); + shareInfo.setNotifyDesc(configService.getValue(ConfigKeyEnum.goodsShareNotifyPDD.getKey(),system)); // 娣诲姞鍒嗕韩璁板綍 - BigDecimal shareRate = hongBaoManageService.getShareRate(); + BigDecimal shareRate = hongBaoManageService.getShareRate(acceptData.getSystem()); BigDecimal shareMoney = PinDuoDuoUtil.getGoodsFanLiMoney(goods, shareRate); shareInfo.setShareMoney("楼" + shareMoney.toString()); @@ -990,7 +965,7 @@ String commentText = ""; String recommendText = ""; if (VersionUtil.greaterThan_2_0_7(acceptData.getPlatform(), acceptData.getVersion())) { - String qtemplate = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); + String qtemplate = configService.getValue(ConfigKeyEnum.quickShareGoodsText.getKey(),system); recommendText = qtemplate.replace("[鍟嗗搧鏍囬]", goods.getGoodsName()); // 鎬婚攢閲� @@ -1006,7 +981,7 @@ } recommendText = recommendText.replace("鎺ㄨ崘鐞嗙敱:[鎺ㄨ崘璇璢", ""); - String quickCommentText = configService.get(ConfigKeyEnum.quickSharePDDCommentText.getKey()); + String quickCommentText = configService.getValue(ConfigKeyEnum.quickSharePDDCommentText.getKey(),system); commentText = quickCommentText.replace("[鍘熶环]", MoneyBigDecimalUtil .div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100)).setScale(2).toString()); commentText = commentText.replace("[閾炬帴]", jumpLink); @@ -1030,8 +1005,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,acceptData.getSystem())))); out.print(JsonUtil.loadTrueResult( JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); @@ -1067,6 +1042,316 @@ } /** + * 鍞搧浼氬垎浜� + * @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; + } + + SystemEnum system=SystemInfoUtil.getSystem(acceptData); + + 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.getValue(ConfigKeyEnum.shareRuleLinkVIP.getKey(),system)); + shareInfo.setPictUrl(goods.getGoodsThumbUrl()); + if (needGoods) { + shareInfo + .setGoodsInfo(GoodsDetailVOFactory.convertVIPGoods(goods, + new ConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()), + hongBaoManageService.getShareRate(acceptData.getSystem()), Constant.MAX_REWARD_RATE, + hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem())))); + } + + 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.goodsShareNotifyImgsVIP.getKey(), acceptData.getPlatform(), + Integer.parseInt(acceptData.getVersion()),system); + shareInfo.setNotifyPicture(imgs); + shareInfo.setNotifyPictureNew(imgs); + + shareInfo.setNotifyDesc(configService.getValue(ConfigKeyEnum.goodsShareNotifyVIP.getKey(),system)); + + // 娣诲姞鍒嗕韩璁板綍 + BigDecimal shareRate = hongBaoManageService.getShareRate(acceptData.getSystem()); + 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.getValue(ConfigKeyEnum.quickShareGoodsText.getKey(),system); + recommendText = qtemplate.replace("[鍟嗗搧鏍囬]", goods.getGoodsName()); + recommendText = recommendText.replace("閿�閲�:[閿�閲廬", ""); + recommendText = recommendText.replace("鎺ㄨ崘鐞嗙敱:[鎺ㄨ崘璇璢", ""); + recommendText = recommendText.replace("浼樻儬鍒�:[鍒搁潰棰漖鍏�", ""); + + String quickCommentText = configService.getValue(ConfigKeyEnum.quickShareVIPCommentText.getKey(),system); + commentText = quickCommentText.replace("[鍦ㄥ敭浠穄", BigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMarketPrice())).toString()); + commentText = commentText.replace("[閾炬帴]", jumpLink.getUrl()); + commentText = commentText.replace("[鎶樻墸浠穄", "" +MoneyBigDecimalUtil.getWithNoZera(new BigDecimal(goods.getVipPrice()))); + + shareInfo.setRecommendText(deleteBlankLine(recommendText)); + shareInfo.setCommentText(deleteBlankLine(commentText)); + + // 璁剧疆璇勮鏂囨湰閫夐」 + shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getCommentText(), inviteCode, + VipShopUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem())))); + + 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<>(); + } + + if (imgList.size() > 10) { + imgList = imgList.subList(0, 9); + } + + 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; + } + + SystemEnum system=SystemInfoUtil.getSystem(acceptData); + + 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.getValue(ConfigKeyEnum.shareRuleLinkSuning.getKey(),system)); + 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(acceptData.getSystem()), + hongBaoManageService.getShareRate(acceptData.getSystem()), Constant.MAX_REWARD_RATE, + hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem())))); + } + + String template = shareGoodsTextTemplateService.getTextTemplateBySuNing(uid); + //String shareText = shareGoodsTextTemplateService.createQuickShareTextSuNing(template, goods, jumpLink); + + String shareText = shareGoodsTextTemplateService.createCommonShareTextSuNing(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()),system); + JSONArray array = JSONArray.fromObject(imgs); + + shareInfo.setNotifyPicture(array.size() > 1 ? array.optString(1) : array.optString(0)); + + // 2.0.7鐗堟湰鍚庣殑鎻愮ず鍥剧墖 + imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs207.getKey(),system); + array = JSONArray.fromObject(imgs); + shareInfo.setNotifyPictureNew(array.size() > 1 ? array.optString(1) : array.optString(0)); + + shareInfo.setNotifyDesc(configService.getValue(ConfigKeyEnum.goodsShareNotifySuning.getKey(),system)); + + // 娣诲姞鍒嗕韩璁板綍 + BigDecimal shareRate = hongBaoManageService.getShareRate(acceptData.getSystem()); + 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 commodityPrice = goods.getCommodityInfo().getCommodityPrice(); + if (StringUtil.isNullOrEmpty(commodityPrice)) { + commodityPrice = goods.getCommodityInfo().getSnPrice(); + } + + String commentText = ""; + String recommendText = ""; + String qtemplate = configService.getValue(ConfigKeyEnum.quickShareGoodsText.getKey(),system); + recommendText = qtemplate.replace("[鍟嗗搧鏍囬]", goods.getCommodityInfo().getCommodityName()); + + recommendText = recommendText.replace("鎺ㄨ崘鐞嗙敱:[鎺ㄨ崘璇璢", ""); + + + String quickCommentText = configService.getValue(ConfigKeyEnum.quickShareSuNingCommentText.getKey(),system); + commentText = quickCommentText.replace("[鍘熶环]", BigDecimalUtil.getWithNoZera(new BigDecimal(commodityPrice)).toString()); + commentText = commentText.replace("[閾炬帴]", jumpLink); + + + String salesCountMidea = ""; + Integer count = Integer.parseInt(goods.getCommodityInfo().getMonthSales()); + if (count < 10000) { + salesCountMidea = count + ""; + } else { + double sales = count; + salesCountMidea = String.format("%.1f", sales / 10000); + salesCountMidea = salesCountMidea + "涓�"; + } + if (StringUtil.isNullOrEmpty(salesCountMidea) || salesCountMidea.equals("0")) { + recommendText = recommendText.replace("閿�閲�:[閿�閲廬", ""); + } else { + recommendText = recommendText.replace("[閿�閲廬", salesCountMidea.replace("涓�", "w")); + } + + + if (goods.getCouponInfo() != null && !StringUtil.isNullOrEmpty(goods.getCouponInfo().getCouponUrl())) {// 鏈夊埜 + BigDecimal amount = new BigDecimal(goods.getCouponInfo().getCouponValue()); + BigDecimal startFee = new BigDecimal(goods.getCouponInfo().getBounsLimit()); + BigDecimal zkPrice = new BigDecimal(commodityPrice); + BigDecimal couponPrice = zkPrice; + if (zkPrice.compareTo(startFee) >= 0) { + couponPrice = zkPrice.subtract(amount); + } + recommendText = recommendText.replace("[鍒搁潰棰漖", + BigDecimalUtil.getWithNoZera(new BigDecimal(goods.getCouponInfo().getCouponValue())).toString()); + commentText = commentText.replace("[鍒稿悗浠穄",BigDecimalUtil.getWithNoZera(couponPrice).toString()); + } else { + 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,acceptData.getSystem())))); + + 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); + } + }); + } + + /** * 棰勮鍒嗕韩妯℃澘 * * @param acceptData @@ -1077,7 +1362,7 @@ * @param out */ @RequestMapping(value = "viewShareTextTemplate", method = RequestMethod.POST) - public void viewShareTextTemplate(AcceptData acceptData, Long uid, String template, Integer goodsType, Long goodsId, + public void viewShareTextTemplate(AcceptData acceptData, Long uid, String template, Integer goodsType, String goodsId, Long tljId, Boolean hasCoupon, PrintWriter out) { if (uid == null) { out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); @@ -1089,23 +1374,28 @@ return; } - if (goodsType == null || goodsType > 3 || goodsType < 1) { - out.print(JsonUtil.loadFalseResult(3, "骞冲彴绫诲瀷涓嶆纭�")); - return; - } - if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { - createTaoBaoViewText(goodsType, uid, template, goodsId, tljId, hasCoupon, out); + createTaoBaoViewText(goodsType, uid, template,Long.parseLong(goodsId) , tljId, hasCoupon, out); return; } if (goodsType == Constant.SOURCE_TYPE_JD) { - createJDViewText(goodsType, uid, template, goodsId, hasCoupon, out); + createJDViewText(goodsType, uid, template, Long.parseLong(goodsId), hasCoupon, out); return; } if (goodsType == Constant.SOURCE_TYPE_PDD) { - createPDDViewText(goodsType, uid, template, goodsId, hasCoupon, out); + createPDDViewText(goodsType, uid, template, Long.parseLong(goodsId), hasCoupon, out); + return; + } + + if (goodsType == Constant.SOURCE_TYPE_VIP) { + createVIPViewText(goodsType, uid, template, Long.parseLong(goodsId), hasCoupon, out); + return; + } + + if (goodsType == Constant.SOURCE_TYPE_SUNING) { + createSuNingViewText(goodsType, uid, template, goodsId, hasCoupon, out); return; } } @@ -1121,7 +1411,7 @@ * @param hasCoupon * @param out */ - public void createTaoBaoViewText(Integer goodsType, Long uid, String template, Long goodsId, Long tljId, + private void createTaoBaoViewText(Integer goodsType, Long uid, String template, Long goodsId, Long tljId, Boolean hasCoupon, PrintWriter out) { TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goodsId); if (goods == null) @@ -1140,49 +1430,13 @@ template = getShareTemplate(goodsType, uid, hasCoupon, tljId); } - // 鏍¢獙鍒告ā鏉挎槸鍚︽纭� - if (hasCoupon) { - // 鏈夊埜鍟嗗搧 - if (tljId != null) { - try { - shareGoodsTextTemplateService.isTaoLiJinTemplateRight(template); - } catch (ShareGoodsTextTemplateException e) { - out.print(JsonUtil.loadFalseResult(5, e.getMsg())); - return; - } - } else { - try { - shareGoodsTextTemplateService.isCouponTemplateRight(template); - } catch (ShareGoodsTextTemplateException e) { - out.print(JsonUtil.loadFalseResult(5, e.getMsg())); - return; - } - } - } else { - // 鏅�氬晢鍝� - try { - shareGoodsTextTemplateService.isCommonTemplateRight(template); - } catch (ShareGoodsTextTemplateException e) { - out.print(JsonUtil.loadFalseResult(5, e.getMsg())); - return; - } + // 鏍¢獙妯℃澘鏄惁姝g‘ + try { + shareGoodsTextTemplateService.verifyRightTB(template); + } catch (ShareGoodsTextTemplateException e) { + out.print(JsonUtil.loadFalseResult(5, e.getMsg())); + return; } - - String url = null; - if (tljId != null) { - UserTaoLiJinRecord userTaoLiJinRecord = userTaoLiJinRecordService.selectByPrimaryKey(tljId); - if (userTaoLiJinRecord == null) { - out.print(JsonUtil.loadFalseResult(5, "娣樼ぜ閲戦鍙栭摼鎺ヤ笉瀛樺湪")); - return; - } - url = userTaoLiJinRecord.getSendUrl(); - } else { - url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(), - Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), - goods.getAuctionId() + ""); - } - - String shortLink = HttpUtil.getShortLink(url); // 鏌ヨ鏄惁鏈夊垎浜� UserShareGoodsHistory userShareHistory = shareGoodsService.getShareGoodsHistory(uid, goods.getAuctionId()); @@ -1197,14 +1451,13 @@ app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY); app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET); app.setPid(TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT); - TaoBaoGoodsBrief goodsLink = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app); + TaoBaoGoodsBrief goodsLink = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app,null,null); if (goodsLink != null) token = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), StringUtil.isNullOrEmpty(goodsLink.getCouponLink()) ? goodsLink.getAuctionUrl() : goodsLink.getCouponLink()); } - String content = shareGoodsTextTemplateService.createContentByTemplate(template, uid, goods, token, shortLink, - hasCoupon, tljId); + String content = shareGoodsTextTemplateService.createContentTB(template, goods, token, hasCoupon); JSONObject data = new JSONObject(); data.put("content", content); out.print(JsonUtil.loadTrueResult(data)); @@ -1217,11 +1470,10 @@ * @param template * @param goodsType * @param goodsId - * @param tljId * @param hasCoupon * @param out */ - public void createJDViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon, + private void createJDViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon, PrintWriter out) { JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(goodsId); if (goods == null) { @@ -1234,23 +1486,11 @@ } // 鏍¢獙鍒告ā鏉挎槸鍚︽纭� - if (hasCoupon) { - // 鏈夊埜鍟嗗搧 - try { - shareGoodsTextTemplateService.isCouponTemplateRightJD(template); - } catch (ShareGoodsTextTemplateException e) { - out.print(JsonUtil.loadFalseResult(5, e.getMsg())); - return; - } - - } else { - // 鏅�氬晢鍝� - try { - shareGoodsTextTemplateService.isCommonTemplateRightJD(template); - } catch (ShareGoodsTextTemplateException e) { - out.print(JsonUtil.loadFalseResult(5, e.getMsg())); - return; - } + try { + shareGoodsTextTemplateService.verifyRightJD(template); + } catch (ShareGoodsTextTemplateException e) { + out.print(JsonUtil.loadFalseResult(5, e.getMsg())); + return; } String couponUrl = null; @@ -1259,11 +1499,10 @@ couponUrl = couponInfo.getLink(); } String materialId = "https://item.jd.com/" + goodsId + ".html"; - String shortLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", + String shortLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,JDApiUtil.POSITION_SHARE + "", uid + ""); - String content = shareGoodsTextTemplateService.createContentByTemplateJD(template, uid, goods, shortLink, - hasCoupon); + String content = shareGoodsTextTemplateService.createContentJD(template, goods, shortLink, hasCoupon); JSONObject data = new JSONObject(); data.put("content", content); out.print(JsonUtil.loadTrueResult(data)); @@ -1276,11 +1515,10 @@ * @param template * @param goodsType * @param goodsId - * @param tljId * @param hasCoupon * @param out */ - public void createPDDViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon, + private void createPDDViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon, PrintWriter out) { PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); if (goods == null) { @@ -1293,23 +1531,11 @@ } // 鏍¢獙鍒告ā鏉挎槸鍚︽纭� - if (hasCoupon) { - // 鏈夊埜鍟嗗搧 - try { - shareGoodsTextTemplateService.isCouponTemplateRightPDD(template); - } catch (ShareGoodsTextTemplateException e) { - out.print(JsonUtil.loadFalseResult(5, e.getMsg())); - return; - } - - } else { - // 鏅�氬晢鍝� - try { - shareGoodsTextTemplateService.isCommonTemplateRightPDD(template); - } catch (ShareGoodsTextTemplateException e) { - out.print(JsonUtil.loadFalseResult(5, e.getMsg())); - return; - } + try { + shareGoodsTextTemplateService.verifyRightPDD(template); + } catch (ShareGoodsTextTemplateException e) { + out.print(JsonUtil.loadFalseResult(5, e.getMsg())); + return; } // // 鍒涘缓h5杩炴帴 @@ -1322,18 +1548,90 @@ String shortLink = PinDuoDuoApiUtil.getPromotionUrl(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", uid + ""); - // 鍒涘缓鍙d护 - String token = PinDuoDuoApiUtil.createGenerate(goodsId); + // // 鍒涘缓鍙d护 + // String token = PinDuoDuoApiUtil.createGenerate(goodsId); // 鐢熸垚鍒嗕韩鍐呭 - String content = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, shortLink, - hasCoupon, token); + String content = shareGoodsTextTemplateService.createContentPDD(template, goods, shortLink, hasCoupon); JSONObject data = new JSONObject(); data.put("content", content); out.print(JsonUtil.loadTrueResult(data)); } + /** + * 鍞搧浼氬垎浜� + * @param goodsType + * @param uid + * @param template + * @param goodsId + * @param hasCoupon + * @param out + */ + private void createVIPViewText(Integer goodsType, Long uid, String template, Long goodsId, Boolean hasCoupon, + PrintWriter out) { + VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(goodsId + ""); + if (goods == null) { + out.print(JsonUtil.loadFalseResult(4, "鍟嗗搧宸蹭笅鏋�")); + return; + } + + if (StringUtil.isNullOrEmpty(template)) { + template = getShareTemplate(goodsType, uid, hasCoupon, null); + } + + // 鏍¢獙鍒告ā鏉挎槸鍚︽纭� + try { + shareGoodsTextTemplateService.verifyRightVIP(template); + } catch (ShareGoodsTextTemplateException e) { + out.print(JsonUtil.loadFalseResult(5, e.getMsg())); + return; + } + + VIPConvertResultDTO jumpLink = VipShopApiUtil.convertLink(goodsId + "", VipShopUtil.getShareChanTag(uid)); + + // 鐢熸垚鍒嗕韩鍐呭 + String content = shareGoodsTextTemplateService.createContentVIP(template, goods, jumpLink.getUrl()); + + JSONObject data = new JSONObject(); + data.put("content", content); + out.print(JsonUtil.loadTrueResult(data)); + } + + + + private void createSuNingViewText(Integer goodsType, Long uid, String template, String goodsId, Boolean hasCoupon, + PrintWriter out) { + String[] ids = SuningUtil.getGoodsIdDetail(goodsId); + SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(ids[1], ids[0]); + if (goods == null) { + out.print(JsonUtil.loadFalseResult(4, "鍟嗗搧宸蹭笅鏋�")); + return; + } + + if (StringUtil.isNullOrEmpty(template)) { + template = getShareTemplate(goodsType, uid, hasCoupon, null); + } + + // 鏍¢獙鍒告ā鏉挎槸鍚︽纭� + try { + shareGoodsTextTemplateService.verifyRightSuNing(template); + } catch (ShareGoodsTextTemplateException e) { + out.print(JsonUtil.loadFalseResult(5, e.getMsg())); + return; + } + + String couponLink = goods.getCouponInfo().getCouponUrl(); + String jumpLink = SuningApiUtil.convertLink(SuningUtil.getProductUrl(ids[0], ids[1]), + StringUtil.isNullOrEmpty(couponLink) ? null : couponLink, SuningApiUtil.PID_SHARE, uid + ""); + + // 鐢熸垚鏅�氬垎浜唴瀹� + String content = shareGoodsTextTemplateService.createCommonShareTextSuNing(template, goods, jumpLink); + + JSONObject data = new JSONObject(); + data.put("content", content); + out.print(JsonUtil.loadTrueResult(data)); + } /** * 鑾峰彇鍒嗕韩妯℃澘 * @@ -1345,58 +1643,15 @@ private String getShareTemplate(int goodsType, Long uid, boolean hasCoupon, Long tljId) { String template = ""; if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { - if (hasCoupon) { - if (tljId != null) { - template = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid); - if (StringUtil.isNullOrEmpty(template)) - template = configTaoLiJinService.getValueByKey("goods_share_text", new Date()); - } else { - template = shareGoodsTextTemplateService.geteCouponTemplate(uid); - if (StringUtil.isNullOrEmpty(template)) - template = configService.get(ConfigKeyEnum.goodsShareTextCoupon.getKey()); - } - - } else { - template = shareGoodsTextTemplateService.getCommonTemplate(uid); - if (StringUtil.isNullOrEmpty(template)) - template = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey()); - } + template = shareGoodsTextTemplateService.getTextTemplateByTB(uid); } else if (goodsType == Constant.SOURCE_TYPE_JD) { - ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid); - if (hasCoupon) { - if (textTemplate != null) { - template = textTemplate.getShareJDTextTemplateCoupon(); - } - if (StringUtil.isNullOrEmpty(template)) { - template = configService.get(ConfigKeyEnum.goodsShareTextCouponJD.getKey()); - } - } else { - if (textTemplate != null) { - template = textTemplate.getShareJDTextTemplate(); - } - - if (StringUtil.isNullOrEmpty(template)) { - template = configService.get(ConfigKeyEnum.goodsShareTextNoCouponJD.getKey()); - } - } + template = shareGoodsTextTemplateService.getTextTemplateByJD(uid); } else if (goodsType == Constant.SOURCE_TYPE_PDD) { - ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid); - if (hasCoupon) { - if (textTemplate != null) { - template = textTemplate.getSharePDDTextTemplateCoupon(); - } - if (StringUtil.isNullOrEmpty(template)) { - template = configService.get(ConfigKeyEnum.goodsShareTextCouponPDD.getKey()); - } - } else { - if (textTemplate != null) { - template = textTemplate.getSharePDDTextTemplate(); - } - - if (StringUtil.isNullOrEmpty(template)) { - template = configService.get(ConfigKeyEnum.goodsShareTextNocouponPDD.getKey()); - } - } + template = shareGoodsTextTemplateService.getTextTemplateByPDD(uid); + } else if (goodsType == Constant.SOURCE_TYPE_VIP) { + template = shareGoodsTextTemplateService.getTextTemplateByVIP(uid); + } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { + template = shareGoodsTextTemplateService.getTextTemplateBySuNing(uid); } return template; } @@ -1435,22 +1690,22 @@ */ @RequestMapping(value = "getShareTextTemplateRules", method = RequestMethod.POST) public void getShareTextTemplateRules(AcceptData acceptData, Integer goodsType, Long tljId, PrintWriter out) { - if (goodsType == null || goodsType > 3 || goodsType < 1) { - out.print(JsonUtil.loadFalseResult(3, "骞冲彴绫诲瀷涓嶆纭�")); - return; - } - + SystemEnum system=SystemInfoUtil.getSystem(acceptData); if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { if (tljId != null) { out.print( JsonUtil.loadTrueResult(configTaoLiJinService.getValueByKey("share_goods_rules", new Date()))); } else { - out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRules.getKey()))); + out.print(JsonUtil.loadTrueResult(configService.getValue(ConfigKeyEnum.shareGoodsTemplateRules.getKey(),system))); } } else if (goodsType == Constant.SOURCE_TYPE_JD) { - out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRulesJD.getKey()))); + out.print(JsonUtil.loadTrueResult(configService.getValue(ConfigKeyEnum.shareGoodsTemplateRulesJD.getKey(),system))); } else if (goodsType == Constant.SOURCE_TYPE_PDD) { - out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRulesPDD.getKey()))); + out.print(JsonUtil.loadTrueResult(configService.getValue(ConfigKeyEnum.shareGoodsTemplateRulesPDD.getKey(),system))); + } else if (goodsType == Constant.SOURCE_TYPE_VIP) { + out.print(JsonUtil.loadTrueResult(configService.getValue(ConfigKeyEnum.shareGoodsTemplateRulesVIP.getKey(),system))); + } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { + out.print(JsonUtil.loadTrueResult(configService.getValue(ConfigKeyEnum.shareGoodsTemplateRulesSuNing.getKey(),system))); } } @@ -1471,46 +1726,17 @@ return; } - if (goodsType == null || goodsType > 3 || goodsType < 1) { - out.print(JsonUtil.loadFalseResult(3, "骞冲彴绫诲瀷涓嶆纭�")); - return; - } - try { if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { - // 鏍¢獙鍒告ā鏉挎槸鍚︽纭� - if (hasCoupon) { - // 鏈夊埜鍟嗗搧 - if (tljId != null) { - shareGoodsTextTemplateService.isTaoLiJinTemplateRight(template); - shareGoodsTextTemplateService.saveTaoLiJinTemplate(uid, template); - } else { - shareGoodsTextTemplateService.isCouponTemplateRight(template); - shareGoodsTextTemplateService.saveCouponTemplate(uid, template); - } - } else { - // 鏅�氬晢鍝� - shareGoodsTextTemplateService.isCommonTemplateRight(template); - shareGoodsTextTemplateService.saveCommonTemplate(uid, template); - } + shareGoodsTextTemplateService.saveTemplateTB(uid, template); } else if (goodsType == Constant.SOURCE_TYPE_JD) { - if (hasCoupon) { - shareGoodsTextTemplateService.isCouponTemplateRightJD(template); - shareGoodsTextTemplateService.saveCouponTemplateJD(uid, template); - } else { - shareGoodsTextTemplateService.isCommonTemplateRightJD(template); - shareGoodsTextTemplateService.saveCommonTemplateJD(uid, template); - out.print(JsonUtil.loadTrueResult("")); - } + shareGoodsTextTemplateService.saveTemplateJD(uid, template); } else if (goodsType == Constant.SOURCE_TYPE_PDD) { - if (hasCoupon) { - shareGoodsTextTemplateService.isCouponTemplateRightPDD(template); - shareGoodsTextTemplateService.saveCouponTemplatePDD(uid, template); - } else { - shareGoodsTextTemplateService.isCommonTemplateRightPDD(template); - shareGoodsTextTemplateService.saveCommonTemplatePDD(uid, template); - out.print(JsonUtil.loadTrueResult("")); - } + shareGoodsTextTemplateService.saveTemplatePDD(uid, template); + } else if (goodsType == Constant.SOURCE_TYPE_VIP) { + shareGoodsTextTemplateService.saveTemplateVIP(uid, template); + } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { + shareGoodsTextTemplateService.saveTemplateSuNing(uid, template); } } catch (ShareGoodsTextTemplateException e) { out.print(JsonUtil.loadFalseResult(5, e.getMsg())); @@ -1529,40 +1755,23 @@ * @param out */ @RequestMapping(value = "resetShareTextTemplate", method = RequestMethod.POST) - public void resetShareTextTemplate(AcceptData acceptData, Long uid, Long goodsId, Long tljId, Boolean hasCoupon, + public void resetShareTextTemplate(AcceptData acceptData, Long uid, String goodsId, Long tljId, Boolean hasCoupon, Integer goodsType, PrintWriter out) { if (uid == null) { out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); return; } - if (goodsType == null || goodsType > 3 || goodsType < 1) { - out.print(JsonUtil.loadFalseResult(3, "骞冲彴绫诲瀷涓嶆纭�")); - return; - } - if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { - if (hasCoupon) { - if (tljId != null) { - shareGoodsTextTemplateService.resetTaoLijinTemplate(uid); - } else { - shareGoodsTextTemplateService.resetCouponTemplate(uid); - } - } else { - shareGoodsTextTemplateService.resetCommonTemplate(uid); - } + shareGoodsTextTemplateService.resetCommonTemplate(uid); } else if (goodsType == Constant.SOURCE_TYPE_JD) { - if (hasCoupon) { - shareGoodsTextTemplateService.resetCouponTemplateJD(uid); - } else { - shareGoodsTextTemplateService.resetCommonTemplateJD(uid); - } + shareGoodsTextTemplateService.resetCommonTemplateJD(uid); } else if (goodsType == Constant.SOURCE_TYPE_PDD) { - if (hasCoupon) { - shareGoodsTextTemplateService.resetCouponTemplatePDD(uid); - } else { - shareGoodsTextTemplateService.resetCommonTemplatePDD(uid); - } + shareGoodsTextTemplateService.resetCommonTemplatePDD(uid); + } else if (goodsType == Constant.SOURCE_TYPE_VIP) { + shareGoodsTextTemplateService.resetCommonTemplateVIP(uid); + } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { + shareGoodsTextTemplateService.resetCommonTemplateSuNing(uid); } if (goodsId != null) { @@ -1590,7 +1799,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); @@ -1623,8 +1836,8 @@ } } - ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(), - acceptData.getVersion()); + ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), + acceptData.getVersion(),acceptData.getSystem()); Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); @@ -1683,7 +1896,7 @@ } @RequestMapping(value = "getShareTextQuick", method = RequestMethod.POST) - public void getShareTextQuick(AcceptData acceptData, Long goodsId, Integer goodsType, Long uid, PrintWriter out) { + public void getShareTextQuick(AcceptData acceptData, String goodsId, Integer goodsType, Long uid, PrintWriter out) { if (uid == null) { out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�")); return; @@ -1695,15 +1908,15 @@ } GoodsDetailVO goodsDetail = null; - ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(), - acceptData.getVersion()); - paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate()); + ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), + acceptData.getVersion(),acceptData.getSystem()); + paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem())); if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { - TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goodsId); + TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(Long.parseLong(goodsId)); if (goods == null) { try { - goods = redisManager.getTaoBaoGoodsBrief(goodsId); + goods = redisManager.getTaoBaoGoodsBrief(Long.parseLong(goodsId)); } catch (TaobaoGoodsDownException e) { goods = null; } @@ -1712,14 +1925,25 @@ goodsDetail = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO); } } else if (goodsType == Constant.SOURCE_TYPE_JD) { - JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(goodsId); + JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); if (goods != null) { goodsDetail = GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO); } } else if (goodsType == Constant.SOURCE_TYPE_PDD) { - PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); + PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(Long.parseLong(goodsId)); if (goods != null) { goodsDetail = GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO); + } + } else if (goodsType == Constant.SOURCE_TYPE_VIP) { + VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(goodsId + ""); + if (goods == null) { + goodsDetail = GoodsDetailVOFactory.convertVIPGoods(goods, paramsDTO); + } + } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { + String[] ids = SuningUtil.getGoodsIdDetail(goodsId); + SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(ids[1], ids[0]); + if (goods != null) { + goodsDetail = GoodsDetailVOFactory.convertSuningGoods(goods, paramsDTO); } } @@ -1728,9 +1952,9 @@ return; } - String template = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); + String template = configService.getValue(ConfigKeyEnum.quickShareGoodsText.getKey(),SystemInfoUtil.getSystem(acceptData)); 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