思迅商品同步

This commit is contained in:
Jack 2025-01-08 23:55:32 +08:00
parent 271ddfbb53
commit 0c8d281f73
4 changed files with 260 additions and 240 deletions

View File

@ -39,6 +39,9 @@ public class ShopProductBase implements Serializable {
@ApiModelProperty(value = "产品名称(in=>2,100)") @ApiModelProperty(value = "产品名称(in=>2,100)")
private String product_name; private String product_name;
@ApiModelProperty(value = "商品货号")
private String product_number;
@ApiModelProperty(value = "商品卖点:商品广告词") @ApiModelProperty(value = "商品卖点:商品广告词")
private String product_tips; private String product_tips;

View File

@ -12,6 +12,8 @@ import com.suisung.mall.common.utils.HttpServletUtils;
import com.suisung.mall.common.utils.I18nUtil; import com.suisung.mall.common.utils.I18nUtil;
import com.suisung.mall.shop.config.BaiduConfig; import com.suisung.mall.shop.config.BaiduConfig;
import okhttp3.*; import okhttp3.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
@ -22,9 +24,10 @@ import java.util.Map;
public class BaiduAi { public class BaiduAi {
static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build(); static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build();
private static final Logger log = LoggerFactory.getLogger(BaiduAi.class);
public static void main(String[] args) throws IOException { public static void main(String[] args) {
String url = "https://lancerdt.oss-accelerate.aliyuncs.com/mall/images/media/store/10002/20240123d3c27007baf740c9bdc429f850259501.jpg"; String url = "https://lancerdt.oss-accelerate.aliyuncs.com/mall/images/media/store/10002/20240123d3c27007baf740c9bdc429f850259501.jpg";
BaiduAiBriefDTO brief = new BaiduAiBriefDTO(); BaiduAiBriefDTO brief = new BaiduAiBriefDTO();
@ -64,7 +67,7 @@ public class BaiduAi {
} }
public static String addProductImg(String url, BaiduAiBriefDTO brief) throws IOException { public static String addProductImg(String url, BaiduAiBriefDTO brief) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("url", url); map.put("url", url);
map.put("brief", JSON.toJSONString(brief)); map.put("brief", JSON.toJSONString(brief));
@ -73,39 +76,38 @@ public class BaiduAi {
try { try {
par = HttpServletUtils.generateParams(map, "utf-8"); par = HttpServletUtils.generateParams(map, "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, par); RequestBody body = RequestBody.create(mediaType, par);
Request request = new Request.Builder() Request request = new Request.Builder()
.url("https://aip.baidubce.com/rest/2.0/image-classify/v1/realtime_search/product/add?access_token=" + BaiduConfig.getAccessToken()) .url("https://aip.baidubce.com/rest/2.0/image-classify/v1/realtime_search/product/add?access_token=" + BaiduConfig.getAccessToken())
.method("POST", body) .method("POST", body)
.addHeader("Content-Type", "application/x-www-form-urlencoded") .addHeader("Content-Type", "application/x-www-form-urlencoded")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.build(); .build();
Response response = HTTP_CLIENT.newCall(request).execute(); Response response = HTTP_CLIENT.newCall(request).execute();
String resultStr = response.body().string(); String resultStr = response.body().string();
System.out.println(resultStr); System.out.println(resultStr);
JSONObject jsonObject = JSONUtil.parseObj(resultStr); JSONObject jsonObject = JSONUtil.parseObj(resultStr);
Integer errCode = Convert.toInt(jsonObject.get("error_code")); Integer errCode = Convert.toInt(jsonObject.get("error_code"));
String errMessage = Convert.toStr(jsonObject.get("error_msg")); // String errMessage = Convert.toStr(jsonObject.get("error_msg"));
String contSign = Convert.toStr(jsonObject.get("cont_sign")); String contSign = Convert.toStr(jsonObject.get("cont_sign"));
if (CheckUtil.isEmpty(errCode)) { if (CheckUtil.isNotEmpty(errCode)) {
return "";
}
} else { return contSign;
} catch (Exception e) {
log.error("Baidu Ai 添加图片异常", e.getMessage());
return ""; return "";
} }
return contSign;
} }
public static String editProductImg(String url, BaiduAiBriefDTO brief) throws IOException { public static String editProductImg(String url, BaiduAiBriefDTO brief) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("url", url); map.put("url", url);
map.put("brief", JSON.toJSONString(brief)); map.put("brief", JSON.toJSONString(brief));
@ -114,40 +116,41 @@ public class BaiduAi {
try { try {
par = HttpServletUtils.generateParams(map, "utf-8"); par = HttpServletUtils.generateParams(map, "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, par); RequestBody body = RequestBody.create(mediaType, par);
Request request = new Request.Builder() Request request = new Request.Builder()
.url("https://aip.baidubce.com/rest/2.0/image-classify/v1/realtime_search/product/update?access_token=" + BaiduConfig.getAccessToken()) .url("https://aip.baidubce.com/rest/2.0/image-classify/v1/realtime_search/product/update?access_token=" + BaiduConfig.getAccessToken())
.method("POST", body) .method("POST", body)
.addHeader("Content-Type", "application/x-www-form-urlencoded") .addHeader("Content-Type", "application/x-www-form-urlencoded")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.build(); .build();
Response response = HTTP_CLIENT.newCall(request).execute(); Response response = HTTP_CLIENT.newCall(request).execute();
String resultStr = response.body().string(); String resultStr = response.body().string();
System.out.println(resultStr); System.out.println(resultStr);
JSONObject jsonObject = JSONUtil.parseObj(resultStr); JSONObject jsonObject = JSONUtil.parseObj(resultStr);
Integer errCode = Convert.toInt(jsonObject.get("error_code")); Integer errCode = Convert.toInt(jsonObject.get("error_code"));
String errMessage = Convert.toStr(jsonObject.get("error_msg")); String errMessage = Convert.toStr(jsonObject.get("error_msg"));
String contSign = Convert.toStr(jsonObject.get("cont_sign")); String contSign = Convert.toStr(jsonObject.get("cont_sign"));
if (CheckUtil.isEmpty(errCode)) { if (CheckUtil.isEmpty(errCode)) {
} else { } else {
return "";
}
return contSign;
} catch (Exception e) {
log.error("Baidu Ai 编辑图片异常", e.getMessage());
return ""; return "";
} }
return contSign;
} }
public static String removeProductImg(String url, String cont_sign) throws IOException { public static String removeProductImg(String url, String cont_sign) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
if (CheckUtil.isNotEmpty(url)) { if (CheckUtil.isNotEmpty(url)) {
@ -162,38 +165,37 @@ public class BaiduAi {
try { try {
par = HttpServletUtils.generateParams(map, "utf-8"); par = HttpServletUtils.generateParams(map, "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, par); RequestBody body = RequestBody.create(mediaType, par);
Request request = new Request.Builder() Request request = new Request.Builder()
.url("https://aip.baidubce.com/rest/2.0/image-classify/v1/realtime_search/product/delete?access_token=" + BaiduConfig.getAccessToken()) .url("https://aip.baidubce.com/rest/2.0/image-classify/v1/realtime_search/product/delete?access_token=" + BaiduConfig.getAccessToken())
.method("POST", body) .method("POST", body)
.addHeader("Content-Type", "application/x-www-form-urlencoded") .addHeader("Content-Type", "application/x-www-form-urlencoded")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.build(); .build();
Response response = HTTP_CLIENT.newCall(request).execute(); Response response = HTTP_CLIENT.newCall(request).execute();
String resultStr = response.body().string(); String resultStr = response.body().string();
System.out.println(resultStr); // System.out.println(resultStr);
JSONObject jsonObject = JSONUtil.parseObj(resultStr); JSONObject jsonObject = JSONUtil.parseObj(resultStr);
Integer errCode = Convert.toInt(jsonObject.get("error_code")); Integer errCode = Convert.toInt(jsonObject.get("error_code"));
String errMessage = Convert.toStr(jsonObject.get("error_msg")); String errMessage = Convert.toStr(jsonObject.get("error_msg"));
String contSign = Convert.toStr(jsonObject.get("cont_sign")); String contSign = Convert.toStr(jsonObject.get("cont_sign"));
if (CheckUtil.isEmpty(errCode)) { if (CheckUtil.isNotEmpty(errCode)) {
return "";
}
} else { return contSign;
} catch (Exception e) {
log.error("Baidu Ai 删除图片异常", e.getMessage());
return ""; return "";
} }
return contSign;
} }
public static List<Map> searchProductImg(String url, Integer pn, Integer rn) throws IOException { public static List<Map> searchProductImg(String url, Integer pn, Integer rn) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("url", url); map.put("url", url);
@ -209,45 +211,47 @@ public class BaiduAi {
try { try {
par = HttpServletUtils.generateParams(map, "utf-8"); par = HttpServletUtils.generateParams(map, "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, par);
Request request = new Request.Builder()
.url("https://aip.baidubce.com/rest/2.0/image-classify/v1/realtime_search/product/search?access_token=" + BaiduConfig.getAccessToken())
.method("POST", body)
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.addHeader("Accept", "application/json")
.build();
Response response = HTTP_CLIENT.newCall(request).execute();
String resultStr = response.body().string(); MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
System.out.println(resultStr); RequestBody body = RequestBody.create(mediaType, par);
Request request = new Request.Builder()
.url("https://aip.baidubce.com/rest/2.0/image-classify/v1/realtime_search/product/search?access_token=" + BaiduConfig.getAccessToken())
.method("POST", body)
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.addHeader("Accept", "application/json")
.build();
Response response = HTTP_CLIENT.newCall(request).execute();
JSONObject jsonObject = JSONUtil.parseObj(resultStr); String resultStr = response.body().string();
System.out.println(resultStr);
Integer errCode = Convert.toInt(jsonObject.get("error_code")); JSONObject jsonObject = JSONUtil.parseObj(resultStr);
String errMessage = Convert.toStr(jsonObject.get("error_msg"));
String contSign = Convert.toStr(jsonObject.get("cont_sign"));
Integer result_num = Convert.toInt(jsonObject.get("result_num")); Integer errCode = Convert.toInt(jsonObject.get("error_code"));
String errMessage = Convert.toStr(jsonObject.get("error_msg"));
String contSign = Convert.toStr(jsonObject.get("cont_sign"));
List<Map> items = new ArrayList<>(); Integer result_num = Convert.toInt(jsonObject.get("result_num"));
if (CheckUtil.isNotEmpty(result_num)) { List<Map> items = new ArrayList<>();
JSONArray resData = (JSONArray) jsonObject.get("result");
if (resData == null) { if (CheckUtil.isNotEmpty(result_num)) {
throw new ApiException(I18nUtil._("返回结果为空!")); JSONArray resData = (JSONArray) jsonObject.get("result");
if (resData == null) {
log.error(I18nUtil._("Baidu Ai 搜索图片,返回结果为空!"));
return null;
}
items = JSONUtil.toList(resData, Map.class);
} else {
return items;
} }
items = JSONUtil.toList(resData, Map.class);
} else {
return items; return items;
} catch (Exception e) {
log.error("Baidu Ai 搜索图片异常", e.getMessage());
return null;
} }
return items;
} }
} }

View File

@ -259,6 +259,14 @@ public interface ShopProductBaseService extends IBaseService<ShopProductBase> {
*/ */
Map getProductBasicInfo(Long product_id, Integer store_id); Map getProductBasicInfo(Long product_id, Integer store_id);
/**
* 根据店铺Id和商品货号获取商品Id
* @param store_id
* @param product_number
* @return
*/
Long getProductIdByStoreAndProductNumber(Integer store_id, String product_number);
@Transactional @Transactional
boolean updateProductSubsite(Integer store_id); boolean updateProductSubsite(Integer store_id);

View File

@ -67,6 +67,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.util.Pair;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
@ -98,149 +99,102 @@ import static io.seata.common.util.LambdaUtils.distinctByKey;
@Transactional @Transactional
@Service @Service
public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseMapper, ShopProductBase> implements ShopProductBaseService { public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseMapper, ShopProductBase> implements ShopProductBaseService {
private final Logger logger = LoggerFactory.getLogger(ShopProductBaseServiceImpl.class);
@Autowired @Autowired
private ShopBaseProductCategoryService shopBaseProductCategoryService; private ShopBaseProductCategoryService shopBaseProductCategoryService;
@Autowired @Autowired
private ShopProductMetaService shopProductMetaService; private ShopProductMetaService shopProductMetaService;
@Autowired @Autowired
private ShopProductPreSaleService shopProductPreSaleService; private ShopProductPreSaleService shopProductPreSaleService;
@Autowired @Autowired
private ShopProductBaseService shopProductBaseService; private ShopProductBaseService shopProductBaseService;
@Autowired @Autowired
private ShopStoreAnalyticsService shopStoreAnalyticsService; private ShopStoreAnalyticsService shopStoreAnalyticsService;
@Autowired @Autowired
private ShopProductAnalyticsService shopProductAnalyticsService; private ShopProductAnalyticsService shopProductAnalyticsService;
@Autowired @Autowired
private ShopProductDetailService shopProductDetailService; private ShopProductDetailService shopProductDetailService;
@Autowired @Autowired
private ShopProductInfoService shopProductInfoService; private ShopProductInfoService shopProductInfoService;
@Autowired @Autowired
private ShopProductValidPeriodService shopProductValidPeriodService; private ShopProductValidPeriodService shopProductValidPeriodService;
@Autowired @Autowired
private ShopProductItemService shopProductItemService; private ShopProductItemService shopProductItemService;
@Autowired @Autowired
private AccountBaseConfigService accountBaseConfigService; private AccountBaseConfigService accountBaseConfigService;
@Autowired @Autowired
private ShopBaseCurrencyService shopBaseCurrencyService; private ShopBaseCurrencyService shopBaseCurrencyService;
@Autowired @Autowired
private ShopUserCartService shopUserCartService; private ShopUserCartService shopUserCartService;
@Autowired @Autowired
private ShopStoreTransportTypeService transportTypeService; private ShopStoreTransportTypeService transportTypeService;
@Autowired @Autowired
private ShopBaseProductCategoryService productCategoryService; private ShopBaseProductCategoryService productCategoryService;
@Autowired @Autowired
private ShopProductIndexService shopProductIndexService; private ShopProductIndexService shopProductIndexService;
@Autowired @Autowired
private ShopProductImageService shopProductImageService; private ShopProductImageService shopProductImageService;
@Autowired @Autowired
private ShopStoreBaseService shopStoreBaseService; private ShopStoreBaseService shopStoreBaseService;
@Autowired @Autowired
private ShopBaseProductSpecService baseProductSpecService; private ShopBaseProductSpecService baseProductSpecService;
@Autowired @Autowired
private ShopBaseStoreGradeService baseStoreGradeService; private ShopBaseStoreGradeService baseStoreGradeService;
@Autowired @Autowired
private ShopProductAssistIndexService assistIndexService; private ShopProductAssistIndexService assistIndexService;
@Autowired @Autowired
private ShopProductDataService shopProductDataService; private ShopProductDataService shopProductDataService;
@Autowired @Autowired
private ShopProductItemSeqService shopProductItemSeqService; private ShopProductItemSeqService shopProductItemSeqService;
@Autowired @Autowired
private ShopProductValidPeriodService validPeriodService; private ShopProductValidPeriodService validPeriodService;
@Autowired @Autowired
private ShopUserSearchHistoryService shopUserSearchHistoryService; private ShopUserSearchHistoryService shopUserSearchHistoryService;
@Autowired @Autowired
private ShopBaseStateCodeService shopBaseStateCodeService; private ShopBaseStateCodeService shopBaseStateCodeService;
@Autowired @Autowired
private ShopProductBaseMapper shopProductBaseMapper; private ShopProductBaseMapper shopProductBaseMapper;
@Autowired @Autowired
private ShopStoreActivityBaseService shopStoreActivityBaseService; private ShopStoreActivityBaseService shopStoreActivityBaseService;
@Autowired @Autowired
private ShopStoreActivityItemService shopStoreActivityItemService; private ShopStoreActivityItemService shopStoreActivityItemService;
@Autowired @Autowired
private ShopActivityGroupbookingService shopActivityGroupbookingService; private ShopActivityGroupbookingService shopActivityGroupbookingService;
@Autowired @Autowired
private ShopBaseProductTypeService shopBaseProductTypeService; private ShopBaseProductTypeService shopBaseProductTypeService;
@Autowired @Autowired
private ShopNumberSeqService shopNumberSeqService; private ShopNumberSeqService shopNumberSeqService;
@Autowired @Autowired
private EduService eduService; private EduService eduService;
@Autowired @Autowired
private ShopBaseDistrictService shopBaseDistrictService; private ShopBaseDistrictService shopBaseDistrictService;
@Autowired @Autowired
private ShopBaseContractTypeService shopBaseContractTypeService; private ShopBaseContractTypeService shopBaseContractTypeService;
@Autowired @Autowired
private ShopBaseMarketCategoryService shopBaseMarketCategoryService; private ShopBaseMarketCategoryService shopBaseMarketCategoryService;
@Autowired @Autowired
private MessageService messageService; private MessageService messageService;
@Autowired @Autowired
private ShopOrderItemService shopOrderItemService; private ShopOrderItemService shopOrderItemService;
@Autowired @Autowired
private SearchService searchService; private SearchService searchService;
@Autowired @Autowired
private ShopChainItemService shopChainItemService; private ShopChainItemService shopChainItemService;
@Autowired @Autowired
private ShopUserProductBrowseService shopUserProductBrowseService; private ShopUserProductBrowseService shopUserProductBrowseService;
@Autowired @Autowired
private ShopUserProductBuyService shopUserProductBuyService; private ShopUserProductBuyService shopUserProductBuyService;
@Autowired @Autowired
private ShopUserFavoritesItemService shopUserFavoritesItemService; private ShopUserFavoritesItemService shopUserFavoritesItemService;
@Autowired @Autowired
private MqMessageService mqMessageService; private MqMessageService mqMessageService;
@Autowired @Autowired
private ThreadPoolExecutor executor; private ThreadPoolExecutor executor;
@Autowired @Autowired
private ShopBaseLangMetaService shopBaseLangMetaService; private ShopBaseLangMetaService shopBaseLangMetaService;
@Resource @Resource
private SxSyncGoodsService sxSyncGoodsService; private SxSyncGoodsService sxSyncGoodsService;
private final Logger logger = LoggerFactory.getLogger(ShopProductBaseServiceImpl.class);
@Override @Override
public boolean trySaveProduct(String productObj, String productItems) { public boolean trySaveProduct(String productObj, String productItems) {
@ -690,7 +644,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
} }
/** /**
* 尝试保存一个商品所有信息 * 尝试保存一个商品所有信息会抛出异常
* *
* @param shopProductBase 商品基础表信息 * @param shopProductBase 商品基础表信息
* @param shopProductIndex 商品索引表信息 * @param shopProductIndex 商品索引表信息
@ -704,35 +658,67 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
* @return * @return
*/ */
public boolean trySaveProduct(ShopProductBase shopProductBase, ShopProductIndex shopProductIndex, ShopProductData shopProductData, ShopProductDetail shopProductDetail, ShopProductInfo shopProductInfo, List<ShopProductItem> shopProductItemList, List<ShopProductImage> shopProductImageList, ShopProductValidPeriod shopProductValidPeriod, List<ShopProductAssistIndex> shopProductAssistIndexList) { public boolean trySaveProduct(ShopProductBase shopProductBase, ShopProductIndex shopProductIndex, ShopProductData shopProductData, ShopProductDetail shopProductDetail, ShopProductInfo shopProductInfo, List<ShopProductItem> shopProductItemList, List<ShopProductImage> shopProductImageList, ShopProductValidPeriod shopProductValidPeriod, List<ShopProductAssistIndex> shopProductAssistIndexList) {
Pair<Boolean, String> pair = saveProduct(shopProductBase, shopProductIndex, shopProductData, shopProductDetail, shopProductInfo, shopProductItemList, shopProductImageList, shopProductValidPeriod, shopProductAssistIndexList);
if (!pair.getFirst()) {
throw new ApiException(pair.getSecond());
}
return true;
}
/**
* 保存一个商品所有信息不会抛出异常
*
* @param shopProductBase 商品基础表信息
* @param shopProductIndex 商品索引表信息
* @param shopProductData 商品数据表信息
* @param shopProductDetail 商品详情表信息
* @param shopProductInfo 商品信息表信息
* @param shopProductItemList 商品SKU信息
* @param shopProductImageList 商品图片信息
* @param shopProductValidPeriod 虚拟商品信息
* @param shopProductAssistIndexList 辅助信息表
* @return
*/
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(); Integer store_id = shopProductBase.getStore_id();
ShopStoreBase storeBase = null; ShopStoreBase storeBase = null;
if (store_id == null) { if (store_id == null) {
return false; return Pair.of(false, I18nUtil._("缺少店铺ID!"));
} else { }
storeBase = shopStoreBaseService.get(store_id);
Integer store_type = storeBase.getStore_type(); storeBase = shopStoreBaseService.get(store_id);
// 判断是否为供应商店铺 Integer store_type = storeBase.getStore_type();
if (store_type == 2) { // 判断是否为供应商店铺
shopProductIndex.setProduct_fx_enable(1); // 供应商是否允许批发市场分销 if (store_type == 2) {
shopProductIndex.setProduct_dist_enable(0); // 三级分销逻辑 shopProductIndex.setProduct_fx_enable(1); // 供应商是否允许批发市场分销
shopProductIndex.setProduct_dist_enable(0); // 三级分销逻辑
}
// TODO 判断违禁词
// 商品是否需要审核
boolean verify_type = accountBaseConfigService.getConfig("product_verify_flag", false);
Long productId = shopProductBase.getProduct_id();
// add 2025-01-08
if (productId == null) {
// 根据店铺id和商品货号获取商品id
productId = getProductIdByStoreAndProductNumber(store_id, shopProductBase.getProduct_number());
if (productId != null && productId > 0) {
shopProductBase.setProduct_id(productId);
} }
} }
// todo 判断违禁词
// 是否需要审核
boolean verify_type = accountBaseConfigService.getConfig("product_verify_flag", false);
Long product_id = shopProductBase.getProduct_id();
boolean isUpdate = false; boolean isUpdate = false;
String product_image_old = ""; String product_image_old = "";
if (product_id == null && storeBase != null) { if (productId == null && storeBase != null) {
product_id = shopNumberSeqService.createNextNo("product_id"); // 生成商品ID:product_id
productId = shopNumberSeqService.createNextNo("product_id");
if (null == product_id) { if (null == productId) {
throw new ApiException(I18nUtil._("生成商品编号异常!")); return Pair.of(false, I18nUtil._("生成商品编号异常!"));
} else { } else {
shopProductBase.setProduct_id(product_id); shopProductBase.setProduct_id(productId);
} }
// begin 新增判断发布商品数量是否超限 // begin 新增判断发布商品数量是否超限
@ -740,26 +726,23 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
ShopBaseStoreGrade store_grade_row = baseStoreGradeService.get(store_grade_id); ShopBaseStoreGrade store_grade_row = baseStoreGradeService.get(store_grade_id);
if (store_grade_row == null) { if (store_grade_row == null) {
// 店铺等级有误! return Pair.of(false, I18nUtil._("店铺等级有误!"));
throw new ApiException(I18nUtil._("店铺等级有误!"));
} }
Integer store_grade_product_limit = store_grade_row.getStore_grade_product_limit(); Integer store_grade_product_limit = store_grade_row.getStore_grade_product_limit();
if (store_grade_product_limit != null && store_grade_product_limit != 0) { if (store_grade_product_limit != null && store_grade_product_limit != 0) {
QueryWrapper<ShopProductIndex> indexQueryWrapper = new QueryWrapper<>(); QueryWrapper<ShopProductIndex> indexQueryWrapper = new QueryWrapper<>();
indexQueryWrapper.eq("store_id", store_id); indexQueryWrapper.eq("store_id", store_id);
// 当前的商品数量
long product_num = shopProductIndexService.count(indexQueryWrapper); long product_num = shopProductIndexService.count(indexQueryWrapper);
if (product_num >= store_grade_product_limit) { if (product_num >= store_grade_product_limit) {
throw new ApiException(I18nUtil._("发布产品数超过店铺当前等级可允许发布商品数")); return Pair.of(false, I18nUtil._("发布产品数超过店铺当前等级可允许发布商品数!"));
} }
} }
} else { } else {
//for baiduAi //for baiduAi 以图搜图
ShopProductBase productBaseOld = shopProductBaseService.get(product_id); ShopProductBase productBaseOld = shopProductBaseService.get(productId);
if (productBaseOld != null) { if (productBaseOld != null) {
product_image_old = productBaseOld.getProduct_image(); product_image_old = productBaseOld.getProduct_image();
isUpdate = true; isUpdate = true;
@ -775,6 +758,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
// 判断状态 - 用户端 // 判断状态 - 用户端
Integer product_state_id = shopProductBase.getProduct_state_id(); Integer product_state_id = shopProductBase.getProduct_state_id();
if (ObjectUtil.equal(product_state_id, StateCode.PRODUCT_STATE_OFF_THE_SHELF)) { if (ObjectUtil.equal(product_state_id, StateCode.PRODUCT_STATE_OFF_THE_SHELF)) {
// 下架状态
shopProductIndex.setProduct_sale_time(shopProductBase.getProduct_sale_time().getTime()); shopProductIndex.setProduct_sale_time(shopProductBase.getProduct_sale_time().getTime());
} else { } else {
// 修正状态 // 修正状态
@ -818,12 +802,12 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
BigDecimal max_item_market_price = shopProductItemList.stream().map(ShopProductItem::getItem_market_price).max(BigDecimal::compareTo).get(); 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); BigDecimal product_market_price = NumberUtil.max(max_item_unit_price, max_item_market_price);
shopProductBase.setProduct_market_price(product_market_price); shopProductBase.setProduct_market_price(product_market_price);
// 保存商品基本信息
if (!saveOrUpdate(shopProductBase)) { if (!saveOrUpdate(shopProductBase)) {
throw new ApiException(ResultCode.FAILED); return Pair.of(false, I18nUtil._("保存 productBase 商品信息出错!"));
} }
Long productId = shopProductBase.getProduct_id();
// 商品辅助属性 // 商品辅助属性
List<String> assistItemList = new ArrayList<>(); List<String> assistItemList = new ArrayList<>();
if (CollUtil.isNotEmpty(shopProductAssistIndexList)) { if (CollUtil.isNotEmpty(shopProductAssistIndexList)) {
@ -835,7 +819,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
assistIndex.setProduct_id(productId); assistIndex.setProduct_id(productId);
if (!assistIndexService.saveOrUpdate(assistIndex)) { if (!assistIndexService.saveOrUpdate(assistIndex)) {
throw new ApiException(ResultCode.FAILED); return Pair.of(false, I18nUtil._("保存 ShopProductAssistIndex 商品附加属性出错!"));
} }
} }
} }
@ -873,22 +857,22 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
ShopProductIndex temp_info_row = shopProductIndexService.findOne(indexQueryWrapper); ShopProductIndex temp_info_row = shopProductIndexService.findOne(indexQueryWrapper);
if (temp_info_row != null && !ObjectUtil.equal(temp_info_row.getProduct_id(), productId)) { if (temp_info_row != null && !ObjectUtil.equal(temp_info_row.getProduct_id(), productId)) {
// 商品货号已经存在不可重 // 商品货号已经存在不可重
throw new ApiException(I18nUtil._("商品货号已经存在,不可重复!")); return Pair.of(false, I18nUtil._("商品货号已经存在,不可重复!"));
} }
} }
if (!shopProductIndexService.saveOrUpdate(shopProductIndex)) { if (!shopProductIndexService.saveOrUpdate(shopProductIndex)) {
throw new ApiException(ResultCode.FAILED); return Pair.of(false, I18nUtil._("保存 shopProductIndex 出错!"));
} }
shopProductDetail.setProduct_id(productId); shopProductDetail.setProduct_id(productId);
if (!shopProductDetailService.saveOrUpdate(shopProductDetail)) { if (!shopProductDetailService.saveOrUpdate(shopProductDetail)) {
throw new ApiException(ResultCode.FAILED); return Pair.of(false, I18nUtil._("保存 shopProductDetail 出错!"));
} }
shopProductData.setProduct_id(productId); shopProductData.setProduct_id(productId);
if (!shopProductDataService.saveOrUpdate(shopProductData)) { if (!shopProductDataService.saveOrUpdate(shopProductData)) {
throw new ApiException(ResultCode.FAILED); return Pair.of(false, I18nUtil._("保存 shopProductData 出错!"));
} }
// 保存product image, 图片和规格属性一起保存 // 保存product image, 图片和规格属性一起保存
@ -912,9 +896,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
image_row.setProduct_image_id(product_image_id); image_row.setProduct_image_id(product_image_id);
//图片相同不做处理 //图片相同不做处理
if (product_image_row.getItem_image_default().equals(image_row.getItem_image_default())) { if (!product_image_row.getItem_image_default().equals(image_row.getItem_image_default())) {
} else {
//图片不同先删除旧的 添加新的 //图片不同先删除旧的 添加新的
if (CheckUtil.isNotEmpty(product_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()); del_baidu_image_row.add(product_image_row.getItem_image_default());
@ -925,8 +907,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
add_baidu_image_row.add(product_image_row.getItem_image_default()); add_baidu_image_row.add(product_image_row.getItem_image_default());
} }
} }
continue;
} }
} }
} }
@ -955,7 +935,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
image_row.setItem_image_ext_2(""); image_row.setItem_image_ext_2("");
if (!shopProductImageService.saveOrUpdate(image_row)) { if (!shopProductImageService.saveOrUpdate(image_row)) {
throw new ApiException(ResultCode.FAILED); return Pair.of(false, I18nUtil._("保存 shopProductImage 出错!"));
} }
} }
@ -969,7 +949,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
// 读取商品基础数据 为了判断是否为分销供应商商品 // 读取商品基础数据 为了判断是否为分销供应商商品
Map product_uniqid = new HashMap(); Map product_uniqid = new HashMap();
ShopProductBase product_base_row = get(product_id); ShopProductBase product_base_row = get(productId);
for (ShopProductItem item_row : shopProductItemList) { for (ShopProductItem item_row : shopProductItemList) {
item_row.setProduct_id(productId); item_row.setProduct_id(productId);
item_row.setCategory_id(shopProductIndex.getCategory_id()); item_row.setCategory_id(shopProductIndex.getCategory_id());
@ -981,7 +961,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
cn.hutool.json.JSONArray array_item_spec = cn.hutool.json.JSONUtil.parseArray(item_spec); cn.hutool.json.JSONArray array_item_spec = cn.hutool.json.JSONUtil.parseArray(item_spec);
List<Integer> spec_item_ids = new ArrayList<>(); List<Integer> spec_item_ids = new ArrayList<>();
List<String> item_names = new ArrayList<>(); List<String> item_names = new ArrayList<>();
Long item_id = null; Long item_id;
for (Object josn_item_spec : array_item_spec) { for (Object josn_item_spec : array_item_spec) {
cn.hutool.json.JSONObject item = (cn.hutool.json.JSONObject) ((cn.hutool.json.JSONObject) josn_item_spec).get("item"); cn.hutool.json.JSONObject item = (cn.hutool.json.JSONObject) ((cn.hutool.json.JSONObject) josn_item_spec).get("item");
@ -1016,13 +996,13 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
item_id = shopNumberSeqService.createNextNo("item_id"); item_id = shopNumberSeqService.createNextNo("item_id");
if (null == item_id) { if (null == item_id) {
throw new ApiException(I18nUtil._("生成商品ItemId异常!")); return Pair.of(false, I18nUtil._("生成商品 ItemId 异常!"));
} else { } else {
field_row.setItem_id(item_id); field_row.setItem_id(item_id);
} }
if (!shopProductItemSeqService.saveOrUpdate(field_row)) { if (!shopProductItemSeqService.saveOrUpdate(field_row)) {
throw new ApiException(ResultCode.FAILED); return Pair.of(false, I18nUtil._("保存 shopProductItemSeq 出错!"));
} }
} }
@ -1038,7 +1018,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
item_row.setItem_freetime(0); item_row.setItem_freetime(0);
if (!shopProductItemService.saveOrUpdate(item_row)) { if (!shopProductItemService.saveOrUpdate(item_row)) {
throw new ApiException(ResultCode.FAILED); return Pair.of(false, I18nUtil._("保存 shopProductItem 出错!"));
} }
item_ids_new.add(item_row.getItem_id()); item_ids_new.add(item_row.getItem_id());
@ -1075,7 +1055,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
shopStoreActivityItemService.remove(activityItemQueryWrapper); shopStoreActivityItemService.remove(activityItemQueryWrapper);
if (!shopProductItemService.remove(item_ids_deprecate)) { if (!shopProductItemService.remove(item_ids_deprecate)) {
throw new ApiException(I18nUtil._("删除废弃sku失败")); return Pair.of(false, I18nUtil._("删除废弃sku失败"));
} }
} }
//start 清理sku相关数据 //start 清理sku相关数据
@ -1084,14 +1064,19 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
shopProductInfo.setProduct_id(productId); shopProductInfo.setProduct_id(productId);
shopProductInfo.setProduct_uniqid(JSONUtil.toJsonStr(product_uniqid)); shopProductInfo.setProduct_uniqid(JSONUtil.toJsonStr(product_uniqid));
if (!shopProductInfoService.saveOrUpdate(shopProductInfo)) { if (!shopProductInfoService.saveOrUpdate(shopProductInfo)) {
throw new ApiException(ResultCode.FAILED); return Pair.of(false, I18nUtil._("保存 shopProductInfo 出错!"));
} }
// virtual // virtual
if (shopProductValidPeriod != null) { if (shopProductValidPeriod != null) {
shopProductValidPeriod.setProduct_id(productId); shopProductValidPeriod.setProduct_id(productId);
Integer product_valid_type = shopProductValidPeriod.getProduct_valid_type();
if(product_valid_type==null){
product_valid_type = 1001;
}
shopProductValidPeriod.setProduct_valid_type(product_valid_type);// 默认到店服务 add 2025-01-08 避免出错
if (!validPeriodService.saveOrUpdate(shopProductValidPeriod)) { if (!validPeriodService.saveOrUpdate(shopProductValidPeriod)) {
throw new ApiException(ResultCode.FAILED); return Pair.of(false, I18nUtil._("保存 shopProductValidPeriod 出错!"));
} }
} }
@ -1099,12 +1084,14 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
if (CheckUtil.isNotEmpty(shopProductBase.getProduct_add_time())) { if (CheckUtil.isNotEmpty(shopProductBase.getProduct_add_time())) {
ShopProductAnalytics shopProductAnalytics = new ShopProductAnalytics(); ShopProductAnalytics shopProductAnalytics = new ShopProductAnalytics();
shopProductAnalytics.setProduct_id(shopProductIndex.getProduct_id()); shopProductAnalytics.setProduct_id(shopProductIndex.getProduct_id());
shopProductAnalytics.setProduct_click(0); // 默认0 add 2025-01-08 避免出错
shopProductAnalyticsService.saveOrUpdate(shopProductAnalytics); shopProductAnalyticsService.saveOrUpdate(shopProductAnalytics);
} }
//店铺统计 //店铺统计
if (!shopStoreAnalyticsService.saveProductAnalyticsNum(store_id)) { if (!shopStoreAnalyticsService.saveProductAnalyticsNum(store_id)) {
throw new ApiException(ResultCode.FAILED); return Pair.of(false, I18nUtil._("保存 shopStoreAnalytics 出错!"));
} }
//修改活动产品分类 //修改活动产品分类
@ -1126,9 +1113,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
boolean img_search_enable = accountBaseConfigService.getConfig("img_search_enable", false); boolean img_search_enable = accountBaseConfigService.getConfig("img_search_enable", false);
if (img_search_enable) { if (img_search_enable) {
//todo product_item_img模式放入队列异步处理 //todo product_item_img模式放入队列异步处理
//List<String> del_baidu_image_row = new ArrayList<>();
//List<String> add_baidu_image_row = new ArrayList<>();
//product_image //product_image
String contSign = ""; String contSign = "";
String product_image_new = shopProductBase.getProduct_image(); String product_image_new = shopProductBase.getProduct_image();
@ -1137,16 +1121,10 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
if (product_image_new.equals(product_image_old)) { if (product_image_new.equals(product_image_old)) {
product_image_new = ""; product_image_new = "";
product_image_old = ""; product_image_old = "";
} else {
} }
if (CheckUtil.isNotEmpty(product_image_old)) { if (CheckUtil.isNotEmpty(product_image_old)) {
try { contSign = BaiduAi.removeProductImg(product_image_old, "");
contSign = BaiduAi.removeProductImg(product_image_old, "");
} catch (Exception e) {
logger.warn(String.format("BaiduAi删除图片异常 : %s %s", product_image_old, e.getMessage()));
}
} }
if (CheckUtil.isNotEmpty(product_image_new)) { if (CheckUtil.isNotEmpty(product_image_new)) {
@ -1154,25 +1132,21 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
briefDTO.setProductName(shopProductBase.getProduct_name()); briefDTO.setProductName(shopProductBase.getProduct_name());
briefDTO.setProductId(shopProductBase.getProduct_id()); briefDTO.setProductId(shopProductBase.getProduct_id());
try { contSign = BaiduAi.addProductImg(product_image_new, briefDTO);
contSign = BaiduAi.addProductImg(product_image_new, briefDTO); ShopProductIndex productIndex = new ShopProductIndex();
ShopProductIndex productIndex = new ShopProductIndex(); productIndex.setProduct_id(productId);
productIndex.setProduct_id(product_id); productIndex.setProduct_contsign(contSign);
productIndex.setProduct_contsign(contSign); shopProductIndexService.edit(productIndex);
shopProductIndexService.edit(productIndex);
} catch (Exception e) {
logger.warn(String.format("BaiduAi添加图片异常 : %s %s", product_image_new, e.getMessage()));
}
} }
} }
//同步修改分销商品 //同步修改分销商品
if (isUpdate && shopProductIndex.getStore_type().equals(2)) { if (isUpdate && shopProductIndex.getStore_type().equals(2)) {
List<MqMessageVo> mqMessageVos = Collections.singletonList(new MqMessageVo(MqConstant.SHOP_EXCHANGE, MqConstant.SHOP_UPDATEDISTPRODUCT_ROUTING_KEY, product_id)); List<MqMessageVo> mqMessageVos = Collections.singletonList(new MqMessageVo(MqConstant.SHOP_EXCHANGE, MqConstant.SHOP_UPDATEDISTPRODUCT_ROUTING_KEY, productId));
mqMessageService.sendBatchMqMsg(mqMessageVos); mqMessageService.sendBatchMqMsg(mqMessageVos);
} }
return true; return Pair.of(true, I18nUtil._("保存处理成功!"));
} }
/** /**
@ -1520,22 +1494,22 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
//是否启用以图搜图 //是否启用以图搜图
boolean img_search_enable = accountBaseConfigService.getConfig("img_search_enable", false); boolean img_search_enable = accountBaseConfigService.getConfig("img_search_enable", false);
if (img_search_enable && CheckUtil.isNotEmpty(productSearchDTO.getProduct_img_url())) { if (img_search_enable && CheckUtil.isNotEmpty(productSearchDTO.getProduct_img_url())) {
try {
List<Map> product_contsign_map = BaiduAi.searchProductImg(productSearchDTO.getProduct_img_url(), productSearchDTO.getPage() - 1, productSearchDTO.getRows());
//List<String> contsigns = product_contsign_map.stream().map(s -> Convert.toStr(s.get("cont_sign"))).distinct().collect(Collectors.toList()); List<Map> product_contsign_map = BaiduAi.searchProductImg(productSearchDTO.getProduct_img_url(), productSearchDTO.getPage() - 1, productSearchDTO.getRows());
List<String> contsigns = new ArrayList<>();
for (Map row : product_contsign_map) { //List<String> contsigns = product_contsign_map.stream().map(s -> Convert.toStr(s.get("cont_sign"))).distinct().collect(Collectors.toList());
BigDecimal score = Convert.toBigDecimal(row.get("score")); List<String> contsigns = new ArrayList<>();
if (score.compareTo(BigDecimal.valueOf(0.8)) > 0) {
contsigns.add(Convert.toStr(row.get("cont_sign"))); for (Map row : product_contsign_map) {
} BigDecimal score = Convert.toBigDecimal(row.get("score"));
if (score.compareTo(BigDecimal.valueOf(0.8)) > 0) {
contsigns.add(Convert.toStr(row.get("cont_sign")));
} }
}
if (CollUtil.isNotEmpty(contsigns)) { if (CollUtil.isNotEmpty(contsigns)) {
column_row.in("product_contsign", contsigns); column_row.in("product_contsign", contsigns);
} }
/* /*
//todo 修正排序 //todo 修正排序
@ -1543,9 +1517,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
BigDecimal score = Convert.toBigDecimal(row.get("score")); BigDecimal score = Convert.toBigDecimal(row.get("score"));
} }
*/ */
} catch (IOException e) {
throw new RuntimeException(e);
}
} }
// 是否启用es // 是否启用es
@ -5077,6 +5049,31 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
} }
} }
/**
* 根据店铺Id和商品货号获取商品Id
*
* @param store_id
* @param product_number
* @return
*/
@Override
public Long getProductIdByStoreAndProductNumber(Integer store_id, String product_number) {
if (StrUtil.isBlank(product_number) || ObjectUtil.isNull(store_id)) {
return null;
}
QueryWrapper<ShopProductBase> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("store_id", store_id);
queryWrapper.eq("product_number", product_number);
queryWrapper.select("product_id");
ShopProductBase record = getOne(queryWrapper);
if (record == null || record.getProduct_id() == null) {
return null;
}
return record.getProduct_id();
}
@Override @Override
@Transactional @Transactional
public boolean updateProductSubsite(Integer store_id) { public boolean updateProductSubsite(Integer store_id) {
@ -5109,6 +5106,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
Long total = sxSyncGoodsService.countByStoreId(storeId, CommonConstant.Disable2); Long total = sxSyncGoodsService.countByStoreId(storeId, CommonConstant.Disable2);
Integer pageSize = 100; Integer pageSize = 100;
Integer pages = com.suisung.mall.shop.sixun.utils.CommonUtil.getPagesCount(total.intValue(), pageSize); Integer pages = com.suisung.mall.shop.sixun.utils.CommonUtil.getPagesCount(total.intValue(), pageSize);
int successCnt = 0;
for (int i = 1; i <= pages; i++) { for (int i = 1; i <= pages; i++) {
List<SxSyncGoods> goodsList = sxSyncGoodsService.pageByStoreId(storeId, CommonConstant.Disable2, i, pageSize).getRecords(); List<SxSyncGoods> goodsList = sxSyncGoodsService.pageByStoreId(storeId, CommonConstant.Disable2, i, pageSize).getRecords();
@ -5116,7 +5114,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
continue; continue;
} }
//shopProductBase, shopProductIndex, shopProductData, shopProductDetail, productInfo, itemList, productImageList, virtual, assistIndices // shopProductBase, shopProductIndex, shopProductData, shopProductDetail, shopProductInfo, shopProductItemList, ShopProductImageList, shopProductValidPeriod, ShopProductAssistIndexList
for (SxSyncGoods sxSyncGoods : goodsList) { for (SxSyncGoods sxSyncGoods : goodsList) {
Date currentDate = new Date(); Date currentDate = new Date();
@ -5129,10 +5127,11 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
ShopProductBase shopProductBase = new ShopProductBase(); ShopProductBase shopProductBase = new ShopProductBase();
shopProductBase.setProduct_sale_time(Convert.toDate(DateUtil.current() + 600)); //10分钟 shopProductBase.setProduct_sale_time(Convert.toDate(DateUtil.current() + 600)); //10分钟
shopProductBase.setProduct_name(sxSyncGoods.getItem_subname());
shopProductBase.setProduct_tips("");
shopProductBase.setStore_id(storeIdInt); shopProductBase.setStore_id(storeIdInt);
shopProductBase.setProduct_number(sxSyncGoods.getItem_no());
shopProductBase.setProduct_name(sxSyncGoods.getItem_subname());
shopProductBase.setStore_name(store_row.getStore_name()); shopProductBase.setStore_name(store_row.getStore_name());
shopProductBase.setProduct_tips("");
shopProductBase.setProduct_video(""); shopProductBase.setProduct_video("");
shopProductBase.setTransport_type_id(StateCode.DELIVERY_TYPE_SAME_CITY); shopProductBase.setTransport_type_id(StateCode.DELIVERY_TYPE_SAME_CITY);
shopProductBase.setProduct_state_id(StateCode.PRODUCT_STATE_NORMAL); shopProductBase.setProduct_state_id(StateCode.PRODUCT_STATE_NORMAL);
@ -5213,11 +5212,17 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
shopProductItemList.add(shopProductItem); shopProductItemList.add(shopProductItem);
// 保存数据 // 保存数据
trySaveProduct(shopProductBase, shopProductIndex, shopProductData, shopProductDetail, shopProductInfo, shopProductItemList, new ArrayList<ShopProductImage>(), new ShopProductValidPeriod(), new ArrayList<ShopProductAssistIndex>()); Pair<Boolean, String> pair = saveProduct(shopProductBase, shopProductIndex, shopProductData, shopProductDetail, shopProductInfo, shopProductItemList, new ArrayList<ShopProductImage>(), new ShopProductValidPeriod(), new ArrayList<ShopProductAssistIndex>());
if (!pair.getFirst()) {
logger.error(pair.getSecond());
continue;
}
successCnt += 1;
} }
} }
return true; return successCnt > 0;
} }