From 89e89fe2b2a1578a94b2e2c8ee81efbfbbf85f08 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期五, 23 八月 2019 14:18:42 +0800
Subject: [PATCH] 兑换邀请码调整
---
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java | 319 ++++++++++++++++++++++++++++------------------------
1 files changed, 172 insertions(+), 147 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
index 9301a50..5217831 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -3,10 +3,12 @@
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
+import org.json.simple.JSONArray;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -17,6 +19,7 @@
import com.yeshi.fanli.dto.jd.JDCouponInfo;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
+import com.yeshi.fanli.dto.pdd.PDDPromotionUrl;
import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.ShamUser;
@@ -410,7 +413,7 @@
// 鎺ㄥ箍绾㈠寘
if (from != null && from.equals("taolijin")) {
// 璁$畻鎺ㄥ箍绾㈠寘
- String warningRate = configTaoLiJinService.getValueByKey("warning_value");
+ String warningRate = configTaoLiJinService.getValueByKey("warning_value", new Date());
BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods);
// 鎺ㄥ箍绾㈠寘 涓嶈兘灏忎簬1
@@ -419,8 +422,8 @@
return;
}
- // 鏄惁涓烘柊鐢ㄦ埛
- boolean isNewUser = userInfoExtraService.isNewUser(uid);
+ // 鍙栨秷鏂扮敤鎴疯嚜璐�
+ boolean isNewUser = false;// userInfoExtraService.isNewUser(uid);
if (isNewUser) {
// 鍒ゅ畾涓鸿�佺敤鎴凤細 鏂颁汉鍙浣跨敤浜嗘柊浜虹孩鍖咃紝涔熷氨鏄偅1鍧楅挶锛岄偅涔堬紝浠栫湅鍒扮殑鍒嗕韩鐖嗘涓殑鍟嗗搧-灏卞彧鑳藉垎浜��
long countRecord = userTaoLiJinRecordService.countRecordByUid(uid);
@@ -464,6 +467,11 @@
otherInfo.setSpreadHongBao(spreadHongBao);
goodsDetail.setOtherInfo(otherInfo);
+ goodsDetail.getMoneyInfo().setFanliMoney(TaoBaoUtil.getGoodsHongBaoInfo(goods,
+ hongBaoManageService.getTLJShareRate(System.currentTimeMillis())));
+ goodsDetail.getMoneyInfo().setShareMoney(TaoBaoUtil.getGoodsHongBaoInfo(goods,
+ hongBaoManageService.getTLJShareRate(System.currentTimeMillis())));
+
// 鐢ㄦ埛娣樼ぜ閲�
UserMoneyExtra userMoneyExtra = userMoneyExtraService.selectByPrimaryKey(uid);
if (userMoneyExtra == null || userMoneyExtra.getTlj() == null) {
@@ -471,7 +479,7 @@
} else {
extraVO.setUserTLJ(userMoneyExtra.getTlj().setScale(2).toString());
}
- helpLink = configTaoLiJinService.getValueByKey("share_goods_help_link");
+ helpLink = configTaoLiJinService.getValueByKey("share_goods_help_link", new Date());
} else if (from != null && from.equals("taolijin_buy")) {
// 鏌ヨ鍒嗕韩搴�
@@ -583,8 +591,7 @@
if (couponInfo != null) {
// 鍒搁摼鎺ュ鐞�
String materialId = "https://item.jd.com/" + id + ".html";
- String url = JDApiUtil.convertLink(materialId, couponInfo.getLink(), JDApiUtil.POSITION_COUPON + "",
- null);
+ String url = JDApiUtil.convertLink(materialId, couponInfo.getLink(), JDApiUtil.POSITION_COUPON + "", null);
couponInfo.setLink(url);
}
@@ -715,9 +722,11 @@
BigDecimal shareRate = hongBaoManageService.getShareRate();
GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, fanLiRate, shareRate);
CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
+ PDDPromotionUrl convertUrl = null;
if (couponInfo != null) {
- String url = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_COUPON + "", null);
- couponInfo.setLink(url);
+ convertUrl = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_COUPON + "", null);
+ if (convertUrl != null)
+ couponInfo.setLink(convertUrl.getUrl());
}
ShopInfoVO shopInfo = goodsDetail.getShopInfo();
@@ -741,6 +750,11 @@
String salesTip = pddGoods.getSalesTip();
if (!StringUtil.isNullOrEmpty(salesTip)) {
+ int indexOf = salesTip.indexOf("+");
+ if (indexOf > 0) {
+ salesTip = salesTip.substring(0, indexOf);
+ }
+
int totalSales = 0;
if (salesTip.contains("涓�")) {
salesTip = salesTip.substring(0, salesTip.indexOf("涓�"));
@@ -776,12 +790,7 @@
extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_PDD));
}
- // 娴嬭瘯
- SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system,
- "goods_detail_jump_taobao");
- if ("1".equalsIgnoreCase((params.getValue() + "").trim())) {
- extraVO.setIsNative(true);
- }
+ extraVO.setIsNative(true);
// 鍒嗕韩璺緞
String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
@@ -803,6 +812,11 @@
ShareVO shareInfoVO = new ShareVO();
shareInfoVO.setHelpLink(helpLink);
extraVO.setShare(shareInfoVO);
+
+ if (convertUrl != null) {
+ extraVO.setCouponJumpLink(convertUrl.getUrl());
+ extraVO.setNativeCouponJumpLink(PinDuoDuoUtil.getAndroidNativeURI(convertUrl.getUrl()));
+ }
JSONObject object = new JSONObject();
object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
@@ -834,148 +848,158 @@
goodsType = Constant.SOURCE_TYPE_TAOBAO;
}
- // 浜笢
- if (goodsType == Constant.SOURCE_TYPE_JD) {
- JSONObject data = new JSONObject();
- data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
-
- List<JDGoods> list = JDUtil.getRecommendGoodsById(id);
- if (list == null) {
- list = new ArrayList<JDGoods>();
- } else if (list.size() > 10) {
- list = list.subList(0, 10);
- }
-
- BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
- BigDecimal shareRate = hongBaoManageService.getShareRate();
- List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
-
- for (JDGoods goods : list) {
- listDetailVO.add(GoodsDetailVOFactory.convertJDGoods(goods, fanLiRate, shareRate));
- }
-
- // 鍙栧伓鏁颁釜鏁版嵁
- if (listDetailVO.size() % 2 != 0) {
- listDetailVO.remove(listDetailVO.size() - 1);
- }
-
- data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
- out.print(JsonUtil.loadTrueResult(data));
- return;
- }
-
- // 鎷煎澶�
- if (goodsType == Constant.SOURCE_TYPE_PDD) {
- JSONObject data = new JSONObject();
- data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
-
- List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
-
- List<Long> goodsIdList = PinDuoDuoUtil.getRecommendGoodsId(id);
- if (goodsIdList != null && goodsIdList.size() > 0) {
- PDDSearchFilter pddfilter = new PDDSearchFilter();
- pddfilter.setPage(1);
- pddfilter.setPageSize(Constant.PAGE_SIZE);
- Long[] strings = new Long[goodsIdList.size()];
- pddfilter.setGoodsIdList(goodsIdList.toArray(strings));
-
- PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
- if (result != null) {
- List<PDDGoodsDetail> goodsList = result.getGoodsList();
- if (goodsList != null && goodsList.size() > 0) {
-
- if (goodsList.size() > 10) {
- goodsList = goodsList.subList(0, 10);
- }
-
- BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
- BigDecimal shareRate = hongBaoManageService.getShareRate();
- for (PDDGoodsDetail goods : goodsList) {
- listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, fanLiRate, shareRate));
- }
- }
- }
- }
-
- // 鍙栧伓鏁颁釜鏁版嵁
- if (listDetailVO.size() % 2 != 0) {
- listDetailVO.remove(listDetailVO.size() - 1);
- }
-
- data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
- out.print(JsonUtil.loadTrueResult(data));
- return;
- }
-
- List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getRelationGoodsRecommend(id, 10);
- // 鍒濆鍖�
- if (goodsList == null) {
- goodsList = new ArrayList<TaoBaoGoodsBrief>();
- }
-
- List<GoodsDetailVO> listExtra = new ArrayList<GoodsDetailVO>();
- TaoKeAppInfo app = new TaoKeAppInfo();
- app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
- app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
- app.setAdzoneId(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]);
- app.setPid(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT);
-
- List<Long> ids = new ArrayList<>();
- for (TaoBaoGoodsBrief goods : goodsList)
- ids.add(goods.getAuctionId());
-
try {
- goodsList = TaoKeApiUtil.getBatchGoodsInfo(ids);
- } catch (TaoKeApiException e1) {
- e1.printStackTrace();
- } catch (TaobaoGoodsDownException e1) {
- e1.printStackTrace();
- }
- if (goodsList != null && goodsList.size() > 0) {
+ // 浜笢
+ if (goodsType == Constant.SOURCE_TYPE_JD) {
+ JSONObject data = new JSONObject();
+ data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
- BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
- BigDecimal shareRate = hongBaoManageService.getShareRate();
+ List<JDGoods> list = JDUtil.getRecommendGoodsById(id);
+ if (list == null) {
+ list = new ArrayList<JDGoods>();
+ } else if (list.size() > 10) {
+ list = list.subList(0, 10);
+ }
- goodsList.parallelStream().forEach(goods -> {
- if (goods != null) {
- // 鑾峰彇璇︽儏
- TaoBaoGoodsBrief taoBaoGoodsBrief = null;
- try {
- taoBaoGoodsBrief = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goods.getAuctionId());
- } catch (Exception e) {
- e.printStackTrace();
- }
+ BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
+ BigDecimal shareRate = hongBaoManageService.getShareRate();
+ List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
- if (taoBaoGoodsBrief == null) {
- TaoBaoGoodsBrief newGoods = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app);
- goods.setCouponInfo(newGoods.getCouponInfo());
- goods.setCouponLink(newGoods.getCouponLink());
- goods.setTkRate(newGoods.getTkRate());
- taoBaoGoodsBrief = goods;
- }
+ for (JDGoods goods : list) {
+ listDetailVO.add(GoodsDetailVOFactory.convertJDGoods(goods, fanLiRate, shareRate));
+ }
- if (taoBaoGoodsBrief != null) {
- listExtra.add(GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate, shareRate));
+ // 鍙栧伓鏁颁釜鏁版嵁
+ if (listDetailVO.size() % 2 != 0) {
+ listDetailVO.remove(listDetailVO.size() - 1);
+ }
+
+ data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
+ out.print(JsonUtil.loadTrueResult(data));
+ return;
+ }
+
+ // 鎷煎澶�
+ if (goodsType == Constant.SOURCE_TYPE_PDD) {
+ JSONObject data = new JSONObject();
+ data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
+
+ List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
+
+ List<Long> goodsIdList = PinDuoDuoUtil.getRecommendGoodsId(id);
+ if (goodsIdList != null && goodsIdList.size() > 0) {
+ PDDSearchFilter pddfilter = new PDDSearchFilter();
+ pddfilter.setPage(1);
+ pddfilter.setPageSize(Constant.PAGE_SIZE);
+ Long[] strings = new Long[goodsIdList.size()];
+ pddfilter.setGoodsIdList(goodsIdList.toArray(strings));
+
+ PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
+ if (result != null) {
+ List<PDDGoodsDetail> goodsList = result.getGoodsList();
+ if (goodsList != null && goodsList.size() > 0) {
+
+ if (goodsList.size() > 10) {
+ goodsList = goodsList.subList(0, 10);
+ }
+
+ BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
+ BigDecimal shareRate = hongBaoManageService.getShareRate();
+ for (PDDGoodsDetail goods : goodsList) {
+ listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, fanLiRate, shareRate));
+ }
+ }
}
}
- });
- }
- List<GoodsDetailVO> listQuality = new ArrayList<GoodsDetailVO>();
- // 鍙栧伓鏁颁釜鏁版嵁
- if (listExtra.size() % 2 != 0) {
- listExtra.remove(listExtra.size() - 1);
- }
+ // 鍙栧伓鏁颁釜鏁版嵁
+ if (listDetailVO.size() % 2 != 0) {
+ listDetailVO.remove(listDetailVO.size() - 1);
+ }
- if (listQuality.size() % 2 != 0) {
- listQuality.remove(listQuality.size() - 1);
- }
+ data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
+ out.print(JsonUtil.loadTrueResult(data));
+ return;
+ }
- JSONObject data = new JSONObject();
- data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listExtra));
- data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listQuality));
- out.print(JsonUtil.loadTrueResult(data));
+ List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.getRelationGoodsRecommend(id, 10);
+ // 鍒濆鍖�
+ if (goodsList == null) {
+ goodsList = new ArrayList<TaoBaoGoodsBrief>();
+ }
+
+ List<GoodsDetailVO> listExtra = new ArrayList<GoodsDetailVO>();
+ TaoKeAppInfo app = new TaoKeAppInfo();
+ app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
+ app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
+ app.setAdzoneId(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]);
+ app.setPid(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT);
+
+ List<Long> ids = new ArrayList<>();
+ for (TaoBaoGoodsBrief goods : goodsList)
+ ids.add(goods.getAuctionId());
+
+ try {
+ goodsList = TaoKeApiUtil.getBatchGoodsInfo(ids);
+ } catch (TaoKeApiException e1) {
+ e1.printStackTrace();
+ } catch (TaobaoGoodsDownException e1) {
+ e1.printStackTrace();
+ }
+
+ if (goodsList != null && goodsList.size() > 0) {
+
+ BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
+ BigDecimal shareRate = hongBaoManageService.getShareRate();
+
+ goodsList.parallelStream().forEach(goods -> {
+ if (goods != null) {
+ // 鑾峰彇璇︽儏
+ TaoBaoGoodsBrief taoBaoGoodsBrief = null;
+ try {
+ taoBaoGoodsBrief = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goods.getAuctionId());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ if (taoBaoGoodsBrief == null) {
+ TaoBaoGoodsBrief newGoods = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app);
+ goods.setCouponInfo(newGoods.getCouponInfo());
+ goods.setCouponLink(newGoods.getCouponLink());
+ goods.setTkRate(newGoods.getTkRate());
+ taoBaoGoodsBrief = goods;
+ }
+
+ if (taoBaoGoodsBrief != null) {
+ listExtra.add(
+ GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, fanLiRate, shareRate));
+ }
+ }
+ });
+ }
+
+ List<GoodsDetailVO> listQuality = new ArrayList<GoodsDetailVO>();
+ // 鍙栧伓鏁颁釜鏁版嵁
+ if (listExtra.size() % 2 != 0) {
+ listExtra.remove(listExtra.size() - 1);
+ }
+
+ if (listQuality.size() % 2 != 0) {
+ listQuality.remove(listQuality.size() - 1);
+ }
+
+ JSONObject data = new JSONObject();
+ data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listExtra));
+ data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listQuality));
+ out.print(JsonUtil.loadTrueResult(data));
+ } catch (Exception e) {
+ LogHelper.errorDetailInfo(e);
+ JSONObject data = new JSONObject();
+ data.put("listQuality", new JSONArray());
+ data.put("listGuess", new JSONArray());
+ out.print(JsonUtil.loadTrueResult(data));
+ }
}
/**
@@ -1060,10 +1084,11 @@
return;
}
- String jumpLink = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_FANLI + "", uid + "");
+ PDDPromotionUrl convertUrl = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_FANLI + "", uid + "");
JSONObject data = new JSONObject();
data.put("native", true);
- data.put("jumpLink", jumpLink);
+ data.put("jumpLink", convertUrl.getUrl());
+ data.put("nativeJumpLink", PinDuoDuoUtil.getAndroidNativeURI(convertUrl.getUrl()));
out.print(JsonUtil.loadTrueResult(data));
}
--
Gitblit v1.8.0