|
|
@@ -61,7 +61,7 @@ public class GoodsWriteService {
|
|
|
insertImageRel(goodsId, intList(data.get("imagesIds")));
|
|
|
insertServiceRel(goodsId, intList(data.get("serviceIds")));
|
|
|
insertSpecRel(goodsId, castList(data.get("newSpecList")));
|
|
|
- insertSkuList(goodsId, intVal(data.get("spec_type"), 0), castList(data.get("newSkuList")));
|
|
|
+ insertSkuList(goodsId, intVal(data.get("specType"), 0), castList(data.get("newSkuList")));
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
@@ -80,59 +80,59 @@ public class GoodsWriteService {
|
|
|
goodsSpecRelMapper.delete(Wrappers.<GoodsSpecRel>lambdaQuery().eq(GoodsSpecRel::getGoodsId, goodsId));
|
|
|
insertSpecRel(goodsId, castList(data.get("newSpecList")));
|
|
|
goodsSkuMapper.delete(Wrappers.<GoodsSku>lambdaQuery().eq(GoodsSku::getGoodsId, goodsId));
|
|
|
- insertSkuList(goodsId, intVal(data.get("spec_type"), 0), castList(data.get("newSkuList")));
|
|
|
+ insertSkuList(goodsId, intVal(data.get("specType"), 0), castList(data.get("newSkuList")));
|
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------ 商品主体
|
|
|
|
|
|
private Goods buildGoods(Map<String, Object> data, Integer goodsId) {
|
|
|
int now = (int) (System.currentTimeMillis() / 1000);
|
|
|
- int specType = intVal(data.get("spec_type"), 0);
|
|
|
+ int specType = intVal(data.get("specType"), 0);
|
|
|
|
|
|
Goods g = new Goods();
|
|
|
if (goodsId != null) {
|
|
|
g.setGoodsId(goodsId);
|
|
|
}
|
|
|
- g.setGoodsType(intVal(data.get("goods_type"), 10));
|
|
|
- g.setGoodsName(str(data.get("goods_name"), ""));
|
|
|
- g.setGoodsNo(str(data.get("goods_no"), ""));
|
|
|
- g.setVideoId(intVal(data.get("video_id"), 0));
|
|
|
- g.setVideoCoverId(intVal(data.get("video_cover_id"), 0));
|
|
|
- g.setSellingPoint(str(data.get("selling_point"), ""));
|
|
|
+ g.setGoodsType(intVal(data.get("goodsType"), 10));
|
|
|
+ g.setGoodsName(str(data.get("goodsName"), ""));
|
|
|
+ g.setGoodsNo(str(data.get("goodsNo"), ""));
|
|
|
+ g.setVideoId(intVal(data.get("videoId"), 0));
|
|
|
+ g.setVideoCoverId(intVal(data.get("videoCoverId"), 0));
|
|
|
+ g.setSellingPoint(str(data.get("sellingPoint"), ""));
|
|
|
g.setSpecType(specType);
|
|
|
- g.setDeductStockType(intVal(data.get("deduct_stock_type"), 20));
|
|
|
- g.setIsRestrict(intVal(data.get("is_restrict"), 0));
|
|
|
- g.setRestrictTotal(intVal(data.get("restrict_total"), 0));
|
|
|
- g.setRestrictSingle(intVal(data.get("restrict_single"), 0));
|
|
|
+ g.setDeductStockType(intVal(data.get("deductStockType"), 20));
|
|
|
+ g.setIsRestrict(intVal(data.get("isRestrict"), 0));
|
|
|
+ g.setRestrictTotal(intVal(data.get("restrictTotal"), 0));
|
|
|
+ g.setRestrictSingle(intVal(data.get("restrictSingle"), 0));
|
|
|
g.setContent(str(data.get("content"), ""));
|
|
|
- g.setSalesInitial(intVal(data.get("sales_initial"), 0));
|
|
|
- g.setDeliveryId(intVal(data.get("delivery_id"), 0));
|
|
|
- g.setIsPointsGift(intVal(data.get("is_points_gift"), 1));
|
|
|
- g.setIsPointsDiscount(intVal(data.get("is_points_discount"), 1));
|
|
|
- g.setIsAlonePointsDiscount(intVal(data.get("is_alone_points_discount"), 0));
|
|
|
- g.setPointsDiscountConfig(str(data.get("points_discount_config"), ""));
|
|
|
- g.setIsIndDeliveryType(intVal(data.get("is_ind_delivery_type"), 0));
|
|
|
+ g.setSalesInitial(intVal(data.get("salesInitial"), 0));
|
|
|
+ g.setDeliveryId(intVal(data.get("deliveryId"), 0));
|
|
|
+ g.setIsPointsGift(intVal(data.get("isPointsGift"), 1));
|
|
|
+ g.setIsPointsDiscount(intVal(data.get("isPointsDiscount"), 1));
|
|
|
+ g.setIsAlonePointsDiscount(intVal(data.get("isAlonePointsDiscount"), 0));
|
|
|
+ g.setPointsDiscountConfig(str(data.get("pointsDiscountConfig"), ""));
|
|
|
+ g.setIsIndDeliveryType(intVal(data.get("isIndDeliveryType"), 0));
|
|
|
g.setStatus(intVal(data.get("status"), 10));
|
|
|
g.setSort(intVal(data.get("sort"), 0));
|
|
|
g.setIsDelete(0);
|
|
|
- g.setStoreId(intVal(data.get("store_id"), STORE_ID));
|
|
|
+ g.setStoreId(intVal(data.get("storeId"), STORE_ID));
|
|
|
g.setUpdateTime(now);
|
|
|
if (goodsId == null) {
|
|
|
g.setSalesActual(0);
|
|
|
g.setCreateTime(now);
|
|
|
}
|
|
|
// 配送方式:库内为 json 字符串
|
|
|
- List<Integer> deliveryType = intList(data.get("delivery_type"));
|
|
|
+ List<Integer> deliveryType = intList(data.get("deliveryType"));
|
|
|
g.setDeliveryType(deliveryType);
|
|
|
// 会员折扣
|
|
|
- int isEnableGrade = intVal(data.get("is_enable_grade"), 1);
|
|
|
- int isAloneGrade = intVal(data.get("is_alone_grade"), 0);
|
|
|
+ int isEnableGrade = intVal(data.get("isEnableGrade"), 1);
|
|
|
+ int isAloneGrade = intVal(data.get("isAloneGrade"), 0);
|
|
|
if (isEnableGrade == 0) {
|
|
|
isAloneGrade = 0;
|
|
|
}
|
|
|
g.setIsEnableGrade(isEnableGrade);
|
|
|
g.setIsAloneGrade(isAloneGrade);
|
|
|
- g.setAloneGradeEquity(buildAloneGradeEquity(data.get("alone_grade_equity"), isAloneGrade));
|
|
|
+ g.setAloneGradeEquity(buildAloneGradeEquity(data.get("aloneGradeEquity"), isAloneGrade));
|
|
|
|
|
|
// 价格与库存区间
|
|
|
if (specType == 20) {
|
|
|
@@ -145,13 +145,13 @@ public class GoodsWriteService {
|
|
|
g.setLinePriceMin(linePrices[0]);
|
|
|
g.setLinePriceMax(linePrices[1]);
|
|
|
} else if (specType == 10) {
|
|
|
- BigDecimal goodsPrice = decimal(data.get("goods_price"));
|
|
|
- BigDecimal linePrice = decimal(data.get("line_price"));
|
|
|
+ BigDecimal goodsPrice = decimal(data.get("goodsPrice"));
|
|
|
+ BigDecimal linePrice = decimal(data.get("linePrice"));
|
|
|
g.setGoodsPriceMin(goodsPrice);
|
|
|
g.setGoodsPriceMax(goodsPrice);
|
|
|
g.setLinePriceMin(linePrice);
|
|
|
g.setLinePriceMax(linePrice);
|
|
|
- g.setStockTotal(intVal(data.get("stock_num"), 0));
|
|
|
+ g.setStockTotal(intVal(data.get("stockNum"), 0));
|
|
|
}
|
|
|
|
|
|
// 规格与 sku 数据生成(写入 spec / spec_value 表并回填 ID)
|
|
|
@@ -164,10 +164,10 @@ public class GoodsWriteService {
|
|
|
data.put("newSkuList", getNewSkuList(newSpecList, skuList));
|
|
|
} else if (specType == 10) {
|
|
|
Map<String, Object> skuItem = new LinkedHashMap<>();
|
|
|
- skuItem.put("goods_price", data.get("goods_price"));
|
|
|
- skuItem.put("line_price", data.get("line_price"));
|
|
|
- skuItem.put("stock_num", data.get("stock_num"));
|
|
|
- skuItem.put("goods_weight", data.get("goods_weight"));
|
|
|
+ skuItem.put("goodsPrice", data.get("goodsPrice"));
|
|
|
+ skuItem.put("linePrice", data.get("linePrice"));
|
|
|
+ skuItem.put("stockNum", data.get("stockNum"));
|
|
|
+ skuItem.put("goodsWeight", data.get("goodsWeight"));
|
|
|
data.put("newSkuList", List.of(skuItem));
|
|
|
} else {
|
|
|
data.put("newSpecList", List.of());
|
|
|
@@ -195,7 +195,7 @@ public class GoodsWriteService {
|
|
|
private void checkSpecData(List<Map<String, Object>> specList) {
|
|
|
List<String> names = new ArrayList<>();
|
|
|
for (Map<String, Object> item : specList) {
|
|
|
- names.add(str(item.get("spec_name"), ""));
|
|
|
+ names.add(str(item.get("specName"), ""));
|
|
|
}
|
|
|
if (names.size() != names.stream().distinct().count()) {
|
|
|
throw new BizException("很抱歉,不能存在重复的规格组");
|
|
|
@@ -203,7 +203,7 @@ public class GoodsWriteService {
|
|
|
for (Map<String, Object> item : specList) {
|
|
|
List<String> values = new ArrayList<>();
|
|
|
for (Map<String, Object> value : castList(item.get("valueList"))) {
|
|
|
- values.add(str(value.get("spec_value"), ""));
|
|
|
+ values.add(str(value.get("specValue"), ""));
|
|
|
}
|
|
|
if (values.size() != values.stream().distinct().count()) {
|
|
|
throw new BizException("很抱歉,不能存在重复的规格值");
|
|
|
@@ -216,7 +216,7 @@ public class GoodsWriteService {
|
|
|
int now = (int) (System.currentTimeMillis() / 1000);
|
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
|
for (Map<String, Object> item : specList) {
|
|
|
- String specName = str(item.get("spec_name"), "");
|
|
|
+ String specName = str(item.get("specName"), "");
|
|
|
Spec spec = specMapper.selectOne(Wrappers.<Spec>lambdaQuery()
|
|
|
.eq(Spec::getSpecName, specName)
|
|
|
.eq(Spec::getStoreId, storeId)
|
|
|
@@ -229,7 +229,7 @@ public class GoodsWriteService {
|
|
|
specMapper.insert(spec);
|
|
|
}
|
|
|
Map<String, Object> group = new LinkedHashMap<>(item);
|
|
|
- group.put("spec_id", spec.getSpecId());
|
|
|
+ group.put("specId", spec.getSpecId());
|
|
|
group.put("valueList", getNewValueList(spec.getSpecId(), castList(item.get("valueList")), storeId));
|
|
|
result.add(group);
|
|
|
}
|
|
|
@@ -240,7 +240,7 @@ public class GoodsWriteService {
|
|
|
int now = (int) (System.currentTimeMillis() / 1000);
|
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
|
for (Map<String, Object> item : valueList) {
|
|
|
- String value = str(item.get("spec_value"), "");
|
|
|
+ String value = str(item.get("specValue"), "");
|
|
|
SpecValue specValue = specValueMapper.selectOne(Wrappers.<SpecValue>lambdaQuery()
|
|
|
.eq(SpecValue::getSpecId, specId)
|
|
|
.eq(SpecValue::getSpecValue, value)
|
|
|
@@ -255,7 +255,7 @@ public class GoodsWriteService {
|
|
|
specValueMapper.insert(specValue);
|
|
|
}
|
|
|
Map<String, Object> valueItem = new LinkedHashMap<>(item);
|
|
|
- valueItem.put("spec_value_id", specValue.getSpecValueId());
|
|
|
+ valueItem.put("specValueId", specValue.getSpecValueId());
|
|
|
result.add(valueItem);
|
|
|
}
|
|
|
return result;
|
|
|
@@ -282,14 +282,14 @@ public class GoodsWriteService {
|
|
|
if (value == null) {
|
|
|
continue;
|
|
|
}
|
|
|
- specValueIds.add(intVal(value.get("spec_value_id"), 0));
|
|
|
+ specValueIds.add(intVal(value.get("specValueId"), 0));
|
|
|
Map<String, Object> prop = new LinkedHashMap<>();
|
|
|
Map<String, Object> groupInfo = new LinkedHashMap<>();
|
|
|
- groupInfo.put("name", str(group.get("spec_name"), ""));
|
|
|
- groupInfo.put("id", intVal(group.get("spec_id"), 0));
|
|
|
+ groupInfo.put("name", str(group.get("specName"), ""));
|
|
|
+ groupInfo.put("id", intVal(group.get("specId"), 0));
|
|
|
Map<String, Object> valueInfo = new LinkedHashMap<>();
|
|
|
- valueInfo.put("name", str(value.get("spec_value"), ""));
|
|
|
- valueInfo.put("id", intVal(value.get("spec_value_id"), 0));
|
|
|
+ valueInfo.put("name", str(value.get("specValue"), ""));
|
|
|
+ valueInfo.put("id", intVal(value.get("specValueId"), 0));
|
|
|
prop.put("group", groupInfo);
|
|
|
prop.put("value", valueInfo);
|
|
|
goodsProps.add(prop);
|
|
|
@@ -297,7 +297,7 @@ public class GoodsWriteService {
|
|
|
Map<String, Object> item = new LinkedHashMap<>(sku);
|
|
|
item.put("specValueIds", specValueIds);
|
|
|
item.put("goodsProps", goodsProps);
|
|
|
- item.put("goods_sku_id", String.join("_", specValueIds.stream().map(String::valueOf).toList()));
|
|
|
+ item.put("goodsSkuId", String.join("_", specValueIds.stream().map(String::valueOf).toList()));
|
|
|
result.add(item);
|
|
|
}
|
|
|
return result;
|
|
|
@@ -383,12 +383,12 @@ public class GoodsWriteService {
|
|
|
private void insertSpecRel(int goodsId, List<Map<String, Object>> specList) {
|
|
|
int now = (int) (System.currentTimeMillis() / 1000);
|
|
|
for (Map<String, Object> item : specList) {
|
|
|
- int specId = intVal(item.get("spec_id"), 0);
|
|
|
+ int specId = intVal(item.get("specId"), 0);
|
|
|
for (Map<String, Object> value : castList(item.get("valueList"))) {
|
|
|
GoodsSpecRel rel = new GoodsSpecRel();
|
|
|
rel.setGoodsId(goodsId);
|
|
|
rel.setSpecId(specId);
|
|
|
- rel.setSpecValueId(intVal(value.get("spec_value_id"), 0));
|
|
|
+ rel.setSpecValueId(intVal(value.get("specValueId"), 0));
|
|
|
rel.setStoreId(STORE_ID);
|
|
|
rel.setCreateTime(now);
|
|
|
goodsSpecRelMapper.insert(rel);
|
|
|
@@ -405,10 +405,10 @@ public class GoodsWriteService {
|
|
|
sku.setGoodsSkuId("0");
|
|
|
sku.setImageId(0);
|
|
|
sku.setGoodsSkuNo("");
|
|
|
- sku.setGoodsPrice(decimal(item.get("goods_price")));
|
|
|
- sku.setLinePrice(decimal(item.get("line_price")));
|
|
|
- sku.setStockNum(intVal(item.get("stock_num"), 0));
|
|
|
- sku.setGoodsWeight(doubleVal(item.get("goods_weight")));
|
|
|
+ sku.setGoodsPrice(decimal(item.get("goodsPrice")));
|
|
|
+ sku.setLinePrice(decimal(item.get("linePrice")));
|
|
|
+ sku.setStockNum(intVal(item.get("stockNum"), 0));
|
|
|
+ sku.setGoodsWeight(doubleVal(item.get("goodsWeight")));
|
|
|
sku.setGoodsProps("");
|
|
|
sku.setSpecValueIds("");
|
|
|
sku.setStoreId(STORE_ID);
|
|
|
@@ -423,16 +423,16 @@ public class GoodsWriteService {
|
|
|
for (Map<String, Object> item : skuList) {
|
|
|
GoodsSku sku = new GoodsSku();
|
|
|
sku.setGoodsId(goodsId);
|
|
|
- sku.setGoodsSkuId(str(item.get("goods_sku_id"), "0"));
|
|
|
- sku.setImageId(intVal(item.get("image_id"), 0));
|
|
|
- sku.setGoodsSkuNo(str(item.get("goods_sku_no"), ""));
|
|
|
+ sku.setGoodsSkuId(str(item.get("goodsSkuId"), "0"));
|
|
|
+ sku.setImageId(intVal(item.get("imageId"), 0));
|
|
|
+ sku.setGoodsSkuNo(str(item.get("goodsSkuNo"), ""));
|
|
|
// 对齐 PHP:goods_price ?: 0.01,line_price ?: 0
|
|
|
- BigDecimal goodsPrice = decimal(item.get("goods_price"));
|
|
|
+ BigDecimal goodsPrice = decimal(item.get("goodsPrice"));
|
|
|
sku.setGoodsPrice(goodsPrice.compareTo(BigDecimal.ZERO) == 0
|
|
|
? new BigDecimal("0.01") : goodsPrice);
|
|
|
- sku.setLinePrice(decimal(item.get("line_price")));
|
|
|
- sku.setStockNum(intVal(item.get("stock_num"), 0));
|
|
|
- sku.setGoodsWeight(doubleVal(item.get("goods_weight")));
|
|
|
+ sku.setLinePrice(decimal(item.get("linePrice")));
|
|
|
+ sku.setStockNum(intVal(item.get("stockNum"), 0));
|
|
|
+ sku.setGoodsWeight(doubleVal(item.get("goodsWeight")));
|
|
|
sku.setGoodsProps(PhpStr.jsonEncode(item.get("goodsProps")));
|
|
|
sku.setSpecValueIds(PhpStr.jsonEncode(item.get("specValueIds")));
|
|
|
sku.setStoreId(STORE_ID);
|
|
|
@@ -445,7 +445,7 @@ public class GoodsWriteService {
|
|
|
// ------------------------------------------------------------------ 工具
|
|
|
|
|
|
private int stockTotal(List<Map<String, Object>> skuList) {
|
|
|
- return skuList.stream().mapToInt(item -> intVal(item.get("stock_num"), 0)).sum();
|
|
|
+ return skuList.stream().mapToInt(item -> intVal(item.get("stockNum"), 0)).sum();
|
|
|
}
|
|
|
|
|
|
/** 价格区间:过滤空/0 值后取 min/max,全空返回 [0, 0] */
|