| | |
| | | package com.yeshi.fanli.service.impl.brand;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | 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.jd.JDGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoShop;
|
| | | 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.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 BrandInfoMapper brandInfoMapper;
|
| | | |
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private BrandClassShopService brandClassShopService;
|
| | |
|
| | | |
| | | @Resource
|
| | | private BrandShopCaheDao brandShopCaheDao;
|
| | |
|
| | | @Resource
|
| | | private BrandGoodsCaheService brandGoodsCaheService;
|
| | |
|
| | | @Resource
|
| | | private BrandShopCaheService brandShopCaheService;
|
| | |
|
| | | @Override
|
| | | public void saveObject(BrandInfo record) throws BrandInfoException{
|
| | | public void saveObject(BrandInfo record) throws BrandInfoException {
|
| | | String name = record.getName();
|
| | | if (name == null || name.trim().length() == 0)
|
| | | throw new BrandInfoException(1, "名称不能为空");
|
| | | |
| | |
|
| | | Integer state = record.getState();
|
| | | if (state == null)
|
| | | record.setState(0);
|
| | | |
| | |
|
| | | Long id = record.getId();
|
| | | if (id == null) {
|
| | | record.setCreateTime(new Date());
|
| | |
| | | BrandInfo resultObj = brandInfoMapper.selectByPrimaryKey(id);
|
| | | if (resultObj == null)
|
| | | throw new BrandInfoException(1, "修改内容已不存在");
|
| | | |
| | |
|
| | | record.setCreateTime(resultObj.getCreateTime());
|
| | | record.setUpdateTime(new Date());
|
| | | brandInfoMapper.updateByPrimaryKey(record);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @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
|
| | | @Cacheable(value = "brandCache", key = "'listValidBrandInfoCache-'+#cid")
|
| | | public List<BrandInfo> listValidBrandInfoCache(Long cid) {
|
| | | List<BrandInfo> listInfo = new ArrayList<BrandInfo>();
|
| | | |
| | |
|
| | | List<TaoBaoShop> listShop = brandClassShopService.listEffectiveClassShop(cid);
|
| | | if (listShop == null || listShop.size() == 0)
|
| | | return listInfo;
|
| | |
| | | }
|
| | | return listInfo;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | @Cacheable(value = "brandCache", key = "'listBrandInfoCache-'+#start+'-'+#start +'-'+#cid")
|
| | | public List<BrandInfoVO> listBrandInfoCache(long start, int count, Long cid) {
|
| | | List<BrandInfoVO> listInfo = new ArrayList<BrandInfoVO>();
|
| | | |
| | |
|
| | | List<TaoBaoShopVO> listShop = brandClassShopService.listEffectiveShop(start, count, cid);
|
| | | if (listShop == null || listShop.size() == 0)
|
| | | return listInfo;
|
| | | |
| | |
|
| | | for (TaoBaoShopVO taoBaoShopVO : listShop) {
|
| | | String shopNameCustom = taoBaoShopVO.getShopNameCustom();
|
| | | if (!StringUtil.isNullOrEmpty(shopNameCustom)) {
|
| | |
| | | if (!StringUtil.isNullOrEmpty(shopIconCustom)) {
|
| | | taoBaoShopVO.setShopIcon(shopIconCustom);
|
| | | }
|
| | | |
| | |
|
| | | BrandInfoVO brandInfoVO = new BrandInfoVO();
|
| | | brandInfoVO.setId(taoBaoShopVO.getId());
|
| | | brandInfoVO.setName(taoBaoShopVO.getShopName());
|
| | |
| | | return listInfo;
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public long countBrandInfo(Long cid){
|
| | | 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)
|
| | | return;
|
| | |
|
| | | for (BrandInfo brandInfo : list) {
|
| | | String key = brandInfo.getName();
|
| | | if (StringUtil.isNullOrEmpty(key))
|
| | | continue;
|
| | |
|
| | | // 添加商品
|
| | | int goodsTotal = brandGoodsCaheService.addBrandGoods(brandInfo);
|
| | |
|
| | | brandInfo.setGoodsTotal(goodsTotal);
|
| | | brandInfo.setUpdateTime(new Date());
|
| | | brandInfoMapper.updateByPrimaryKeySelective(brandInfo);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countValidByCid(Long cid) {
|
| | | return brandInfoMapper.countValidByCid(cid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countValidByCidToApp(Long cid) {
|
| | | return brandInfoMapper.countValidByCidToApp(cid);
|
| | | }
|
| | |
|
| | | @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;
|
| | | }
|
| | | }
|