|
|
@@ -1,17 +1,39 @@
|
|
|
package org.dromara.external.handler.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.dromara.external.api.zhongche.domain.vo.GoodsImageUpdateVo;
|
|
|
-import org.dromara.external.api.zhongche.domain.vo.GoodsPriceUpdateVo;
|
|
|
-import org.dromara.external.api.zhongche.domain.vo.GoodsStatusUpdateVo;
|
|
|
-import org.dromara.external.api.zhongche.domain.vo.GoodsUpdateVo;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.dromara.common.core.exception.api.ZhongcheException;
|
|
|
+import org.dromara.common.core.utils.StringUtils;
|
|
|
+import org.dromara.external.api.zhongche.domain.GoodsImageUpdateItem;
|
|
|
+import org.dromara.external.api.zhongche.domain.GoodsImportItem;
|
|
|
+import org.dromara.external.api.zhongche.domain.GoodsPropertiesUpdateItem;
|
|
|
+import org.dromara.external.api.zhongche.domain.GoodsStatusUpdateItem;
|
|
|
+import org.dromara.external.api.zhongche.domain.bo.*;
|
|
|
+import org.dromara.external.api.zhongche.domain.vo.*;
|
|
|
+import org.dromara.external.controller.tongji.TongJiPullController;
|
|
|
import org.dromara.external.domain.ExternalProduct;
|
|
|
+import org.dromara.external.domain.ExternalProductCategory;
|
|
|
+import org.dromara.external.domain.ExternalPushPoolLog;
|
|
|
+import org.dromara.external.domain.vo.ExternalProductVo;
|
|
|
import org.dromara.external.handler.ProductPushStrategy;
|
|
|
+import org.dromara.external.mapper.ExternalProductMapper;
|
|
|
+import org.dromara.external.service.IExternalProductCategoryService;
|
|
|
+import org.dromara.external.service.IExternalPushPoolLogService;
|
|
|
+import org.dromara.product.api.RemoteProductService;
|
|
|
import org.dromara.product.api.domain.ProductVo;
|
|
|
+import org.dromara.product.api.domain.zhongche.dto.ProductAggregateDto;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
-import java.util.List;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author
|
|
|
@@ -21,69 +43,377 @@ import java.util.List;
|
|
|
@RequiredArgsConstructor
|
|
|
@Slf4j
|
|
|
public class TongjiPushStrategy implements ProductPushStrategy {
|
|
|
- /**
|
|
|
- * 推送商品
|
|
|
- *
|
|
|
- * @param itemId
|
|
|
- * @param products
|
|
|
- */
|
|
|
+
|
|
|
+ private final String username = "20240316001";
|
|
|
+
|
|
|
+ @DubboReference
|
|
|
+ private final RemoteProductService remoteProductService;
|
|
|
+
|
|
|
+ private final TongJiPullController tongJiPullController;
|
|
|
+
|
|
|
+ private final ExternalProductMapper externalProductMapper;
|
|
|
+
|
|
|
+ private final IExternalProductCategoryService externalProductCategoryService;
|
|
|
+
|
|
|
+ private final IExternalPushPoolLogService externalPushPoolLogService;
|
|
|
+
|
|
|
+ private final ObjectMapper objectMapper;
|
|
|
+
|
|
|
@Override
|
|
|
- public void push(Long itemId, List<ExternalProduct> products) {
|
|
|
+ public void push( Long itemId,List<ExternalProduct> products) {
|
|
|
+ List<ExternalProductVo> productVoList = new ArrayList<>();
|
|
|
+ for (ExternalProduct product : products) {
|
|
|
+ ExternalProductVo vo = BeanUtil.toBean(product, ExternalProductVo.class);
|
|
|
+ productVoList.add(vo);
|
|
|
+ }
|
|
|
+ productVoList.forEach(item -> {
|
|
|
+ ExternalProductVo externalProductVo = BeanUtil.toBean(item, ExternalProductVo.class);
|
|
|
+ ProductVo productDetail = remoteProductService.getProductDetail(item.getProductId());
|
|
|
+ BeanUtil.copyProperties(productDetail, item);
|
|
|
+ item.setId(externalProductVo.getId());
|
|
|
+ item.setProductStatus(externalProductVo.getProductStatus());
|
|
|
+ item.setMemberPrice(productDetail.getMemberPrice());
|
|
|
+ item.setProductImage(productDetail.getImageUrl());
|
|
|
+ });
|
|
|
+
|
|
|
+ // 收集所有 externalCategoryId
|
|
|
+ Set<Long> categoryIds = productVoList.stream()
|
|
|
+ .map(ExternalProductVo::getExternalCategoryId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ if (!categoryIds.isEmpty()) {
|
|
|
+ List<ExternalProductCategory> categoryList =
|
|
|
+ externalProductCategoryService.listByIds(categoryIds);
|
|
|
+
|
|
|
+ // 转成 Map <id, name>
|
|
|
+ Map<Long, ExternalProductCategory> categoryMap = categoryList.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ ExternalProductCategory::getId,
|
|
|
+ Function.identity()
|
|
|
+
|
|
|
+ ));
|
|
|
+
|
|
|
+ // 回填分类名称
|
|
|
+ productVoList.forEach(item -> {
|
|
|
+ ExternalProductCategory externalProductCategory =
|
|
|
+ categoryMap.get(item.getExternalCategoryId());
|
|
|
+ item.setStandardCatalogName(externalProductCategory.getCategoryName());
|
|
|
+ item.setExternalCategoryNo(externalProductCategory.getCategoryNo());
|
|
|
+ });
|
|
|
+
|
|
|
+ List<Long> productIds = productVoList.stream()
|
|
|
+ .map(ExternalProductVo::getProductId)
|
|
|
+ .filter(Objects::nonNull) // 过滤空 ID,避免远程调用报错
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ //远程调用获取 ProductAggregateDto 列表
|
|
|
+ final Map<Long, ProductAggregateDto> productAggregateMap = new HashMap<>();
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(productIds)) {
|
|
|
+ List<ProductAggregateDto> productAggregateList =
|
|
|
+ remoteProductService.getProductInfo(productIds);
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(productAggregateList)) {
|
|
|
+ productAggregateMap.putAll(
|
|
|
+ productAggregateList.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ ProductAggregateDto::getProductId,
|
|
|
+ dto -> dto,
|
|
|
+ (existing, replacement) -> existing
|
|
|
+ ))
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<GoodsImportItem> batchGoods = new ArrayList<>();
|
|
|
+ productVoList.forEach(item -> {
|
|
|
+ GoodsImportItem goodsImportItem = new GoodsImportItem();
|
|
|
+ goodsImportItem.setGoodsId(item.getProductNo());
|
|
|
+ goodsImportItem.setCatalogId(item.getBottomCategoryId().toString());
|
|
|
+ goodsImportItem.setCatalogName(item.getCategoryName());
|
|
|
+ goodsImportItem.setStandardCatalogId(item.getExternalCategoryNo());
|
|
|
+ goodsImportItem.setStandardCatalogName(item.getStandardCatalogName());
|
|
|
+ //这里有英文有中文混合,需要处理
|
|
|
+ String brandName = item.getBrandName();
|
|
|
+ if (isChinese(brandName)) {
|
|
|
+ goodsImportItem.setBrandName(brandName);
|
|
|
+ } else if (isEnglish(brandName)) {
|
|
|
+ goodsImportItem.setBrandNameEn(brandName);
|
|
|
+ }
|
|
|
+ goodsImportItem.setName(item.getItemName());
|
|
|
+ goodsImportItem.setDsPrice(item.getMarketPrice());
|
|
|
+ goodsImportItem.setPrice(item.getExternalPrice());
|
|
|
+ //第三方价格
|
|
|
+ goodsImportItem.setThirdPrice(item.getExternalPrice());
|
|
|
+ goodsImportItem.setUnit(item.getUnitName());
|
|
|
+ //TODO 库存
|
|
|
+// goodsImportItem.setStock(productAggregateMap.get(item.getProductId()).getStock());
|
|
|
+ goodsImportItem.setStock(999);
|
|
|
+ //链接
|
|
|
+ goodsImportItem.setGoodsUrl(productAggregateMap.get(item.getProductId()).getGoodsUrl());
|
|
|
+ goodsImportItem.setThirdUrl(productAggregateMap.get(item.getProductId()).getThirdUrl());
|
|
|
+ //图片
|
|
|
+ String rawImageStr = item.getProductImage();
|
|
|
+ List<String> imageList = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotBlank(rawImageStr)) {
|
|
|
+ String[] imagePaths = rawImageStr.split(",");
|
|
|
+ for (String path : imagePaths) {
|
|
|
+ String trimedPath = path.trim();
|
|
|
+ if (StringUtils.isNotBlank(trimedPath)) {
|
|
|
+ imageList.add(trimedPath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String barImgUrlsJson;
|
|
|
+ try {
|
|
|
+ barImgUrlsJson = objectMapper.writeValueAsString(imageList);
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ barImgUrlsJson = "[]";
|
|
|
+ }
|
|
|
+ goodsImportItem.setBarImgUrls(barImgUrlsJson);
|
|
|
+ //TODO 商品描述
|
|
|
+ goodsImportItem.setDescription(productAggregateMap.get(item.getProductId()).getDescription());
|
|
|
|
|
|
+ //TODO 商品规格 默认 颜色:白色
|
|
|
+// if (StringUtils.isNotBlank(productAggregateMap.get(item.getProductId()).getDiyAttributesList())) {
|
|
|
+// String diyAttributesList = productAggregateMap.get(item.getProductId()).getDiyAttributesList();
|
|
|
+// List<Map> list = JSONUtil.toList(diyAttributesList, Map.class);
|
|
|
+// //格式为[{attributeKey:"",attributeValue:""}]转换成 [{key:value}]
|
|
|
+// List<Map<String, String>> map = list.stream().map(e -> {
|
|
|
+// Map<String, String> result = new HashMap<>();
|
|
|
+// result.put(e.get("attributeKey").toString(), e.get("attributeValue").toString());
|
|
|
+// return result;
|
|
|
+// }).collect(Collectors.toList());
|
|
|
+// goodsImportItem.setProperties(JSONUtil.toJsonStr(map));
|
|
|
+// }else{
|
|
|
+ goodsImportItem.setProperties("{\"保质期\":\"12个月\"}");
|
|
|
+// }
|
|
|
+
|
|
|
+ //TODO 是否自营
|
|
|
+ goodsImportItem.setIsSelfOperated(1);
|
|
|
+ //税率
|
|
|
+ goodsImportItem.setTax( new BigDecimal("0.13"));
|
|
|
+ //TODO 税收编码 默认填 1
|
|
|
+ goodsImportItem.setTaxCode("107022301");
|
|
|
+ batchGoods.add(goodsImportItem);
|
|
|
+ });
|
|
|
+ GoodsImportBo bo = new GoodsImportBo();
|
|
|
+ bo.setAccount(username);
|
|
|
+ bo.setGoods(batchGoods);
|
|
|
+ GoodsImportVo goodsImportVo = new GoodsImportVo();
|
|
|
+
|
|
|
+ try {
|
|
|
+ goodsImportVo = tongJiPullController.egoodsImport(bo);
|
|
|
+ if (goodsImportVo.getResult() == 1) {
|
|
|
+ externalProductMapper.update(
|
|
|
+ Wrappers.lambdaUpdate(ExternalProduct.class)
|
|
|
+ .set(ExternalProduct::getPushStatus, 1)
|
|
|
+ .in(ExternalProduct::getId, productIds)
|
|
|
+ .eq(ExternalProduct::getItemId, itemId)
|
|
|
+ );
|
|
|
+ }else {
|
|
|
+ externalProductMapper.update(
|
|
|
+ Wrappers.lambdaUpdate(ExternalProduct.class)
|
|
|
+ .set(ExternalProduct::getConnectStatus, 1)
|
|
|
+ .set(ExternalProduct::getPushStatus, 2)
|
|
|
+ .set(ExternalProduct::getRemark, goodsImportVo.getMessage())
|
|
|
+ .in(ExternalProduct::getId, productIds)
|
|
|
+ .eq(ExternalProduct::getItemId, itemId)
|
|
|
+ );
|
|
|
+ for (Long productId : productIds) {
|
|
|
+ ExternalPushPoolLog externalPushPoolLog = new ExternalPushPoolLog();
|
|
|
+ externalPushPoolLog.setProductId(productId);
|
|
|
+ externalPushPoolLog.setItemId(itemId);
|
|
|
+ externalPushPoolLog.setPushStatus("1");
|
|
|
+ externalPushPoolLog.setRemark(goodsImportVo.getMessage());
|
|
|
+ externalPushPoolLogService.save(externalPushPoolLog);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (ZhongcheException e) {
|
|
|
+ externalProductMapper.update(
|
|
|
+ Wrappers.lambdaUpdate(ExternalProduct.class)
|
|
|
+ .set(ExternalProduct::getConnectStatus, 1)
|
|
|
+ .set(ExternalProduct::getPushStatus, 2)
|
|
|
+ .set(ExternalProduct::getRemark, e.getMessage())
|
|
|
+ .in(ExternalProduct::getId, productIds)
|
|
|
+ .eq(ExternalProduct::getItemId, itemId)
|
|
|
+ );
|
|
|
+ for (Long productId : productIds) {
|
|
|
+ ExternalPushPoolLog externalPushPoolLog = new ExternalPushPoolLog();
|
|
|
+ externalPushPoolLog.setItemId(itemId);
|
|
|
+ externalPushPoolLog.setProductId(productId);
|
|
|
+ externalPushPoolLog.setPushStatus("1");
|
|
|
+ externalPushPoolLog.setReason(e.getMessage());
|
|
|
+ externalPushPoolLogService.save(externalPushPoolLog);
|
|
|
+ }
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 商品价格变更
|
|
|
- *
|
|
|
- * @param itemId
|
|
|
- * @param products
|
|
|
- */
|
|
|
@Override
|
|
|
- public GoodsPriceUpdateVo updatePrice(Long itemId, List<ProductVo> products) {
|
|
|
- return null;
|
|
|
+ public GoodsPriceUpdateVo updatePrice(Long itemId,List<ProductVo> products) {
|
|
|
+ GoodsImportBo bo = new GoodsImportBo();
|
|
|
+ bo.setAccount(username);
|
|
|
+ List<ExternalProductVo> externalProductVos = externalProductMapper.selectVoList(Wrappers.lambdaQuery(ExternalProduct.class).eq(ExternalProduct::getItemId, itemId));
|
|
|
+ Map<String, BigDecimal> decimalMap = externalProductVos.stream().collect(Collectors.toMap(ExternalProductVo::getProductNo, ExternalProductVo::getExternalPrice));
|
|
|
+ bo.setGoods(products.stream().map(item ->{
|
|
|
+ GoodsImportItem goodsImportItem = new GoodsImportItem();
|
|
|
+ goodsImportItem.setGoodsId(item.getProductNo());
|
|
|
+ goodsImportItem.setDsPrice(item.getMarketPrice());
|
|
|
+ goodsImportItem.setPrice(decimalMap.get(item.getProductNo()));
|
|
|
+ return goodsImportItem;
|
|
|
+ }).toList());
|
|
|
+ return tongJiPullController.egoodsPriceUpdate(bo);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 商品上下架状态变更
|
|
|
- *
|
|
|
- * @param productNos
|
|
|
- * @param status
|
|
|
- */
|
|
|
@Override
|
|
|
public GoodsStatusUpdateVo updateStatus(List<String> productNos, Integer status) {
|
|
|
- return null;
|
|
|
+ GoodsStatusUpdateBo goodsStatusUpdateBo = new GoodsStatusUpdateBo();
|
|
|
+ goodsStatusUpdateBo.setAccount(username);
|
|
|
+ goodsStatusUpdateBo.setGoods(productNos.stream().map(productNo -> {
|
|
|
+ GoodsStatusUpdateItem item = new GoodsStatusUpdateItem();
|
|
|
+ item.setGoodsId(productNo);
|
|
|
+ item.setStatus(status);
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+ return tongJiPullController.egoodsStatusUpdate(goodsStatusUpdateBo);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 商品图片变更
|
|
|
- *
|
|
|
- * @param itemId
|
|
|
- * @param products
|
|
|
- */
|
|
|
@Override
|
|
|
- public GoodsImageUpdateVo updateImages(Long itemId, List<ProductVo> products) {
|
|
|
- return null;
|
|
|
+ public GoodsImageUpdateVo updateImages(Long itemId,List<ProductVo> products) {
|
|
|
+ try {
|
|
|
+ GoodsImageUpdateBo bo = new GoodsImageUpdateBo();
|
|
|
+ bo.setAccount(username);
|
|
|
+ bo.setGoods(products.stream().map(item -> {
|
|
|
+ GoodsImageUpdateItem goodsImageUpdateItem = new GoodsImageUpdateItem();
|
|
|
+ goodsImageUpdateItem.setBarImgUrls(item.getImageUrl());
|
|
|
+ goodsImageUpdateItem.setGoodsId(item.getProductNo());
|
|
|
+ return goodsImageUpdateItem;
|
|
|
+ }).toList());
|
|
|
+ return tongJiPullController.egoodsImgsUpdate(bo);
|
|
|
+ }catch (ZhongcheException e){
|
|
|
+ for (ProductVo productVo : products) {
|
|
|
+ ExternalPushPoolLog externalPushPoolLog = new ExternalPushPoolLog();
|
|
|
+ externalPushPoolLog.setItemId(itemId);
|
|
|
+ externalPushPoolLog.setProductId(productVo.getId());
|
|
|
+ externalPushPoolLog.setPushStatus("1");
|
|
|
+ externalPushPoolLog.setReason(e.getMessage());
|
|
|
+ externalPushPoolLogService.save(externalPushPoolLog);
|
|
|
+ }
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public GoodsUpdateVo updateProperties(Long itemId,List<ProductVo> products) {
|
|
|
+ try {
|
|
|
+ GoodsPropertiesUpdateBo bo = new GoodsPropertiesUpdateBo();
|
|
|
+ bo.setAccount(username);
|
|
|
+ bo.setGoods(products.stream().map(item ->{
|
|
|
+ GoodsPropertiesUpdateItem goodsImageUpdateItem = new GoodsPropertiesUpdateItem();
|
|
|
+ goodsImageUpdateItem.setProperties("{\"保质期\":\"12个月\"}");
|
|
|
+ goodsImageUpdateItem.setGoodsId(item.getProductNo());
|
|
|
+ return goodsImageUpdateItem;
|
|
|
+ }).toList());
|
|
|
+ return tongJiPullController.egoodsPropertiesUpdate(bo);
|
|
|
+ }catch (ZhongcheException e){
|
|
|
+ for (ProductVo productVo : products) {
|
|
|
+ ExternalPushPoolLog externalPushPoolLog = new ExternalPushPoolLog();
|
|
|
+ externalPushPoolLog.setItemId(itemId);
|
|
|
+ externalPushPoolLog.setProductId(productVo.getId());
|
|
|
+ externalPushPoolLog.setPushStatus("1");
|
|
|
+ externalPushPoolLog.setReason(e.getMessage());
|
|
|
+ externalPushPoolLogService.save(externalPushPoolLog);
|
|
|
+ }
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public GoodsUpdateVo updateDetail(Long itemId,List<ProductVo> products) {
|
|
|
+ try {
|
|
|
+ GoodsDetailBo bo = new GoodsDetailBo();
|
|
|
+ bo.setAccount(username);
|
|
|
+ bo.setGoods(products.stream().map(item ->{
|
|
|
+ GoodsDetailUpdateBo goodsImageUpdateItem = new GoodsDetailUpdateBo();
|
|
|
+ goodsImageUpdateItem.setBrandName(item.getBrandName());
|
|
|
+ goodsImageUpdateItem.setDescription(item.getPcDetail());
|
|
|
+ goodsImageUpdateItem.setUpc(item.getBarCoding());
|
|
|
+ goodsImageUpdateItem.setMoq(BigDecimal.valueOf(item.getMinOrderQuantity()));
|
|
|
+ goodsImageUpdateItem.setIsSelfOperated(1);
|
|
|
+ goodsImageUpdateItem.setGoodsUrl("https://item.xiaoluwebsite.xyz/item?productNo="+item.getProductNo());
|
|
|
+ goodsImageUpdateItem.setThirdUrl(item.getReferenceLink());
|
|
|
+ goodsImageUpdateItem.setTaxCode("107022301");
|
|
|
+ goodsImageUpdateItem.setTax(BigDecimal.valueOf(0.13));
|
|
|
+ goodsImageUpdateItem.setUnit(item.getUnitName());
|
|
|
+ goodsImageUpdateItem.setStandardCatalogId("1374013891398471680");
|
|
|
+ goodsImageUpdateItem.setStandardCatalogName("福利套餐");
|
|
|
+ goodsImageUpdateItem.setGoodsId(item.getProductNo());
|
|
|
+ goodsImageUpdateItem.setTax(BigDecimal.valueOf(0.13));
|
|
|
+ return goodsImageUpdateItem;
|
|
|
+ }).toList());
|
|
|
+ return tongJiPullController.egoodsDetailUpdate(bo);
|
|
|
+ }catch (ZhongcheException e){
|
|
|
+ for (ProductVo productVo : products) {
|
|
|
+ ExternalPushPoolLog externalPushPoolLog = new ExternalPushPoolLog();
|
|
|
+ externalPushPoolLog.setItemId(itemId);
|
|
|
+ externalPushPoolLog.setProductId(productVo.getId());
|
|
|
+ externalPushPoolLog.setPushStatus("1");
|
|
|
+ externalPushPoolLog.setReason(e.getMessage());
|
|
|
+ externalPushPoolLogService.save(externalPushPoolLog);
|
|
|
+ }
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // --------------------- 核心判断方法 ---------------------
|
|
|
/**
|
|
|
- * 商品规格信息变更
|
|
|
- *
|
|
|
- * @param itemId
|
|
|
- * @param products
|
|
|
+ * 判断字符串是否包含中文汉字(核心判断逻辑)
|
|
|
+ * @param str 待判断字符串
|
|
|
+ * @return true=包含中文,false=不包含
|
|
|
*/
|
|
|
- @Override
|
|
|
- public GoodsUpdateVo updateProperties(Long itemId, List<ProductVo> products) {
|
|
|
- return null;
|
|
|
+ private boolean isChinese(String str) {
|
|
|
+ // 匹配任意中文字符(Unicode 中文编码范围)
|
|
|
+ return str.matches(".*[\\u4e00-\\u9fa5]+.*");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 商品详情信息变更
|
|
|
- *
|
|
|
- * @param itemId
|
|
|
- * @param products
|
|
|
+ * 判断字符串是否为纯英文(字母、数字、空格、常见标点)
|
|
|
+ * @param str 待判断字符串
|
|
|
+ * @return true=纯英文/数字,false=包含其他字符
|
|
|
*/
|
|
|
- @Override
|
|
|
- public GoodsUpdateVo updateDetail(Long itemId, List<ProductVo> products) {
|
|
|
- return null;
|
|
|
+ private boolean isEnglish(String str) {
|
|
|
+ // 匹配字母、数字、空格、横线、点、下划线(可根据业务扩展)
|
|
|
+ return str.matches("[a-zA-Z0-9 \\-\\.\\_]+");
|
|
|
}
|
|
|
+
|
|
|
+ /*public static void main(String[] args) {
|
|
|
+ String username = "admin";
|
|
|
+ List<GoodsImportItem> batchGoods = new ArrayList<>();
|
|
|
+ GoodsImportItem item = new GoodsImportItem();
|
|
|
+ item.setGoodsId("362031");
|
|
|
+ item.setCatalogId("13012");
|
|
|
+ item.setCatalogName("原装墨盒");
|
|
|
+ item.setStandardCatalogId("1750717233748832257");
|
|
|
+ item.setStandardCatalogName("铁圈装订机耗材");
|
|
|
+ item.setBrandName("得力");
|
|
|
+ item.setName("得力");
|
|
|
+ item.setDsPrice(new BigDecimal(41));
|
|
|
+ item.setPrice(new BigDecimal(34));
|
|
|
+ item.setUnit("个");
|
|
|
+ item.setStock(100);
|
|
|
+ item.setBarImgUrls("[\"https://img1.com\",\"https://img2.com\"]");
|
|
|
+ item.setDescription("得力商品");
|
|
|
+ item.setProperties("{\"颜色\":\"红色\",\"尺寸\":\"XL\",\"材质\":\"棉|涤纶\"}");
|
|
|
+ item.setIsSelfOperated(1);
|
|
|
+ item.setTax(new BigDecimal(0.05));
|
|
|
+ item.setTaxCode("123456");
|
|
|
+ batchGoods.add(item);
|
|
|
+ GoodsImportBo bo = new GoodsImportBo();
|
|
|
+ bo.setAccount(username);
|
|
|
+ bo.setGoods(batchGoods);
|
|
|
+ tongJiPullController tongJiPullController = new tongJiPullController();
|
|
|
+ GoodsImportVo resp = tongJiPullController.egoodsImport(bo);
|
|
|
+ System.out.println(resp);
|
|
|
+ }*/
|
|
|
}
|