From 48b511dbf38054a4d6bc4383681ce50fd11df378 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期四, 14 五月 2020 21:48:20 +0800
Subject: [PATCH] VIP数据预览
---
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java | 517 ++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 366 insertions(+), 151 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 525eec0..0ce3f20 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
@@ -1,6 +1,7 @@
package com.yeshi.fanli.controller.client.v1;
import java.io.PrintWriter;
+import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
@@ -17,6 +18,13 @@
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.taobao.TbImgUtil;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+import com.yeshi.fanli.controller.client.v2.ShareControllerV2;
import com.yeshi.fanli.dto.share.ShareGoodsRecordDTO;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
@@ -25,17 +33,17 @@
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.dynamic.DynamicInfo;
import com.yeshi.fanli.entity.dynamic.GoodsPicture;
import com.yeshi.fanli.entity.system.BusinessSystem;
+import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.entity.system.SystemClientParams;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
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;
@@ -46,29 +54,28 @@
import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
import com.yeshi.fanli.service.inter.goods.ShareGoodsTextTemplateService;
-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.order.config.HongBaoManageService;
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;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
+import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
import com.yeshi.fanli.util.AESUtil;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TaoBaoConstant;
-import com.yeshi.fanli.util.account.UserUtil;
import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
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 +138,12 @@
@Resource
private BusinessEmergent110Service businessEmergent110Service;
-
+
@Resource
private ConfigTaoLiJinService configTaoLiJinService;
-
- @Resource
- private GoodsTaoLiJinRateService goodsTaoLiJinRateService;
@Resource
private UserTaoLiJinRecordService userTaoLiJinRecordService;
-
// 鑾峰彇鍟嗗搧鍒嗕韩閾炬帴
@RequestMapping(value = "getGoodsShareUrl")
@@ -161,7 +164,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;
@@ -179,127 +182,78 @@
}
UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByUid(uid);
+ String relationId = null;
+ 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 {
- String relationId = null;
- if (extraInfo != null && extraInfo.getRelationId() != null && extraInfo.getRelationValid() != null
- && extraInfo.getRelationValid() == true)
- relationId = extraInfo.getRelationId();
-
- TaoBaoLink taoBaoLink = new TaoBaoLink();
- if (source != null && "taolijin".equals(source)) {
- taoBaoLink = shareGoodsService.getTaoLiJinLinkForShare(uid, auctionId, relationId);
- } else {
- taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId);
- }
-
+ 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 + "");
- 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;
}
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("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
+ data.put("rule", configService.get(ConfigKeyEnum.shareSingleGoodsRule.getKey()));
data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
String shareText = "";
// 鏃犲埜
- String shopType = taoBaoLink.getGoods().getUserType() == 0 ? "娣樺疂浠�" : "澶╃尗浠�";
+ 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");
+ text = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey());
shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle()).replace("{鍟嗗搧鍘熶环}",
MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "");
} else// 鏈夊埜
{
- 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()) + "");
- }
-
+ 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("{娣樺彛浠", taoBaoLink.getTaoToken());
+ .replace("{棰嗗埜鐭摼}", shortLink).replace("{娣樺彛浠", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
data.put("shareText", shareText);
String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
if (descText.startsWith("\\r\\n"))
descText = descText.substring(0);
data.put("descText", 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())
data.put("notifyPicture", array.optString(p));
- data.put("notifyDesc", configService.get("goods_share_notify"));
+ data.put("notifyDesc", configService.get(ConfigKeyEnum.goodsShareNotify.getKey()));
// 娣诲姞鍒嗕韩璁板綍
BigDecimal rate = hongBaoManageService.getShareRate();
@@ -307,7 +261,8 @@
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 {
@@ -329,7 +284,7 @@
history.setHongbao(shareMoney);
history.setCreateTime(new Date());
history.setGoodsType(UserShareGoodsHistory.TYPE_TAOBAO);
- history.setTkCode(taobaoLink.getTaoToken());
+ history.setTkCode(TaoBaoUtil.filterTaoToken(taobaoLink.getTaoToken()));
history.setLink(taobaoLink.getClickUrl());
history.setQuanLink(taobaoLink.getCouponLink());
history.setGoodsId(taobaoLink.getGoods().getAuctionId());
@@ -345,7 +300,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, "鍒嗕韩鍑洪敊"));
@@ -354,7 +309,174 @@
out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""));
}
+ }
+ /**
+ * 娣樼ぜ閲戝垱寤哄垎浜�
+ *
+ * @param uid
+ * @param auctionId
+ * @param totalNum
+ * @param relationId
+ * @param request
+ * @param 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();
+
+ // 璁$畻鎺ㄥ箍绾㈠寘
+ String warningRate = configTaoLiJinService.getValueByKey("warning_value", null);
+ BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods);
+
+ // 鎺ㄥ箍绾㈠寘 涓嶈兘灏忎簬1
+ if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) {
+ out.print(JsonUtil.loadFalseResult(1, "璇ュ晢鍝佹窐绀奸噾涓嶈冻"));
+ return;
+ }
+
+ JSONObject data = new JSONObject();
+ data.put("spreadMoney", " 楼" + spreadMoney.toString());
+
+ String taoLiJinLink = null;
+ Long tljId = null;
+ try {
+ UserTaoLiJinRecord record = userTaoLiJinRecordService.createShareTaoLiJin(uid, totalNum, goods);
+ tljId = record.getId();
+ taoLiJinLink = record.getSendUrl();
+ data.put("tljId", tljId);
+ data.put("surplusMoney", record.getSurplusMoney());
+ } catch (UserTaoLiJinRecordException e) {
+ 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 + "", AESUtil.encrypt(tljId + "", Constant.UIDAESKEY));
+ String shortLink = HttpUtil.getShortLink(url);
+ if (!StringUtil.isNullOrEmpty(shortLink)) {
+ url = shortLink;
+ }
+ data.put("clickUrl", url);
+
+ // 鍒涘缓娣樺彛浠�
+ 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);
+ }
+ }
+ data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
+
+ data.put("rule",
+ "http://apph5.banliapp.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 ? TaoBaoConstant.SHARE_PRICE_TAOBAO
+ : TaoBaoConstant.SHARE_PRICE_TM;
+ String shareText = "";
+
+ 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.getTaoLiJinTemplate(uid);
+ if (StringUtil.isNullOrEmpty(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(spreadMoney).toString())
+ .replace("{浼樻儬鍒镐环}", TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()) + "");
+ }
+
+ shareText = shareText.replace("{搴楅摵绫诲瀷}", shopType)
+ .replace("{鏈堥攢閲弣", TaoBaoUtil.getSaleCount(taoBaoLink.getGoods().getBiz30day()))
+ .replace("{棰嗗埜鐭摼}", shortLink).replace("{娣樺彛浠", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
+ data.put("shareText", shareText);
+ String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
+ if (descText.startsWith("\\r\\n"))
+ descText = descText.substring(0);
+ data.put("descText", descText);
+
+ String imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey());
+ JSONArray array = JSONArray.fromObject(imgs);
+ int p = (int) (array.size() * Math.random());
+ if (p < array.size())
+ data.put("notifyPicture", array.optString(p));
+ data.put("notifyDesc", configService.get(ConfigKeyEnum.goodsShareNotify.getKey()));
+
+ // 娣诲姞鍒嗕韩璁板綍
+ BigDecimal rate = hongBaoManageService.getShareRate();
+ BigDecimal shareMoney = TaoBaoUtil.getShareGoodsHongBaoInfo(taoBaoLink.getGoods(), rate);
+
+ data.put("shareMoney", "楼" + shareMoney.toString());
+ try {
+ ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsDetail(uid, auctionId,
+ Constant.SOURCE_TYPE_TAOBAO, true);
+ data.put("shareId", shareRecord.getRedisKey());
+ } catch (Exception e) {
+ try {
+ LogHelper.errorDetailInfo(e);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+ out.print(JsonUtil.loadTrueResult(data));
+
+ 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 + "auctionId:" + auctionId, "");
+ // 鍒嗕韩鍑洪敊鎶ヨ
+ try {
+ monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "鍒嗕韩鍑洪敊"));
+ } catch (Exception e1) {
+ }
+ out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
+ businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""));
+ }
}
/**
@@ -389,15 +511,28 @@
List<UserShareGoodsRecord> list = new ArrayList<UserShareGoodsRecord>();
long count = userShareGoodsRecordService.countQueryByUid(uid, source);
-
if (count > 0) {
list = userShareGoodsRecordService.getMyShareGoodsRecords((page - 1) * pageSize, pageSize, uid, source);
}
- data.put("count", count);
- data.put("result_list", list);
- out.print(JsonUtil.loadTrueResult(data));
+ GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
+ gsonBuilder.registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() {
+ @Override
+ public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) {
+ if (value == null) {
+ return new JsonPrimitive("");
+ } else {
+ // 淇濈暀2浣嶅皬鏁�
+ value = value.setScale(2);
+ return new JsonPrimitive(value.toString());
+ }
+ }
+ });
+ Gson gson = gsonBuilder.create();
+ data.put("count", count);
+ data.put("result_list", gson.toJson(list));
+ out.print(JsonUtil.loadTrueResult(data));
} catch (Exception e) {
out.print(JsonUtil.loadFalseResult("鍔犺浇澶辫触"));
e.printStackTrace();
@@ -474,7 +609,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()));
@@ -496,6 +631,7 @@
public void updateRecord(AcceptData acceptData, String shareId, String type, PrintWriter out) {
if (StringUtil.isNullOrEmpty(shareId)) {
out.print(JsonUtil.loadFalseResult("鍙傛暟涓嶆纭�"));
+ return;
}
// 鏇存柊鍒嗕韩鐢熸晥
@@ -503,13 +639,9 @@
@Override
public void run() {
try {
- userShareGoodsRecordService.takeEffectShareRecord(shareId);
+ userShareGoodsRecordService.takeEffectShareRecord(acceptData, shareId);
} catch (UserShareGoodsRecordException eu) {
- try {
- LogHelper.errorDetailInfo(eu);
- } catch (Exception e) {
- e.printStackTrace();
- }
+
} catch (Exception e) {
try {
LogHelper.errorDetailInfo(e);
@@ -533,7 +665,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, "鐢ㄦ埛鏈櫥褰�"));
@@ -557,7 +689,7 @@
out.print(JsonUtil.loadFalseResult(4, "鍟嗗搧宸蹭笅鏋�"));
return;
}
-
+
if (StringUtil.isNullOrEmpty(template))
template = getShareTemplate(uid, hasCoupon, tljId);
@@ -602,10 +734,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 = "";
@@ -700,7 +831,7 @@
out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
return;
}
-
+
if (hasCoupon) {
if (tljId != null) {
shareGoodsTextTemplateService.resetTaoLijinTemplate(uid);
@@ -724,20 +855,19 @@
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);
if (StringUtil.isNullOrEmpty(template))
- template = configService.get("goods_share_text_coupon");
+ template = configService.get(ConfigKeyEnum.goodsShareTextCoupon.getKey());
return template;
}
-
-
+
} else {
String template = shareGoodsTextTemplateService.getCommonTemplate(uid);
if (StringUtil.isNullOrEmpty(template))
- template = configService.get("goods_share_text_nocoupon");
+ template = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey());
return template;
}
}
@@ -756,12 +886,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));
@@ -776,9 +906,9 @@
@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")));
+ out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRules.getKey())));
}
}
@@ -817,18 +947,74 @@
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;
+ }
+
+ } else {
+ List<GoodsPicture> imgs = dynamicInfo.getImgs();
+ if (imgs == null || imgs.size() == 0) {
+ out.print(JsonUtil.loadFalseResult("鎵�鏈夊晢鍝佸凡鎶㈠厜"));
+ return;
+ }
+
+ int count = 0;
+ for (GoodsPicture goodsPicture : imgs) {
+ if (goodsPicture.getGoodState() == 1) {
+ count++;
+ continue;
}
+
+ TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods();
+ if (goods == null) {
+ count++;
+ continue;
+ }
+
+ if (goods.getState() != null && goods.getState() == 1) {
+ count++;
+ continue;
+ }
+
+ if (!goods.isCoupon()) {
+ count++;
+ continue;
+ }
+ }
+
+ if (count >= imgs.size()) {
+ out.print(JsonUtil.loadFalseResult("鎵�鏈夊晢鍝佸凡鎶㈠厜"));
+ return;
}
}
@@ -841,13 +1027,13 @@
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();
@@ -856,10 +1042,10 @@
data.put("shareMoney", new BigDecimal(content.substring(index + 1, content.length())).toString());
// 鍒嗕韩鎻愰啋
- data.put("notifyDesc", configService.get("goods_share_notify"));
+ data.put("notifyDesc", configService.get(ConfigKeyEnum.goodsShareNotify.getKey()));
// 鍒嗕韩鎻愮ず璇�
- 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()) {
@@ -872,7 +1058,7 @@
// 甯姪閾炬帴
data.put("helpLink",
- "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
+ "http://apph5.banliapp.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
if (cid == 2) { // 2 鎺ㄨ崘濂借揣
ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordDynamic(uid,
@@ -894,6 +1080,7 @@
if (!StringUtil.isNullOrEmpty(shortLink)) {
url = shortLink;
}
+
data.put("clickUrl", url);
// 娣樺疂鍙d护
@@ -904,16 +1091,47 @@
relationId = extraInfo.getRelationId();
}
TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId);
- data.put("token", taoBaoLink.getTaoToken());
+ TaoBaoGoodsBrief goods = taoBaoLink.getGoods();
+ if (!com.yeshi.fanli.util.VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(),
+ acceptData.getVersion()))
+ data.put("clickUrl",
+ ShareControllerV2.getERCodeContentNew(
+ configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), goods,
+ taoBaoLink.getTaoToken()));
+
+ data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
+
+ String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
+ // 娴嬭瘯
+ List<String> commentTexts = new ArrayList<>();
+ String commentTextStr = configService.get(ConfigKeyEnum.shareSingleGoodsCommentText.getKey());
+ if (!StringUtil.isNullOrEmpty(commentTextStr)) {
+ JSONArray arr = JSONArray.fromObject(commentTextStr);
+ for (int i = 0; i < arr.size(); i++) {
+ if (StringUtil.isNullOrEmpty(inviteCode)) {
+ if (arr.optString(i).contains("[閭�璇风爜]")) {
+ continue;
+ }
+ }
+ if (StringUtil.isNullOrEmpty(inviteCode))
+ commentTexts.add(arr.optString(i).replace("[涓嬭浇閾炬帴]", Constant.YINGYONGBAO_LINK)
+ .replace("[娣樺彛浠", data.optString("token")));
+ else
+ commentTexts.add(arr.optString(i).replace("[涓嬭浇閾炬帴]", Constant.YINGYONGBAO_LINK)
+ .replace("[閭�璇风爜]", inviteCode).replace("[娣樺彛浠", data.optString("token")));
+ }
+ }
+ data.put("commentTexts", commentTexts);
+ data.put("wxErCode",
+ ShareControllerV2.getERCodeContentNew(
+ configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), goods,
+ taoBaoLink.getTaoToken()));
}
} else if (cid == 4) { // 閭�璇峰垎浜�
- String inviteCode = null;
- UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
- if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
- inviteCode = userInfoExtra.getInviteCode();
- } else {
+ String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
+ if (StringUtil.isNullOrEmpty(inviteCode)) {
out.print(JsonUtil.loadFalseResult(9001, "閭�璇风爜鏈縺娲�"));
return;
}
@@ -929,7 +1147,7 @@
}
}
title = title.replace("銆愰個璇风爜銆�", inviteCode);
- title = title.replace("銆愰個璇烽摼鎺ャ��", UserUtil.getInviteShortLink(uid));
+ title = title.replace("銆愰個璇烽摼鎺ャ��", Constant.YINGYONGBAO_LINK);
data.put("title", title);
} else { // 鏈夊浘鍒嗕韩
@@ -979,12 +1197,9 @@
String valueBr = valueN.replace("\n", "<br><br>");
data.put("inviteRules", valueBr);
- // 閭�璇烽摼鎺�
- String shortLink = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/"
- + Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid);
- data.put("inviteLink", shortLink);
+ data.put("inviteLink", Constant.YINGYONGBAO_LINK);
data.put("inviteCode", inviteCode);
- data.put("helpLink", configService.get("invite_help_link"));
+ data.put("helpLink", configService.get(ConfigKeyEnum.inviteHelpLink.getKey()));
}
}
out.print(JsonUtil.loadTrueResult(data));
--
Gitblit v1.8.0