From 573c491b4a1ba60e12a5678a01c1546c0077c1ee Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 30 七月 2019 09:07:42 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java | 327 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 311 insertions(+), 16 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java index 6f3792c..7d27c30 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java @@ -15,10 +15,17 @@ import com.yeshi.fanli.dto.common.CommonContentTypeEnum; import com.yeshi.fanli.dto.dataoke.DaTaoKeGoodsResult; import com.yeshi.fanli.entity.bus.clazz.GoodsClass; +import com.yeshi.fanli.entity.bus.lable.QualityFactory; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; +import com.yeshi.fanli.entity.taobao.TaobaoMeterial; import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2; import com.yeshi.fanli.service.inter.goods.CommonTemplateContentService; +import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService; +import com.yeshi.fanli.service.inter.lable.QualityGoodsService; +import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService; +import com.yeshi.fanli.service.inter.taobao.TaobaoMeterialService; import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService; +import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.dataoke.DaTaoKeApiUtil; import com.yeshi.fanli.util.taobao.DaTaoKeUtil; import com.yeshi.fanli.util.taobao.TaoBaoUtil; @@ -28,6 +35,18 @@ @Resource private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService; + + @Resource + private TaobaoMeterialService taobaoMeterialService; + + @Resource + private TaoKeGoodsService taoKeGoodsService; + + @Resource + private HongBaoManageService hongBaoManageService; + + @Resource + private QualityGoodsService qualityGoodsService; private static List<CommonContentNav> getCommonNav() { List<CommonContentNav> navList = new ArrayList<>(); @@ -65,28 +84,30 @@ navList.add(new CommonContentNav(gc.getId() + "", gc.getName())); } } else if (type == CommonContentTypeEnum.chaoSheng) { - navList.add(new CommonContentNav("1", "5%~10%杩斿埄")); - navList.add(new CommonContentNav("2", "10%~20%杩斿埄")); - navList.add(new CommonContentNav("3", "20%~30%杩斿埄")); - navList.add(new CommonContentNav("4", "30%~40%杩斿埄")); - navList.add(new CommonContentNav("5", "40%浠ヤ笂杩斿埄")); + navList.add(new CommonContentNav("1", "1-5鍏冭繑鍒�")); + navList.add(new CommonContentNav("2", "5-10鍏冭繑鍒� ")); + navList.add(new CommonContentNav("3", "10-15鍏冭繑鍒�")); + navList.add(new CommonContentNav("4", "15-20鍏冭繑鍒�")); + navList.add(new CommonContentNav("5", "20鍏冧互涓婅繑鍒�")); } else if (type == CommonContentTypeEnum.haoQuan) { - navList.add(new CommonContentNav("1", "5~10鍏冨埜")); - navList.add(new CommonContentNav("2", "10~30鍏冨埜")); - navList.add(new CommonContentNav("3", "30~50鍏冨埜")); - navList.add(new CommonContentNav("4", "50鍏冧互涓婂埜")); + navList.add(new CommonContentNav("1", "1-5鍏冨埜")); + navList.add(new CommonContentNav("2", "5-10鍏冨埜")); + navList.add(new CommonContentNav("3", "10-20鍏冨埜")); + navList.add(new CommonContentNav("4", "20-30鍏冨埜")); + navList.add(new CommonContentNav("5", "30-50鍏冨埜")); + navList.add(new CommonContentNav("6", "50鍏冧互涓婂埜")); } else if (type == CommonContentTypeEnum.juJia) { navList = getCommonNav(); } else if (type == CommonContentTypeEnum.meiShi) { navList = getCommonNav(); } else if (type == CommonContentTypeEnum.muYin) { navList.add(new CommonContentNav("1", "绮鹃��")); - navList.add(new CommonContentNav("2", "澶囧瓡")); - navList.add(new CommonContentNav("3", "0~6鏈�")); - navList.add(new CommonContentNav("4", "7~12鏈�")); - navList.add(new CommonContentNav("5", "1~3宀�")); - navList.add(new CommonContentNav("6", "4~6宀�")); - navList.add(new CommonContentNav("7", "7~12宀�")); + navList.add(new CommonContentNav("澶囧瓡", "澶囧瓡")); + navList.add(new CommonContentNav("0鑷�6涓湀", "0~6鏈�")); + navList.add(new CommonContentNav("7鑷�12涓湀", "7~12鏈�")); + navList.add(new CommonContentNav("1鑷�3宀�", "1~3宀�")); + navList.add(new CommonContentNav("4鑷�6宀�", "4~6宀�")); + navList.add(new CommonContentNav("7鑷�12宀�", "7~12宀�")); } else if (type == CommonContentTypeEnum.reMai) { navList = getCommonNav(); } else if (type == CommonContentTypeEnum.chuanYiDaPei) { @@ -103,6 +124,8 @@ navList = getCommonNav(); } else if (type == CommonContentTypeEnum.qiCheHuWai) { navList = getCommonNav(); + } else if (type == CommonContentTypeEnum.chaoPinReMai) { + navList = getCommonNav(); } return navList; @@ -113,6 +136,12 @@ public CommonContentResult getContentList(CommonContentTypeEnum type, String cid, int page, int pageSize) { if (type == CommonContentTypeEnum._9k9) { return get9K9Content(cid, page, pageSize); + } else if (type == CommonContentTypeEnum.juJia) { + return getJuJiaShengHuoContent(cid, page, pageSize); + } else if (type == CommonContentTypeEnum.muYin) { + return getMuYinJingXuanContent(cid, page, pageSize); + } else if (type == CommonContentTypeEnum.meiShi) { + return getYouXuanMeiShiContent(cid, page, pageSize); } else if (type == CommonContentTypeEnum.chuanYiDaPei) { return getChuanYiDaPeiContent(cid, page, pageSize); } else if (type == CommonContentTypeEnum.meiZhuangGehu) { @@ -127,11 +156,28 @@ return getYunDongKuXieContent(cid, page, pageSize); } else if (type == CommonContentTypeEnum.qiCheHuWai) { return getQiCheHuWaiContent(cid, page, pageSize); + } else if (type == CommonContentTypeEnum.chaoPinReMai) { + return getChaoPinReMaiContent(cid, page, pageSize); + } else if (type == CommonContentTypeEnum.chaoSheng) { + return getCaoShengContent(cid, page, pageSize); + } else if (type == CommonContentTypeEnum.haoQuan) { + return getHaoQuanContent(cid, page, pageSize); } return null; } + /** + * 9蹇�9鍖呴偖 + * + * @param cid + * @param page + * @param pageSize + * @return + */ private CommonContentResult get9K9Content(String cid, int page, int pageSize) { + if (pageSize == 20) + pageSize = 50; + DaTaoKeGoodsResult result = null; if ("-1".equalsIgnoreCase(cid)) { result = DaTaoKeApiUtil.search("", null, null, new BigDecimal("10"), page, pageSize, @@ -156,6 +202,255 @@ goodsList.add(TaoBaoUtil.convert(detail)); } return new CommonContentResult(goodsList, count); + } + + /** + * 瓒呯骇鐪侀挶 + * + * @param cid + * @param page + * @param pageSize + * @return + */ + private CommonContentResult getCaoShengContent(String cid, int page, int pageSize) { + pageSize = Constant.PAGE_SIZE; + Integer startAmount = null; + Integer endAmount = null; + + if (cid.equalsIgnoreCase(1 + "")) { + startAmount = 1; + endAmount = 5; + } else if (cid.equalsIgnoreCase(2 + "")) { + startAmount = 5; + endAmount = 10; + } else if (cid.equalsIgnoreCase(3 + "")) { + startAmount = 10; + endAmount = 15; + } else if (cid.equalsIgnoreCase(4 + "")) { + startAmount = 15; + endAmount = 20; + } else if (cid.equalsIgnoreCase(5 + "")) { + startAmount = 20; + endAmount = 10000; + } + + double tkRate = 20.00; + + BigDecimal proportion = hongBaoManageService.getFanLiRate(); + List<QualityFactory> listQuery = qualityGoodsService.listQueryByRebateAmount((page - 1) * pageSize, pageSize, + proportion.toString(), startAmount, endAmount, tkRate); + + long count = qualityGoodsService.countQueryByRebateAmount(proportion.toString(), startAmount, endAmount, + tkRate); + + List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); + // 閬嶅巻鍒楄〃鏁版嵁 + if (listQuery != null) + for (QualityFactory quality : listQuery) { + TaoBaoGoodsBrief taoBaoGoodsBrief = quality.getTaoBaoGoodsBrief(); + if (taoBaoGoodsBrief == null) { + continue; + } + + int biz30day = taoBaoGoodsBrief.getBiz30day(); + if (biz30day >= 10000) { + double sales = biz30day; + String salesCountMidea = String.format("%.1f", sales / 10000); + taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�"); + } else { + taoBaoGoodsBrief.setSalesCount(biz30day + ""); + } + goodsList.add(taoBaoGoodsBrief); + } + return new CommonContentResult(goodsList, count); + } + + /** + * 楂橀濂藉埜 + * + * @param cid + * @param page + * @param pageSize + * @return + */ + private CommonContentResult getHaoQuanContent(String cid, int page, int pageSize) { + pageSize = Constant.PAGE_SIZE; + + Integer startAmount = null; + Integer endAmount = null; + + if (cid.equalsIgnoreCase(1 + "")) { + startAmount = 1; + endAmount = 5; + } else if (cid.equalsIgnoreCase(2 + "")) { + startAmount = 5; + endAmount = 10; + } else if (cid.equalsIgnoreCase(3 + "")) { + startAmount = 10; + endAmount = 20; + } else if (cid.equalsIgnoreCase(4 + "")) { + startAmount = 20; + endAmount = 30; + } else if (cid.equalsIgnoreCase(5 + "")) { + startAmount = 30; + endAmount = 50; + } else if (cid.equalsIgnoreCase(6 + "")) { + startAmount = 50; + endAmount = 10000; + } + + Integer startPropor = 20; + + List<QualityFactory> listQuery = qualityGoodsService.listQueryByCouponAmount((page - 1) * pageSize, pageSize, + startAmount, endAmount, startPropor); + + long count = qualityGoodsService.countQueryByCouponAmount(startAmount, endAmount, startPropor); + + List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); + + // 閬嶅巻鍒楄〃鏁版嵁 + + for (QualityFactory selectionGoods : listQuery) { + + TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief(); + + if (taoBaoGoodsBrief == null) { + continue; + } + + int biz30day = taoBaoGoodsBrief.getBiz30day(); + if (biz30day >= 10000) { + double sales = biz30day; + String salesCountMidea = String.format("%.1f", sales / 10000); + taoBaoGoodsBrief.setSalesCount(salesCountMidea + "涓�"); + } else { + taoBaoGoodsBrief.setSalesCount(biz30day + ""); + } + goodsList.add(taoBaoGoodsBrief); + } + return new CommonContentResult(goodsList, count); + } + + /** + * 灞呭鐢熸椿 + * + * @param cid + * @param page + * @param pageSize + * @return + */ + private CommonContentResult getJuJiaShengHuoContent(String cid, int page, int pageSize) { + DaTaoKeGoodsResult result = null; + List<Integer> cidList = new ArrayList<>(); + cidList.add(4);// 灞呭鐢熸椿 + int sort = getCommonSort(cid); + result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, sort); + List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); + long count = 0; + if (result != null) { + count = result.getTotalCount(); + if (result.getGoodsList() != null) + for (DaTaoKeDetailV2 detail : result.getGoodsList()) + goodsList.add(TaoBaoUtil.convert(detail)); + } + return new CommonContentResult(goodsList, count); + } + + /** + * 浼橀�夌編椋� + * + * @param cid + * @param page + * @param pageSize + * @return + */ + private CommonContentResult getYouXuanMeiShiContent(String cid, int page, int pageSize) { + DaTaoKeGoodsResult result = null; + List<Integer> cidList = new ArrayList<>(); + cidList.add(6);// 缇庨 + int sort = getCommonSort(cid); + result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, sort); + List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); + long count = 0; + if (result != null) { + count = result.getTotalCount(); + if (result.getGoodsList() != null) + for (DaTaoKeDetailV2 detail : result.getGoodsList()) + goodsList.add(TaoBaoUtil.convert(detail)); + } + return new CommonContentResult(goodsList, count); + } + + /** + * 娼搧鐑崠 + * + * @param cid + * @param page + * @param pageSize + * @return + */ + private CommonContentResult getChaoPinReMaiContent(String cid, int page, int pageSize) { + DaTaoKeGoodsResult result = null; + + int sort = getCommonSort(cid); + result = DaTaoKeApiUtil.search("娼�", null, null, null, page, pageSize, sort); + List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); + long count = 0; + if (result != null) { + count = result.getTotalCount(); + if (result.getGoodsList() != null) + for (DaTaoKeDetailV2 detail : result.getGoodsList()) + goodsList.add(TaoBaoUtil.convert(detail)); + } + return new CommonContentResult(goodsList, count); + } + + /** + * 鑾峰彇姣嶅┐绮鹃�� + * + * @param cid + * @param page + * @param pageSize + * @return + */ + private CommonContentResult getMuYinJingXuanContent(String cid, int page, int pageSize) { + DaTaoKeGoodsResult result = null; + if ("1".equalsIgnoreCase(cid)) {// 澶ф窐瀹㈡暟鎹� + List<Integer> cidList = new ArrayList<>(); + cidList.add(2);// 姣嶅┐ + result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, DaTaoKeApiUtil.SORT_DEFAULT); + List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); + long count = 0; + if (result != null) { + count = result.getTotalCount(); + if (result.getGoodsList() != null) + for (DaTaoKeDetailV2 detail : result.getGoodsList()) + goodsList.add(TaoBaoUtil.convert(detail)); + } + return new CommonContentResult(goodsList, count); + + } else {// + List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache("姣嶅┐_" + cid, + "姣嶅┐涓婚"); + + if (taobaoMeterials == null || taobaoMeterials.size() == 0) { + return null; + } + + TaobaoMeterial meterial = taobaoMeterials.get(0); + Integer materialId = meterial.getMaterialId(); + if (materialId != null) { + List<TaoBaoGoodsBrief> listBrands = new ArrayList<>(); + try { + listBrands = taoKeGoodsService.listByMaterial(materialId, page, pageSize); + } catch (Exception e) { + e.printStackTrace(); + } + return new CommonContentResult(listBrands, 1000); + } + return new CommonContentResult(new ArrayList<>(), 0); + } + } /** @@ -331,7 +626,7 @@ cidList.add(7); cidList.add(13); int sort = getCommonSort(cid); - result = DaTaoKeApiUtil.search("", null, null, null, page, pageSize, sort); + result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, sort); DaTaoKeGoodsResult result1 = DaTaoKeApiUtil.search("杩愬姩 鐢�", cidList, null, null, page, pageSize, sort); List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); long count = 0; -- Gitblit v1.8.0