From 3ce9e928e082ff8abf697dba560cbfbb412e89f8 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期一, 11 十一月 2019 15:45:02 +0800
Subject: [PATCH] 商城后台编辑
---
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java | 453 +++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 298 insertions(+), 155 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 0bb666b..89b75a2 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;
@@ -14,9 +16,12 @@
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.taobao.TbImgUtil;
+import com.yeshi.fanli.dto.ConfigParamsDTO;
+import com.yeshi.fanli.dto.jd.JDCategoryInfo;
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;
@@ -24,6 +29,7 @@
import com.yeshi.fanli.entity.bus.user.UserMoneyExtra;
import com.yeshi.fanli.entity.goods.CollectionGoodsV2;
import com.yeshi.fanli.entity.jd.JDGoods;
+import com.yeshi.fanli.entity.jd.JDGoodsClass;
import com.yeshi.fanli.entity.system.BusinessSystem;
import com.yeshi.fanli.entity.system.SystemClientParams;
import com.yeshi.fanli.entity.taobao.ClientTBPid;
@@ -36,13 +42,16 @@
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException;
import com.yeshi.fanli.log.LogHelper;
+import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.config.BusinessSystemService;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.config.SystemClientParamsService;
import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service;
import com.yeshi.fanli.service.inter.goods.ScanHistoryV2Service;
import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
-import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
+import com.yeshi.fanli.service.inter.jd.JDGoodsClassService;
+import com.yeshi.fanli.service.inter.money.UserMoneyExtraService;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
@@ -56,8 +65,9 @@
import com.yeshi.fanli.service.inter.user.UserGoodsStorageService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
-import com.yeshi.fanli.service.inter.user.UserMoneyExtraService;
+import com.yeshi.fanli.service.inter.user.integral.IntegralGetService;
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;
@@ -80,6 +90,7 @@
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import com.yeshi.fanli.vo.goods.MoneyInfoVO;
import com.yeshi.fanli.vo.goods.OtherInfo;
+import com.yeshi.fanli.vo.goods.RewardCouponVO;
import com.yeshi.fanli.vo.goods.ShareVO;
import com.yeshi.fanli.vo.goods.ShopInfoVO;
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
@@ -167,6 +178,15 @@
@Resource
private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
+ @Resource
+ private IntegralGetService integralGetService;
+
+ @Resource
+ private JumpDetailV2Service jumpDetailV2Service;
+
+ @Resource
+ private JDGoodsClassService jdGoodsClassService;
+
/**
* 娣樺疂鍟嗗搧璇︽儏
*
@@ -246,7 +266,6 @@
taoBaoGoodsUpdateService.offlineTaoBaoGoods(id);
}
});
-
}
} else {
@@ -330,7 +349,17 @@
BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
BigDecimal shareRate = hongBaoManageService.getShareRate();
- GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertTaoBao(goods, null, fanLiRate, shareRate);
+ ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
+ GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO);
+
+ if (TaoBaoUtil.isYUShou(goods)) {
+ if (!StringUtil.isNullOrEmpty(goods.getPresaleDiscountFeeText())) {
+ if (goodsDetail.getLabels() == null)
+ goodsDetail.setLabels(new ArrayList<>());
+ goodsDetail.getLabels().add(new ClientTextStyleVO(goods.getPresaleDiscountFeeText(), "#FF2B4E"));
+ }
+ }
+ // 鍦ㄦ爣棰樻坊鍔犱紭鎯犱俊鎭�
// 搴楅摵淇℃伅
TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(id, goods.getSellerId());
@@ -410,7 +439,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 +448,8 @@
return;
}
- // 鏄惁涓烘柊鐢ㄦ埛
- boolean isNewUser = userInfoExtraService.isNewUser(uid);
+ // 鍙栨秷鏂扮敤鎴疯嚜璐�
+ boolean isNewUser = false;// userInfoExtraService.isNewUser(uid);
if (isNewUser) {
// 鍒ゅ畾涓鸿�佺敤鎴凤細 鏂颁汉鍙浣跨敤浜嗘柊浜虹孩鍖咃紝涔熷氨鏄偅1鍧楅挶锛岄偅涔堬紝浠栫湅鍒扮殑鍒嗕韩鐖嗘涓殑鍟嗗搧-灏卞彧鑳藉垎浜��
long countRecord = userTaoLiJinRecordService.countRecordByUid(uid);
@@ -464,6 +493,20 @@
otherInfo.setSpreadHongBao(spreadHongBao);
goodsDetail.setOtherInfo(otherInfo);
+ // 1.6.5鍚庢敼涓虹鍒╀环
+ if (com.yeshi.fanli.util.VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) {
+ if (goodsDetail.getCouponPrice() != null
+ && goodsDetail.getCouponPrice().compareTo(new BigDecimal(0)) > 0)
+ goodsDetail.setCouponPrice(goodsDetail.getCouponPrice().subtract(spreadMoney));
+ else
+ goodsDetail.setZkPrice(goodsDetail.getZkPrice().subtract(spreadMoney));
+ }
+
+ 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 +514,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")) {
// 鏌ヨ鍒嗕韩搴�
@@ -487,17 +530,38 @@
shareValid = false;
helpLink = configService.get("zigoulijian_nofanli_help");
- String tljHongBao = TaoBaoUtil.getGoodsHongBaoMoney(goods, new BigDecimal(70)).toString();
+ BigDecimal tljHongBao = TaoBaoUtil.getGoodsHongBaoMoney(goods, TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE);
ReduceHongBao reduceHongBao = new ReduceHongBao();
reduceHongBao.setLeft(buyGoods.getLeftHongBaoCount());
- reduceHongBao.setMoney(tljHongBao);
+ reduceHongBao.setMoney(tljHongBao.toString());
reduceHongBao.setName("浠樻绔嬪噺 ");
reduceHongBao.setTip("褰撴棩棰嗗彇锛屽綋鏃ュ唴浣跨敤锛岃繃鏈熷け鏁�");
reduceHongBao.setTotal(buyGoods.getTotalHongBaoCount());
OtherInfo otherInfo = new OtherInfo();
otherInfo.setReduceHongBao(reduceHongBao);
+ goodsDetail.setOtherInfo(otherInfo);
+
+ // 1.6.5鍚庢敼涓虹鍒╀环
+ if (com.yeshi.fanli.util.VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) {
+ if (goodsDetail.getCouponPrice() != null
+ && goodsDetail.getCouponPrice().compareTo(new BigDecimal(0)) > 0)
+ goodsDetail.setCouponPrice(goodsDetail.getCouponPrice().subtract(tljHongBao));
+ else
+ goodsDetail.setZkPrice(goodsDetail.getZkPrice().subtract(tljHongBao));
+ }
+ } else {// 鏅�氳喘涔�
+ OtherInfo otherInfo = new OtherInfo();
+ RewardCouponVO rewardCoupon = new RewardCouponVO();
+ rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
+ JSONObject params1 = new JSONObject();
+ params1.put("url", configService.get("special_guide_reward_coupon_link"));
+ rewardCoupon.setParams(params1.toString());
+ rewardCoupon.setMaxMoney("楼" + TaoBaoUtil.getGoodsHongBaoMoney(goods, fanLiRate).add(MoneyBigDecimalUtil
+ .mul(TaoBaoUtil.getGoodsHongBaoMoney(goods, fanLiRate), Constant.MAX_REWARD_RATE)));
+ rewardCoupon.setDesc("鐢ㄨ繑鍒╁鍔卞埜鏈�楂樿繑");
+ otherInfo.setRewardCoupon(rewardCoupon);
goodsDetail.setOtherInfo(otherInfo);
}
extraVO.setFanliValid(fanliValid);
@@ -577,14 +641,53 @@
BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
BigDecimal shareRate = hongBaoManageService.getShareRate();
- GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, fanLiRate, shareRate);
+ ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
+ GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO);
+
+ // 闄勫姞淇℃伅
+ OtherInfo otherInfo = new OtherInfo();
+
+ // 浜笢plus杩斿埄
+ String maxMoneyPlus = null;
+ JDCategoryInfo categoryInfo = jdGoods.getCategoryInfo();
+ if (categoryInfo != null && categoryInfo.getCid3() != null && jdGoods.getCommissionInfo() != null) {
+ Long cid3 = categoryInfo.getCid3();
+ JDGoodsClass threeClass = jdGoodsClassService.getThreeClassByCid(Integer.parseInt(cid3.toString()));
+ if (threeClass != null && threeClass.getSelfComm() != null
+ && threeClass.getSelfComm().compareTo(new BigDecimal(0)) > 0) {
+ BigDecimal commissionShare = jdGoods.getCommissionInfo().getCommissionShare();
+ // plus姣斾緥 灏忎簬姝e父姣斾緥
+ if (commissionShare != null && commissionShare.compareTo(threeClass.getSelfComm()) > 0) {
+ jdGoods.setCommissionPlus(threeClass.getSelfComm());
+ // plus杩斿埄
+ BigDecimal fanliMoneyPlus = JDUtil.getGoodsFanLiMoneyPlus(jdGoods, fanLiRate);
+ otherInfo.setFanliMoneyPlus("浜笢plus浼氬憳杩斅�" + fanliMoneyPlus);
+ // 浣跨敤濂栧姳鍒告渶楂樿繑
+ maxMoneyPlus = "锛堜含涓減lus浼氬憳鏈�楂樿繑楼"
+ + fanliMoneyPlus.add(MoneyBigDecimalUtil.mul(fanliMoneyPlus, Constant.MAX_REWARD_RATE))
+ + "锛�";
+ }
+ }
+ }
+
+ // 濂栧姳鍒歌繑鍒�
+ RewardCouponVO rewardCoupon = new RewardCouponVO();
+ rewardCoupon.setMaxMoneyPlus(maxMoneyPlus);
+ rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
+ JSONObject params1 = new JSONObject();
+ params1.put("url", configService.get("special_guide_reward_coupon_link"));
+ rewardCoupon.setParams(params1.toString());
+ rewardCoupon.setMaxMoney("楼" + JDUtil.getGoodsFanLiMoney(jdGoods, fanLiRate)
+ .add(MoneyBigDecimalUtil.mul(JDUtil.getGoodsFanLiMoney(jdGoods, fanLiRate), Constant.MAX_REWARD_RATE)));
+ rewardCoupon.setDesc("鐢ㄨ繑鍒╁鍔卞埜鏈�楂樿繑");
+ otherInfo.setRewardCoupon(rewardCoupon);
+ goodsDetail.setOtherInfo(otherInfo);
CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
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);
}
@@ -713,11 +816,28 @@
BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
BigDecimal shareRate = hongBaoManageService.getShareRate();
- GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, fanLiRate, shareRate);
+ ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
+ GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, paramsDTO);
+
+ // 闄勫姞淇℃伅
+ OtherInfo otherInfo = new OtherInfo();
+ RewardCouponVO rewardCoupon = new RewardCouponVO();
+ rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
+ JSONObject params1 = new JSONObject();
+ params1.put("url", configService.get("special_guide_reward_coupon_link"));
+ rewardCoupon.setParams(params1.toString());
+ rewardCoupon.setMaxMoney("楼" + PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods, fanLiRate).add(MoneyBigDecimalUtil
+ .mul(PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods, fanLiRate), Constant.MAX_REWARD_RATE)));
+ rewardCoupon.setDesc("鐢ㄨ繑鍒╁鍔卞埜鏈�楂樿繑");
+ otherInfo.setRewardCoupon(rewardCoupon);
+ goodsDetail.setOtherInfo(otherInfo);
+
CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
+ PDDPromotionUrl convertUrl = null;
if (couponInfo != null) {
- String url = PinDuoDuoApiUtil.getPromotionUrl(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 +861,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 +901,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 +923,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 +959,159 @@
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();
+ ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
+ 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, paramsDTO));
+ }
- 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();
+ ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
+ for (PDDGoodsDetail goods : goodsList) {
+ listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO));
+ }
+ }
}
}
- });
- }
- 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) {
+ } catch (TaobaoGoodsDownException e1) {
+ }
+
+ if (goodsList != null && goodsList.size() > 0) {
+
+ BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
+ BigDecimal shareRate = hongBaoManageService.getShareRate();
+ ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
+
+ 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, paramsDTO));
+ }
+ }
+ });
+ }
+
+ 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));
+ }
}
/**
@@ -1024,6 +1160,9 @@
data.put("native", true);
data.put("jumpLink", jumpLink);
out.print(JsonUtil.loadTrueResult(data));
+
+ // 鑾峰緱閲戝竵
+ integralGetService.addCouponRebate(uid);
}
/**
@@ -1060,11 +1199,15 @@
return;
}
- String jumpLink = PinDuoDuoApiUtil.getPromotionUrl(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));
+
+ // 鑾峰緱閲戝竵
+ integralGetService.addCouponRebate(uid);
}
/**
--
Gitblit v1.8.0