From a7454d8a6325566753358b37ffabfae2faa0ca7f Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 28 四月 2021 19:46:49 +0800 Subject: [PATCH] 拼多多授权调整,支持小程序跳转 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/PinDuoDuoControllerV2.java | 195 +++++++++++++++++++++++++++++------------------- 1 files changed, 117 insertions(+), 78 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/PinDuoDuoControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/PinDuoDuoControllerV2.java index 89932ba..642b8a1 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/PinDuoDuoControllerV2.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/PinDuoDuoControllerV2.java @@ -6,6 +6,11 @@ import javax.annotation.Resource; +import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil; +import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil; +import com.yeshi.fanli.vo.common.WXXCXJumpInfoVO; +import com.yeshi.fanli.vo.pdd.PDDConvertLinkResultVO; +import com.yeshi.fanli.vo.pdd.PDDJumpLinkVO; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.yeshi.utils.JsonUtil; @@ -34,94 +39,128 @@ /** * 鐑攢姒� - * - * @author Administrator * + * @author Administrator */ @Controller @RequestMapping("api/v2/pdd") public class PinDuoDuoControllerV2 { - @Resource - private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; + @Resource + private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; - @Resource - private TaoBaoGoodsBriefService taoBaoGoodsBriefService; + @Resource + private TaoBaoGoodsBriefService taoBaoGoodsBriefService; - @Resource - private JumpDetailV2Service jumpDetailV2Service; + @Resource + private JumpDetailV2Service jumpDetailV2Service; - @Resource - private DaTaoKeGoodsService daTaoKeGoodsService; - - @Resource - private SwiperPictureService swiperPictureService; - - @Resource - private QualityGoodsService qualityGoodsService; - - @Resource - private SpecialService specialService; + @Resource + private DaTaoKeGoodsService daTaoKeGoodsService; - @Resource - private PDDGoodsService pddGoodsService; - + @Resource + private SwiperPictureService swiperPictureService; - - /** - * 鎷煎澶氫笓棰樺垎绫� - * @param acceptData - * @param out - */ - @RequestMapping(value = "getClass") - public void getJDClass(AcceptData acceptData, PrintWriter out) { - JSONObject root = new JSONObject(); - root.put("list", pddGoodsService.getSpecialClass()); - out.print(JsonUtil.loadTrueResult(root)); - } - - - /** - * 鎷煎澶氫笓棰� - * @param acceptData - * @param out - */ - @RequestMapping(value = "getGoodsInfo") - public void getGoodsInfo(AcceptData acceptData, Long cid, Integer page, PrintWriter out) { - JSONObject root = new JSONObject(); - if (cid == 1 && page == 1) { - List<BannerVO> topPicList = swiperPictureService.getByBannerCardAndVersion("pinduoduo_special_index",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()),acceptData.getSystem()); - if (topPicList == null) { - topPicList = new ArrayList<BannerVO>(); - } - root.put("listPic", JsonUtil.getApiCommonGson().toJson(topPicList)); - int platformCode = Constant.getPlatformCode(acceptData.getPlatform()); - List<Special> listSpecial = specialService.listByPlaceKey("pinduoduo_special_index", platformCode, Integer.parseInt(acceptData.getVersion()),acceptData.getSystem()); - if (listSpecial == null) { - listSpecial = new ArrayList<Special>(); - } - root.put("listSpe", JsonUtil.getApiCommonGson().toJson(listSpecial)); - } - - try { - List<PDDGoodsDetail> goodsList = pddGoodsService.specialSearch(page, cid); - JSONArray array = new JSONArray(); - if (goodsList != null && goodsList.size() > 0) { - Gson gson = JsonUtil.getApiCommonGson(); - ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), - acceptData.getVersion(),acceptData.getSystem()); + @Resource + private QualityGoodsService qualityGoodsService; - for (PDDGoodsDetail goods : goodsList) { - GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO); - array.add(gson.toJson(goodsDetailVO)); - } - } - root.put("list", array); - root.put("count", 1000); - out.print(JsonUtil.loadTrueResult(root)); - } catch (PDDOrderException e) { - out.print(JsonUtil.loadFalseResult(e.getMsg())); - } - } - + @Resource + private SpecialService specialService; + + @Resource + private PDDGoodsService pddGoodsService; + + + /** + * 鎷煎澶氫笓棰樺垎绫� + * + * @param acceptData + * @param out + */ + @RequestMapping(value = "getClass") + public void getClass(AcceptData acceptData, PrintWriter out) { + JSONObject root = new JSONObject(); + root.put("list", pddGoodsService.getSpecialClass()); + out.print(JsonUtil.loadTrueResult(root)); + } + + + /** + * 鎷煎澶氫笓棰� + * + * @param acceptData + * @param out + */ + @RequestMapping(value = "getGoodsInfo") + public void getGoodsInfo(AcceptData acceptData, Long cid, Integer page, PrintWriter out) { + JSONObject root = new JSONObject(); + if (cid == 1 && page == 1) { + List<BannerVO> topPicList = swiperPictureService.getByBannerCardAndVersion("pinduoduo_special_index", acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()), acceptData.getSystem()); + if (topPicList == null) { + topPicList = new ArrayList<BannerVO>(); + } + root.put("listPic", JsonUtil.getApiCommonGson().toJson(topPicList)); + int platformCode = Constant.getPlatformCode(acceptData.getPlatform()); + List<Special> listSpecial = specialService.listByPlaceKey("pinduoduo_special_index", platformCode, Integer.parseInt(acceptData.getVersion()), acceptData.getSystem()); + if (listSpecial == null) { + listSpecial = new ArrayList<Special>(); + } + root.put("listSpe", JsonUtil.getApiCommonGson().toJson(listSpecial)); + } + + try { + List<PDDGoodsDetail> goodsList = pddGoodsService.specialSearch(page, cid); + JSONArray array = new JSONArray(); + if (goodsList != null && goodsList.size() > 0) { + Gson gson = JsonUtil.getApiCommonGson(); + ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), + acceptData.getVersion(), acceptData.getSystem()); + + for (PDDGoodsDetail goods : goodsList) { + GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO); + array.add(gson.toJson(goodsDetailVO)); + } + } + root.put("list", array); + root.put("count", 1000); + out.print(JsonUtil.loadTrueResult(root)); + } catch (PDDOrderException e) { + out.print(JsonUtil.loadFalseResult(e.getMsg())); + } + } + + + @RequestMapping(value = "getAuthJumpInfo") + public void getAuthJumpInfo(AcceptData acceptData, Long uid, int type, PrintWriter out) { + if (uid == null || uid == 0L) { + out.print(JsonUtil.loadFalseResult("璇峰厛鐧诲綍")); + return; + } + String pid = null; + //鑷喘 + if (type == 1) { + pid = PinDuoDuoApiUtil.PID_FANLI; + } else {//鍒嗕韩 + pid = PinDuoDuoApiUtil.PID_SHARE; + } + + PDDConvertLinkResultVO authLink = PinDuoDuoApiUtil.getAuthLink(pid, PinDuoDuoUtil.getCustomParams(uid)); + + PDDJumpLinkVO pddJumpLinkVO = new PDDJumpLinkVO(); + + pddJumpLinkVO.set_native(true); + pddJumpLinkVO.setJumpLink(authLink.getMobile_url()); + pddJumpLinkVO.setNativeJumpLink(PinDuoDuoUtil.getAndroidNativeURI(authLink.getMobile_url())); + if (authLink.getWe_app_info() != null) { + WXXCXJumpInfoVO wxxcxJumpInfoVO = new WXXCXJumpInfoVO(); + wxxcxJumpInfoVO.setUserName(authLink.getWe_app_info().getUser_name()); + wxxcxJumpInfoVO.setPath(authLink.getWe_app_info().getPage_path()); + pddJumpLinkVO.setWxxcxJumpInfo(wxxcxJumpInfoVO); + } + + JSONObject data = JSONObject.fromObject(new Gson().toJson(pddJumpLinkVO)); + data.put("native", pddJumpLinkVO.is_native()); + out.print(JsonUtil.loadTrueResult(data)); + } + } -- Gitblit v1.8.0