From 01597125df02b65ddef6489adde6642da8d85b47 Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期二, 10 九月 2019 14:04:28 +0800 Subject: [PATCH] 券记录 + 专题加入时间控制 --- fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponCountMapper.xml | 767 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 383 insertions(+), 384 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponCountMapper.xml b/fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponCountMapper.xml index 66915f4..f04705a 100644 --- a/fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponCountMapper.xml +++ b/fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponCountMapper.xml @@ -1,384 +1,383 @@ -<?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.user.UserSystemCouponCountMapper"> - <resultMap id="BaseResultMap" type="com.yeshi.fanli.vo.user.UserSystemCouponCountVO"> - <id column="usc_id" property="id" jdbcType="BIGINT"/> - <result column="usc_uid" property="uid" jdbcType="BIGINT"/> - <result column="usc_source" property="source" jdbcType="VARCHAR"/> - <result column="usc_state" property="state" jdbcType="INTEGER"/> - <result column="usc_state_activate" property="stateActivated" jdbcType="INTEGER"/> - <result column="usc_start_time" property="startTime" jdbcType="TIMESTAMP"/> - <result column="usc_end_time" property="endTime" jdbcType="TIMESTAMP"/> - <result column="usc_use_time" property="useTime" jdbcType="TIMESTAMP"/> - <result column="usc_create_time" property="createTime" jdbcType="TIMESTAMP"/> - <result column="usc_update_time" property="updateTime" jdbcType="TIMESTAMP"/> - - <association property="systemCoupon" column="ucr_id" - resultMap="com.yeshi.fanli.dao.mybatis.SystemCouponMapper.BaseResultMap"/> - - <association property="userSystemCouponRecord" column="usc_coupon_id" - resultMap="com.yeshi.fanli.dao.mybatis.user.UserSystemCouponRecordMapper.BaseResultMap"/> - </resultMap> - - - <resultMap id="BaseResultSystemMap" type="com.yeshi.fanli.vo.user.SystemCouponVO"> - <id column="sc_id" property="id" jdbcType="BIGINT"/> - <result column="sc_name" property="name" jdbcType="VARCHAR"/> - <result column="sc_picture" property="picture" jdbcType="VARCHAR"/> - <result column="sc_picture_invalid" property="pictureInvalid" jdbcType="VARCHAR"/> - <result column="sc_effect" property="effect" jdbcType="VARCHAR"/> - - <result column="sc_type" property="type" - typeHandler="com.yeshi.fanli.util.mybatishandler.CouponTypeEnumHandler" /> - - <result column="sc_percent" property="percent" jdbcType="DECIMAL"/> - <result column="sc_amount" property="amount" jdbcType="VARCHAR"/> - <result column="sc_expiry_day" property="expiryDay" jdbcType="INTEGER"/> - <result column="sc_rule" property="rule" jdbcType="VARCHAR"/> - <result column="sc_remark" property="remark" jdbcType="VARCHAR"/> - <result column="sc_receive_count" property="receiveCount" jdbcType="INTEGER"/> - <result column="sc_state" property="state" jdbcType="INTEGER"/> - <result column="sc_create_time" property="createTime" jdbcType="TIMESTAMP"/> - <result column="sc_update_time" property="updateTime" jdbcType="TIMESTAMP"/> - - <result column="notUse" property="notUse" jdbcType="BIGINT"/> - <result column="used" property="used" jdbcType="BIGINT"/> - <result column="overdue" property="overdue" jdbcType="BIGINT"/> - <result column="total" property="total" jdbcType="BIGINT"/> - <result column="activateNum" property="activateNum" jdbcType="BIGINT"/> - </resultMap> - - - <resultMap id="BaseResultRecordMap" type="com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord"> - <id column="ucr_id" property="id" jdbcType="BIGINT"/> - <result column="ucr_good_id" property="goodId" jdbcType="BIGINT"/> - <result column="ucr_good_source" property="goodSource" jdbcType="VARCHAR"/> - <result column="ucr_coupon_type" property="couponType" jdbcType="VARCHAR"/> - <result column="ucr_order_no" property="orderNo" jdbcType="VARCHAR"/> - <result column="ucr_state" property="state" jdbcType="INTEGER"/> - <result column="ucr_create_time" property="createTime" jdbcType="TIMESTAMP"/> - <result column="ucr_update_time" property="updateTime" jdbcType="TIMESTAMP"/> - - <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 - LEFT JOIN yeshi_ec_system_coupon p ON p.`sc_id`= uc.`usc_coupon_id` - LEFT JOIN `yeshi_ec_user_system_coupon_record` d ON d.`ucr_user_coupon_id` = uc.`usc_id` - WHERE p.`sc_type` = 'rebatePercentCoupon' - <if test="state != null"> - AND uc.usc_state = #{state} - </if> - - <if test="percent != null"> - AND p.`sc_percent` = #{percent} - </if> - - <if test="key != null and key != '' "> - <if test="keyType == 1"> - AND uc.`usc_uid` = #{key} - </if> - <if test="keyType == 2"> - AND uc.`usc_source` like '%${key}%' - </if> - </if> - ORDER BY uc.`usc_create_time` DESC - LIMIT ${start},${count} - </select> - - <select id="countRebateCoupon" resultType="java.lang.Long"> - SELECT IFNULL(count(uc.`usc_id`),0) FROM `yeshi_ec_user_system_coupon` uc - LEFT JOIN yeshi_ec_system_coupon p ON p.`sc_id`= uc.`usc_coupon_id` - WHERE p.`sc_type` = 'rebatePercentCoupon' - <if test="state != null"> - AND uc.usc_state = #{state} - </if> - <if test="percent != null"> - AND p.`sc_percent` = #{percent} - </if> - <if test="key != null and key != '' "> - <if test="keyType == 1"> - AND uc.`usc_uid` = #{key} - </if> - <if test="keyType == 2"> - AND uc.`usc_source` like '%${key}%' - </if> - </if> - </select> - - - <select id="listSystemCouponByRebate" resultMap="BaseResultSystemMap"> - SELECT * FROM yeshi_ec_system_coupon p - LEFT JOIN - (SELECT SUM(A.notUse)AS notUse, SUM(A.used)AS used, SUM(A.overdue)AS overdue,COUNT(*)AS total,usc_coupon_id - FROM (SELECT IF(cp.`usc_state`=1,1,0)AS notUse,IF(cp.`usc_state`=3,1,0)AS used,IF(cp.`usc_state`=4,1,0)AS overdue,cp.`usc_coupon_id` - FROM `yeshi_ec_user_system_coupon` cp - )A - GROUP BY A.usc_coupon_id)B ON p.`sc_id` = B.usc_coupon_id - WHERE p.`sc_type` = 'rebatePercentCoupon' - <if test="key != null and key != '' "> - AND p.`sc_percent` = #{key} - </if> - ORDER BY - <if test="sort == null">p.`sc_percent`</if> - <if test="sort == 1">B.notUse</if> - <if test="sort == 2">B.notUse DESC</if> - <if test="sort == 3">B.used</if> - <if test="sort == 4">B.used DESC</if> - <if test="sort == 5">B.total</if> - <if test="sort == 6">B.total DESC</if> - - LIMIT ${start},${count} - </select> - - <select id="countSystemCouponRebate" resultType="java.lang.Long"> - SELECT IFNULL(count(p.sc_id),0) FROM `yeshi_ec_system_coupon` p - WHERE p.`sc_type` = 'rebatePercentCoupon' - <if test="key != null and key != '' "> - AND p.`sc_percent` = #{key} - </if> - </select> - - <select id="countRebateMoneyByCouponId" resultType="java.math.BigDecimal"> - SELECT SUM(v2.`hb_money`) FROM yeshi_ec_user_system_coupon c - LEFT JOIN `yeshi_ec_user_system_coupon_record` pr ON c.`usc_id` = pr.`ucr_user_coupon_id` - LEFT JOIN `yeshi_ec_order` o ON o.`orderid` = pr.`ucr_order_no` - LEFT JOIN `yeshi_ec_order_hongbaov2_map` map ON map.`ohm_order_id` = o.`id` - LEFT JOIN `yeshi_ec_hongbao_v2` v2 ON v2.`hb_id`= map.`ohm_hongbao_id` - WHERE v2.`hb_id` IS NOT NULL AND c.`usc_coupon_id` = #{couponId} - </select> - - <select id="listSystemCouponByFree" resultMap="BaseResultSystemMap"> - SELECT * FROM yeshi_ec_system_coupon p - LEFT JOIN - (SELECT SUM(A.notUse)AS notUse, SUM(A.used)AS used, SUM(A.overdue)AS overdue,COUNT(*)AS total, SUM(A.activateNum)AS activateNum,usc_coupon_id - FROM (SELECT IF(cp.`usc_state`=1,1,0)AS notUse,IF(cp.`usc_state`=3,1,0)AS used, - IF(cp.`usc_state`=4,1,0)AS overdue,IF(cp.`usc_state_activate`=1,1,0)AS activateNum,cp.`usc_coupon_id` - FROM `yeshi_ec_user_system_coupon` cp - )A - GROUP BY A.usc_coupon_id)B ON p.`sc_id` = B.usc_coupon_id - WHERE (p.`sc_type` = 'freeCoupon' OR p.`sc_type` = 'welfareFreeCoupon') - ORDER BY - <if test="sort == null">p.sc_id</if> - <if test="sort == 1">B.notUse</if> - <if test="sort == 2">B.notUse DESC</if> - <if test="sort == 3">B.used</if> - <if test="sort == 4">B.used DESC</if> - <if test="sort == 5">B.total</if> - <if test="sort == 6">B.total DESC</if> - - LIMIT ${start},${count} - </select> - - <select id="countSystemCouponFree" resultType="java.lang.Long"> - SELECT IFNULL(count(p.sc_id),0) FROM `yeshi_ec_system_coupon` p - WHERE p.`sc_type` = 'rebatePercentCoupon' - </select> - - <select id="countFreeMoneyByCouponId" resultType="java.math.BigDecimal"> - SELECT SUM(v2.`hb_money`) FROM yeshi_ec_user_system_coupon c - 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 c.`usc_coupon_id` = #{couponId} - </select> - - <select id="listFreeCoupon" resultMap="BaseResultMap"> - SELECT * FROM `yeshi_ec_user_system_coupon` uc - LEFT JOIN yeshi_ec_system_coupon p ON p.`sc_id`= uc.`usc_coupon_id` - LEFT JOIN (SELECT * FROM `yeshi_ec_user_system_coupon_record` d WHERE d.`ucr_state` = 2 or d.`ucr_state` = 3 )A ON A.`ucr_user_coupon_id` = uc.`usc_id` - WHERE (p.`sc_type` = 'freeCoupon' OR p.`sc_type` = 'welfareFreeCoupon') - <if test="state != null"> - AND uc.usc_state = #{state} - </if> - <if test="activated != null"> - AND uc.`usc_state_activate` = #{activated} - </if> - <if test="key != null and key != '' "> - <if test="keyType == 1"> - AND uc.`usc_uid` = #{key} - </if> - <if test="keyType == 2"> - AND uc.`usc_source` like '%${key}%' - </if> - </if> - ORDER BY uc.`usc_create_time` DESC - LIMIT ${start},${count} - </select> - - <select id="countFreeCoupon" resultType="java.lang.Long"> - SELECT IFNULL(count(uc.`usc_id`),0) FROM `yeshi_ec_user_system_coupon` uc - LEFT JOIN yeshi_ec_system_coupon p ON p.`sc_id`= uc.`usc_coupon_id` - WHERE (p.`sc_type` = 'freeCoupon' or p.`sc_type` = 'welfareFreeCoupon') - <if test="state != null"> - AND uc.usc_state = #{state} - </if> - <if test="activated != null"> - AND uc.`usc_state_activate` = #{activated} - </if> - <if test="key != null and key != '' "> - <if test="keyType == 1"> - AND uc.`usc_uid` = #{key} - </if> - <if test="keyType == 2"> - AND uc.`usc_source` like '%${key}%' - </if> - </if> - </select> - - <select id="listFreeCouponRecord" resultMap="BaseResultRecordMap"> - SELECT * FROM `yeshi_ec_user_system_coupon_record` d - LEFT JOIN `yeshi_ec_user_system_coupon` uc ON d.`ucr_user_coupon_id` = uc.`usc_id` - LEFT JOIN yeshi_ec_system_coupon p ON p.`sc_id`= uc.`usc_coupon_id` - WHERE (p.`sc_type` = 'freeCoupon' OR p.`sc_type` = 'welfareFreeCoupon') - <if test="state != null"> - AND d.`ucr_state` = #{state} - </if> - <if test="key != null and key != '' "> - <if test="keyType == 1"> - AND uc.`usc_uid` = #{key} - </if> - <if test="keyType == 2"> - AND uc.`usc_id` = #{key} - </if> - </if> - ORDER BY d.`ucr_create_time` DESC - LIMIT ${start},${count} - </select> - - <select id="countFreeCouponRecord" resultType="java.lang.Long"> - SELECT IFNULL(count(d.`ucr_id`),0) FROM `yeshi_ec_user_system_coupon_record` d - LEFT JOIN `yeshi_ec_user_system_coupon` uc ON d.`ucr_user_coupon_id` = uc.`usc_id` - LEFT JOIN yeshi_ec_system_coupon p ON p.`sc_id`= uc.`usc_coupon_id` - WHERE (p.`sc_type` = 'freeCoupon' or p.`sc_type` = 'welfareFreeCoupon') - <if test="state != null"> - AND d.`ucr_state` = #{state} - </if> - <if test="key != null and key != '' "> - <if test="keyType == 1"> - AND uc.`usc_uid` = #{key} - </if> - <if test="keyType == 2"> - AND uc.`usc_id` = #{key} - </if> - </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 - 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> - -</mapper> +<?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.user.UserSystemCouponCountMapper"> + <resultMap id="BaseResultMap" type="com.yeshi.fanli.vo.user.UserSystemCouponCountVO"> + <id column="usc_id" property="id" jdbcType="BIGINT"/> + <result column="usc_uid" property="uid" jdbcType="BIGINT"/> + <result column="usc_source" property="source" jdbcType="VARCHAR"/> + <result column="usc_state" property="state" jdbcType="INTEGER"/> + <result column="usc_state_activate" property="stateActivated" jdbcType="INTEGER"/> + <result column="usc_start_time" property="startTime" jdbcType="TIMESTAMP"/> + <result column="usc_end_time" property="endTime" jdbcType="TIMESTAMP"/> + <result column="usc_use_time" property="useTime" jdbcType="TIMESTAMP"/> + <result column="usc_create_time" property="createTime" jdbcType="TIMESTAMP"/> + <result column="usc_update_time" property="updateTime" jdbcType="TIMESTAMP"/> + + <association property="systemCoupon" column="ucr_id" + resultMap="com.yeshi.fanli.dao.mybatis.SystemCouponMapper.BaseResultMap"/> + + <association property="userSystemCouponRecord" column="usc_coupon_id" + resultMap="com.yeshi.fanli.dao.mybatis.user.UserSystemCouponRecordMapper.BaseResultMap"/> + </resultMap> + + + <resultMap id="BaseResultSystemMap" type="com.yeshi.fanli.vo.user.SystemCouponVO"> + <id column="sc_id" property="id" jdbcType="BIGINT"/> + <result column="sc_name" property="name" jdbcType="VARCHAR"/> + <result column="sc_picture" property="picture" jdbcType="VARCHAR"/> + <result column="sc_picture_invalid" property="pictureInvalid" jdbcType="VARCHAR"/> + <result column="sc_effect" property="effect" jdbcType="VARCHAR"/> + + <result column="sc_type" property="type" + typeHandler="com.yeshi.fanli.util.mybatishandler.CouponTypeEnumHandler" /> + + <result column="sc_percent" property="percent" jdbcType="DECIMAL"/> + <result column="sc_amount" property="amount" jdbcType="VARCHAR"/> + <result column="sc_expiry_day" property="expiryDay" jdbcType="INTEGER"/> + <result column="sc_rule" property="rule" jdbcType="VARCHAR"/> + <result column="sc_remark" property="remark" jdbcType="VARCHAR"/> + <result column="sc_receive_count" property="receiveCount" jdbcType="INTEGER"/> + <result column="sc_state" property="state" jdbcType="INTEGER"/> + <result column="sc_create_time" property="createTime" jdbcType="TIMESTAMP"/> + <result column="sc_update_time" property="updateTime" jdbcType="TIMESTAMP"/> + + <result column="notUse" property="notUse" jdbcType="BIGINT"/> + <result column="used" property="used" jdbcType="BIGINT"/> + <result column="overdue" property="overdue" jdbcType="BIGINT"/> + <result column="total" property="total" jdbcType="BIGINT"/> + <result column="activateNum" property="activateNum" jdbcType="BIGINT"/> + </resultMap> + + + <resultMap id="BaseResultRecordMap" type="com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord"> + <id column="ucr_id" property="id" jdbcType="BIGINT"/> + <result column="ucr_good_id" property="goodId" jdbcType="BIGINT"/> + <result column="ucr_good_source" property="goodSource" jdbcType="VARCHAR"/> + <result column="ucr_coupon_type" property="couponType" jdbcType="VARCHAR"/> + <result column="ucr_order_no" property="orderNo" jdbcType="VARCHAR"/> + <result column="ucr_state" property="state" jdbcType="INTEGER"/> + <result column="ucr_create_time" property="createTime" jdbcType="TIMESTAMP"/> + <result column="ucr_update_time" property="updateTime" jdbcType="TIMESTAMP"/> + + <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 + LEFT JOIN yeshi_ec_system_coupon p ON p.`sc_id`= uc.`usc_coupon_id` + LEFT JOIN `yeshi_ec_user_system_coupon_record` d ON d.`ucr_user_coupon_id` = uc.`usc_id` + WHERE p.`sc_type` = 'rebatePercentCoupon' + <if test="state != null"> + AND uc.usc_state = #{state} + </if> + + <if test="percent != null"> + AND p.`sc_percent` = #{percent} + </if> + + <if test="key != null and key != '' "> + <if test="keyType == 1"> + AND uc.`usc_uid` = #{key} + </if> + <if test="keyType == 2"> + AND uc.`usc_source` like '%${key}%' + </if> + </if> + ORDER BY uc.`usc_create_time` DESC + LIMIT ${start},${count} + </select> + + <select id="countRebateCoupon" resultType="java.lang.Long"> + SELECT IFNULL(count(uc.`usc_id`),0) FROM `yeshi_ec_user_system_coupon` uc + LEFT JOIN yeshi_ec_system_coupon p ON p.`sc_id`= uc.`usc_coupon_id` + WHERE p.`sc_type` = 'rebatePercentCoupon' + <if test="state != null"> + AND uc.usc_state = #{state} + </if> + <if test="percent != null"> + AND p.`sc_percent` = #{percent} + </if> + <if test="key != null and key != '' "> + <if test="keyType == 1"> + AND uc.`usc_uid` = #{key} + </if> + <if test="keyType == 2"> + AND uc.`usc_source` like '%${key}%' + </if> + </if> + </select> + + + <select id="listSystemCouponByRebate" resultMap="BaseResultSystemMap"> + SELECT * FROM yeshi_ec_system_coupon p + LEFT JOIN + (SELECT SUM(A.notUse)AS notUse, SUM(A.used)AS used, SUM(A.overdue)AS overdue,COUNT(*)AS total,usc_coupon_id + FROM (SELECT IF(cp.`usc_state`=1,1,0)AS notUse,IF(cp.`usc_state`=3,1,0)AS used,IF(cp.`usc_state`=4,1,0)AS overdue,cp.`usc_coupon_id` + FROM `yeshi_ec_user_system_coupon` cp + )A + GROUP BY A.usc_coupon_id)B ON p.`sc_id` = B.usc_coupon_id + WHERE p.`sc_type` = 'rebatePercentCoupon' + <if test="key != null and key != '' "> + AND p.`sc_percent` = #{key} + </if> + ORDER BY + <if test="sort == null">p.`sc_percent`</if> + <if test="sort == 1">B.notUse</if> + <if test="sort == 2">B.notUse DESC</if> + <if test="sort == 3">B.used</if> + <if test="sort == 4">B.used DESC</if> + <if test="sort == 5">B.total</if> + <if test="sort == 6">B.total DESC</if> + + LIMIT ${start},${count} + </select> + + <select id="countSystemCouponRebate" resultType="java.lang.Long"> + SELECT IFNULL(count(p.sc_id),0) FROM `yeshi_ec_system_coupon` p + WHERE p.`sc_type` = 'rebatePercentCoupon' + <if test="key != null and key != '' "> + AND p.`sc_percent` = #{key} + </if> + </select> + + <select id="countRebateMoneyByCouponId" resultType="java.math.BigDecimal"> + SELECT SUM(v2.`hb_money`) FROM yeshi_ec_user_system_coupon c + LEFT JOIN `yeshi_ec_user_system_coupon_record` pr ON c.`usc_id` = pr.`ucr_user_coupon_id` + LEFT JOIN `yeshi_ec_order` o ON o.`orderid` = pr.`ucr_order_no` + LEFT JOIN `yeshi_ec_order_hongbaov2_map` map ON map.`ohm_order_id` = o.`id` + LEFT JOIN `yeshi_ec_hongbao_v2` v2 ON v2.`hb_id`= map.`ohm_hongbao_id` + WHERE v2.`hb_id` IS NOT NULL AND c.`usc_coupon_id` = #{couponId} + </select> + + <select id="listSystemCouponByFree" resultMap="BaseResultSystemMap"> + SELECT * FROM yeshi_ec_system_coupon p + LEFT JOIN + (SELECT SUM(A.notUse)AS notUse, SUM(A.used)AS used, SUM(A.overdue)AS overdue,COUNT(*)AS total, SUM(A.activateNum)AS activateNum,usc_coupon_id + FROM (SELECT IF(cp.`usc_state`=1,1,0)AS notUse,IF(cp.`usc_state`=3,1,0)AS used, + IF(cp.`usc_state`=4,1,0)AS overdue,IF(cp.`usc_state_activate`=1,1,0)AS activateNum,cp.`usc_coupon_id` + FROM `yeshi_ec_user_system_coupon` cp + )A + GROUP BY A.usc_coupon_id)B ON p.`sc_id` = B.usc_coupon_id + WHERE (p.`sc_type` = 'freeCoupon' OR p.`sc_type` = 'welfareFreeCoupon' OR p.`sc_type` = 'freeCouponBuy' OR p.`sc_type` = 'freeCouponGive') + ORDER BY + <if test="sort == null">p.sc_id</if> + <if test="sort == 1">B.notUse</if> + <if test="sort == 2">B.notUse DESC</if> + <if test="sort == 3">B.used</if> + <if test="sort == 4">B.used DESC</if> + <if test="sort == 5">B.total</if> + <if test="sort == 6">B.total DESC</if> + + LIMIT ${start},${count} + </select> + + <select id="countSystemCouponFree" resultType="java.lang.Long"> + SELECT IFNULL(count(p.sc_id),0) FROM `yeshi_ec_system_coupon` p + WHERE p.`sc_type` = 'rebatePercentCoupon' + </select> + + <select id="countFreeMoneyByCouponId" resultType="java.math.BigDecimal"> + SELECT SUM(v2.`hb_money`) FROM yeshi_ec_user_system_coupon c + 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 c.`usc_coupon_id` = #{couponId} + </select> + + <select id="listFreeCoupon" resultMap="BaseResultMap"> + SELECT * FROM `yeshi_ec_user_system_coupon` uc + LEFT JOIN yeshi_ec_system_coupon p ON p.`sc_id`= uc.`usc_coupon_id` + LEFT JOIN (SELECT * FROM `yeshi_ec_user_system_coupon_record` d WHERE d.`ucr_state` = 2 or d.`ucr_state` = 3 )A ON A.`ucr_user_coupon_id` = uc.`usc_id` + WHERE (p.`sc_type` = 'freeCoupon' OR p.`sc_type` = 'welfareFreeCoupon' OR p.`sc_type` = 'freeCouponBuy') + <if test="state != null"> + AND uc.usc_state = #{state} + </if> + <if test="activated != null"> + AND uc.`usc_state_activate` = #{activated} + </if> + <if test="key != null and key != '' "> + <if test="keyType == 1"> + AND uc.`usc_uid` = #{key} + </if> + <if test="keyType == 2"> + AND uc.`usc_source` like '%${key}%' + </if> + </if> + ORDER BY uc.`usc_create_time` DESC + LIMIT ${start},${count} + </select> + + <select id="countFreeCoupon" resultType="java.lang.Long"> + SELECT IFNULL(count(uc.`usc_id`),0) FROM `yeshi_ec_user_system_coupon` uc + LEFT JOIN yeshi_ec_system_coupon p ON p.`sc_id`= uc.`usc_coupon_id` + WHERE (p.`sc_type` = 'freeCoupon' or p.`sc_type` = 'welfareFreeCoupon' OR p.`sc_type` = 'freeCouponBuy') + <if test="state != null"> + AND uc.usc_state = #{state} + </if> + <if test="activated != null"> + AND uc.`usc_state_activate` = #{activated} + </if> + <if test="key != null and key != '' "> + <if test="keyType == 1"> + AND uc.`usc_uid` = #{key} + </if> + <if test="keyType == 2"> + AND uc.`usc_source` like '%${key}%' + </if> + </if> + </select> + + <select id="listFreeCouponRecord" resultMap="BaseResultRecordMap"> + SELECT * FROM `yeshi_ec_user_system_coupon_record` d + LEFT JOIN `yeshi_ec_user_system_coupon` uc ON d.`ucr_user_coupon_id` = uc.`usc_id` + LEFT JOIN yeshi_ec_system_coupon p ON p.`sc_id`= uc.`usc_coupon_id` + WHERE (p.`sc_type` = 'freeCoupon' OR p.`sc_type` = 'welfareFreeCoupon' OR p.`sc_type` = 'freeCouponBuy') + <if test="state != null"> + AND d.`ucr_state` = #{state} + </if> + <if test="key != null and key != '' "> + <if test="keyType == 1"> + AND uc.`usc_uid` = #{key} + </if> + <if test="keyType == 2"> + AND uc.`usc_id` = #{key} + </if> + </if> + ORDER BY d.`ucr_create_time` DESC + LIMIT ${start},${count} + </select> + + <select id="countFreeCouponRecord" resultType="java.lang.Long"> + SELECT IFNULL(count(d.`ucr_id`),0) FROM `yeshi_ec_user_system_coupon_record` d + LEFT JOIN `yeshi_ec_user_system_coupon` uc ON d.`ucr_user_coupon_id` = uc.`usc_id` + LEFT JOIN yeshi_ec_system_coupon p ON p.`sc_id`= uc.`usc_coupon_id` + WHERE (p.`sc_type` = 'freeCoupon' or p.`sc_type` = 'welfareFreeCoupon' OR p.`sc_type` = 'freeCouponBuy') + <if test="state != null"> + AND d.`ucr_state` = #{state} + </if> + <if test="key != null and key != '' "> + <if test="keyType == 1"> + AND uc.`usc_uid` = #{key} + </if> + <if test="keyType == 2"> + AND uc.`usc_id` = #{key} + </if> + </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 + 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> +</mapper> -- Gitblit v1.8.0