From 26f7accb815f55f18f8eedfca4324700a96884ec Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 26 八月 2020 18:23:49 +0800 Subject: [PATCH] 资金验证优化 --- fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5ShareController.java | 369 ++++++++++++++++++++++++++-------------------------- 1 files changed, 183 insertions(+), 186 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 46ec6c2..764ede7 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 @@ -7,6 +7,7 @@ import javax.annotation.Resource; +import com.yeshi.fanli.entity.accept.AcceptData; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.yeshi.utils.JsonUtil; @@ -24,7 +25,7 @@ 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.fanli.entity.taobao.TaoBaoGoodsBrief; +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; @@ -41,207 +42,203 @@ @RequestMapping("api/apph5/v1/share") public class AppH5ShareController { - @Resource - private UserShareGoodsRecordService userShareGoodsRecordService; + @Resource + private UserShareGoodsRecordService userShareGoodsRecordService; - @Resource - private HongBaoManageService hongBaoManageService; + @Resource + private HongBaoManageService hongBaoManageService; - /** - * 鍒嗕韩鍟嗗搧璇︽儏 - * - * @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; - } + /** + * 鍒嗕韩鍟嗗搧璇︽儏 + * + * @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); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - } catch (Exception e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鑾峰彇澶辫触")); - e.printStackTrace(); - } - } + // 鑾峰彇鍟嗗搧淇℃伅 + 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 source - * 鏉ユ簮 - * @param out - */ - @RequestMapping(value = "getList") - public void getList(String callback, Long shareId, PrintWriter out) { - try { - if (shareId == null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("浼犻�掑弬鏁颁笉姝g‘")); - return; - } + /** + * 鍒嗕韩鍟嗗搧鍒楄〃 + * + * @param callback + * @param shareId 鍒嗕韩id + * @param source 鏉ユ簮 + * @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(); + JSONArray array = new JSONArray(); - List<UserShareGoodsGroup> list = userShareGoodsRecordService.listByRecordId(shareId); - if (list != null && list.size() > 0) { - List<Long> listIdTB = new ArrayList<Long>(); - List<Long> listIdJD = new ArrayList<Long>(); - List<Long> listIdPDD = new ArrayList<Long>(); + List<UserShareGoodsGroup> list = userShareGoodsRecordService.listByRecordId(shareId); + if (list != null && list.size() > 0) { + 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; - } + 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; - } + 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()); - } - } + 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()); + } + } - // 娣樺疂楠岃瘉鏄惁鍦ㄥ敭 - List<TaoBaoGoodsBrief> listTB = null; - if (listIdTB.size() > 0) { - try { - listTB = TaoKeApiUtil.getBatchGoodsInfo(listIdTB); - } catch (Exception e) { - e.printStackTrace(); - } - } + // 娣樺疂楠岃瘉鏄惁鍦ㄥ敭 + 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.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<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(); - } - } + // 鎷煎澶氶獙璇佹槸鍚﹀湪鍞� + 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.getFanLiRate(UserLevelEnum.superVIP)); - - - 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(); + Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) + .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); + BigDecimal fanLiRate = hongBaoManageService.getFanLiRate(acceptData.getSystem()); + BigDecimal shareRate = hongBaoManageService.getShareRate(acceptData.getSystem()); + ConfigParamsDTO configParamsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE, + hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP, acceptData.getSystem())); - if (goodsType == Constant.SOURCE_TYPE_TAOBAO && listTB != null && listTB.size() > 0) { - int state = 1; // 榛樿鍋滃敭 - for (TaoBaoGoodsBrief goodsDetail : listTB) { - Long goodsId = goodsDetail.getAuctionId(); - if (goodsId == commonGid || goodsId.equals(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 == commonGid || goodsId.equals(commonGid)) { - state = 0; // 鍦ㄥ敭 - break; - } - } - commonGoods.setState(state); - } + 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 (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); - ; // 宸叉姠鍏� - } - array.add(gson.toJson(detailVO)); - } - } + if (goodsType == Constant.SOURCE_TYPE_TAOBAO && listTB != null && listTB.size() > 0) { + int state = 1; // 榛樿鍋滃敭 + for (TaoBaoGoodsBrief goodsDetail : listTB) { + Long goodsId = goodsDetail.getAuctionId(); + if (goodsId == commonGid || goodsId.equals(commonGid)) { + state = 0; // 鍦ㄥ敭 + break; + } + } + commonGoods.setState(state); + } - String title = ""; - UserShareGoodsRecord userShareGoodsRecord = userShareGoodsRecordService.selectByPrimaryKey(shareId); - if (userShareGoodsRecord != null) { - title = userShareGoodsRecord.getTitle(); - } + if (goodsType == Constant.SOURCE_TYPE_JD && listJD != null && listJD.size() > 0) { + int state = 1; // 榛樿鍋滃敭 + for (JDGoods goodsDetail : listJD) { + Long goodsId = goodsDetail.getSkuId(); + if (goodsId == commonGid || goodsId.equals(commonGid)) { + state = 0; // 鍦ㄥ敭 + break; + } + } + commonGoods.setState(state); + } - 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(); - } - } + 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); + ; // 宸叉姠鍏� + } + 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