| | |
| | | <result column="co_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | <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" /> |
| | |
| | | <result column="co_create_time" property="createTime" jdbcType="TIMESTAMP" /> |
| | | <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP" /> |
| | | <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" /> |
| | |
| | | <result column="userId" property="userId" jdbcType="VARCHAR" /> |
| | | <result column="userName" property="userName" jdbcType="VARCHAR" /> |
| | | <result column="userPortrait" property="userPortrait" jdbcType="VARCHAR" /> |
| | | |
| | | <result column="hb_id" property="hongbaoId" jdbcType="BIGINT" /> |
| | | |
| | | <result column="co_trade_id" property="tradeId" jdbcType="VARCHAR" /> |
| | | |
| | | <result column="co_state_desc" property="stateDesc" jdbcType="VARCHAR" /> |
| | | <result column="co_uid" property="userId" 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" |
| | | resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap" /> |
| | | |
| | | <association property="commonOrderGoods" column="co_order_goods_id" |
| | | resultMap="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.BaseResultMap" /> |
| | | |
| | | </resultMap> |
| | | |
| | | |
| | | <resultMap id="ThreeResultMap" type="com.yeshi.fanli.vo.order.CommonOrderVO"> |
| | | <id column="co_id" property="id" jdbcType="BIGINT" /> |
| | | <result column="co_order_no" property="orderNo" jdbcType="VARCHAR" /> |
| | |
| | | <result column="userPortrait" property="userPortrait" jdbcType="VARCHAR" /> |
| | | <result column="hb_id" property="hongbaoId" jdbcType="BIGINT" /> |
| | | <result column="co_trade_id" property="tradeId" jdbcType="VARCHAR" /> |
| | | |
| | | <association property="userInfo" column="co_uid" |
| | | select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPKey"/> |
| | | |
| | | <association property="commonOrderGoods" column="co_order_goods_id" |
| | | select="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.selectByPrimaryKey"/> |
| | | <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" |
| | | select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPrimaryKey" /> |
| | | <association property="commonOrderGoods" column="co_order_goods_id" |
| | | select="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.selectByPrimaryKey" /> |
| | | </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 |
| | | <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,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, |
| | | co_estimate,co_eIncome,co_payment,co_settlement, co_third_create_time, |
| | | MAX(co_settle_time) AS co_settle_time, co_order_by, co_create_time, |
| | | co_update_time,co_state_desc,co_urank,co_child_source_type |
| | | </sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long"> |
| | |
| | | yeshi_ec_common_order co WHERE co.co_source_type=#{sourceType} and |
| | | co_order_no=#{orderNo} |
| | | </select> |
| | | |
| | | |
| | | <select id="selectBySourceTypeAndTradeId" resultMap="BaseResultMap">SELECT * |
| | | FROM |
| | | yeshi_ec_common_order co WHERE co.co_source_type=#{sourceType} and |
| | | co_trade_id=#{tradeId} limit 1 |
| | | FROM yeshi_ec_common_order co WHERE co.co_source_type=#{sourceType} |
| | | and co_trade_id=#{tradeId} limit 1 |
| | | </select> |
| | | |
| | | <select id="listBySourceTypeAndTradeId" resultMap="BaseResultMap">SELECT * |
| | | FROM |
| | | <select id="listBySourceTypeAndTradeId" resultMap="BaseResultMap">SELECT * FROM |
| | | yeshi_ec_common_order co WHERE co.co_source_type=#{sourceType} and |
| | | co_trade_id=#{tradeId} |
| | | </select> |
| | | |
| | | |
| | | |
| | | <select id="listBySourceTypeAndStateAndThirdCrateTime" resultMap="BaseResultMap">SELECT * |
| | | FROM |
| | | yeshi_ec_common_order co WHERE co.co_source_type=#{sourceType} |
| | | |
| | | <if test="state!=null"> |
| | | and co_state=#{state} |
| | | <select id="listBySourceTypeAndTradeIdList" resultMap="BaseResultMap"> |
| | | SELECT * FROM yeshi_ec_common_order co WHERE |
| | | co.co_source_type=#{sourceType} |
| | | <if test="tradeIdList!=null"> |
| | | <foreach collection="tradeIdList" item="tradeId" open=" and (" |
| | | close=")" separator=" or ">co.co_trade_id=#{tradeId}</foreach> |
| | | </if> |
| | | |
| | | <if test="minTime!=null"> |
| | | and UNIX_TIMESTAMP(co_third_create_time)*1000>=#{minTime} |
| | | </if> |
| | | |
| | | |
| | | <if test="maxTime!=null"> |
| | | and #{maxTime}> UNIX_TIMESTAMP(co_third_create_time)*1000 |
| | | </if> |
| | | |
| | | order by co_id desc |
| | | limit #{start},#{count} |
| | | </select> |
| | | |
| | | |
| | | <select id="listBySourceTypeAndStateAndThirdCrateTime" |
| | | resultMap="BaseResultMap"> |
| | | SELECT * FROM yeshi_ec_common_order co WHERE |
| | | co.co_source_type=#{sourceType} |
| | | <if test="state!=null">and co_state=#{state}</if> |
| | | <if test="minTime!=null">and |
| | | UNIX_TIMESTAMP(co_third_create_time)*1000>=#{minTime}</if> |
| | | <if test="maxTime!=null">and #{maxTime}> |
| | | UNIX_TIMESTAMP(co_third_create_time)*1000 |
| | | </if> |
| | | order by co_id desc limit #{start},#{count} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from |
| | | yeshi_ec_common_order where co_id = #{id,jdbcType=BIGINT} |
| | | </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_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}) |
| | | (#{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"> |
| | |
| | | <if test="createTime != null">co_create_time,</if> |
| | | <if test="updateTime != null">co_update_time,</if> |
| | | <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=","> |
| | |
| | | <if test="orderBy != null">#{orderBy,jdbcType=INTEGER},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="tradeId != null">#{tradeId,jdbcType=VARCHAR}</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="childSourceType != null">#{childSourceType,jdbcType=VARCHAR},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.order.CommonOrder">update |
| | |
| | | #{orderBy,jdbcType=INTEGER},co_create_time = |
| | | #{createTime,jdbcType=TIMESTAMP},co_update_time = |
| | | #{updateTime,jdbcType=TIMESTAMP} ,co_trade_id |
| | | =#{tradeId,jdbcType=VARCHAR} where co_id = #{id,jdbcType=BIGINT} |
| | | =#{tradeId,jdbcType=VARCHAR},co_state_desc |
| | | =#{stateDesc,jdbcType=VARCHAR} ,co_urank =#{urank,jdbcType=INTEGER} |
| | | ,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 |
| | |
| | | <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> |
| | |
| | | </if> |
| | | <if test="endTime != null and endTime != '' ">AND <![CDATA[co.co_third_create_time <= #{endTime}]]> |
| | | </if> |
| | | <if test="day != null and day == 1"> |
| | | <if test="day == 1"> |
| | | <!-- 今天 --> |
| | | AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW()) |
| | | </if> |
| | | <if test="day != null and day == 2"> |
| | | <if test="day == 2"> |
| | | <!-- 昨天 --> |
| | | AND TO_DAYS(NOW()) - TO_DAYS(co.`co_third_create_time`) = 1 |
| | | </if> |
| | | <if test="day != null and day == 3"> |
| | | <if test="day == 3 or day == 10"> |
| | | <!-- 本月 --> |
| | | AND DATE_FORMAT(co.`co_third_create_time`,'%Y%m') = |
| | | DATE_FORMAT(CURDATE(),'%Y%m') |
| | | </if> |
| | | <if test="day != null and day == 4"> |
| | | <if test="day == 4"> |
| | | <!-- 上月 --> |
| | | AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'), |
| | | DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1 |
| | | </if> |
| | | <if test="day == 6"> |
| | | <!-- 上月 --> |
| | | AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'), |
| | | DATE_FORMAT(co.`co_third_create_time`, '%Y%m')) = 1 |
| | | </if> |
| | | <if test="day == 11"> |
| | | <!-- 近3个月产生 --> |
| | | AND co.`co_third_create_time` BETWEEN DATE_SUB(NOW(),INTERVAL 3 |
| | | MONTH) AND NOW() |
| | | </if> |
| | | <if test="day == 12"> |
| | | <!-- 近半年产生 --> |
| | | AND co.`co_third_create_time` BETWEEN DATE_SUB(NOW(),INTERVAL 6 |
| | | MONTH) AND NOW() |
| | | </if> |
| | | </sql> |
| | | <sql id="SELECT_PARAM_HONGBAO_TYPE"> |
| | |
| | | <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> |
| | | <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, |
| | | co_estimate,co_eIncome,co_payment,co_settlement, co_third_create_time, |
| | | MAX(co_settle_time) AS co_settle_time, co_order_by, co_create_time, |
| | | co_update_time |
| | | </sql> |
| | | |
| | | <select id="listUserOrder" resultMap="ResultMap"> |
| | | <!-- 查询用户订单 --> |
| | | SELECT COALESCE(SUM(hb.`hb_money`),0)AS totalMoney, hb.hb_state AS |
| | |
| | | <include refid="Hongbao_Column_List" /> |
| | | FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]> |
| | | <include refid="SELECT_PARAM_HONGBAO_TYPE" /> |
| | | <if test="type == 2 and day == 5"> |
| | | <!-- 本月月将要到账分享订单 --> |
| | | AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') = |
| | | DATE_FORMAT(CURDATE(),'%Y%m') |
| | | </if> |
| | | <if test="type == 3 and day == 5"> |
| | | <!-- 本月将要到账邀请订单 --> |
| | | AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') = |
| | | DATE_FORMAT(CURDATE(),'%Y%m') |
| | | </if> |
| | | <!-- 红包类型 --> |
| | | )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` |
| | |
| | | <!-- 订单号查询 --> |
| | | <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if> |
| | | <!-- 订单来源 --> |
| | | <if test="source != null">AND co.co_source_type = #{source}</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> |
| | | <![CDATA[AND co.co_source_type <> 4 AND co.co_source_type <> 5]]> |
| | | GROUP BY co.`co_order_no`, co.`co_source_type` ORDER BY |
| | | co.co_third_create_time DESC LIMIT ${start},${count} |
| | | </select> |
| | | |
| | | <select id="countUserOrder" resultType="java.lang.Long"> |
| | | <!-- 统计用户订单数量 --> |
| | | SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.ho_id FROM |
| | |
| | | FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]> |
| | | <include refid="SELECT_PARAM_HONGBAO_TYPE" /> |
| | | <!-- 红包类型 --> |
| | | <if test="type == 2 and day == 5"> |
| | | <!-- 本月月将要到账分享订单 --> |
| | | AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') = |
| | | DATE_FORMAT(CURDATE(),'%Y%m') |
| | | </if> |
| | | <if test="type == 3 and day == 5"> |
| | | <!-- 本月将要到账邀请订单 --> |
| | | AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') = |
| | | DATE_FORMAT(CURDATE(),'%Y%m') |
| | | </if> |
| | | )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 |
| | |
| | | <!-- 订单号查询 --> |
| | | <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if> |
| | | <!-- 订单来源 --> |
| | | <if test="source != null">AND co.co_source_type = #{source}</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> |
| | | <![CDATA[AND co.co_source_type <> 4 AND co.co_source_type <> 5]]> |
| | | GROUP BY co.`co_order_no`, co.`co_source_type` )A |
| | | </select> |
| | | <select id="listOrderGoodsInfo" resultMap="ResultMap" |
| | |
| | | </foreach> |
| | | GROUP BY tc.`co_order_no`,tc.`co_order_goods_id` |
| | | </select> |
| | | |
| | | |
| | | <select id="countHistoryOrder" resultType="java.util.HashMap"> |
| | | <!-- 统计历史订单数量 --> |
| | | SELECT SUM(A.self)AS totalSelf,SUM(A.shared)AS |
| | |
| | | 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 |
| | | WHERE hb.hb_id IS NOT NULL and hb.hb_state!=4 |
| | | <if test="day != null and day == 1"> |
| | | <!-- 今天 --> |
| | | AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW()) |
| | |
| | | </if> |
| | | <!-- 订单来源 --> |
| | | <if test="source != null">AND co.co_source_type = #{source}</if> |
| | | |
| | | GROUP BY co.`co_order_no`, co.`co_source_type`)YX |
| | | |
| | | UNION ALL |
| | | |
| | | GROUP BY co.`co_order_no`, co.`co_source_type`)YX UNION ALL |
| | | <!-- 分享订单 --> |
| | | SELECT 0 AS self,IFNULL(COUNT(ho_id),0) AS shared,0 AS invite FROM |
| | | (SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT * |
| | |
| | | = 20 ) 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 |
| | | WHERE hb.hb_id IS NOT NULL and hb.hb_state!=4 |
| | | <if test="day != null and day == 1"> |
| | | <!-- 今天 --> |
| | | AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW()) |
| | |
| | | </if> |
| | | <!-- 订单来源 --> |
| | | <if test="source != null">AND co.co_source_type = #{source}</if> |
| | | |
| | | GROUP BY co.`co_order_no`, co.`co_source_type`)WQ |
| | | |
| | | UNION ALL |
| | | |
| | | GROUP BY co.`co_order_no`, co.`co_source_type`)WQ UNION ALL |
| | | <!-- 邀请订单 --> |
| | | SELECT 0 AS self,0 AS shared,IFNULL(COUNT(ho_id),0) AS invite FROM |
| | | (SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT * |
| | |
| | | (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 hbp.hb_id IS NOT NULL |
| | | co.`co_id`=ho.`ho_order_id` WHERE hbp.hb_id IS NOT NULL and |
| | | hbp.hb_state!=4 |
| | | <if test="day != null and day == 1"> |
| | | <!-- 今天 --> |
| | | AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW()) |
| | |
| | | </if> |
| | | <!-- 订单来源 --> |
| | | <if test="source != null">AND co.co_source_type = #{source}</if> |
| | | |
| | | GROUP BY co.`co_order_no`, co.`co_source_type`)SX )A |
| | | </select> |
| | | |
| | | |
| | | <select id="countByUidAndOrderState" resultType="java.util.HashMap"> |
| | | SELECT SUM(A.valid)AS totalValid, SUM(A.proces)AS |
| | | totalProces,SUM(A.Invalid)AS totalInvite FROM ( |
| | | <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="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"> |
| | | 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" /> |
| | | 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" /> |
| | | 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" /> |
| | | GROUP BY co.`co_order_no`,co.`co_source_type`)A )B |
| | | </select> |
| | | <select id="countUserOrderToApp" resultType="Long"> |
| | | <!-- 有效订单 --> |
| | | SELECT IFNULL(COUNT(ho_id),0) AS valid,0 AS proces,0 AS Invalid FROM |
| | | (SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT * |
| | | FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`=${uid} |
| | | 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 WHERE v2.`hb_uid`=${uid} |
| | | <include refid="SELECT_PARAM_HONGBAO_TYPE" /> |
| | | <if test="state != null and state == 1"> |
| | | <!-- 未到账 --> |
| | | AND (v2.hb_state = 1 or v2.hb_state = 2) |
| | | </if> |
| | | <if test="state != null and state == 2"> |
| | | <!-- 已到账 --> |
| | | AND v2.hb_state = 3 |
| | | </if> |
| | | <if test="state != null and state == 3"> |
| | | <!-- 红包已失效 --> |
| | | AND v2.hb_state =4 |
| | | </if> |
| | | ) 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 <![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" /> |
| | | <!-- 订单来源 --> |
| | | <if test="source != null">AND co.co_source_type = #{source}</if> |
| | | GROUP BY co.`co_order_no`, co.`co_source_type`)YX |
| | | |
| | | UNION ALL |
| | | |
| | | <!-- 维权订单 --> |
| | | SELECT 0 AS valid,IFNULL(COUNT(ho_id),0) AS proces,0 AS Invalid FROM |
| | | (SELECT ho.`ho_id` 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" /> |
| | | ) 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 AND co.`co_state` = 3 |
| | | WHERE hb.hb_id IS NOT NULL<![CDATA[AND co.`co_state` <> 3]]> |
| | | <if test="stateOrder == 1"> |
| | | <!-- 有效订单 --> |
| | | AND (co.`co_state_whole_order` =1 OR co.`co_state_whole_order` = 2) |
| | | </if> |
| | | <if test="stateOrder == 2"> |
| | | <!-- 维权订单 --> |
| | | AND co.`co_state` = 3 |
| | | </if> |
| | | <if test="stateOrder == 3"> |
| | | <!-- 失效订单 --> |
| | | AND co.`co_state_whole_order` = 3 |
| | | </if> |
| | | <!-- 订单时间 --> |
| | | <include refid="SELECT_PARAM_ORDER_CREATE_TIME" /> |
| | | <!-- 订单来源 --> |
| | | <if test="source != null">AND co.co_source_type = #{source}</if> |
| | | GROUP BY co.`co_order_no`, co.`co_source_type`)WQ |
| | | |
| | | UNION ALL |
| | | |
| | | <!-- 失效订单 --> |
| | | SELECT 0 AS valid,0 AS proces,IFNULL(COUNT(ho_id),0) AS Invalid FROM |
| | | (SELECT ho.`ho_id` 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" /> |
| | | ) 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 AND co.`co_state_whole_order` = 3 |
| | | <include refid="SELECT_PARAM_ORDER_CREATE_TIME" /> |
| | | <!-- 订单来源 --> |
| | | <if test="source != null">AND co.co_source_type = #{source}</if> |
| | | GROUP BY co.`co_order_no`, co.`co_source_type`)SX )A |
| | | <!-- 订单来源 --> |
| | | <if test="source != null">AND co.co_source_type = #{source}</if> |
| | | GROUP BY co.`co_order_no`, co.`co_source_type` )A |
| | | </select> |
| | | <!-- <select id="countByUidAndOrderState" resultType="java.util.HashMap"> |
| | | SELECT SUM(A.valid)AS totalValid, SUM(A.proces)AS totalProces,SUM(A.Invalid)AS |
| | | totalInvite FROM ( 有效订单 SELECT IFNULL(COUNT(ho_id),0) AS valid,0 AS proces,0 |
| | | AS Invalid FROM (SELECT ho.`ho_id` 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" /> ) 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 <![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" |
| | | /> 订单来源 <if test="source != null">AND co.co_source_type = #{source}</if> |
| | | GROUP BY co.`co_order_no`, co.`co_source_type`)YX UNION ALL 维权订单 SELECT 0 |
| | | AS valid,IFNULL(COUNT(ho_id),0) AS proces,0 AS Invalid FROM (SELECT ho.`ho_id` |
| | | 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" /> |
| | | ) 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 AND co.`co_state` = 3 <include refid="SELECT_PARAM_ORDER_CREATE_TIME" |
| | | /> 订单来源 <if test="source != null">AND co.co_source_type = #{source}</if> |
| | | GROUP BY co.`co_order_no`, co.`co_source_type`)WQ UNION ALL 失效订单 SELECT 0 |
| | | AS valid,0 AS proces,IFNULL(COUNT(ho_id),0) AS Invalid FROM (SELECT ho.`ho_id` |
| | | 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" /> |
| | | ) 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 AND co.`co_state_whole_order` = 3 <include refid="SELECT_PARAM_ORDER_CREATE_TIME" |
| | | /> 订单来源 <if test="source != null">AND co.co_source_type = #{source}</if> |
| | | GROUP BY co.`co_order_no`, co.`co_source_type`)SX )A </select> --> |
| | | <select id="countBonusOrderNumber" resultType="java.lang.Long"> |
| | | <!-- 奖金统计:订单数量 --> |
| | | SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.`ho_id` FROM |
| | |
| | | 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> <!-- 上月 :统计已收货 --> |
| | | <if test="source != null">AND co.co_source_type = #{source}</if> |
| | | <if test="day != null and day == 4">AND co.`co_state` = 2</if> |
| | | <!-- 上月 :统计已收货 --> |
| | | <if test="source != null">AND co.co_source_type = #{source}</if> |
| | | GROUP BY co.`co_order_no`, co.`co_source_type` )A |
| | | </select> |
| | | <sql id="SELECT_HONGBAO_STATE"> |
| | |
| | | <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> |
| | | ORDER BY co.co_third_create_time DESC LIMIT ${start},${count} |
| | | </select> |
| | | <select id="countQueryByUid" resultType="java.lang.Long"> |
| | |
| | | userPortrait 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.* FROM yeshi_ec_hongbao_order ho LEFT JOIN |
| | | (SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1 |
| | | preAccountTime, co.* 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_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 co ON co.`co_id`=ho.`ho_order_id` |
| | | <if test="listShopId != null">LEFT JOIN yeshi_ec_common_order_goods g ON |
| | | co.`co_order_goods_id`=g.`cog_id` |
| | | </if> |
| | | WHERE hb.hb_id IS NOT NULL |
| | | <include refid="SELECT_PARAM_ORDER_STATE" /> |
| | | <!-- 订单状态 --> |
| | |
| | | <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 == 1 ">AND co.co_order_no = '${key}'</if> |
| | | <if test="keyType == 2 ">AND hb.hb_uid = ${key}</if> |
| | | </if> |
| | | <!-- 订单来源 --> |
| | | <if test="source != null">AND co.co_source_type = #{source}</if> |
| | | <if test="listGoodsId != null"> |
| | | <foreach collection="listGoodsId" item="goodsId" open=" and (" |
| | | separator=" or " close=")">co.`co_order_goods_id` =#{goodsId}</foreach> |
| | | </if> |
| | | <if test="listShopId != null"> |
| | | <foreach collection="listShopId" item="shopId" open=" and (" |
| | | separator=" or " close=")">g.`cog_shop_id` =#{shopId}</foreach> |
| | | </if> |
| | | <if test="minTime != null"> |
| | | <!-- 高风险订单 --> |
| | | AND co.`co_third_create_time`>#{minTime} AND<![CDATA[ (co.`co_estimate`>= ${money} OR co.`co_eIncome`> ${money})]]> |
| | | </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 |
| | | </select> |
| | | <select id="listQueryWithNoChild" resultMap="ThreeResultMap"> |
| | | SELECT A.*,u.id AS userId,u.`nick_name` AS userName,u.`portrait` AS |
| | | userPortrait 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.* 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_HONGBAO_STATE" /> |
| | | <!-- 红包状态 --> |
| | | )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 |
| | | <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 = ${key}</if> |
| | | </if> |
| | | <!-- 订单来源 --> |
| | | <if test="source != null">AND co.co_source_type = #{source}</if> |
| | | <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 |
| | | </select> |
| | |
| | | <include refid="SELECT_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` |
| | | WHERE hb.hb_id IS NOT NULL |
| | | LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` |
| | | <if test="listShopId != null">LEFT JOIN yeshi_ec_common_order_goods g ON |
| | | co.`co_order_goods_id`=g.`cog_id` |
| | | </if> |
| | | 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 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 == 1 ">AND co.co_order_no = '${key}'</if> |
| | | <if test="keyType == 2 ">AND hb.hb_uid = ${key}</if> |
| | | </if> |
| | | <!-- 订单来源 --> |
| | | <if test="source != null">AND co.co_source_type = #{source}</if> |
| | | <if test="listGoodsId != null"> |
| | | <foreach collection="listGoodsId" item="goodsId" open=" and (" |
| | | separator=" or " close=")">co.`co_order_goods_id` =#{goodsId}</foreach> |
| | | </if> |
| | | <if test="listShopId != null"> |
| | | <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> |
| | | <if test="minTime != null"> |
| | | <!-- 高风险订单 --> |
| | | AND co.`co_third_create_time`>#{minTime} AND<![CDATA[ (co.`co_estimate`>= ${money} OR co.`co_eIncome`> ${money})]]> |
| | | </if> |
| | | </select> |
| | | <select id="countQueryWithNoChild" 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_HONGBAO_STATE" /> |
| | | <!-- 红包状态 --> |
| | | )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 |
| | | <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 = ${key}</if> |
| | | </if> |
| | | <if test="payment != null">AND |
| | | co.co_payment <![CDATA[<]]> |
| | | #{payment} |
| | | </if> |
| | | <!-- 订单来源 --> |
| | | <if test="source != null">AND co.co_source_type = #{source}</if> |
| | |
| | | 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 AND co.co_order_no = #{orderNo} AND co.`co_source_type` = #{sourceType} |
| | | WHERE hb.hb_id IS NOT NULL AND co.co_order_no = #{orderNo} AND |
| | | co.`co_source_type` = #{sourceType} |
| | | <if test="orderState != null"> |
| | | AND co.co_state = #{orderState} |
| | | <!-- 已收货 --> |
| | | </if> |
| | | GROUP BY co.`co_order_no`, co.`co_source_type` |
| | | </select> |
| | | <select id="getByOrderNo" resultMap="BaseResultMap">SELECT * FROM |
| | | yeshi_ec_common_order co WHERE co_uid = #{uid} AND |
| | | co_order_no=#{orderNo} |
| | | </select> |
| | | <select id="listByUid" resultMap="BaseResultMap"> |
| | | SELECT * FROM yeshi_ec_common_order co WHERE co_uid = #{uid} |
| | | <if test="stateList!=null"> |
| | | <foreach collection="stateList" separator=" or " open="and (" |
| | | item="state" close=")">co_state=#{state}</foreach> |
| | | </if> |
| | | limit #{start},#{count} |
| | | </select> |
| | | <select id="firstValidOrderByUid" resultMap="ResultMap"> |
| | | SELECT co.*,v2.`hb_get_time` AS accountTime FROM |
| | | yeshi_ec_hongbao_order ho LEFT JOIN yeshi_ec_hongbao_v2 v2 ON |
| | | IF(v2.hb_pid IS NULL,v2.hb_id,v2.hb_pid)=ho.`ho_hongbao_id` LEFT JOIN |
| | | yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` WHERE v2.hb_id |
| | | IS NOT NULL AND v2.`hb_uid` = #{uid} AND v2.`hb_state` = 3 |
| | | <if test="typeHB == 1"> |
| | | <!-- 自购订单 --> |
| | | AND (v2.hb_type =1 or v2.hb_type =2) |
| | | </if> |
| | | <if test="typeHB == 2"> |
| | | <!-- 分享订单 --> |
| | | AND v2.`hb_type` = 20 |
| | | </if> |
| | | <if test="typeHB == 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="typeDate == 3"> |
| | | <!-- 本月 --> |
| | | AND DATE_FORMAT(co.`co_create_time`,'%Y%m') = |
| | | DATE_FORMAT(CURDATE(),'%Y%m') |
| | | </if> |
| | | <if test="typeDate == 4"> |
| | | <!-- 上月 --> |
| | | AND PERIOD_DIFF(DATE_FORMAT(NOW(), |
| | | '%Y%m'),DATE_FORMAT(co.`co_create_time`, '%Y%m')) = 1 |
| | | </if> |
| | | ORDER BY co.`co_id` LIMIT 1 |
| | | </select> |
| | | <select id="getFirstShareOrderByUid" resultMap="BaseResultMap">SELECT co.* FROM |
| | | yeshi_ec_hongbao_order ho LEFT JOIN yeshi_ec_hongbao_v2 v2 ON v2.hb_id |
| | | = ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON |
| | | co.`co_id`=ho.`ho_order_id` WHERE v2.`hb_uid` = #{uid} AND |
| | | v2.`hb_type` = 20 ORDER BY co.`co_third_create_time` LIMIT 1 |
| | | </select> |
| | | <select id="getTotalRewardMoneyByOrderNoAndSourceType" |
| | | resultType="BigDecimal">SELECT SUM(hb_money) FROM(SELECT v2.`hb_money` FROM |
| | | yeshi_ec_hongbao_order ho LEFT JOIN yeshi_ec_hongbao_v2 v2 ON v2.hb_id |
| | | = ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON |
| | | co.`co_id`=ho.`ho_order_id` WHERE v2.`hb_type` = 20 AND v2.`hb_state` |
| | | = 3 AND co.`co_order_no` = #{orderNo} AND co.`co_source_type`= |
| | | #{sourceType})A |
| | | </select> |
| | | <select id="count24HValidOrderByUid" resultType="Long">SELECT |
| | | IFNULL(COUNT(A.co_order_no),0) FROM (SELECT co.`co_order_no` FROM |
| | | yeshi_ec_hongbao_order ho LEFT JOIN yeshi_ec_hongbao_v2 v2 ON v2.hb_id |
| | | = ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON |
| | | co.`co_id`=ho.`ho_order_id` WHERE v2.`hb_type` = 1 AND |
| | | co.`co_state_whole_order`<![CDATA[<>]]> |
| | | 3 AND co.`co_uid` = #{uid} AND co.co_third_create_time <![CDATA[>]]> |
| | | #{minTime} AND co.`co_third_create_time` <![CDATA[<=]]> |
| | | 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}) |
| | | </foreach> |
| | | 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 ]]> |
| | | )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` )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="getOrderList" resultMap="ResultMap"> |
| | | SELECT 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 ]]> |
| | | <include refid="SELECT_PARAM_HONGBAO_TYPE" /> |
| | | <if test="type == 2 and day == 5"> |
| | | <!-- 本月月将要到账分享订单 --> |
| | | AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') = |
| | | DATE_FORMAT(CURDATE(),'%Y%m') |
| | | </if> |
| | | <if test="type == 3 and day == 5"> |
| | | <!-- 本月将要到账邀请订单 --> |
| | | AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') = |
| | | DATE_FORMAT(CURDATE(),'%Y%m') |
| | | </if> |
| | | <!-- 红包类型 --> |
| | | )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_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> |
| | | <!-- 订单来源 --> |
| | | <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> |
| | | <if test="notBackSuVip == true"> |
| | | <![CDATA[AND co.co_source_type <> 4 AND co.co_source_type <> 5]]> |
| | | </if> |
| | | GROUP BY co.`co_order_no`, co.`co_source_type` ORDER BY |
| | | co.co_third_create_time DESC LIMIT ${start},${count} |
| | | </select> |
| | | <select id="countOrderList" 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 ]]> |
| | | <include refid="SELECT_PARAM_HONGBAO_TYPE" /> |
| | | <!-- 红包类型 --> |
| | | <if test="type == 2 and day == 5"> |
| | | <!-- 本月月将要到账分享订单 --> |
| | | AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') = |
| | | DATE_FORMAT(CURDATE(),'%Y%m') |
| | | </if> |
| | | <if test="type == 3 and day == 5"> |
| | | <!-- 本月将要到账邀请订单 --> |
| | | AND DATE_FORMAT(v2.`hb_pre_get_time`,'%Y%m') = |
| | | DATE_FORMAT(CURDATE(),'%Y%m') |
| | | </if> |
| | | )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_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> |
| | | <!-- 订单来源 --> |
| | | <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> |
| | | <if test="notBackSuVip == true"> |
| | | <![CDATA[AND co.co_source_type <> 4 AND co.co_source_type <> 5]]> |
| | | </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> |
| | | |
| | | <select id="getNewestOrderNoByTaoBao" resultType="String"> |
| | | SELECT d.`co_order_no` FROM `yeshi_ec_common_order` d |
| | | WHERE d.`co_source_type` = 1 |
| | | ORDER BY d.`co_id` DESC |
| | | LIMIT 1 |
| | | </select> |
| | | |
| | | <select id="listByOrderNo" resultMap="BaseResultMap"> |
| | | SELECT * FROM `yeshi_ec_common_order` d |
| | | WHERE d.`co_order_no` = #{orderNo} |
| | | GROUP BY d.`co_order_no`,d.`co_source_type` |
| | | </select> |
| | | </mapper> |