From bf5d1b405c759de3faa42af37b1f10f42823b105 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期四, 20 六月 2019 17:07:03 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java | 238 ++++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 185 insertions(+), 53 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java
index 99ff3d5..6730a0b 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java
@@ -22,6 +22,7 @@
import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord;
+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;
@@ -37,6 +38,7 @@
import com.yeshi.fanli.exception.goods.ShareGoodsTextTemplateException;
import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
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;
@@ -47,6 +49,9 @@
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service;
import com.yeshi.fanli.service.inter.monitor.MonitorService;
+import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService;
+import com.yeshi.fanli.service.inter.tlj.GoodsTaoLiJinRateService;
+import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService;
import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
@@ -126,6 +131,16 @@
@Resource
private BusinessEmergent110Service businessEmergent110Service;
+
+ @Resource
+ private ConfigTaoLiJinService configTaoLiJinService;
+
+ @Resource
+ private GoodsTaoLiJinRateService goodsTaoLiJinRateService;
+
+ @Resource
+ private UserTaoLiJinRecordService userTaoLiJinRecordService;
+
// 鑾峰彇鍟嗗搧鍒嗕韩閾炬帴
@RequestMapping(value = "getGoodsShareUrl")
@@ -144,8 +159,9 @@
* @param out
*/
@RequestMapping(value = "gettaobaosharelink")
- public void getTaobaoShareLink(AcceptData acceptData, Long uid, Long auctionId, HttpServletRequest request,
- PrintWriter out) {
+ public void getTaobaoShareLink(AcceptData acceptData, Long uid, Long auctionId, String source, Integer totalNum,
+ HttpServletRequest request, PrintWriter out) {
+
if (uid == null || uid <= 0) {
out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛ID涓嶈兘涓虹┖"));
return;
@@ -168,13 +184,56 @@
if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null
&& extraInfo.getRelationValid() == true)
relationId = extraInfo.getRelationId();
- TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId);
-
+
+ TaoBaoLink taoBaoLink = new TaoBaoLink();
+ if (source != null && "taolijin".equals(source)) {
+ taoBaoLink = shareGoodsService.getTaoLiJinLinkForShare(uid, auctionId, relationId);
+ } else {
+ taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId);
+ }
+
JSONObject data = new JSONObject();
String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
auctionId + "");
+ if (source != null && "taolijin".equals(source)) {
+
+ BigDecimal spreadMoney = goodsTaoLiJinRateService.getGoodsSpreadMoney(taoBaoLink.getGoods());
+ // 鎺ㄥ箍绾㈠寘 涓嶈兘灏忎簬1
+ if (spreadMoney.compareTo(new BigDecimal(1)) < 0) {
+ out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佹窐绀奸噾涓嶈冻1鍏�"));
+ return;
+ }
+ data.put("spreadMoney", "娣樼ぜ閲� 楼" + spreadMoney.toString());
+
+ String taoLiJinLink = null;
+ try {
+ UserTaoLiJinRecord record = userTaoLiJinRecordService.createShareTaoLiJin(uid, totalNum, taoBaoLink.getGoods());
+ taoLiJinLink = record.getSendUrl();
+ data.put("tljId", record.getId());
+ data.put("surplusMoney", record.getSurplusMoney());
+
+ } catch (UserTaoLiJinRecordException e) {
+ out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
+ return;
+ }
+ // 鍒涘缓娣樺彛浠�
+ TaoBaoGoodsBrief goods = taoBaoLink.getGoods();
+ if (!StringUtil.isNullOrEmpty(taoLiJinLink)) {// 閫氳繃绔嬪嵆鎺ㄥ箍鏂瑰紡鑾峰彇娣樺彛浠ゆ垚鍔�
+ String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), taoLiJinLink);
+ if (!StringUtil.isNullOrEmpty(quanToken)) {
+ taoBaoLink.setTaoToken(quanToken);
+ }
+ } else if (!StringUtil.isNullOrEmpty(taoBaoLink.getClickUrl())) {
+ String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), taoBaoLink.getClickUrl());
+ if (!StringUtil.isNullOrEmpty(quanToken)) {
+ taoBaoLink.setTaoToken(quanToken);
+ }
+ }
+ }
+
+
String shortLink = HttpUtil.getShortLink(url);
if (!StringUtil.isNullOrEmpty(shortLink)) {
url = shortLink;
@@ -190,6 +249,7 @@
// 鏃犲埜
String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "娣樺疂浠�" : "澶╃尗浠�";
+
if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
if (StringUtil.isNullOrEmpty(text))
@@ -198,16 +258,33 @@
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()) + "");
+ if (source != null && "taolijin".equals(source)) {
+ String text = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid);
+ if (StringUtil.isNullOrEmpty(text))
+ text = configTaoLiJinService.getValueByKey("goods_share_text");
+
+ shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle())
+ .replace("{鍟嗗搧鍘熶环}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "")
+ .replace("{浼樻儬鍒搁潰棰潁",
+ MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString())
+ .replace("{娣樼ぜ閲戦潰棰潁", MoneyBigDecimalUtil.getWithNoZera(goodsTaoLiJinRateService.getGoodsSpreadMoney(taoBaoLink.getGoods())).toString())
+ .replace("{浼樻儬鍒镐环}", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + "");
+ } 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("{娣樺彛浠", taoBaoLink.getTaoToken());
@@ -241,6 +318,7 @@
}
out.print(JsonUtil.loadTrueResult(data));
+ final TaoBaoLink taobaoLink = taoBaoLink;
// 寮傛鎿嶄綔
com.yeshi.fanli.util.ThreadUtil.run(new Runnable() {
@Override
@@ -251,13 +329,13 @@
history.setHongbao(shareMoney);
history.setCreateTime(new Date());
history.setGoodsType(UserShareGoodsHistory.TYPE_TAOBAO);
- history.setTkCode(taoBaoLink.getTaoToken());
- history.setLink(taoBaoLink.getClickUrl());
- history.setQuanLink(taoBaoLink.getCouponLink());
- history.setGoodsId(taoBaoLink.getGoods().getAuctionId());
- history.setPostPicture(taoBaoLink.getGoods().getPictUrl());
+ history.setTkCode(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();
+ List<String> imgList = taobaoLink.getGoods().getImgList();
if (imgList == null) {
imgList = new ArrayList<>();
}
@@ -455,7 +533,7 @@
* @param out
*/
@RequestMapping(value = "viewShareTextTemplate", method = RequestMethod.POST)
- public void preViewShareTextTemplate(AcceptData acceptData, Long uid, String template, Long goodsId,
+ public void preViewShareTextTemplate(AcceptData acceptData, Long uid, String template, Long goodsId, Long tljId,
Boolean hasCoupon, PrintWriter out) {
if (uid == null) {
out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
@@ -480,19 +558,32 @@
return;
}
+ String from = null;
+ if (tljId != null) {
+ from = "taolijin";
+ }
+
if (StringUtil.isNullOrEmpty(template))
- template = getShareTemplate(uid, hasCoupon);
+ template = getShareTemplate(uid, hasCoupon, from);
// 鏍¢獙鍒告ā鏉挎槸鍚︽纭�
if (hasCoupon) {
// 鏈夊埜鍟嗗搧
- try {
- shareGoodsTextTemplateService.isCouponTemplateRight(template);
- } catch (ShareGoodsTextTemplateException e) {
- out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
- return;
+ 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 {
@@ -503,12 +594,25 @@
}
}
+ 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());
- String 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);
String token = "";
if (userShareHistory != null) {
token = userShareHistory.getTkCode();
@@ -527,7 +631,7 @@
: goodsLink.getCouponLink());
}
String content = shareGoodsTextTemplateService.createContentByTemplate(template, uid, goods, token, shortLink,
- hasCoupon);
+ hasCoupon, from);
JSONObject data = new JSONObject();
data.put("content", content);
out.print(JsonUtil.loadTrueResult(data));
@@ -543,7 +647,7 @@
* @param out
*/
@RequestMapping(value = "saveShareTextTemplate", method = RequestMethod.POST)
- public void saveShareTextTemplate(AcceptData acceptData, Long uid, Boolean hasCoupon, String template,
+ public void saveShareTextTemplate(AcceptData acceptData, Long uid, Long tljId, Boolean hasCoupon, String template,
PrintWriter out) {
if (StringUtil.isNullOrEmpty(template)) {
out.print(JsonUtil.loadFalseResult(1, "鍒嗕韩妯℃澘涓虹┖"));
@@ -552,15 +656,25 @@
// 鏍¢獙鍒告ā鏉挎槸鍚︽纭�
if (hasCoupon) {
// 鏈夊埜鍟嗗搧
- try {
- shareGoodsTextTemplateService.isCouponTemplateRight(template);
- shareGoodsTextTemplateService.saveCouponTemplate(uid, template);
- out.print(JsonUtil.loadTrueResult(""));
- } catch (ShareGoodsTextTemplateException e) {
- out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
- return;
+ if (tljId != null) {
+ try {
+ shareGoodsTextTemplateService.isTaoLiJinTemplateRight(template);
+ shareGoodsTextTemplateService.saveTaoLiJinTemplate(uid, template);
+ out.print(JsonUtil.loadTrueResult(""));
+ } catch (ShareGoodsTextTemplateException e) {
+ out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
+ return;
+ }
+ } else {
+ try {
+ shareGoodsTextTemplateService.isCouponTemplateRight(template);
+ shareGoodsTextTemplateService.saveCouponTemplate(uid, template);
+ out.print(JsonUtil.loadTrueResult(""));
+ } catch (ShareGoodsTextTemplateException e) {
+ out.print(JsonUtil.loadFalseResult(5, e.getMsg()));
+ return;
+ }
}
-
} else {
// 鏅�氬晢鍝�
try {
@@ -585,32 +699,46 @@
* @param out
*/
@RequestMapping(value = "resetShareTextTemplate", method = RequestMethod.POST)
- public void resetShareTextTemplate(AcceptData acceptData, Long uid, Long goodsId, Boolean hasCoupon,
+ public void resetShareTextTemplate(AcceptData acceptData, Long uid, Long goodsId, Long tljId, Boolean hasCoupon,
PrintWriter out) {
if (uid == null) {
out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
return;
}
+
if (hasCoupon) {
- shareGoodsTextTemplateService.resetCouponTemplate(uid);
+ if (tljId != null) {
+ shareGoodsTextTemplateService.resetTaoLijinTemplate(uid);
+ } else {
+ shareGoodsTextTemplateService.resetCouponTemplate(uid);
+ }
} else {
shareGoodsTextTemplateService.resetCommonTemplate(uid);
}
if (goodsId != null) {
- preViewShareTextTemplate(acceptData, uid, null, goodsId, hasCoupon, out);
+ preViewShareTextTemplate(acceptData, uid, null, goodsId, tljId, hasCoupon, out);
return;
}
out.print(JsonUtil.loadTrueResult(""));
}
- private String getShareTemplate(Long uid, boolean hasCoupon) {
+ private String getShareTemplate(Long uid, boolean hasCoupon, String from) {
if (hasCoupon) {
- String template = shareGoodsTextTemplateService.geteCouponTemplate(uid);
- if (StringUtil.isNullOrEmpty(template))
- template = configService.get("goods_share_text_coupon");
- return template;
+ if (!StringUtil.isNullOrEmpty(from) && "taolijin".equals(from)) {
+ String template = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid);
+ if (StringUtil.isNullOrEmpty(template))
+ template = configTaoLiJinService.getValueByKey("goods_share_text");
+ return template;
+ } else {
+ String template = shareGoodsTextTemplateService.geteCouponTemplate(uid);
+ if (StringUtil.isNullOrEmpty(template))
+ template = configService.get("goods_share_text_coupon");
+ return template;
+ }
+
+
} else {
String template = shareGoodsTextTemplateService.getCommonTemplate(uid);
if (StringUtil.isNullOrEmpty(template))
@@ -628,13 +756,13 @@
* @param out
*/
@RequestMapping(value = "getShareTextTemplate", method = RequestMethod.POST)
- public void getShareTextTemplate(AcceptData acceptData, Long uid, Boolean hasCoupon, PrintWriter out) {
+ public void getShareTextTemplate(AcceptData acceptData, Long uid, String from, Boolean hasCoupon, PrintWriter out) {
if (uid == null) {
out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
return;
}
JSONObject data = new JSONObject();
- data.put("template", getShareTemplate(uid, hasCoupon));
+ data.put("template", getShareTemplate(uid, hasCoupon, from));
out.print(JsonUtil.loadTrueResult(data));
}
@@ -645,8 +773,12 @@
* @param out
*/
@RequestMapping(value = "getShareTextTemplateRules", method = RequestMethod.POST)
- public void getShareTextTemplateRules(AcceptData acceptData, PrintWriter out) {
- out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules")));
+ public void getShareTextTemplateRules(AcceptData acceptData, String from, PrintWriter out) {
+ if (!StringUtil.isNullOrEmpty(from) && "taolijin".equals(from)) {
+ out.print(JsonUtil.loadTrueResult( configTaoLiJinService.getValueByKey("share_goods_rules")));
+ } else {
+ out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules")));
+ }
}
/**
--
Gitblit v1.8.0