From d0f12da013131cd291cec6e81a12d661c02c4bf4 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期二, 17 三月 2020 12:14:27 +0800
Subject: [PATCH] 2.1
---
fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5ShareController.java | 218 ++++++++++++++++++++++++++----------------------------
1 files changed, 104 insertions(+), 114 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5ShareController.java b/fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5ShareController.java
index 530fc9c..e394938 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5ShareController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5ShareController.java
@@ -13,6 +13,7 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import com.yeshi.fanli.dto.ConfigParamsDTO;
import com.yeshi.fanli.dto.jd.JDFilter;
import com.yeshi.fanli.dto.jd.JDSearchResult;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
@@ -22,11 +23,14 @@
import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.jd.JDGoods;
-import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
+import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
+import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.jd.JDApiUtil;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
+import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import net.sf.json.JSONArray;
@@ -46,8 +50,10 @@
* 鍒嗕韩鍟嗗搧璇︽儏
*
* @param callback
- * @param shareId 鍒嗕韩id
- * @param source 鏉ユ簮
+ * @param shareId
+ * 鍒嗕韩id
+ * @param source
+ * 鏉ユ簮
* @param out
*/
@RequestMapping(value = "getDetail")
@@ -71,15 +77,17 @@
}
/**
- * 鍒嗕韩鍟嗗搧璇︽儏
+ * 鍒嗕韩鍟嗗搧鍒楄〃
*
* @param callback
- * @param shareId 鍒嗕韩id
- * @param source 鏉ユ簮
+ * @param shareId
+ * 鍒嗕韩id
+ * @param source
+ * 鏉ユ簮
* @param out
*/
- @RequestMapping(value = "getListJD")
- public void getListJD(String callback, Long shareId, PrintWriter out) {
+ @RequestMapping(value = "getList")
+ public void getList(String callback, Long shareId, PrintWriter out) {
try {
if (shareId == null) {
JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("浼犻�掑弬鏁颁笉姝g‘"));
@@ -90,46 +98,98 @@
List<UserShareGoodsGroup> list = userShareGoodsRecordService.listByRecordId(shareId);
if (list != null && list.size() > 0) {
- List<Long> listGid = new ArrayList<Long>();
+ List<Long> listIdTB = new ArrayList<Long>();
+ List<Long> listIdJD = new ArrayList<Long>();
+ List<Long> listIdPDD = new ArrayList<Long>();
+
for (int i = 0; i < list.size(); i++) {
CommonGoods commonGoods = list.get(i).getCommonGoods();
if (commonGoods == null) {
continue;
}
- listGid.add(commonGoods.getGoodsId());
+
+ Integer goodsType = commonGoods.getGoodsType();
+ if (goodsType == null) {
+ continue;
+ }
+
+ if (Constant.SOURCE_TYPE_TAOBAO == goodsType) {
+ listIdTB.add(commonGoods.getGoodsId());
+ } else if (Constant.SOURCE_TYPE_JD == goodsType) {
+ listIdJD.add(commonGoods.getGoodsId());
+ } else if (Constant.SOURCE_TYPE_PDD == goodsType) {
+ listIdPDD.add(commonGoods.getGoodsId());
+ }
}
- // API缃戠粶鎺ュ彛楠岃瘉鏄惁鍦ㄥ敭
- List<JDGoods> listGoods = null;
- try {
- JDFilter filter = new JDFilter();
- filter.setListId(listGid);
- filter.setPageIndex(1);
- filter.setPageSize(100);
- JDSearchResult result = JDApiUtil.queryByKey(filter);
- if (result != null) {
- listGoods = result.getGoodsList();
+ // 娣樺疂楠岃瘉鏄惁鍦ㄥ敭
+ List<TaoBaoGoodsBrief> listTB = null;
+ if (listIdTB.size() > 0) {
+ try {
+ listTB = TaoKeApiUtil.getBatchGoodsInfo(listIdTB);
+ } catch (Exception e) {
+ e.printStackTrace();
}
- } catch (Exception e) {
- e.printStackTrace();
+ }
+
+ // 浜笢楠岃瘉鏄惁鍦ㄥ敭
+ List<JDGoods> listJD = null;
+ if (listIdJD.size() > 0) {
+ try {
+ JDFilter filter = new JDFilter();
+ filter.setListId(listIdJD);
+ filter.setPageIndex(1);
+ filter.setPageSize(100);
+ JDSearchResult result = JDApiUtil.queryByKey(filter);
+ if (result != null) {
+ listJD = result.getGoodsList();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ // 鎷煎澶氶獙璇佹槸鍚﹀湪鍞�
+ List<PDDGoodsDetail> listPDD = null;
+ if (listIdPDD.size() > 0) {
+ try {
+ Long[] ids = new Long[list.size()];
+ PDDSearchFilter sf = new PDDSearchFilter();
+ sf.setPage(1);
+ sf.setPageSize(100);
+ sf.setGoodsIdList(listIdPDD.toArray(ids));
+ PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(sf);
+ if (result != null) {
+ listPDD = result.getGoodsList();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
BigDecimal shareRate = hongBaoManageService.getShareRate();
+ ConfigParamsDTO configParamsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,
+ hongBaoManageService.getVIPFanLiRate());
+
for (UserShareGoodsGroup goodsGroup : list) {
CommonGoods commonGoods = goodsGroup.getCommonGoods();
if (commonGoods == null) {
continue;
}
+ Integer goodsType = commonGoods.getGoodsType();
+ if (goodsType == null) {
+ goodsType = Constant.SOURCE_TYPE_TAOBAO;
+ }
+ Long commonGid = commonGoods.getGoodsId();
- if (listGoods != null && listGoods.size() > 0) {
+ if (goodsType == Constant.SOURCE_TYPE_TAOBAO && listTB != null && listTB.size() > 0) {
int state = 1; // 榛樿鍋滃敭
- Long commonGid = commonGoods.getGoodsId();
- for (JDGoods goodsDetail : listGoods) {
- Long goodsId =goodsDetail.getSkuId();
+ for (TaoBaoGoodsBrief goodsDetail : listTB) {
+ Long goodsId = goodsDetail.getAuctionId();
if (goodsId == commonGid || goodsId.equals(commonGid)) {
state = 0; // 鍦ㄥ敭
break;
@@ -137,93 +197,11 @@
}
commonGoods.setState(state);
}
-
- GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, null, fanLiRate, shareRate);
- if (!detailVO.isHasCoupon()) {
- detailVO.setState(1);; // 宸叉姠鍏�
- }
- array.add(gson.toJson(detailVO));
- }
- }
- String title = "";
- UserShareGoodsRecord userShareGoodsRecord = userShareGoodsRecordService.selectByPrimaryKey(shareId);
- if (userShareGoodsRecord != null) {
- title = userShareGoodsRecord.getTitle();
- }
-
- JSONObject data = new JSONObject();
- data.put("title", title);
- data.put("count", list.size());
- data.put("result_list", array);
- JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
- } catch (Exception e) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鑾峰彇澶辫触"));
- e.printStackTrace();
- }
- }
-
-
- /**
- * 鍒嗕韩鍟嗗搧璇︽儏
- *
- * @param callback
- * @param shareId 鍒嗕韩id
- * @param source 鏉ユ簮
- * @param out
- */
- @RequestMapping(value = "getListPDD")
- public void getListPDD(String callback, Long shareId, PrintWriter out) {
- try {
- if (shareId == null) {
- JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("浼犻�掑弬鏁颁笉姝g‘"));
- return;
- }
-
- JSONArray array = new JSONArray();
-
- List<UserShareGoodsGroup> list = userShareGoodsRecordService.listByRecordId(shareId);
- if (list != null && list.size() > 0) {
- Long[] listGid = new Long[list.size()];
- for (int i = 0; i < list.size(); i++) {
- CommonGoods commonGoods = list.get(i).getCommonGoods();
- if (commonGoods == null) {
- continue;
- }
- listGid[i] = commonGoods.getGoodsId();
- }
-
- // API缃戠粶鎺ュ彛楠岃瘉鏄惁鍦ㄥ敭
- List<PDDGoodsDetail> listGoods = null;
- try {
- PDDSearchFilter sf = new PDDSearchFilter();
- sf.setPage(1);
- sf.setPageSize(100);
- sf.setGoodsIdList(listGid);
- PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(sf);
- if (result != null) {
- listGoods = result.getGoodsList();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
- .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
- BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
- BigDecimal shareRate = hongBaoManageService.getShareRate();
-
- for (UserShareGoodsGroup goodsGroup : list) {
- CommonGoods commonGoods = goodsGroup.getCommonGoods();
- if (commonGoods == null) {
- continue;
- }
-
- if (listGoods != null && listGoods.size() > 0) {
+ if (goodsType == Constant.SOURCE_TYPE_JD && listJD != null && listJD.size() > 0) {
int state = 1; // 榛樿鍋滃敭
- Long commonGid = commonGoods.getGoodsId();
- for (PDDGoodsDetail goodsDetail : listGoods) {
- Long goodsId =goodsDetail.getGoodsId();
+ for (JDGoods goodsDetail : listJD) {
+ Long goodsId = goodsDetail.getSkuId();
if (goodsId == commonGid || goodsId.equals(commonGid)) {
state = 0; // 鍦ㄥ敭
break;
@@ -231,10 +209,22 @@
}
commonGoods.setState(state);
}
-
- GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, null, fanLiRate, shareRate);
+
+ if (goodsType == Constant.SOURCE_TYPE_PDD && listPDD != null && listPDD.size() > 0) {
+ int state = 1; // 榛樿鍋滃敭
+ for (PDDGoodsDetail goodsDetail : listPDD) {
+ Long goodsId = goodsDetail.getGoodsId();
+ if (goodsId == commonGid || goodsId.equals(commonGid)) {
+ state = 0; // 鍦ㄥ敭
+ break;
+ }
+ }
+ commonGoods.setState(state);
+ }
+ GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, configParamsDTO);
if (!detailVO.isHasCoupon()) {
- detailVO.setState(1);; // 宸叉姠鍏�
+ detailVO.setState(1);
+ ; // 宸叉姠鍏�
}
array.add(gson.toJson(detailVO));
}
--
Gitblit v1.8.0