解决品牌问题以及商品条码自动上架

This commit is contained in:
liyj 2025-12-18 10:47:34 +08:00
parent 1157bf3229
commit 59274f9941
3 changed files with 30 additions and 20 deletions

View File

@ -38,7 +38,7 @@ public class SxCategoryModelExcel {
@ExcelProperty(value = "第二级分类", index =2)
private String second_category_name;
@ApiModelProperty(value = "品牌名称")
@ExcelProperty(value = "品牌名称", index =3)
private String brandName;
// @ApiModelProperty(value = "品牌名称")
// @ExcelProperty(value = "品牌名称", index =3)
// private String brandName;
}

View File

@ -41,6 +41,8 @@ import com.suisung.mall.common.utils.DateTimeUtils;
import com.suisung.mall.common.utils.I18nUtil;
import com.suisung.mall.common.utils.StringUtils;
import com.suisung.mall.common.utils.phone.PhoneNumberUtils;
import com.suisung.mall.core.consts.ConstantRedis;
import com.suisung.mall.core.web.service.RedisService;
import com.suisung.mall.shop.base.service.ShopBaseProductBrandService;
import com.suisung.mall.shop.base.service.ShopBaseProductCategoryService;
import com.suisung.mall.shop.base.service.ShopBaseProductSpecService;
@ -102,9 +104,12 @@ public abstract class SyncBaseThirdSxAbstract{
@Autowired
private LibraryProductService libraryProductService;
@Autowired
private RedisService redisService;
@Autowired
public static final Set<String> FORBID_CATEGORY= Collections.unmodifiableSet(new HashSet<>(
Arrays.asList("香烟类","香烟","烟类", "")
Arrays.asList("香烟类","香烟","烟类", "","烟草")
));
/**
@ -141,6 +146,16 @@ public abstract class SyncBaseThirdSxAbstract{
}
List<ShopBaseProductType> productTypeList = new ArrayList<>();
Map<String,String> productTypeListMap=new HashMap<>();
//JSONObject o = (JSONObject) categoryListJSON.get(0);
// String brandName=o.getStr("brandName","其它品牌");
QueryWrapper<ShopBaseProductBrand> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("store_id",Integer.valueOf(storeId));
//queryWrapper.in("brand_name",Arrays.asList(brandName.split(",")));
// queryWrapper.eq("brand_name",brandName);
List<ShopBaseProductBrand> shopBaseProductBrands=productBrandService.list(queryWrapper);
String brandIds=shopBaseProductBrands.stream()
.map(shopBaseProductBrand -> String.valueOf(shopBaseProductBrand.getBrand_id()))
.collect(Collectors.joining(","));
for (int i = 0; i < list.size(); i++) {
String categoryName=list.get(i).getCategory_name();
if(StringUtils.isNotEmpty(getForbidCategory(categoryName))){
@ -155,15 +170,7 @@ public abstract class SyncBaseThirdSxAbstract{
ShopBaseProductType productType=new ShopBaseProductType();
productType.setType_is_draft(1);//发布
productType.setStore_id(Integer.valueOf(storeId));
String brandName=o.getStr("brandName","其它品牌");
QueryWrapper<ShopBaseProductBrand> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("store_id",Integer.valueOf(storeId));
queryWrapper.in("brand_name",Arrays.asList(brandName.split(",")));
// queryWrapper.eq("brand_name",brandName);
List<ShopBaseProductBrand> shopBaseProductBrands=productBrandService.list(queryWrapper);
String brandIds=shopBaseProductBrands.stream()
.map(shopBaseProductBrand -> String.valueOf(shopBaseProductBrand.getBrand_id()))
.collect(Collectors.joining(","));
if (o != null) {
// 重要分类类型处理强调共性
Integer typeId = 1001;
@ -877,7 +884,6 @@ public abstract class SyncBaseThirdSxAbstract{
shopProductIndex.setProduct_sale_time(currentDate.getTime());
shopProductIndex.setStore_category_ids(""); // 店铺分类编号(DOT)
shopProductIndex.setProduct_tags("");// 商品标签(DOT)
shopProductIndex.setBrand_id(0);
shopProductIndex.setProduct_name(productName); // 产品名称:店铺平台先在对用表中检索后通过id检索,检索使用
shopProductIndex.setProduct_name_index(productName); // 名称索引关键字(DOT)
shopProductIndex.setCategory_id(categoryId); // 商品分类
@ -1098,7 +1104,7 @@ public abstract class SyncBaseThirdSxAbstract{
}
// spec_id++;
}
List<String> shopBaseProductTypeReidisKeyList=new ArrayList<>();
if(!insertShopBaseProductSpecList.isEmpty()){
List<Integer> specIdList=shopNumberSeqService.getBatchSpecId(insertShopBaseProductSpecList.size());
for(int i=0;i<specIdList.size();i++){
@ -1108,6 +1114,7 @@ public abstract class SyncBaseThirdSxAbstract{
if((shopBaseProductType.getType_name()+"规格").equals(insertShopBaseProductSpecList.get(finalI).getSpec_name())){
shopBaseProductType.setType_spec_ids(String.valueOf(finalSpec_id));
}
shopBaseProductTypeReidisKeyList.add(ConstantRedis.Cache_NameSpace + "shop_base_product_type:" +shopBaseProductType.getType_id());
});
insertShopBaseProductSpecList.get(i).setSpec_id(finalSpec_id);
}
@ -1122,6 +1129,9 @@ public abstract class SyncBaseThirdSxAbstract{
if(CollectionUtil.isNotEmpty(shopBaseProductTypes)){
productTypeService.updateBatchById(shopBaseProductTypes,shopBaseProductTypes.size());
}
if(!shopBaseProductTypeReidisKeyList.isEmpty()){//删除缓存
redisService.del(shopBaseProductTypeReidisKeyList);
}
productCategoryService.clearCategoryCache(storeId);
}

View File

@ -140,7 +140,7 @@ public class SyncShopImageServiceImpl implements SyncShopImageService {
while (index<3){
try {
List<ImageMappingDto> imageMappingDtos=CovertToShopProductImage(list);//调用es排除异常重新连接
syncBatchShopImage(imageMappingDtos);
syncBatchShopImage(imageMappingDtos,StateCode.PRODUCT_STATE_OFF_THE_SHELF);
success.getAndIncrement();
message= "成功" + finalI;
break;
@ -163,7 +163,7 @@ public class SyncShopImageServiceImpl implements SyncShopImageService {
final int finalI = i;
futures.add(executor.submit(() -> {
try {
syncBatchShopImage(imageMappingDtos);
syncBatchShopImage(imageMappingDtos,StateCode.PRODUCT_STATE_NORMAL);
success.getAndIncrement();
return "图库匹配成功" + finalI;
} catch (Exception e) {
@ -192,7 +192,7 @@ public class SyncShopImageServiceImpl implements SyncShopImageService {
* 把匹配的数据更新到商品的图库表
* @param imageMappingDtos
*/
private void syncBatchShopImage(List<ImageMappingDto> imageMappingDtos){
private void syncBatchShopImage(List<ImageMappingDto> imageMappingDtos,int product_state_id){
if(CollectionUtil.isEmpty(imageMappingDtos)){
log.info("没有匹配到图库");
return;
@ -223,14 +223,14 @@ public class SyncShopImageServiceImpl implements SyncShopImageService {
shopProductImageList.add(shopProductImage);
shopProductBase.setProduct_id(imageMappingDto.getProductId());
shopProductBase.setProduct_image(thumb);
shopProductBase.setProduct_state_id(StateCode.PRODUCT_STATE_OFF_THE_SHELF);
shopProductBase.setProduct_state_id(product_state_id);
shopProductBaseList.add(shopProductBase);
shopProductItem.setProduct_id(imageMappingDto.getProductId());
shopProductItem.setItem_enable(StateCode.PRODUCT_STATE_NORMAL);
shopProductItemList.add(shopProductItem);
ShopProductIndex shopProductIndex=new ShopProductIndex();
shopProductIndex.setProduct_id(imageMappingDto.getProductId());
shopProductIndex.setProduct_state_id(StateCode.PRODUCT_STATE_OFF_THE_SHELF);
shopProductIndex.setProduct_state_id(product_state_id);
shopProductIndexList.add(shopProductIndex);
}
synchronized (this){