From f0f94a69b05dd6049e1b3dff2ef3f7a9ac8332fb Mon Sep 17 00:00:00 2001 From: yujian <Administrator@Admin> Date: 星期三, 26 十二月 2018 14:14:10 +0800 Subject: [PATCH] 订单接口优化 --- fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml | 174 +++++++++++++++++++++++++-------------------------------- 1 files changed, 77 insertions(+), 97 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml b/fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml index a6c58c8..f6c9057 100644 --- a/fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml +++ b/fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml @@ -137,8 +137,14 @@ LEFT JOIN yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id` LEFT JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR th.`hb_pid` = tr.`ho_hongbao_id` ) WHERE th.`hb_uid` = #{uid} - <if test="state != null"> - AND th.hb_state = #{state} + <if test="state != null and state == 1"> <!-- 鏈埌璐� --> + AND (th.hb_state = 1 or th.hb_state = 2) + </if> + <if test="state != null and state == 2"> <!-- 宸插埌璐� --> + AND th.hb_state = 3 + </if> + <if test="state != null and state == 3"> <!-- 绾㈠寘宸插け鏁� --> + AND th.hb_state =4 </if> <if test="type != null and type == 1"> <!-- 鑷喘璁㈠崟 --> AND (th.hb_type =1 or th.hb_type =2) @@ -152,12 +158,33 @@ <if test="orderNo != null"> AND tc.co_order_no = #{orderNo} </if> + <if test="orderState != null and orderState == 1"> + AND (tc.co_state = 1 or tc.co_state = 2) <!-- 鏈夋晥璁㈠崟 --> + </if> + <if test="orderState != null and orderState == 2"> + AND tc.co_state = 3 <!-- 缁存潈璁㈠崟 --> + </if> + <if test="orderState != null and orderState == 3"> + AND tc.co_state = 4 <!-- 澶辨晥璁㈠崟 --> + </if> <if test="startTime != null"> AND <![CDATA[tc.co_create_time >= #{startTime}]]> </if> <if test="endTime != null"> AND <![CDATA[tc.co_create_time < #{endTime}]]> </if> + <if test ="day != null and day == 1"> <!-- 浠婂ぉ --> + AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW()) + </if> + <if test="day != null and day == 2"> <!-- 鏄ㄥぉ --> + AND TO_DAYS(NOW()) - TO_DAYS(tc.`co_create_time`) = 1 + </if> + <if test="day != null and day == 3"> <!-- 鏈湀 --> + AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m') + </if> + <if test="day != null and day == 4"> <!-- 涓婃湀 --> + AND PERIOD_DIFF( DATE_FORMAT(NOW(), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1 + </if> GROUP BY tc.`co_order_no`,tc.co_source_type ORDER BY tc.co_create_time DESC LIMIT ${start},${count} @@ -168,8 +195,14 @@ LEFT JOIN yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id` LEFT JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR th.`hb_pid` = tr.`ho_hongbao_id` ) WHERE th.`hb_uid` = #{uid} - <if test="state != null"> - AND th.hb_state = #{state} + <if test="state != null and state == 1"> <!-- 鏈埌璐� --> + AND (th.hb_state = 1 or th.hb_state = 2) + </if> + <if test="state != null and state == 2"> <!-- 宸插埌璐� --> + AND th.hb_state = 3 + </if> + <if test="state != null and state == 3"> <!-- 绾㈠寘宸插け鏁� --> + AND th.hb_state =4 </if> <if test="type != null and type == 1"> <!-- 鑷喘璁㈠崟 --> AND (th.hb_type =1 or th.hb_type =2) @@ -180,6 +213,17 @@ <if test="type != null and type == 3"> <!-- 閭�璇疯鍗� --> AND (th.`hb_type` = 5 OR th.`hb_type` = 6 OR th.`hb_type` = 7) </if> + + <if test="orderState != null and orderState = 1"> + AND (tc.co_state = 1 or tc.co_state = 2) <!-- 鏈夋晥璁㈠崟 --> + </if> + <if test="orderState != null and orderState = 2"> + AND tc.co_state = 3 <!-- 缁存潈璁㈠崟 --> + </if> + <if test="orderState != null and orderState = 3"> + AND tc.co_state = 4 <!-- 澶辨晥璁㈠崟 --> + </if> + <if test="orderNo != null"> AND tc.co_order_no = #{orderNo} </if> @@ -189,6 +233,18 @@ <if test="endTime != null"> AND <![CDATA[tc.co_create_time < #{endTime}]]> </if> + <if test ="day != null and day == 1"> <!-- 浠婂ぉ --> + AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW()) + </if> + <if test="day != null and day == 2"> <!-- 鏄ㄥぉ --> + AND TO_DAYS(NOW()) - TO_DAYS(tc.`co_create_time`) = 1 + </if> + <if test="day != null and day == 3"> <!-- 鏈湀 --> + AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m') + </if> + <if test="day != null and day == 4"> <!-- 涓婃湀 --> + AND PERIOD_DIFF( DATE_FORMAT(NOW(), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1 + </if> </select> <select id="listByOrderNoAndType" resultMap="ResultMap" parameterType="java.util.List"> @@ -332,6 +388,7 @@ <if test="type != null and type == 3"> <!-- 閭�璇疯鍗� --> AND (th.`hb_type` = 5 OR th.`hb_type` = 6 OR th.`hb_type` = 7) </if> + <if test ="day != null and day == 1"> <!-- 浠婂ぉ --> AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW()) </if> @@ -339,10 +396,10 @@ AND TO_DAYS(NOW()) - TO_DAYS(tc.`co_create_time`) = 1 </if> <if test="day != null and day == 3"> <!-- 鏈湀 --> - AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE( ),'%Y%m') + AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m') </if> <if test="day != null and day == 4"> <!-- 涓婃湀 --> - AND ERIOD_DIFF( DATE_FORMAT( now( ), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1 + AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1 </if> </select> @@ -370,10 +427,10 @@ AND TO_DAYS(NOW()) - TO_DAYS(tc.`co_create_time`) = 1 </if> <if test="day != null and day == 3"> <!-- 鏈湀 --> - AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE( ),'%Y%m') + AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m') </if> <if test="day != null and day == 4"> <!-- 涓婃湀 --> - AND ERIOD_DIFF( DATE_FORMAT( now( ), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1 + AND PERIOD_DIFF( DATE_FORMAT(NOW(), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1 </if> </select> @@ -393,6 +450,15 @@ <if test="type != null and type == 3"> <!-- 閭�璇疯鍗� --> AND (th.`hb_type` = 5 OR th.`hb_type` = 6 OR th.`hb_type` = 7) </if> + <if test="orderState != null and orderState == 1"> + AND (tc.co_state = 1 or tc.co_state = 2) <!-- 鏈夋晥璁㈠崟 --> + </if> + <if test="orderState != null and orderState == 2"> + AND tc.co_state = 3 <!-- 缁存潈璁㈠崟 --> + </if> + <if test="orderState != null and orderState == 3"> + AND tc.co_state = 4 <!-- 澶辨晥璁㈠崟 --> + </if> <if test ="day != null and day == 1"> <!-- 浠婂ぉ --> AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW()) </if> @@ -400,100 +466,14 @@ AND TO_DAYS(NOW()) - TO_DAYS(tc.`co_create_time`) = 1 </if> <if test="day != null and day == 3"> <!-- 鏈湀 --> - AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE( ),'%Y%m') + AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m') </if> <if test="day != null and day == 4"> <!-- 涓婃湀 --> - AND ERIOD_DIFF( DATE_FORMAT( now( ), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1 + AND PERIOD_DIFF( DATE_FORMAT(NOW(), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1 </if> GROUP BY tc.`co_order_no`,tc.co_source_type ORDER BY tc.co_create_time DESC LIMIT ${start},${count} </select> - - <select id="countBonusOrderByState" resultType="java.util.HashMap"> - SELECT SUM(valid)AS totalValid, SUM(proces)AS totalProces ,SUM(Invalid)AS totalInvite - FROM (SELECT IFNULL(COUNT(DISTINCT tc.`co_order_no`,tc.`co_source_type`),0) AS valid,0 AS proces,0 AS Invalid - FROM yeshi_ec_common_order tc - LEFT JOIN yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id` - LEFT JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR th.`hb_pid` = tr.`ho_hongbao_id` ) - WHERE th.`hb_uid` = #{uid} AND (tc.`co_state` = 1 OR tc.`co_state` = 2) - <if test="type != null and type == 1"> <!-- 鑷喘璁㈠崟 --> - AND (th.hb_type =1 or th.hb_type =2) - </if> - <if test="type != null and type == 2"> <!-- 鍒嗕韩璁㈠崟 --> - AND (th.`hb_type` = 20 OR th.`hb_type` = 21 OR th.`hb_type` = 22) - </if> - <if test="type != null and type == 3"> <!-- 閭�璇疯鍗� --> - AND (th.`hb_type` = 5 OR th.`hb_type` = 6 OR th.`hb_type` = 7) - </if> - <if test ="day != null and day == 1"> <!-- 浠婂ぉ --> - AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW()) - </if> - <if test="day != null and day == 2"> <!-- 鏄ㄥぉ --> - AND TO_DAYS(NOW()) - TO_DAYS(tc.`co_create_time`) = 1 - </if> - <if test="day != null and day == 3"> <!-- 鏈湀 --> - AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE( ),'%Y%m') - </if> - <if test="day != null and day == 4"> <!-- 涓婃湀 --> - AND ERIOD_DIFF( DATE_FORMAT( now( ), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1 - </if> - UNION - - SELECT 0 AS valid,IFNULL(COUNT(DISTINCT tc.`co_order_no`,tc.`co_source_type`),0) AS proces,0 AS Invalid - FROM yeshi_ec_common_order tc - LEFT JOIN yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id` - LEFT JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR th.`hb_pid` = tr.`ho_hongbao_id` ) - WHERE th.`hb_uid` = #{uid} AND tc.`co_state` =3 - <if test="type != null and type == 1"> <!-- 鑷喘璁㈠崟 --> - AND (th.hb_type =1 or th.hb_type =2) - </if> - <if test="type != null and type == 2"> <!-- 鍒嗕韩璁㈠崟 --> - AND (th.`hb_type` = 20 OR th.`hb_type` = 21 OR th.`hb_type` = 22) - </if> - <if test="type != null and type == 3"> <!-- 閭�璇疯鍗� --> - AND (th.`hb_type` = 5 OR th.`hb_type` = 6 OR th.`hb_type` = 7) - </if> - <if test ="day != null and day == 1"> <!-- 浠婂ぉ --> - AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW()) - </if> - <if test="day != null and day == 2"> <!-- 鏄ㄥぉ --> - AND TO_DAYS(NOW()) - TO_DAYS(tc.`co_create_time`) = 1 - </if> - <if test="day != null and day == 3"> <!-- 鏈湀 --> - AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE( ),'%Y%m') - </if> - <if test="day != null and day == 4"> <!-- 涓婃湀 --> - AND ERIOD_DIFF( DATE_FORMAT( now( ), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1 - </if> - UNION - - SELECT 0 AS valid,0 AS proces,IFNULL(COUNT(DISTINCT tc.`co_order_no`,tc.`co_source_type`),0) AS Invalid - FROM yeshi_ec_common_order tc - LEFT JOIN yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id` - LEFT JOIN yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR th.`hb_pid` = tr.`ho_hongbao_id` ) - WHERE th.`hb_uid`= #{uid} AND tc.`co_state` = 4 - <if test="type != null and type == 1"> <!-- 鑷喘璁㈠崟 --> - AND (th.hb_type =1 or th.hb_type =2) - </if> - <if test="type != null and type == 2"> <!-- 鍒嗕韩璁㈠崟 --> - AND (th.`hb_type` = 20 OR th.`hb_type` = 21 OR th.`hb_type` = 22) - </if> - <if test="type != null and type == 3"> <!-- 閭�璇疯鍗� --> - AND (th.`hb_type` = 5 OR th.`hb_type` = 6 OR th.`hb_type` = 7) - </if> - <if test ="day != null and day == 1"> <!-- 浠婂ぉ --> - AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW()) - </if> - <if test="day != null and day == 2"> <!-- 鏄ㄥぉ --> - AND TO_DAYS(NOW()) - TO_DAYS(tc.`co_create_time`) = 1 - </if> - <if test="day != null and day == 3"> <!-- 鏈湀 --> - AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') = DATE_FORMAT(CURDATE( ),'%Y%m') - </if> - <if test="day != null and day == 4"> <!-- 涓婃湀 --> - AND ERIOD_DIFF( DATE_FORMAT( now( ), '%Y%m'), DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1 - </if> - )A - </select> + </mapper> -- Gitblit v1.8.0