| | |
| | | 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;
|
| | |
| | | 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); |
| | | String commentText = template.replace("[原价]", goods.getZkPrice().toString()); |
| | | commentText = commentText.replace("[口令]", token); |
| | | if (StringUtil.isNullOrEmpty(goods.getCouponInfo())) { |
| | | commentText = commentText.replace("领券抢购", "抢购"); |
| | | commentText = commentText.replace("【券后价】[券后价]元", ""); |
| | | } else { |
| | | commentText = commentText.replace("[券后价]", TaoBaoUtil.getAfterUseCouplePrice(goods) + ""); |
| | | } |
| | | return commentText; |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | taoBaoLink.getGoods(), shareInfo.getToken()));
|
| | |
|
| | | // 提示图文内容
|
| | | String imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey());
|
| | | String imgs = configService.getByVersion(ConfigKeyEnum.goodsShareNotifyImgs.getKey(), platform, |
| | | Integer.parseInt(version)); |
| | | JSONArray array = JSONArray.fromObject(imgs);
|
| | |
|
| | | shareInfo.setNotifyPicture(array.optString(0));
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | // 设置评论文本选项
|
| | | shareInfo.setCommentTextChoiceList(getCommentChoiceList(shareInfo.getShareText(), null, inviteCode,
|
| | | TaoBaoUtil.getGoodsHongBaoMoney(taoBaoLink.getGoods(), hongBaoManageService.getFanLiRate())));
|
| | | shareInfo.setCommentText(shareInfo.getShareText());
|
| | |
|
| | | String commentText = ""; |
| | | String recommendText = ""; |
| | | if (VersionUtil.greaterThan_2_0_7(platform, version)) {
|
| | | String recommend = taoBaoLink.getGoods().getTitle();
|
| | | if (!StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getDescription()))
|
| | | recommend += "\n\r" + taoBaoLink.getGoods().getDescription();
|
| | | shareInfo.setRecommendText(recommend);
|
| | | } else
|
| | | shareInfo.setRecommendText(shareInfo.getDescText());
|
| | | TaoBaoGoodsBrief goods = taoBaoLink.getGoods(); |
| | | String template = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); |
| | | recommendText = template.replace("[商品标题]", goods.getTitle()).replace("[销量]", |
| | | TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day())); |
| | | if (StringUtil.isNullOrEmpty(goods.getDescription())) { |
| | | recommendText = recommendText.replace("推荐语:[推荐语]", ""); |
| | | } else { |
| | | recommendText = recommendText.replace("[推荐语]", goods.getDescription()); |
| | | } |
| | | |
| | | String quickCommentText = configService.get(ConfigKeyEnum.quickShareTBCommentText.getKey()); |
| | | commentText = quickCommentText.replace("[原价]", goods.getZkPrice().toString()); |
| | | 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()) + ""); |
| | | recommendText = recommendText.replace("[券面额]", |
| | | MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString()); |
| | | } |
| | | } else { |
| | | recommendText = shareInfo.getDescText(); |
| | | commentText = shareInfo.getShareText(); |
| | | } |
| | | 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)));
|
| | |
| | |
|
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | |
|
| | | // 设置评论文本选项
|
| | | shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getShareText(), inviteCode,
|
| | | JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getFanLiRate())));
|
| | | 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()).replace("[销量]", |
| | | JDUtil.getSaleCount(jdGoods.getInOrderCount30Days())); |
| | | // 无推荐语 |
| | | recommendText = recommendText.replace("推荐语:[推荐语]", ""); |
| | |
|
| | | shareInfo.setCommentText(shareInfo.getShareText());
|
| | | if (VersionUtil.greaterThan_2_0_7(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | shareInfo.setRecommendText(jdGoods.getSkuName());
|
| | | else
|
| | | shareInfo.setRecommendText(shareInfo.getDescText());
|
| | | 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("【券后价】[券后价]元", ""); |
| | | recommendText = recommendText.replace("优惠券:[券面额]", ""); |
| | | } else { |
| | | 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(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"); |
| | | } |
| | | |
| | |
|
| | | /**
|
| | | * 拼多多分享
|
| | |
| | |
|
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | |
|
| | | // 设置评论文本选项
|
| | | shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getShareText(), inviteCode,
|
| | | PinDuoDuoUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate())));
|
| | | String commentText = ""; |
| | | String recommendText = ""; |
| | | if (VersionUtil.greaterThan_2_0_7(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | String qtemplate = configService.get(ConfigKeyEnum.quickShareGoodsText.getKey()); |
| | | recommendText = qtemplate.replace("[商品标题]", goods.getGoodsName()); |
| | |
|
| | | shareInfo.setCommentText(shareInfo.getShareText());
|
| | | if (VersionUtil.greaterThan_2_0_7(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | shareInfo.setRecommendText(goods.getGoodsName());
|
| | | else
|
| | | shareInfo.setRecommendText(shareInfo.getDescText());
|
| | | // 总销量 |
| | | 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 = 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 = recommendText.replace("[券面额]", BigDecimalUtil.getWithNoZera(amount).toString()); |
| | | } |
| | | } else { |
| | | commentText = shareInfo.getShareText(); |
| | | recommendText = shareInfo.getDescText(); |
| | | } |
| | | 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) { |
| | | 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) { |
| | | try { |
| | | goods = redisManager.getTaoBaoGoodsBrief(goodsId); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | goods = null; |
| | | } |
| | | } |
| | | if (goods != null) { |
| | | goodsDetail = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO); |
| | | } |
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) { |
| | | JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(goodsId); |
| | | if (goods != null) { |
| | | goodsDetail = GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO); |
| | | } |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId); |
| | | 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())) { |
| | | template = template.replace("[推荐语]", 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())); |
| | | } else { |
| | | template = template.replace("优惠券:[券面额]", ""); |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("description", template); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | }
|