From e915a40b79552686b8d8a8cfc48a341fa2c0f518 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期三, 27 十一月 2019 18:08:47 +0800 Subject: [PATCH] 订单统计 + 资金明细 --- fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml | 77 ++++++++++++++++++++++++++++++++------ 1 files changed, 65 insertions(+), 12 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 2df964f..38e1dea 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 @@ -159,6 +159,12 @@ select="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.selectByPrimaryKey" /> </resultMap> + <resultMap id="OrderCountMap" type="com.yeshi.fanli.vo.order.OrderCountVO" > + <result column="self" property="self" jdbcType="BIGINT" /> + <result column="shared" property="shared" jdbcType="BIGINT" /> + <result column="invite" property="invite" jdbcType="BIGINT" /> + </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,co_trade_id,co_state_desc </sql> @@ -390,28 +396,28 @@ </if> <if test="day != null and day == 3"> <!-- 鏈湀 --> - AND DATE_FORMAT(co.`co_third_create_time`,'%Y%m') = - DATE_FORMAT(CURDATE(),'%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_settle_time`, '%Y%m')) = 1 + AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'), DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1 </if> </sql> <sql id="SELECT_PARAM_HONGBAO_TYPE"> - <if test="type != null and type == 1"> - <!-- 鑷喘璁㈠崟 --> + <if test="type != null and type == 1"> <!-- 鑷喘璁㈠崟 --> AND (v2.hb_type =1 or v2.hb_type =2) </if> - <if test="type != null and type == 2"> - <!-- 鍒嗕韩璁㈠崟 --> + <if test="type != null and type == 2"> <!-- 鍒嗕韩璁㈠崟 --> AND v2.`hb_type` = 20 </if> - <if test="type != null and type == 3"> - <!-- 閭�璇疯鍗� --> - 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) + <if test="type != null and type == 3"> <!-- 閭�璇疯鍗� --> + 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) + </if> + <if test="type == 2 and day == 5"> <!-- 鏈湀鏈堝皢瑕佸埌璐� --> + AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'), DATE_FORMAT(v2.`hb_pre_get_time`, '%Y%m')) = 1 + </if> + <if test="type == 3 and day == 5"> <!-- 鏈湀灏嗚鍒拌处 --> + AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'), DATE_FORMAT(v2.`hb_pre_get_time`, '%Y%m')) = 1 </if> </sql> <sql id="SELECT_PARAM_HONGBAO_STATE"> @@ -604,6 +610,53 @@ GROUP BY co.`co_order_no`, co.`co_source_type`)SX )A </select> + + <sql id="OrderCountQuery"> + WHERE co.`co_state_whole_order`<![CDATA[<>]]>3 + <if test="day == 1"> <!-- 浠婂ぉ --> + AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW()) + </if> + <if test="day == 2"> <!-- 鏄ㄥぉ --> + AND TO_DAYS(NOW()) - TO_DAYS(co.`co_third_create_time`) = 1 + </if> + <if test="day == 3"> <!-- 鏈湀 --> + AND DATE_FORMAT(co.`co_third_create_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m') + </if> + <if test="day == 4"> <!-- 涓婃湀 --> + AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1 + </if> + <!-- 璁㈠崟鏉ユ簮 --> + <if test="source != null">AND co.co_source_type = #{source}</if> + </sql> + + <select id="getOrderCount" resultMap="OrderCountMap"> + SELECT sum(self) as self,sum(shared) as shared,sum(invite) as invite from + ( + SELECT IFNULL(COUNT(co_order_no),0)AS self,0 AS shared,0 AS invite FROM + (SELECT co.`co_order_no` FROM (SELECT * FROM yeshi_ec_hongbao_v2 v WHERE v.`hb_uid`= ${uid} AND v.`hb_type` = 1)v2 + LEFT JOIN yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id` = IF(v2.hb_pid IS NULL,v2.hb_id,v2.hb_pid) + LEFT JOIN yeshi_ec_common_order co ON co.`co_id` = ho.`ho_order_id` + <include refid="OrderCountQuery"></include> + GROUP BY co.`co_order_no`,co.`co_source_type`)A + UNION ALL + SELECT 0 AS self,IFNULL(COUNT(co_order_no),0)AS shared,0 AS invite FROM + (SELECT co.`co_order_no` FROM (SELECT * FROM yeshi_ec_hongbao_v2 v WHERE v.`hb_uid`= ${uid} AND v.`hb_type` = 20)v2 + LEFT JOIN yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id` = IF(v2.hb_pid IS NULL,v2.hb_id,v2.hb_pid) + LEFT JOIN yeshi_ec_common_order co ON co.`co_id` = ho.`ho_order_id` + <include refid="OrderCountQuery"></include> + GROUP BY co.`co_order_no`,co.`co_source_type`)A + UNION ALL + SELECT 0 AS self,0 AS shared,IFNULL(COUNT(co_order_no),0)AS invite FROM + (SELECT co.`co_order_no` FROM (SELECT * FROM yeshi_ec_hongbao_v2 v + WHERE v.`hb_uid`= ${uid} + AND (v.`hb_type` = 5 OR v.`hb_type` = 6 OR v.`hb_type` = 7 OR v.`hb_type` = 21 OR v.`hb_type` = 22))v2 + LEFT JOIN yeshi_ec_hongbao_order ho ON ho.`ho_hongbao_id` = IF(v2.hb_pid IS NULL,v2.hb_id,v2.hb_pid) + LEFT JOIN yeshi_ec_common_order co ON co.`co_id` = ho.`ho_order_id` + <include refid="OrderCountQuery"></include> + GROUP BY co.`co_order_no`,co.`co_source_type`)A + )B + </select> + <select id="countUserOrderToApp" resultType="Long"> <!-- 鏈夋晥璁㈠崟 --> -- Gitblit v1.8.0