v1.0.37 #49
@@ -68,6 +68,14 @@ public class GaoSalesOrderItem extends UUIDEntity {
|
|||||||
/// 基础单位数量系数快照
|
/// 基础单位数量系数快照
|
||||||
private BigDecimal baseQuantityPerUnitSnapshot;
|
private BigDecimal baseQuantityPerUnitSnapshot;
|
||||||
|
|
||||||
|
/// 当前 SKU 是否允许业务数量保留小数
|
||||||
|
@Transient
|
||||||
|
private Boolean allowDecimalQuantity;
|
||||||
|
|
||||||
|
/// 当前 SKU 基础单位名称
|
||||||
|
@Transient
|
||||||
|
private String baseUnitName;
|
||||||
|
|
||||||
/// 购买数量
|
/// 购买数量
|
||||||
private BigDecimal quantity;
|
private BigDecimal quantity;
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,12 @@ import java.util.List;
|
|||||||
/// @since 2026-09-06
|
/// @since 2026-09-06
|
||||||
public interface GaoProductSkuMapper extends BaseMapper<GaoProductSku, String> {
|
public interface GaoProductSkuMapper extends BaseMapper<GaoProductSku, String> {
|
||||||
|
|
||||||
|
/// 批量查询 SKU
|
||||||
|
///
|
||||||
|
/// @param idList SKU ID 集合
|
||||||
|
/// @return SKU 列表
|
||||||
|
List<GaoProductSku> selectByIdList(@Param("idList") Collection<String> idList);
|
||||||
|
|
||||||
/// 按产品查询 SKU
|
/// 按产品查询 SKU
|
||||||
List<GaoProductSku> selectByProductId(@Param("productId") String productId);
|
List<GaoProductSku> selectByProductId(@Param("productId") String productId);
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,12 @@ import java.util.List;
|
|||||||
/// @since 2026-09-06
|
/// @since 2026-09-06
|
||||||
public interface GaoProductSkuService extends BaseService<GaoProductSku, String> {
|
public interface GaoProductSkuService extends BaseService<GaoProductSku, String> {
|
||||||
|
|
||||||
|
/// 批量查询 SKU
|
||||||
|
///
|
||||||
|
/// @param idList SKU ID 集合
|
||||||
|
/// @return SKU 列表,包含单位、规格和附件临时数据
|
||||||
|
List<GaoProductSku> listByIdList(Collection<String> idList);
|
||||||
|
|
||||||
/// 查询 SKU 详情
|
/// 查询 SKU 详情
|
||||||
GaoProductSku detail(String id);
|
GaoProductSku detail(String id);
|
||||||
|
|
||||||
|
|||||||
+10
@@ -76,6 +76,16 @@ public class GaoProductSkuServiceImplement extends AbstractEntityService<GaoProd
|
|||||||
return sku;
|
return sku;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<GaoProductSku> listByIdList(Collection<String> idList) {
|
||||||
|
if (idList == null || idList.isEmpty()) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
List<GaoProductSku> result = mapper.selectByIdList(idList);
|
||||||
|
fillTransient(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GaoProductSku> listByProductId(String productId) {
|
public List<GaoProductSku> listByProductId(String productId) {
|
||||||
TimiException.required(productId, "not found productId");
|
TimiException.required(productId, "not found productId");
|
||||||
|
|||||||
+32
@@ -115,6 +115,7 @@ public class GaoSalesOrderServiceImplement extends AbstractEntityService<GaoSale
|
|||||||
TimiException.required(order, "not found sales order");
|
TimiException.required(order, "not found sales order");
|
||||||
storeScopeService.checkStoreId(order.getStoreId());
|
storeScopeService.checkStoreId(order.getStoreId());
|
||||||
List<GaoSalesOrderItem> itemList = itemMapper.selectBySalesOrderId(order.getId());
|
List<GaoSalesOrderItem> itemList = itemMapper.selectBySalesOrderId(order.getId());
|
||||||
|
fillItemDisplayInfo(itemList);
|
||||||
for (GaoSalesOrderItem item : itemList) {
|
for (GaoSalesOrderItem item : itemList) {
|
||||||
fillItemBalance(item);
|
fillItemBalance(item);
|
||||||
}
|
}
|
||||||
@@ -562,6 +563,37 @@ public class GaoSalesOrderServiceImplement extends AbstractEntityService<GaoSale
|
|||||||
item.setRemainingBaseQuantity(baseQuantity.subtract(fulfilledBaseQuantity));
|
item.setRemainingBaseQuantity(baseQuantity.subtract(fulfilledBaseQuantity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 填充订单项数量展示所需的 SKU 信息
|
||||||
|
///
|
||||||
|
/// @param itemList 订单项列表
|
||||||
|
private void fillItemDisplayInfo(List<GaoSalesOrderItem> itemList) {
|
||||||
|
if (itemList == null || itemList.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<String> skuIdList = itemList.stream()
|
||||||
|
.map(GaoSalesOrderItem::getSkuId)
|
||||||
|
.filter(value -> value != null && !value.isBlank())
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
|
if (skuIdList.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<String, GaoProductSku> skuMap = skuService.listByIdList(skuIdList).stream()
|
||||||
|
.collect(java.util.stream.Collectors.toMap(GaoProductSku::getId, java.util.function.Function.identity()));
|
||||||
|
for (GaoSalesOrderItem item : itemList) {
|
||||||
|
GaoProductSku sku = skuMap.get(item.getSkuId());
|
||||||
|
if (sku == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
item.setAllowDecimalQuantity(sku.getAllowDecimalQuantity());
|
||||||
|
item.setBaseUnitName(sku.getUnitList().stream()
|
||||||
|
.filter(unit -> Boolean.TRUE.equals(unit.getIsBase()))
|
||||||
|
.map(GaoProductSkuUnit::getName)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void fillItemAttachments(List<GaoSalesOrderItem> itemList) {
|
private void fillItemAttachments(List<GaoSalesOrderItem> itemList) {
|
||||||
if (itemList == null || itemList.isEmpty()) {
|
if (itemList == null || itemList.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
<mapper namespace="com.imyeyu.api.modules.gao.mapper.GaoProductSkuMapper">
|
<mapper namespace="com.imyeyu.api.modules.gao.mapper.GaoProductSkuMapper">
|
||||||
|
<select id="selectByIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoProductSku">
|
||||||
|
SELECT * FROM `gao_product_sku` WHERE `deleted_at` IS NULL
|
||||||
|
<choose><when test="idList != null and !idList.isEmpty()">AND `id` IN <foreach collection="idList" item="id" open="(" separator="," close=")">#{id}</foreach></when><otherwise>AND FALSE</otherwise></choose>
|
||||||
|
ORDER BY `id`
|
||||||
|
</select>
|
||||||
<select id="selectByProductId" resultType="com.imyeyu.api.modules.gao.entity.GaoProductSku">
|
<select id="selectByProductId" resultType="com.imyeyu.api.modules.gao.entity.GaoProductSku">
|
||||||
SELECT * FROM `gao_product_sku` WHERE `product_id` = #{productId} AND `deleted_at` IS NULL ORDER BY `sort`, `created_at`
|
SELECT * FROM `gao_product_sku` WHERE `product_id` = #{productId} AND `deleted_at` IS NULL ORDER BY `sort`, `created_at`
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
Reference in New Issue
Block a user