yujian
2020-06-09 554de444b87aab5f93cb1593a8095612cf9479a7
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponCountMapper.xml
@@ -61,8 +61,8 @@
   
   <association property="userSystemCoupon" column="ucr_user_coupon_id" 
      resultMap="com.yeshi.fanli.dao.mybatis.user.UserSystemCouponMapper.BaseResultMap"/>
  </resultMap>
  
  <select id="listRebateCoupon" resultMap="BaseResultMap">
   SELECT * FROM `yeshi_ec_user_system_coupon` uc
@@ -268,115 +268,28 @@
      </if>
  </select>
  
  <select id="getRebateCouponUsedNumToCharts" resultType="java.util.HashMap">
     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" resultType="java.util.HashMap">
     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" resultType="java.util.HashMap">
      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
  <select id="countFreeMoneyByTypeAndDay" resultType="BigDecimal">
      SELECT SUM(v2.`hb_money`) 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`
    WHERE pr.`ucr_state` = 3 AND sp.`sc_type` = #{type}
         AND TO_DAYS(v2.`hb_get_time`) = TO_DAYS(#{preDay})
  </select>
  <select id="countRebateMoneyByDay" resultType="BigDecimal">
     SELECT SUM(v2.`hb_money`)  FROM yeshi_ec_hongbao_v2 v2
   WHERE  v2.`hb_type`= 10 AND TO_DAYS(v2.`hb_get_time`) = TO_DAYS(#{preDay})
  </select>
  <select id="countCouponNumByDay" resultType="BigDecimal">
    SELECT COUNT(c.`usc_id`) FROM yeshi_ec_user_system_coupon c
     LEFT JOIN yeshi_ec_system_coupon p ON  p.`sc_id`= c.`usc_coupon_id`
   WHERE p.`sc_type` = #{type} AND TO_DAYS(c.`usc_create_time`) = TO_DAYS(#{preDay})
  </select>
</mapper>