From d5dfd55f3dc45948a59cdcfef30e5fbc770f5721 Mon Sep 17 00:00:00 2001
From: Administrator <Administrator@MS-20170306HGUF>
Date: 星期日, 23 二月 2020 15:11:19 +0800
Subject: [PATCH] 图片尺寸保存
---
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java | 511 ++++++++++++++++++++++++++++++++++----------------------
1 files changed, 308 insertions(+), 203 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 375d6b1..966378b 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
@@ -32,9 +32,11 @@
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinRecord;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
import com.yeshi.fanli.entity.bus.user.UserInfo;
+import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.goods.ShareGoodsTextTemplate;
import com.yeshi.fanli.entity.jd.JDGoods;
+import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoLink;
import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
@@ -71,7 +73,6 @@
import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
-import com.yeshi.fanli.util.factory.MonitorFactory;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.jd.JDApiUtil;
import com.yeshi.fanli.util.jd.JDUtil;
@@ -81,6 +82,7 @@
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.util.taobao.TaoLiJinUtil;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
+import com.yeshi.fanli.vo.goods.ShareGoodsCommentChoiceInfo;
import com.yeshi.fanli.vo.goods.ShareInfoVO;
import net.sf.json.JSONArray;
@@ -156,22 +158,53 @@
@Resource
private UserTaoLiJinRecordService userTaoLiJinRecordService;
+ private List<ShareGoodsCommentChoiceInfo> getCommentChoiceList(String token, String link, String inviteCode,
+ BigDecimal fanliMoney) {
+ List<ShareGoodsCommentChoiceInfo> list = new ArrayList<>();
+ if (!StringUtil.isNullOrEmpty(token))
+ list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_TOKEN, "娣樺彛浠�",
+ String.format("寰╄=杩欐潯%s\n杩涘叆銆怲ao瀹濄�戝嵆鍙姠璐�", token), true, false));
+ if (!StringUtil.isNullOrEmpty(link)) {
+ list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_LINK, "閾炬帴", link, true, false));
+ }
+ if (!StringUtil.isNullOrEmpty(inviteCode)) {
+ list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_INVITE_CODE, "閭�璇风爜",
+ "閭�璇风爜锛�" + inviteCode, false, true));
+ }
+
+ list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_DOWNLOAD_LINK, "涓嬭浇閾炬帴",
+ "涓嬭浇閾炬帴锛�" + Constant.YINGYONGBAO_LINK, false, true));
+
+ list.add(new ShareGoodsCommentChoiceInfo(ShareGoodsCommentChoiceInfo.TYPE_FANLI_MONEY, "杩斿埄閲戦",
+ "杩斿埄閲戦锛毬� " + fanliMoney, false, true));
+
+ return list;
+ }
+
/**
- * 鑾峰彇娣樺疂鐨勫垎浜摼鎺�
*
* @param acceptData
* @param uid
* -鐢ㄦ埛ID
- * @param auctionId-鍟嗗搧ID
+ * @param goodsId-鍟嗗搧ID
+ * @param source
+ * @param totalNum
+ * @param goodsType
+ * @param needGoods
+ * -鏄惁闇�瑕佸晢鍝佷俊鎭�
+ * @param request
* @param out
*/
@RequestMapping(value = "createShareInfo")
public void createShareInfo(AcceptData acceptData, Long uid, Long goodsId, String source, Integer totalNum,
- Integer goodsType, HttpServletRequest request, PrintWriter out) {
+ Integer goodsType, Boolean needGoods, HttpServletRequest request, PrintWriter out) {
if (uid == null || uid <= 0) {
out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛ID涓嶈兘涓虹┖"));
return;
}
+
+ if (needGoods == null)
+ needGoods = false;
try {
// 鏃ュ織璁板綍
String info = String.format("type=share&uid=%s&goodsId=%s&source=%s&goodsType=%s", uid, goodsId, source,
@@ -193,36 +226,25 @@
// 娣樺疂
if (goodsType == null || goodsType == Constant.SOURCE_TYPE_TAOBAO) {
- createTaoBaoShare(acceptData, uid, goodsId, totalNum, source, request, out);
+ createTaoBaoShare(acceptData, uid, goodsId, totalNum, source, needGoods, request, out);
return;
}
// 浜笢
if (goodsType == Constant.SOURCE_TYPE_JD) {
- createJDShare(acceptData, uid, goodsId, source, out);
+ createJDShare(acceptData, uid, goodsId, source, needGoods, out);
return;
}
// 鎷煎澶�
if (goodsType == Constant.SOURCE_TYPE_PDD) {
- createPDDShare(acceptData, uid, goodsId, source, out);
+ createPDDShare(acceptData, uid, goodsId, source, needGoods, out);
return;
}
}
- public static String getERCodeContent(TaoBaoGoodsBrief goods, String token) {
- String content = String.format("銆�%s銆�%s鍏�", goods.getUserType() == 1 ? "T鐚环" : "T瀹濅环",
- MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + "");
- content += "\n\r";
-
- if (!StringUtil.isNullOrEmpty(goods.getCouponInfo())) {
- content += String.format("銆愬埜鍚庝环銆�%s鍏�", TaoBaoUtil.getAfterUseCouplePrice(goods) + "");
- content += "\n\r";
- }
- content += "------------";
- content += "\n\r";
- content += "寰╁埗杩欐潯" + token + "锛岄�插叆Tao瀹濆嵆鍙喘涔�";
- return content;
+ public static String getERCodeContent(String template, TaoBaoGoodsBrief goods, String token) {
+ return template.replace("[娣樺彛浠", token);
}
/**
@@ -237,9 +259,20 @@
* @param out
*/
public void createTaoBaoShare(AcceptData acceptData, Long uid, Long goodsId, Integer totalNum, String source,
- HttpServletRequest request, PrintWriter out) {
+ Boolean needGoods, HttpServletRequest request, PrintWriter out) {
+ if (needGoods == null)
+ needGoods = false;
UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByUid(uid);
+ UserInfoExtra userExtraInfo = userInfoExtraService.getUserInfoExtra(uid);
+ String inviteCode = null;
+ if (userExtraInfo != null) {
+ if (!StringUtil.isNullOrEmpty(userExtraInfo.getInviteCodeVip())) {
+ inviteCode = userExtraInfo.getInviteCodeVip();
+ } else {
+ inviteCode = userExtraInfo.getInviteCode();
+ }
+ }
String relationId = null;
if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null
&& extraInfo.getRelationValid() == true)
@@ -251,143 +284,13 @@
}
// 娣樼ぜ閲戝垱寤哄垎浜�
- if (source != null && "taolijin".equals(source)) {
+ if (source != null && "taolijin".equals(source)) {// 娣樼ぜ閲戝垎浜垱寤�
createTaoLijin(uid, goodsId, totalNum, relationId, request, out);
return;
- }
-
- try {
- ShareInfoVO shareInfo = new ShareInfoVO();
- // 娴嬭瘯
- List<String> commentTexts = new ArrayList<>();
- commentTexts.add("鍙d护1");
- commentTexts.add("鍙d护2鍙d护鍙d护娣樺彛浠ゅ彛浠ゅ彛浠ゆ窐鍙d护");
- commentTexts.add("鍙d护3");
- commentTexts.add("鍙d护鍙d护娣樺彛浠ゅ彛浠ゅ彛浠ゆ窐鍙d护鍙d护鍙d护娣樺彛浠ゅ彛浠ゅ彛浠ゆ窐鍙d护鍙d护鍙d护娣樺彛浠ゅ彛浠ゅ彛浠ゆ窐鍙d护");
- shareInfo.setCommentTexts(commentTexts);
-
- TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, goodsId, relationId);
-
- String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
- Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
- goodsId + "");
-
- String shortLink = HttpUtil.getShortLink(url);
- if (!StringUtil.isNullOrEmpty(shortLink)) {
- url = shortLink;
- }
-
- shareInfo.setClickUrl(url);
- shareInfo.setToken(TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
- shareInfo.setRule(configService.get("share_single_goods_rule"));
- shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
-
- String shareText = "";
- // 鏃犲埜
- String shopType = taoBaoLink.getGoods().getUserType() == 0 ? TaoBaoConstant.SHARE_PRICE_TAOBAO
- : TaoBaoConstant.SHARE_PRICE_TM;
-
- if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
- String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
- if (StringUtil.isNullOrEmpty(text))
- text = configService.get("goods_share_text_nocoupon");
- 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("goods_share_text_coupon");
-
- shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle())
- .replace("{鍟嗗搧鍘熶环}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "")
- .replace("{浼樻儬鍒搁潰棰潁",
- MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString())
- .replace("{浼樻儬鍒镐环}", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + "");
- }
-
- shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType)
- .replace("{鏈堥攢閲弣", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()))
- .replace("{棰嗗埜鐭摼}", shortLink).replace("{娣樺彛浠", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
-
- shareInfo.setShareText(shareText);
-
- String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
- if (descText.startsWith("\\r\\n")) {
- descText = descText.substring(0);
- }
- shareInfo.setDescText(descText);
- // 娴嬭瘯
- // 2.0.2涔嬪墠
- if (!VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion()))
- shareInfo.setClickUrl(getERCodeContent(taoBaoLink.getGoods(), shareInfo.getToken()));
-
- shareInfo.setWxErCode(getERCodeContent(taoBaoLink.getGoods(), shareInfo.getToken()));
-
- // 鎻愮ず鍥炬枃鍐呭
- String imgs = configService.get("goods_share_notify_imgs");
- JSONArray array = JSONArray.fromObject(imgs);
- int p = (int) (array.size() * Math.random());
- if (p < array.size()) {
- shareInfo.setNotifyPicture(array.optString(p));
- }
- shareInfo.setNotifyDesc(configService.get("goods_share_notify"));
-
- // 鍒嗕韩閲戦
- BigDecimal rate = hongBaoManageService.getShareRate();
- BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
- shareInfo.setShareMoney("楼" + shareMoney.toString());
-
- // 鍒嗕韩id
- try {
- ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
- Constant.SOURCE_TYPE_TAOBAO, false);
- shareInfo.setShareId(shareRecord.getRedisKey());
- } catch (Exception e) {
- try {
- LogHelper.errorDetailInfo(e);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
-
- out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(shareInfo)));
-
- final TaoBaoLink taobaoLink = taoBaoLink;
- // 寮傛鎿嶄綔
- 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(UserShareGoodsHistory.TYPE_TAOBAO);
- history.setTkCode(TaoBaoUtil.filterTaoToken(taobaoLink.getTaoToken()));
- history.setLink(taobaoLink.getClickUrl());
- history.setQuanLink(taobaoLink.getCouponLink());
- history.setGoodsId(taobaoLink.getGoods().getAuctionId());
- history.setPostPicture(taobaoLink.getGoods().getPictUrl());
-
- List<String> imgList = taobaoLink.getGoods().getImgList();
- if (imgList == null) {
- imgList = new ArrayList<>();
- }
- history.setPictures(JsonUtil.getGson().toJson(imgList));
- shareGoodsService.addShareGoodsHistory(history);
- }
- });
+ } else {// 鏅�氬垎浜垱寤�
+ createCommonTaoBaoShare(acceptData.getPlatform(), acceptData.getVersion(), goodsId, inviteCode, uid,
+ needGoods, relationId, out);
return;
- } catch (ShareGoodsException e) {
- LogHelper.errorDetailInfo(e, "鍒嗕韩鍑洪敊:uid:" + uid + " goodsId:" + goodsId, "");
- // 鍒嗕韩鍑洪敊鎶ヨ
- try {
- monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "鍒嗕韩鍑洪敊"));
- } catch (Exception e1) {
- }
- out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
- businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(goodsId + ""));
}
}
@@ -470,7 +373,7 @@
}
}
shareInfo.setToken(TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
- shareInfo.setRule(configService.get("share_single_goods_rule"));
+ shareInfo.setRule(configService.get(ConfigKeyEnum.shareSingleGoodsRule.getKey()));
shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(goods.getPictUrl(), 500));
// 鏃犲埜
@@ -481,7 +384,7 @@
if (StringUtil.isNullOrEmpty(goods.getCouponInfo())) {
String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
if (StringUtil.isNullOrEmpty(text))
- text = configService.get("goods_share_text_nocoupon");
+ text = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey());
shareText = text.replace("{鏍囬}", goods.getTitle()).replace("{鍟嗗搧鍘熶环}",
MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()) + "");
} else// 鏈夊埜
@@ -508,13 +411,11 @@
shareInfo.setDescText(descText);
- String imgs = configService.get("goods_share_notify_imgs");
+ String imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey());
JSONArray array = JSONArray.fromObject(imgs);
- int p = (int) (array.size() * Math.random());
- if (p < array.size()) {
- shareInfo.setNotifyPicture(array.optString(p));
- }
- shareInfo.setNotifyDesc(configService.get("goods_share_notify"));
+ shareInfo.setNotifyPicture(array.optString(0));
+
+ shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotify.getKey()));
// 娣诲姞鍒嗕韩璁板綍
BigDecimal rate = hongBaoManageService.getShareRate();
@@ -550,7 +451,7 @@
history.setQuanLink(taobaoLink.getCouponLink());
history.setGoodsId(finalGoods.getAuctionId());
history.setPostPicture(finalGoods.getPictUrl());
-
+ history.setShareImg(taobaoLink.getClickUrl());
List<String> imgList = finalGoods.getImgList();
if (imgList == null) {
imgList = new ArrayList<>();
@@ -567,6 +468,169 @@
}
}
+ public void createCommonTaoBaoShare(String platform, String version, Long goodsId, String inviteCode, Long uid,
+ boolean needGoods, String relationId, PrintWriter out) {
+ try {
+ ShareInfoVO shareInfo = new ShareInfoVO();
+
+ TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, goodsId, relationId);
+
+ if (taoBaoLink != null && taoBaoLink.getGoods() != null && needGoods) {
+ ConfigParamsDTO dto = hongBaoManageService.getShowComputeRate(platform, version);
+ GoodsDetailVO goodsInfo = GoodsDetailVOFactory.convertTaoBao(taoBaoLink.getGoods(), dto);
+ shareInfo.setGoodsInfo(goodsInfo);
+ }
+
+ String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
+ Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
+ goodsId + "");
+
+ String shortLink = HttpUtil.getShortLink(url);
+ if (!StringUtil.isNullOrEmpty(shortLink)) {
+ url = shortLink;
+ }
+
+ shareInfo.setClickUrl(url);
+ shareInfo.setToken(TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
+ shareInfo.setRule(configService.get(ConfigKeyEnum.shareSingleGoodsRule.getKey()));
+ shareInfo.setPictUrl(TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
+
+ String commentTextStr = configService.get(ConfigKeyEnum.shareSingleGoodsCommentText.getKey());
+ List<String> commentTexts = new ArrayList<>();
+ if (!StringUtil.isNullOrEmpty(commentTextStr)) {
+ JSONArray array = JSONArray.fromObject(commentTextStr);
+ for (int i = 0; i < array.size(); i++) {
+ if (StringUtil.isNullOrEmpty(inviteCode)) {
+ if (array.optString(i).contains("[閭�璇风爜]")) {
+ continue;
+ }
+ }
+ if (StringUtil.isNullOrEmpty(inviteCode))
+ commentTexts.add(array.optString(i).replace("[涓嬭浇閾炬帴]", Constant.YINGYONGBAO_LINK)
+ .replace("[娣樺彛浠", shareInfo.getToken()));
+ else
+ commentTexts.add(array.optString(i).replace("[涓嬭浇閾炬帴]", Constant.YINGYONGBAO_LINK)
+ .replace("[閭�璇风爜]", inviteCode).replace("[娣樺彛浠", shareInfo.getToken()));
+ }
+ }
+ shareInfo.setCommentTexts(commentTexts);
+
+ String shareText = "";
+ // 鏃犲埜
+ String shopType = taoBaoLink.getGoods().getUserType() == 0 ? TaoBaoConstant.SHARE_PRICE_TAOBAO
+ : TaoBaoConstant.SHARE_PRICE_TM;
+
+ 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()) + "");
+ }
+
+ shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType)
+ .replace("{鏈堥攢閲弣", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()))
+ .replace("{棰嗗埜鐭摼}", shortLink).replace("{娣樺彛浠", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
+
+ shareInfo.setShareText(shareText);
+
+ String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
+ if (descText.startsWith("\\r\\n")) {
+ descText = descText.substring(0);
+ }
+ shareInfo.setDescText(descText);
+ // 娴嬭瘯
+ // 2.0.2涔嬪墠
+ 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()),
+ 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));
+
+ shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotify.getKey()));
+
+ // 鍒嗕韩閲戦
+ BigDecimal rate = hongBaoManageService.getShareRate();
+ BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
+ shareInfo.setShareMoney("楼" + shareMoney.toString());
+
+ // 鍒嗕韩id
+ try {
+ ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, goodsId,
+ Constant.SOURCE_TYPE_TAOBAO, false);
+ shareInfo.setShareId(shareRecord.getRedisKey());
+ } catch (Exception e) {
+ try {
+ LogHelper.errorDetailInfo(e);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ // 璁剧疆璇勮鏂囨湰閫夐」
+ shareInfo.setCommentTextChoiceList(getCommentChoiceList(shareInfo.getToken(), null, inviteCode,
+ TaoBaoUtil.getGoodsHongBaoMoney(taoBaoLink.getGoods(), hongBaoManageService.getFanLiRate())));
+ shareInfo.setCommentText(shareInfo.getShareText());
+
+ if (VersionUtil.greaterThan_2_0_7(platform, version))
+ shareInfo.setRecommendText(taoBaoLink.getGoods().getDescription());
+ else
+ shareInfo.setRecommendText(shareInfo.getDescText());
+
+ out.print(JsonUtil.loadTrueResult(
+ JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo)));
+
+ final TaoBaoLink taobaoLink = taoBaoLink;
+ // 寮傛鎿嶄綔
+ 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(UserShareGoodsHistory.TYPE_TAOBAO);
+ history.setTkCode(TaoBaoUtil.filterTaoToken(taobaoLink.getTaoToken()));
+ history.setLink(taobaoLink.getClickUrl());
+ history.setQuanLink(taobaoLink.getCouponLink());
+ history.setGoodsId(taobaoLink.getGoods().getAuctionId());
+ history.setPostPicture(taobaoLink.getGoods().getPictUrl());
+ List<String> imgList = taobaoLink.getGoods().getImgList();
+ if (imgList == null) {
+ imgList = new ArrayList<>();
+ }
+ history.setPictures(JsonUtil.getGson().toJson(imgList));
+ shareGoodsService.addShareGoodsHistory(history);
+ }
+ });
+ return;
+ } catch (ShareGoodsException e) {
+ LogHelper.errorDetailInfo(e, "鍒嗕韩鍑洪敊:uid:" + uid + " goodsId:" + goodsId, "");
+ out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
+ businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(goodsId + ""));
+ }
+ }
+
/**
* 浜笢鍒涘缓鍒嗕韩
*
@@ -578,7 +642,8 @@
* @param request
* @param out
*/
- public void createJDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) {
+ public void createJDShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods,
+ PrintWriter out) {
JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
if (jdGoods == null) {
out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佸凡涓嬫灦"));
@@ -592,17 +657,24 @@
// goodsId + "");
String couponUrl = null;
- JDCouponInfo couponInfo = jdGoods.getCouponInfo();
+ JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(jdGoods);
if (couponInfo != null) {
couponUrl = couponInfo.getLink();
}
String materialId = "https://item.jd.com/" + goodsId + ".html";
- String jumpLink = JDApiUtil.convertShortLink(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid + "");
+ String jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "",
+ uid + "");
ShareInfoVO shareInfo = new ShareInfoVO();
shareInfo.setClickUrl(jumpLink);
- shareInfo.setRule(configService.get("share_rule_link_jd"));
+ shareInfo.setWxErCode(jumpLink);
+ shareInfo.setRule(configService.get(ConfigKeyEnum.shareRuleLinkJD.getKey()));
shareInfo.setPictUrl(jdGoods.getPicUrl());
+ shareInfo.setCommentTexts(new ArrayList<>());
+
+ if (needGoods)
+ shareInfo.setGoodsInfo(GoodsDetailVOFactory.convertJDGoods(jdGoods,
+ hongBaoManageService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion())));
String shareText = "";
boolean hasCoupon = false;
@@ -614,14 +686,14 @@
shareText = textTemplate.getShareJDTextTemplate();
if (StringUtil.isNullOrEmpty(shareText))
- shareText = configService.get("goods_share_text_nocoupon_jd");
+ shareText = configService.get(ConfigKeyEnum.goodsShareTextNoCouponJD.getKey());
} else { // 鏈夊埜妯℃澘
hasCoupon = true;
if (textTemplate != null)
shareText = textTemplate.getShareJDTextTemplateCoupon();
if (StringUtil.isNullOrEmpty(shareText))
- shareText = configService.get("goods_share_text_coupon_jd");
+ shareText = configService.get(ConfigKeyEnum.goodsShareTextCouponJD.getKey());
}
shareText = shareGoodsTextTemplateService.createContentByTemplateJD(shareText, uid, jdGoods, jumpLink,
hasCoupon);
@@ -633,13 +705,13 @@
}
shareInfo.setDescText(descText);
- String imgs = configService.get("goods_share_notify_imgs");
+ String imgs = configService.getByVersion(ConfigKeyEnum.goodsShareNotifyImgs.getKey(), acceptData.getPlatform(),
+ Integer.parseInt(acceptData.getVersion()));
JSONArray array = JSONArray.fromObject(imgs);
- int p = (int) (array.size() * Math.random());
- if (p < array.size()) {
- shareInfo.setNotifyPicture(array.optString(p));
- }
- shareInfo.setNotifyDesc(configService.get("goods_share_notify_jd"));
+
+ shareInfo.setNotifyPicture(array.size() > 1 ? array.optString(1) : array.optString(0));
+
+ shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotifyJD.getKey()));
// 娣诲姞鍒嗕韩璁板綍
BigDecimal shareRate = hongBaoManageService.getShareRate();
@@ -656,7 +728,18 @@
e1.printStackTrace();
}
}
- out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(shareInfo)));
+
+ String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
+
+ // 璁剧疆璇勮鏂囨湰閫夐」
+ shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getClickUrl(), inviteCode,
+ JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getFanLiRate())));
+
+ shareInfo.setCommentText(shareInfo.getShareText());
+ shareInfo.setRecommendText(shareInfo.getDescText());
+
+ out.print(JsonUtil.loadTrueResult(
+ JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo)));
// 寮傛鎿嶄綔
final JDGoods goods = jdGoods;
@@ -674,6 +757,7 @@
history.setQuanLink(null);
history.setGoodsId(goodsId);
history.setPostPicture(goods.getPicUrl());
+ history.setShareImg(jumpLink);
List<String> imgList = goods.getImageList();
if (imgList == null) {
@@ -694,7 +778,8 @@
* @param source
* @param out
*/
- public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, PrintWriter out) {
+ public void createPDDShare(AcceptData acceptData, Long uid, Long goodsId, String source, boolean needGoods,
+ PrintWriter out) {
PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
if (goods == null) {
out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佸凡涓嬫灦"));
@@ -711,8 +796,17 @@
ShareInfoVO shareInfo = new ShareInfoVO();
shareInfo.setClickUrl(jumpLink);
- shareInfo.setRule(configService.get("share_rule_link_pdd"));
+ shareInfo.setWxErCode(jumpLink);
+ shareInfo.setCommentTexts(new ArrayList<>());
+ shareInfo.setRule(configService.get(ConfigKeyEnum.shareRuleLinkPDD.getKey()));
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;
@@ -722,14 +816,14 @@
template = textTemplate.getSharePDDTextTemplate();
if (StringUtil.isNullOrEmpty(template))
- template = configService.get("goods_share_text_nocoupon_pdd");
+ template = configService.get(ConfigKeyEnum.goodsShareTextNocouponPDD.getKey());
} else {
hasCoupon = true;
if (textTemplate != null)
template = textTemplate.getSharePDDTextTemplateCoupon();
if (StringUtil.isNullOrEmpty(template))
- template = configService.get("goods_share_text_coupon_pdd");
+ template = configService.get(ConfigKeyEnum.goodsShareTextCouponPDD.getKey());
}
// 鍒涘缓鍙d护
@@ -747,13 +841,13 @@
shareInfo.setDescText(descText);
//
- String imgs = configService.get("goods_share_notify_imgs");
+ String imgs = configService.getByVersion(ConfigKeyEnum.goodsShareNotifyImgs.getKey(), acceptData.getPlatform(),
+ Integer.parseInt(acceptData.getVersion()));
JSONArray array = JSONArray.fromObject(imgs);
- int p = (int) (array.size() * Math.random());
- if (p < array.size()) {
- shareInfo.setNotifyPicture(array.optString(p));
- }
- shareInfo.setNotifyDesc(configService.get("goods_share_notify_pdd"));
+
+ shareInfo.setNotifyPicture(array.size() > 1 ? array.optString(1) : array.optString(0));
+
+ shareInfo.setNotifyDesc(configService.get(ConfigKeyEnum.goodsShareNotifyPDD.getKey()));
// 娣诲姞鍒嗕韩璁板綍
BigDecimal shareRate = hongBaoManageService.getShareRate();
@@ -771,7 +865,18 @@
e1.printStackTrace();
}
}
- out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGson().toJson(shareInfo)));
+
+ String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
+
+ // 璁剧疆璇勮鏂囨湰閫夐」
+ shareInfo.setCommentTextChoiceList(getCommentChoiceList(null, shareInfo.getClickUrl(), inviteCode,
+ PinDuoDuoUtil.getGoodsFanLiMoney(goods, hongBaoManageService.getFanLiRate())));
+
+ shareInfo.setCommentText(shareInfo.getShareText());
+ shareInfo.setRecommendText(shareInfo.getDescText());
+
+ out.print(JsonUtil.loadTrueResult(
+ JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create().toJson(shareInfo)));
// 寮傛鎿嶄綔
com.yeshi.fanli.util.ThreadUtil.run(new Runnable() {
@@ -788,7 +893,7 @@
history.setQuanLink(null);
history.setGoodsId(goodsId);
history.setPostPicture(goods.getGoodsImageUrl());
-
+ history.setShareImg(jumpLink);
List<String> imgList = null;
String[] goodsGalleryUrls = goods.getGoodsGalleryUrls();
if (goodsGalleryUrls != null) {
@@ -991,12 +1096,13 @@
}
String couponUrl = null;
- JDCouponInfo couponInfo = goods.getCouponInfo();
+ JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods);
if (couponInfo != null) {
couponUrl = couponInfo.getLink();
}
String materialId = "https://item.jd.com/" + goodsId + ".html";
- String shortLink = JDApiUtil.convertShortLink(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid + "");
+ String shortLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "",
+ uid + "");
String content = shareGoodsTextTemplateService.createContentByTemplateJD(template, uid, goods, shortLink,
hasCoupon);
@@ -1089,13 +1195,13 @@
} else {
template = shareGoodsTextTemplateService.geteCouponTemplate(uid);
if (StringUtil.isNullOrEmpty(template))
- template = configService.get("goods_share_text_coupon");
+ template = configService.get(ConfigKeyEnum.goodsShareTextCoupon.getKey());
}
} else {
template = shareGoodsTextTemplateService.getCommonTemplate(uid);
if (StringUtil.isNullOrEmpty(template))
- template = configService.get("goods_share_text_nocoupon");
+ template = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey());
}
} else if (goodsType == Constant.SOURCE_TYPE_JD) {
ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
@@ -1104,7 +1210,7 @@
template = textTemplate.getShareJDTextTemplateCoupon();
}
if (StringUtil.isNullOrEmpty(template)) {
- template = configService.get("goods_share_text_coupon_jd");
+ template = configService.get(ConfigKeyEnum.goodsShareTextCouponJD.getKey());
}
} else {
if (textTemplate != null) {
@@ -1112,7 +1218,7 @@
}
if (StringUtil.isNullOrEmpty(template)) {
- template = configService.get("goods_share_text_nocoupon_jd");
+ template = configService.get(ConfigKeyEnum.goodsShareTextNoCouponJD.getKey());
}
}
} else if (goodsType == Constant.SOURCE_TYPE_PDD) {
@@ -1122,7 +1228,7 @@
template = textTemplate.getSharePDDTextTemplateCoupon();
}
if (StringUtil.isNullOrEmpty(template)) {
- template = configService.get("goods_share_text_coupon_pdd");
+ template = configService.get(ConfigKeyEnum.goodsShareTextCouponPDD.getKey());
}
} else {
if (textTemplate != null) {
@@ -1130,7 +1236,7 @@
}
if (StringUtil.isNullOrEmpty(template)) {
- template = configService.get("goods_share_text_nocoupon_pdd");
+ template = configService.get(ConfigKeyEnum.goodsShareTextNocouponPDD.getKey());
}
}
}
@@ -1181,12 +1287,12 @@
out.print(
JsonUtil.loadTrueResult(configTaoLiJinService.getValueByKey("share_goods_rules", new Date())));
} else {
- out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules")));
+ out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRules.getKey())));
}
} else if (goodsType == Constant.SOURCE_TYPE_JD) {
- out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules_jd")));
+ out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRulesJD.getKey())));
} else if (goodsType == Constant.SOURCE_TYPE_PDD) {
- out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules_pdd")));
+ out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRulesPDD.getKey())));
}
}
@@ -1359,9 +1465,8 @@
}
}
- BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
- BigDecimal shareRate = hongBaoManageService.getShareRate();
- ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
+ ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
+ acceptData.getVersion());
Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
--
Gitblit v1.8.0