新增商品规格名称匹配
This commit is contained in:
parent
6f9565331a
commit
1c5b4648f5
@ -5606,11 +5606,11 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
|
|
||||||
//计算规格
|
//计算规格
|
||||||
if (CollUtil.isNotEmpty(newProducts)) {
|
if (CollUtil.isNotEmpty(newProducts)) {
|
||||||
productMappingService.computeProductMapping(newProducts, newProducts.get(0).getStore_id(), false,DicEnum.YESORNO_0.getCode());
|
productMappingService.computeProductMapping(newProducts, newProducts.get(0).getStore_id(), false);
|
||||||
}
|
}
|
||||||
if (CollUtil.isNotEmpty(updateProducts)) {//如果时自动优先,则按平台规则切割商品
|
if (CollUtil.isNotEmpty(updateProducts)) {//如果时自动优先,则按平台规则切割商品
|
||||||
if (DicEnum.PRIORITY_MODE_2.getCode().equals(priorityMode)) {
|
if (DicEnum.PRIORITY_MODE_2.getCode().equals(priorityMode)) {
|
||||||
productMappingService.computeProductMapping(updateProducts, updateProducts.get(0).getStore_id(), true,DicEnum.YESORNO_0.getCode());
|
productMappingService.computeProductMapping(updateProducts, updateProducts.get(0).getStore_id(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Pair.of(true, String.format("处理成功,新增%d条,更新%d条",
|
return Pair.of(true, String.format("处理成功,新增%d条,更新%d条",
|
||||||
|
|||||||
@ -20,9 +20,8 @@ public interface ProductMappingService extends IBaseService<ProductMapping> {
|
|||||||
* @param shopProductBaseList
|
* @param shopProductBaseList
|
||||||
* @param storeId
|
* @param storeId
|
||||||
* @param isUpdate
|
* @param isUpdate
|
||||||
* @param isFilter 1:只更新未匹配商品规格,0:更新全部商品规格
|
|
||||||
*/
|
*/
|
||||||
void computeProductMapping(List<ShopProductBase> shopProductBaseList,Integer storeId, boolean isUpdate,String isFilter);
|
void computeProductMapping(List<ShopProductBase> shopProductBaseList,Integer storeId, boolean isUpdate);
|
||||||
|
|
||||||
Map getProductMapping(Integer storeId);
|
Map getProductMapping(Integer storeId);
|
||||||
|
|
||||||
|
|||||||
@ -123,13 +123,11 @@ public class ProductMappingServiceImpl extends BaseServiceImpl<ProductMappingMap
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void computeProductMapping(List<ShopProductBase> shopProductBaseList,Integer storeId,boolean isUpdate,String isFilter) {
|
public void computeProductMapping(List<ShopProductBase> shopProductBaseList,Integer storeId,boolean isUpdate) {
|
||||||
if(DicEnum.YESORNO_1.getCode().equals(isFilter)){
|
shopProductBaseList= shopProductBaseList.stream().filter(base ->StateCode.PRODUCT_STATE_OFF_THE_SHELF_UNCHECK==(base.getProduct_state_id())).collect(Collectors.toList());
|
||||||
shopProductBaseList= shopProductBaseList.stream().filter(base ->StateCode.PRODUCT_STATE_OFF_THE_SHELF_UNCHECK==(base.getProduct_state_id())).collect(Collectors.toList());
|
if (CollUtil.isEmpty(shopProductBaseList)) {
|
||||||
if (CollUtil.isEmpty(shopProductBaseList)) {
|
log.info("没有规格数据要处理");
|
||||||
log.info("没有规格数据要处理");
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Map shopProductSpecItemMap = shopProductSpecItemService.getExistItem(storeId);
|
Map shopProductSpecItemMap = shopProductSpecItemService.getExistItem(storeId);
|
||||||
Map productMappingMap = this.getProductMapping(storeId);
|
Map productMappingMap = this.getProductMapping(storeId);
|
||||||
@ -339,22 +337,19 @@ public class ProductMappingServiceImpl extends BaseServiceImpl<ProductMappingMap
|
|||||||
*/
|
*/
|
||||||
private ShopProductSpecItem processShopProductSpecItem(ShopProductBase base,Integer categoryId,Map shopProductSpecItemMap,Map ShopBaseProductSpecMap, Map productMappingMap,Integer specItemId){
|
private ShopProductSpecItem processShopProductSpecItem(ShopProductBase base,Integer categoryId,Map shopProductSpecItemMap,Map ShopBaseProductSpecMap, Map productMappingMap,Integer specItemId){
|
||||||
String productName=base.getProduct_name();
|
String productName=base.getProduct_name();
|
||||||
if(null!=productMappingMap.get(productName)||StringUtils.isNotEmpty(base.getSpecItem())){
|
if(null!=productMappingMap.get(productName)){
|
||||||
ShopBaseProductSpec shopBaseProductSpec= (ShopBaseProductSpec) ShopBaseProductSpecMap.get(categoryId);
|
ShopBaseProductSpec shopBaseProductSpec= (ShopBaseProductSpec) ShopBaseProductSpecMap.get(categoryId);
|
||||||
if(null==shopBaseProductSpec){
|
if(null==shopBaseProductSpec){
|
||||||
shopBaseProductSpec= (ShopBaseProductSpec) ShopBaseProductSpecMap.get(String.valueOf(categoryId));
|
shopBaseProductSpec= (ShopBaseProductSpec) ShopBaseProductSpecMap.get(String.valueOf(categoryId));
|
||||||
}
|
}
|
||||||
Integer specId= shopBaseProductSpec.getSpec_id();
|
Integer specId= shopBaseProductSpec.getSpec_id();
|
||||||
String Spec_item_name=base.getSpecItem()+(StringUtils.isNotEmpty(base.getSpecUnit())?base.getSpecUnit():"");
|
|
||||||
ShopProductSpecItem addShopProductSpecItem=new ShopProductSpecItem();
|
ShopProductSpecItem addShopProductSpecItem=new ShopProductSpecItem();
|
||||||
if(StringUtils.isEmpty(Spec_item_name)){//如不是切割规格,不需要重置价格
|
ProductMapping productMapping= (ProductMapping) productMappingMap.get(productName);
|
||||||
ProductMapping productMapping= (ProductMapping) productMappingMap.get(productName);
|
String Spec_item_name=productMapping.getProductName()+ BigDecimalFormatter.formatWithoutTrailingZeros(productMapping.getSpecValue())+productMapping.getSpecUnit();
|
||||||
Spec_item_name=productMapping.getProductName()+ BigDecimalFormatter.formatWithoutTrailingZeros(productMapping.getSpecValue())+productMapping.getSpecUnit();
|
|
||||||
//计算价格
|
//计算价格
|
||||||
BigDecimal[] bigDecimals= ProductPriceCalculator.calculatePriceAndQuantity(base.getUnit_price(),base.getShop_weight(),productMapping.getSpecValue(),productMapping.getSpecUnit());
|
BigDecimal[] bigDecimals= ProductPriceCalculator.calculatePriceAndQuantity(base.getUnit_price(),base.getShop_weight(),productMapping.getSpecValue(),productMapping.getSpecUnit());
|
||||||
addShopProductSpecItem.setItemPrice(bigDecimals[0]);
|
addShopProductSpecItem.setItemPrice(bigDecimals[0]);
|
||||||
addShopProductSpecItem.setItemQuantity(bigDecimals[1]);
|
addShopProductSpecItem.setItemQuantity(bigDecimals[1]);
|
||||||
}
|
|
||||||
Integer Spec_item_id = null;
|
Integer Spec_item_id = null;
|
||||||
addShopProductSpecItem.setUpdate(true);
|
addShopProductSpecItem.setUpdate(true);
|
||||||
if(ObjectUtil.isNotEmpty(shopProductSpecItemMap.get(Spec_item_name))){
|
if(ObjectUtil.isNotEmpty(shopProductSpecItemMap.get(Spec_item_name))){
|
||||||
@ -422,7 +417,7 @@ public class ProductMappingServiceImpl extends BaseServiceImpl<ProductMappingMap
|
|||||||
int finalI = i;
|
int finalI = i;
|
||||||
Integer finalStoreId = storeId;
|
Integer finalStoreId = storeId;
|
||||||
futures.add(executor.submit(() -> {
|
futures.add(executor.submit(() -> {
|
||||||
this.computeProductMapping(shopProductBaseService.lists(queryWrapper, finalI,SHOPBASEPAGE).getRecords(), finalStoreId,false,DicEnum.YESORNO_1.getCode());
|
this.computeProductMapping(shopProductBaseService.lists(queryWrapper, finalI,SHOPBASEPAGE).getRecords(), finalStoreId,false);
|
||||||
return "成功" + finalI;
|
return "成功" + finalI;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -735,9 +735,7 @@ public abstract class SyncBaseThirdSxAbstract{
|
|||||||
shopProductBase.setCategoryId(categoryId);
|
shopProductBase.setCategoryId(categoryId);
|
||||||
shopProductBase.setProduct_sale_time(Convert.toDate(DateUtil.current() + 600)); //10分钟
|
shopProductBase.setProduct_sale_time(Convert.toDate(DateUtil.current() + 600)); //10分钟
|
||||||
shopProductBase.setStore_id(storeIdInt);
|
shopProductBase.setStore_id(storeIdInt);
|
||||||
|
|
||||||
shopProductBase.setProduct_number((String) jsonObj.get("product_number"));
|
shopProductBase.setProduct_number((String) jsonObj.get("product_number"));
|
||||||
shopProductBase.setProduct_name((String) jsonObj.get("product_name"));
|
|
||||||
|
|
||||||
shopProductBase.setStore_name(store_row.getStore_name());
|
shopProductBase.setStore_name(store_row.getStore_name());
|
||||||
shopProductBase.setProduct_tips("");
|
shopProductBase.setProduct_tips("");
|
||||||
@ -778,6 +776,15 @@ public abstract class SyncBaseThirdSxAbstract{
|
|||||||
shopProductBase.setProduct_state_id(StateCode.PRODUCT_STATE_OFF_THE_SHELF);//默认是下架
|
shopProductBase.setProduct_state_id(StateCode.PRODUCT_STATE_OFF_THE_SHELF);//默认是下架
|
||||||
shopProductBase.setUnit_price(BigDecimal.valueOf(jsonObj.getDouble("retail_price")));
|
shopProductBase.setUnit_price(BigDecimal.valueOf(jsonObj.getDouble("retail_price")));
|
||||||
}
|
}
|
||||||
|
if(productName.contains("g")||productName.contains("ml")||productName.contains("ML")||productName.contains("kg")||
|
||||||
|
productName.contains("KG")||productName.contains("L")||productName.contains("l")){
|
||||||
|
|
||||||
|
}else {
|
||||||
|
String spectItem=StringUtils.isNotEmpty(shopProductBase.getSpecItem())?shopProductBase.getSpecItem():"";
|
||||||
|
String unit=StringUtils.isNotEmpty(shopProductBase.getSpecUnit())?shopProductBase.getSpecUnit():"";
|
||||||
|
productName=productName+spectItem+"/"+unit;
|
||||||
|
}
|
||||||
|
shopProductBase.setProduct_name(productName);
|
||||||
// ShopProductIndex
|
// ShopProductIndex
|
||||||
ShopProductIndex shopProductIndex = new ShopProductIndex();
|
ShopProductIndex shopProductIndex = new ShopProductIndex();
|
||||||
shopProductIndex.setProduct_add_time(currentDate.getTime());
|
shopProductIndex.setProduct_add_time(currentDate.getTime());
|
||||||
@ -785,8 +792,8 @@ public abstract class SyncBaseThirdSxAbstract{
|
|||||||
shopProductIndex.setStore_category_ids(""); // 店铺分类编号(DOT)
|
shopProductIndex.setStore_category_ids(""); // 店铺分类编号(DOT)
|
||||||
shopProductIndex.setProduct_tags("");// 商品标签(DOT)
|
shopProductIndex.setProduct_tags("");// 商品标签(DOT)
|
||||||
shopProductIndex.setBrand_id(0);
|
shopProductIndex.setBrand_id(0);
|
||||||
shopProductIndex.setProduct_name(shopProductBase.getProduct_name()); // 产品名称:店铺平台先在对用表中检索后通过id检索,检索使用
|
shopProductIndex.setProduct_name(productName); // 产品名称:店铺平台先在对用表中检索后通过id检索,检索使用
|
||||||
shopProductIndex.setProduct_name_index(shopProductIndex.getProduct_name()); // 名称索引关键字(DOT)
|
shopProductIndex.setProduct_name_index(productName); // 名称索引关键字(DOT)
|
||||||
shopProductIndex.setCategory_id(categoryId); // 商品分类
|
shopProductIndex.setCategory_id(categoryId); // 商品分类
|
||||||
shopProductIndex.setProduct_fx_enable(0); // 供应商是否允许批发市场分销
|
shopProductIndex.setProduct_fx_enable(0); // 供应商是否允许批发市场分销
|
||||||
shopProductIndex.setProduct_dist_enable(0); // 是否允许三级分销
|
shopProductIndex.setProduct_dist_enable(0); // 是否允许三级分销
|
||||||
@ -864,7 +871,7 @@ public abstract class SyncBaseThirdSxAbstract{
|
|||||||
//shopProductImage
|
//shopProductImage
|
||||||
ShopProductImage shopProductImage = new ShopProductImage();
|
ShopProductImage shopProductImage = new ShopProductImage();
|
||||||
shopProductImage.setStore_id(storeIdInt);
|
shopProductImage.setStore_id(storeIdInt);
|
||||||
shopProductImage.setProduct_name(jsonObj.getStr("product_name"));
|
shopProductImage.setProduct_name(productName);
|
||||||
shopProductImage.setProduct_from("1005");
|
shopProductImage.setProduct_from("1005");
|
||||||
|
|
||||||
//添加数据到list
|
//添加数据到list
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user