admin
2019-04-09 573868c096a920acdb2c003f518d3a94f2e5567c
fanli/src/main/java/com/yeshi/fanli/mapping/order/LostOrderMapper.xml
@@ -12,17 +12,16 @@
      <result column="remake" property="remake" jdbcType="VARCHAR" />
      <result column="judge" property="judge" jdbcType="VARCHAR" />
      <result column="result_code" property="resultCode" jdbcType="INTEGER" />
      <result column="ip_info" property="ipInfo" jdbcType="VARCHAR" />
      <association property="userInfo" column="uid"
         javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
         <id column="uid" property="id" jdbcType="BIGINT" />
      </association>
      <association property="order" column="oid"
         javaType="com.yeshi.fanli.entity.bus.user.Order">
         <id column="oid" property="id" jdbcType="BIGINT" />
      </association>
   </resultMap>
   <resultMap id="AllResultMap" type="com.yeshi.fanli.entity.bus.user.LostOrder">
      <id column="id" property="id" jdbcType="BIGINT" />
      <result column="orderId" property="orderId" jdbcType="VARCHAR" />
@@ -35,26 +34,20 @@
      <result column="result_code" property="resultCode" jdbcType="INTEGER" />
      <association property="userInfo" column="uid"
         select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPKey" />
      <association property="order" column="oid"
         select="com.yeshi.fanli.dao.mybatis.order.OrderMapper.selectByPrimaryKey">
      </association>
         select="com.yeshi.fanli.dao.mybatis.order.OrderMapper.selectByPrimaryKey" />
   </resultMap>
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
      yeshi_ec_lost_order where id = #{id,jdbcType=BIGINT}
   </delete>
      yeshi_ec_lost_order where id = #{id,jdbcType=BIGINT}</delete>
   <select id="selectByOrderId" resultMap="BaseResultMap"
      parameterType="java.lang.String">
      select * from yeshi_ec_lost_order where orderId=#{0}
      parameterType="java.lang.String">select * from yeshi_ec_lost_order where orderId=#{0}
   </select>
   <select id="selectByPrimaryKey" resultMap="BaseResultMap"
      parameterType="java.lang.Long">
      select * from yeshi_ec_lost_order where id=#{0}
      parameterType="java.lang.Long">select * from yeshi_ec_lost_order where id=#{0}</select>
   <select id="listByStateAndResultCode" resultMap="BaseResultMap">select * from
      yeshi_ec_lost_order where `state`=#{state} and
      `result_code`=#{resultCode} ORDER BY id DESC limit #{start},#{count}
   </select>
   <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.LostOrder">
      update yeshi_ec_lost_order
      <set>
@@ -68,81 +61,40 @@
         <if test="remake != null">remake=#{remake,jdbcType=VARCHAR},</if>
         <if test="judge != null">judge=#{judge,jdbcType=VARCHAR},</if>
         <if test="resultCode != null">result_code=#{resultCode,jdbcType=INTEGER},</if>
         <if test="ipInfo !=null">ip_info =#{ipInfo,jdbcType=VARCHAR},</if>
      </set>
      where id = #{id,jdbcType=BIGINT}
   </update>
   <select id="countByUid" resultType="java.util.HashMap">
      SELECT IFNULL(COUNT(id), 0)
      AS total,IFNULL(SUM(CASE WHEN state = 1 THEN 1
      ELSE 0 END),0) AS
      totalPass,
      IFNULL(SUM(CASE WHEN state = 2 THEN 1 ELSE 0 END),0) AS
      totalReject
      FROM
      yeshi_ec_lost_order WHERE uid = #{uid};
   </select>
   <select id="countByUid" resultType="java.util.HashMap">SELECT IFNULL(COUNT(id), 0)
      AS total,IFNULL(SUM(CASE WHEN state = 1 THEN 1 ELSE 0 END),0) AS
      totalPass, IFNULL(SUM(CASE WHEN state = 2 THEN 1 ELSE 0 END),0) AS
      totalReject FROM yeshi_ec_lost_order WHERE uid = #{uid};</select>
   <select id="listQuery" resultMap="AllResultMap">
      SELECT d.* FROM yeshi_ec_lost_order d
      left join yeshi_ec_user u on
      d.uid = u.id
      WHERE 1=1
      <if test='key != null and key != ""'>
         AND (d.orderId like '%${key}%' or d.uid like '%${key}%' or
         u.nick_name
         like '%${key}%')
      </if>
      <if test='state != null'>
         AND d.state = #{state}
      </if>
      <if test='handleType != null and handleType == 0'>
         AND d.state = 0
      </if>
      <if test='handleType != null and handleType != 0'>
         AND (d.state = 1 or d.state = 2)
      </if>
      ORDER BY d.createTime desc
      LIMIT ${start},${count}
      SELECT d.* FROM yeshi_ec_lost_order d left join yeshi_ec_user u on
      d.uid = u.id WHERE 1=1
      <if test="key != null and key != &quot;&quot;">AND (d.orderId like '%${key}%' or d.uid like '%${key}%' or
         u.nick_name like '%${key}%')</if>
      <if test="state != null">AND d.state = #{state}</if>
      <if test="handleType != null and handleType == 0">AND d.state = 0</if>
      <if test="handleType != null and handleType != 0">AND (d.state = 1 or d.state = 2)</if>
      ORDER BY d.createTime desc LIMIT ${start},${count}
   </select>
   <select id="countQuery" resultType="java.lang.Long">
      SELECT IFNULL(count(d.id),0) FROM yeshi_ec_lost_order d
      left join
      yeshi_ec_user u on d.uid = u.id
      WHERE 1=1
      <if test='key != null and key != ""'>
         AND (d.orderId like '%${key}%' or d.uid like '%${key}%' or
         u.nick_name
         like '%${key}%')
      </if>
      <if test='state != null'>
         AND d.state = #{state}
      </if>
      <if test='handleType != null and handleType == 0'>
         AND d.state = 0
      </if>
      <if test='handleType != null and handleType != 0'>
         AND (d.state = 1 or d.state = 2)
      </if>
      SELECT IFNULL(count(d.id),0) FROM yeshi_ec_lost_order d left join
      yeshi_ec_user u on d.uid = u.id WHERE 1=1
      <if test="key != null and key != &quot;&quot;">AND (d.orderId like '%${key}%' or d.uid like '%${key}%' or
         u.nick_name like '%${key}%')</if>
      <if test="state != null">AND d.state = #{state}</if>
      <if test="handleType != null and handleType == 0">AND d.state = 0</if>
      <if test="handleType != null and handleType != 0">AND (d.state = 1 or d.state = 2)</if>
   </select>
   <select id="countLostNum" resultType="java.util.HashMap">
      SELECT COUNT(t.`id`) AS showValue,
      <if test="dateType == 1">
         FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d') AS
         'showDate'
      </if>
      <if test="dateType == 2">
         FROM_UNIXTIME(t.`createTime`/1000,'%m') AS 'showDate'
      </if>
      <if test="dateType == 3">
         FROM_UNIXTIME(t.`createTime`/1000,'%Y') AS 'showDate'
      </if>
      FROM `yeshi_ec_lost_order` t
      WHERE t.`createTime`IS NOT NULL
      <if test="dateType == 1">FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d') AS
         'showDate'</if>
      <if test="dateType == 2">FROM_UNIXTIME(t.`createTime`/1000,'%m') AS 'showDate'</if>
      <if test="dateType == 3">FROM_UNIXTIME(t.`createTime`/1000,'%Y') AS 'showDate'</if>
      FROM `yeshi_ec_lost_order` t WHERE t.`createTime`IS NOT NULL
      <if test="startTime != null and startTime != '' ">
         AND FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
      </if>
@@ -150,48 +102,25 @@
         AND FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]>
         '${endTime}'
      </if>
      <if test="year != null and year != '' ">
         AND FROM_UNIXTIME(t.`createTime`/1000,'%Y') = '${year}'
      <if test="year != null and year != '' ">AND FROM_UNIXTIME(t.`createTime`/1000,'%Y') = '${year}'
      </if>
      <if test="resultCode != null and resultCode != 0 ">
         AND t.`result_code` = ${resultCode}
      <if test="resultCode != null and resultCode != 0 ">AND t.`result_code` = ${resultCode}</if>
      <if test="dateType == 1">GROUP BY FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d')
      </if>
      <if test="dateType == 1">
         GROUP BY FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d')
      </if>
      <if test="dateType == 2">
         GROUP BY FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m')
      </if>
      <if test="dateType == 3">
         GROUP BY FROM_UNIXTIME(t.`createTime`/1000,'%Y')
      </if>
      <if test="dateType == 2">GROUP BY FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m')</if>
      <if test="dateType == 3">GROUP BY FROM_UNIXTIME(t.`createTime`/1000,'%Y')</if>
      ORDER BY t.`createTime`
   </select>
   <select id="countAppealMoney" resultType="java.util.HashMap">
      SELECT CAST(SUM(v.`hb_money`)AS DECIMAL(19,2)) AS showValue,
      <if test="dateType == 1">
         FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d') AS
         'showDate'
      </if>
      <if test="dateType == 2">
         FROM_UNIXTIME(t.`createTime`/1000,'%m') AS 'showDate'
      </if>
      <if test="dateType == 3">
         FROM_UNIXTIME(t.`createTime`/1000,'%Y') AS 'showDate'
      </if>
      FROM `yeshi_ec_lost_order` t
      LEFT JOIN `yeshi_ec_common_order` tc ON
      tc.`co_order_no` = t.`orderId`
      LEFT JOIN `yeshi_ec_hongbao_order` h ON
      h.`ho_order_id` = tc.`co_id`
      LEFT JOIN `yeshi_ec_hongbao_v2`v ON
      h.`ho_hongbao_id` = v.`hb_id`
      WHERE t.`createTime`IS NOT NULL AND
      <if test="dateType == 1">FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d') AS
         'showDate'</if>
      <if test="dateType == 2">FROM_UNIXTIME(t.`createTime`/1000,'%m') AS 'showDate'</if>
      <if test="dateType == 3">FROM_UNIXTIME(t.`createTime`/1000,'%Y') AS 'showDate'</if>
      FROM `yeshi_ec_lost_order` t LEFT JOIN `yeshi_ec_common_order` tc ON
      tc.`co_order_no` = t.`orderId` LEFT JOIN `yeshi_ec_hongbao_order` h ON
      h.`ho_order_id` = tc.`co_id` LEFT JOIN `yeshi_ec_hongbao_v2`v ON
      h.`ho_hongbao_id` = v.`hb_id` WHERE t.`createTime`IS NOT NULL AND
      t.`result_code` = 2 AND (v.`hb_type` =1 OR v.`hb_type` = 2)
      <if test="startTime != null and startTime != '' ">
         AND FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
@@ -200,28 +129,19 @@
         AND FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]>
         '${endTime}'
      </if>
      <if test="year != null and year != '' ">
         AND FROM_UNIXTIME(t.`createTime`/1000,'%Y') = '${year}'
      <if test="year != null and year != '' ">AND FROM_UNIXTIME(t.`createTime`/1000,'%Y') = '${year}'
      </if>
      <if test="dateType == 1">
         GROUP BY FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d')
      <if test="dateType == 1">GROUP BY FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d')
      </if>
      <if test="dateType == 2">
         GROUP BY FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m')
      </if>
      <if test="dateType == 3">
         GROUP BY FROM_UNIXTIME(t.`createTime`/1000,'%Y')
      </if>
      <if test="dateType == 2">GROUP BY FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m')</if>
      <if test="dateType == 3">GROUP BY FROM_UNIXTIME(t.`createTime`/1000,'%Y')</if>
      ORDER BY t.`createTime`
   </select>
   <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.LostOrder"
      useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_lost_order
      (id,orderId,type,state,createTime,handleTime,uid,oid,remake,judge,result_code)
      (id,orderId,type,state,createTime,handleTime,uid,oid,remake,judge,result_code,id,ip_info)
      values
      (#{id,jdbcType=BIGINT},#{orderId,jdbcType=VARCHAR},#{type,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=BIGINT},#{handleTime,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{order.id,jdbcType=BIGINT},#{remake,jdbcType=VARCHAR},#{judge,jdbcType=VARCHAR},#{resultCode,jdbcType=INTEGER})
      (#{id,jdbcType=BIGINT},#{orderId,jdbcType=VARCHAR},#{type,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=BIGINT},#{handleTime,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{order.id,jdbcType=BIGINT},#{remake,jdbcType=VARCHAR},#{judge,jdbcType=VARCHAR},#{resultCode,jdbcType=INTEGER},#{id,jdbcType=BIGINT},#{ipInfo,jdbcType=VARCHAR})
   </insert>
   <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.LostOrder"
      useGeneratedKeys="true" keyProperty="id">
@@ -238,6 +158,7 @@
         <if test="remake != null">remake,</if>
         <if test="judge != null">judge,</if>
         <if test="resultCode != null">result_code,</if>
         <if test="ipInfo != null">ip_info,</if>
      </trim>
      values
      <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -252,6 +173,7 @@
         <if test="remake != null">#{remake,jdbcType=VARCHAR},</if>
         <if test="judge != null">#{judge,jdbcType=VARCHAR},</if>
         <if test="resultCode != null">#{resultCode,jdbcType=INTEGER},</if>
         <if test="ipInfo != null">#{ipInfo,jdbcType=VARCHAR}</if>
      </trim>
   </insert>
   <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.LostOrder">update
@@ -259,54 +181,28 @@
      #{type,jdbcType=INTEGER},state = #{state,jdbcType=INTEGER},createTime
      = #{createTime,jdbcType=BIGINT},handleTime =
      #{handleTime,jdbcType=BIGINT},uid = #{userInfo.id,jdbcType=BIGINT},oid
      =
      #{order.id,jdbcType=BIGINT},remake = #{remake,jdbcType=VARCHAR},judge
      =
      #{judge,jdbcType=VARCHAR},result_code =
      #{resultCode,jdbcType=INTEGER}
      where id = #{id,jdbcType=BIGINT}
      = #{order.id,jdbcType=BIGINT},remake =
      #{remake,jdbcType=VARCHAR},judge =
      #{judge,jdbcType=VARCHAR},result_code = #{resultCode,jdbcType=INTEGER}
      ,ip_info =#{ipInfo,jdbcType=VARCHAR} where id = #{id,jdbcType=BIGINT}
   </update>
   <delete id="deleteByUid" parameterType="java.lang.Long">delete from
      yeshi_ec_lost_order where uid = #{0}
   </delete>
   <select id="listByUidOrderByCreateTimeDesc" resultMap="BaseResultMap">
      select *
      yeshi_ec_lost_order where uid = #{0}</delete>
   <select id="listByUidOrderByCreateTimeDesc" resultMap="BaseResultMap">select *
      from yeshi_ec_lost_order where uid=#{uid} order by id desc limit
      #{start},#{count}
   </select>
   <select id="countAllByUid" resultType="java.lang.Long">
      select count(id) from
      yeshi_ec_lost_order where uid=#{0}
   </select>
      #{start},#{count}</select>
   <select id="countAllByUid" resultType="java.lang.Long">select count(id) from
      yeshi_ec_lost_order where uid=#{0}</select>
   <select id="listByOrderIdAndTypeAndState" resultMap="BaseResultMap">
      select * from yeshi_ec_lost_order where orderId=#{orderId}
      <if test="type!=null">
         and type=#{type}
      </if>
      <if test="type!=null">and type=#{type}</if>
      <if test="stateList!=null">
         <foreach collection="stateList" item="state" open="and ("
            close=")" separator=" or ">
            state=#{state}
         </foreach>
            close=")" separator=" or ">state=#{state}</foreach>
      </if>
   </select>
   <update id="processFail">
      UPDATE `yeshi_ec_lost_order` lo SET
      lo.`result_code`=3 WHERE lo.`state`=1
      AND lo.`result_code`=1 AND
      UNIX_TIMESTAMP()*1000- lo.`handleTime`>1000* 60 * 60 * 24 * 3
   <update id="processFail">UPDATE `yeshi_ec_lost_order` lo SET
      lo.`result_code`=3 WHERE lo.`state`=1 AND lo.`result_code`=1 AND
      UNIX_TIMESTAMP()*1000- lo.`handleTime`&gt;1000* 60 * 60 * 24 * 3
   </update>
</mapper>