From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 25 二月 2025 16:41:22 +0800
Subject: [PATCH] 淘宝转链接口更新

---
 fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5ShareController.java |  293 ++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 244 insertions(+), 49 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 adc2f7f..bc8de03 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
@@ -1,49 +1,244 @@
-package com.yeshi.fanli.controller.apph5;
-
-import java.io.PrintWriter;
-
-import javax.annotation.Resource;
-
-import net.sf.json.JSONObject;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.yeshi.utils.JsonUtil;
-
-import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
-
-@Controller
-@RequestMapping("api/apph5/v1/share")
-public class AppH5ShareController {
-
-	@Resource
-	private UserShareGoodsRecordService userShareGoodsRecordService;
-	
-	/**
-	 * 鍒嗕韩鍟嗗搧璇︽儏
-	 * @param callback
-	 * @param shareId  鍒嗕韩id
-	 * @param source   鏉ユ簮
-	 * @param out
-	 */
-	@RequestMapping(value = "getDetail")
-	public void getDetail(String callback, Long shareId, String source, String fingerprint, PrintWriter out) {
-		
-		try {
-			
-			if (shareId == null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("浼犻�掑弬鏁颁笉姝g‘"));
-				return;
-			}
-			
-			// 鑾峰彇鍟嗗搧淇℃伅
-			JSONObject data = userShareGoodsRecordService.getGoodsGroupDetail(shareId);
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-			
-		} catch (Exception e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鑾峰彇澶辫触"));
-			e.printStackTrace();
-		}
-	}
-	
-}
+package com.yeshi.fanli.controller.apph5;
+
+import java.io.PrintWriter;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import com.yeshi.fanli.entity.accept.AcceptData;
+import com.yeshi.fanli.util.taobao.TaoBaoUtil;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.yeshi.utils.JsonUtil;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.yeshi.fanli.dto.GoodsMoneyConfigParamsDTO;
+import com.yeshi.fanli.dto.jd.JDFilter;
+import com.yeshi.fanli.dto.jd.JDSearchResult;
+import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
+import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
+import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
+import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
+import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord;
+import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
+import com.yeshi.fanli.entity.goods.CommonGoods;
+import com.yeshi.fanli.entity.jd.JDGoods;
+import com.yeshi.goods.facade.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;
+import net.sf.json.JSONObject;
+
+@Controller
+@RequestMapping("api/apph5/v1/share")
+public class AppH5ShareController {
+
+    @Resource
+    private UserShareGoodsRecordService userShareGoodsRecordService;
+
+    @Resource
+    private HongBaoManageService hongBaoManageService;
+
+    /**
+     * 鍒嗕韩鍟嗗搧璇︽儏
+     *
+     * @param callback
+     * @param shareId  鍒嗕韩id
+     * @param source   鏉ユ簮
+     * @param out
+     */
+    @RequestMapping(value = "getDetail")
+    public void getDetail(AcceptData acceptData, String callback, Long shareId, String source, String fingerprint, PrintWriter out) {
+        try {
+            if (shareId == null) {
+                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("浼犻�掑弬鏁颁笉姝g‘"));
+                return;
+            }
+
+            // 鑾峰彇鍟嗗搧淇℃伅
+            JSONObject data = userShareGoodsRecordService.getGoodsGroupDetail(shareId, acceptData.getSystem());
+            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+        } catch (Exception e) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鑾峰彇澶辫触"));
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 鍒嗕韩鍟嗗搧鍒楄〃
+     *
+     * @param callback
+     * @param shareId  鍒嗕韩id
+     * @param out
+     */
+    @RequestMapping(value = "getList")
+    public void getList(AcceptData acceptData, 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) {
+                List<String> listIdTB = new ArrayList<>();
+                List<String> listIdJD = new ArrayList<>();
+                List<Long> listIdPDD = new ArrayList<Long>();
+
+                for (int i = 0; i < list.size(); i++) {
+                    CommonGoods commonGoods = list.get(i).getCommonGoods();
+                    if (commonGoods == null) {
+                        continue;
+                    }
+
+                    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(Long.parseLong(commonGoods.getGoodsId()));
+                    }
+                }
+
+                // 娣樺疂楠岃瘉鏄惁鍦ㄥ敭
+                List<TaoBaoGoodsBrief> listTB = null;
+                if (listIdTB.size() > 0) {
+                    try {
+                        listTB = TaoKeApiUtil.getBatchGoodsInfo(listIdTB);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+
+                // 浜笢楠岃瘉鏄惁鍦ㄥ敭
+                List<JDGoods> listJD = null;
+                if (listIdJD.size() > 0) {
+                    try {
+                        JDFilter filter = new JDFilter();
+                        filter.setListItemId(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, "437032");
+                        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(acceptData.getSystem());
+                BigDecimal shareRate = hongBaoManageService.getShareRate(acceptData.getSystem());
+                GoodsMoneyConfigParamsDTO configParamsDTO = new GoodsMoneyConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,
+                        hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP, acceptData.getSystem()));
+
+
+                for (UserShareGoodsGroup goodsGroup : list) {
+                    CommonGoods commonGoods = goodsGroup.getCommonGoods();
+                    if (commonGoods == null) {
+                        continue;
+                    }
+                    Integer goodsType = commonGoods.getGoodsType();
+                    if (goodsType == null) {
+                        goodsType = Constant.SOURCE_TYPE_TAOBAO;
+                    }
+                    String commonGid = commonGoods.getGoodsId();
+
+                    if (goodsType == Constant.SOURCE_TYPE_TAOBAO && listTB != null && listTB.size() > 0) {
+                        int state = 1; // 榛樿鍋滃敭
+                        for (TaoBaoGoodsBrief goodsDetail : listTB) {
+                            String goodsId = goodsDetail.getAuctionId();
+                            if (TaoBaoUtil.isEqual(goodsId, commonGid)) {
+                                state = 0; // 鍦ㄥ敭
+                                break;
+                            }
+                        }
+                        commonGoods.setState(state);
+                    }
+
+                    if (goodsType == Constant.SOURCE_TYPE_JD && listJD != null && listJD.size() > 0) {
+                        int state = 1; // 榛樿鍋滃敭
+                        for (JDGoods goodsDetail : listJD) {
+                            Long goodsId = goodsDetail.getSkuId();
+                            if (goodsId == Long.parseLong(commonGid)) {
+                                state = 0; // 鍦ㄥ敭
+                                break;
+                            }
+                        }
+                        commonGoods.setState(state);
+                    }
+
+                    if (goodsType == Constant.SOURCE_TYPE_PDD && listPDD != null && listPDD.size() > 0) {
+                        int state = 1; // 榛樿鍋滃敭
+                        for (PDDGoodsDetail goodsDetail : listPDD) {
+                            Long goodsId = goodsDetail.getGoodsId();
+                            if (goodsId == Long.parseLong(commonGid)) {
+                                state = 0; // 鍦ㄥ敭
+                                break;
+                            }
+                        }
+                        commonGoods.setState(state);
+                    }
+                    GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, configParamsDTO);
+                    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();
+        }
+    }
+}

--
Gitblit v1.8.0