虚拟商品重量字段兼容问题处理

This commit is contained in:
Chopper 2021-06-22 15:08:06 +08:00
parent 8f93ac4d49
commit 19154aa2b8
2 changed files with 12 additions and 2 deletions

View File

@ -240,9 +240,12 @@ public class Goods extends BaseEntity {
if (StringUtil.isEmpty(sku.get("cost").toString()) || Integer.parseInt( sku.get("cost").toString()) <= 0) { if (StringUtil.isEmpty(sku.get("cost").toString()) || Integer.parseInt( sku.get("cost").toString()) <= 0) {
throw new ServiceException(ResultCode.GOODS_SKU_COST_ERROR); throw new ServiceException(ResultCode.GOODS_SKU_COST_ERROR);
} }
if (StringUtil.isEmpty(sku.get("weight").toString()) || Integer.parseInt( sku.get("weight").toString()) < 0) { //虚拟商品没有重量字段
if(sku.containsKey("weight")) {
if (StringUtil.isEmpty(sku.get("weight").toString()) || Integer.parseInt(sku.get("weight").toString()) < 0) {
throw new ServiceException(ResultCode.GOODS_SKU_WEIGHT_ERROR); throw new ServiceException(ResultCode.GOODS_SKU_WEIGHT_ERROR);
} }
}
if (StringUtil.isEmpty(sku.get("quantity").toString()) || Integer.parseInt( sku.get("quantity").toString()) < 0) { if (StringUtil.isEmpty(sku.get("quantity").toString()) || Integer.parseInt( sku.get("quantity").toString()) < 0) {
throw new ServiceException(ResultCode.GOODS_SKU_QUANTITY_ERROR); throw new ServiceException(ResultCode.GOODS_SKU_QUANTITY_ERROR);
} }

View File

@ -164,6 +164,13 @@ public class GoodsSku extends BaseEntity {
@ApiModelProperty(value = "商品类型", required = true) @ApiModelProperty(value = "商品类型", required = true)
private String goodsType; private String goodsType;
public Double getWeight() {
if (weight == null) {
return 0d;
}
return weight;
}
@Override @Override
public Date getUpdateTime() { public Date getUpdateTime() {
if (super.getUpdateTime() == null) { if (super.getUpdateTime() == null) {