⚡ 优化毛利分析订单查询
This commit is contained in:
@@ -116,10 +116,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
-->
|
||||
</resultMap>
|
||||
|
||||
<select id="selectAreaCustomerIds" resultType="long">
|
||||
select customer_id
|
||||
from ctr_customer
|
||||
where customer_area = #{customerArea} and del_flag = '0'
|
||||
limit #{limit}
|
||||
</select>
|
||||
|
||||
<sql id="profitReportFromAndWhere">
|
||||
from prc_income_bill i
|
||||
inner join prc_order_bill p on p.bill_id = i.bill_id
|
||||
<if test="customerArea != null and customerArea != ''">
|
||||
<if test="areaCustomerIds == null and customerArea != null and customerArea != ''">
|
||||
left join ctr_customer c on c.customer_id = p.customer_id and c.del_flag = '0'
|
||||
</if>
|
||||
<!-- 提成表关联暂停使用,毛利报表不再依赖提成配置。
|
||||
@@ -129,9 +136,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<where>
|
||||
<!-- 不将未匹配产品、国家或重量段的计费失败订单纳入毛利报表;保留历史空值(按成功处理)。 -->
|
||||
and (p.billing_fail_status is null or p.billing_fail_status not in (1, 2, 3))
|
||||
<if test="customerArea != null and customerArea != ''">
|
||||
and c.customer_area = #{customerArea}
|
||||
</if>
|
||||
<choose>
|
||||
<when test="areaCustomerIds != null and areaCustomerIds.size() > 0">
|
||||
and p.customer_id in
|
||||
<foreach collection="areaCustomerIds" item="customerId" open="(" separator="," close=")">
|
||||
#{customerId}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test="areaCustomerIds != null">
|
||||
and 1 = 0
|
||||
</when>
|
||||
<when test="customerArea != null and customerArea != ''">
|
||||
and c.customer_area = #{customerArea}
|
||||
</when>
|
||||
</choose>
|
||||
<if test="beginBizDate != null">
|
||||
and p.biz_date >= #{beginBizDate}
|
||||
</if>
|
||||
@@ -251,7 +269,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="arBillStatus != null and arBillStatus != '' and productDrilldown != true">
|
||||
and p.ar_bill_status = #{arBillStatus}
|
||||
</if>
|
||||
order by p.biz_date desc, p.bill_id desc
|
||||
</select>
|
||||
|
||||
<!-- 汇总和产品维度使用同一套逐单有效数据计算,毛利率按有效销售额加权。 -->
|
||||
|
||||
Reference in New Issue
Block a user