|
@@ -670,6 +670,15 @@
|
|
|
<if test="customerId != null and customerId != ''">
|
|
|
AND too.old_customer_id = #{customerId}
|
|
|
</if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND too.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="businessName != null and businessName != ''">
|
|
|
+ AND (SELECT COUNT(DISTINCT oog.order_sn) FROM top_old_order_goods oog WHERE too.order_sn = oog.order_sn AND INSTR(oog.business_full_name,#{businessName}) ) > 0
|
|
|
+ </if>
|
|
|
+ <if test="customerName != null and customerName != ''">
|
|
|
+ AND too.purchase_org LIKE CONCAT('%',#{customerName},'%')
|
|
|
+ </if>
|
|
|
GROUP BY
|
|
|
too.old_customer_id UNION ALL
|
|
|
SELECT
|
|
@@ -693,6 +702,24 @@
|
|
|
<if test="customerId != null and customerId != ''">
|
|
|
AND o.tenant_id = #{customerId}
|
|
|
</if>
|
|
|
+ <if test="businessName != null and businessName != ''">
|
|
|
+ AND (
|
|
|
+ SELECT
|
|
|
+ COUNT(DISTINCT og.order_sn)
|
|
|
+ FROM order_goods og
|
|
|
+ LEFT JOIN goods g ON og.goods_id = g.goods_id
|
|
|
+ LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
|
|
|
+ LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
|
|
|
+ LEFT JOIN course_business cb ON g.business_id = cb.id
|
|
|
+ WHERE o.order_sn = og.order_sn
|
|
|
+ AND INSTR(CONCAT(cet.education_name,cpt.project_name,cb.business_name),#{businessName}) ) > 0
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND o.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="customerName != null and customerName != ''">
|
|
|
+ AND (SELECT COUNT(s.tenant_id) FROM sys_tenant s WHERE o.tenant_id = s.tenant_id AND s.tenant_name LIKE CONCAT('%',#{customerName},'%')) > 0
|
|
|
+ </if>
|
|
|
GROUP BY
|
|
|
o.tenant_id
|
|
|
) a
|
|
@@ -775,6 +802,15 @@
|
|
|
<if test="customerId != null and customerId != ''">
|
|
|
AND too.old_customer_id = #{customerId}
|
|
|
</if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND too.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="businessName != null and businessName != ''">
|
|
|
+ AND (SELECT COUNT(DISTINCT oog.order_sn) FROM top_old_order_goods oog WHERE too.order_sn = oog.order_sn AND INSTR(oog.business_full_name,#{businessName}) ) > 0
|
|
|
+ </if>
|
|
|
+ <if test="customerName != null and customerName != ''">
|
|
|
+ AND too.purchase_org LIKE CONCAT('%',#{customerName},'%')
|
|
|
+ </if>
|
|
|
GROUP BY
|
|
|
too.old_customer_id UNION ALL
|
|
|
SELECT
|
|
@@ -798,6 +834,24 @@
|
|
|
<if test="customerId != null and customerId != ''">
|
|
|
AND o.tenant_id = #{customerId}
|
|
|
</if>
|
|
|
+ <if test="businessName != null and businessName != ''">
|
|
|
+ AND (
|
|
|
+ SELECT
|
|
|
+ COUNT(DISTINCT og.order_sn)
|
|
|
+ FROM order_goods og
|
|
|
+ LEFT JOIN goods g ON og.goods_id = g.goods_id
|
|
|
+ LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
|
|
|
+ LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
|
|
|
+ LEFT JOIN course_business cb ON g.business_id = cb.id
|
|
|
+ WHERE o.order_sn = og.order_sn
|
|
|
+ AND INSTR(CONCAT(cet.education_name,cpt.project_name,cb.business_name),#{businessName}) ) > 0
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND o.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="customerName != null and customerName != ''">
|
|
|
+ AND (SELECT COUNT(s.tenant_id) FROM sys_tenant s WHERE o.tenant_id = s.tenant_id AND s.tenant_name LIKE CONCAT('%',#{customerName},'%')) > 0
|
|
|
+ </if>
|
|
|
GROUP BY
|
|
|
o.tenant_id
|
|
|
) a
|
|
@@ -845,12 +899,12 @@
|
|
|
) num_total
|
|
|
</select>
|
|
|
|
|
|
- <select id="getDetailStatisticsTotal" parameterType="java.lang.Long"
|
|
|
+ <select id="getDetailStatisticsTotal" parameterType="com.zhongzheng.modules.top.order.bo.TopDetailStatisticsTotal"
|
|
|
resultType="com.zhongzheng.modules.top.order.vo.TopOrderStatisticsDetailTotalVo">
|
|
|
SELECT
|
|
|
((
|
|
|
SELECT
|
|
|
- SUM( too.order_received - too.order_refunded ) AS money
|
|
|
+ IFNULL(SUM( too.order_received - too.order_refunded ),0) AS money
|
|
|
FROM
|
|
|
top_old_order too
|
|
|
WHERE
|
|
@@ -863,9 +917,21 @@
|
|
|
<if test="endTime != null and endTime != ''">
|
|
|
AND too.check_time <= #{endTime}
|
|
|
</if>
|
|
|
+ <if test="customerId != null and customerId != ''">
|
|
|
+ AND too.old_customer_id = #{customerId}
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND too.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="businessName != null and businessName != ''">
|
|
|
+ AND (SELECT COUNT(DISTINCT oog.order_sn) FROM top_old_order_goods oog WHERE too.order_sn = oog.order_sn AND INSTR(oog.business_full_name,#{businessName}) ) > 0
|
|
|
+ </if>
|
|
|
+ <if test="customerName != null and customerName != ''">
|
|
|
+ AND too.purchase_org LIKE CONCAT('%',#{customerName},'%')
|
|
|
+ </if>
|
|
|
) + (
|
|
|
SELECT
|
|
|
- SUM( o.pay_price ) AS money
|
|
|
+ IFNULL(SUM( o.pay_price ),0) AS money
|
|
|
FROM
|
|
|
`order` o
|
|
|
WHERE
|
|
@@ -880,6 +946,27 @@
|
|
|
<if test="endTime != null and endTime != ''">
|
|
|
AND o.create_time <= #{endTime}
|
|
|
</if>
|
|
|
+ <if test="customerId != null and customerId != ''">
|
|
|
+ AND o.tenant_id = #{customerId}
|
|
|
+ </if>
|
|
|
+ <if test="businessName != null and businessName != ''">
|
|
|
+ AND (
|
|
|
+ SELECT
|
|
|
+ COUNT(DISTINCT og.order_sn)
|
|
|
+ FROM order_goods og
|
|
|
+ LEFT JOIN goods g ON og.goods_id = g.goods_id
|
|
|
+ LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
|
|
|
+ LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
|
|
|
+ LEFT JOIN course_business cb ON g.business_id = cb.id
|
|
|
+ WHERE o.order_sn = og.order_sn
|
|
|
+ AND INSTR(CONCAT(cet.education_name,cpt.project_name,cb.business_name),#{businessName}) ) > 0
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND o.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="customerName != null and customerName != ''">
|
|
|
+ AND (SELECT COUNT(s.tenant_id) FROM sys_tenant s WHERE o.tenant_id = s.tenant_id AND s.tenant_name LIKE CONCAT('%',#{customerName},'%')) > 0
|
|
|
+ </if>
|
|
|
)) moneyTotal,
|
|
|
((
|
|
|
SELECT
|
|
@@ -896,6 +983,18 @@
|
|
|
<if test="endTime != null and endTime != ''">
|
|
|
AND too.check_time <= #{endTime}
|
|
|
</if>
|
|
|
+ <if test="customerId != null and customerId != ''">
|
|
|
+ AND too.old_customer_id = #{customerId}
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND too.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="businessName != null and businessName != ''">
|
|
|
+ AND (SELECT COUNT(DISTINCT oog.order_sn) FROM top_old_order_goods oog WHERE too.order_sn = oog.order_sn AND INSTR(oog.business_full_name,#{businessName}) ) > 0
|
|
|
+ </if>
|
|
|
+ <if test="customerName != null and customerName != ''">
|
|
|
+ AND too.purchase_org LIKE CONCAT('%',#{customerName},'%')
|
|
|
+ </if>
|
|
|
) + (
|
|
|
SELECT
|
|
|
COUNT(o.order_id) AS orderNum
|
|
@@ -913,6 +1012,27 @@
|
|
|
<if test="endTime != null and endTime != ''">
|
|
|
AND o.create_time <= #{endTime}
|
|
|
</if>
|
|
|
+ <if test="customerId != null and customerId != ''">
|
|
|
+ AND o.tenant_id = #{customerId}
|
|
|
+ </if>
|
|
|
+ <if test="businessName != null and businessName != ''">
|
|
|
+ AND (
|
|
|
+ SELECT
|
|
|
+ COUNT(DISTINCT og.order_sn)
|
|
|
+ FROM order_goods og
|
|
|
+ LEFT JOIN goods g ON og.goods_id = g.goods_id
|
|
|
+ LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
|
|
|
+ LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
|
|
|
+ LEFT JOIN course_business cb ON g.business_id = cb.id
|
|
|
+ WHERE o.order_sn = og.order_sn
|
|
|
+ AND INSTR(CONCAT(cet.education_name,cpt.project_name,cb.business_name),#{businessName}) ) > 0
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND o.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="customerName != null and customerName != ''">
|
|
|
+ AND (SELECT COUNT(s.tenant_id) FROM sys_tenant s WHERE o.tenant_id = s.tenant_id AND s.tenant_name LIKE CONCAT('%',#{customerName},'%')) > 0
|
|
|
+ </if>
|
|
|
)) orderNumTotal
|
|
|
</select>
|
|
|
|