server/company/src/main/java/com/doumee/api/business/GoodsController.java
@@ -66,9 +66,10 @@ @PostMapping("/createPlat") @RequiresPermissions("business:goods:create") public ApiResponse createPlat(@RequestBody GoodCreatePlatRequest param) { goodsService.openSyncSwitch(); goodsService.createPlat(param); cateParamSelectService.dealCateParamSelect(); return ApiResponse.success("操作成功"); return ApiResponse.success("同步操作成功,请稍后刷新查看商品同步信息"); } @ApiOperation("根据ID删除") server/company/src/main/java/com/doumee/config/shiro/ShiroConfig.java
@@ -107,13 +107,13 @@ map.put("/public/uploadLocal","anon"); map.put("/business/company/register", "anon"); map.put("/business/labels/page","anon"); map.put("/business/*/list","anon"); map.put("/business/goods/goodsPage","anon"); map.put("/business/goods/h5Image","anon"); map.put("/business/goods/export","anon"); map.put("/business/goods/listForH5","anon"); // map.put("/business/company/register", "anon"); // map.put("/business/labels/page","anon"); // map.put("/business/*/list","anon"); // map.put("/business/goods/goodsPage","anon"); // map.put("/business/goods/h5Image","anon"); // map.put("/business/goods/export","anon"); // map.put("/business/goods/listForH5","anon"); // - 放行swagger server/service/src/main/java/com/doumee/core/utils/Constants.java
@@ -30,6 +30,7 @@ public static final String PK_IMG = "PK_IMG"; public static final String RANGE_SIZE = "RANGE_SIZE"; public static final String CATE_PARAM_OPEN = "_CATE_PARAM_OPEN"; public static final String OPEN_SYNC_SWITCH = "OPEN_SYNC_SWITCH"; public static final String SYSTEM ="SYSTEM"; server/service/src/main/java/com/doumee/dao/business/model/Brand.java
@@ -77,4 +77,7 @@ @TableField(exist = false) private String imgfullurl; @ApiModelProperty(value = "分类主键") @TableField(exist = false) private Integer categoryId; } server/service/src/main/java/com/doumee/service/business/GoodsService.java
@@ -123,4 +123,7 @@ List<Goods> findListForH5(GoodsRequest goodsRequest); Integer createPlat(GoodCreatePlatRequest param); void openSyncSwitch(); } server/service/src/main/java/com/doumee/service/business/impl/BrandServiceImpl.java
@@ -161,6 +161,8 @@ if (Constants.equalsInteger(user.getType(), Constants.UserType.SYSTEM.getKey())) { wrapper.lambda().eq(Brand::getType,Constants.ONE); }else { wrapper.lambda().exists(!Objects.isNull(brand.getCategoryId())," select 1 from goods g where g.brand_id = brand.id and g.category_id = "+brand.getCategoryId()+" and g.COMPANY_ID = "+user.getCompanyId()+" " + " and g.STATUS = 0 and g.ISDELETED = 0 "); wrapper.lambda().and(i->i.eq(Brand::getCompanyId,user.getCompanyId()) .or().eq(Brand::getType,Constants.ONE) ); server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
@@ -29,6 +29,8 @@ 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; @@ -82,7 +84,8 @@ @Autowired private CateParamSelectMapper cateParamSelectMapper; @Autowired private RedisTemplate redisTemplate; @Override @@ -130,6 +133,8 @@ return goods.getId(); } @Async @Override @Transactional( rollbackFor = {Exception.class, BusinessException.class}) public Integer createPlat(GoodCreatePlatRequest param){ @@ -177,6 +182,7 @@ } List<Multifile> multifileList = new ArrayList<>(); List<GoodsParam> goodsParamList = new ArrayList<>(); try{ for(BaseGoods model : goodsList){ //遍历平台商品信息,进行商品信息同步 Goods goods = initGoodsPlatParam(user,model,param); @@ -195,7 +201,11 @@ if(goodsParamList.size()>0){ goodsParamMapper.insertBatch(goodsParamList); } }catch (Exception e){ e.printStackTrace(); }finally { redisTemplate.opsForValue().set(user.getCompanyId()+Constants.OPEN_SYNC_SWITCH,false); } return 1; } @@ -297,6 +307,7 @@ return p.getPrice().setScale(0,BigDecimal.ROUND_CEILING); } } throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"数据异常请刷新重试"); } //如果没有配置入手价,安装加价系数来计算 // if(model.getCateRatePrice()==null){ @@ -760,8 +771,8 @@ 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()); @@ -1128,5 +1139,17 @@ 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); } } server/service/src/main/java/com/doumee/service/impl/CateParamSelectServiceImpl.java
@@ -173,4 +173,6 @@ redisTemplate.opsForValue().set(loginUserInfo.getCompanyId()+Constants.CATE_PARAM_OPEN,false); } } }