|
|
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.sckw.core.common.enums.enums.DictEnum;
|
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
import com.sckw.core.exception.BusinessException;
|
|
|
+import com.sckw.core.exception.CustomPromptException;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
|
import com.sckw.core.model.page.PageResult;
|
|
|
import com.sckw.core.model.vo.TableBottom;
|
|
|
@@ -16,6 +17,7 @@ import com.sckw.core.utils.BeanUtils;
|
|
|
import com.sckw.core.utils.CollectionUtils;
|
|
|
import com.sckw.core.utils.NumberUtils;
|
|
|
import com.sckw.core.utils.StringUtils;
|
|
|
+import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.excel.utils.DateUtil;
|
|
|
import com.sckw.payment.api.dubbo.PayCenterDubboService;
|
|
|
@@ -273,7 +275,10 @@ public class KwpGoodsService {
|
|
|
}
|
|
|
if (Objects.equals(goods.getStatus(), GoodsStatusEnum.PUT_ON_SHELVES.getCode()) ||
|
|
|
Objects.equals(goods.getStatus(), GoodsStatusEnum.TAKE_OFF_SHELVES.getCode())) {
|
|
|
- judgeParameters(param);
|
|
|
+ String msg = judgeParameters(param);
|
|
|
+ if (StringUtils.isNotBlank(msg)) {
|
|
|
+ throw new BusinessException(msg);
|
|
|
+ }
|
|
|
if (Objects.equals(goods.getStatus(), GoodsStatusEnum.PUT_ON_SHELVES.getCode()) &&
|
|
|
goods.getAmount().compareTo(param.getAmount()) != 0) {
|
|
|
throw new BusinessException("上架商品不可修改库存数量!");
|
|
|
@@ -349,103 +354,104 @@ public class KwpGoodsService {
|
|
|
* @Param param:
|
|
|
* @return: void
|
|
|
*/
|
|
|
- private void judgeParameters(UpdateGoodsParam param) {
|
|
|
+ private String judgeParameters(UpdateGoodsParam param) {
|
|
|
if (StringUtils.isBlank(param.getName())) {
|
|
|
- throw new BusinessException("商品名称不能为空!");
|
|
|
+ return "商品名称不能为空!";
|
|
|
}
|
|
|
if (StringUtils.isBlank(param.getGoodsType())) {
|
|
|
- throw new BusinessException("商品类型不能为空!");
|
|
|
+ return "商品类型不能为空!";
|
|
|
}
|
|
|
if (StringUtils.isBlank(param.getUnit())) {
|
|
|
- throw new BusinessException("计量单位不能为空!");
|
|
|
+ return "计量单位不能为空!";
|
|
|
}
|
|
|
if (StringUtils.isBlank(param.getSpec())) {
|
|
|
- throw new BusinessException("规格尺寸不能为空!");
|
|
|
+ return "规格尺寸不能为空!";
|
|
|
}
|
|
|
if (Objects.isNull(param.getAmount())) {
|
|
|
- throw new BusinessException("库存数量不能为空!");
|
|
|
+ return "库存数量不能为空!";
|
|
|
}
|
|
|
if (StringUtils.isBlank(param.getTaxRate())) {
|
|
|
- throw new BusinessException("发票税率不能为空!");
|
|
|
+ return "发票税率不能为空!";
|
|
|
}
|
|
|
if (Objects.isNull(param.getPrepaidLimit())) {
|
|
|
- throw new BusinessException("是否设置预付限额不能为空!");
|
|
|
+ return "是否设置预付限额不能为空!";
|
|
|
}
|
|
|
if (Objects.equals(param.getPrepaidLimit(), 1) && Objects.isNull(param.getAdvancePrice())) {
|
|
|
- throw new BusinessException("设置预付限额时,预付款最低限额不能为空!");
|
|
|
+ return "设置预付限额时,预付款最低限额不能为空!";
|
|
|
}
|
|
|
|
|
|
List<GoodsAttributes> attributes = param.getAttributes();
|
|
|
if (CollectionUtils.isNotEmpty(attributes)) {
|
|
|
- attributes.forEach(e -> {
|
|
|
+ for (GoodsAttributes e : attributes) {
|
|
|
if (StringUtils.isBlank(e.getName()) || StringUtils.isBlank(e.getVal())) {
|
|
|
- throw new BusinessException("参数名称或参数值不能为空且!");
|
|
|
+ return "参数名称或参数值不能为空!";
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
List<GoodsImages> images = param.getImages();
|
|
|
if (CollectionUtils.isNotEmpty(images)) {
|
|
|
- images.forEach(e -> {
|
|
|
+ for (GoodsImages e : images) {
|
|
|
if (StringUtils.isBlank(e.getImage())) {
|
|
|
- throw new BusinessException("商品图片地址不能为空!");
|
|
|
+ return "商品图片地址不能为空!";
|
|
|
}
|
|
|
if (Objects.isNull(e.getSort())) {
|
|
|
- throw new BusinessException("商品图片排序不能为空!");
|
|
|
+ return "商品图片排序不能为空!";
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
List<GoodsPriceRanges> priceRanges = param.getPriceRanges();
|
|
|
if (CollectionUtils.isEmpty(priceRanges)) {
|
|
|
- throw new BusinessException("价格梯度不能为空!");
|
|
|
+ return "价格梯度不能为空!";
|
|
|
}
|
|
|
- priceRanges.forEach(e -> {
|
|
|
+ for (GoodsPriceRanges e : priceRanges) {
|
|
|
if (Objects.isNull(e.getStartAmount()) || e.getStartAmount().compareTo(BigDecimal.ZERO) < 0) {
|
|
|
- throw new BusinessException("起售量最小为零!");
|
|
|
+ return "起售量不能为空且最小为零!";
|
|
|
}
|
|
|
if (Objects.isNull(e.getEndAmount()) || e.getEndAmount().compareTo(new BigDecimal("-1.00")) < 0) {
|
|
|
- throw new BusinessException("上限售量最小为零!");
|
|
|
+ return "上限售量不能为空且最小为零!";
|
|
|
}
|
|
|
if (Objects.isNull(e.getPrice()) || e.getStartAmount().compareTo(BigDecimal.ZERO) < 0) {
|
|
|
- throw new BusinessException("含税价最低为零!");
|
|
|
+ return "含税价不能为空且最低为零!";
|
|
|
}
|
|
|
if (Objects.isNull(e.getSort())) {
|
|
|
- throw new BusinessException("价格梯度顺序不能为空!");
|
|
|
+ return "价格梯度顺序不能为空!";
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
AddressInfo address = param.getAddressInfo();
|
|
|
if (Objects.isNull(address)) {
|
|
|
- throw new BusinessException("地址信息不能为空!");
|
|
|
+ return "地址信息不能为空!";
|
|
|
}
|
|
|
if (StringUtils.isBlank(address.getName()) || address.getName().length() > 50) {
|
|
|
- throw new BusinessException("地址名称不能为空且最长50字符!");
|
|
|
+ return "地址名称不能为空且最长50字符!";
|
|
|
}
|
|
|
if (StringUtils.isBlank(address.getType())) {
|
|
|
- throw new BusinessException("地址类型不能为空!");
|
|
|
+ return "地址类型不能为空!";
|
|
|
}
|
|
|
if (StringUtils.isBlank(address.getContacts())) {
|
|
|
- throw new BusinessException("联系人不能为空!");
|
|
|
+ return "联系人不能为空!";
|
|
|
}
|
|
|
if (StringUtils.isBlank(address.getPhone())) {
|
|
|
- throw new BusinessException("联系电话不能为空!");
|
|
|
+ return "联系电话不能为空!";
|
|
|
}
|
|
|
if (Objects.isNull(address.getCityCode())) {
|
|
|
- throw new BusinessException("所在地区code不能为空!");
|
|
|
+ return "所在地区code不能为空!";
|
|
|
}
|
|
|
if (StringUtils.isBlank(address.getCityName()) || address.getCityName().length() > 40) {
|
|
|
- throw new BusinessException("所属区域名称不能为空最长40字符!");
|
|
|
+ return "所属区域名称不能为空最长40字符!";
|
|
|
}
|
|
|
if (Objects.isNull(address.getLat())) {
|
|
|
- throw new BusinessException("纬度不能为空!");
|
|
|
+ return "纬度不能为空!";
|
|
|
}
|
|
|
if (Objects.isNull(address.getLng())) {
|
|
|
- throw new BusinessException("经度不能为空!");
|
|
|
+ return "经度不能为空!";
|
|
|
}
|
|
|
if (Objects.isNull(param.getSupplyEntId())) {
|
|
|
- throw new BusinessException("供应企业不能为空!");
|
|
|
+ return "供应企业不能为空!";
|
|
|
}
|
|
|
if (Objects.isNull(param.getManager())) {
|
|
|
- throw new BusinessException("客户经理不能为空!");
|
|
|
+ return "客户经理不能为空!";
|
|
|
}
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -656,7 +662,10 @@ public class KwpGoodsService {
|
|
|
updateParam.setPriceRanges(BeanUtils.copyToList(kwpGoodsPriceRangeService.getByGoodsId(id), GoodsPriceRanges.class));
|
|
|
updateParam.setImages(BeanUtils.copyToList(kwpGoodsImageService.getByGoodsId(id), GoodsImages.class));
|
|
|
updateParam.setAddressInfo(BeanUtils.copyProperties(kwpGoodsAddressService.getByGoodsId(id), AddressInfo.class));
|
|
|
- judgeParameters(updateParam);
|
|
|
+ String msg = judgeParameters(updateParam);
|
|
|
+ if (StringUtils.isNotBlank(msg)) {
|
|
|
+ throw new CustomPromptException(HttpStatus.GOODS_PUT_ON_SHELVES_FAIL_CODE, msg);
|
|
|
+ }
|
|
|
}
|
|
|
LambdaUpdateWrapper<KwpGoods> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.set(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode()).set(KwpGoods::getAddedTime, new Date()).eq(KwpGoods::getId, id);
|