|
|
@@ -8,15 +8,24 @@ import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.apache.commons.compress.utils.Lists;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.dromara.common.core.domain.jldx.JLDXResult;
|
|
|
+import org.dromara.external.api.erp.domain.ErpProductCategory;
|
|
|
import org.dromara.external.api.jldx.*;
|
|
|
import org.dromara.external.api.jldx.bo.*;
|
|
|
+import org.dromara.external.domain.ExternalProduct;
|
|
|
+import org.dromara.external.domain.ExternalProductCategory;
|
|
|
+import org.dromara.external.service.IExternalProductCategoryService;
|
|
|
+import org.dromara.external.service.IExternalProductService;
|
|
|
+import org.dromara.product.api.RemoteProductService;
|
|
|
+import org.dromara.product.api.domain.ProductVo;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -32,6 +41,12 @@ import java.util.stream.Collectors;
|
|
|
@RequestMapping(value = "/api")
|
|
|
public class JLDXController {
|
|
|
|
|
|
+ private final IExternalProductCategoryService iExternalProductCategoryService;
|
|
|
+
|
|
|
+ private final IExternalProductService iExternalProductService;
|
|
|
+
|
|
|
+ @DubboReference
|
|
|
+ private RemoteProductService remoteProductService;
|
|
|
|
|
|
/**
|
|
|
* 查询商品对外接口列表
|
|
|
@@ -42,7 +57,18 @@ public class JLDXController {
|
|
|
if(ObjectUtil.isNotEmpty(JLDXResult)){
|
|
|
return JLDXResult;
|
|
|
}
|
|
|
- List<BProductCategory> list = new ArrayList<>();
|
|
|
+ List<ExternalProductCategory> externalProductCategories = iExternalProductCategoryService.list(Wrappers.lambdaQuery(ExternalProductCategory.class)
|
|
|
+ .select(ExternalProductCategory::getCategoryNo, ExternalProductCategory::getCategoryName, ExternalProductCategory::getId)
|
|
|
+ .eq(ExternalProductCategory::getClassLevel, 3)
|
|
|
+ .eq(ExternalProductCategory::getItemId, 13)
|
|
|
+ );
|
|
|
+ List<BProductCategory> list = externalProductCategories.stream().map(item -> {
|
|
|
+ BProductCategory bProductCategory = new BProductCategory();
|
|
|
+ bProductCategory.setId(item.getId());
|
|
|
+ bProductCategory.setCategoryNo(item.getCategoryNo());
|
|
|
+ bProductCategory.setCategoryName(item.getCategoryName());
|
|
|
+ return bProductCategory;
|
|
|
+ }).toList();
|
|
|
List<Map<String, Object>> maps = list.stream().map(item -> {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("id", item.getId());
|
|
|
@@ -64,6 +90,17 @@ public class JLDXController {
|
|
|
return JLDXResult.fail("catalog_id不能为空");
|
|
|
}
|
|
|
List<BProductExternal> bProductExternals = new ArrayList<>();
|
|
|
+ List<ExternalProduct> externalProducts = iExternalProductService.list(
|
|
|
+ Wrappers.lambdaQuery(ExternalProduct.class)
|
|
|
+ .select(ExternalProduct::getProductNo)
|
|
|
+ .eq(ExternalProduct::getItemId, 13)
|
|
|
+ .eq(ExternalProduct::getCategoryId, bo.getCatalog_id())
|
|
|
+ );
|
|
|
+ bProductExternals = externalProducts.stream().map(item -> {
|
|
|
+ BProductExternal bProductExternal = new BProductExternal();
|
|
|
+ bProductExternal.setSku(item.getProductNo());
|
|
|
+ return bProductExternal;
|
|
|
+ }).toList();
|
|
|
List<String> skus = bProductExternals.stream().map(item -> item.getSku()).toList();
|
|
|
return JLDXResult.ok(skus);
|
|
|
}
|
|
|
@@ -80,9 +117,53 @@ public class JLDXController {
|
|
|
return JLDXResult.fail("sku不能为空");
|
|
|
}
|
|
|
BProductExternal sku = new BProductExternal();
|
|
|
- if(ObjectUtil.isEmpty(sku)){
|
|
|
+ ExternalProduct externalProduct = iExternalProductService.getOne(Wrappers.lambdaQuery(ExternalProduct.class)
|
|
|
+ .eq(ExternalProduct::getProductNo, bo.getSku())
|
|
|
+ .eq(ExternalProduct::getItemId, 13)
|
|
|
+ .last("limit 1")
|
|
|
+ );
|
|
|
+ if(ObjectUtil.isEmpty(externalProduct)){
|
|
|
return JLDXResult.fail("商品不存在");
|
|
|
}
|
|
|
+ List<ProductVo> productDetailsByNo = remoteProductService.getProductDetailsByNo(bo.getSku());
|
|
|
+
|
|
|
+ ProductVo productVo = productDetailsByNo.get(0);
|
|
|
+ //匹配字段productVo到sku
|
|
|
+ sku.setSku(productVo.getProductNo());
|
|
|
+ sku.setName(productVo.getItemName());
|
|
|
+ sku.setBrandName(productVo.getBrandName());
|
|
|
+ sku.setModel(productVo.getSpecification());
|
|
|
+ sku.setUpc(productVo.getBarCoding());
|
|
|
+ sku.setUnit(productVo.getUnitName());
|
|
|
+ sku.setWeight(productVo.getProductWeight());
|
|
|
+ sku.setImagePath(productVo.getProductImage());
|
|
|
+ sku.setImages(productVo.getImageUrl());
|
|
|
+ sku.setIntroduction(productVo.getPcDetail());
|
|
|
+ sku.setService(productVo.getAfterSalesService());
|
|
|
+ sku.setCode69(productVo.getBarCoding());
|
|
|
+ sku.setPrice(externalProduct.getExternalPrice());
|
|
|
+ sku.setMallPrice(productVo.getMarketPrice());
|
|
|
+ sku.setNum(externalProduct.getTotalInventory() != null ? productVo.getTotalInventory().intValue() : 0);
|
|
|
+
|
|
|
+ // 设置商品状态:1=已上架,0=下架
|
|
|
+ if (productVo.getProductStatus() != null) {
|
|
|
+ sku.setState(externalProduct.getProductStatus() == 1 ? "1" : "0");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置分类信息
|
|
|
+ if (productVo.getBottomCategoryId() != null) {
|
|
|
+ sku.setCatalogId(externalProduct.getCategoryId());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置属性信息
|
|
|
+// if (ObjectUtil.isNotEmpty(productVo.getAttributesList())) {
|
|
|
+// sku.setAttributes(productVo.getAttributesList());
|
|
|
+// }
|
|
|
+
|
|
|
+ // 设置规格参数
|
|
|
+// if (ObjectUtil.isNotEmpty(productVo.getSpecification())) {
|
|
|
+// sku.setParam(productVo.getSpecification());
|
|
|
+// }
|
|
|
Map<String, Object> map = BeanUtil.beanToMap(sku, true, false);
|
|
|
map.put("code_69",sku.getCode69());
|
|
|
map.put("code_69_file",sku.getCode69File());
|
|
|
@@ -105,7 +186,57 @@ public class JLDXController {
|
|
|
if(ObjectUtil.isEmpty(skusSplit)){
|
|
|
return JLDXResult.fail("skus不能为空");
|
|
|
}
|
|
|
- List<BProductExternal> bProductExternals = new ArrayList<>();
|
|
|
+
|
|
|
+ ExternalProduct externalProduct = iExternalProductService.getOne(Wrappers.lambdaQuery(ExternalProduct.class)
|
|
|
+ .in(ExternalProduct::getProductNo, skusSplit)
|
|
|
+ .eq(ExternalProduct::getItemId, 13)
|
|
|
+ .last("limit 1")
|
|
|
+ );
|
|
|
+ if(ObjectUtil.isEmpty(externalProduct)){
|
|
|
+ return JLDXResult.fail("商品不存在");
|
|
|
+ }
|
|
|
+ List<ProductVo> productDetailsByNo = remoteProductService.getProductDetailsByNo(bo.getSkus());
|
|
|
+
|
|
|
+ List<BProductExternal> bProductExternals = productDetailsByNo.stream().map(productVo -> {
|
|
|
+ BProductExternal sku = new BProductExternal();
|
|
|
+ //匹配字段productVo到sku
|
|
|
+ sku.setSku(productVo.getProductNo());
|
|
|
+ sku.setName(productVo.getItemName());
|
|
|
+ sku.setBrandName(productVo.getBrandName());
|
|
|
+ sku.setModel(productVo.getSpecification());
|
|
|
+ sku.setUpc(productVo.getBarCoding());
|
|
|
+ sku.setUnit(productVo.getUnitName());
|
|
|
+ sku.setWeight(productVo.getProductWeight());
|
|
|
+ sku.setImagePath(productVo.getProductImage());
|
|
|
+ sku.setImages(productVo.getImageUrl());
|
|
|
+ sku.setIntroduction(productVo.getPcDetail());
|
|
|
+ sku.setService(productVo.getAfterSalesService());
|
|
|
+ sku.setCode69(productVo.getBarCoding());
|
|
|
+ sku.setPrice(externalProduct.getExternalPrice());
|
|
|
+ sku.setMallPrice(productVo.getMarketPrice());
|
|
|
+ sku.setNum(externalProduct.getTotalInventory() != null ? productVo.getTotalInventory().intValue() : 0);
|
|
|
+
|
|
|
+ // 设置商品状态:1=已上架,0=下架
|
|
|
+ if (productVo.getProductStatus() != null) {
|
|
|
+ sku.setState(externalProduct.getProductStatus() == 1 ? "1" : "0");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置分类信息
|
|
|
+ if (productVo.getBottomCategoryId() != null) {
|
|
|
+ sku.setCatalogId(externalProduct.getCategoryId());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置属性信息
|
|
|
+// if (ObjectUtil.isNotEmpty(productVo.getAttributesList())) {
|
|
|
+// sku.setAttributes(productVo.getAttributesList());
|
|
|
+// }
|
|
|
+
|
|
|
+ // 设置规格参数
|
|
|
+// if (ObjectUtil.isNotEmpty(productVo.getSpecification())) {
|
|
|
+// sku.setParam(productVo.getSpecification());
|
|
|
+// }
|
|
|
+ return sku;
|
|
|
+ }).toList();
|
|
|
List<Map<String, Object>> maps = bProductExternals.stream().map(item -> {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("sku", item.getSku());
|
|
|
@@ -131,7 +262,19 @@ public class JLDXController {
|
|
|
if(ObjectUtil.isEmpty(skusSplit)){
|
|
|
return JLDXResult.fail("sku不能为空");
|
|
|
}
|
|
|
- List<BProductExternal> bProductExternals = new ArrayList<>();
|
|
|
+ List<ExternalProduct> externalProducts = iExternalProductService.list(Wrappers.lambdaQuery(ExternalProduct.class)
|
|
|
+ .in(ExternalProduct::getProductNo, skusSplit)
|
|
|
+ .eq(ExternalProduct::getItemId, 13)
|
|
|
+ );
|
|
|
+ if(ObjectUtil.isEmpty(externalProducts)){
|
|
|
+ return JLDXResult.fail("商品不存在");
|
|
|
+ }
|
|
|
+ List<BProductExternal> bProductExternals = externalProducts.stream().map(externalProduct -> {
|
|
|
+ BProductExternal bProductExternal = new BProductExternal();
|
|
|
+ bProductExternal.setSku(externalProduct.getProductNo());
|
|
|
+ bProductExternal.setState(externalProduct.getProductStatus() == 1 ? "1" : "0");
|
|
|
+ return bProductExternal;
|
|
|
+ }).toList();
|
|
|
List<Map<String, Object>> maps = bProductExternals.stream().map(item -> {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("sku", item.getSku());
|
|
|
@@ -157,7 +300,17 @@ public class JLDXController {
|
|
|
if(ObjectUtil.isEmpty(skusSplit)){
|
|
|
return JLDXResult.fail("sku不能为空");
|
|
|
}
|
|
|
- List<BProductExternal> bProductExternals = new ArrayList<>();
|
|
|
+ List<ExternalProduct> externalProducts = iExternalProductService.list(Wrappers.lambdaQuery(ExternalProduct.class)
|
|
|
+ .in(ExternalProduct::getProductNo, skusSplit)
|
|
|
+ .eq(ExternalProduct::getItemId, 13)
|
|
|
+ );
|
|
|
+ List<ProductVo> productDetailsByNo = remoteProductService.getProductDetailsByNo(bo.getSku());
|
|
|
+ List<BProductExternal> bProductExternals = productDetailsByNo.stream().map(productVo -> {
|
|
|
+ BProductExternal bProductExternal = new BProductExternal();
|
|
|
+ bProductExternal.setSku(productVo.getProductNo());
|
|
|
+ bProductExternal.setImages(productVo.getImageUrl());
|
|
|
+ return bProductExternal;
|
|
|
+ }).toList();
|
|
|
List<Map<String, Object>> maps = bProductExternals.stream().map(item -> {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("sku", item.getSku());
|
|
|
@@ -245,7 +398,19 @@ public class JLDXController {
|
|
|
if(ObjectUtil.isEmpty(skusSplit)){
|
|
|
return JLDXResult.fail("sku不能为空");
|
|
|
}
|
|
|
- List<BProductExternal> bProductExternals = new ArrayList<>();
|
|
|
+ List<ExternalProduct> externalProducts = iExternalProductService.list(Wrappers.lambdaQuery(ExternalProduct.class)
|
|
|
+ .in(ExternalProduct::getProductNo, skusSplit)
|
|
|
+ .eq(ExternalProduct::getItemId, 13)
|
|
|
+ );
|
|
|
+ Map<String, BigDecimal> decimalMap = externalProducts.stream().collect(Collectors.toMap(ExternalProduct::getProductNo, ExternalProduct::getExternalPrice));
|
|
|
+ List<ProductVo> productDetailsByNo = remoteProductService.getProductDetailsByNo(bo.getSku());
|
|
|
+ List<BProductExternal> bProductExternals = productDetailsByNo.stream().map(productVo -> {
|
|
|
+ BProductExternal bProductExternal = new BProductExternal();
|
|
|
+ bProductExternal.setSku(productVo.getProductNo());
|
|
|
+ bProductExternal.setPrice(decimalMap.get(productVo.getProductNo()) != null ? decimalMap.get(productVo.getProductNo()) : BigDecimal.ZERO);
|
|
|
+ bProductExternal.setMallPrice(productVo.getMarketPrice());
|
|
|
+ return bProductExternal;
|
|
|
+ }).toList();
|
|
|
List<Map<String, Object>> maps = bProductExternals.stream().map(item -> {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("sku", item.getSku());
|
|
|
@@ -274,7 +439,16 @@ public class JLDXController {
|
|
|
if(ObjectUtil.isEmpty(skusSplit)){
|
|
|
return JLDXResult.fail("sku不能为空");
|
|
|
}
|
|
|
- List<BProductExternal> bProductExternals = new ArrayList<>();
|
|
|
+ List<ExternalProduct> externalProducts = iExternalProductService.list(Wrappers.lambdaQuery(ExternalProduct.class)
|
|
|
+ .in(ExternalProduct::getProductNo, skusSplit)
|
|
|
+ .eq(ExternalProduct::getItemId, 13)
|
|
|
+ );
|
|
|
+ List<BProductExternal> bProductExternals = externalProducts.stream().map(item -> {
|
|
|
+ BProductExternal bProductExternal = new BProductExternal();
|
|
|
+ bProductExternal.setSku(item.getProductNo());
|
|
|
+ bProductExternal.setNum(item.getAvailableInventory());
|
|
|
+ return bProductExternal;
|
|
|
+ }).toList();
|
|
|
if(ObjectUtil.isEmpty(bProductExternals)){
|
|
|
List<Map<String, Object>> maps = Arrays.stream(skusSplit).map(item -> {
|
|
|
Map<String, Object> map = new HashMap<>();
|