feat: can fulfillment sku order filter
This commit is contained in:
+24
@@ -16,6 +16,7 @@ import com.imyeyu.api.modules.gao.entity.GaoProductSkuUnit;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoSalesOrder;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoSalesOrderItem;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoStore;
|
||||
import com.imyeyu.api.modules.gao.mapper.GaoProductSkuUnitMapper;
|
||||
import com.imyeyu.api.modules.gao.mapper.GaoSalesOrderItemMapper;
|
||||
import com.imyeyu.api.modules.gao.mapper.GaoSalesOrderMapper;
|
||||
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
||||
@@ -92,6 +93,7 @@ public class GaoSalesOrderServiceImplement extends AbstractEntityService<GaoSale
|
||||
|
||||
private final GaoSalesOrderMapper mapper;
|
||||
private final GaoSalesOrderItemMapper itemMapper;
|
||||
private final GaoProductSkuUnitMapper skuUnitMapper;
|
||||
private final GaoFundRecordService fundRecordService;
|
||||
private final ObjectProvider<GaoOrderFulfillmentService> fulfillmentServiceProvider;
|
||||
private final ObjectProvider<GaoOrderPaymentService> paymentServiceProvider;
|
||||
@@ -120,6 +122,7 @@ public class GaoSalesOrderServiceImplement extends AbstractEntityService<GaoSale
|
||||
result.setTotal(mapper.countByQuery(page));
|
||||
List<GaoSalesOrder> list = mapper.selectByQuery(page);
|
||||
fillItemList(list);
|
||||
fillFilteredSkuBaseUnit(list, page.getFulfillableSkuId());
|
||||
fillCustomer(list);
|
||||
result.setList(list);
|
||||
return result;
|
||||
@@ -801,6 +804,27 @@ public class GaoSalesOrderServiceImplement extends AbstractEntityService<GaoSale
|
||||
fillItemAttachments(itemList);
|
||||
}
|
||||
|
||||
/// 为筛选出的 SKU 填充基础单位,整页只查询一次
|
||||
///
|
||||
/// @param orderList 当前页订单
|
||||
/// @param skuId 筛选的 SKU ID
|
||||
private void fillFilteredSkuBaseUnit(List<GaoSalesOrder> orderList, String skuId) {
|
||||
if (orderList == null || orderList.isEmpty() || skuId == null || skuId.isBlank()) {
|
||||
return;
|
||||
}
|
||||
String baseUnitName = skuUnitMapper.selectBySkuId(skuId).stream()
|
||||
.filter(unit -> Boolean.TRUE.equals(unit.getIsBase()))
|
||||
.map(GaoProductSkuUnit::getName)
|
||||
.findFirst().orElse(null);
|
||||
for (GaoSalesOrder order : orderList) {
|
||||
for (GaoSalesOrderItem item : order.getItemList()) {
|
||||
if (skuId.equals(item.getSkuId())) {
|
||||
item.setBaseUnitName(baseUnitName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 填充订单项履约余额投影
|
||||
///
|
||||
/// @param item 订单项
|
||||
|
||||
@@ -24,6 +24,9 @@ public class GaoSalesOrderPage extends BasePage {
|
||||
/// 套餐配置 ID
|
||||
private String packageConfigId;
|
||||
|
||||
/// 筛选存在可履约明细的 SKU ID
|
||||
private String fulfillableSkuId;
|
||||
|
||||
/// 订单类型
|
||||
private GaoSalesOrder.OrderType orderType;
|
||||
|
||||
|
||||
@@ -23,6 +23,15 @@
|
||||
o.`deleted_at` IS NULL
|
||||
<if test="storeId != null and storeId != ''">AND o.`store_id` = #{storeId}</if>
|
||||
<if test="customerId != null and customerId != ''">AND o.`customer_id` = #{customerId}</if>
|
||||
<if test="fulfillableSkuId != null and fulfillableSkuId != ''">
|
||||
AND o.`status` <> 'CANCELLED'
|
||||
AND EXISTS (
|
||||
SELECT 1 FROM `gao_sales_order_item` i
|
||||
WHERE i.`sales_order_id` = o.`id` AND i.`deleted_at` IS NULL
|
||||
AND i.`sku_id` = #{fulfillableSkuId}
|
||||
AND COALESCE(i.`fulfilled_base_quantity`, 0) + COALESCE(i.`reserved_base_quantity`, 0) < COALESCE(i.`base_quantity`, 0)
|
||||
)
|
||||
</if>
|
||||
<if test="packageConfigId != null and packageConfigId != ''">
|
||||
AND EXISTS (
|
||||
SELECT 1 FROM `gao_customer_package` cp
|
||||
|
||||
Reference in New Issue
Block a user