| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <?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.ruoyi.subsidy.mapper.SubsidyQueueMapper">
- <resultMap type="com.ruoyi.subsidy.domain.SubsidyQueue" id="SubsidyQueueResult">
- <result property="queueId" column="queue_id"/>
- <result property="userId" column="user_id"/>
- <result property="userName" column="user_name"/>
- <result property="userMobile" column="user_mobile"/>
- <result property="orderId" column="order_id"/>
- <result property="orderNo" column="order_no"/>
- <result property="currentBusinessId" column="current_business_id"/>
- <result property="currentBusinessName" column="current_business_name"/>
- <result property="originalBusinessId" column="original_business_id"/>
- <result property="originalBusinessName" column="original_business_name"/>
- <result property="queueOrder" column="queue_order"/>
- <result property="payAmount" column="pay_amount"/>
- <result property="shouldSubsidyAmount" column="should_subsidy_amount"/>
- <result property="actualSubsidyAmount" column="actual_subsidy_amount"/>
- <result property="subsidyPoints" column="subsidy_points"/>
- <result property="subsidyStatus" column="subsidy_status"/>
- <result property="cutIn" column="cut_in"/>
- <result property="cancelled" column="cancelled"/>
- <result property="exchanged" column="exchanged"/>
- <result property="exchangePoints" column="exchange_points"/>
- <result property="actualPointsAfterCancel" column="actual_points_after_cancel"/>
- <result property="consumeTime" column="consume_time"/>
- <result property="queueTime" column="queue_time"/>
- <result property="completeTime" column="complete_time"/>
- <result property="cancelTime" column="cancel_time"/>
- <result property="cancelType" column="cancel_type"/>
- <result property="exchangeTime" column="exchange_time"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- <result property="moveTime" column="move_time"/>
- <result property="refundStatus" column="refund_status"/>
- <result property="purchaseSource" column="purchase_source"/>
- </resultMap>
- <select id="validQueueIds" resultType="java.lang.Long">
- select queue_id from tb_subsidy_queue
- where current_business_id = #{businessId}
- and subsidy_status = 0
- and cut_in = 0
- order by queue_order asc
- </select>
- <sql id="boWhere">
- <if test="query.bo!=null and query.bo.currentBusinessName!=null and query.bo.currentBusinessName!=''">
- and tsq.current_business_name like concat('%',#{query.bo.currentBusinessName},'%')
- </if>
- <if test="query.bo!=null and query.bo.orderNo!=null and query.bo.orderNo!=''">
- and tsq.order_no like concat('%',#{query.bo.orderNo},'%')
- </if>
- <if test="query.bo!=null and query.bo.userMobile!=null and query.bo.userMobile!=''">
- and tsq.user_mobile like concat('%',#{query.bo.userMobile},'%')
- </if>
- <if test="query.bo!=null and query.bo.userName!=null and query.bo.userName!=''">
- and tsq.user_name like concat('%',#{query.bo.userName},'%')
- </if>
- <if test="query.bo!=null and query.bo.subsidyStatus!=null">
- and tsq.subsidy_status = #{query.bo.subsidyStatus}
- </if>
- <if test="query.bo!=null and query.bo.consumeStartTime!=null">
- and tsq.consume_time >= #{query.bo.consumeStartTime}
- </if>
- <if test="query.bo!=null and query.bo.consumeEndTime!=null">
- and tsq.consume_time <= #{query.bo.consumeEndTime}
- </if>
- <if test="query.bo!=null and query.bo.queueStartTime!=null">
- and tsq.queue_time >= #{query.bo.queueStartTime}
- </if>
- <if test="query.bo!=null and query.bo.queueEndTime!=null">
- and tsq.queue_time <= #{query.bo.queueEndTime}
- </if>
- <if test="query.bo!=null and query.bo.refundStartTime!=null">
- and too.refund_time >= #{query.bo.refundStartTime}
- </if>
- <if test="query.bo!=null and query.bo.refundEndTime!=null">
- and too.refund_time <= #{query.bo.refundEndTime}
- </if>
- <if test="query.bo!=null and query.bo.orderStatus!=null">
- and too.order_status = #{query.bo.orderStatus.code}
- </if>
- <if test="query.bo!=null and query.bo.payType!=null">
- and too.pay_type = #{query.bo.payType.code}
- </if>
- </sql>
- <select id="getSubsidyAmount" resultType="java.math.BigDecimal">
- select
- <if test="query.countType == 1">
- IFNULL(sum(tsq.actual_subsidy_amount),0)
- </if>
- <if test="query.countType == 2">
- IFNULL(sum(tsq.subsidy_points),0)
- </if>
- <if test="query.countType == 3">
- IFNULL(sum(tsq.should_subsidy_amount-tsq.actual_subsidy_amount),0)
- </if>
- from tb_subsidy_queue as tsq
- left join tb_online_order as too on tsq.order_id = too.order_id
- <where>
- <if test="query.businessId != null">
- and tsq.current_business_id = #{query.businessId}
- </if>
- <if test="query.businessIds != null and query.businessIds.size>0">
- and tsq.current_business_id in
- <foreach item="item" collection="query.businessIds" separator="," open="(" close=")" index="">
- #{item}
- </foreach>
- </if>
- <if test="query.countType == 3">
- and tsq.subsidy_status = 0
- </if>
- <if test="query.countType == 1">
- and tsq.subsidy_status = 1
- </if>
- <include refid="boWhere" />
- </where>
- </select>
- <update id="validQueueOrderRearrange">
- update tb_subsidy_queue
- set queue_order = queue_order - 1
- where current_business_id = #{businessId}
- and subsidy_status = 0
- and queue_id != #{excludeQueueId}
- and queue_order > #{currentQueueOrder}
- </update>
- </mapper>
|