From 88b54772dbcf5ecab1e2316e4e4626ac901b8908 Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期二, 22 一月 2019 15:58:24 +0800 Subject: [PATCH] 邀请码添加返回状态 --- fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml | 335 ++++++++++++++++++++++++++++++------------------------- 1 files changed, 185 insertions(+), 150 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 bc4583a..9efebd0 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 @@ -95,6 +95,16 @@ <result column="totalCount" property="totalCount" jdbcType="INTEGER" /> <result column="totalSettlement" property="totalSettlement" jdbcType="DECIMAL" /> <result column="totalPayment" property="totalPayment" jdbcType="DECIMAL" /> + + + <result column="userId" property="userId" jdbcType="VARCHAR" /> + <result column="userName" property="userName" jdbcType="VARCHAR" /> + <result column="userPortrait" property="userPortrait" jdbcType="VARCHAR" /> + + <result column="levelOneId" property="levelOneId" jdbcType="VARCHAR" /> + <result column="levelOneMoney" property="levelOneMoney" jdbcType="VARCHAR" /> + <result column="levelTwoId" property="levelTwoId" jdbcType="VARCHAR" /> + <result column="levelTwoMoney" property="levelTwoMoney" jdbcType="VARCHAR" /> <association property="userInfo" column="co_uid" resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap"> @@ -105,6 +115,7 @@ </association> </resultMap> + <sql id="Base_Column_List">co_id,co_uid,co_order_no,co_source_type,co_source_position,co_order_goods_id,co_count,co_state,co_state_whole_order,co_estimate,co_eIncome,co_payment,co_settlement,co_third_create_time,co_settle_time,co_order_by,co_create_time,co_update_time </sql> @@ -255,24 +266,24 @@ <sql id="SELECT_PARAM_ORDER_CREATE_TIME"> <if test="startTime != null and startTime != '' "> - AND <![CDATA[co.co_create_time >= #{startTime}]]> + AND <![CDATA[co.co_third_create_time >= #{startTime}]]> </if> <if test="endTime != null and endTime != '' "> - AND <![CDATA[co.co_create_time <= #{endTime}]]> + AND <![CDATA[co.co_third_create_time <= #{endTime}]]> </if> <if test="day != null and day == 1"> <!-- 浠婂ぉ --> - AND TO_DAYS(co.`co_create_time`) = TO_DAYS(NOW()) + AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW()) </if> <if test="day != null and day == 2"> <!-- 鏄ㄥぉ --> - AND TO_DAYS(NOW()) - TO_DAYS(co.`co_create_time`) = 1 + AND TO_DAYS(NOW()) - TO_DAYS(co.`co_third_create_time`) = 1 </if> <if test="day != null and day == 3"> <!-- 鏈湀 --> - AND DATE_FORMAT(co.`co_create_time`,'%Y%m') = + AND DATE_FORMAT(co.`co_third_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(co.`co_create_time`, '%Y%m')) = 1 + DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1 </if> </sql> @@ -290,48 +301,45 @@ <sql id="SELECT_PARAM_HONGBAO_STATE"> <if test="state != null and state == 1"> <!-- 鏈埌璐� --> - AND (v2.hb_state = 1 or v2.hb_state = 2) + AND (hb.hb_state = 1 or hb.hb_state = 2) </if> <if test="state != null and state == 2"> <!-- 宸插埌璐� --> - AND v2.hb_state = 3 + AND hb.hb_state = 3 </if> - <if test="state != null and state == 3"> <!-- 绾㈠寘宸插け鏁� --> - AND v2.hb_state =4 + <if test="state != null and state == 3"> <!-- 绾㈠寘宸插け鏁堛�佹暣涓鍗曞け鏁� --> + AND hb.hb_state =4 AND co.co_state_whole_order = 3 </if> </sql> + <sql id="Hongbao_Column_List"> + hb_id,hb_uid,hb_urank,hb_pid,hb_type,hb_state,hb_pre_get_time,hb_get_time,hb_version, + IF(v2.`hb_state` = 4, 0, v2.hb_money)AS hb_money + </sql> <select id="listUserOrder" resultMap="ResultMap"> <!-- 鏌ヨ鐢ㄦ埛璁㈠崟 --> - SELECT COALESCE(SUM(IF(hb.hb_id IS NULL,hbp.`hb_money`,hb.`hb_money`)),0)AS totalMoney, - IF(hb.hb_id IS NULL,hbp.`hb_state`,hb.hb_state) AS hongBaoState, - IF(hb.hb_id IS NULL,hbp.`hb_type`,hb.`hb_type`) AS hongBaoType, - IF(hb.hb_id IS NULL,hbp.`hb_get_time`,hb.`hb_get_time`) AS accountTime, - IF(hb.hb_id IS NULL,hbp.`hb_pre_get_time`,hb.`hb_pre_get_time`) AS preAccountTime, + SELECT COALESCE(SUM(hb.`hb_money`),0)AS totalMoney, + hb.hb_state AS hongBaoState, + hb.`hb_type` AS hongBaoType, + hb.`hb_get_time` AS accountTime, + hb.`hb_pre_get_time`AS preAccountTime, co.* FROM yeshi_ec_hongbao_order ho - LEFT JOIN (SELECT * FROM yeshi_ec_hongbao_v2 v2 + LEFT JOIN (SELECT <include refid="Hongbao_Column_List"/> FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} <include refid="SELECT_PARAM_HONGBAO_TYPE"/> <!-- 绾㈠寘绫诲瀷 --> - <include refid="SELECT_PARAM_HONGBAO_STATE"/> <!-- 绾㈠寘鐘舵�� --> - )hb ON hb.hb_id=ho.`ho_hongbao_id` - - LEFT JOIN (SELECT * FROM yeshi_ec_hongbao_v2 v2 - WHERE v2.`hb_uid`= #{uid} - <include refid="SELECT_PARAM_HONGBAO_TYPE"/> <!-- 绾㈠寘绫诲瀷 --> - <include refid="SELECT_PARAM_HONGBAO_STATE"/> <!-- 绾㈠寘鐘舵�� --> - )hbp ON hbp.hb_pid=ho.`ho_hongbao_id` - + )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` - WHERE (hb.hb_id IS NOT NULL OR hbp.hb_id IS NOT NULL) + WHERE hb.hb_id IS NOT NULL <include refid="SELECT_PARAM_ORDER_STATE"/> <!-- 璁㈠崟鐘舵�� --> <include refid="SELECT_PARAM_ORDER_CREATE_TIME"/> <!-- 璁㈠崟鏃堕棿 --> + <include refid="SELECT_PARAM_HONGBAO_STATE"/> <!-- 绾㈠寘鐘舵�� --> <if test="orderNo != null and orderNo !='' "> AND co.co_order_no = #{orderNo} </if> GROUP BY co.`co_order_no`, co.`co_source_type` - ORDER BY co.co_create_time DESC + ORDER BY co.co_third_create_time DESC LIMIT ${start},${count} </select> @@ -339,22 +347,16 @@ <!-- 缁熻鐢ㄦ埛璁㈠崟鏁伴噺 --> SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.ho_id FROM yeshi_ec_hongbao_order ho - LEFT JOIN (SELECT * FROM yeshi_ec_hongbao_v2 v2 + LEFT JOIN (SELECT <include refid="Hongbao_Column_List"/> FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} <include refid="SELECT_PARAM_HONGBAO_TYPE"/> <!-- 绾㈠寘绫诲瀷 --> - <include refid="SELECT_PARAM_HONGBAO_STATE"/> <!-- 绾㈠寘鐘舵�� --> - )hb ON hb.hb_id=ho.`ho_hongbao_id` - - LEFT JOIN (SELECT * FROM yeshi_ec_hongbao_v2 v2 - WHERE v2.`hb_uid`= #{uid} - <include refid="SELECT_PARAM_HONGBAO_TYPE"/> <!-- 绾㈠寘绫诲瀷 --> - <include refid="SELECT_PARAM_HONGBAO_STATE"/> <!-- 绾㈠寘鐘舵�� --> - )hbp ON hbp.hb_pid=ho.`ho_hongbao_id` + )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` - WHERE (hb.hb_id IS NOT NULL OR hbp.hb_id IS NOT NULL) + WHERE hb.hb_id IS NOT NULL <include refid="SELECT_PARAM_ORDER_STATE"/> <!-- 璁㈠崟鐘舵�� --> <include refid="SELECT_PARAM_ORDER_CREATE_TIME"/> <!-- 璁㈠崟鏃堕棿 --> + <include refid="SELECT_PARAM_HONGBAO_STATE"/> <!-- 绾㈠寘鐘舵�� --> <if test="orderNo != null and orderNo !='' "> AND co.co_order_no = #{orderNo} </if> @@ -388,26 +390,22 @@ LEFT JOIN ( SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= ${uid} AND (v2.`hb_type` = 1 OR v2.`hb_type` = 2) - ) hb ON hb.hb_id=ho.`ho_hongbao_id` - LEFT JOIN ( - SELECT * FROM yeshi_ec_hongbao_v2 v2 - WHERE v2.`hb_uid`= ${uid} AND (v2.`hb_type` = 1 OR v2.`hb_type` = 2) - ) hbp ON hbp.hb_pid=ho.`ho_hongbao_id` + ) hb ON hb.hb_id=ho.`ho_hongbao_id` <!-- 鑷喘璁㈠崟 --> LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` - WHERE (hb.hb_id IS NOT NULL OR hbp.hb_id IS NOT NULL) + WHERE hb.hb_id IS NOT NULL <if test="day != null and day == 1"> <!-- 浠婂ぉ --> - AND TO_DAYS(co.`co_create_time`) = TO_DAYS(NOW()) + AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW()) </if> <if test="day != null and day == 2"> <!-- 鏄ㄥぉ --> - AND TO_DAYS(NOW()) - TO_DAYS(co.`co_create_time`) = 1 + AND TO_DAYS(NOW()) - TO_DAYS(co.co_third_create_time) = 1 </if> <if test="day != null and day == 3"> <!-- 鏈湀 --> - AND DATE_FORMAT(co.`co_create_time`,'%Y%m') = + AND DATE_FORMAT(co.`co_third_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(co.`co_create_time`, '%Y%m')) = 1 + DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1 </if> GROUP BY co.`co_order_no`, co.`co_source_type`)YX @@ -418,26 +416,23 @@ LEFT JOIN ( SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= ${uid} AND v2.`hb_type` = 20 - ) hb ON hb.hb_id=ho.`ho_hongbao_id` - LEFT JOIN ( - SELECT * FROM yeshi_ec_hongbao_v2 v2 - WHERE v2.`hb_uid`= ${uid} AND v2.`hb_type` = 20 - ) hbp ON hbp.hb_pid=ho.`ho_hongbao_id` + ) hb ON hb.hb_id=ho.`ho_hongbao_id` <!-- 鍒嗕韩璁㈠崟 --> + LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` - WHERE (hb.hb_id IS NOT NULL OR hbp.hb_id IS NOT NULL) + WHERE hb.hb_id IS NOT NULL <if test="day != null and day == 1"> <!-- 浠婂ぉ --> - AND TO_DAYS(co.`co_create_time`) = TO_DAYS(NOW()) + AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW()) </if> <if test="day != null and day == 2"> <!-- 鏄ㄥぉ --> - AND TO_DAYS(NOW()) - TO_DAYS(co.`co_create_time`) = 1 + AND TO_DAYS(NOW()) - TO_DAYS(co.`co_third_create_time`) = 1 </if> <if test="day != null and day == 3"> <!-- 鏈湀 --> - AND DATE_FORMAT(co.`co_create_time`,'%Y%m') = + AND DATE_FORMAT(co.`co_third_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(co.`co_create_time`, '%Y%m')) = 1 + DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1 </if> GROUP BY co.`co_order_no`, co.`co_source_type`)WQ @@ -450,28 +445,22 @@ WHERE v2.`hb_uid`= ${uid} AND (v2.`hb_type` = 5 OR v2.`hb_type` = 6 OR v2.`hb_type` = 7 OR v2.`hb_type` = 21 OR v2.`hb_type` = 22 ) - ) hb ON hb.hb_id=ho.`ho_hongbao_id` - LEFT JOIN ( - SELECT * FROM yeshi_ec_hongbao_v2 v2 - WHERE v2.`hb_uid`= ${uid} - AND (v2.`hb_type` = 5 OR v2.`hb_type` = 6 OR v2.`hb_type` = 7 - OR v2.`hb_type` = 21 OR v2.`hb_type` = 22 ) ) hbp ON hbp.hb_pid=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` - WHERE (hb.hb_id IS NOT NULL OR hbp.hb_id IS NOT NULL) + WHERE hbp.hb_id IS NOT NULL <if test="day != null and day == 1"> <!-- 浠婂ぉ --> - AND TO_DAYS(co.`co_create_time`) = TO_DAYS(NOW()) + AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW()) </if> <if test="day != null and day == 2"> <!-- 鏄ㄥぉ --> - AND TO_DAYS(NOW()) - TO_DAYS(co.`co_create_time`) = 1 + AND TO_DAYS(NOW()) - TO_DAYS(co.`co_third_create_time`) = 1 </if> <if test="day != null and day == 3"> <!-- 鏈湀 --> - AND DATE_FORMAT(co.`co_create_time`,'%Y%m') = + AND DATE_FORMAT(co.`co_third_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(co.`co_create_time`, '%Y%m')) = 1 + DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1 </if> GROUP BY co.`co_order_no`, co.`co_source_type`)SX )A @@ -487,14 +476,10 @@ LEFT JOIN ( SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" /> - ) hb ON hb.hb_id=ho.`ho_hongbao_id` - LEFT JOIN ( - SELECT * FROM yeshi_ec_hongbao_v2 v2 - WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" /> - ) hbp ON hbp.hb_pid=ho.`ho_hongbao_id` + ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` - WHERE (hb.hb_id IS NOT NULL OR hbp.hb_id IS NOT NULL) + WHERE hb.hb_id IS NOT NULL <![CDATA[AND co.`co_state` <> 3]]> AND (co.`co_state_whole_order` =1 OR co.`co_state_whole_order` = 2) <include refid="SELECT_PARAM_ORDER_CREATE_TIME" /> @@ -507,13 +492,9 @@ LEFT JOIN ( SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" /> - ) hb ON hb.hb_id=ho.`ho_hongbao_id` - LEFT JOIN ( - SELECT * FROM yeshi_ec_hongbao_v2 v2 - WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" /> - ) hbp ON hbp.hb_pid=ho.`ho_hongbao_id` + ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` - WHERE (hb.hb_id IS NOT NULL OR hbp.hb_id IS NOT NULL) + WHERE hb.hb_id IS NOT NULL AND co.`co_state` = 3 <include refid="SELECT_PARAM_ORDER_CREATE_TIME" /> GROUP BY co.`co_order_no`, co.`co_source_type`)WQ @@ -525,13 +506,9 @@ LEFT JOIN ( SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" /> - ) hb ON hb.hb_id=ho.`ho_hongbao_id` - LEFT JOIN ( - SELECT * FROM yeshi_ec_hongbao_v2 v2 - WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" /> - ) hbp ON hbp.hb_pid=ho.`ho_hongbao_id` + ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` - WHERE (hb.hb_id IS NOT NULL OR hbp.hb_id IS NOT NULL) + WHERE hb.hb_id IS NOT NULL AND co.`co_state_whole_order` = 3 <include refid="SELECT_PARAM_ORDER_CREATE_TIME" /> GROUP BY co.`co_order_no`, co.`co_source_type`)SX @@ -547,75 +524,58 @@ LEFT JOIN ( SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" /> - ) hb ON hb.hb_id=ho.`ho_hongbao_id` - - LEFT JOIN ( - SELECT * FROM yeshi_ec_hongbao_v2 v2 - WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" /> - ) hbp ON hbp.hb_pid=ho.`ho_hongbao_id` - + ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` - WHERE (hb.hb_id IS NOT NULL OR hbp.hb_id IS NOT NULL) + WHERE hb.hb_id IS NOT NULL <include refid="SELECT_PARAM_ORDER_CREATE_TIME" /> - <if test="day != null and day == 4"> - AND co.`co_state` = 2 <!-- 涓婃湀 :缁熻宸叉敹璐� --> - </if> GROUP BY co.`co_order_no`, co.`co_source_type` )A </select> <select id="countBonusOrderMoney" resultType="java.math.BigDecimal"> <!-- 濂栭噾缁熻锛氳鍗曟�昏繑鍒╅噾棰� 鍘绘帀宸插け鏁� --> - SELECT COALESCE(SUM(IF(hb.hb_id IS NULL,hbp.`hb_money`,hb.`hb_money`)),0)AS totalmoney + SELECT COALESCE(SUM(hb.`hb_money`),0)AS totalmoney FROM yeshi_ec_hongbao_order ho LEFT JOIN ( - SELECT * FROM yeshi_ec_hongbao_v2 v2 + SELECT <include refid="Hongbao_Column_List"/> FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" /> AND (v2.hb_state = 1 or v2.hb_state = 2 or v2.hb_state = 3) - ) hb ON hb.hb_id=ho.`ho_hongbao_id` - LEFT JOIN ( - SELECT * FROM yeshi_ec_hongbao_v2 v2 - WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" /> - AND (v2.hb_state = 1 or v2.hb_state = 2 or v2.hb_state = 3) - ) hbp ON hbp.hb_pid=ho.`ho_hongbao_id` + ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` - WHERE (hb.hb_id IS NOT NULL OR hbp.hb_id IS NOT NULL) + WHERE hb.hb_id IS NOT NULL <include refid="SELECT_PARAM_ORDER_CREATE_TIME" /> <if test="day != null and day == 4"> - AND co.`co_state` = 2 <!-- 涓婃湀 :缁熻宸叉敹璐� --> + AND co.`co_state` = 2 <!-- 涓婃湀 :缁熻宸叉敹璐� --> </if> </select> <select id="countBonusOrderMoneyAndNumber" resultType="java.util.HashMap"> - <!-- 濂栭噾缁熻锛氳鍗曟�昏繑鍒╅噾棰� 鍘绘帀宸插け鏁� --> - SELECT COUNT(ho.`ho_id`) AS totalNum, - CAST(SUM(IF(hb.hb_id IS NULL,hbp.`hb_money`,hb.`hb_money`))AS DECIMAL(19,2)) AS totalmoney - FROM yeshi_ec_hongbao_order ho - LEFT JOIN ( - SELECT * FROM yeshi_ec_hongbao_v2 v2 - WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" /> - AND (v2.hb_state = 1 or v2.hb_state = 2 or v2.hb_state = 3) - ) hb ON hb.hb_id=ho.`ho_hongbao_id` - LEFT JOIN ( - SELECT * FROM yeshi_ec_hongbao_v2 v2 - WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" /> - AND (v2.hb_state = 1 or v2.hb_state = 2 or v2.hb_state = 3) - ) hbp ON hbp.hb_pid=ho.`ho_hongbao_id` - LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` - WHERE (hb.hb_id IS NOT NULL OR hbp.hb_id IS NOT NULL) - <include refid="SELECT_PARAM_ORDER_CREATE_TIME" /> - <if test="day != null and day == 4"> - AND co.`co_state` = 2 <!-- 涓婃湀 :缁熻宸叉敹璐� --> - </if> + SELECT COUNT(*) AS totalNum, CAST(SUM(moneys) AS DECIMAL(19,2)) AS totalmoney FROM + (SELECT CAST(SUM(hb.`hb_money`) AS DECIMAL(19,2))AS moneys + FROM yeshi_ec_hongbao_order ho + LEFT JOIN ( + SELECT <include refid="Hongbao_Column_List"/> FROM yeshi_ec_hongbao_v2 v2 + WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" /> + AND (v2.hb_state = 1 or v2.hb_state = 2 or v2.hb_state = 3) + ) hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` + + LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` + WHERE hb.hb_id IS NOT NULL + <include refid="SELECT_PARAM_ORDER_CREATE_TIME" /> + <if test="day != null and day == 4"> + AND co.`co_state` = 2 <!-- 涓婃湀 :缁熻宸叉敹璐� --> + </if> + GROUP BY co.`co_order_no`, co.`co_source_type` + )A </select> <select id="listQueryByUid" resultMap="ResultMap"> <!-- 鏌ヨ鐢ㄦ埛璁㈠崟 --> - SELECT IF(hb.hb_id IS NULL,hbp.`hb_money`,hb.`hb_money`) AS totalMoney, - IF(hb.hb_id IS NULL,hbp.`hb_state`,hb.hb_state) AS hongBaoState, - IF(hb.hb_id IS NULL,hbp.`hb_type`,hb.`hb_type`) AS hongBaoType, - IF(hb.hb_id IS NULL,hbp.`hb_get_time`,hb.`hb_get_time`) AS accountTime, - IF(hb.hb_id IS NULL,hbp.`hb_pre_get_time`,hb.`hb_pre_get_time`) AS preAccountTime, + SELECT hb.`hb_money` AS totalMoney, + hb.hb_state AS hongBaoState, + hb.`hb_type` AS hongBaoType, + hb.`hb_get_time` AS accountTime, + hb.`hb_pre_get_time` AS preAccountTime, co.*,cog.* FROM yeshi_ec_hongbao_order ho @@ -623,23 +583,16 @@ WHERE v2.`hb_uid`= #{uid} <include refid="SELECT_PARAM_HONGBAO_TYPE"/> <!-- 绾㈠寘绫诲瀷 --> <include refid="SELECT_PARAM_HONGBAO_STATE"/> <!-- 绾㈠寘鐘舵�� --> - )hb ON hb.hb_id=ho.`ho_hongbao_id` - - LEFT JOIN (SELECT * FROM yeshi_ec_hongbao_v2 v2 - WHERE v2.`hb_uid`= #{uid} - <include refid="SELECT_PARAM_HONGBAO_TYPE"/> <!-- 绾㈠寘绫诲瀷 --> - <include refid="SELECT_PARAM_HONGBAO_STATE"/> <!-- 绾㈠寘鐘舵�� --> - )hbp ON hbp.hb_pid=ho.`ho_hongbao_id` - + )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` LEFT JOIN yeshi_ec_common_order_goods cog ON cog.`cog_id`= co.`co_order_goods_id` - WHERE (hb.hb_id IS NOT NULL OR hbp.hb_id IS NOT NULL) + WHERE hb.hb_id IS NOT NULL <include refid="SELECT_PARAM_ORDER_STATE"/> <!-- 璁㈠崟鐘舵�� --> <include refid="SELECT_PARAM_ORDER_CREATE_TIME"/> <!-- 璁㈠崟鏃堕棿 --> <if test="orderNo != null and orderNo !='' "> AND co.co_order_no = #{orderNo} </if> - ORDER BY co.co_create_time DESC + ORDER BY co.co_third_create_time DESC LIMIT ${start},${count} </select> @@ -651,16 +604,10 @@ WHERE v2.`hb_uid`= #{uid} <include refid="SELECT_PARAM_HONGBAO_TYPE"/> <!-- 绾㈠寘绫诲瀷 --> <include refid="SELECT_PARAM_HONGBAO_STATE"/> <!-- 绾㈠寘鐘舵�� --> - )hb ON hb.hb_id=ho.`ho_hongbao_id` - - LEFT JOIN (SELECT * FROM yeshi_ec_hongbao_v2 v2 - WHERE v2.`hb_uid`= #{uid} - <include refid="SELECT_PARAM_HONGBAO_TYPE"/> <!-- 绾㈠寘绫诲瀷 --> - <include refid="SELECT_PARAM_HONGBAO_STATE"/> <!-- 绾㈠寘鐘舵�� --> - )hbp ON hbp.hb_pid=ho.`ho_hongbao_id` + )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` - WHERE (hb.hb_id IS NOT NULL OR hbp.hb_id IS NOT NULL) + WHERE hb.hb_id IS NOT NULL <include refid="SELECT_PARAM_ORDER_STATE"/> <!-- 璁㈠崟鐘舵�� --> <include refid="SELECT_PARAM_ORDER_CREATE_TIME"/> <!-- 璁㈠崟鏃堕棿 --> <if test="orderNo != null and orderNo !='' "> @@ -669,4 +616,92 @@ )A </select> + <select id="getBuFenOrderState" resultMap="ResultMap"> + SELECT co.co_state,v2.`hb_state` AS hongBaoState FROM `yeshi_ec_common_order` co + LEFT JOIN yeshi_ec_hongbao_order ho ON co.`co_id`=ho.`ho_order_id` + LEFT JOIN yeshi_ec_hongbao_v2 v2 ON IF(v2.hb_pid IS NULL,v2.hb_id,v2.hb_pid)=ho.`ho_hongbao_id` + WHERE co.`co_order_no` = #{orderNo} AND co.co_state<![CDATA[<>]]> 4 AND v2.hb_uid = #{uid} + ORDER BY co.`co_state` DESC + LIMIT 1 + </select> + + <select id="listQuery" resultMap="ResultMap"> + + SELECT A.*,u.id AS userId,u.`nick_name` AS userName,u.`portrait` AS userPortrait, + pv2.`hb_uid` AS levelOneId,pv2.`hb_money` AS levelOneMoney, + ppv2.`hb_uid` AS levelTwoId,ppv2.`hb_money` AS levelTwoMoney + + FROM (SELECT hb.hb_id,hb.hb_uid,hb.`hb_money` AS totalMoney, + hb.hb_state AS hongBaoState, + hb.`hb_type` AS hongBaoType, + hb.`hb_get_time` AS accountTime, + hb.`hb_pre_get_time` AS preAccountTime, + co.*,cog.* + FROM yeshi_ec_hongbao_order ho + + LEFT JOIN (SELECT * FROM yeshi_ec_hongbao_v2 v2 + WHERE 1=1 + <include refid="SELECT_PARAM_HONGBAO_TYPE"/> <!-- 绾㈠寘绫诲瀷 --> + <include refid="SELECT_PARAM_HONGBAO_STATE"/> <!-- 绾㈠寘鐘舵�� --> + )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` + LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` + LEFT JOIN yeshi_ec_common_order_goods cog ON cog.`cog_id`= co.`co_order_goods_id` + WHERE hb.hb_id IS NOT NULL + <include refid="SELECT_PARAM_ORDER_STATE"/> <!-- 璁㈠崟鐘舵�� --> + <if test="startTime != null and startTime != '' "> + AND <![CDATA[co.co_third_create_time >= #{startTime}]]> + </if> + <if test="endTime != null and endTime != '' "> + AND <![CDATA[co.co_third_create_time <= #{endTime}]]> + </if> + + <if test="key != null and key != '' "> + <if test="keyType == 1 "> + AND co.co_order_no = ${key} + </if> + <if test="keyType == 2 "> + AND hb.hb_uid like = ${key} + </if> + </if> + + ORDER BY co.co_third_create_time DESC + LIMIT ${start},${count} + ) A + LEFT JOIN yeshi_ec_user u ON u.id = A.hb_uid + LEFT JOIN yeshi_ec_hongbao_v2 pv2 ON pv2.`hb_pid` = A.hb_id + LEFT JOIN yeshi_ec_hongbao_v2 ppv2 ON ppv2.`hb_pid` = A.hb_id + + </select> + + <select id="countQuery" resultType="java.lang.Long"> + SELECT count(ho.ho_id) + FROM yeshi_ec_hongbao_order ho + + LEFT JOIN (SELECT * FROM yeshi_ec_hongbao_v2 v2 + WHERE 1=1 + <include refid="SELECT_PARAM_HONGBAO_TYPE"/> <!-- 绾㈠寘绫诲瀷 --> + <include refid="SELECT_PARAM_HONGBAO_STATE"/> <!-- 绾㈠寘鐘舵�� --> + )hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id` + LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` + LEFT JOIN yeshi_ec_common_order_goods cog ON cog.`cog_id`= co.`co_order_goods_id` + WHERE hb.hb_id IS NOT NULL + <include refid="SELECT_PARAM_ORDER_STATE"/> <!-- 璁㈠崟鐘舵�� --> + + <if test="startTime != null and startTime != '' "> + AND <![CDATA[co.co_third_create_time >= #{startTime}]]> + </if> + <if test="endTime != null and endTime != '' "> + AND <![CDATA[co.co_third_create_time <= #{endTime}]]> + </if> + + <if test="key != null and key != '' "> + <if test="keyType == 1 "> + AND co.co_order_no = ${key} + </if> + <if test="keyType == 2 "> + AND hb.hb_uid like = ${key} + </if> + </if> + </select> + </mapper> -- Gitblit v1.8.0