| | |
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collections;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | 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.exception.taobao.TaoKeApiException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonTemplateContentService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
|
| | | import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaobaoMeterialService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
|
| | | 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;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | @Service
|
| | | public class CommonTemplateContentServiceImpl implements CommonTemplateContentService {
|
| | |
|
| | | @Resource
|
| | | private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
|
| | | private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
|
| | |
|
| | | @Resource
|
| | | private TaobaoMeterialService taobaoMeterialService;
|
| | |
|
| | | @Resource
|
| | | private TaoKeGoodsService taoKeGoodsService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private QualityGoodsService qualityGoodsService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
|
| | |
|
| | | private static List<CommonContentNav> getCommonNav() {
|
| | | List<CommonContentNav> navList = new ArrayList<>();
|
| | |
| | | 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.chaoPinReMai) {
|
| | | navList = getCommonNav();
|
| | | } else if (type == CommonContentTypeEnum.mianDan) {
|
| | | navList = new ArrayList<>();
|
| | | }
|
| | |
|
| | | return navList;
|
| | |
| | | @Cacheable(value = "commonContentCache", key = "#type+'-'+#cid+'-'+#page+'-'+#pageSize")
|
| | | @Override
|
| | | public CommonContentResult getContentList(CommonContentTypeEnum type, String cid, int page, int pageSize) {
|
| | | CommonContentResult result = null;
|
| | | if (type == CommonContentTypeEnum._9k9) {
|
| | | return get9K9Content(cid, page, pageSize);
|
| | | result = get9K9Content(cid, page, pageSize);
|
| | | } else if (type == CommonContentTypeEnum.juJia) {
|
| | | return getJuJiaShengHuoContent(cid, page, pageSize);
|
| | | result = getJuJiaShengHuoContent(cid, page, pageSize);
|
| | | } else if (type == CommonContentTypeEnum.muYin) {
|
| | | return getMuYinJingXuanContent(cid, page, pageSize);
|
| | | result = getMuYinJingXuanContent(cid, page, pageSize);
|
| | | } else if (type == CommonContentTypeEnum.meiShi) {
|
| | | return getYouXuanMeiShiContent(cid, page, pageSize);
|
| | | result = getYouXuanMeiShiContent(cid, page, pageSize);
|
| | | } else if (type == CommonContentTypeEnum.chuanYiDaPei) {
|
| | | return getChuanYiDaPeiContent(cid, page, pageSize);
|
| | | result = getChuanYiDaPeiContent(cid, page, pageSize);
|
| | | } else if (type == CommonContentTypeEnum.meiZhuangGehu) {
|
| | | return getMeiZhuangGeHuContent(cid, page, pageSize);
|
| | | result = getMeiZhuangGeHuContent(cid, page, pageSize);
|
| | | } else if (type == CommonContentTypeEnum.jingPinXieBao) {
|
| | | return getJingPinXieBaoContent(cid, page, pageSize);
|
| | | result = getJingPinXieBaoContent(cid, page, pageSize);
|
| | | } else if (type == CommonContentTypeEnum.chaoNanReMai) {
|
| | | return getChaoNanReMaiContent(cid, page, pageSize);
|
| | | result = getChaoNanReMaiContent(cid, page, pageSize);
|
| | | } else if (type == CommonContentTypeEnum.shuMaShouJi) {
|
| | | return getShuMaShouJiContent(cid, page, pageSize);
|
| | | result = getShuMaShouJiContent(cid, page, pageSize);
|
| | | } else if (type == CommonContentTypeEnum.yunDongKuXie) {
|
| | | return getYunDongKuXieContent(cid, page, pageSize);
|
| | | result = getYunDongKuXieContent(cid, page, pageSize);
|
| | | } else if (type == CommonContentTypeEnum.qiCheHuWai) {
|
| | | return getQiCheHuWaiContent(cid, page, pageSize);
|
| | | result = getQiCheHuWaiContent(cid, page, pageSize);
|
| | | } else if (type == CommonContentTypeEnum.chaoPinReMai) {
|
| | | return getChaoPinReMaiContent(cid, page, pageSize);
|
| | | result = getChaoPinReMaiContent(cid, page, pageSize);
|
| | | } else if (type == CommonContentTypeEnum.chaoSheng) {
|
| | | result = getCaoShengContent(cid, page, pageSize);
|
| | | } else if (type == CommonContentTypeEnum.haoQuan) {
|
| | | result = getHaoQuanContent(cid, page, pageSize);
|
| | | } else if (type == CommonContentTypeEnum.mianDan) {
|
| | | result = getMianDanContent(page, pageSize);
|
| | | }
|
| | | return null;
|
| | |
|
| | | if (result != null) {// 商品信息过滤
|
| | | List<TaoBaoGoodsBrief> goodsList = taoBaoGoodsUpdateService
|
| | | .filterImportantTaoBaoGoods(result.getGoodsList());
|
| | | result.setGoodsList(goodsList);
|
| | | }
|
| | |
|
| | | return result;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 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,
|
| | | result = DaTaoKeApiUtil.getGoodsList("", null, null, new BigDecimal("10"), null, page, pageSize,
|
| | | DaTaoKeApiUtil.SORT_DEFAULT);
|
| | |
|
| | | if (result == null || result.getGoodsList() == null || result.getGoodsList().size() == 0) {
|
| | | result = new DaTaoKeGoodsResult();
|
| | | result.setGoodsList(
|
| | | daTaoKeGoodsDetailV2Service.listByMaxPrice(null, new BigDecimal("10"), null, page, pageSize));
|
| | | result.setTotalCount(daTaoKeGoodsDetailV2Service.countByMaxPrice(null, new BigDecimal("10")));
|
| | | }
|
| | |
|
| | | } else if ("0".equalsIgnoreCase(cid)) {
|
| | | result = DaTaoKeApiUtil.search("", null, null, new BigDecimal("10"), page, pageSize,
|
| | | result = DaTaoKeApiUtil.getGoodsList("", null, null, new BigDecimal("10"), null, page, pageSize,
|
| | | DaTaoKeApiUtil.SORT_CREATETIME);
|
| | | if (result == null || result.getGoodsList() == null || result.getGoodsList().size() == 0) {
|
| | | result = new DaTaoKeGoodsResult();
|
| | | result.setGoodsList(daTaoKeGoodsDetailV2Service.listByMaxPrice(null, new BigDecimal("10"), "createTime",
|
| | | page, pageSize));
|
| | | result.setTotalCount(daTaoKeGoodsDetailV2Service.countByMaxPrice(null, new BigDecimal("10")));
|
| | | }
|
| | | } else {
|
| | | List<Integer> cidList = new ArrayList<>();
|
| | | cidList.add(Integer.parseInt(cid));
|
| | | result = DaTaoKeApiUtil.search("", cidList, null, new BigDecimal("10"), page, pageSize,
|
| | | result = DaTaoKeApiUtil.getGoodsList("", cidList, null, new BigDecimal("10"), null, page, pageSize,
|
| | | DaTaoKeApiUtil.SORT_DEFAULT);
|
| | |
|
| | | if (result == null || result.getGoodsList() == null || result.getGoodsList().size() == 0) {
|
| | | result = new DaTaoKeGoodsResult();
|
| | | result.setGoodsList(daTaoKeGoodsDetailV2Service.listByMaxPrice(Integer.parseInt(cid),
|
| | | new BigDecimal("10"), null, page, pageSize));
|
| | | result.setTotalCount(
|
| | | daTaoKeGoodsDetailV2Service.countByMaxPrice(Integer.parseInt(cid), new BigDecimal("10")));
|
| | | }
|
| | | }
|
| | |
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | |
| | | 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 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);
|
| | | }
|
| | |
| | | List<Integer> cidList = new ArrayList<>();
|
| | | cidList.add(4);// 居家生活
|
| | | int sort = getCommonSort(cid);
|
| | | result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, sort);
|
| | | result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | long count = 0;
|
| | | if (result != null) {
|
| | |
| | | List<Integer> cidList = new ArrayList<>();
|
| | | cidList.add(6);// 美食
|
| | | int sort = getCommonSort(cid);
|
| | | result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, sort);
|
| | | result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | long count = 0;
|
| | | if (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);
|
| | | result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize,
|
| | | DaTaoKeApiUtil.SORT_DEFAULT);
|
| | |
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | long count = 0;
|
| | | if (result != null) {
|
| | |
| | | List<Integer> cidList = new ArrayList<>();
|
| | | cidList.add(1);// 女装
|
| | | int sort = getCommonSort(cid);
|
| | | result = DaTaoKeApiUtil.search("内衣 女", cidList, null, null, page, pageSize, sort);
|
| | | result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
|
| | |
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | long count = 0;
|
| | | if (result != null) {
|
| | |
| | | cidList.add(7);
|
| | | cidList.add(13);
|
| | | int sort = getCommonSort(cid);
|
| | | result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, sort);
|
| | | result = DaTaoKeApiUtil.getGoodsList("", cidList, null, null, null, page, pageSize, sort);
|
| | | DaTaoKeGoodsResult result1 = DaTaoKeApiUtil.search("运动 男", cidList, null, null, page, pageSize, sort);
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | long count = 0;
|
| | |
| | | return new CommonContentResult(goodsList, count);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取免单商品
|
| | | * |
| | | * @return
|
| | | */
|
| | | private CommonContentResult getMianDanContent(int page, int pageSize) {
|
| | | CommonContentResult result = new CommonContentResult();
|
| | | List<QualityFactory> listQuery = qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize);
|
| | | long count = qualityGoodsService.countFreeGoods();
|
| | | result.setCount(count);
|
| | | List<Long> listGid = new ArrayList<Long>();
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | for (QualityFactory qualityFactory : listQuery) {
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief();
|
| | | if (taoBaoGoodsBrief == null) {
|
| | | continue;
|
| | | }
|
| | | listGid.add(taoBaoGoodsBrief.getAuctionId());
|
| | | goodsList.add(taoBaoGoodsBrief);
|
| | | }
|
| | | // 去掉已经不在售的商品
|
| | | List<TaoBaoGoodsBrief> listTaoKeGoods = null;
|
| | | try {
|
| | | listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
|
| | | } catch (TaoKeApiException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | Map<Long, TaoBaoGoodsBrief> goodsMap = new HashMap<>();
|
| | | if (listTaoKeGoods != null)
|
| | | for (TaoBaoGoodsBrief goods : listTaoKeGoods)
|
| | | goodsMap.put(goods.getAuctionId(), goods);
|
| | | for (int i = 0; i < goodsList.size(); i++) {
|
| | | if (goodsMap.get(goodsList.get(i).getAuctionId()) == null) {
|
| | | goodsList.remove(i--);
|
| | | }
|
| | | }
|
| | | // 过滤基本商品信息
|
| | | goodsList = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(goodsList);
|
| | |
|
| | | for (int i = 0; i < goodsList.size(); i++) {
|
| | | TaoBaoGoodsBrief goods = goodsList.get(i);
|
| | | BigDecimal price = TaoBaoUtil.getAfterUseCouplePrice(goods);
|
| | | if (price.compareTo(new BigDecimal(10)) >= 0) {
|
| | | goodsList.remove(i--);
|
| | | }
|
| | | }
|
| | | result.setGoodsList(goodsList);
|
| | | return result;
|
| | | }
|
| | |
|
| | | }
|