| | |
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | import com.yeshi.fanli.dao.brand.BrandShopCaheDao;
|
| | | import com.yeshi.fanli.dao.mybatis.brand.BrandInfoMapper;
|
| | | import com.yeshi.fanli.dto.ConfigParamsDTO;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.entity.brand.BrandGoodsCahe;
|
| | | import com.yeshi.fanli.entity.brand.BrandInfo;
|
| | |
| | | @Resource
|
| | | private BrandShopCaheService brandShopCaheService;
|
| | |
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | | |
| | | |
| | | @Override
|
| | | public void saveObject(MultipartFile file, BrandInfo record) throws BrandInfoException {
|
| | | String name = record.getName();
|
| | | if (name == null || name.trim().length() == 0)
|
| | | if (StringUtil.isNullOrEmpty(name))
|
| | | throw new BrandInfoException(1, "名称不能为空");
|
| | |
|
| | | String shopKey = record.getShopKey();
|
| | | if (StringUtil.isNullOrEmpty(shopKey))
|
| | | record.setShopKey(name);
|
| | | |
| | | String searchKey = record.getSearchKey();
|
| | | if (StringUtil.isNullOrEmpty(searchKey))
|
| | | record.setSearchKey(name);
|
| | | |
| | | Integer state = record.getState();
|
| | | if (state == null)
|
| | | record.setState(0);
|
| | |
| | |
|
| | | if (picture != null && picture.trim().length() > 0) {
|
| | | // 删除老图
|
| | | if (picture != null && picture.trim().length() > 0 && !Constant.IS_TEST) {
|
| | | COSManager.getInstance().deleteFile(picture);
|
| | | if (resultObj.getIcon() != null && resultObj.getIcon().trim().length() > 0 && !Constant.IS_TEST) {
|
| | | COSManager.getInstance().deleteFile(resultObj.getIcon());
|
| | | };
|
| | | // 存储新图
|
| | | record.setIcon(picture);
|
| | | } else {
|
| | | record.setIcon(resultObj.getIcon());
|
| | | }
|
| | | |
| | | record.setGoodsTotal(resultObj.getGoodsTotal());
|
| | | if (state == 0){
|
| | | record.setGoodsTotal(0);
|
| | | } else {
|
| | | record.setGoodsTotal(resultObj.getGoodsTotal());
|
| | | }
|
| | | record.setCreateTime(resultObj.getCreateTime());
|
| | | record.setUpdateTime(new Date());
|
| | | brandInfoMapper.updateByPrimaryKey(record);
|
| | | |
| | | |
| | | if (state == 0){
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | brandGoodsCaheService.removeByBrandId(id);
|
| | | brandShopCaheService.removeByBrandId(id);
|
| | | }
|
| | | });
|
| | | }
|
| | | }
|
| | |
|
| | | if (state == 1) {
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | int goodsTotal = brandGoodsCaheService.addBrandGoods(record);
|
| | | record.setGoodsTotal(goodsTotal);
|
| | | brandInfoMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | | });
|
| | | }
|
| | | }
|
| | |
|
| | |
| | |
|
| | | @Override
|
| | | public int deleteBatchByPrimaryKey(List<Long> list) {
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | for (Long id: list) {
|
| | | brandGoodsCaheService.removeByBrandId(id);
|
| | | brandShopCaheService.removeByBrandId(id);
|
| | | }
|
| | | }
|
| | | });
|
| | | |
| | | return brandInfoMapper.deleteBatchByPrimaryKey(list);
|
| | | }
|
| | |
|
| | |
| | | return brandClassShopService.countBrandShopinfo(cid);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public void removeAgoByDate(Date date) {
|
| | | // 删除商品
|
| | | brandGoodsCaheService.removeAgoByDate(date);
|
| | | |
| | | // 删除店铺
|
| | | brandShopCaheService.removeAgoByDate(date);
|
| | | |
| | | long count = brandInfoMapper.countValidByCid(null);
|
| | | if (count == 0)
|
| | | return;
|
| | |
|
| | | for (int page = 0; page < (count / 100) + 1; page++) {
|
| | | updateTotalGoods(page * 100, 100);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 更新商品数量
|
| | | * @param start
|
| | | * @param count
|
| | | */
|
| | | private void updateTotalGoods(long start, int count) {
|
| | | List<BrandInfo> list = brandInfoMapper.listValidAll(start, count);
|
| | | if (list == null || list.size() == 0)
|
| | | return;
|
| | | |
| | | for (BrandInfo brandInfo : list) {
|
| | | long goodsTotal = brandGoodsCaheService.countByBrandId(brandInfo.getId());
|
| | | |
| | | BrandInfo updateInfo = new BrandInfo();
|
| | | updateInfo.setId(brandInfo.getId());
|
| | | updateInfo.setGoodsTotal((int)goodsTotal);
|
| | | brandInfoMapper.updateByPrimaryKeySelective(updateInfo);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public void addShopAndGoods(long start, int count) {
|
| | | List<BrandInfo> list = brandInfoMapper.listValidAll(start, count);
|
| | |
| | | return;
|
| | |
|
| | | for (BrandInfo brandInfo : list) {
|
| | | String key = brandInfo.getName();
|
| | | if (StringUtil.isNullOrEmpty(key))
|
| | | String name = brandInfo.getName();
|
| | | String searchKey = brandInfo.getSearchKey();
|
| | | if (StringUtil.isNullOrEmpty(name) && StringUtil.isNullOrEmpty(searchKey))
|
| | | continue;
|
| | |
|
| | | // 添加商品
|
| | |
| | | return brandInfoMapper.listValidByCidToApp(cid);
|
| | | }
|
| | |
|
| | | @Cacheable(value = "brandCache", key = "'listValidToApp-'+#start+'-'+#start +'-'+#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);
|
| | |
| | |
|
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | |
|
| | | ConfigParamsDTO configParamsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
|
| | | List<BrandInfoVO> listInfo = new ArrayList<BrandInfoVO>();
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | BrandInfoVO brand = list.get(i);
|
| | |
| | | for (BrandGoodsCahe brandGoods : listGoods) {
|
| | | JDGoods goodsJD = brandGoods.getGoodsJD();
|
| | | if (goodsJD != null) {
|
| | | listGoodsVO.add(GoodsDetailVOFactory.convertJDGoods(goodsJD, fanLiRate, shareRate));
|
| | | listGoodsVO.add(GoodsDetailVOFactory.convertJDGoods(goodsJD, configParamsDTO));
|
| | | continue;
|
| | | }
|
| | |
|
| | | TaoBaoGoodsBrief goodsTB = brandGoods.getGoodsTB();
|
| | | if (goodsTB != null) {
|
| | | listGoodsVO.add(GoodsDetailVOFactory.convertTaoBao(goodsTB, null, fanLiRate, shareRate));
|
| | | listGoodsVO.add(GoodsDetailVOFactory.convertTaoBao(goodsTB, configParamsDTO));
|
| | | continue;
|
| | | }
|
| | |
|
| | | PDDGoodsDetail goodsPDD = brandGoods.getGoodsPDD();
|
| | | if (goodsPDD != null) {
|
| | | listGoodsVO.add(GoodsDetailVOFactory.convertPDDGoods(goodsPDD, fanLiRate, shareRate));
|
| | | listGoodsVO.add(GoodsDetailVOFactory.convertPDDGoods(goodsPDD, configParamsDTO));
|
| | | continue;
|
| | | }
|
| | | }
|