From 8f45af9d6cdae97f4f265d2f2a123d990cf1bb1d Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期一, 06 五月 2019 17:57:07 +0800
Subject: [PATCH] 设备未读消息处理,分类BUG修改
---
fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsController.java | 152 ++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 132 insertions(+), 20 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsController.java
index cd35db8..c2eb367 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsController.java
@@ -11,6 +11,7 @@
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
+import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.taobao.ClientTBPid;
import com.yeshi.fanli.entity.taobao.PidUser;
import com.yeshi.fanli.entity.taobao.TBPid;
@@ -18,13 +19,17 @@
import com.yeshi.fanli.entity.taobao.TaoBaoLink;
import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
+import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
import com.yeshi.fanli.service.inter.monitor.MonitorService;
+import com.yeshi.fanli.service.inter.taobao.TaoBaoBuyRelationMapService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
import com.yeshi.fanli.service.inter.user.TBPidService;
import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
+import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.TaoBaoConstant;
import com.yeshi.fanli.util.factory.MonitorFactory;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
@@ -49,6 +54,12 @@
@Resource
private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
+ @Resource
+ private UserInfoService userInfoService;
+
+ @Resource
+ private TaoBaoBuyRelationMapService taoBaoBuyRelationMapService;
+
/**
* 鑾峰彇娣樺疂鐨勫垎浜摼鎺�
*
@@ -59,10 +70,16 @@
* @param out
*/
@RequestMapping(value = "gettaobaolink")
- public void getTaobaoShareLink(AcceptData acceptData, Long uid, Long auctionId, HttpServletRequest request,
+ public void getTaoBaoLink(AcceptData acceptData, Long uid, Long auctionId, HttpServletRequest request,
PrintWriter out) {
if (uid == null || uid <= 0) {
out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛ID涓嶈兘涓虹┖"));
+ return;
+ }
+
+ UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
+ if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
+ out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
return;
}
@@ -71,47 +88,95 @@
return;
}
+ TaoBaoGoodsBrief goods = null;
+
+ try {
+ goods = TaoKeApiUtil.getSimpleGoodsInfo(auctionId);
+ } catch (TaobaoGoodsDownException e) {
+ out.print(JsonUtil.loadFalseResult(3, "鍟嗗搧宸蹭笅鏋�"));
+ return;
+ } catch (Exception e) {
+ try {
+ LogHelper.errorDetailInfo(e, "鑾峰彇鍟嗗搧绠�鐗堣鎯呭嚭閿�", auctionId + "");
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ }
+
JSONObject data = new JSONObject();
boolean isNative = false;
String pid = null;
+ boolean specialConvert = false;
+
+ if (goods.getMaterialLibType() != null && goods.getMaterialLibType() == 1) {
+ specialConvert = true;
+ } else
+ specialConvert = false;
+
String specialId = null;
+ String relationId = null;
// 鏌ヨ鐢ㄦ埛ID鏄惁缁戝畾浜嗕細鍛樿繍钀D
UserExtraTaoBaoInfo userInfo = userExtraTaoBaoInfoService.getByUid(uid);
if (userInfo != null && !StringUtil.isNullOrEmpty(userInfo.getSpecialId()) && userInfo.getSpecialValid() != null
&& userInfo.getSpecialValid() == true) {
specialId = userInfo.getSpecialId();
+ relationId = userInfo.getRelationId();
// 宸茬粡缁戝畾
- try {
- TaoBaoGoodsBrief goods = TaoKeApiUtil.getSimpleGoodsInfo(auctionId);
- if (goods.getMaterialLibType() != null && goods.getMaterialLibType() == 1) {
- isNative = true;
- } else
- isNative = false;
- } catch (TaobaoGoodsDownException e) {
- out.print(JsonUtil.loadFalseResult(3, "鍟嗗搧宸蹭笅鏋�"));
- return;
- }
+ if (specialConvert) {
+ isNative = true;
+ } else
+ isNative = false;
- pid = Constant.TAOBAO_SPECIAL_PID_DEFAULT;
+ pid = TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT;
} else {// 灏氭湭缁戝畾
isNative = true;
}
data.put("native", isNative);
+
+ int pidType = PidUser.TYPE_FANLI_ANDROID;
+ if (acceptData.getPlatform().equalsIgnoreCase("ios"))
+ pidType = PidUser.TYPE_FANLI_IOS;
try {
- int pidType = PidUser.TYPE_FANLI_ANDROID;
- if (acceptData.getPlatform().equalsIgnoreCase("ios"))
- pidType = PidUser.TYPE_FANLI_IOS;
TaoBaoLink taoBaoLink = null;
- if (!StringUtil.isNullOrEmpty(specialId)) {
- taoBaoLink = shareGoodsService.getTaoBaoLinkForBuyWithSpecial(uid, specialId, auctionId);
- } else {
- taoBaoLink = shareGoodsService.getTaoBaoLinkForBuy(uid, auctionId, pidType);
+ // 鏄繑鍒╁晢鍝佸簱鐨勫晢鍝�
+ if (specialConvert) {
+ if (!StringUtil.isNullOrEmpty(specialId)) {
+ taoBaoLink = shareGoodsService.getTaoBaoLinkForBuyWithSpecial(uid, specialId, auctionId);
+ data.put("native", true);
+ } else {
+ if (!specialConvert && !isNative) {
+ if (pidType == PidUser.TYPE_FANLI_ANDROID)
+ taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
+ tbPidService.getAndroidDefault().getPid());
+ else
+ taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
+ tbPidService.getIOSDefault().getPid());
+ } else
+ taoBaoLink = shareGoodsService.getTaoBaoLinkForBuy(uid, auctionId, pidType);
+ }
+ } else {// 涓嶆槸杩斿埄搴撶殑鍟嗗搧锛岀敤鐗规畩PID鏇夸唬
+ try {
+ relationId = taoBaoBuyRelationMapService.getRelationId(uid);
+ } catch (Exception e) {
+ LogHelper.errorDetailInfo(e, "uid:" + uid, null);
+ }
+ if (!StringUtil.isNullOrEmpty(relationId)) {//
+ taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId,
+ TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
+ data.put("native", true);
+ } else {
+ if (pidType == PidUser.TYPE_FANLI_ANDROID)
+ taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
+ tbPidService.getAndroidDefault().getPid());
+ else
+ taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
+ tbPidService.getIOSDefault().getPid());
+ }
}
-
JSONObject link = new JSONObject();
link.put("clickUrl", taoBaoLink.getClickUrl());
link.put("couponUrl", taoBaoLink.getCouponLink());
@@ -151,4 +216,51 @@
}
+ /**
+ * 鏄惁鍦ㄥ弬涓庢帹骞�
+ */
+
+ /**
+ * 鏄惁鍦ㄥ弬涓庢帹骞�
+ *
+ * @param goodsId
+ * -鍟嗗搧ID
+ * @param goodsType
+ * -TB/JD
+ * @param out
+ */
+ @RequestMapping(value = "isGoodsExtend")
+ public void isGoodsExtend(AcceptData acceptData, String goodsId, String goodsType, PrintWriter out) {
+ if (StringUtil.isNullOrEmpty(goodsId)) {
+ out.print(JsonUtil.loadFalseResult(1, "鏈弬涓庢帹骞�"));
+ return;
+ }
+ if (StringUtil.isNullOrEmpty(goodsType)) {
+ out.print(JsonUtil.loadFalseResult(2, "缂哄皯goodsType"));
+ return;
+ }
+ if ("TB".equalsIgnoreCase(goodsType)) {
+ TaoBaoGoodsBrief goods = null;
+ try {
+ goods = TaoKeApiUtil.getSimpleGoodsInfo(Long.parseLong(goodsId));
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ } catch (TaobaoGoodsDownException e) {
+ e.printStackTrace();
+ }
+
+ JSONObject data = new JSONObject();
+
+ if (goods == null) {
+ data.put("extend", false);
+ data.put("url", "https://h5.m.taobao.com/awp/core/detail.htm?id=" + goodsId);
+ } else {
+ data.put("extend", true);
+ }
+ out.print(JsonUtil.loadTrueResult(data));
+ } else {
+ out.print(JsonUtil.loadFalseResult(3, "鏆備笉鏀寔鍏朵粬鍟嗗搧绫诲瀷"));
+ }
+ }
+
}
--
Gitblit v1.8.0