Merge remote-tracking branch 'origin/main'

This commit is contained in:
Jack 2025-07-05 12:11:44 +08:00
commit d7793cc24f
10 changed files with 113 additions and 24 deletions

View File

@ -42,7 +42,7 @@ public class StateCode {
public static final int PRODUCT_STATE_NORMAL = 1001; //正常
public static final int PRODUCT_STATE_OFF_THE_SHELF = 1002; //下架
public static final int PRODUCT_STATE_OFF_THE_SHELF_UNCHECK = 1003; //同步数据的状态下架未分配商品
public static final int PRODUCT_STATE_OFF_THE_SHELF_UNCHECK = 1003; //同步数据的状态下架未分配商品,也叫待审核
public static final int DEMAND_STATE_CONDUCT = 1000; //采购中
public static final int DEMAND_STATE_REJECT = 1030; //被驳回

View File

@ -161,7 +161,7 @@ public class ShopOrderItem implements Serializable {
private Integer order_item_saler_id;
@ApiModelProperty(value = "分销商品编号")
private Long item_src_id;
private String item_src_id;
@ApiModelProperty(value = "拆单同步状态")
private Integer order_item_supplier_sync;

View File

@ -126,7 +126,7 @@ public class ShopProductItem implements Serializable {
private Integer item_freetime;
@ApiModelProperty(value = "供应商SKU编号")
private Long item_src_id;
private String item_src_id;
@ApiModelProperty(value = "商品分类")
private Integer category_id;

View File

@ -2596,8 +2596,8 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
Map tmp_filter_order_item = null;
for (Map filter_order_item : filter_order_item_list) {
Long item_src_id = Convert.toLong(filter_order_item.get("item_src_id"));
Long _item_src_id = Convert.toLong(order_item.get("item_src_id"));
String item_src_id = Convert.toStr(filter_order_item.get("item_src_id"));
String _item_src_id = Convert.toStr(order_item.get("item_src_id"));
if (item_src_id != null && ObjectUtil.equal(item_src_id, _item_src_id)) {
tmp_filter_order_item = filter_order_item;
break;
@ -3158,7 +3158,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
shopStoreAnalyticsService.edit(analytics);
Integer order_item_inventory_lock = order_item_row.getOrder_item_inventory_lock();
Long item_src_id = order_item_row.getItem_src_id();
String item_src_id = order_item_row.getItem_src_id();
if (ObjectUtil.equal(1002, order_item_inventory_lock) && CheckUtil.isEmpty(item_src_id)) {
Long item_id = order_item_row.getItem_id();
if (shopProductItemService.lockSkuStock(item_id, order_item_row.getOrder_item_quantity()) <= 0) {
@ -4911,7 +4911,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
List<ShopProductItem> product_item_rows = shopProductItemService.find(productItemQueryWrapper);
for (ShopProductItem product_item_row : product_item_rows) {
Long item_src_id = product_item_row.getItem_src_id();
String item_src_id = product_item_row.getItem_src_id();
Optional<ShopOrderItem> orderItemOpl = order_item_rows.stream().filter(s -> ObjectUtil.equal(s.getItem_id(), item_src_id)).findFirst();
if (orderItemOpl.isPresent()) {
ShopOrderItem shopOrderItem = orderItemOpl.get();
@ -5548,7 +5548,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
// end 剔除已出库/发货的商品
}
List<Long> item_src_ids = order_item_rows.stream().map(s -> s.getItem_src_id()).distinct().collect(Collectors.toList());
List<String> item_src_ids = order_item_rows.stream().map(s -> s.getItem_src_id()).distinct().collect(Collectors.toList());
if (CollUtil.isNotEmpty(item_src_ids)) {
List item_rows = new ArrayList();
@ -5580,7 +5580,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
}
for (ShopOrderItem item_row : order_item_rows) {
Long item_src_id = item_row.getItem_src_id();
String item_src_id = item_row.getItem_src_id();
if (CheckUtil.isNotEmpty(item_src_id)) {
HashMap tmp = new HashMap();
tmp.put("item_id", item_row.getItem_src_id());
@ -6613,9 +6613,9 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
Long product_id = Convert.toLong(_item.get("product_id"));
Long item_id = Convert.toLong(_item.get("item_id"));
Long item_src_id = Convert.toLong(_item.get("item_src_id")); // 商品 SKU id
String item_src_id = Convert.toStr(_item.get("item_src_id")); // 商品 SKU id
if (CheckUtil.isEmpty(item_src_id)) {
item_src_id = item_id;
item_src_id = String.valueOf(item_id);
}
String product_item_name = (String) _item.get("product_item_name");
@ -7069,7 +7069,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
Long pulse_product_id = (Long) pulse.get("product_id");
Long pulse_item_id = (Long) pulse.get("item_id");
Long pulse_item_src_id = (Long) pulse.get("item_src_id");
String pulse_item_src_id = (String) pulse.get("item_src_id");
Integer pulse_category_id = (Integer) pulse.get("category_id");
String pulse_product_item_name = (String) pulse.get("product_item_name");
String pulse_cart_file = (String) pulse.get("cart_file");

View File

@ -2135,7 +2135,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
if (shopOrderItem == null) {
throw new ApiException(I18nUtil._("源订单商品信息不存在!"));
}
Long itemSrcId = shopOrderItem.getItem_src_id();
String itemSrcId = shopOrderItem.getItem_src_id();
QueryWrapper<ShopOrderItem> orderItemQueryWrapper = new QueryWrapper<>();
orderItemQueryWrapper.eq("item_id", itemSrcId);
orderItemQueryWrapper.eq("src_order_id", order_id);

View File

@ -64,11 +64,11 @@ import com.suisung.mall.shop.product.pojo.vo.ProductVo;
import com.suisung.mall.shop.product.service.*;
import com.suisung.mall.shop.sixun.service.SxSyncGoodsService;
import com.suisung.mall.shop.store.service.*;
import com.suisung.mall.shop.sync.keymanage.RedisKey;
import com.suisung.mall.shop.sync.service.ProductMappingService;
import com.suisung.mall.shop.sync.service.StoreDbConfigService;
import com.suisung.mall.shop.user.service.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.utils.CloneUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -87,7 +87,10 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
@ -502,6 +505,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
BigDecimal item_sales_rate = Convert.toBigDecimal(productItemMap.get("item_sales_rate"));
if (item_id != null) item.setItem_id(item_id);
item.setItem_src_id(String.valueOf(item_id));
item.setItem_number(item_number);
item.setItem_enable(item_enable);
item.setItem_barcode(item_barcode);
@ -1311,7 +1315,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
if (CollUtil.isNotEmpty($product_item_rows)) {
for (ShopProductItem $product_item_row : $product_item_rows) {
if (dist_copy) {
$product_item_row.setItem_src_id($product_item_row.getItem_id());
$product_item_row.setItem_src_id(String.valueOf($product_item_row.getItem_id()));
}
$product_item_row.setItem_cost_price($product_item_row.getItem_unit_price());
@ -2972,6 +2976,18 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
});
}
}
boolean openCount=getParameter("openCount",false);//1是开启0是不开启
if(openCount){
ShopProductIndex shopProductIndex=new ShopProductIndex();
shopProductIndex.setCategory_id(category_id);
shopProductIndex.setStore_id(store_id);
Integer[] countArrays= countShopIndex(shopProductIndex);
data.put("allRecords",countArrays[0]);//全部
data.put("normalRecords",countArrays[1]);//销售中
data.put("offRecords",countArrays[2]);//仓库中
data.put("illegalRecords",countArrays[3]);//违规禁售
data.put("unCheckedRecords",countArrays[4]);//未分配或者待审核
}
return data;
}
}
@ -4682,12 +4698,12 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
throw new ApiException(I18nUtil._("产品Item集合为空!"));
}
Map<Long, ShopProductItem> oneProductItemMap = oneProductItems.stream().collect(Collectors.toMap(ShopProductItem::getItem_src_id, ShopProductItem -> ShopProductItem, (k1, k2) -> k1));
Map<String, ShopProductItem> oneProductItemMap = oneProductItems.stream().collect(Collectors.toMap(ShopProductItem::getItem_src_id, ShopProductItem -> ShopProductItem, (k1, k2) -> k1));
if ($productItemMap.size() != oneProductItemMap.size()) {
putDown = true;
} else {
for (Long item_src_id : oneProductItemMap.keySet()) {
for (String item_src_id : oneProductItemMap.keySet()) {
ShopProductItem $productItem = $productItemMap.get(item_src_id);
if ($productItem == null) {
@ -4877,9 +4893,9 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
throw new ApiException(I18nUtil._("产品Item集合为空!"));
}
Map<Long, ShopProductItem> productItemMap = shopProductItems.stream().collect(Collectors.toMap(ShopProductItem::getItem_src_id, ShopProductItem -> ShopProductItem, (k1, k2) -> k1));
Map<String, ShopProductItem> productItemMap = shopProductItems.stream().collect(Collectors.toMap(ShopProductItem::getItem_src_id, ShopProductItem -> ShopProductItem, (k1, k2) -> k1));
for (Long item_src_id : productItemMap.keySet()) {
for (String item_src_id : productItemMap.keySet()) {
ShopProductItem $productItem = $productItemMap.get(item_src_id);
if ($productItem == null) {
@ -4897,7 +4913,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
newProductItem.setVersion(productItem.getVersion());
}
newProductItem.setItem_src_id(newProductItem.getItem_id());
newProductItem.setItem_src_id(String.valueOf(newProductItem.getItem_id()));
newProductItem.setItem_cost_price(newProductItem.getItem_unit_price());
newProductItem.setStore_id(store_id);
newProductItem.setProduct_id(product_id);
@ -6128,5 +6144,77 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
return resultMap;
}
//计算全部销售中仓库中违规禁销未分配商品的数量
public Integer[] countShopIndex(ShopProductIndex shopProductIndex) {
//商品状态:1001-正常;1002-下架仓库中;1003-待审核; 1000-违规禁售,1003
int taskCount = 5;
CompletableFuture<Integer> count1 = CompletableFuture.supplyAsync(() -> {
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
if(ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())){
queryWrapper.eq("category_id",shopProductIndex.getCategory_id());
}
queryWrapper.eq("store_id",shopProductIndex.getStore_id());
return ((int) shopProductIndexService.count(queryWrapper));
});
CompletableFuture<Integer> count2 = CompletableFuture.supplyAsync(() -> {
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
if(ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())){
queryWrapper.eq("category_id",shopProductIndex.getCategory_id());
}
queryWrapper.eq("store_id",shopProductIndex.getStore_id());
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_NORMAL);
return ((int) shopProductIndexService.count(queryWrapper));
});
CompletableFuture<Integer> count3 = CompletableFuture.supplyAsync(() -> {
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
if(ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())){
queryWrapper.eq("category_id",shopProductIndex.getCategory_id());
}
queryWrapper.eq("store_id",shopProductIndex.getStore_id());
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_OFF_THE_SHELF);
return ((int) shopProductIndexService.count(queryWrapper));
});
CompletableFuture<Integer> count4 = CompletableFuture.supplyAsync(() -> {
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
if(ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())){
queryWrapper.eq("category_id",shopProductIndex.getCategory_id());
}
queryWrapper.eq("store_id",shopProductIndex.getStore_id());
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_ILLEGAL);
return ((int) shopProductIndexService.count(queryWrapper));
});
CompletableFuture<Integer> count5 = CompletableFuture.supplyAsync(() -> {
QueryWrapper<ShopProductIndex> queryWrapper=new QueryWrapper<>();
if(ObjectUtil.isNotEmpty(shopProductIndex.getCategory_id())){
queryWrapper.eq("category_id",shopProductIndex.getCategory_id());
}
queryWrapper.eq("store_id",shopProductIndex.getStore_id());
queryWrapper.eq("product_state_id",StateCode.PRODUCT_STATE_OFF_THE_SHELF_UNCHECK);
return ((int) shopProductIndexService.count(queryWrapper));
});
// 等待所有任务完成
CompletableFuture<Void> allFutures = CompletableFuture.allOf(count1, count2, count3,count4,count5);
allFutures.thenRun(() -> {
logger.info("所有统计任务完成");
});
Integer[] resultInt=new Integer[taskCount];
try {
resultInt[0]=count1.get();
resultInt[1]=count2.get();
resultInt[2]=count3.get();
resultInt[3]=count4.get();
resultInt[4]=count5.get();
} catch (Exception e) {
throw new RuntimeException(e);
}
return resultInt;
}
public static void main(String[] args) {
AtomicInteger count1=new AtomicInteger(0);//全部
System.out.println(count1.addAndGet(10));
System.out.println(count1);
}
}

View File

@ -2014,7 +2014,7 @@ public class ShopProductItemServiceImpl extends BaseServiceImpl<ShopProductItemM
List<ShopProductItem> item_src_rows = new ArrayList<>();
Boolean supplier_market_enable = accountBaseConfigService.getConfig("supplier_market_enable", false);
if (supplier_market_enable) {
List<Long> item_src_ids = itemList.stream().map(ShopProductItem::getItem_src_id).distinct().collect(Collectors.toList());
List<String> item_src_ids = itemList.stream().map(ShopProductItem::getItem_src_id).distinct().collect(Collectors.toList());
if (CollUtil.isNotEmpty(item_src_ids)) {
item_src_rows = gets(CollUtil.join(item_src_ids, ","));
}
@ -2126,7 +2126,7 @@ public class ShopProductItemServiceImpl extends BaseServiceImpl<ShopProductItemM
item_row.put("item_market_price", NumberUtil.mul(item_market_price, currency_exchange_rate));
// 修正为供应商库存
Long item_src_id = Convert.toLong(item_row.get("item_src_id"));
String item_src_id = Convert.toStr(item_row.get("item_src_id"));
Optional<ShopProductItem> itemOpl = item_src_rows.stream().filter(s -> ObjectUtil.equal(item_src_id, s.getItem_id())).findFirst();
if (itemOpl.isPresent() && CheckUtil.isNotEmpty(item_src_id)) {

View File

@ -382,7 +382,7 @@ public class ProductMappingServiceImpl extends BaseServiceImpl<ProductMappingMap
QueryWrapper<StoreDbConfig> storeDbConfigQueryWrapper = new QueryWrapper<>();
storeDbConfigQueryWrapper.select("priority_mode");
storeDbConfigQueryWrapper.eq("store_id", storeId);
StoreDbConfig storeDbConfig= storeDbConfigService.getOne(storeDbConfigQueryWrapper);
StoreDbConfig storeDbConfig= storeDbConfigService.findOne(storeDbConfigQueryWrapper);
if(null==storeDbConfig){
return CommonResult.failed("同步数据库配置不能为空");
}

View File

@ -788,7 +788,7 @@ public abstract class SyncBaseThirdSxAbstract{
ShopProductItem shopProductItem = new ShopProductItem();
shopProductItem.setStore_id(storeIdInt);
shopProductItem.setCategory_id(categoryId);
shopProductItem.setItem_src_id(jsonObj.getLong("product_number"));
shopProductItem.setItem_src_id(jsonObj.getStr("product_number"));
//零售价
shopProductItem.setItem_unit_price(BigDecimal.valueOf(jsonObj.getDouble("retail_price")));
shopProductItem.setItem_advice_price(BigDecimal.valueOf(jsonObj.getDouble("retail_price")));

View File

@ -0,0 +1 @@
alter table shop_product_item modify `item_src_id` varchar(50) NOT NULL DEFAULT '0' COMMENT '供应商SKU编号';