<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.yeshi.fanli.dao.mybatis.order.CommonOrderMapper">
|
<resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.order.CommonOrder">
|
<id column="co_id" property="id" jdbcType="BIGINT"/>
|
<result column="co_order_no" property="orderNo" jdbcType="VARCHAR"/>
|
<result column="co_source_type" property="sourceType" jdbcType="INTEGER"/>
|
<result column="co_source_position" property="sourcePosition" jdbcType="VARCHAR"/>
|
<result column="co_count" property="count" jdbcType="INTEGER"/>
|
<result column="co_state" property="state" jdbcType="INTEGER"/>
|
<result column="co_estimate" property="estimate" jdbcType="DECIMAL"/>
|
<result column="co_eIncome" property="eIncome" jdbcType="DECIMAL"/>
|
<result column="co_payment" property="payment" jdbcType="DECIMAL"/>
|
<result column="co_settlement" property="settlement" jdbcType="DECIMAL"/>
|
<result column="co_third_create_time" property="thirdCreateTime" jdbcType="TIMESTAMP"/>
|
<result column="co_settle_time" property="settleTime" jdbcType="TIMESTAMP"/>
|
<result column="co_create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
<result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
|
<association property="userInfo" column="co_uid"
|
javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
|
<id column="co_uid" property="id" jdbcType="BIGINT" />
|
</association>
|
|
<association property="commonOrderGoods" column="co_order_goods_id"
|
javaType="com.yeshi.fanli.entity.order.CommonOrderGoods">
|
<id column="co_order_goods_id" property="id" jdbcType="BIGINT" />
|
</association>
|
</resultMap>
|
|
<resultMap id="ResultMap" 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="co_source_type" property="sourceType" jdbcType="INTEGER"/>
|
<result column="co_source_position" property="sourcePosition" jdbcType="VARCHAR"/>
|
<result column="co_count" property="count" jdbcType="INTEGER"/>
|
<result column="co_state" property="state" jdbcType="INTEGER"/>
|
<result column="co_estimate" property="estimate" jdbcType="DECIMAL"/>
|
<result column="co_eIncome" property="eIncome" jdbcType="DECIMAL"/>
|
<result column="co_payment" property="payment" jdbcType="DECIMAL"/>
|
<result column="co_settlement" property="settlement" jdbcType="DECIMAL"/>
|
<result column="co_third_create_time" property="thirdCreateTime" jdbcType="TIMESTAMP"/>
|
<result column="co_settle_time" property="settleTime" jdbcType="TIMESTAMP"/>
|
<result column="co_create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
<result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
|
<result column="totalMoney" property="hongBao" jdbcType="DECIMAL"/>
|
<result column="hongBaoState" property="hongBaoState" jdbcType="INTEGER"/>
|
<result column="hongBaoType" property="hongBaoType" jdbcType="INTEGER"/>
|
<result column="accountTime" property="accountTime" jdbcType="TIMESTAMP"/>
|
<result column="preAccountTime" property="preAccountTime" jdbcType="TIMESTAMP"/>
|
|
<result column="totalCount" property="totalCount" jdbcType="INTEGER"/>
|
<result column="totalSettlement" property="totalSettlement" jdbcType="DECIMAL"/>
|
|
<association property="userInfo" column="co_uid"
|
resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap">
|
</association>
|
|
<association property="commonOrderGoods" column="co_order_goods_id"
|
resultMap="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.BaseResultMap">
|
</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_estimate,co_eIncome,co_payment,co_settlement,co_third_create_time,co_settle_time,cog_create_time,cog_update_time</sql>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
|
<include refid="Base_Column_List"/>from yeshi_ec_common_order where co_id = #{id,jdbcType=BIGINT}
|
</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,cog_create_time,cog_update_time) 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})</insert>
|
<insert id="insertSelective" parameterType="com.yeshi.fanli.entity.order.CommonOrder" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_common_order
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">co_id,</if>
|
<if test="userInfo != null">co_uid,</if>
|
<if test="orderNo != null">co_order_no,</if>
|
<if test="sourceType != null">co_source_type,</if>
|
<if test="sourcePosition != null">co_source_position,</if>
|
<if test="commonOrderGoods != null">co_order_goods_id,</if>
|
<if test="count != null">co_count,</if>
|
<if test="state != null">co_state,</if>
|
<if test="estimate != null">co_estimate,</if>
|
<if test="eIncome != null">co_eIncome,</if>
|
<if test="payment != null">co_payment,</if>
|
<if test="settlement != null">co_settlement,</if>
|
<if test="thirdCreateTime != null">co_third_create_time,</if>
|
<if test="settleTime != null">co_settle_time,</if>
|
<if test="createTime != null">cog_create_time,</if>
|
<if test="updateTime != null">cog_update_time,</if>
|
</trim>values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">#{id,jdbcType=BIGINT},</if>
|
<if test="userInfo != null">#{userInfo.id,jdbcType=BIGINT},</if>
|
<if test="orderNo != null">#{orderNo,jdbcType=VARCHAR},</if>
|
<if test="sourceType != null">#{sourceType,jdbcType=INTEGER},</if>
|
<if test="sourcePosition != null">#{sourcePosition,jdbcType=VARCHAR},</if>
|
<if test="commonOrderGoods != null">#{commonOrderGoods.id,jdbcType=BIGINT},</if>
|
<if test="count != null">#{count,jdbcType=INTEGER},</if>
|
<if test="state != null">#{state,jdbcType=INTEGER},</if>
|
<if test="estimate != null">#{estimate,jdbcType=DECIMAL},</if>
|
<if test="eIncome != null">#{eIncome,jdbcType=DECIMAL},</if>
|
<if test="payment != null">#{payment,jdbcType=DECIMAL},</if>
|
<if test="settlement != null">#{settlement,jdbcType=DECIMAL},</if>
|
<if test="thirdCreateTime != null">#{thirdCreateTime,jdbcType=TIMESTAMP},</if>
|
<if test="settleTime != null">#{settleTime,jdbcType=TIMESTAMP},</if>
|
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
|
<if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
|
</trim>
|
</insert>
|
<update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.order.CommonOrder">update yeshi_ec_common_order set co_uid = #{userInfo.id,jdbcType=BIGINT},co_order_no = #{orderNo,jdbcType=VARCHAR},co_source_type = #{sourceType,jdbcType=INTEGER},co_source_position = #{sourcePosition,jdbcType=VARCHAR},co_order_goods_id = #{commonOrderGoods.id,jdbcType=BIGINT},co_count = #{count,jdbcType=INTEGER},co_state = #{state,jdbcType=INTEGER},co_estimate = #{estimate,jdbcType=DECIMAL},co_eIncome = #{eIncome,jdbcType=DECIMAL},co_payment = #{payment,jdbcType=DECIMAL},co_settlement = #{settlement,jdbcType=DECIMAL},co_third_create_time = #{thirdCreateTime,jdbcType=TIMESTAMP},co_settle_time = #{settleTime,jdbcType=TIMESTAMP},cog_create_time = #{createTime,jdbcType=TIMESTAMP},cog_update_time = #{updateTime,jdbcType=TIMESTAMP} where co_id = #{id,jdbcType=BIGINT}</update>
|
<update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.order.CommonOrder">update yeshi_ec_common_order
|
<set>
|
<if test="userInfo != null">co_uid=#{userInfo.id,jdbcType=BIGINT},</if>
|
<if test="orderNo != null">co_order_no=#{orderNo,jdbcType=VARCHAR},</if>
|
<if test="sourceType != null">co_source_type=#{sourceType,jdbcType=INTEGER},</if>
|
<if test="sourcePosition != null">co_source_position=#{sourcePosition,jdbcType=VARCHAR},</if>
|
<if test="commonOrderGoods != null">co_order_goods_id=#{commonOrderGoods.id,jdbcType=BIGINT},</if>
|
<if test="count != null">co_count=#{count,jdbcType=INTEGER},</if>
|
<if test="state != null">co_state=#{state,jdbcType=INTEGER},</if>
|
<if test="estimate != null">co_estimate=#{estimate,jdbcType=DECIMAL},</if>
|
<if test="eIncome != null">co_eIncome=#{eIncome,jdbcType=DECIMAL},</if>
|
<if test="payment != null">co_payment=#{payment,jdbcType=DECIMAL},</if>
|
<if test="settlement != null">co_settlement=#{settlement,jdbcType=DECIMAL},</if>
|
<if test="thirdCreateTime != null">co_third_create_time=#{thirdCreateTime,jdbcType=TIMESTAMP},</if>
|
<if test="settleTime != null">co_settle_time=#{settleTime,jdbcType=TIMESTAMP},</if>
|
<if test="createTime != null">cog_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
|
<if test="updateTime != null">cog_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
|
</set> where co_id = #{id,jdbcType=BIGINT}
|
</update>
|
|
<select id="listGroupOrderNoByUid" resultMap="ResultMap" >
|
SELECT COALESCE(SUM(th.`hb_money`),0)AS totalMoney,tc.*,th.hb_state AS hongBaoState, th.hb_type AS hongBaoType,
|
th.hb_get_time AS accountTime,th.hb_get_time AS accountTime,th.hb_pre_get_time AS preAccountTime
|
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}
|
<if test="state != null">
|
AND th.hb_state = #{state}
|
</if>
|
<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="orderNo != null">
|
AND tc.co_order_no = #{orderNo}
|
</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>
|
GROUP BY tc.`co_order_no`
|
ORDER BY tc.co_create_time DESC
|
LIMIT #{start},#{count}
|
</select>
|
|
<select id="countGroupOrderNoByUid" resultType="java.lang.Long">
|
SELECT IFNULL(COUNT(DISTINCT tc.`co_order_no`,tc.`co_source_type`),0) 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}
|
<if test="state != null">
|
AND th.hb_state = #{state}
|
</if>
|
<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="orderNo != null">
|
AND tc.co_order_no = #{orderNo}
|
</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>
|
</select>
|
|
<select id="listByOrderNoAndType" resultMap="ResultMap" parameterType="java.util.List">
|
SELECT COALESCE(SUM(tc.`co_settlement`),0)AS totalSettlement,COALESCE(SUM(tc.`co_count`),0)AS totalCount,tc.`co_source_type`,tc.`co_order_no`,tg.*
|
FROM yeshi_ec_common_order_goods tg
|
LEFT JOIN yeshi_ec_common_order tc ON tc.`co_order_goods_id` = tg.`cog_id`
|
WHERE
|
<foreach collection="list" item="item" separator=" OR ">
|
(tc.`co_source_type` = #{item.sourceType,jdbcType=INTEGER} AND tc.`co_order_no` = #{item.orderNo,jdbcType=VARCHAR})
|
</foreach>
|
GROUP BY tc.`co_order_no`,tc.`co_order_goods_id`
|
</select>
|
|
<select id="countOrderByHongBaoType" resultType="java.util.HashMap">
|
SELECT SUM(self)AS totalSelf, SUM(shared)AS totalShared ,SUM(invite)AS totalInvite FROM (
|
SELECT IFNULL(COUNT(DISTINCT tc.`co_order_no`,tc.`co_source_type`),0) AS self,0 AS shared,0 AS invite 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`
|
WHERE th.`hb_uid` = ${uid}
|
AND (th.`hb_type` = 1 OR th.`hb_type` = 2)
|
<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>
|
UNION
|
|
SELECT 0 AS self, IFNULL(COUNT(DISTINCT tc.`co_order_no`,tc.`co_source_type`),0) AS shared,0 AS invite 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 (th.`hb_type` = 20 OR th.`hb_type` = 21 OR th.`hb_type` = 22)
|
<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>
|
UNION
|
SELECT 0 AS self,0 AS shared,IFNULL(COUNT(DISTINCT tc.`co_order_no`,tc.`co_source_type`),0) AS invite 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 (th.`hb_type` = 5 OR th.`hb_type` = 6 OR th.`hb_type` = 7)
|
<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>
|
)A
|
</select>
|
|
|
<select id="countOrder" resultType="java.lang.Long">
|
SELECT IFNULL(COUNT(DISTINCT tc.`co_order_no`,tc.`co_source_type`),0) 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 1=1
|
<if test="uid != null">
|
AND th.`hb_uid` = ${uid}
|
</if>
|
<if test ="isToday == 1">
|
AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW())
|
</if>
|
</select>
|
|
<select id="countOrderMoney" resultType="java.lang.Long">
|
SELECT IFNULL(SUM(th.`hb_money`),0)AS totalmoney 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 <![CDATA[tc.`co_state` <> 4]]>
|
<if test ="isToday == 1">
|
AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW())
|
</if>
|
GROUP BY tc.`co_order_no`,tc.`co_source_type`
|
</select>
|
|
<select id="countByUidAndOrderState" 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 th.hb_type = #{type}
|
</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>
|
|
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 th.hb_type = #{type}
|
</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>
|
|
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 th.hb_type = #{type}
|
</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>
|
)A
|
</select>
|
|
</mapper>
|