From 0dc81dc9086d40f8427dccf4fa74b527898ad544 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 11 九月 2019 15:53:07 +0800
Subject: [PATCH] 用返利奖励券最高返修改
---
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java | 176 ++++++++++++++++++++++++++++++++--------------------------
1 files changed, 97 insertions(+), 79 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 d34d6b9..a75cbfa 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
@@ -34,8 +34,8 @@
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
import com.yeshi.fanli.entity.taobao.TaoBaoLink;
import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
-import com.yeshi.fanli.exception.ShareGoodsException;
import com.yeshi.fanli.exception.goods.ShareGoodsTextTemplateException;
+import com.yeshi.fanli.exception.share.ShareGoodsException;
import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.exception.tlj.UserTaoLiJinRecordException;
@@ -50,7 +50,6 @@
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;
@@ -69,6 +68,7 @@
import com.yeshi.fanli.util.factory.MonitorFactory;
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.vo.msg.ClientTextStyleVO;
import net.sf.json.JSONArray;
@@ -131,16 +131,12 @@
@Resource
private BusinessEmergent110Service businessEmergent110Service;
-
+
@Resource
private ConfigTaoLiJinService configTaoLiJinService;
-
- @Resource
- private GoodsTaoLiJinRateService goodsTaoLiJinRateService;
@Resource
private UserTaoLiJinRecordService userTaoLiJinRecordService;
-
// 鑾峰彇鍟嗗搧鍒嗕韩閾炬帴
@RequestMapping(value = "getGoodsShareUrl")
@@ -161,7 +157,7 @@
@RequestMapping(value = "gettaobaosharelink")
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;
@@ -183,20 +179,25 @@
if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null
&& extraInfo.getRelationValid() == true)
relationId = extraInfo.getRelationId();
-
+
+ if (StringUtil.isNullOrEmpty(relationId)) {
+ out.print(JsonUtil.loadFalseResult(3, "娣樺疂鏈巿鏉冿紝璇峰墠寰�\"鎴戠殑\"缁戝畾娣樺疂璐﹀彿"));
+ return;
+ }
+
if (source != null && "taolijin".equals(source)) {
createTaoLijin(uid, auctionId, totalNum, relationId, request, out);
return;
}
-
+
try {
TaoBaoLink 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 + "");
-
+
String shortLink = HttpUtil.getShortLink(url);
if (!StringUtil.isNullOrEmpty(shortLink)) {
url = shortLink;
@@ -204,15 +205,13 @@
data.put("clickUrl", url);
data.put("token", taoBaoLink.getTaoToken());
- data.put("rule",
- "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
+ data.put("rule", configService.get("share_single_goods_rule"));
data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
String shareText = "";
// 鏃犲埜
String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "娣樺疂浠�" : "澶╃尗浠�";
-
if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
if (StringUtil.isNullOrEmpty(text))
@@ -224,14 +223,14 @@
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());
@@ -254,7 +253,7 @@
data.put("shareMoney", "楼" + shareMoney.toString());
try {
- ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId);
+ ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId, Constant.SOURCE_TYPE_TAOBAO, false);
data.put("shareId", shareRecord.getRedisKey());
} catch (Exception e) {
try {
@@ -292,7 +291,7 @@
});
return;
} catch (ShareGoodsException e) {
- LogHelper.errorDetailInfo(e, "鍒嗕韩鍑洪敊:uid:"+uid+"auctionId:"+auctionId, "");
+ LogHelper.errorDetailInfo(e, "鍒嗕韩鍑洪敊:uid:" + uid + "auctionId:" + auctionId, "");
// 鍒嗕韩鍑洪敊鎶ヨ
try {
monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "鍒嗕韩鍑洪敊"));
@@ -302,10 +301,10 @@
businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""));
}
}
-
-
+
/**
* 娣樼ぜ閲戝垱寤哄垎浜�
+ *
* @param uid
* @param auctionId
* @param totalNum
@@ -313,22 +312,26 @@
* @param request
* @param out
*/
- public void createTaoLijin(Long uid, Long auctionId, int totalNum, String relationId, HttpServletRequest request, PrintWriter out) {
+ public void createTaoLijin(Long uid, Long auctionId, int totalNum, String relationId, HttpServletRequest request,
+ PrintWriter out) {
try {
TaoBaoLink taoBaoLink = shareGoodsService.getTaoLiJinLinkForShare(uid, auctionId, relationId);
-
+
TaoBaoGoodsBrief goods = taoBaoLink.getGoods();
-
- BigDecimal spreadMoney = goodsTaoLiJinRateService.getGoodsSpreadMoney(goods);
+
+ // 璁$畻鎺ㄥ箍绾㈠寘
+ String warningRate = configTaoLiJinService.getValueByKey("warning_value",null);
+ BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods);
+
// 鎺ㄥ箍绾㈠寘 涓嶈兘灏忎簬1
- if (spreadMoney.compareTo(new BigDecimal(1)) < 0) {
- out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佹窐绀奸噾涓嶈冻1鍏�"));
+ if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) {
+ out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佹窐绀奸噾涓嶈冻"));
return;
}
-
+
JSONObject data = new JSONObject();
- data.put("spreadMoney", "娣樼ぜ閲� 楼" + spreadMoney.toString());
-
+ data.put("spreadMoney", " 楼" + spreadMoney.toString());
+
String taoLiJinLink = null;
Long tljId = null;
try {
@@ -341,39 +344,39 @@
out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
return;
}
-
+
String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&tid=%s", configService.getH5Host(),
Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
- auctionId + "", tljId);
+ auctionId + "", AESUtil.encrypt(tljId + "", Constant.UIDAESKEY));
String shortLink = HttpUtil.getShortLink(url);
if (!StringUtil.isNullOrEmpty(shortLink)) {
url = shortLink;
}
data.put("clickUrl", url);
-
-
+
// 鍒涘缓娣樺彛浠�
- String taoToken = null;
if (!StringUtil.isNullOrEmpty(taoLiJinLink)) {// 閫氳繃绔嬪嵆鎺ㄥ箍鏂瑰紡鑾峰彇娣樺彛浠ゆ垚鍔�
String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), taoLiJinLink);
if (!StringUtil.isNullOrEmpty(quanToken)) {
- taoToken = quanToken;
+ taoBaoLink.setTaoToken(quanToken);
}
} else if (!StringUtil.isNullOrEmpty(taoBaoLink.getClickUrl())) {
- String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(), taoBaoLink.getClickUrl());
+ String quanToken = TaoKeApiUtil.getTKToken(goods.getPictUrl(), goods.getTitle(),
+ taoBaoLink.getClickUrl());
if (!StringUtil.isNullOrEmpty(quanToken)) {
- taoToken = quanToken;
+ taoBaoLink.setTaoToken(quanToken);
}
}
- data.put("token", taoToken);
-
- data.put("rule", "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
+ data.put("token", taoBaoLink.getTaoToken());
+
+ data.put("rule",
+ "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
// 鏃犲埜
String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "娣樺疂浠�" : "澶╃尗浠�";
String shareText = "";
-
+
if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
if (StringUtil.isNullOrEmpty(text))
@@ -384,16 +387,16 @@
{
String text = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid);
if (StringUtil.isNullOrEmpty(text))
- text = configTaoLiJinService.getValueByKey("goods_share_text");
-
+ text = configTaoLiJinService.getValueByKey("goods_share_text",new Date());
+
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("{娣樼ぜ閲戦潰棰潁", MoneyBigDecimalUtil.getWithNoZera(spreadMoney).toString())
.replace("{浼樻儬鍒镐环}", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + "");
}
-
+
shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType)
.replace("{鏈堥攢閲弣", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()))
.replace("{棰嗗埜鐭摼}", shortLink).replace("{娣樺彛浠", taoBaoLink.getTaoToken());
@@ -402,7 +405,7 @@
if (descText.startsWith("\\r\\n"))
descText = descText.substring(0);
data.put("descText", descText);
-
+
String imgs = configService.get("goods_share_notify_imgs");
JSONArray array = JSONArray.fromObject(imgs);
int p = (int) (array.size() * Math.random());
@@ -416,7 +419,7 @@
data.put("shareMoney", "楼" + shareMoney.toString());
try {
- ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId);
+ ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId, Constant.SOURCE_TYPE_TAOBAO, true);
data.put("shareId", shareRecord.getRedisKey());
} catch (Exception e) {
try {
@@ -454,7 +457,7 @@
});
return;
} catch (ShareGoodsException e) {
- LogHelper.errorDetailInfo(e, "鍒嗕韩鍑洪敊:uid:"+uid+"auctionId:"+auctionId, "");
+ LogHelper.errorDetailInfo(e, "鍒嗕韩鍑洪敊:uid:" + uid + "auctionId:" + auctionId, "");
// 鍒嗕韩鍑洪敊鎶ヨ
try {
monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "鍒嗕韩鍑洪敊"));
@@ -464,10 +467,6 @@
businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""));
}
}
-
-
-
-
/**
* 鍒嗕韩璁板綍缁熻鍒楄〃
@@ -586,7 +585,7 @@
@RequestMapping(value = "sharedetail", method = RequestMethod.POST)
public void shareDetail(AcceptData acceptData, Long uid, Long auctionId, String type, PrintWriter out) {
try {
- userShareGoodsRecordService.saveSingleShareRecord(uid, auctionId);
+ userShareGoodsRecordService.saveSingleShareRecord(uid, auctionId, Constant.SOURCE_TYPE_TAOBAO);
out.print(JsonUtil.loadTrueResult("鍒嗕韩鎴愬姛"));
} catch (UserShareGoodsRecordException e) {
out.print(JsonUtil.loadFalseResult(e.getMsg()));
@@ -608,6 +607,7 @@
public void updateRecord(AcceptData acceptData, String shareId, String type, PrintWriter out) {
if (StringUtil.isNullOrEmpty(shareId)) {
out.print(JsonUtil.loadFalseResult("鍙傛暟涓嶆纭�"));
+ return;
}
// 鏇存柊鍒嗕韩鐢熸晥
@@ -615,7 +615,7 @@
@Override
public void run() {
try {
- userShareGoodsRecordService.takeEffectShareRecord(shareId);
+ userShareGoodsRecordService.takeEffectShareRecord(acceptData, shareId);
} catch (UserShareGoodsRecordException eu) {
try {
LogHelper.errorDetailInfo(eu);
@@ -645,7 +645,7 @@
* @param out
*/
@RequestMapping(value = "viewShareTextTemplate", method = RequestMethod.POST)
- public void preViewShareTextTemplate(AcceptData acceptData, Long uid, String template, Long goodsId, Long tljId,
+ 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, "鐢ㄦ埛鏈櫥褰�"));
@@ -669,7 +669,7 @@
out.print(JsonUtil.loadFalseResult(4, "鍟嗗搧宸蹭笅鏋�"));
return;
}
-
+
if (StringUtil.isNullOrEmpty(template))
template = getShareTemplate(uid, hasCoupon, tljId);
@@ -714,10 +714,9 @@
Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
goods.getAuctionId() + "");
}
-
+
String shortLink = HttpUtil.getShortLink(url);
-
-
+
// 鏌ヨ鏄惁鏈夊垎浜�
UserShareGoodsHistory userShareHistory = shareGoodsService.getShareGoodsHistory(uid, goods.getAuctionId());
String token = "";
@@ -812,7 +811,7 @@
out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
return;
}
-
+
if (hasCoupon) {
if (tljId != null) {
shareGoodsTextTemplateService.resetTaoLijinTemplate(uid);
@@ -836,7 +835,7 @@
if (tljId != null) {
String template = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid);
if (StringUtil.isNullOrEmpty(template))
- template = configTaoLiJinService.getValueByKey("goods_share_text");
+ template = configTaoLiJinService.getValueByKey("goods_share_text",new Date());
return template;
} else {
String template = shareGoodsTextTemplateService.geteCouponTemplate(uid);
@@ -844,8 +843,7 @@
template = configService.get("goods_share_text_coupon");
return template;
}
-
-
+
} else {
String template = shareGoodsTextTemplateService.getCommonTemplate(uid);
if (StringUtil.isNullOrEmpty(template))
@@ -868,12 +866,12 @@
out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
return;
}
-
+
if (hasCoupon == null) {
out.print(JsonUtil.loadFalseResult(1, "鏄惁鏈夊埜瀛楁涓虹┖"));
return;
}
-
+
JSONObject data = new JSONObject();
data.put("template", getShareTemplate(uid, hasCoupon, tljId));
out.print(JsonUtil.loadTrueResult(data));
@@ -888,7 +886,7 @@
@RequestMapping(value = "getShareTextTemplateRules", method = RequestMethod.POST)
public void getShareTextTemplateRules(AcceptData acceptData, Long tljId, PrintWriter out) {
if (tljId != null) {
- out.print(JsonUtil.loadTrueResult( configTaoLiJinService.getValueByKey("share_goods_rules")));
+ out.print(JsonUtil.loadTrueResult(configTaoLiJinService.getValueByKey("share_goods_rules",new Date())));
} else {
out.print(JsonUtil.loadTrueResult(configService.get("share_goods_template_rules")));
}
@@ -929,19 +927,40 @@
if (cid == 1 || cid == 2) { // 1 鐑攢鍗曞搧 2 鎺ㄨ崘濂借揣
if (cid == 1) {
List<GoodsPicture> imgs = dynamicInfo.getImgs();
+ if (imgs == null || imgs.size() == 0) {
+ out.print(JsonUtil.loadFalseResult("璇ュ晢鍝佸凡涓嬫灦"));
+ return;
+ }
+
GoodsPicture goodsPicture = imgs.get(0);
if (goodsPicture.getGoodState() == 1) {
out.print(JsonUtil.loadFalseResult("璇ュ晢鍝佸凡涓嬫灦"));
return;
- } else {
- TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods();
- try {
- TaoKeApiUtil.getSimpleGoodsInfo(goods.getAuctionId());
- } catch (TaobaoGoodsDownException e) {
- out.print(JsonUtil.loadFalseResult("璇ュ晢鍝佸凡涓嬫灦"));
- return;
- }
+ }
+
+ TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods();
+ if (goods == null) {
+ out.print(JsonUtil.loadFalseResult("璇ュ晢鍝佸凡涓嬫灦"));
+ return;
}
+
+ if (goods.getState() != null && goods.getState() == 1) {
+ out.print(JsonUtil.loadFalseResult("璇ュ晢鍝佸凡涓嬫灦"));
+ return;
+ }
+
+ if (!goods.isCoupon()) {
+ out.print(JsonUtil.loadFalseResult("璇ュ晢鍝佸凡涓嬫灦"));
+ return;
+ }
+
+ try {
+ TaoKeApiUtil.getSimpleGoodsInfo(goods.getAuctionId());
+ } catch (TaobaoGoodsDownException e) {
+ out.print(JsonUtil.loadFalseResult("璇ュ晢鍝佸凡涓嬫灦"));
+ return;
+ }
+
}
// 鍒嗕韩鏂囧瓧
@@ -953,13 +972,12 @@
title += textStyleVO.getContent();
}
}
-
-
- if(StringUtil.isNullOrEmpty(title)) {
+
+ if (StringUtil.isNullOrEmpty(title)) {
title = "缁欎綘鎺ㄨ崘绮鹃�夊ソ鐗╀紭鎯犲埜锛岃喘鐗╁墠鍏堥鍒革紝鍒敊杩囦紭鎯犲摝~";
}
data.put("title", title);
- data.put("content", "鎴戝湪杩斿埄鍒稿彂鐜颁簡涓�涓緢濂界殑鍟嗗搧锛屽揩鏉ョ湅鐪媬");
+ data.put("content",String.format("鎴戝湪%s鍙戠幇浜嗕竴涓緢濂界殑鍟嗗搧锛屽揩鏉ョ湅鐪媬",Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion())));
// 鍒嗕韩濂栭噾
ClientTextStyleVO desc = dynamicInfo.getDesc();
--
Gitblit v1.8.0