|
@@ -33,7 +33,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
@Autowired
|
|
|
private GoodsAttributeDao goodsAttributeDao;
|
|
|
@Autowired
|
|
|
- private AttributeCategoryDao attributeCategoryDao;
|
|
|
+ private AttributeDao attributeDao;
|
|
|
@Autowired
|
|
|
private ProductDao productDao;
|
|
|
@Autowired
|
|
@@ -93,25 +93,30 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
builder.put("goodsUnit", "商品单位");
|
|
|
builder.put("primaryPicUrl", "商品主图");
|
|
|
builder.put("listPicUrl", "商品列表图");
|
|
|
- builder.put("goodsRate", "商品税率");
|
|
|
- builder.put("retailPrice", "零售价格");
|
|
|
builder.put("isHot", "热销");
|
|
|
|
|
|
- if (!Dict.orderBizType.item_11.getItem().equals(goods.getGoodsBizType())) {
|
|
|
- // 海关信息,普通货物可不添加
|
|
|
- builder.put("sku", "SKU");
|
|
|
- builder.put("prodBarcode", "产品编码");
|
|
|
- builder.put("brand", "产品品牌");
|
|
|
- builder.put("unitCode", "计量单位代码");
|
|
|
- builder.put("cusGoodsCode", "海关商品编码");
|
|
|
- builder.put("ciqProdModel", "国检规格型号");
|
|
|
- builder.put("oriCntCode", "原产国代码");
|
|
|
- builder.put("cusDeclEle", "海关申报要素");
|
|
|
- builder.put("cusRecCode", "海关备案编号");
|
|
|
- }
|
|
|
R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
|
|
|
if (Integer.valueOf(r.get("code").toString()) != 0) {
|
|
|
throw new RRException(r.get("msg").toString());
|
|
|
+ } else {
|
|
|
+ if (!Dict.orderBizType.item_11.getItem().equals(goods.getGoodsBizType())) {
|
|
|
+ // 海关信息,普通货物可不添加
|
|
|
+ builder.put("sku", "SKU");
|
|
|
+ builder.put("goodsRate", "商品税率");
|
|
|
+ builder.put("retailPrice", "零售价");
|
|
|
+ builder.put("prodBarcode", "产品编码");
|
|
|
+ builder.put("brand", "产品品牌");
|
|
|
+ builder.put("unitCode", "计量单位代码");
|
|
|
+ builder.put("cusGoodsCode", "海关商品编码");
|
|
|
+ builder.put("ciqProdModel", "国检规格型号");
|
|
|
+ builder.put("oriCntCode", "原产国代码");
|
|
|
+ builder.put("cusDeclEle", "海关申报要素");
|
|
|
+ builder.put("cusRecCode", "海关备案编号");
|
|
|
+ }
|
|
|
+ r = ValidatorUtil.isEmpty(builder.build(), valideDate);
|
|
|
+ if (Integer.valueOf(r.get("code").toString()) != 0) {
|
|
|
+ throw new RRException(r.get("msg").toString());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 商品轮播图
|
|
@@ -132,6 +137,10 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
}
|
|
|
|
|
|
// 添加商品
|
|
|
+ if (Dict.orderBizType.item_02.getItem().equals(goods.getGoodsBizType())
|
|
|
+ || Dict.orderBizType.item_10.getItem().equals(goods.getGoodsBizType())) {
|
|
|
+ goods.setIsHot(0);
|
|
|
+ }
|
|
|
goods.setAttributeCategory(categoryDao.queryObject(goods.getCategoryId()).getParentId());
|
|
|
goods.setAddTime(new Date());
|
|
|
goods.setIsDelete(0);
|
|
@@ -157,12 +166,12 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if (attributeEntityList != null && attributeEntityList.size() > 0) {
|
|
|
for (GoodsAttributeEntity item : attributeEntityList) {
|
|
|
if (item.getIsDelete() == 0) {
|
|
|
- if (item.getAttributeId() != null && StringUtils.isNotEmpty(item.getValue())) {
|
|
|
+ if (item.getId() == null && item.getAttributeId() != null && StringUtils.isNotEmpty(item.getValue())) {
|
|
|
item.setGoodsId(id);
|
|
|
goodsAttributeDao.save(item);
|
|
|
- } else if (item.getAttributeId() != null && StringUtils.isNullOrEmpty(item.getValue())) {
|
|
|
- throw new RRException("商品属性【" + attributeCategoryDao.queryObject(item.getAttributeId()).getName() + "】值不能为空!");
|
|
|
- } else if (item.getAttributeId() == null) {
|
|
|
+ } else if (item.getId() == null && item.getAttributeId() != null && StringUtils.isNullOrEmpty(item.getValue())) {
|
|
|
+ throw new RRException("商品属性【" + attributeDao.queryObject(item.getAttributeId()).getName() + "】值不能为空!");
|
|
|
+ } else if (item.getId() == null && item.getAttributeId() == null) {
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
@@ -206,25 +215,31 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
builder.put("goodsUnit", "商品单位");
|
|
|
builder.put("primaryPicUrl", "商品主图");
|
|
|
builder.put("listPicUrl", "商品列表图");
|
|
|
- builder.put("goodsRate", "商品税率");
|
|
|
builder.put("isHot", "热销");
|
|
|
|
|
|
- if (!Dict.orderBizType.item_11.getItem().equals(goods.getGoodsBizType())) {
|
|
|
- // 海关信息,普通货物可不添加
|
|
|
- builder.put("sku", "SKU");
|
|
|
- builder.put("retailPrice", "零售价");
|
|
|
- builder.put("prodBarcode", "产品编码");
|
|
|
- builder.put("brand", "产品品牌");
|
|
|
- builder.put("unitCode", "计量单位代码");
|
|
|
- builder.put("cusGoodsCode", "海关商品编码");
|
|
|
- builder.put("ciqProdModel", "国检规格型号");
|
|
|
- builder.put("oriCntCode", "原产国代码");
|
|
|
- builder.put("cusDeclEle", "海关申报要素");
|
|
|
- builder.put("cusRecCode", "海关备案编号");
|
|
|
- }
|
|
|
+
|
|
|
R r = ValidatorUtil.isEmpty(builder.build(), valideDate);
|
|
|
if (Integer.valueOf(r.get("code").toString()) != 0) {
|
|
|
throw new RRException(r.get("msg").toString());
|
|
|
+ } else {
|
|
|
+ if (!Dict.orderBizType.item_11.getItem().equals(goods.getGoodsBizType())) {
|
|
|
+ // 海关信息,普通货物可不添加
|
|
|
+ builder.put("sku", "SKU");
|
|
|
+ builder.put("goodsRate", "商品税率");
|
|
|
+ builder.put("retailPrice", "零售价");
|
|
|
+ builder.put("prodBarcode", "产品编码");
|
|
|
+ builder.put("brand", "产品品牌");
|
|
|
+ builder.put("unitCode", "计量单位代码");
|
|
|
+ builder.put("cusGoodsCode", "海关商品编码");
|
|
|
+ builder.put("ciqProdModel", "国检规格型号");
|
|
|
+ builder.put("oriCntCode", "原产国代码");
|
|
|
+ builder.put("cusDeclEle", "海关申报要素");
|
|
|
+ builder.put("cusRecCode", "海关备案编号");
|
|
|
+ }
|
|
|
+ r = ValidatorUtil.isEmpty(builder.build(), valideDate);
|
|
|
+ if (Integer.valueOf(r.get("code").toString()) != 0) {
|
|
|
+ throw new RRException(r.get("msg").toString());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 商品轮播图
|
|
@@ -246,6 +261,10 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
}
|
|
|
|
|
|
// 修改商品
|
|
|
+ if (Dict.orderBizType.item_02.getItem().equals(goods.getGoodsBizType())
|
|
|
+ || Dict.orderBizType.item_10.getItem().equals(goods.getGoodsBizType())) {
|
|
|
+ goods.setIsHot(0);
|
|
|
+ }
|
|
|
goods.setAttributeCategory(categoryDao.queryObject(goods.getCategoryId()).getParentId());
|
|
|
goods.setIsDelete(0);
|
|
|
goods.setIsNew(0);
|
|
@@ -280,14 +299,14 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
if (attributeEntityList != null && attributeEntityList.size() > 0) {
|
|
|
for (GoodsAttributeEntity item : attributeEntityList) {
|
|
|
if (item.getIsDelete() == 0) {
|
|
|
- if (item.getAttributeId() != null && StringUtils.isNotEmpty(item.getValue())) {
|
|
|
+ if (item.getId() != null) {
|
|
|
+ goodsAttributeDao.update(item);
|
|
|
+ } else if (item.getId() == null && item.getAttributeId() != null && StringUtils.isNotEmpty(item.getValue())) {
|
|
|
item.setGoodsId(goods.getId());
|
|
|
goodsAttributeDao.save(item);
|
|
|
- } else if (item.getAttributeId() != null && StringUtils.isNullOrEmpty(item.getValue())) {
|
|
|
- throw new RRException("商品属性【" + attributeCategoryDao.queryObject(item.getAttributeId()).getName() + "】值不能为空!");
|
|
|
- } else if (item.getId() != null) {
|
|
|
- goodsAttributeDao.update(item);
|
|
|
- } else if (item.getAttributeId() == null) {
|
|
|
+ } else if (item.getId() == null && item.getAttributeId() != null && StringUtils.isNullOrEmpty(item.getValue())) {
|
|
|
+ throw new RRException("商品属性【" + attributeDao.queryObject(item.getAttributeId()).getName() + "】值不能为空!");
|
|
|
+ } else if (item.getId() == null && item.getAttributeId() == null) {
|
|
|
continue;
|
|
|
}
|
|
|
} else if (item.getIsDelete() == 1) {
|