From 9b94a83132a60a0c7dba86063ba073aa18bda58b Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 30 四月 2020 14:30:57 +0800 Subject: [PATCH] 订单增加子来源类型,线上用户等级同步优化 --- fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml | 139 +++++++++++++++++++++++----------------------- 1 files changed, 70 insertions(+), 69 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 1f03465..feb21b7 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 @@ -25,6 +25,8 @@ <result column="co_trade_id" property="tradeId" jdbcType="VARCHAR" /> <result column="co_state_desc" property="stateDesc" jdbcType="VARCHAR" /> <result column="co_urank" property="urank" jdbcType="INTEGER" /> + <result column="co_child_source_type" property="childSourceType" + jdbcType="VARCHAR" /> <association property="userInfo" column="co_uid" javaType="com.yeshi.fanli.entity.bus.user.UserInfo"> <id column="co_uid" property="id" jdbcType="BIGINT" /> @@ -58,6 +60,8 @@ <result column="co_trade_id" property="tradeId" jdbcType="VARCHAR" /> <result column="co_state_desc" property="stateDesc" jdbcType="VARCHAR" /> <result column="co_urank" property="urank" jdbcType="INTEGER" /> + <result column="co_child_source_type" property="childSourceType" + jdbcType="VARCHAR" /> <association property="userInfo" column="co_uid" javaType="com.yeshi.fanli.entity.bus.user.UserInfo"> <id column="co_uid" property="id" jdbcType="BIGINT" /> @@ -157,7 +161,7 @@ <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,co_urank + <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,co_urank,co_child_source_type </sql> <sql id="Order_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, @@ -221,9 +225,9 @@ </delete> <insert id="insert" parameterType="com.yeshi.fanli.entity.order.CommonOrder" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_common_order - (co_id,co_uid,co_order_no,co_source_type,co_source_position,co_order_goods_id,co_count,co_state,co_estimate,co_eIncome,co_payment,co_settlement,co_third_create_time,co_settle_time,co_create_time,co_update_time,co_state_whole_order,co_order_by,co_trade_id,co_state_desc,co_urank) + (co_id,co_uid,co_order_no,co_source_type,co_source_position,co_order_goods_id,co_count,co_state,co_estimate,co_eIncome,co_payment,co_settlement,co_third_create_time,co_settle_time,co_create_time,co_update_time,co_state_whole_order,co_order_by,co_trade_id,co_state_desc,co_urank,co_child_source_type) values - (#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{orderNo,jdbcType=VARCHAR},#{sourceType,jdbcType=INTEGER},#{sourcePosition,jdbcType=VARCHAR},#{commonOrderGoods.id,jdbcType=BIGINT},#{count,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{estimate,jdbcType=DECIMAL},#{eIncome,jdbcType=DECIMAL},#{payment,jdbcType=DECIMAL},#{settlement,jdbcType=DECIMAL},#{thirdCreateTime,jdbcType=TIMESTAMP},#{settleTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{stateWholeOrder,jdbcType=INTEGER},#{orderBy,jdbcType=INTEGER},#{tradeId,jdbcType=VARCHAR},#{stateDesc,jdbcType=VARCHAR},#{urank,jdbcType=INTEGER}) + (#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{orderNo,jdbcType=VARCHAR},#{sourceType,jdbcType=INTEGER},#{sourcePosition,jdbcType=VARCHAR},#{commonOrderGoods.id,jdbcType=BIGINT},#{count,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{estimate,jdbcType=DECIMAL},#{eIncome,jdbcType=DECIMAL},#{payment,jdbcType=DECIMAL},#{settlement,jdbcType=DECIMAL},#{thirdCreateTime,jdbcType=TIMESTAMP},#{settleTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{stateWholeOrder,jdbcType=INTEGER},#{orderBy,jdbcType=INTEGER},#{tradeId,jdbcType=VARCHAR},#{stateDesc,jdbcType=VARCHAR},#{urank,jdbcType=INTEGER},#{childSourceType,jdbcType=VARCHAR}) </insert> <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.order.CommonOrder" useGeneratedKeys="true" keyProperty="id"> @@ -250,6 +254,7 @@ <if test="tradeId != null">co_trade_id,</if> <if test="stateDesc != null">co_state_desc,</if> <if test="urank != null">co_urank,</if> + <if test="childSourceType != null">co_child_source_type,</if> </trim> values <trim prefix="(" suffix=")" suffixOverrides=","> @@ -273,7 +278,8 @@ <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> <if test="tradeId != null">#{tradeId,jdbcType=VARCHAR},</if> <if test="stateDesc != null">#{stateDesc,jdbcType=VARCHAR},</if> - <if test="urank != null">#{urank,jdbcType=INTEGER}</if> + <if test="urank != null">#{urank,jdbcType=INTEGER},</if> + <if test="childSourceType != null">#{childSourceType,jdbcType=VARCHAR},</if> </trim> </insert> <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.order.CommonOrder">update @@ -297,7 +303,8 @@ #{updateTime,jdbcType=TIMESTAMP} ,co_trade_id =#{tradeId,jdbcType=VARCHAR},co_state_desc =#{stateDesc,jdbcType=VARCHAR} ,co_urank =#{urank,jdbcType=INTEGER} - where co_id = #{id,jdbcType=BIGINT} + ,co_child_source_type =#{childSourceType,jdbcType=VARCHAR} where co_id + = #{id,jdbcType=BIGINT} </update> <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.order.CommonOrder"> update yeshi_ec_common_order @@ -323,10 +330,11 @@ <if test="orderBy != null">co_order_by=#{orderBy,jdbcType=INTEGER},</if> <if test="createTime != null">co_create_time=#{createTime,jdbcType=TIMESTAMP},</if> <if test="updateTime != null">co_update_time=#{updateTime,jdbcType=TIMESTAMP},</if> - <if test="id !=null">co_id =#{id,jdbcType=BIGINT},</if> <if test="tradeId !=null">co_trade_id =#{tradeId,jdbcType=VARCHAR},</if> <if test="stateDesc !=null">co_state_desc =#{stateDesc,jdbcType=VARCHAR},</if> <if test="urank !=null">co_urank =#{urank,jdbcType=INTEGER},</if> + <if test="childSourceType !=null">co_child_source_type=#{childSourceType,jdbcType=VARCHAR}, + </if> </set> where co_id = #{id,jdbcType=BIGINT} </update> @@ -452,10 +460,9 @@ <!-- 璁㈠崟鍙锋煡璇� --> <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if> <!-- 璁㈠崟鏉ユ簮 --> - <if test="listSource != null and listSource.size() > 0"> - <foreach collection="listSource" item="item" open="AND (" close=")" separator="or"> - co.co_source_type = #{item} - </foreach> + <if test="listSource != null and listSource.size() > 0"> + <foreach collection="listSource" item="item" open="AND (" + close=")" separator="or">co.co_source_type = #{item}</foreach> </if> GROUP BY co.`co_order_no`, co.`co_source_type` ORDER BY co.co_third_create_time DESC LIMIT ${start},${count} @@ -489,10 +496,9 @@ <!-- 璁㈠崟鍙锋煡璇� --> <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if> <!-- 璁㈠崟鏉ユ簮 --> - <if test="listSource != null and listSource.size() > 0"> - <foreach collection="listSource" item="item" open="AND (" close=")" separator="or"> - co.co_source_type = #{item} - </foreach> + <if test="listSource != null and listSource.size() > 0"> + <foreach collection="listSource" item="item" open="AND (" + close=")" separator="or">co.co_source_type = #{item}</foreach> </if> GROUP BY co.`co_order_no`, co.`co_source_type` )A </select> @@ -626,10 +632,9 @@ '%Y%m'),DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1 </if> <!-- 璁㈠崟鏉ユ簮 --> - <if test="listSource != null and listSource.size() > 0"> - <foreach collection="listSource" item="item" open="AND (" close=")" separator="or"> - co.co_source_type = #{item} - </foreach> + <if test="listSource != null and listSource.size() > 0"> + <foreach collection="listSource" item="item" open="AND (" + close=")" separator="or">co.co_source_type = #{item}</foreach> </if> </sql> <select id="getOrderCount" resultMap="OrderCountMap"> @@ -810,11 +815,10 @@ <include refid="SELECT_PARAM_ORDER_CREATE_TIME" /> <!-- 璁㈠崟鏃堕棿 --> <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if> - - <if test="payment != null"> - AND co.co_payment <![CDATA[<]]> #{payment} + <if test="payment != null">AND + co.co_payment <![CDATA[<]]> + #{payment} </if> - ORDER BY co.co_third_create_time DESC LIMIT ${start},${count} </select> <select id="countQueryByUid" resultType="java.lang.Long"> @@ -913,8 +917,9 @@ </if> <!-- 璁㈠崟鏉ユ簮 --> <if test="source != null">AND co.co_source_type = #{source}</if> - <if test="payment != null"> - AND co.co_payment <![CDATA[<]]> #{payment} + <if test="payment != null">AND + co.co_payment <![CDATA[<]]> + #{payment} </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 @@ -952,8 +957,9 @@ <foreach collection="listShopId" item="shopId" open=" and (" separator=" or " close=")">g.`cog_shop_id` =#{shopId}</foreach> </if> - <if test="payment != null"> - AND co.co_payment <![CDATA[<]]> #{payment} + <if test="payment != null">AND + co.co_payment <![CDATA[<]]> + #{payment} </if> <if test="minTime != null"> <!-- 楂橀闄╄鍗� --> @@ -979,8 +985,9 @@ <if test="keyType == 1 ">AND co.co_order_no = '${key}'</if> <if test="keyType == 2 ">AND hb.hb_uid = ${key}</if> </if> - <if test="payment != null"> - AND co.co_payment <![CDATA[<]]> #{payment} + <if test="payment != null">AND + co.co_payment <![CDATA[<]]> + #{payment} </if> <!-- 璁㈠崟鏉ユ簮 --> <if test="source != null">AND co.co_source_type = #{source}</if> @@ -1086,46 +1093,42 @@ DATE_SUB(NOW(), INTERVAL 1 DAY) GROUP BY co.`co_order_no`,co.`co_source_type`)A </select> - <select id="searchOrderByUid" resultMap="ResultMap"> - SELECT COALESCE(SUM(hb.`hb_money`),0)AS totalMoney, hb.hb_state AS hongBaoState, hb.`hb_type` AS hongBaoType, - MAX(hb.`hb_get_time`) AS accountTime, MAX(hb.`hb_pre_get_time`) AS preAccountTime, <include refid="Order_Column_List" /> - 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} AND <![CDATA[v2.`hb_type`<>10]]>)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 - <foreach collection="list" item="esOrder" open=" and (" close=")" separator=" or "> - (co.co_trade_id=#{esOrder.tradeId} AND co.co_source_type = #{esOrder.platform}) + SELECT COALESCE(SUM(hb.`hb_money`),0)AS totalMoney, hb.hb_state AS + hongBaoState, hb.`hb_type` AS hongBaoType, MAX(hb.`hb_get_time`) AS + accountTime, MAX(hb.`hb_pre_get_time`) AS preAccountTime, + <include refid="Order_Column_List" /> + 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} AND <![CDATA[v2.`hb_type`<>10]]>)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 + <foreach collection="list" item="esOrder" open=" and (" close=")" + separator=" or ">(co.co_trade_id=#{esOrder.tradeId} AND co.co_source_type = + #{esOrder.platform}) </foreach> - GROUP BY co.`co_order_no`, co.`co_source_type` - ORDER BY co.co_third_create_time DESC - LIMIT ${start},${count} + GROUP BY co.`co_order_no`, co.`co_source_type` ORDER BY + co.co_third_create_time DESC LIMIT ${start},${count} </select> - <select id="countSearchOrderByUid" resultType="java.lang.Long"> SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.ho_id 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} AND <![CDATA[v2.`hb_type`<> 10 ]]> + yeshi_ec_hongbao_order ho LEFT JOIN (SELECT + <include refid="Hongbao_Column_List" /> + FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]> )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 - <foreach collection="list" item="esOrder" open=" and (" close=")" separator=" or "> - (co.co_trade_id=#{esOrder.tradeId} AND co.co_source_type = #{esOrder.platform}) + <foreach collection="list" item="esOrder" open=" and (" close=")" + separator=" or ">(co.co_trade_id=#{esOrder.tradeId} AND co.co_source_type = + #{esOrder.platform}) </foreach> GROUP BY co.`co_order_no`, co.`co_source_type` )A </select> - - <select id="getMinSettleTimeAndUid" resultMap="BaseResultMap"> - SELECT d.`co_uid`,MAX(d.`co_settle_time`) AS co_settle_time FROM `yeshi_ec_common_order` d - WHERE d.`co_settle_time` IS NOT NULL AND d.`co_payment` > 1 - GROUP BY d.`co_uid` - </select> - - - - + <select id="getMinSettleTimeAndUid" resultMap="BaseResultMap">SELECT + d.`co_uid`,MAX(d.`co_settle_time`) AS co_settle_time FROM + `yeshi_ec_common_order` d WHERE d.`co_settle_time` IS NOT NULL AND + d.`co_payment` > 1 GROUP BY d.`co_uid`</select> <select id="getOrderList" resultMap="ResultMap"> SELECT hb.`hb_type` AS hongBaoType, MAX(hb.`hb_get_time`) AS accountTime, MAX(hb.`hb_pre_get_time`) AS preAccountTime, @@ -1156,10 +1159,9 @@ <!-- 璁㈠崟鍙锋煡璇� --> <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if> <!-- 璁㈠崟鏉ユ簮 --> - <if test="listSource != null and listSource.size() > 0"> - <foreach collection="listSource" item="item" open="AND (" close=")" separator="or"> - co.co_source_type = #{item} - </foreach> + <if test="listSource != null and listSource.size() > 0"> + <foreach collection="listSource" item="item" open="AND (" + close=")" separator="or">co.co_source_type = #{item}</foreach> </if> GROUP BY co.`co_order_no`, co.`co_source_type` ORDER BY co.co_third_create_time DESC LIMIT ${start},${count} @@ -1192,16 +1194,15 @@ <!-- 璁㈠崟鍙锋煡璇� --> <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if> <!-- 璁㈠崟鏉ユ簮 --> - <if test="listSource != null and listSource.size() > 0"> - <foreach collection="listSource" item="item" open="AND (" close=")" separator="or"> - co.co_source_type = #{item} - </foreach> + <if test="listSource != null and listSource.size() > 0"> + <foreach collection="listSource" item="item" open="AND (" + close=")" separator="or">co.co_source_type = #{item}</foreach> </if> GROUP BY co.`co_order_no`, co.`co_source_type` )A </select> - - <select id="countOrderByUidAndSettled" resultType="Long"> - SELECT COUNT(d.`co_id`) FROM `yeshi_ec_common_order` d - WHERE d.`co_uid` = #{uid} AND d.`co_settle_time` IS NOT NULL AND d.`co_payment` >= #{payment} + <select id="countOrderByUidAndSettled" resultType="Long">SELECT + COUNT(d.`co_id`) FROM `yeshi_ec_common_order` d WHERE d.`co_uid` = + #{uid} AND d.`co_settle_time` IS NOT NULL AND d.`co_payment` >= + #{payment} </select> </mapper> -- Gitblit v1.8.0