思迅商品同步
This commit is contained in:
parent
0c8d281f73
commit
0fd7d8ca8d
@ -682,12 +682,13 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
*/
|
||||
public Pair<Boolean, String> saveProduct(ShopProductBase shopProductBase, ShopProductIndex shopProductIndex, ShopProductData shopProductData, ShopProductDetail shopProductDetail, ShopProductInfo shopProductInfo, List<ShopProductItem> shopProductItemList, List<ShopProductImage> shopProductImageList, ShopProductValidPeriod shopProductValidPeriod, List<ShopProductAssistIndex> shopProductAssistIndexList) {
|
||||
Integer store_id = shopProductBase.getStore_id();
|
||||
ShopStoreBase storeBase = null;
|
||||
if (store_id == null) {
|
||||
return Pair.of(false, I18nUtil._("缺少店铺ID!"));
|
||||
}
|
||||
|
||||
storeBase = shopStoreBaseService.get(store_id);
|
||||
ShopStoreBase storeBase = shopStoreBaseService.get(store_id);
|
||||
if (storeBase == null) return Pair.of(false, I18nUtil._("缺少店铺信息!"));
|
||||
|
||||
Integer store_type = storeBase.getStore_type();
|
||||
// 判断是否为供应商店铺
|
||||
if (store_type == 2) {
|
||||
@ -712,7 +713,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
|
||||
boolean isUpdate = false;
|
||||
String product_image_old = "";
|
||||
if (productId == null && storeBase != null) {
|
||||
if (productId == null) {
|
||||
// 生成商品ID:product_id
|
||||
productId = shopNumberSeqService.createNextNo("product_id");
|
||||
if (null == productId) {
|
||||
@ -802,7 +803,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
BigDecimal max_item_market_price = shopProductItemList.stream().map(ShopProductItem::getItem_market_price).max(BigDecimal::compareTo).get();
|
||||
BigDecimal product_market_price = NumberUtil.max(max_item_unit_price, max_item_market_price);
|
||||
shopProductBase.setProduct_market_price(product_market_price);
|
||||
// 保存商品基本信息
|
||||
// 注:保存商品基本信息
|
||||
if (!saveOrUpdate(shopProductBase)) {
|
||||
return Pair.of(false, I18nUtil._("保存 productBase 商品信息出错!"));
|
||||
}
|
||||
@ -812,22 +813,21 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
List<String> assistItemList = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(shopProductAssistIndexList)) {
|
||||
for (ShopProductAssistIndex assistIndex : shopProductAssistIndexList) {
|
||||
if (StringUtils.isNotBlank(assistIndex.getAssist_item_id())) {
|
||||
assistItemList.add(assistIndex.getAssist_item_id());
|
||||
String product_assist_index_id = productId + "-" + assistIndex.getAssist_id();
|
||||
assistIndex.setProduct_assist_index_id(product_assist_index_id);
|
||||
assistIndex.setProduct_id(productId);
|
||||
if (StringUtils.isBlank(assistIndex.getAssist_item_id())) continue;
|
||||
|
||||
if (!assistIndexService.saveOrUpdate(assistIndex)) {
|
||||
return Pair.of(false, I18nUtil._("保存 ShopProductAssistIndex 商品附加属性出错!"));
|
||||
}
|
||||
}
|
||||
assistItemList.add(assistIndex.getAssist_item_id());
|
||||
String product_assist_index_id = productId + "-" + assistIndex.getAssist_id();
|
||||
assistIndex.setProduct_assist_index_id(product_assist_index_id);
|
||||
assistIndex.setProduct_id(productId);
|
||||
|
||||
if (!assistIndexService.saveOrUpdate(assistIndex))
|
||||
return Pair.of(false, I18nUtil._("保存 ShopProductAssistIndex 商品附加属性出错!"));
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(assistItemList)) {
|
||||
// 商品es索引 shopProductIndex
|
||||
if (CollectionUtil.isNotEmpty(assistItemList))
|
||||
shopProductIndex.setProduct_assist_data(StrUtil.join(",", assistItemList));
|
||||
}
|
||||
|
||||
shopProductIndex.setProduct_id(productId);
|
||||
shopProductIndex.setProduct_unit_price(item_unit_price);
|
||||
@ -840,9 +840,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
shopProductIndex.setProduct_verify_id(shopProductBase.getProduct_verify_id());
|
||||
|
||||
// 判断店铺是否开启
|
||||
if (storeBase == null) {
|
||||
storeBase = shopStoreBaseService.get(shopProductBase.getStore_id());
|
||||
}
|
||||
shopProductIndex.setStore_is_open(storeBase.getStore_is_open());
|
||||
shopProductIndex.setStore_is_selfsupport(storeBase.getStore_is_selfsupport());
|
||||
shopProductIndex.setStore_type(storeBase.getStore_type());
|
||||
@ -890,23 +887,27 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
for (ShopProductImage image_row : shopProductImageList) {
|
||||
Long color_id = image_row.getColor_id();
|
||||
Long _color_id = product_image_row.getColor_id();
|
||||
if (ObjectUtil.equal(color_id, _color_id)) {
|
||||
Long product_image_id = product_image_row.getProduct_image_id();
|
||||
product_image_id_now_row.add(product_image_id);
|
||||
image_row.setProduct_image_id(product_image_id);
|
||||
if (!ObjectUtil.equal(color_id, _color_id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//图片相同,不做处理
|
||||
if (!product_image_row.getItem_image_default().equals(image_row.getItem_image_default())) {
|
||||
//图片不同,先删除旧的, 添加新的。
|
||||
if (CheckUtil.isNotEmpty(product_image_row.getItem_image_default())) {
|
||||
del_baidu_image_row.add(product_image_row.getItem_image_default());
|
||||
}
|
||||
Long product_image_id = product_image_row.getProduct_image_id();
|
||||
product_image_id_now_row.add(product_image_id);
|
||||
image_row.setProduct_image_id(product_image_id);
|
||||
|
||||
//添加新的
|
||||
if (CheckUtil.isNotEmpty(image_row.getItem_image_default())) {
|
||||
add_baidu_image_row.add(product_image_row.getItem_image_default());
|
||||
}
|
||||
}
|
||||
//图片相同,不做处理
|
||||
if (product_image_row.getItem_image_default().equals(image_row.getItem_image_default())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//图片不同,先删除旧的, 添加新的。
|
||||
if (CheckUtil.isNotEmpty(product_image_row.getItem_image_default())) {
|
||||
del_baidu_image_row.add(product_image_row.getItem_image_default());
|
||||
}
|
||||
|
||||
//添加新的
|
||||
if (CheckUtil.isNotEmpty(image_row.getItem_image_default())) {
|
||||
add_baidu_image_row.add(product_image_row.getItem_image_default());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1027,6 +1028,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
List<Object> sku_uniqid_list = Arrays.asList(item_id, item_unit_price, "", item_enable);
|
||||
product_uniqid.put(sku_uniqid, sku_uniqid_list);
|
||||
|
||||
// 教育课程类订单
|
||||
if (kind_id == StateCode.PRODUCT_KIND_EDU) {
|
||||
Optional<ShopProductImage> imageOptional = shopProductImageList.stream().filter(s -> ObjectUtil.equal(s.getColor_id(), item_row.getColor_id())).findFirst();
|
||||
ShopProductImage image = imageOptional.orElseGet(ShopProductImage::new);
|
||||
@ -1058,20 +1060,20 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
return Pair.of(false, I18nUtil._("删除废弃sku失败!"));
|
||||
}
|
||||
}
|
||||
//start 清理sku相关数据
|
||||
//end 清理sku相关数据
|
||||
|
||||
// info
|
||||
// 注:shopProductInfo
|
||||
shopProductInfo.setProduct_id(productId);
|
||||
shopProductInfo.setProduct_uniqid(JSONUtil.toJsonStr(product_uniqid));
|
||||
if (!shopProductInfoService.saveOrUpdate(shopProductInfo)) {
|
||||
return Pair.of(false, I18nUtil._("保存 shopProductInfo 出错!"));
|
||||
}
|
||||
|
||||
// virtual
|
||||
// shopProductValidPeriod 虚拟商品
|
||||
if (shopProductValidPeriod != null) {
|
||||
shopProductValidPeriod.setProduct_id(productId);
|
||||
Integer product_valid_type = shopProductValidPeriod.getProduct_valid_type();
|
||||
if(product_valid_type==null){
|
||||
if (product_valid_type == null) {
|
||||
product_valid_type = 1001;
|
||||
}
|
||||
shopProductValidPeriod.setProduct_valid_type(product_valid_type);// 默认到店服务 add 2025-01-08 避免出错
|
||||
@ -1080,16 +1082,15 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
}
|
||||
}
|
||||
|
||||
//商品统计初始化
|
||||
// 商品统计 shopProductAnalytics 初始化
|
||||
if (CheckUtil.isNotEmpty(shopProductBase.getProduct_add_time())) {
|
||||
ShopProductAnalytics shopProductAnalytics = new ShopProductAnalytics();
|
||||
shopProductAnalytics.setProduct_id(shopProductIndex.getProduct_id());
|
||||
shopProductAnalytics.setProduct_click(0); // 默认0 add 2025-01-08 避免出错
|
||||
|
||||
shopProductAnalyticsService.saveOrUpdate(shopProductAnalytics);
|
||||
}
|
||||
|
||||
//店铺统计
|
||||
//店铺统计商品数量
|
||||
if (!shopStoreAnalyticsService.saveProductAnalyticsNum(store_id)) {
|
||||
return Pair.of(false, I18nUtil._("保存 shopStoreAnalytics 出错!"));
|
||||
}
|
||||
@ -1100,7 +1101,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
|
||||
ShopStoreActivityItem shopStoreActivityItem = new ShopStoreActivityItem();
|
||||
shopStoreActivityItem.setCategory_id(shopProductIndex.getCategory_id());
|
||||
|
||||
boolean edit = shopStoreActivityItemService.edit(shopStoreActivityItem, objectQueryWrapper);
|
||||
|
||||
// 是否启用es
|
||||
@ -1124,7 +1124,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
}
|
||||
|
||||
if (CheckUtil.isNotEmpty(product_image_old)) {
|
||||
contSign = BaiduAi.removeProductImg(product_image_old, "");
|
||||
BaiduAi.removeProductImg(product_image_old, contSign);
|
||||
}
|
||||
|
||||
if (CheckUtil.isNotEmpty(product_image_new)) {
|
||||
@ -1146,7 +1146,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
||||
mqMessageService.sendBatchMqMsg(mqMessageVos);
|
||||
}
|
||||
|
||||
return Pair.of(true, I18nUtil._("保存处理成功!"));
|
||||
return Pair.of(true, I18nUtil._("保存成功!"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user