|
- <?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.WxBillOtherMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillOther">
- <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="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="expired_day" jdbcType="INTEGER" property="expiredDay" />
- <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="name" jdbcType="VARCHAR" property="name" />
-
- <result column="comments" jdbcType="VARCHAR" property="comments" />
- <result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
- <result column="pay_way" jdbcType="INTEGER" property="payWay"/>
-
- <result column="merchant_name" property="merchantName"/>
-
- <result column="starttime" property="starttime"/>
- <result column="endtime" property="endtime"/>
- <result column="freeze" property="freeze"/>
- <result column="service_charge_pay" property="serviceChargePay"/>
- <result column="bill_type_name" property="billTypeName"/>
- <result column="bill_remark" property="billRemark"/>
- </resultMap>
-
- <sql id="allColumns">
- `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`,`name`,`comments`,
- `rent_shop_type`,`pay_way`,`starttime`,`endtime`,endtime,service_charge_pay,`apply_status`,`apply_pay_img`,`apply_update_time`,
- '其他费用' bill_type_name, CONCAT(`name`,',',`comments`) bill_remark
- </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 != 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 != 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 != userId "> and `user_id` = #{userId} </if>
- <if test=" null != shopId "> and `shop_id` = #{shopId} </if>
- <if test=" null != updatetime "> and `updatetime` = #{updatetime} </if>
- <if test=" null != name "> and `name` = #{name} </if>
- <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
- <if test=" null != payWay ">and `pay_way` = #{payWay}</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.WxBillOther" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_bill_other
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="selectById" parameterType="Long" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_bill_other
- where id = #{id}
- </select>
-
- <sql id = "queryBillListConditions">
- <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 != merchantId ">and br.`merchant_id` = #{merchantId}</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 != name and ''!=name">and br.`name` like concat('%',#{name},'%')</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` > 0 and br.status not in (3,6))
- </if>
- <if test=" null != nearBillLastTime and null != oweBillLastTime">
- and (br.`starttime` > #{oweBillLastTime} and br.`starttime` <= #{nearBillLastTime} and br.status not in (3,6))
- </if>
- <if test=" null != merchantIds ">
- and br.`merchant_id` in
- <foreach collection="merchantIds" index="index" item="midItem" open="(" separator="," close=")">
- #{midItem}
- </foreach>
- </if>
-
- </where>
- </sql>
-
- <select id="queryBillList" parameterType="com.iformall.domain.po.WxBillOther" 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.shop_name,br.`updatetime`,br.`apply_status`,
- br.`apply_pay_img`,br.`apply_update_time`,br.`merchant_id`,br.shop_id,br.name,br.comments,br.`rent_shop_type`,
- br.pay_way,br.`starttime`,br.`endtime`,br.freeze,br.service_charge_pay,'其他费用' bill_type_name, CONCAT(br.`name`,',',br.`comments`) bill_remark
- from wx_bill_other br
- <include refid="queryBillListConditions" />
- <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" />
- </resultMap>
- <select id="getBillMonthSum" parameterType="com.iformall.domain.po.WxBillOther" resultMap="SumBaseResultMap">
- select sum(br.receive_pay) receive_pay , sum(br.pay) paid from wx_bill_other br
- <include refid="queryBillListConditions"/>
- </select>
-
- <select id="getMerchantIdList" parameterType="com.iformall.domain.po.WxBillOther" resultType="Long">
- select distinct merchant_id from wx_bill_other br
- <include refid="queryBillListConditions"/>
- </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.WxBillOther" resultMap="HotNotifyBaseResultMap">
- select count(1) total_count , sum(br.`receive_pay` - br.`pay`) total_money,MIN(br.starttime) min_begin_time from wx_bill_other br
- <include refid="queryBillListConditions"/>
- </select>
-
- <update id="updateNotPaidStatus" parameterType="hashmap">
- update wx_bill_other set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- and status!=#{paid} and DATEDIFF(now(),receive_date)>0
- </update>
-
- <update id="updateWaitPayStatus" parameterType="hashmap">
- update wx_bill_other set status=#{waitPay} where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- and status!=#{paid} and DATEDIFF(now(),receive_date) <=0
- </update>
-
-
- <select id="queryPayInfoTotal" resultType="hashmap" parameterType="hashmap">
- select round(sum(t.receivepay)/100,2) receivepay,round(sum(t.pay)/100,2) pay from
- (
- select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_other
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- and receive_date between #{startdate} and #{enddate}
- union
- select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_daily
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- and receive_date between #{startdate} and #{enddate}
- ) t
- </select>
-
-
- <select id="queryOweInfo" resultType="hashmap" parameterType="hashmap">
- select IFNULL(round(sum(res.owe)/100,2),0) owe,res.tenant_id from
- (
- select IFNULL(sum(receive_pay - pay),0) owe,tenant_id from wx_bill_daily
- where status = 1
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- and receive_date between #{startdate} and #{enddate}
- union all
- select IFNULL(sum(receive_pay - pay),0) owe,tenant_id from wx_bill_daily
- where status = 1
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- and receive_date between #{startdate} and #{enddate}
- ) res
- </select>
-
- </mapper>
|