|
- <?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.WxBillDailyMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillDaily">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="receive_pay" jdbcType="VARCHAR" property="receivePay"/>
- <result column="pay" jdbcType="VARCHAR" property="pay"/>
- <result column="receive_date" jdbcType="TIMESTAMP" property="receiveDate" />
- <result column="pay_date" jdbcType="TIMESTAMP" property="payDate" />
- <result column="createtime" jdbcType="TIMESTAMP" property="createtime" />
- <result column="create_by" jdbcType="BIGINT" property="createBy"/>
- <result column="create_by_name" jdbcType="VARCHAR" property="createByName"/>
- <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
- <result column="update_by_name" jdbcType="VARCHAR" property="updateByName"/>
- <result column="expired_day" jdbcType="INTEGER" property="expiredDay" />
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="status" jdbcType="INTEGER" property="status" />
- <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
- <result column="apply_pay_img" jdbcType="INTEGER" property="applyPayImg"/>
- <result column="apply_update_time" jdbcType="INTEGER" property="applyUpdateTime"/>
- <result column="is_del" jdbcType="INTEGER" property="isDel" />
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
- <result column="user_id" jdbcType="BIGINT" property="userId" />
- <result column="shop_id" jdbcType="BIGINT" property="shopId" />
- <result column="shop_name" jdbcType="VARCHAR" property="shopName" />
- <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" />
- <result column="type" jdbcType="INTEGER" property="type" />
- <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
- <result column="pay_way" jdbcType="BIGINT" property="payWay"/>
- <result column="price_detail" jdbcType="VARCHAR" property="priceDetail"/>
-
- <result column="starttime" property="starttime"/>
- <result column="endtime" property="endtime"/>
- <result column="last_owe_call_time" jdbcType="TIMESTAMP" property="lastOweCallTime"/>
- <result column="last_owe_call_user" jdbcType="VARCHAR" property="lastOweCallUser"/>
- <result column="freeze" property="freeze"/>
- <result column="build_way" property="buildWay"/>
- <result column="service_charge_pay" property="serviceChargePay"/>
- <result column="remark" jdbcType="VARCHAR" property="remark"/>
-
- <result column="energy_reading_calcuteId" jdbcType="BIGINT" property="energyReadingCalcuteId" />
- <result column="energy_reading_id" jdbcType="BIGINT" property="energyReadingId" />
- <result column="energy_fees_id" jdbcType="BIGINT" property="energyFeesId"/>
- <result column="set_off" jdbcType="VARCHAR" property="setOff"/>
- </resultMap>
-
- <sql id="allColumns">
- `id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`,`apply_status`,`apply_pay_img`,`apply_update_time`,
- `tenant_id`,`parent_tenant_id`,`status`,`is_del`,`merchant_id`,`user_id`,`shop_id`,`shop_name`,`updatetime`,`type`,`last_owe_call_time`,
- `rent_shop_type`,`pay_way`,`price_detail`,`starttime`,`endtime`,freeze,build_way,service_charge_pay,`remark`,`last_owe_call_user`,
- `create_by`,`create_by_name`,`update_by`,`update_by_name`,`energy_reading_calcuteId`,`energy_reading_id`,`energy_fees_id`,`set_off`
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
- <if test=" null != id "> and `id` = #{id} </if>
- <if test=" null != receivePay "> and `receive_pay` = #{receivePay} </if>
- <if test=" null != pay "> and `pay` = #{pay} </if>
- <if test=" null != receiveDate "> and `receive_date` = #{receiveDate} </if>
- <if test=" null != payDate "> and `pay_date` = #{payDate} </if>
- <if test=" null != createtime "> and `createtime` = #{createtime} </if>
- <if test=" null != expiredDay "> and `expired_day` = #{expiredDay} </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 != status "> and `status` = #{status} </if>
- <if test=" null != applyStatus ">and `apply_status` = #{applyStatus}</if>
- <if test=" null != isDel "> and `is_del` = #{isDel} </if>
- <if test=" null != merchantId "> and `merchant_id` = #{merchantId} </if>
- <if test=" null != energyFeesId ">and `energy_fees_id` = #{energyFeesId}</if>
- <if test=" null != userId "> and `user_id` = #{userId} </if>
- <if test=" null != updatetime "> and `updatetime` = #{updatetime} </if>
- <if test=" null != type "> and `type` = #{type} </if>
- <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
- <if test=" null != payWay ">and `pay_way` = #{payWay}</if>
- <if test=" null != buildWay ">and `build_way` = #{buildWay}</if>
- <if test=" null != energyReadingCalcuteId ">and `energy_reading_calcuteId` = #{energyReadingCalcuteId}</if>
- <if test=" null != energyReadingId ">and `energy_reading_id` = #{energyReadingId}</if>
- <if test=" 1 == notifyed ">and (`last_owe_call_time` is not null and `receive_pay` - `pay` - IFNULL(`set_off`,'0') > 0 and status not in (3,6,7) )</if>
-
- <if test=" null != statusList ">
- and status in
- <foreach collection="statusList" index="index" item="stItem" open="(" separator="," close=")">
- #{stItem}
- </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 != notInIds ">
- and id not in
- <foreach collection="notInIds" index="index" item="nidItem" open="(" separator="," close=")">
- #{nidItem}
- </foreach>
- </if>
-
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </sql>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxBillDaily" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_bill_daily
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="selectById" parameterType="HashMap" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_bill_daily
- where id = #{id} and tenant_id = #{tenantId}
- </select>
-
- <sql id = "queryBillDailyListConditions" >
- <where>
- 1 = 1
- <if test=" null != id ">and br.`id` = #{id}</if>
- <if test=" null != tenantId and '' != tenantId"> and br.`tenant_id` = #{tenantId}</if>
- <if test=" null != parentTenantId and '' != parentTenantId">and br.`parent_tenant_id` = #{parentTenantId}</if>
- <if test=" null != freeze ">and br.`freeze` = #{freeze}</if>
- <if test=" null != id ">and br.`id` = #{id}</if>
- <if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
- <if test=" null != energyFeesId ">and br.`energy_fees_id` = #{energyFeesId}</if>
- <if test=" null != status ">and br.`status` = #{status}</if>
- <if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if>
- <if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
- <if test=" null != type ">and br.`type` = #{type}</if>
- <if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
- <if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
- <if test=" null != starttime">and br.`starttime` <= #{starttime}</if>
- <if test=" null != endtime">and br.`endtime` >= #{endtime}</if>
- <if test=" null != month and '' != month">
- and date_format(br.starttime,'%Y-%m') <= #{month} and date_format(br.endtime,'%Y-%m') >= #{month}
- </if>
- <if test=" null == nearBillLastTime and null != oweBillLastTime">
- and (br.`starttime` <= #{oweBillLastTime} and br.`receive_pay` - br.`pay` - IFNULL(br.`set_off`,'0') > 0 and br.status not in (3,6,7))
- </if>
- <if test=" null != nearBillLastTime and null != oweBillLastTime">
- and (br.`starttime` > #{oweBillLastTime} and br.`starttime` <= #{nearBillLastTime} and br.`receive_pay` - br.`pay` - IFNULL(br.`set_off`,'0') > 0 and br.status not in (3,6,7))
- </if>
- <if test=" null != needPayStartDay">
- and (br.`starttime` <= #{needPayStartDay} and br.`receive_pay` - br.`pay` - IFNULL(br.`set_off`,'0') > 0 and br.status not in (3,6,7))
- </if>
- <if test=" null != buildWay ">and br.`build_way` = #{buildWay}</if>
- <if test=" null != energyReadingCalcuteId ">and br.`energy_reading_calcuteId` = #{energyReadingCalcuteId}</if>
- <if test=" null != energyReadingId ">and br.`energy_reading_id` = #{energyReadingId}</if>
- <if test=" 1 == notifyed ">and (br.`last_owe_call_time` is not null and br.`receive_pay` - br.`pay` - IFNULL(br.`set_off`,'0') > 0 and br.status not in (3,6,7) )</if>
- <if test=" null != merchantIds ">
- and br.`merchant_id` in
- <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
- #{midItem}
- </foreach>
- </if>
- <if test=" null != notInIds ">
- and br.`id` not in
- <foreach collection="notInIds" index="index" item="nidItem" open="(" separator="," close=")">
- #{nidItem}
- </foreach>
- </if>
- <if test=" null != statusList ">
- and br.status in
- <foreach collection="statusList" index="index" item="stItem" open="(" separator="," close=")">
- #{stItem}
- </foreach>
- </if>
- </where>
- </sql>
-
- <select id="queryBillDailyList" parameterType="com.iformall.domain.po.WxBillDaily" resultMap="BaseResultMap">
- select br.`id`,br.`tenant_id`,br.`parent_tenant_id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day` ,
- br.`status`,br.`updatetime`,br.`merchant_id`,br.shop_id,br.`last_owe_call_time`,br.`last_owe_call_user`,br.`set_off`,
- br.shop_name,br.type,br.`rent_shop_type`,br.pay_way,br.price_detail,br.`starttime`,br.`endtime`,br.`build_way`,
- br.freeze,br.service_charge_pay,br.`apply_status`,br.`apply_pay_img`,br.`apply_update_time`,br.`remark`,br.`energy_fees_id`,
- br.`create_by`,br.`create_by_name`,br.`update_by`,br.`update_by_name`,br.`energy_reading_calcuteId`,br.`energy_reading_id`
- from wx_bill_daily br
- <include refid="queryBillDailyListConditions" />
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- <if test=" null == sortColumns">order by id desc</if>
- </select>
-
- <resultMap id="SumBaseResultMap" type="com.iformall.domain.vo.WxBillSum">
- <result column="receive_pay" jdbcType="VARCHAR" property="needPay"/>
- <result column="paid" jdbcType="VARCHAR" property="paid" />
- <result column="min_date" jdbcType="TIMESTAMP" property="minDate" />
- <result column="max_date" jdbcType="TIMESTAMP" property="maxDate" />
- <result column="service_pay" jdbcType="VARCHAR" property="servicePay"/>
- <result column="late_pay" jdbcType="VARCHAR" property="latePay"/>
- <result column="return_pay" jdbcType="VARCHAR" property="returnPay"/>
- </resultMap>
- <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxBillDaily" resultMap="SumBaseResultMap">
- select
- sum(CAST(br.receive_pay AS DECIMAL(20,2))) receive_pay ,
- sum(CAST(br.pay AS DECIMAL(20,2))) paid,
- min(starttime) min_date,
- max(endtime) max_date,
- sum(CAST(br.service_charge_pay AS DECIMAL(20,2))) service_pay ,
- '0' late_pay,
- '0' return_pay
- from wx_bill_daily br
- <include refid="queryBillDailyListConditions"/>
- </select>
-
- <select id="getMerchantIdList" parameterType="com.iformall.domain.po.WxBillDaily" resultType="Long">
- select distinct merchant_id from wx_bill_daily br
- <include refid="queryBillDailyListConditions"/>
- </select>
-
- <resultMap id="HotNotifyBaseResultMap" type="com.iformall.domain.vo.WxBillHotNotify">
- <result column="total_count" jdbcType="INTEGER" property="totalCount"/>
- <result column="total_money" jdbcType="VARCHAR" property="totalMoney" />
- <result column="min_begin_time" jdbcType="TIMESTAMP" property="minBeginTime"/>
- </resultMap>
- <select id="getBillHotNotify" parameterType="com.iformall.domain.po.WxBillDaily" resultMap="HotNotifyBaseResultMap">
- select count(1) total_count , sum(CAST(br.`receive_pay` AS DECIMAL(20,2)) - CAST(br.`pay` AS DECIMAL(20,2)) - CAST(IFNULL(br.`set_off`,'0') AS DECIMAL(20,2))) total_money,MIN(br.starttime) min_begin_time from wx_bill_daily br
- <include refid="queryBillDailyListConditions"/>
- </select>
-
- <resultMap id="NotifyResultMap" type="com.iformall.domain.vo.WxBillNotify">
- <result column="bill_type" jdbcType="INTEGER" property="billType"/>
- <result column="bill_type_name" jdbcType="VARCHAR" property="billTypeName" />
- <result column="bill_id" jdbcType="BIGINT" property="billId" />
- <result column="starttime" jdbcType="TIMESTAMP" property="starttime"/>
- <result column="endtime" jdbcType="TIMESTAMP" property="endtime"/>
- <result column="receive_pay" jdbcType="VARCHAR" property="receivePay"/>
- <result column="pay" jdbcType="VARCHAR" property="pay"/>
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
- </resultMap>
- <select id="getBillNotifyList" parameterType="com.iformall.domain.po.WxBillDaily" resultMap="NotifyResultMap">
- select #{billType} bill_type,#{billTypeName} bill_type_name,br.id as bill_id, br.starttime,br.endtime,br.receive_pay,br.pay,br.merchant_id from wx_bill_daily br
- <include refid="queryBillDailyListConditions"/>
- </select>
-
-
- <update id="updateNotPaidStatus" parameterType="hashmap">
- update wx_bill_daily set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
- where status!=#{paid}
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- and DATEDIFF(now(),receive_date)>0
- </update>
-
- <update id="updateWaitPayStatus" parameterType="hashmap">
- update wx_bill_daily set status=#{waitPay} where status!=#{paid}
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- and DATEDIFF(now(),receive_date) <=0
- </update>
-
- <delete id = "deleteById" parameterType="HashMap">
- delete from wx_bill_daily where id = #{id} and tenant_id = #{tenantId}
- </delete>
-
- <insert id="insertBills" parameterType="HashMap">
- INSERT INTO wx_bill_daily (`id`,`tenant_id`,`parent_tenant_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`createtime`,`expired_day`,`status`,`is_del`,
- `merchant_id`,`user_id`,`shop_id`,`shop_name`,`updatetime`,`type`,`rent_shop_type`,`apply_status`,`pay_way`,`price_detail`,
- `starttime`,`endtime`,`freeze`,`build_way`,`service_charge_pay`,`apply_pay_img`,`apply_update_time`,`remark`,`create_by`,`update_by`,
- `create_by_name`,`update_by_name`,`energy_reading_calcuteId`,`energy_reading_id`,`energy_fees_id`)
- VALUES
- <foreach collection="list" item="item" index="index" separator=",">
- (
- #{item.id},#{item.tenantId},#{item.parentTenantId},#{item.receivePay},#{item.pay},#{item.receiveDate},#{item.payDate},#{item.createtime},#{item.expiredDay},#{item.status},#{item.isDel},
- #{item.merchantId},#{item.userId},#{item.shopId},#{item.shopName},#{item.updatetime},#{item.type},#{item.rentShopType},#{item.applyStatus},#{item.payWay},#{item.priceDetail},
- #{item.starttime},#{item.endtime},#{item.freeze},#{item.buildWay},#{item.serviceChargePay},#{item.applyPayImg},#{item.applyUpdateTime},#{item.remark},#{item.createBy},#{item.updateBy},
- #{item.createByName},#{item.updateByName},#{item.energyReadingCalcuteId},#{item.energyReadingId},#{item.energyFeesId}
- )
- </foreach>
- </insert>
-
- <delete id = "deleteEnergyReadingBills" parameterType="HashMap">
- delete from wx_bill_daily where energy_reading_calcuteId = #{energyReadingCalcuteId} and tenant_id = #{tenantId} and status = 2 and pay <= 0 and IFNULL(`set_off`,'0') <= 0
- </delete>
-
- <delete id="deleteNoNeedPayBill" parameterType="com.iformall.domain.po.WxBillDaily">
- delete from wx_bill_daily where merchant_id = #{merchantId} and status = 2
- and starttime > #{shopEndtime} and IFNULL(`pay`,'0') <= 0 AND IFNULL(`set_off`,'0') <= 0
- </delete>
-
- </mapper>
|