|
- <?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.iformall.mapper.WxCardSpendMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCardSpend">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="card_id" jdbcType="BIGINT" property="cardId"/>
- <result column="card_type" jdbcType="BIGINT" property="cardType"/>
- <result column="owner_id" jdbcType="BIGINT" property="ownerId"/>
- <result column="pay_type" jdbcType="INTEGER" property="payType"/>
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
- <result column="order_id" jdbcType="BIGINT" property="orderId"/>
- <result column="pos_order_id" jdbcType="BIGINT" property="posOrderId"/>
- <result column="deduction_amount" jdbcType="INTEGER" property="deductionAmount"/>
- <result column="payment" jdbcType="INTEGER" property="payment"/>
- <result column="real_payment" jdbcType="INTEGER" property="realPayment"/>
- <result column="subsidy" jdbcType="INTEGER" property="subsidy"/>
- <result column="card_remain_amount" jdbcType="INTEGER" property="cardRemainAmount"/>
- <result column="card_before_amount" jdbcType="INTEGER" property="cardBeforeAmount"/>
- <result column="card_remain_real_amount" jdbcType="INTEGER" property="cardRemainRealAmount"/>
- <result column="card_before_real_amount" jdbcType="INTEGER" property="cardBeforeRealAmount"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
- <result column="pay_status" jdbcType="INTEGER" property="payStatus"/>
- <result column="pay_from" jdbcType="INTEGER" property="payFrom"/>
- <result column="refund_status" jdbcType="INTEGER" property="refundStatus"/>
- <result column="refund_remark" jdbcType="VARCHAR" property="refundRemark"/>
- <result column="settlement_status" jdbcType="INTEGER" property="settlementStatus"/>
- </resultMap>
-
- <sql id="allColumns">
- `id`,`tenant_id`,`parent_tenant_id`,`card_id`,`card_type`,`owner_id`,`pay_type`,`merchant_id`,`order_id`,`pos_order_id`,
- `deduction_amount`,`payment`,`real_payment`,`subsidy`, `card_remain_amount`,
- `card_before_amount`,`card_remain_real_amount`,`card_before_real_amount`,
- `create_date`, `update_date`, `pay_status`, `pay_from`, `refund_status`, `refund_remark`, `settlement_status`
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
- <if test=" null != id ">
- and `id` = #{id}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != cardId ">
- and `card_id` = #{cardId}
- </if>
- <if test=" null != ownerId ">
- and `owner_id` = #{ownerId}
- </if>
- <if test=" null != payType ">
- and `pay_type` = #{payType}
- </if>
- <if test=" null != merchantId ">
- and `merchant_id` = #{merchantId}
- </if>
- <if test=" null != orderId ">
- and `order_id` = #{orderId}
- </if>
- <if test=" null != posOrderId ">
- and `pos_order_id` = #{posOrderId}
- </if>
- <if test=" null != deductionAmount ">
- and `deduction_amount` = #{deductionAmount}
- </if>
- <if test=" null != payment ">
- and `payment` = #{payment}
- </if>
- <if test=" null != realPayment ">
- and `real_payment` = #{realPayment}
- </if>
- <if test=" null != cardRemainAmount ">
- and `card_remain_amount` = #{cardRemainAmount}
- </if>
- <if test=" null != cardBeforeAmount ">
- and `card_before_amount` = #{cardBeforeAmount}
- </if>
- <if test=" null != cardRemainRealAmount ">
- and `card_remain_real_amount` = #{cardRemainRealAmount}
- </if>
- <if test=" null != cardBeforeRealAmount ">
- and `card_before_real_amount` = #{cardBeforeRealAmount}
- </if>
- <if test=" null != createDate ">
- and `create_date` = #{createDate}
- </if>
- <if test=" null != updateDate ">
- and `update_date` = #{updateDate}
- </if>
- <if test=" null != payStatus ">
- and `pay_status` = #{payStatus}
- </if>
- <if test=" null != payFrom ">
- and `pay_from` = #{payFrom}
- </if>
- <if test=" null != refundStatus ">
- and `refund_status` = #{refundStatus}
- </if>
- <if test=" null != settlementStatus ">
- and `settlement_status` = #{settlementStatus}
- </if>
-
- <if test=" null != startdate">
- and `create_date` >= #{startdate}
- </if>
- <if test="null != enddate">
- and `create_date` <= #{enddate}
- </if>
- <if test=" null != payTypeS ">
- and `pay_type` in
- <foreach collection="payTypeS" index="index" item="ptItem" open="(" separator="," close=")">
- #{ptItem}
- </foreach>
- </if>
- <if test=" null != merchantIdList ">
- and `merchant_id` in
- <foreach collection="merchantIdList" index="index" item="midItem" open="(" separator="," close=")">
- #{midItem}
- </foreach>
- </if>
- <if test=" null != payStatusS ">
- and `pay_status` in
- <foreach collection="payStatusS" index="index" item="psItem" open="(" separator="," close=")">
- #{psItem}
- </foreach>
- </if>
- <if test=" null != cardIdList ">
- and `card_id` in
- <foreach collection="cardIdList" index="index" item="cardIdItem" open="(" separator="," close=")">
- #{cardIdItem}
- </foreach>
- </if>
- <if test=" null != ownerIdList ">
- and owner_id in
- <foreach collection="ownerIdList" index="index" item="owneridItem" open="(" separator="," close=")">
- #{owneridItem}
- </foreach>
- </if>
- <if test=" null != orderIdList ">
- and order_id in
- <foreach collection="orderIdList" index="index" item="oidItem" open="(" separator="," close=")">
- #{oidItem}
- </foreach>
- </if>
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != sortColumns">order by ${sortColumns}</if>
- </sql>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxCardSpend" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_card_spend
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <select id="updateByCond" parameterType="com.iformall.domain.po.WxCardSpend">
- update wx_card_spend
- set `settlement_status` = #{settlementStatus}, `update_date` = #{updateDate}
- <where>
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != startdate and null!=enddate">
- and `create_date` between #{startdate} and #{enddate}
- </if>
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- </where>
- </select>
-
- <delete id="deleteForPrevCancel" parameterType="com.iformall.domain.po.WxCardSpend">
- delete from wx_card_spend
- where `tenant_id` = #{tenantId} and `id` = #{id} and `pay_status` = #{payStatus}
- </delete>
-
- <select id="findCount" parameterType="com.iformall.domain.po.WxCardSpend" resultType="Integer">
- select count(*)
- from wx_card_spend cs
- <if test=" null != businessId ">
- inner join wx_merchant m
- on m.id = cs.merchant_id
- and m.business_id = #{businessId}
- <if test=" null != subBusinessId ">
- and m.sub_business_id = #{subBusinessId}
- </if>
- </if>
- where 1 = 1
- <if test=" null != payType ">
- and cs.`pay_type` = #{payType}
- </if>
- <if test=" null != ownerId ">
- and cs.`owner_id` = #{ownerId}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and cs.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and cs.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != startdate and null!=enddate">
- and cs.`create_date` between #{startdate} and #{enddate}
- </if>
- <if test=" 0 == timeSlot">
- and date_format(cs.create_date,'%H:%m') >= '06:00'
- and date_format(cs.create_date,'%H:%m') < '18:00'
- and date_format(cs.create_date,'%w') in (1,2,3,4,5)
- </if>
-
- <if test=" 1 == timeSlot">
- and ((date_format(cs.create_date,'%H:%m') >= '18:00'
- and date_format(cs.create_date,'%w') in (1,2,3,4))
- or
- ((date_format(cs.create_date,'%H:%m') < '06:00')
- and date_format(cs.create_date,'%w') in (1,2,3,4,5)))
- </if>
-
- <if test=" 2 == timeSlot">
- and date_format(cs.create_date,'%H:%m') >= '06:00'
- and date_format(cs.create_date,'%H:%m') < '18:00'
- and date_format(cs.create_date,'%w') in (0,6)
- </if>
-
- <if test=" 3 == timeSlot">
- and ((date_format(cs.create_date,'%H:%m') >= '18:00'
- and date_format(cs.create_date,'%w') in (5,6,0))
- or
- ((date_format(cs.create_date,'%H:%m') < '06:00')
- and date_format(cs.create_date,'%w') in (6,0)))
- </if>
- </select>
-
- <select id="getMerchantCount" parameterType="com.iformall.domain.po.WxCardSpend" resultType="hashmap">
- select cs.merchant_id as merchantId, count(1) as count
- from wx_card_spend cs
- where cs.`owner_id` = #{ownerId}
- and cs.`tenant_id` = #{tenantId}
- <if test=" null != payType ">
- and cs.`pay_type` = #{payType}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and cs.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != startdate and null!=enddate">
- and cs.`create_date` between #{startdate} and #{enddate}
- </if>
- <if test=" 0 == timeSlot">
- and date_format(cs.create_date,'%H:%m') >= '06:00'
- and date_format(cs.create_date,'%H:%m') < '18:00'
- and date_format(cs.create_date,'%w') in (1,2,3,4,5)
- </if>
-
- <if test=" 1 == timeSlot">
- and ((date_format(cs.create_date,'%H:%m') >= '18:00'
- and date_format(cs.create_date,'%w') in (1,2,3,4))
- or
- ((date_format(cs.create_date,'%H:%m') < '06:00')
- and date_format(cs.create_date,'%w') in (1,2,3,4,5)))
- </if>
-
- <if test=" 2 == timeSlot">
- and date_format(cs.create_date,'%H:%m') >= '06:00'
- and date_format(cs.create_date,'%H:%m') < '18:00'
- and date_format(cs.create_date,'%w') in (0,6)
- </if>
-
- <if test=" 3 == timeSlot">
- and ((date_format(cs.create_date,'%H:%m') >= '18:00'
- and date_format(cs.create_date,'%w') in (5,6,0))
- or
- ((date_format(cs.create_date,'%H:%m') < '06:00')
- and date_format(cs.create_date,'%w') in (6,0)))
- </if>
- group by cs.merchant_id
- </select>
-
- <select id="sumMerchant" parameterType="com.iformall.domain.po.WxCardSpend" resultType="hashmap">
- select cs.merchant_id,cs.pay_type,
- IFNULL(SUM(cs.`deduction_amount`),0) as sum_deduction_amount,
- IFNULL(SUM(cs.`payment`),0) as sum_payment,
- IFNULL(SUM(cs.`real_payment`),0) as sum_real_payment,
- IFNULL(SUM(cs.`subsidy`),0) as sum_subsidy
- from wx_card_spend cs
- <include refid="dynamicWhereConditions"/>
- group by cs.merchant_id,cs.pay_type
- </select>
-
- <select id="getMerchantIdList" parameterType="com.iformall.domain.vo.WxCardSpendVo" resultType="Long">
- select distinct cs.merchant_id
- from wx_card_spend cs
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <select id="sumCardSpend" parameterType="com.iformall.domain.vo.WxCardSpendVo" resultType="hashmap">
- select
- IFNULL(SUM(cs.`deduction_amount`),0) as sum_deduction_amount,
- IFNULL(SUM(cs.`payment`),0) as sum_payment,
- IFNULL(SUM(cs.`real_payment`),0) as sum_real_payment,
- IFNULL(SUM(cs.`subsidy`),0) as sum_subsidy
- from wx_card_spend cs
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <select id="sumRealPayment" parameterType="com.iformall.domain.vo.WxCardSpendVo" resultType="Integer">
- select
- IFNULL(SUM(cs.`real_payment`),0) as sum_real_payment
- from wx_card_spend cs
- where cs.`tenant_id` = #{tenantId}
- and cs.`merchant_id` = #{merchantId}
- <if test=" null != payType ">
- and cs.`pay_type` = #{payType}
- </if>
- <if test=" null != startdate ">
- AND cs.`create_date` >= #{startdate}
- </if>
- <if test=" null != enddate ">
- AND cs.`create_date` <= #{enddate}
- </if>
- </select>
-
-
- </mapper>
|