| | |
| | | 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) |
| | |
| | | <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} |
| | |
| | | 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) |
| | |
| | | <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> |
| | |
| | | <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"> |
| | |
| | | <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> |
| | |
| | | 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> |
| | | |
| | |
| | | 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> |
| | | |
| | |
| | | <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> |
| | |
| | | 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> |