admin
2019-01-03 5981b2cae7c20ec9021c8ccbe1a926f35f640210
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml
@@ -17,6 +17,7 @@
      <result column="co_third_create_time" property="thirdCreateTime"
         jdbcType="TIMESTAMP" />
      <result column="co_settle_time" property="settleTime" jdbcType="TIMESTAMP" />
      <result column="co_order_by" property="orderBy" jdbcType="INTEGER" />
      <result column="co_create_time" property="createTime" jdbcType="TIMESTAMP" />
      <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP" />
@@ -28,6 +29,36 @@
      <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="BaseDetailResultMap" 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_order_by" property="orderBy" jdbcType="INTEGER" />
      <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" resultMap="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.BaseResultMap">
      </association>
   </resultMap>
@@ -46,6 +77,7 @@
      <result column="co_third_create_time" property="thirdCreateTime"
         jdbcType="TIMESTAMP" />
      <result column="co_settle_time" property="settleTime" jdbcType="TIMESTAMP" />
      <result column="co_order_by" property="orderBy" jdbcType="INTEGER" />
      <result column="co_create_time" property="createTime" jdbcType="TIMESTAMP" />
      <result column="co_update_time" property="updateTime" jdbcType="TIMESTAMP" />
@@ -71,7 +103,7 @@
   </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,co_create_time,co_update_time
   <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,co_order_by,co_create_time,co_update_time
   </sql>
   <select id="selectByPrimaryKey" resultMap="BaseResultMap"
      parameterType="java.lang.Long">
@@ -84,8 +116,18 @@
      count(co_id) from yeshi_ec_common_order where co_order_no=#{orderNO}
      and co_source_type=#{orderType}
   </select>
   <select id="selectByOrderNoAndOrderTypeAndOrderBy" resultMap="BaseResultMap">
      select
      * from yeshi_ec_common_order where co_order_no=#{orderNo}
      and
      co_source_type=#{orderType} and co_order_by=#{orderBy}
   </select>
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
      yeshi_ec_common_order where co_id = #{id,jdbcType=BIGINT}</delete>
      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)
@@ -110,6 +152,7 @@
         <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="orderBy != null">co_order_by,</if>
         <if test="createTime != null">co_create_time,</if>
         <if test="updateTime != null">co_update_time,</if>
      </trim>
@@ -129,6 +172,7 @@
         <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="orderBy != null">#{orderBy,jdbcType=INTEGER},</if>
         <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
         <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
      </trim>
@@ -147,7 +191,8 @@
      #{payment,jdbcType=DECIMAL},co_settlement =
      #{settlement,jdbcType=DECIMAL},co_third_create_time =
      #{thirdCreateTime,jdbcType=TIMESTAMP},co_settle_time =
      #{settleTime,jdbcType=TIMESTAMP},co_create_time =
      #{settleTime,jdbcType=TIMESTAMP},co_order_by =
      #{orderBy,jdbcType=INTEGER},co_create_time =
      #{createTime,jdbcType=TIMESTAMP},co_update_time =
      #{updateTime,jdbcType=TIMESTAMP} where co_id = #{id,jdbcType=BIGINT}
   </update>
@@ -170,6 +215,7 @@
         <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="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>
      </set>
@@ -179,11 +225,14 @@
   <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
      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
      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 state == 1">  <!-- 未到账 -->
@@ -237,15 +286,18 @@
         DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1
      </if>
      GROUP BY tc.`co_order_no`,tc.co_source_type
      ORDER BY tc.co_create_time DESC
      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
      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 state == 1">  <!-- 未到账 -->
@@ -307,8 +359,10 @@
      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`
      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
@@ -323,12 +377,15 @@
      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_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`
      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)
      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>
@@ -340,12 +397,15 @@
      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_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
      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)
      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>
@@ -356,11 +416,14 @@
      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
      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)
      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>
@@ -377,8 +440,10 @@
      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
      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)
@@ -418,8 +483,10 @@
      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
      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
@@ -458,8 +525,10 @@
      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
      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
@@ -535,8 +604,10 @@
   <select id="countBonusOrderMoney" resultType="java.math.BigDecimal">
      SELECT COALESCE(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
      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 <![CDATA[tc.`co_state` <> 4]]>
      <if test="uid != null">
@@ -570,11 +641,14 @@
   <select id="listBonusOrder" 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
      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
      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="type != null and type == 1"> <!-- 自购订单 -->
@@ -610,7 +684,8 @@
         DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1
      </if>
      GROUP BY tc.`co_order_no`,tc.co_source_type
      ORDER BY tc.co_create_time DESC
      ORDER BY tc.co_create_time
      DESC
      LIMIT ${start},${count}
   </select>