| | |
| | | package com.yeshi.fanli.service.impl.brand;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
| | |
|
| | | import com.yeshi.fanli.dao.brand.BrandShopCaheDao;
|
| | | import com.yeshi.fanli.dao.mybatis.brand.BrandInfoMapper;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.entity.brand.BrandGoodsCahe;
|
| | | import com.yeshi.fanli.entity.brand.BrandInfo;
|
| | | import com.yeshi.fanli.entity.brand.BrandShopCahe;
|
| | | import com.yeshi.fanli.entity.taobao.SearchShopFilter;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoShop;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoShopInfo;
|
| | | import com.yeshi.fanli.exception.brand.BrandInfoException;
|
| | | import com.yeshi.fanli.service.inter.brand.BrandClassShopService;
|
| | | import com.yeshi.fanli.service.inter.brand.BrandGoodsCaheService;
|
| | | import com.yeshi.fanli.service.inter.brand.BrandInfoService;
|
| | | import com.yeshi.fanli.service.inter.brand.BrandShopCaheService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.goods.ShopInfoVOFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.vo.brand.BrandInfoVO;
|
| | | import com.yeshi.fanli.vo.brand.TaoBaoShopVO;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | |
|
| | | @Service
|
| | | public class BrandInfoServiceImpl implements BrandInfoService {
|
| | |
| | | @Resource
|
| | | private BrandGoodsCaheService brandGoodsCaheService;
|
| | |
|
| | | |
| | | @Resource
|
| | | private BrandShopCaheService brandShopCaheService;
|
| | |
|
| | | @Override
|
| | | public void saveObject(BrandInfo record) throws BrandInfoException{
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public int deleteBatchByPrimaryKey(List<Long> list) {
|
| | | return brandInfoMapper.deleteBatchByPrimaryKey(list);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public List<BrandInfo> listQuery(long start, int count, String key, Integer state) {
|
| | | return null;
|
| | | public List<BrandInfo> listQuery(long start, int count, String key, Long cid, Integer state) {
|
| | | return brandInfoMapper.listQuery(start, count, key, cid, state);
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public long countQuery(String key, Integer state) {
|
| | | return 0;
|
| | | public long countQuery(String key, Long cid, Integer state) {
|
| | | return brandInfoMapper.countQuery(key, cid, state);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | }
|
| | | return listInfo;
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | @Cacheable(value = "brandCache", key = "'listBrandInfoCache-'+#start+'-'+#start +'-'+#cid")
|
| | |
| | | return listInfo;
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public long countBrandInfo(Long cid){
|
| | | return brandClassShopService.countBrandShopinfo(cid);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public void addShopAndGoods(long start, int count) {
|
| | | List<BrandInfo> list = brandInfoMapper.listValidAll(start, count);
|
| | | if(list == null || list.size() == 0)
|
| | |
| | | if(StringUtil.isNullOrEmpty(key))
|
| | | continue;
|
| | |
|
| | | // 添加店铺
|
| | | addBrandShop(brandInfo);
|
| | | |
| | | // 添加店铺
|
| | | // 添加商品
|
| | | int goodsTotal = brandGoodsCaheService.addBrandGoods(brandInfo);
|
| | |
|
| | | brandInfo.setGoodsTotal(goodsTotal);
|
| | | brandInfo.setUpdateTime(new Date());
|
| | | brandInfoMapper.updateByPrimaryKeySelective(brandInfo);
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 加入品牌店铺
|
| | | * @param brandInfo
|
| | | */
|
| | | private void addBrandShop(BrandInfo brandInfo) {
|
| | | SearchShopFilter filter = new SearchShopFilter();
|
| | | filter.setKey(brandInfo.getName());
|
| | | filter.setPageSize(100);
|
| | | filter.setTmall(true);
|
| | | filter.setSort("(total_auction_des");
|
| | | |
| | | |
| | | TaoBaoShopInfo taoBaoShop = null;
|
| | | for(int page = 1; page < 3; page++) {
|
| | | filter.setPage(page);
|
| | | List<TaoBaoShopInfo> listShop = TaoKeApiUtil.searchShop(filter);
|
| | | if(listShop == null || listShop.size() == 0)
|
| | | continue;
|
| | | |
| | | for (TaoBaoShopInfo shop: listShop) {
|
| | | String shopTitle = shop.getShopTitle();
|
| | | if(StringUtil.isNullOrEmpty(shopTitle))
|
| | | continue;
|
| | | |
| | | if(!shopTitle.contains("旗舰店"))
|
| | | continue;
|
| | | |
| | | taoBaoShop = shop;
|
| | | break;
|
| | | @Override
|
| | | public long countValidByCid(Long cid) {
|
| | | return brandInfoMapper.countValidByCid(cid);
|
| | | }
|
| | |
|
| | | if (taoBaoShop != null) |
| | | break;
|
| | | @Override
|
| | | public long countValidByCidToApp(Long cid) {
|
| | | return brandInfoMapper.countValidByCidToApp(cid);
|
| | | }
|
| | |
|
| | | BrandShopCahe brandShop = new BrandShopCahe();
|
| | | brandShop.setBrandId(brandInfo.getId());
|
| | | brandShop.setShop(ShopInfoVOFactory.convertTaoBaoShop(taoBaoShop));
|
| | | brandShop.setCreateTime(new Date());
|
| | | brandShop.setUpdateTime(new Date());
|
| | | brandShopCaheDao.save(brandShop);
|
| | | @Override
|
| | | @Cacheable(value = "brandCache", key = "'listValidByCidToApp-'+#cid")
|
| | | public List<BrandInfo> listValidByCidToApp(Long cid) {
|
| | | if (cid == null)
|
| | | return null;
|
| | | return brandInfoMapper.listValidByCidToApp(cid);
|
| | | }
|
| | |
|
| | | @Cacheable(value = "brandCache", key = "'listValidToApp-'+#start+'-'+#start +'-'+#cid")
|
| | | @Override
|
| | | public List<BrandInfoVO> listValidToApp(long start, int count, Long cid) {
|
| | | List<BrandInfoVO> list = brandInfoMapper.listBrandInfoVO(start, count, cid);
|
| | | if (list == null || list.size() == 0)
|
| | | return null;
|
| | |
|
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | |
|
| | | List<BrandInfoVO> listInfo = new ArrayList<BrandInfoVO>();
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | BrandInfoVO brand = list.get(i);
|
| | | if (brand == null)
|
| | | continue;
|
| | | |
| | | List<BrandGoodsCahe> listGoods = brandGoodsCaheService.getByBrandId(1, 3, brand.getId());
|
| | | if (listGoods == null || listGoods.size() < 3)
|
| | | continue;
|
| | |
|
| | | List<GoodsDetailVO> listGoodsVO = new ArrayList<GoodsDetailVO>();
|
| | | for (BrandGoodsCahe brandGoods : listGoods) {
|
| | | JDGoods goodsJD = brandGoods.getGoodsJD();
|
| | | if (goodsJD != null) {
|
| | | listGoodsVO.add(GoodsDetailVOFactory.convertJDGoods(goodsJD, fanLiRate, shareRate));
|
| | | continue;
|
| | | }
|
| | |
|
| | | TaoBaoGoodsBrief goodsTB = brandGoods.getGoodsTB();
|
| | | if (goodsTB != null) {
|
| | | listGoodsVO.add(GoodsDetailVOFactory.convertTaoBao(goodsTB, null, fanLiRate, shareRate));
|
| | | continue;
|
| | | }
|
| | |
|
| | | PDDGoodsDetail goodsPDD = brandGoods.getGoodsPDD();
|
| | | if (goodsPDD != null) {
|
| | | listGoodsVO.add(GoodsDetailVOFactory.convertPDDGoods(goodsPDD, fanLiRate, shareRate));
|
| | | continue;
|
| | | }
|
| | | }
|
| | |
|
| | | if (listGoodsVO.size() >= 3) {
|
| | | brand.setListGoods(listGoodsVO);
|
| | | listInfo.add(brand);
|
| | | }
|
| | | }
|
| | | return listInfo;
|
| | | }
|
| | | }
|