yujian
2020-04-21 5af10f175689549ca44b74e9fc1c7ee0ec92c2d7
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponCountMapper.xml
@@ -63,10 +63,6 @@
      resultMap="com.yeshi.fanli.dao.mybatis.user.UserSystemCouponMapper.BaseResultMap"/>
  </resultMap>
  
  <resultMap id="ChartMap" type="com.yeshi.fanli.dto.ChartTDO">
   <result column="showDate" property="showDate" jdbcType="VARCHAR" />
   <result column="showValue" property="showValue" jdbcType="VARCHAR" />
 </resultMap>
  
  <select id="listRebateCoupon" resultMap="BaseResultMap">
   SELECT * FROM `yeshi_ec_user_system_coupon` uc
@@ -270,118 +266,6 @@
            AND uc.`usc_id` = #{key}
         </if>
      </if>
  </select>
  <select id="getRebateCouponUsedNumToCharts" resultMap="ChartMap">
     SELECT IFNULL(COUNT(c.`usc_id`),0) AS showValue,
        <if test="dateType == 1">
         DATE_FORMAT(c.`usc_use_time`,'%Y-%m-%d') AS 'showDate'
      </if>
      <if test="dateType == 2">
         DATE_FORMAT(c.`usc_use_time`,'%m') AS 'showDate'
      </if>
      <if test="dateType == 3">
         DATE_FORMAT(c.`usc_use_time`,'%Y') AS 'showDate'
      </if>
     FROM yeshi_ec_user_system_coupon c
     LEFT JOIN yeshi_ec_system_coupon p   ON  p.`sc_id`= c.`usc_coupon_id`
   WHERE c.`usc_state` = 3 AND  p.`sc_type` = 'rebatePercentCoupon'
        <if test="startTime != null and startTime != '' ">
         AND DATE_FORMAT(c.`usc_use_time`,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
      </if>
      <if test="endTime != null and endTime != '' ">
         AND DATE_FORMAT(c.`usc_use_time`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
      </if>
      <if test="year != null and year != '' ">
         AND DATE_FORMAT(c.`usc_use_time`,'%Y') = '${year}'
      </if>
      <if test="dateType == 1">
         GROUP BY DATE_FORMAT(c.`usc_use_time`,'%Y-%m-%d')
      </if>
      <if test="dateType == 2">
         GROUP BY DATE_FORMAT(c.`usc_use_time`,'%Y-%m')
      </if>
      <if test="dateType == 3">
         GROUP BY DATE_FORMAT(c.`usc_use_time`,'%Y')
      </if>
   ORDER BY c.`usc_use_time`
  </select>
  <select id="getRebateCouponMoneyToCharts" resultMap="ChartMap">
     SELECT IFNULL(SUM(c.`hb_money`),0) AS showValue,
        <if test="dateType == 1">
         DATE_FORMAT(c.`hb_get_time`,'%Y-%m-%d') AS 'showDate'
      </if>
      <if test="dateType == 2">
         DATE_FORMAT(c.`hb_get_time`,'%m') AS 'showDate'
      </if>
      <if test="dateType == 3">
         DATE_FORMAT(c.`hb_get_time`,'%Y') AS 'showDate'
      </if>
     FROM yeshi_ec_hongbao_v2 c
   WHERE  c.`hb_type`= 10
        <if test="startTime != null and startTime != '' ">
         AND DATE_FORMAT(c.`hb_get_time`,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
      </if>
      <if test="endTime != null and endTime != '' ">
         AND DATE_FORMAT(c.`hb_get_time`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
      </if>
      <if test="year != null and year != '' ">
         AND DATE_FORMAT(c.`hb_get_time`,'%Y') = '${year}'
      </if>
      <if test="dateType == 1">
         GROUP BY DATE_FORMAT(c.`hb_get_time`,'%Y-%m-%d')
      </if>
      <if test="dateType == 2">
         GROUP BY DATE_FORMAT(c.`hb_get_time`,'%Y-%m')
      </if>
      <if test="dateType == 3">
         GROUP BY DATE_FORMAT(c.`hb_get_time`,'%Y')
      </if>
   ORDER BY c.`hb_get_time`
  </select>
  <select id="getFreeCouponMoneyToCharts" resultMap="ChartMap">
      SELECT IFNULL(SUM(v2.`hb_money`),0) AS showValue,
        <if test="dateType == 1">
         DATE_FORMAT(v2.`hb_get_time`,'%Y-%m-%d') AS 'showDate'
      </if>
      <if test="dateType == 2">
         DATE_FORMAT(v2.`hb_get_time`,'%m') AS 'showDate'
      </if>
      <if test="dateType == 3">
         DATE_FORMAT(v2.`hb_get_time`,'%Y') AS 'showDate'
      </if>
      FROM yeshi_ec_user_system_coupon c
      LEFT JOIN yeshi_ec_system_coupon sp ON sp.`sc_id` = c.`usc_coupon_id`
    LEFT JOIN `yeshi_ec_user_system_coupon_record` pr ON c.`usc_id` = pr.`ucr_user_coupon_id`
    LEFT JOIN `yeshi_ec_common_order` co ON pr.`ucr_order_no` = co.`co_order_no`
    LEFT JOIN `yeshi_ec_hongbao_order` ho ON ho.`ho_order_id` = co.`co_id`
    LEFT JOIN `yeshi_ec_hongbao_v2` v2 ON ho.`ho_hongbao_id` = v2.`hb_id`
    WHERE pr.`ucr_state` = 3 AND sp.`sc_type` = #{couponType}
        <if test="startTime != null and startTime != '' ">
         AND DATE_FORMAT(v2.`hb_get_time`,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
      </if>
      <if test="endTime != null and endTime != '' ">
         AND DATE_FORMAT(v2.`hb_get_time`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
      </if>
      <if test="year != null and year != '' ">
         AND DATE_FORMAT(v2.`hb_get_time`,'%Y') = '${year}'
      </if>
      <if test="dateType == 1">
         GROUP BY DATE_FORMAT(v2.`hb_get_time`,'%Y-%m-%d')
      </if>
      <if test="dateType == 2">
         GROUP BY DATE_FORMAT(v2.`hb_get_time`,'%Y-%m')
      </if>
      <if test="dateType == 3">
         GROUP BY DATE_FORMAT(v2.`hb_get_time`,'%Y')
      </if>
   ORDER BY v2.`hb_get_time`
  </select>