21 changed files with 916 additions and 50 deletions
@ -0,0 +1,64 @@ |
|||||
|
package com.qs.serve.modules.goods.controller; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.qs.serve.common.model.annotation.SysLog; |
||||
|
import com.qs.serve.common.model.dto.PageVo; |
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import com.qs.serve.common.model.enums.BizType; |
||||
|
import com.qs.serve.common.model.enums.SystemModule; |
||||
|
import com.qs.serve.common.util.PageUtil; |
||||
|
import com.qs.serve.common.util.CopierUtil; |
||||
|
import com.qs.serve.common.util.StringUtils; |
||||
|
import com.qs.serve.modules.goods.entity.bo.GoodsAccreditBo; |
||||
|
import com.qs.serve.modules.goods.entity.vo.GoodsAccreditVo; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.security.access.prepost.PreAuthorize; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import com.qs.serve.modules.goods.entity.GoodsAccredit; |
||||
|
import com.qs.serve.modules.goods.service.GoodsAccreditService; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 商品 授权规则 |
||||
|
* @author YenHex |
||||
|
* @since 2024-04-01 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@AllArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("goods/accredit") |
||||
|
public class GoodsAccreditController { |
||||
|
|
||||
|
private GoodsAccreditService goodsAccreditService; |
||||
|
|
||||
|
/** |
||||
|
* ID查询 |
||||
|
* @param cateId |
||||
|
* @param spuId |
||||
|
* @param skuId |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/getById") |
||||
|
public R<GoodsAccreditVo> getById(String cateId,String spuId,String skuId){ |
||||
|
GoodsAccreditVo goodsAccredit = goodsAccreditService.getById(cateId,spuId,skuId); |
||||
|
return R.ok(goodsAccredit); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 更新 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/updateById") |
||||
|
@SysLog(module = SystemModule.GOODS, title = "规则", biz = BizType.UPDATE) |
||||
|
public R<?> updateById(@RequestBody @Valid GoodsAccreditBo param){ |
||||
|
goodsAccreditService.modify(param); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,96 @@ |
|||||
|
package com.qs.serve.modules.goods.entity; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.io.Serializable; |
||||
|
import java.math.BigDecimal; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
import lombok.Data; |
||||
|
import org.hibernate.validator.constraints.Length; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
/** |
||||
|
* 规则 实体类 |
||||
|
* @author YenHex |
||||
|
* @since 2024-04-01 |
||||
|
*/ |
||||
|
@Data |
||||
|
@TableName("goods_accredit") |
||||
|
public class GoodsAccredit implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** id */ |
||||
|
@TableId(type = IdType.AUTO) |
||||
|
private Long id; |
||||
|
|
||||
|
/** 客户id */ |
||||
|
private Long spuId; |
||||
|
|
||||
|
/** 销售区域id */ |
||||
|
@Length(max = 32,message = "销售区域id长度不能超过32字") |
||||
|
private String categoryId; |
||||
|
|
||||
|
/** 空标识 */ |
||||
|
private Integer emptyFlag; |
||||
|
|
||||
|
/** 备注 */ |
||||
|
@Length(max = 255,message = "备注长度不能超过255字") |
||||
|
private String remark; |
||||
|
|
||||
|
/** 创建时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private LocalDateTime createTime; |
||||
|
|
||||
|
/** 最后更新时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private LocalDateTime updateTime; |
||||
|
|
||||
|
/** 所属租户 */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String tenantId; |
||||
|
|
||||
|
/** 逻辑删除标记(0:显示;1:隐藏) */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String delFlag; |
||||
|
|
||||
|
/** 创建人 */ |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private String createBy; |
||||
|
|
||||
|
/** 更新人 */ |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private String updateBy; |
||||
|
|
||||
|
|
||||
|
public static GoodsAccredit toNewObject(GoodsAccredit source){ |
||||
|
GoodsAccredit accredit = new GoodsAccredit(); |
||||
|
accredit.setId(source.getId()); |
||||
|
accredit.setSpuId(source.getSpuId()); |
||||
|
accredit.setCategoryId(source.getCategoryId()); |
||||
|
accredit.setEmptyFlag(source.getEmptyFlag()); |
||||
|
accredit.setRemark(source.getRemark()); |
||||
|
accredit.setCreateTime(source.getCreateTime()); |
||||
|
accredit.setUpdateTime(source.getUpdateTime()); |
||||
|
accredit.setTenantId(source.getTenantId()); |
||||
|
accredit.setDelFlag(source.getDelFlag()); |
||||
|
accredit.setCreateBy(source.getCreateBy()); |
||||
|
accredit.setUpdateBy(source.getUpdateBy()); |
||||
|
return accredit; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,95 @@ |
|||||
|
package com.qs.serve.modules.goods.entity; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.io.Serializable; |
||||
|
import java.math.BigDecimal; |
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
import com.fasterxml.jackson.annotation.JsonProperty; |
||||
|
import lombok.Data; |
||||
|
import org.hibernate.validator.constraints.Length; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
/** |
||||
|
* 商品sku规则 实体类 |
||||
|
* @author YenHex |
||||
|
* @since 2024-04-01 |
||||
|
*/ |
||||
|
@Data |
||||
|
@TableName("goods_accredit_item") |
||||
|
public class GoodsAccreditItem implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** id */ |
||||
|
@TableId(type = IdType.AUTO) |
||||
|
private Long id; |
||||
|
|
||||
|
/** 规则id */ |
||||
|
@NotNull(message = "规则id不能为空") |
||||
|
private Long accId; |
||||
|
|
||||
|
/** 0:in,1:not-in */ |
||||
|
private Integer accType; |
||||
|
|
||||
|
/** 维度类型:supplier-客户;bizRegion-行政区域;saleRegion-销售区域 */ |
||||
|
@NotNull(message = "维度类型:0-客户;1-行政区域;2-销售区域不能为空") |
||||
|
private String targetType; |
||||
|
|
||||
|
/** 维度编码 */ |
||||
|
@NotBlank(message = "维度编码不能为空") |
||||
|
@Length(max = 255,message = "维度编码长度不能超过255字") |
||||
|
private String targetCode; |
||||
|
|
||||
|
/** 维度名称 */ |
||||
|
@Length(max = 255,message = "维度名称长度不能超过255字") |
||||
|
private String targetName; |
||||
|
|
||||
|
/** 维度id */ |
||||
|
@NotBlank(message = "维度id不能为空") |
||||
|
@Length(max = 30,message = "维度id长度不能超过30字") |
||||
|
private String targetId; |
||||
|
|
||||
|
/** 备注 */ |
||||
|
@Length(max = 255,message = "备注长度不能超过255字") |
||||
|
private String remark; |
||||
|
|
||||
|
/** 创建时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private LocalDateTime createTime; |
||||
|
|
||||
|
/** 最后更新时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private LocalDateTime updateTime; |
||||
|
|
||||
|
/** 所属租户 */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String tenantId; |
||||
|
|
||||
|
/** 逻辑删除标记(0:显示;1:隐藏) */ |
||||
|
@JsonIgnore |
||||
|
@JsonProperty |
||||
|
private String delFlag; |
||||
|
|
||||
|
/** 创建人 */ |
||||
|
@TableField(fill = FieldFill.INSERT) |
||||
|
private String createBy; |
||||
|
|
||||
|
/** 更新人 */ |
||||
|
@TableField(fill = FieldFill.UPDATE) |
||||
|
private String updateBy; |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,49 @@ |
|||||
|
package com.qs.serve.modules.goods.entity.bo; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2024/4/1 |
||||
|
*/ |
||||
|
@Data |
||||
|
@NoArgsConstructor |
||||
|
public class GoodsAccreditBo { |
||||
|
|
||||
|
/** 授权ID(更新必传) */ |
||||
|
private Long accId; |
||||
|
|
||||
|
private String spuId; |
||||
|
|
||||
|
private String skuId; |
||||
|
|
||||
|
private String categoryId; |
||||
|
|
||||
|
/** 只能选的销售区域 */ |
||||
|
private List<String> onlySaleRegionIds; |
||||
|
|
||||
|
/** 不能选的销售区域 */ |
||||
|
private List<String> notInSaleRegionIds; |
||||
|
|
||||
|
/** 只能选的行政区域 */ |
||||
|
private List<String> onlyBizRegionIds; |
||||
|
|
||||
|
/** 不能选的行政区域 */ |
||||
|
private List<String> notInBizRegionIds; |
||||
|
|
||||
|
/** 只能选的客户 */ |
||||
|
private List<String> onlySupplierIds; |
||||
|
|
||||
|
/** 不能选的客户 */ |
||||
|
private List<String> notInSupplierIds; |
||||
|
|
||||
|
public GoodsAccreditBo(String categoryId,String spuId,String skuId){ |
||||
|
this.categoryId = categoryId; |
||||
|
this.spuId = spuId; |
||||
|
this.skuId = skuId; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,42 @@ |
|||||
|
package com.qs.serve.modules.goods.entity.vo; |
||||
|
|
||||
|
import com.qs.serve.modules.bms.entity.BmsRegion; |
||||
|
import com.qs.serve.modules.bms.entity.BmsRegion2; |
||||
|
import com.qs.serve.modules.bms.entity.BmsSupplier; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2024/4/1 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class GoodsAccreditVo { |
||||
|
|
||||
|
/** 规则ID(更新必传) */ |
||||
|
private Long accreditId; |
||||
|
|
||||
|
/** 备注 */ |
||||
|
private String remark; |
||||
|
|
||||
|
/** 可下单 销售区域 */ |
||||
|
private List<BmsRegion> onlySaleRegionList; |
||||
|
|
||||
|
/** 不可下单 销售区域 */ |
||||
|
private List<BmsRegion> notInSaleRegionList; |
||||
|
|
||||
|
/** 可下单 行政区域 */ |
||||
|
private List<BmsRegion2> onlyBizRegionList; |
||||
|
|
||||
|
/** 不可下单 行政区域 */ |
||||
|
private List<BmsRegion2> notInBizRegionList; |
||||
|
|
||||
|
/** 可下单 客户 */ |
||||
|
private List<BmsSupplier> onlySupplierList; |
||||
|
|
||||
|
/** 不可下单 客户 */ |
||||
|
private List<BmsSupplier> notInSupplierList; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
package com.qs.serve.modules.goods.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.qs.serve.modules.goods.entity.GoodsAccreditItem; |
||||
|
|
||||
|
/** |
||||
|
* 商品sku规则 Mapper |
||||
|
* @author YenHex |
||||
|
* @date 2024-04-01 |
||||
|
*/ |
||||
|
public interface GoodsAccreditItemMapper extends BaseMapper<GoodsAccreditItem> { |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,14 @@ |
|||||
|
package com.qs.serve.modules.goods.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.qs.serve.modules.goods.entity.GoodsAccredit; |
||||
|
|
||||
|
/** |
||||
|
* 规则 Mapper |
||||
|
* @author YenHex |
||||
|
* @date 2024-04-01 |
||||
|
*/ |
||||
|
public interface GoodsAccreditMapper extends BaseMapper<GoodsAccredit> { |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,14 @@ |
|||||
|
package com.qs.serve.modules.goods.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import com.qs.serve.modules.goods.entity.GoodsAccreditItem; |
||||
|
|
||||
|
/** |
||||
|
* 商品sku规则 服务接口 |
||||
|
* @author YenHex |
||||
|
* @date 2024-04-01 |
||||
|
*/ |
||||
|
public interface GoodsAccreditItemService extends IService<GoodsAccreditItem> { |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,20 @@ |
|||||
|
package com.qs.serve.modules.goods.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import com.qs.serve.modules.goods.entity.GoodsAccredit; |
||||
|
import com.qs.serve.modules.goods.entity.bo.GoodsAccreditBo; |
||||
|
import com.qs.serve.modules.goods.entity.vo.GoodsAccreditVo; |
||||
|
|
||||
|
/** |
||||
|
* 规则 服务接口 |
||||
|
* @author YenHex |
||||
|
* @date 2024-04-01 |
||||
|
*/ |
||||
|
public interface GoodsAccreditService extends IService<GoodsAccredit> { |
||||
|
|
||||
|
void modify(GoodsAccreditBo param); |
||||
|
|
||||
|
GoodsAccreditVo getById(String cateId, String spuId, String skuId); |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,22 @@ |
|||||
|
package com.qs.serve.modules.goods.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import com.qs.serve.modules.goods.entity.GoodsAccreditItem; |
||||
|
import com.qs.serve.modules.goods.service.GoodsAccreditItemService; |
||||
|
import com.qs.serve.modules.goods.mapper.GoodsAccreditItemMapper; |
||||
|
|
||||
|
/** |
||||
|
* 商品sku规则 服务实现类 |
||||
|
* @author YenHex |
||||
|
* @since 2024-04-01 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@AllArgsConstructor |
||||
|
public class GoodsAccreditItemServiceImpl extends ServiceImpl<GoodsAccreditItemMapper,GoodsAccreditItem> implements GoodsAccreditItemService { |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,264 @@ |
|||||
|
package com.qs.serve.modules.goods.service.impl; |
||||
|
|
||||
|
import cn.hutool.core.collection.CollUtil; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import com.qs.serve.common.util.Assert; |
||||
|
import com.qs.serve.modules.bms.entity.BmsRegion; |
||||
|
import com.qs.serve.modules.bms.entity.BmsRegion2; |
||||
|
import com.qs.serve.modules.bms.entity.BmsSupplier; |
||||
|
import com.qs.serve.modules.bms.mapper.BmsRegion2Mapper; |
||||
|
import com.qs.serve.modules.bms.mapper.BmsRegionMapper; |
||||
|
import com.qs.serve.modules.bms.mapper.BmsSupplierMapper; |
||||
|
import com.qs.serve.modules.goods.entity.*; |
||||
|
import com.qs.serve.modules.goods.entity.bo.GoodsAccreditBo; |
||||
|
import com.qs.serve.modules.goods.entity.vo.GoodsAccreditVo; |
||||
|
import com.qs.serve.modules.goods.mapper.GoodsAccreditItemMapper; |
||||
|
import com.qs.serve.modules.goods.mapper.GoodsCategoryMapper; |
||||
|
import com.qs.serve.modules.goods.mapper.GoodsSpuMapper; |
||||
|
import com.qs.serve.modules.goods.service.GoodsAccreditItemService; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import com.qs.serve.modules.goods.service.GoodsAccreditService; |
||||
|
import com.qs.serve.modules.goods.mapper.GoodsAccreditMapper; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* 规则 服务实现类 |
||||
|
* @author YenHex |
||||
|
* @since 2024-04-01 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@AllArgsConstructor |
||||
|
public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,GoodsAccredit> implements GoodsAccreditService { |
||||
|
|
||||
|
private final GoodsCategoryMapper categoryMapper; |
||||
|
private final GoodsSpuMapper goodsSpuMapper; |
||||
|
|
||||
|
private final BmsRegionMapper regionMapper; |
||||
|
private final BmsRegion2Mapper region2Mapper; |
||||
|
private final BmsSupplierMapper supplierMapper; |
||||
|
|
||||
|
private final GoodsAccreditItemService goodsAccreditItemService; |
||||
|
|
||||
|
@Override |
||||
|
public void modify(GoodsAccreditBo param) { |
||||
|
GoodsAccredit goodsAccredit = null; |
||||
|
if(param.getAccId()==null){ |
||||
|
goodsAccredit = this.getGoodsAccredit(param); |
||||
|
}else { |
||||
|
goodsAccredit = this.getById(param.getAccId()); |
||||
|
} |
||||
|
|
||||
|
if(goodsAccredit==null){ |
||||
|
Assert.throwEx("参数异常 500B2 "); |
||||
|
} |
||||
|
|
||||
|
boolean b1 = CollUtil.isNotEmpty(param.getNotInSaleRegionIds()); |
||||
|
boolean b2 = CollUtil.isNotEmpty(param.getOnlySaleRegionIds()); |
||||
|
boolean b3 = CollUtil.isNotEmpty(param.getNotInBizRegionIds()); |
||||
|
boolean b4 = CollUtil.isNotEmpty(param.getNotInBizRegionIds()); |
||||
|
boolean b5 = CollUtil.isNotEmpty(param.getOnlySupplierIds()); |
||||
|
boolean b6 = CollUtil.isNotEmpty(param.getNotInSupplierIds()); |
||||
|
|
||||
|
//清空历史
|
||||
|
goodsAccreditItemService.remove(new LambdaQueryWrapper<GoodsAccreditItem>() |
||||
|
.eq(GoodsAccreditItem::getAccId,goodsAccredit.getId())); |
||||
|
|
||||
|
if(!b1 && !b2 && !b3 && !b4 && !b5 && !b6){ |
||||
|
if(goodsAccredit.getId()!=null){ |
||||
|
goodsAccredit.setEmptyFlag(1); |
||||
|
this.updateById(goodsAccredit); |
||||
|
} |
||||
|
}else { |
||||
|
if(goodsAccredit.getId()!=null){ |
||||
|
goodsAccredit.setEmptyFlag(0); |
||||
|
this.updateById(goodsAccredit); |
||||
|
}else { |
||||
|
this.save(goodsAccredit); |
||||
|
param.setAccId(goodsAccredit.getId()); |
||||
|
} |
||||
|
} |
||||
|
Long accId = goodsAccredit.getId(); |
||||
|
|
||||
|
if(b1){ |
||||
|
List<BmsRegion> saleRegionList = regionMapper.selectBatchIds(param.getOnlySaleRegionIds()); |
||||
|
List<GoodsAccreditItem> list = saleRegionList.stream().map(a->{ |
||||
|
GoodsAccreditItem item = new GoodsAccreditItem(); |
||||
|
item.setAccId(accId); |
||||
|
item.setAccType(0); |
||||
|
item.setTargetType("saleRegion"); |
||||
|
item.setTargetCode(a.getCode()); |
||||
|
item.setTargetName(a.getName()); |
||||
|
item.setTargetId(a.getId()); |
||||
|
return item; |
||||
|
}).collect(Collectors.toList()); |
||||
|
goodsAccreditItemService.saveBatch(list); |
||||
|
} |
||||
|
|
||||
|
if(b2){ |
||||
|
List<BmsRegion> saleRegionList = regionMapper.selectBatchIds(param.getNotInSaleRegionIds()); |
||||
|
List<GoodsAccreditItem> list = saleRegionList.stream().map(a->{ |
||||
|
GoodsAccreditItem item = new GoodsAccreditItem(); |
||||
|
item.setAccId(accId); |
||||
|
item.setAccType(1); |
||||
|
item.setTargetType("saleRegion"); |
||||
|
item.setTargetCode(a.getCode()); |
||||
|
item.setTargetName(a.getName()); |
||||
|
item.setTargetId(a.getId()); |
||||
|
return item; |
||||
|
}).collect(Collectors.toList()); |
||||
|
goodsAccreditItemService.saveBatch(list); |
||||
|
} |
||||
|
|
||||
|
if(b3){ |
||||
|
List<BmsRegion2> regionList = region2Mapper.selectBatchIds(param.getOnlyBizRegionIds()); |
||||
|
List<GoodsAccreditItem> list = regionList.stream().map(a->{ |
||||
|
GoodsAccreditItem item = new GoodsAccreditItem(); |
||||
|
item.setAccId(accId); |
||||
|
item.setAccType(0); |
||||
|
item.setTargetType("bizRegion"); |
||||
|
item.setTargetCode(a.getCode()); |
||||
|
item.setTargetName(a.getName()); |
||||
|
item.setTargetId(a.getId()); |
||||
|
return item; |
||||
|
}).collect(Collectors.toList()); |
||||
|
goodsAccreditItemService.saveBatch(list); |
||||
|
} |
||||
|
|
||||
|
if(b4){ |
||||
|
List<BmsRegion2> regionList = region2Mapper.selectBatchIds(param.getNotInBizRegionIds()); |
||||
|
List<GoodsAccreditItem> list = regionList.stream().map(a->{ |
||||
|
GoodsAccreditItem item = new GoodsAccreditItem(); |
||||
|
item.setAccId(accId); |
||||
|
item.setAccType(1); |
||||
|
item.setTargetType("bizRegion"); |
||||
|
item.setTargetCode(a.getCode()); |
||||
|
item.setTargetName(a.getName()); |
||||
|
item.setTargetId(a.getId()); |
||||
|
return item; |
||||
|
}).collect(Collectors.toList()); |
||||
|
goodsAccreditItemService.saveBatch(list); |
||||
|
} |
||||
|
|
||||
|
if(b5){ |
||||
|
List<BmsSupplier> supplierList = supplierMapper.selectBatchIds(param.getOnlySupplierIds()); |
||||
|
List<GoodsAccreditItem> list = supplierList.stream().map(a->{ |
||||
|
GoodsAccreditItem item = new GoodsAccreditItem(); |
||||
|
item.setAccId(accId); |
||||
|
item.setAccType(0); |
||||
|
item.setTargetType("supplier"); |
||||
|
item.setTargetCode(a.getCode()); |
||||
|
item.setTargetName(a.getName()); |
||||
|
item.setTargetId(a.getId()); |
||||
|
return item; |
||||
|
}).collect(Collectors.toList()); |
||||
|
goodsAccreditItemService.saveBatch(list); |
||||
|
} |
||||
|
|
||||
|
if(b6){ |
||||
|
List<BmsSupplier> supplierList = supplierMapper.selectBatchIds(param.getNotInSupplierIds()); |
||||
|
List<GoodsAccreditItem> list = supplierList.stream().map(a->{ |
||||
|
GoodsAccreditItem item = new GoodsAccreditItem(); |
||||
|
item.setAccId(accId); |
||||
|
item.setAccType(1); |
||||
|
item.setTargetType("supplier"); |
||||
|
item.setTargetCode(a.getCode()); |
||||
|
item.setTargetName(a.getName()); |
||||
|
item.setTargetId(a.getId()); |
||||
|
return item; |
||||
|
}).collect(Collectors.toList()); |
||||
|
goodsAccreditItemService.saveBatch(list); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public GoodsAccreditVo getById(String cateId, String spuId, String skuId) { |
||||
|
GoodsAccredit accredit = this.getGoodsAccredit(new GoodsAccreditBo(cateId,spuId,skuId)); |
||||
|
GoodsAccreditVo accreditVo = new GoodsAccreditVo(); |
||||
|
if(accredit!=null){ |
||||
|
List<GoodsAccreditItem> accreditItemList = goodsAccreditItemService |
||||
|
.list(new LambdaQueryWrapper<GoodsAccreditItem>().eq(GoodsAccreditItem::getAccId,accredit.getId())); |
||||
|
Map<String,List<GoodsAccreditItem>> accMap = accreditItemList.stream() |
||||
|
.collect(Collectors.groupingBy(GoodsAccreditItem::getTargetType)); |
||||
|
List<GoodsAccreditItem> list1 = accMap.get("supplier"); |
||||
|
List<GoodsAccreditItem> list2 = accMap.get("bizRegion"); |
||||
|
List<GoodsAccreditItem> list3 = accMap.get("caleRegion"); |
||||
|
|
||||
|
if(CollUtil.isNotEmpty(list1)){ |
||||
|
Map<Integer,List<GoodsAccreditItem>> listMap = list1.stream() |
||||
|
.collect(Collectors.groupingBy(GoodsAccreditItem::getAccType)); |
||||
|
List<GoodsAccreditItem> onlyList = listMap.get(0); |
||||
|
List<GoodsAccreditItem> notInList = listMap.get(1); |
||||
|
if(CollUtil.isNotEmpty(onlyList)){ |
||||
|
List<String> ids = onlyList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
||||
|
accreditVo.setOnlySupplierList(supplierMapper.selectBatchIds(ids)); |
||||
|
} |
||||
|
if(CollUtil.isNotEmpty(notInList)){ |
||||
|
List<String> ids = notInList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
||||
|
accreditVo.setNotInSupplierList(supplierMapper.selectBatchIds(ids)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if(CollUtil.isNotEmpty(list2)){ |
||||
|
Map<Integer,List<GoodsAccreditItem>> listMap = list2.stream() |
||||
|
.collect(Collectors.groupingBy(GoodsAccreditItem::getAccType)); |
||||
|
List<GoodsAccreditItem> onlyList = listMap.get(0); |
||||
|
List<GoodsAccreditItem> notInList = listMap.get(1); |
||||
|
if(CollUtil.isNotEmpty(onlyList)){ |
||||
|
List<String> ids = onlyList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
||||
|
accreditVo.setOnlyBizRegionList(region2Mapper.selectBatchIds(ids)); |
||||
|
} |
||||
|
if(CollUtil.isNotEmpty(notInList)){ |
||||
|
List<String> ids = notInList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
||||
|
accreditVo.setNotInBizRegionList(region2Mapper.selectBatchIds(ids)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if(CollUtil.isNotEmpty(list3)){ |
||||
|
Map<Integer,List<GoodsAccreditItem>> listMap = list3.stream() |
||||
|
.collect(Collectors.groupingBy(GoodsAccreditItem::getAccType)); |
||||
|
List<GoodsAccreditItem> onlyList = listMap.get(0); |
||||
|
List<GoodsAccreditItem> notInList = listMap.get(1); |
||||
|
if(CollUtil.isNotEmpty(onlyList)){ |
||||
|
List<String> ids = onlyList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
||||
|
accreditVo.setOnlySaleRegionList(regionMapper.selectBatchIds(ids)); |
||||
|
} |
||||
|
if(CollUtil.isNotEmpty(notInList)){ |
||||
|
List<String> ids = notInList.stream().map(GoodsAccreditItem::getTargetId).collect(Collectors.toList()); |
||||
|
accreditVo.setNotInSaleRegionList(regionMapper.selectBatchIds(ids)); |
||||
|
} |
||||
|
} |
||||
|
return accreditVo; |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
private GoodsAccredit getGoodsAccredit(GoodsAccreditBo param){ |
||||
|
GoodsAccredit accredit = null; |
||||
|
if(param.getCategoryId()!=null){ |
||||
|
GoodsCategory category = categoryMapper.selectById(param.getCategoryId()); |
||||
|
if(category!=null){ |
||||
|
accredit = new GoodsAccredit(); |
||||
|
accredit.setCategoryId(category.getId().toString()); |
||||
|
} |
||||
|
}else if (param.getSpuId()!=null){ |
||||
|
GoodsSpu spu = goodsSpuMapper.selectById(param.getSpuId()); |
||||
|
if(spu!=null){ |
||||
|
accredit = new GoodsAccredit(); |
||||
|
accredit.setSpuId(spu.getId()); |
||||
|
} |
||||
|
} |
||||
|
return accredit; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
Loading…
Reference in new issue