|
@@ -833,44 +833,121 @@
|
|
|
FROM
|
|
|
(
|
|
|
SELECT
|
|
|
- tenant_id,
|
|
|
- SUM( order_received - order_refunded ) money
|
|
|
+ allu.tenant_id,
|
|
|
+ SUM( allu.money2 ) money
|
|
|
<if test="tenantId != null and tenantId != ''">
|
|
|
- , create_no,any_value(create_username) as create_username
|
|
|
+ , allu.create_no,allu.create_username
|
|
|
</if>
|
|
|
FROM
|
|
|
- v_top_order
|
|
|
- WHERE
|
|
|
- 1 = 1
|
|
|
- AND `status` = 1
|
|
|
- AND check_status = 1
|
|
|
- AND check_time BETWEEN #{startTime}
|
|
|
- AND #{endTime}
|
|
|
- <if test="tenantId != null and tenantId != ''">
|
|
|
- AND tenant_id = #{tenantId}
|
|
|
- </if>
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ tenant_id,
|
|
|
+ SUM( order_received - order_refunded ) money2
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ , create_no,any_value(create_username) as create_username
|
|
|
+ </if>
|
|
|
+ FROM
|
|
|
+ top_old_order
|
|
|
+ WHERE
|
|
|
+ 1 = 1
|
|
|
+ AND `status` = 1
|
|
|
+ AND check_status = 1
|
|
|
+ AND old_customer_id IS NOT NULL
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
+ AND check_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND check_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ tenant_id
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ , create_no
|
|
|
+ </if>
|
|
|
+ UNION ALL
|
|
|
+ SELECT
|
|
|
+ og.tenant_id,
|
|
|
+ IFNULL( SUM( og.goods_received ), 0 ) money2
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ ,'' AS create_no, '' as create_username
|
|
|
+ </if>
|
|
|
+ FROM
|
|
|
+ `order` o
|
|
|
+ LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
|
|
|
+ WHERE
|
|
|
+ o.`status` = 1
|
|
|
+ AND o.order_status = 1
|
|
|
+ AND og.refund_status != 2
|
|
|
+ AND (
|
|
|
+ o.input_order_sn IS NULL
|
|
|
+ OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 1 ) AND o.tenant_id IS NOT NULL
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
+ AND o.create_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND o.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND o.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ AND og.pay_status != 1
|
|
|
+ GROUP BY
|
|
|
+ og.tenant_id
|
|
|
+ ) allu
|
|
|
GROUP BY
|
|
|
- tenant_id
|
|
|
+ allu.tenant_id
|
|
|
<if test="tenantId != null and tenantId != ''">
|
|
|
- , create_no
|
|
|
+ , allu.create_no,allu.create_username
|
|
|
</if>
|
|
|
ORDER BY
|
|
|
- money DESC
|
|
|
+ money DESC
|
|
|
) vo
|
|
|
LEFT JOIN sys_tenant st ON vo.tenant_id = st.tenant_id
|
|
|
</select>
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
<select id="getSingleTenantStatistics" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
|
|
|
resultType="BigDecimal">
|
|
|
SELECT
|
|
|
- IFNULL(SUM( vo.order_received - vo.order_refunded ),0) money
|
|
|
+ (IFNULL(SUM( vo.order_received - vo.order_refunded ),0)+(
|
|
|
+ SELECT
|
|
|
+ IFNULL(SUM( og.goods_received ),0)
|
|
|
+ FROM
|
|
|
+ `order` o
|
|
|
+ LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
|
|
|
+ WHERE
|
|
|
+ o.`status` = 1
|
|
|
+ AND o.order_status = 1
|
|
|
+ AND og.refund_status != 2
|
|
|
+ AND og.pay_status != 1
|
|
|
+ AND (
|
|
|
+ o.input_order_sn IS NULL
|
|
|
+ OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 1 ) AND o.tenant_id IS NOT NULL
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
+ AND o.create_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND o.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND o.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="createNo != null and createNo != ''">
|
|
|
+ AND 1=0
|
|
|
+ </if>
|
|
|
+ )) money
|
|
|
FROM
|
|
|
- v_top_order vo
|
|
|
+ top_old_order vo
|
|
|
WHERE
|
|
|
1 = 1
|
|
|
AND vo.`status` = 1
|
|
|
AND vo.check_status = 1
|
|
|
+ AND vo.old_customer_id IS NOT NULL
|
|
|
AND vo.check_time BETWEEN #{startTime}
|
|
|
AND #{endTime}
|
|
|
<if test="tenantId != null and tenantId != ''">
|
|
@@ -889,17 +966,26 @@
|
|
|
FROM
|
|
|
(
|
|
|
SELECT
|
|
|
+ allu.tenant_id,
|
|
|
+ SUM(order_num2) order_num
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ , allu.create_no,allu.create_username
|
|
|
+ </if>
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
tenant_id,
|
|
|
- COUNT( * ) order_num
|
|
|
+ COUNT( * ) order_num2
|
|
|
<if test="tenantId != null and tenantId != ''">
|
|
|
, create_no,any_value(create_username) as create_username
|
|
|
</if>
|
|
|
FROM
|
|
|
- v_top_order
|
|
|
+ top_old_order
|
|
|
WHERE
|
|
|
1 = 1
|
|
|
AND `status` = 1
|
|
|
AND check_status = 1
|
|
|
+ AND old_customer_id IS NOT NULL
|
|
|
<if test="startTime != null and startTime != ''">
|
|
|
AND check_time >= #{startTime}
|
|
|
</if>
|
|
@@ -914,6 +1000,41 @@
|
|
|
<if test="tenantId != null and tenantId != ''">
|
|
|
, create_no
|
|
|
</if>
|
|
|
+ UNION ALL
|
|
|
+ SELECT
|
|
|
+ og.tenant_id,
|
|
|
+ COUNT( * ) order_num2
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ ,'' AS create_no, '' as create_username
|
|
|
+ </if>
|
|
|
+ FROM
|
|
|
+ `order` o
|
|
|
+ LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
|
|
|
+ WHERE
|
|
|
+ o.`status` = 1
|
|
|
+ AND o.order_status = 1
|
|
|
+ AND og.refund_status != 2
|
|
|
+ AND (
|
|
|
+ o.input_order_sn IS NULL
|
|
|
+ OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 1 ) AND o.tenant_id IS NOT NULL
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
+ AND o.create_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND o.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND o.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ AND og.pay_status != 1
|
|
|
+ GROUP BY
|
|
|
+ og.tenant_id
|
|
|
+ ) allu
|
|
|
+ GROUP BY
|
|
|
+ allu.tenant_id
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ , allu.create_no,allu.create_username
|
|
|
+ </if>
|
|
|
ORDER BY
|
|
|
order_num DESC
|
|
|
) vo
|
|
@@ -923,13 +1044,37 @@
|
|
|
<select id="getSingleTenantStatisticsOrderNum" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
|
|
|
resultType="java.lang.Long">
|
|
|
SELECT
|
|
|
- IFNULL(COUNT( * ),0)
|
|
|
+ (IFNULL(COUNT( * ),0)+(
|
|
|
+ SELECT
|
|
|
+ IFNULL(COUNT(o.order_id),0) AS orderNum
|
|
|
FROM
|
|
|
- v_top_order
|
|
|
+ `order` o
|
|
|
+ WHERE
|
|
|
+ o.`status` = 1
|
|
|
+ AND o.order_status = 1
|
|
|
+ AND (
|
|
|
+ o.input_order_sn IS NULL
|
|
|
+ OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 1 ) AND o.tenant_id IS NOT NULL
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
+ AND o.create_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND o.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND o.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="createNo != null and createNo != ''">
|
|
|
+ AND 1=0
|
|
|
+ </if>
|
|
|
+ ))
|
|
|
+ FROM
|
|
|
+ top_old_order
|
|
|
WHERE
|
|
|
1 = 1
|
|
|
AND `status` = 1
|
|
|
AND check_status = 1
|
|
|
+ AND old_customer_id IS NOT NULL
|
|
|
<if test="startTime != null and startTime != ''">
|
|
|
AND check_time >= #{startTime}
|
|
|
</if>
|
|
@@ -947,42 +1092,420 @@
|
|
|
<select id="getNumStatisticsTotalWithBo" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
|
|
|
resultType="java.lang.Long">
|
|
|
|
|
|
+
|
|
|
+ SELECT
|
|
|
+ (IFNULL(COUNT(too.order_id),0)+(
|
|
|
SELECT
|
|
|
- IFNULL(COUNT(*),0)
|
|
|
+ IFNULL(COUNT(o.order_id),0) AS orderNum
|
|
|
FROM
|
|
|
- v_top_order
|
|
|
+ `order` o
|
|
|
WHERE
|
|
|
- `status` = 1
|
|
|
- AND check_status = 1
|
|
|
+ o.`status` = 1
|
|
|
+ AND o.order_status = 1
|
|
|
+ AND (
|
|
|
+ o.input_order_sn IS NULL
|
|
|
+ OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 1 ) AND o.tenant_id IS NOT NULL
|
|
|
<if test="startTime != null and startTime != ''">
|
|
|
- AND check_time >= #{startTime}
|
|
|
+ AND o.create_time >= #{startTime}
|
|
|
</if>
|
|
|
<if test="endTime != null and endTime != ''">
|
|
|
- AND check_time <= #{endTime}
|
|
|
+ AND o.create_time <= #{endTime}
|
|
|
</if>
|
|
|
<if test="tenantId != null and tenantId != ''">
|
|
|
- AND tenant_id = #{tenantId}
|
|
|
+ AND o.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ )) AS orderNum
|
|
|
+ FROM
|
|
|
+ top_old_order too
|
|
|
+ WHERE
|
|
|
+ too.`status` = 1
|
|
|
+ AND too.check_status = 1
|
|
|
+ AND too.old_customer_id IS NOT NULL
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
+ AND too.check_time >= #{startTime}
|
|
|
</if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND too.check_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND too.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+
|
|
|
</select>
|
|
|
|
|
|
<select id="getMoneyStatisticsWithBo" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
|
|
|
resultType="java.math.BigDecimal">
|
|
|
|
|
|
SELECT
|
|
|
- IFNULL(SUM( order_received - order_refunded ),0)
|
|
|
+ IFNULL(SUM( too.order_received - too.order_refunded ),0)+ (
|
|
|
+ SELECT
|
|
|
+ IFNULL(SUM( og.goods_received ),0) AS money
|
|
|
FROM
|
|
|
- v_top_order
|
|
|
+ `order` o
|
|
|
+ LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
|
|
|
WHERE
|
|
|
- `status` = 1
|
|
|
- AND check_status = 1
|
|
|
+ o.`status` = 1
|
|
|
+ AND o.order_status = 1
|
|
|
+ AND og.refund_status != 2
|
|
|
+ AND og.pay_status != 1
|
|
|
+ AND (
|
|
|
+ o.input_order_sn IS NULL
|
|
|
+ OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 1 ) AND o.tenant_id IS NOT NULL
|
|
|
<if test="startTime != null and startTime != ''">
|
|
|
- AND check_time >= #{startTime}
|
|
|
+ AND o.create_time >= #{startTime}
|
|
|
</if>
|
|
|
<if test="endTime != null and endTime != ''">
|
|
|
- AND check_time <= #{endTime}
|
|
|
+ AND o.create_time <= #{endTime}
|
|
|
</if>
|
|
|
<if test="tenantId != null and tenantId != ''">
|
|
|
- AND tenant_id = #{tenantId}
|
|
|
+ AND o.tenant_id = #{tenantId}
|
|
|
</if>
|
|
|
+ ) AS money
|
|
|
+ FROM
|
|
|
+ top_old_order too
|
|
|
+ WHERE
|
|
|
+ too.`status` = 1
|
|
|
+ AND too.check_status = 1
|
|
|
+ AND too.old_customer_id IS NOT NULL
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
+ AND too.check_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND too.check_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND too.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getBusinessOrderMoney" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
|
|
|
+ resultType="com.zhongzheng.modules.top.order.vo.TopOrderStatisticsMoneyVo">
|
|
|
+ SELECT
|
|
|
+ allu.business_name,
|
|
|
+ SUM( allu.money ) money
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ ouu.business_name,
|
|
|
+ IFNULL( SUM( oo.order_received - oo.order_refunded ), 0 ) money
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ ou.order_sn,
|
|
|
+ ou.business_name
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ `otg`.`order_sn` AS `order_sn`,
|
|
|
+ concat( substr( `otg`.`business_full_name`, 5, 4 ), '-', `otg`.`business_name` ) AS `business_name`
|
|
|
+ FROM
|
|
|
+ `top_old_order_goods` `otg`
|
|
|
+ ) ou
|
|
|
+ GROUP BY
|
|
|
+ ou.order_sn,
|
|
|
+ ou.business_name
|
|
|
+ ) ouu
|
|
|
+ LEFT JOIN top_old_order oo ON ouu.order_sn = oo.order_sn
|
|
|
+ WHERE
|
|
|
+ oo.`status` = 1
|
|
|
+ AND oo.check_status = 1
|
|
|
+ AND oo.old_customer_id IS NOT NULL
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
+ AND oo.check_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND oo.check_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND oo.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="createNo != null and createNo != ''">
|
|
|
+ AND oo.create_no = #{createNo}
|
|
|
+ </if>
|
|
|
+ <if test="businessName != null and businessName != ''">
|
|
|
+ AND ouu.business_name = #{businessName}
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ ouu.business_name UNION ALL
|
|
|
+ SELECT
|
|
|
+ nou.business_name,
|
|
|
+ SUM( nou.goods_received ) AS money
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ `og`.`order_sn` AS `order_sn`,
|
|
|
+ concat( `cet`.`education_name`, '-', `cb`.`business_name`, `cpt`.`project_name` ) AS `business_name`,
|
|
|
+ og.goods_received
|
|
|
+ FROM
|
|
|
+ ((((
|
|
|
+ `order` o
|
|
|
+ LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
|
|
|
+ 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`.`education_type_id` = `cpt`.`id`
|
|
|
+ )))
|
|
|
+ LEFT JOIN `course_business` `cb` ON ((
|
|
|
+ `g`.`business_id` = `cb`.`id`
|
|
|
+ )))
|
|
|
+ WHERE
|
|
|
+ og.pay_status != 1
|
|
|
+ AND (
|
|
|
+ o.input_order_sn IS NULL
|
|
|
+ OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 1 ) AND o.tenant_id IS NOT NULL
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
+ AND og.create_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND og.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND og.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="createNo != null and createNo != ''">
|
|
|
+ AND 1=0
|
|
|
+ </if>
|
|
|
+ AND og.refund_status != 2
|
|
|
+ ) nou
|
|
|
+ WHERE 1=1
|
|
|
+ <if test="businessName != null and businessName != ''">
|
|
|
+ AND nou.business_name = #{businessName}
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ nou.business_name
|
|
|
+ ) allu
|
|
|
+ GROUP BY
|
|
|
+ allu.business_name
|
|
|
+ ORDER BY
|
|
|
+ money DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getBusinessOrderNum" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
|
|
|
+ resultType="com.zhongzheng.modules.top.order.vo.TopOrderStatisticsNumVo">
|
|
|
+ SELECT
|
|
|
+ allu.business_name,
|
|
|
+ SUM( allu.order_num ) order_num
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ ouu.business_name,
|
|
|
+ IFNULL(COUNT( ouu.order_goods_id ),0) order_num
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ `otg`.`order_sn` AS `order_sn`,
|
|
|
+ `otg`.`order_goods_id` AS `order_goods_id`,
|
|
|
+ concat( substr( `otg`.`business_full_name`, 5, 4 ), '-', `otg`.`business_name` ) AS `business_name`
|
|
|
+ FROM
|
|
|
+ `top_old_order_goods` `otg`
|
|
|
+ ) ouu
|
|
|
+ LEFT JOIN top_old_order oo ON ouu.order_sn = oo.order_sn
|
|
|
+ WHERE
|
|
|
+ oo.`status` = 1
|
|
|
+ AND oo.check_status = 1
|
|
|
+ AND oo.old_customer_id IS NOT NULL
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
+ AND oo.check_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND oo.check_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND oo.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="createNo != null and createNo != ''">
|
|
|
+ AND oo.create_no = #{createNo}
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ ouu.business_name UNION ALL
|
|
|
+ SELECT
|
|
|
+ nou.business_name,
|
|
|
+ COUNT( nou.order_goods_id ) order_num
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ `og`.`order_sn` AS `order_sn`,
|
|
|
+ concat( `cet`.`education_name`, '-', `cb`.`business_name`, `cpt`.`project_name` ) AS `business_name`,
|
|
|
+ og.order_goods_id
|
|
|
+ FROM
|
|
|
+ ((((
|
|
|
+ `order` o
|
|
|
+ LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
|
|
|
+ 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`.`education_type_id` = `cpt`.`id`
|
|
|
+ )))
|
|
|
+ LEFT JOIN `course_business` `cb` ON ((
|
|
|
+ `g`.`business_id` = `cb`.`id`
|
|
|
+ )))
|
|
|
+ WHERE
|
|
|
+ og.pay_status != 1
|
|
|
+ AND og.refund_status != 2
|
|
|
+ AND (
|
|
|
+ o.input_order_sn IS NULL
|
|
|
+ OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 1 ) AND o.tenant_id IS NOT NULL
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
+ AND og.create_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND og.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND og.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="createNo != null and createNo != ''">
|
|
|
+ AND 1=0
|
|
|
+ </if>
|
|
|
+ ) nou
|
|
|
+ GROUP BY
|
|
|
+ nou.business_name
|
|
|
+ ) allu
|
|
|
+ GROUP BY
|
|
|
+ allu.business_name
|
|
|
+ ORDER BY
|
|
|
+ order_num DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="getOrderGoodsNumStatisticsTotalWithBo" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
|
|
|
+ resultType="java.lang.Long">
|
|
|
+
|
|
|
+ SELECT
|
|
|
+ IFNULL(COUNT( og.order_goods_id ),0)+ (
|
|
|
+ SELECT
|
|
|
+ IFNULL(COUNT( otg.order_goods_id ),0) order_num
|
|
|
+ FROM
|
|
|
+ `top_old_order_goods` `otg`
|
|
|
+ LEFT JOIN top_old_order oo ON otg.order_sn = oo.order_sn
|
|
|
+ WHERE
|
|
|
+ oo.`status` = 1
|
|
|
+ AND oo.check_status = 1
|
|
|
+ AND oo.old_customer_id IS NOT NULL
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
+ AND oo.check_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND oo.check_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND oo.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="createNo != null and createNo != ''">
|
|
|
+ AND oo.create_no = #{createNo}
|
|
|
+ </if>
|
|
|
+ )
|
|
|
+ order_num
|
|
|
+ FROM
|
|
|
+ `order` o
|
|
|
+ LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
|
|
|
+ WHERE
|
|
|
+ o.`status` = 1
|
|
|
+ AND o.order_status = 1
|
|
|
+ AND og.refund_status != 2
|
|
|
+ AND og.pay_status != 1
|
|
|
+ AND (
|
|
|
+ o.input_order_sn IS NULL
|
|
|
+ OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 1 ) AND o.tenant_id IS NOT NULL
|
|
|
+ <if test="startTime != null and startTime != ''">
|
|
|
+ AND og.create_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null and endTime != ''">
|
|
|
+ AND og.create_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ <if test="tenantId != null and tenantId != ''">
|
|
|
+ AND og.tenant_id = #{tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="createNo != null and createNo != ''">
|
|
|
+ AND 1=0
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getBusinessList" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderStatisticsBo"
|
|
|
+ resultType="string">
|
|
|
+ SELECT
|
|
|
+ allu.business_name
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ ouu.business_name,
|
|
|
+ IFNULL( SUM( oo.order_received - oo.order_refunded ), 0 ) money
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ ou.order_sn,
|
|
|
+ ou.business_name
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ `otg`.`order_sn` AS `order_sn`,
|
|
|
+ concat( substr( `otg`.`business_full_name`, 5, 4 ), '-', `otg`.`business_name` ) AS `business_name`
|
|
|
+ FROM
|
|
|
+ `top_old_order_goods` `otg`
|
|
|
+ ) ou
|
|
|
+ GROUP BY
|
|
|
+ ou.order_sn,
|
|
|
+ ou.business_name
|
|
|
+ ) ouu
|
|
|
+ LEFT JOIN top_old_order oo ON ouu.order_sn = oo.order_sn
|
|
|
+ WHERE
|
|
|
+ oo.`status` = 1
|
|
|
+ AND oo.check_status = 1
|
|
|
+ GROUP BY
|
|
|
+ ouu.business_name UNION ALL
|
|
|
+ SELECT
|
|
|
+ nou.business_name,
|
|
|
+ SUM( nou.goods_received ) AS money
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ `og`.`order_sn` AS `order_sn`,
|
|
|
+ concat( `cet`.`education_name`, '-', `cb`.`business_name`, `cpt`.`project_name` ) AS `business_name`,
|
|
|
+ og.goods_received
|
|
|
+ FROM
|
|
|
+ ((((
|
|
|
+ `order` o
|
|
|
+ LEFT JOIN `order_goods` `og` ON o.order_sn = og.order_sn
|
|
|
+ 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`.`education_type_id` = `cpt`.`id`
|
|
|
+ )))
|
|
|
+ LEFT JOIN `course_business` `cb` ON ((
|
|
|
+ `g`.`business_id` = `cb`.`id`
|
|
|
+ )))
|
|
|
+ WHERE
|
|
|
+ og.pay_status != 1
|
|
|
+ AND (
|
|
|
+ o.input_order_sn IS NULL
|
|
|
+ OR ( SELECT COUNT( too.order_id ) FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn ) < 1
|
|
|
+ )
|
|
|
+ AND o.tenant_id IS NOT NULL
|
|
|
+ AND og.refund_status != 2
|
|
|
+ ) nou
|
|
|
+ WHERE
|
|
|
+ 1 = 1
|
|
|
+ GROUP BY
|
|
|
+ nou.business_name
|
|
|
+ ) allu
|
|
|
+ WHERE
|
|
|
+ allu.business_name IS NOT NULL
|
|
|
+ GROUP BY
|
|
|
+ allu.business_name
|
|
|
+ ORDER BY
|
|
|
+ SUM( allu.money ) DESC
|
|
|
</select>
|
|
|
</mapper>
|