|
|
@@ -82,6 +82,9 @@ public class KwpGoodsService {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void addDraft(AddGoodsDraftParam param) {
|
|
|
+ if (nameDuplicationJudgment(param.getName(), null)) {
|
|
|
+ throw new BusinessException("已存在相同商品名称!");
|
|
|
+ }
|
|
|
//添加商品信息
|
|
|
KwpGoods goods = BeanUtils.copyProperties(param, KwpGoods.class);
|
|
|
AddressInfo address = param.getAddressInfo();
|
|
|
@@ -106,6 +109,9 @@ public class KwpGoodsService {
|
|
|
if (Objects.equals(param.getPrepaidLimit(), 1) && Objects.isNull(param.getAdvancePrice())) {
|
|
|
throw new BusinessException("设置预付限额时,预付款最低限额不能为空!");
|
|
|
}
|
|
|
+ if (nameDuplicationJudgment(param.getName(), null)) {
|
|
|
+ throw new BusinessException("已存在相同商品名称!");
|
|
|
+ }
|
|
|
//添加商品信息
|
|
|
KwpGoods goods = BeanUtils.copyProperties(param, KwpGoods.class);
|
|
|
AddressInfo address = param.getAddressInfo();
|
|
|
@@ -258,6 +264,9 @@ public class KwpGoodsService {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void update(UpdateGoodsParam param) {
|
|
|
+ if (nameDuplicationJudgment(param.getName(), param.getId())) {
|
|
|
+ throw new BusinessException("已存在相同商品名称!");
|
|
|
+ }
|
|
|
KwpGoods goods = getGoodsById(param.getId());
|
|
|
if (Objects.isNull(goods)) {
|
|
|
throw new BusinessException("当前商品不存在!");
|
|
|
@@ -968,4 +977,23 @@ public class KwpGoodsService {
|
|
|
ne(KwpGoods::getStatus, GoodsStatusEnum.SAVED.getCode());
|
|
|
return kwpGoodsMapper.selectCount(wrapper);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc: 商品名称判重
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-08-16 15:24
|
|
|
+ * @Param name:
|
|
|
+ * @Param id:
|
|
|
+ * @return: java.lang.Boolean
|
|
|
+ */
|
|
|
+ public Boolean nameDuplicationJudgment(String name, Long id) {
|
|
|
+ LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(KwpGoods::getSupplyEntId, LoginUserHolder.getEntId())
|
|
|
+ .eq(KwpGoods::getName, name).eq(KwpGoods::getDelFlag, Global.NO);
|
|
|
+ if (Objects.nonNull(id)) {
|
|
|
+ wrapper.ne(KwpGoods::getId, id);
|
|
|
+ }
|
|
|
+ Long count = kwpGoodsMapper.selectCount(wrapper);
|
|
|
+ return Objects.nonNull(count) && count > 0L;
|
|
|
+ }
|
|
|
}
|