| | |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | @Autowired |
| | | private CateParamSelectMapper cateParamSelectMapper; |
| | | |
| | | |
| | | @Autowired |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | |
| | | @Override |
| | |
| | | |
| | | return goods.getId(); |
| | | } |
| | | |
| | | @Async |
| | | @Override |
| | | @Transactional( rollbackFor = {Exception.class, BusinessException.class}) |
| | | public Integer createPlat(GoodCreatePlatRequest param){ |
| | |
| | | } |
| | | List<Multifile> multifileList = new ArrayList<>(); |
| | | List<GoodsParam> goodsParamList = new ArrayList<>(); |
| | | for(BaseGoods model : goodsList){ |
| | | //遍历平台商品信息,进行商品信息同步 |
| | | Goods goods = initGoodsPlatParam(user,model,param); |
| | | if(goods == null){ |
| | | continue; |
| | | try{ |
| | | for(BaseGoods model : goodsList){ |
| | | //遍历平台商品信息,进行商品信息同步 |
| | | Goods goods = initGoodsPlatParam(user,model,param); |
| | | if(goods == null){ |
| | | continue; |
| | | } |
| | | goodsMapper.insert(goods); |
| | | //开始处理附件 |
| | | dealPlatMultifule(goods.getId(),user,model,multifileList); |
| | | //开始处理参数配置 |
| | | dealPlatGoodsParam(model,goods,user,goodsParamList); |
| | | } |
| | | goodsMapper.insert(goods); |
| | | //开始处理附件 |
| | | dealPlatMultifule(goods.getId(),user,model,multifileList); |
| | | //开始处理参数配置 |
| | | dealPlatGoodsParam(model,goods,user,goodsParamList); |
| | | if(multifileList.size()>0){ |
| | | multifileMapper.insertBatch(multifileList); |
| | | } |
| | | if(goodsParamList.size()>0){ |
| | | goodsParamMapper.insertBatch(goodsParamList); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | }finally { |
| | | redisTemplate.opsForValue().set(user.getCompanyId()+Constants.OPEN_SYNC_SWITCH,false); |
| | | } |
| | | if(multifileList.size()>0){ |
| | | multifileMapper.insertBatch(multifileList); |
| | | } |
| | | if(goodsParamList.size()>0){ |
| | | goodsParamMapper.insertBatch(goodsParamList); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | |
| | | return p.getPrice().setScale(0,BigDecimal.ROUND_CEILING); |
| | | } |
| | | } |
| | | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"数据异常请刷新重试"); |
| | | } |
| | | //如果没有配置入手价,安装加价系数来计算 |
| | | // if(model.getCateRatePrice()==null){ |
| | |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第【"+(num)+"】行商品品牌无效,请检查输入!"); |
| | | } |
| | | if(goodsMapper.selectCount(new QueryWrapper<Goods>().eq("ISDELETED",Constants.ZERO).eq("name",m.getName()))>0){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+m.getName()+"】已存在"); |
| | | }; |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"第【"+(num)+"】行【"+m.getName()+"】已存在"); |
| | | } |
| | | Goods newModel = new Goods(); |
| | | newModel.setRemark(m.getId()); |
| | | newModel.setCategoryId(cate.getId()); |
| | |
| | | return goodsList; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void openSyncSwitch() { |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | Boolean openSyncSwitch = (Boolean)redisTemplate.opsForValue().get(loginUserInfo.getCompanyId()+Constants.OPEN_SYNC_SWITCH); |
| | | if(openSyncSwitch!=null && openSyncSwitch ){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"数据同步中,请稍后刷新重试"); |
| | | } |
| | | redisTemplate.opsForValue().set(loginUserInfo.getCompanyId()+Constants.OPEN_SYNC_SWITCH,true); |
| | | } |
| | | } |
| | | |