| | |
| | | BigDecimal fanliMoney) { |
| | | List<ShareGoodsCommentChoiceInfo> list = new ArrayList<>(); |
| | | if (!StringUtil.isNullOrEmpty(token)) |
| | | list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_TOKEN, "淘口令", |
| | | String.format("復製这条%s\n进入【Tao宝】即可抢购", token), true, false)); |
| | | list.add( |
| | | new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_TOKEN, "淘口令", token, true, false)); |
| | | if (!StringUtil.isNullOrEmpty(link)) { |
| | | list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_LINK, "链接", link, true, false)); |
| | | } |
| | |
| | | } |
| | | |
| | | public static String getERCodeContent(String template, TaoBaoGoodsBrief goods, String token) { |
| | | //return template.replace("[淘口令]", 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("[口令]", token); |
| | | if (StringUtil.isNullOrEmpty(goods.getCouponInfo())) { |
| | | commentText= commentText.replace("领券抢购", "抢购"); |
| | | commentText= commentText.replace("【券后价】[券后价]元", ""); |
| | | commentText = commentText.replace("领券抢购", "抢购"); |
| | | commentText = commentText.replace("【券后价】[券后价]元", ""); |
| | | } else { |
| | | commentText= commentText.replace("[券后价]", TaoBaoUtil.getAfterUseCouplePrice(goods) + ""); |
| | | commentText = commentText.replace("[券后价]", TaoBaoUtil.getAfterUseCouplePrice(goods) + ""); |
| | | } |
| | | return commentText; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 创建淘宝分享信息 |
| | | * |
| | |
| | | JSONArray array = JSONArray.fromObject(imgs); |
| | | shareInfo.setNotifyPicture(array.optString(0)); |
| | | |
| | | // 2.0.7版本后的提示图片 |
| | | imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs207.getKey()); |
| | | array = JSONArray.fromObject(imgs); |
| | | shareInfo.setNotifyPictureNew(array.optString(0)); |
| | | |
| | | shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotify.getKey())); |
| | | |
| | | // 添加分享记录 |
| | |
| | | descText = descText.substring(0); |
| | | } |
| | | shareInfo.setDescText(descText); |
| | | |
| | | |
| | | // 测试 |
| | | // 2.0.2之前 |
| | | if (!VersionUtil.greaterThan_2_0_2(platform, version)) |
| | | if (VersionUtil.greaterThan_2_0_7(platform, version)) { |
| | | shareInfo.setClickUrl(getERCodeContentNew(configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()), |
| | | taoBaoLink.getGoods(), shareInfo.getToken())); |
| | | } else if (!VersionUtil.greaterThan_2_0_2(platform, version)) { |
| | | shareInfo.setClickUrl(getERCodeContent(configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), |
| | | taoBaoLink.getGoods(), shareInfo.getToken())); |
| | | } |
| | | |
| | | shareInfo.setWxErCode(getERCodeContent(configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), |
| | | if (VersionUtil.greaterThan_2_0_7(platform, version)) { |
| | | shareInfo.setWxErCode(getERCodeContentNew(configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()), |
| | | taoBaoLink.getGoods(), shareInfo.getToken())); |
| | | |
| | | } else { |
| | | shareInfo.setWxErCode(getERCodeContent(configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), |
| | | taoBaoLink.getGoods(), shareInfo.getToken())); |
| | | } |
| | | |
| | | |
| | | // 提示图文内容 |
| | | String imgs = configService.getByVersion(ConfigKeyEnum.goodsShareNotifyImgs.getKey(), platform, |
| | | Integer.parseInt(version)); |
| | | JSONArray array = JSONArray.fromObject(imgs); |
| | | |
| | | shareInfo.setNotifyPicture(array.optString(0)); |
| | | |
| | | // 2.0.7版本后的提示图片 |
| | | imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs207.getKey()); |
| | | array = JSONArray.fromObject(imgs); |
| | | shareInfo.setNotifyPictureNew(array.optString(0)); |
| | | |
| | | shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotify.getKey())); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | // 设置评论文本选项 |
| | | shareInfo.setCommentTextChoiceList(getCommentChoiceList(shareInfo.getToken(), null, inviteCode, |
| | | TaoBaoUtil.getGoodsHongBaoMoney(taoBaoLink.getGoods(), hongBaoManageService.getFanLiRate()))); |
| | | |
| | | String commentText = ""; |
| | | String recommendText = ""; |
| | | if (VersionUtil.greaterThan_2_0_7(platform, version)){ |
| | | if (VersionUtil.greaterThan_2_0_7(platform, version)) { |
| | | TaoBaoGoodsBrief goods = taoBaoLink.getGoods(); |
| | | String template = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); |
| | | recommendText = template.replace("[商品标题]", goods.getTitle()). |
| | | replace("[销量]", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day())); |
| | | recommendText = template.replace("[商品标题]", goods.getTitle()); |
| | | if (StringUtil.isNullOrEmpty(goods.getDescription())) { |
| | | recommendText = recommendText.replace("推荐语:[推荐语]", ""); |
| | | recommendText = recommendText.replace("推荐理由:[推荐语]", ""); |
| | | } else { |
| | | recommendText = recommendText.replace("[推荐语]", goods.getDescription()); |
| | | } |
| | | |
| | | String sales = TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()); |
| | | if (sales.equals("0")) { |
| | | recommendText = recommendText.replace("销量:[销量]", ""); |
| | | } else { |
| | | recommendText = recommendText.replace("[销量]", sales.replace("万", "w")); |
| | | } |
| | | |
| | | String quickCommentText = configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()); |
| | | commentText = quickCommentText.replace("[原价]", goods.getZkPrice().toString()); |
| | | commentText = quickCommentText.replace("[口令]", 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("优惠券:[券面额]", ""); |
| | | commentText = commentText.replace("领券抢购", "抢购"); |
| | | commentText = commentText.replace("【券后价】[券后价]元", ""); |
| | | recommendText = recommendText.replace("优惠券:[券面额]元", ""); |
| | | } else { |
| | | commentText= commentText.replace("[券后价]", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + ""); |
| | | recommendText = recommendText.replace("[券面额]", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString()); |
| | | commentText = commentText.replace("[券后价]", |
| | | TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + ""); |
| | | recommendText = recommendText.replace("[券面额]", |
| | | MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString()); |
| | | } |
| | | } else { |
| | | recommendText = shareInfo.getDescText(); |
| | | commentText = shareInfo.getShareText(); |
| | | } |
| | | shareInfo.setCommentText(commentText); |
| | | shareInfo.setRecommendText(recommendText); |
| | | |
| | | shareInfo.setCommentText(deleteBlankLine(commentText)); |
| | | shareInfo.setRecommendText(deleteBlankLine(recommendText)); |
| | | |
| | | // 设置评论文本选项 |
| | | shareInfo.setCommentTextChoiceList(getCommentChoiceList(shareInfo.getCommentText(), null, inviteCode, |
| | | TaoBaoUtil.getGoodsHongBaoMoney(taoBaoLink.getGoods(), hongBaoManageService.getFanLiRate()))); |
| | | |
| | | out.print(JsonUtil.loadTrueResult( |
| | | JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); |
| | | |
| | |
| | | |
| | | shareInfo.setNotifyPicture(array.size() > 1 ? array.optString(1) : array.optString(0)); |
| | | |
| | | // 2.0.7版本后的提示图片 |
| | | imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs207.getKey()); |
| | | array = JSONArray.fromObject(imgs); |
| | | shareInfo.setNotifyPictureNew(array.size() > 1 ? array.optString(1) : array.optString(0)); |
| | | |
| | | shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotifyJD.getKey())); |
| | | |
| | | // 添加分享记录 |
| | |
| | | |
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); |
| | | |
| | | // 设置评论文本选项 |
| | | shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getClickUrl(), inviteCode, |
| | | JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getFanLiRate()))); |
| | | |
| | | String commentText = ""; |
| | | String recommendText = ""; |
| | | if (VersionUtil.greaterThan_2_0_7(acceptData.getPlatform(), acceptData.getVersion())){ |
| | | if (VersionUtil.greaterThan_2_0_7(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | String template = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); |
| | | recommendText = template.replace("[商品标题]", jdGoods.getSkuName()). |
| | | replace("[销量]", JDUtil.getSaleCount(jdGoods.getInOrderCount30Days())); |
| | | recommendText = template.replace("[商品标题]", jdGoods.getSkuName()); |
| | | // 无推荐语 |
| | | recommendText = recommendText.replace("推荐语:[推荐语]", ""); |
| | | 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 = quickCommentText.replace("[链接]", jumpLink); |
| | | commentText = commentText.replace("[链接]", jumpLink); |
| | | if (couponInfo == null) { |
| | | commentText= commentText.replace("领券抢购", "抢购"); |
| | | commentText= commentText.replace("【券后价】[券后价]元", ""); |
| | | recommendText = recommendText.replace("优惠券:[券面额]", ""); |
| | | commentText = commentText.replace("领券抢购", "抢购"); |
| | | commentText = commentText.replace("【券后价】[券后价]元", ""); |
| | | recommendText = recommendText.replace("优惠券:[券面额]元", ""); |
| | | } else { |
| | | commentText= commentText.replace("[券后价]", BigDecimalUtil.getWithNoZera(JDUtil.getQuanPrice(jdGoods)).toString()); |
| | | recommendText = recommendText.replace("[券面额]",BigDecimalUtil.getWithNoZera(JDUtil.getShowCouponInfo(jdGoods).getDiscount()).toString()); |
| | | commentText = commentText.replace("[券后价]", |
| | | BigDecimalUtil.getWithNoZera(JDUtil.getQuanPrice(jdGoods)).toString()); |
| | | recommendText = recommendText.replace("[券面额]", |
| | | BigDecimalUtil.getWithNoZera(JDUtil.getShowCouponInfo(jdGoods).getDiscount()).toString()); |
| | | } |
| | | } else { |
| | | commentText = shareInfo.getShareText(); |
| | | recommendText = shareInfo.getDescText(); |
| | | } |
| | | shareInfo.setCommentText(commentText); |
| | | shareInfo.setRecommendText(recommendText); |
| | | shareInfo.setCommentText(deleteBlankLine(commentText)); |
| | | shareInfo.setRecommendText(deleteBlankLine(recommendText)); |
| | | |
| | | // 设置评论文本选项 |
| | | shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getCommentText(), inviteCode, |
| | | JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getFanLiRate()))); |
| | | |
| | | out.print(JsonUtil.loadTrueResult( |
| | | JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | 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"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 拼多多分享 |
| | |
| | | |
| | | shareInfo.setNotifyPicture(array.size() > 1 ? array.optString(1) : array.optString(0)); |
| | | |
| | | // 2.0.7版本后的提示图片 |
| | | imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs207.getKey()); |
| | | array = JSONArray.fromObject(imgs); |
| | | shareInfo.setNotifyPictureNew(array.size() > 1 ? array.optString(1) : array.optString(0)); |
| | | |
| | | shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotifyPDD.getKey())); |
| | | |
| | | // 添加分享记录 |
| | |
| | | |
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); |
| | | |
| | | // 设置评论文本选项 |
| | | shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getClickUrl(), inviteCode, |
| | | PinDuoDuoUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate()))); |
| | | |
| | | String commentText = ""; |
| | | String recommendText = ""; |
| | | if (VersionUtil.greaterThan_2_0_7(acceptData.getPlatform(), acceptData.getVersion())){ |
| | | if (VersionUtil.greaterThan_2_0_7(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | String qtemplate = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); |
| | | recommendText = qtemplate.replace("[商品标题]", goods.getGoodsName()); |
| | | |
| | | |
| | | // 总销量 |
| | | String salesTip = goods.getSalesTip(); |
| | | if (StringUtil.isNullOrEmpty(salesTip)) { |
| | | salesTip = "0"; |
| | | } |
| | | recommendText = recommendText.replace("[销量]", salesTip); |
| | | recommendText = recommendText.replace("推荐语:[推荐语]", ""); |
| | | |
| | | String quickCommentText = configService.get(ConfigKeyEnum.quickSharePDDCommentText.getKey()); |
| | | commentText = quickCommentText.replace("[原价]", MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100)).setScale(2).toString()); |
| | | commentText = quickCommentText.replace("[链接]", jumpLink); |
| | | if (!hasCoupon) { |
| | | commentText= commentText.replace("领券抢购", "抢购"); |
| | | commentText= commentText.replace("【券后价】[券后价]元", ""); |
| | | recommendText = template.replace("优惠券:[券面额]", ""); |
| | | if (salesTip.equals("0")) { |
| | | recommendText = recommendText.replace("销量:[销量]", ""); |
| | | } else { |
| | | commentText= commentText.replace("[券后价]", BigDecimalUtil.getWithNoZera(PinDuoDuoUtil.getQuanPrice(goods)).toString()); |
| | | recommendText = recommendText.replace("[销量]", salesTip.replace("万", "w")); |
| | | recommendText = recommendText.replace("销量", "总销量"); |
| | | } |
| | | recommendText = recommendText.replace("推荐理由:[推荐语]", ""); |
| | | |
| | | String quickCommentText = configService.get(ConfigKeyEnum.quickSharePDDCommentText.getKey()); |
| | | commentText = quickCommentText.replace("[原价]", MoneyBigDecimalUtil |
| | | .div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100)).setScale(2).toString()); |
| | | commentText = commentText.replace("[链接]", jumpLink); |
| | | if (!hasCoupon) { |
| | | commentText = commentText.replace("领券抢购", "抢购"); |
| | | commentText = commentText.replace("【券后价】[券后价]元", ""); |
| | | recommendText = recommendText.replace("优惠券:[券面额]元", ""); |
| | | } else { |
| | | commentText = commentText.replace("[券后价]", |
| | | BigDecimalUtil.getWithNoZera(PinDuoDuoUtil.getQuanPrice(goods)).toString()); |
| | | |
| | | BigDecimal hundred = new BigDecimal(100); |
| | | BigDecimal amount = MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), hundred); |
| | | recommendText = template.replace("[券面额]", BigDecimalUtil.getWithNoZera(amount).toString()); |
| | | recommendText = recommendText.replace("[券面额]", BigDecimalUtil.getWithNoZera(amount).toString()); |
| | | } |
| | | } else { |
| | | commentText = shareInfo.getShareText(); |
| | | recommendText = shareInfo.getDescText(); |
| | | } |
| | | shareInfo.setRecommendText(recommendText); |
| | | shareInfo.setCommentText(commentText); |
| | | |
| | | shareInfo.setRecommendText(deleteBlankLine(recommendText)); |
| | | shareInfo.setCommentText(deleteBlankLine(commentText)); |
| | | |
| | | // 设置评论文本选项 |
| | | shareInfo.setCommentTextChoiceList(getCommentChoiceList(null,shareInfo.getCommentText(), inviteCode, |
| | | PinDuoDuoUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate()))); |
| | | |
| | | out.print(JsonUtil.loadTrueResult( |
| | | JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo))); |
| | | |
| | |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "getShareTextQuick", method = RequestMethod.POST) |
| | | public void getShareTextQuick(AcceptData acceptData, Long goodsId, Integer goodsType, |
| | | Long uid, PrintWriter out) { |
| | | public void getShareTextQuick(AcceptData acceptData, Long goodsId, Integer goodsType, Long uid, PrintWriter out) { |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | |
| | | if (goodsType == null || goodsId == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请传递正确的商品信息")); |
| | | return; |
| | | } |
| | | |
| | | |
| | | GoodsDetailVO goodsDetail = null; |
| | | ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(), |
| | | acceptData.getVersion()); |
| | | paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate()); |
| | | |
| | | |
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goodsId); |
| | | if (goods == null){ |
| | | if (goods == null) { |
| | | try { |
| | | goods = redisManager.getTaoBaoGoodsBrief(goodsId); |
| | | } catch (TaobaoGoodsDownException e) { |
| | |
| | | if (goods != null) { |
| | | goodsDetail = GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | if (goodsDetail == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "该商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | |
| | | String template = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); |
| | | template = template.replace("[商品标题]", goodsDetail.getTitle()).replace("[销量]", goodsDetail.getSalesCount()); |
| | | if (StringUtil.isNullOrEmpty(goodsDetail.getDescription())) { |
| | |
| | | } else { |
| | | template = template.replace("推荐语:[推荐语]", ""); |
| | | } |
| | | |
| | | |
| | | if (goodsDetail.isHasCoupon()) { |
| | | template = template.replace("[券面额]", String.format("满%s元减%s元", |
| | | MoneyBigDecimalUtil.getWithNoZera(goodsDetail.getCouponInfo().getStartFee()).toString(), |
| | | MoneyBigDecimalUtil.getWithNoZera(goodsDetail.getCouponInfo().getAmount()).toString())); |
| | | template = template.replace("[券面额]", |
| | | String.format("满%s元减%s元", |
| | | MoneyBigDecimalUtil.getWithNoZera(goodsDetail.getCouponInfo().getStartFee()).toString(), |
| | | MoneyBigDecimalUtil.getWithNoZera(goodsDetail.getCouponInfo().getAmount()).toString())); |
| | | } else { |
| | | template = template.replace("优惠券:[券面额]", ""); |
| | | } |
| | | |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("description", template); |
| | | out.print(JsonUtil.loadTrueResult(data)); |