!226 增加商品sku参数空值判断

Merge pull request !226 from OceansDeep/feature/pg
This commit is contained in:
OceansDeep 2022-08-19 09:47:26 +00:00 committed by Gitee
commit f5f99efff6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 7 additions and 0 deletions

View File

@ -79,6 +79,7 @@ public enum ResultCode {
MUST_HAVE_SALES_MODEL(11022, "销售模式为批发时必须要有批发规则!"),
HAVE_INVALID_SALES_MODEL(11023, "批发规则存在小于等于0的无效数据"),
MUST_HAVE_GOODS_SKU_VALUE(11024, "规格值不能为空!"),
GOODS_PARAMS_ERROR(11013, "商品参数错误,刷新后重试"),
PHYSICAL_GOODS_NEED_TEMP(11014, "实物商品需选择配送模板"),

View File

@ -194,6 +194,12 @@ public class Goods extends BaseEntity {
if (!sku.containsKey("quantity") || StringUtil.isEmpty(sku.get("quantity").toString()) || Convert.toInt(sku.get("quantity").toString()) < 0) {
throw new ServiceException(ResultCode.GOODS_SKU_QUANTITY_ERROR);
}
sku.values().forEach(i -> {
if (CharSequenceUtil.isBlank(i.toString())) {
throw new ServiceException(ResultCode.MUST_HAVE_GOODS_SKU_VALUE);
}
});
}
}