From 51a4ff5d777028d52a19c314a99f796334cb7b51 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 23 十一月 2019 18:30:01 +0800 Subject: [PATCH] 配置文件修改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/goods/TaoBaoGoodsBriefServiceImpl.java | 76 +++++++++++++++++++++++++++++++------ 1 files changed, 63 insertions(+), 13 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/TaoBaoGoodsBriefServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/TaoBaoGoodsBriefServiceImpl.java index f740c54..311edb1 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/TaoBaoGoodsBriefServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/TaoBaoGoodsBriefServiceImpl.java @@ -1,7 +1,10 @@ package com.yeshi.fanli.service.impl.goods; import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.annotation.Resource; @@ -13,10 +16,10 @@ import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig; import com.yeshi.fanli.entity.taobao.TaoKeAppInfo; -import com.yeshi.fanli.exception.ShareGoodsException; +import com.yeshi.fanli.exception.share.ShareGoodsException; import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService; -import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService; +import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService; import com.yeshi.fanli.service.inter.user.TBPidService; import com.yeshi.fanli.util.taobao.TaoBaoUtil; @@ -37,8 +40,6 @@ @Resource private TaoBaoUnionConfigService taoBaoUnionConfigService; - - @Override public String getGoodsUserHongBao(TaoBaoGoodsBrief goods) { BigDecimal rate = hongBaoManageService.getFanLiRate(); @@ -52,18 +53,26 @@ } @Override + public void deleteByPrimaryKey(Long id) { + taoBaoGoodsBriefMapper.deleteByPrimaryKey(id); + } + + @Override + public void deleteBatchByGoodsId(List<Long> list) { + taoBaoGoodsBriefMapper.deleteBatchByGoodsId(list); + } + + @Override public List<TaoBaoGoodsBrief> queryByAuctionId(Long auctionId) { return taoBaoGoodsBriefMapper.queryByAuctionId(auctionId); } @Override - public List<TaoBaoGoodsBrief> listQueryByAuctionId(List<Long> list) { - return taoBaoGoodsBriefMapper.queryGoodsByAuctionId(list); - } - - @Override - public int insertSelective(TaoBaoGoodsBrief taoBaoGoodsBrief) { - return taoBaoGoodsBriefMapper.insertSelective(taoBaoGoodsBrief); + public List<Long> listExistById(List<Long> list) { + if (list != null && list.size() > 0) + return taoBaoGoodsBriefMapper.listExistById(list); + else + return null; } @Override @@ -75,8 +84,6 @@ public TaoBaoGoodsBrief selectByPrimaryKey(Long id) { return taoBaoGoodsBriefMapper.selectByPrimaryKey(id); } - - @Override public void setGoodsBriefDefault(TaoBaoGoodsBrief goodsBrief) { @@ -188,4 +195,47 @@ return taoBaoGoodsBrief; } + @Override + public List<TaoBaoGoodsBrief> listByShopId(long start, int count, Long shopId) { + return taoBaoGoodsBriefMapper.listByShopId(start, count, shopId); + } + + @Override + public long countByShopId(Long shopId) { + return taoBaoGoodsBriefMapper.countByShopId(shopId); + } + + @Override + public List<TaoBaoGoodsBrief> filterOffLineGoods(List<TaoBaoGoodsBrief> goodsList) { + int page = goodsList.size() % 40 == 0 ? goodsList.size() / 40 -1 : goodsList.size() / 40; + List<TaoBaoGoodsBrief> flist = new ArrayList<>(); + for (int i = 0; i <= page; i++) { + List<TaoBaoGoodsBrief> list = goodsList.subList(i * 40, + i * 40 + 40 > goodsList.size() ?goodsList.size(): i * 40 + 40 ); + String ids = ""; + for (TaoBaoGoodsBrief goods : list) { + ids += goods.getAuctionId() + ","; + } + ids = ids.endsWith(",") ? ids.substring(0, ids.length() - 1) : ids; + Map<Long, TaoBaoGoodsBrief> goodsMap = new HashMap<>(); + try { + List<TaoBaoGoodsBrief> finalList = TaoKeApiUtil.getBatchGoodsInfos(ids); + if (finalList != null) + for (TaoBaoGoodsBrief ggods : finalList) + goodsMap.put(ggods.getAuctionId(), ggods); + + for (int j = 0; j < list.size(); j++) { + if (goodsMap.get(list.get(j).getAuctionId()) == null) { + list.remove(j); + j--; + } + } + } catch (TaobaoGoodsDownException e) { + e.printStackTrace(); + } + flist.addAll(list); + } + return flist; + } + } -- Gitblit v1.8.0