下单库存校验

This commit is contained in:
2026-04-10 16:57:30 +08:00
parent 0e600d76f8
commit 3fe532ee7d
5 changed files with 71 additions and 207 deletions

View File

@@ -45,39 +45,6 @@
where id = #{orderId};
</update>
<select id="getHandoverCashAmount" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(t1.pay_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
and t1.pay_type = 'cash_pay'
</where>
</select>
<select id="getHandoverRefundAmount" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(t1.refund_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
</where>
</select>
<select id="getHandoverTotalAmount" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(t1.pay_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
</where>
</select>
<select id="getHandoverOrderNum" resultType="java.lang.Integer">
SELECT
count(*)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
</where>
</select>
<select id="getHandoverDetailList" resultType="com.czg.account.vo.HandoverProductListVo">
SELECT
t2.product_id,
@@ -96,53 +63,7 @@
t2.product_id,
t2.sku_id
</select>
<select id="getHandoverWechatAmount" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(t1.pay_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
and t1.pay_type = 'wechat_mini'
</where>
</select>
<select id="getHandoverAlipayAmount" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(t1.pay_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
and t1.pay_type = 'alipay_mini'
</where>
</select>
<select id="getHandoverVipPayAmount" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(t1.pay_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
and t1.pay_type = 'vip_pay'
</where>
</select>
<select id="getHandoverVipChargeAmount" resultType="java.math.BigDecimal">
select ifnull(sum(t1.amount), 0)
from tb_shop_user_flow t1
where t1.shop_id = #{shopId}
and t1.biz_code in ('cashIn', 'wechatIn', 'alipayIn', 'adminIn')
and t1.recharge_id is not null
<![CDATA[
AND t1.create_time >= str_to_date(#{loginTime}, '%Y-%m-%d %H:%i:%s')
AND t1.create_time <= str_to_date(#{handoverTime}, '%Y-%m-%d %H:%i:%s')
]]>
</select>
<select id="getHandoverQuickPayAmount" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(pay_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
and t1.pay_type in ('main_scan','back_scan')
</where>
</select>
<select id="getHandoverCategoryList" resultType="com.czg.account.vo.HandoverCategoryListVo">
SELECT case when t3.category_id is null then 0 else t3.category_id end as category_id,
case when t4.name is null then '未分类' else t4.name end as category_name,
@@ -158,14 +79,24 @@
</where>
GROUP BY t3.category_id
</select>
<select id="getHandoverCreditAmount" resultType="java.math.BigDecimal">
<select id="getConsByProductAndNum" resultType="com.czg.product.vo.ConsStockRecord">
SELECT
ifnull(sum(t1.pay_amount),0)
FROM tb_order_info t1
<where>
<include refid="handoverCommonWhere"/>
and t1.pay_type = 'credit_pay'
</where>
r.cons_info_id AS consId,
SUM(
CASE r.product_id
<foreach collection="productUsageMap.entrySet()" item="qty" index="pid">
WHEN #{pid} THEN #{qty}
</foreach>
END
) AS stockNumber
FROM tb_prod_cons_relation r
WHERE r.product_id IN
<foreach collection="productUsageMap.keySet()" item="pid" open="(" separator="," close=")">
#{pid}
</foreach>
GROUP BY r.cons_info_id
</select>
</mapper>