emis-service/emis-biz/src/main/resources/mapper/EmisSettlePayRecordMapper.xml
2025-05-16 15:33:21 +08:00

595 lines
40 KiB
XML

<?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.xdadan.erp.emis.mapper.EmisSettlePayRecordMapper" >
<resultMap type="EmisSettlePayRecord" id="EmisSettlePayRecordResult" extends="com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult">
<result property="id" column="id" />
<result property="payId" column="pay_id" />
<result property="payType" column="pay_type" />
<result property="recType" column="rec_type" />
<result property="payMan" column="pay_man" />
<result property="payManCode" column="pay_man_code" />
<result property="settleBillNo" column="settle_bill_no" />
<result property="blAudit" column="bl_audit" />
<result property="auditDate" column="audit_date" />
<result property="auditManCode" column="audit_man_code" />
<result property="auditSiteCode" column="audit_site_code" />
<result property="customerCode" column="customer_code" />
<result property="customerName" column="customer_name" />
<result property="payMoney" column="pay_money" />
<result property="payStatus" column="pay_status" />
<result property="payStatusDesc" column="pay_status_desc" />
<result property="breakType" column="break_type" />
<result property="breakReason" column="break_reason" />
<result property="breakEmpCode" column="break_emp_code" />
<result property="recManCode" column="rec_man_code" />
<result property="settleType" column="settle_type" />
<result property="refundDate" column="refund_date" />
<result property="refundManCode" column="refund_man_code" />
<result property="refundSeq" column="refund_seq" />
<result property="refundMode" column="refund_mode" />
<result property="refundMoney" column="refund_money" />
<result property="refundReason" column="refund_reason" />
<result property="refundRemark" column="refund_remark" />
<result property="refundOpManCode" column="refund_op_man_code" />
<result property="refundRegisterSiteCode" column="refund_register_site_code" />
<result property="refundRegisterManCode" column="refund_register_man_code" />
<result property="satisfyMoney" column="satisfy_money" />
<result property="satisfyReason" column="satisfy_reason" />
<result property="allowanceMoney" column="allowance_money" />
<result property="allowanceReason" column="allowance_reason" />
<result property="deductionMoney" column="deduction_money" />
<result property="deductionReason" column="deduction_reason" />
<result property="otherMoney" column="other_money" />
<result property="otherReason" column="other_reason" />
<result property="tradeDate" column="trade_date" />
</resultMap>
<resultMap type="PayBackRecordDtl" id="PayBackRecordDtlResult">
<result property="billCode" column="bill_code" />
<result property="payId" column="pay_id" />
<result property="settleBillNo" column="settle_bill_no" />
<result property="payMoney" column="pay_money" />
<association property="waybillDetail"
column="bill_code"
select="com.xdadan.erp.emis.mapper.EmisWaybillMapper.selectWaybillBaseInfoByBillCode"
fetchType="lazy"
/>
<association property="settleBillDetail"
column="settle_bill_no"
select="com.xdadan.erp.emis.mapper.EmisSettleBillMapper.selectSettleBillBySettleBillNo"
fetchType="lazy"
/>
<association property="settlePayRecordDetail"
column="pay_id"
select="selectEmisSettlePayRecordByPayId"
fetchType="lazy"
/>
<association property="settleSubBill"
column="bill_code"
select="com.xdadan.erp.emis.mapper.EmisSettleSubBillMapper.selectSettleSubBillListByBillCode"
fetchType="lazy"
/>
</resultMap>
<sql id="selectEmisSettlePayRecordVo">
select id, pay_id, pay_type, rec_type, pay_man, pay_man_code, settle_bill_no, bl_audit, audit_date, audit_man_code, audit_site_code, customer_code, customer_name, pay_money, pay_status, pay_status_desc, break_type, break_reason, break_emp_code, rec_man_code, settle_type, refund_date, refund_man_code, refund_seq, refund_mode, refund_money, refund_reason, refund_remark, refund_op_man_code, refund_register_site_code, refund_register_man_code, satisfy_money, satisfy_reason, allowance_money, allowance_reason, deduction_money, deduction_reason, other_money, other_reason, trade_date, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_settle_pay_record
</sql>
<select id="getSettlePayStatInfoMap" parameterType="EmisSettlePayRecord" resultType="map">
select sum(pay_money) as totalPayMoney
from emis_settle_pay_record
<where>
del_flag='0'
<if test="id != null "> and id = #{id}</if>
<if test="payId != null and payId != ''"> and pay_id = #{payId}</if>
<if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
<if test="recType != null and recType != ''"> and rec_type = #{recType}</if>
<if test="payMan != null and payMan != ''"> and pay_man like concat('%', #{payMan}, '%')</if>
<if test="payManCode != null and payManCode != ''"> and pay_man_code like concat('%', #{payManCode}, '%')</if>
<if test="blAudit != null and blAudit != ''"> and bl_audit = #{blAudit}</if>
<if test="auditDate != null "> and audit_date = #{auditDate}</if>
<if test="auditManCode != null and auditManCode != ''"> and audit_man_code = #{auditManCode}</if>
<if test="auditSiteCode != null and auditSiteCode != ''"> and audit_site_code = #{auditSiteCode}</if>
<if test="customerCode != null and customerCode != ''"> and customer_code = #{customerCode}</if>
<if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
<if test="payMoney != null "> and pay_money = #{payMoney}</if>
<if test="payStatus != null and payStatus != ''"> and pay_status = #{payStatus}</if>
<if test="payStatusDesc != null and payStatusDesc != ''"> and pay_status_desc like concat('%', #{payStatusDesc}, '%')</if>
<if test="breakType != null and breakType != ''"> and break_type = #{breakType}</if>
<if test="breakReason != null and breakReason != ''"> and break_reason like concat('%', #{breakReason}, '%')</if>
<if test="breakEmpCode != null and breakEmpCode != ''"> and break_emp_code = #{breakEmpCode}</if>
<if test="recManCode != null and recManCode != ''"> and rec_man_code = #{recManCode}</if>
<if test="settleType != null and settleType != ''"> and settle_type = #{settleType}</if>
<if test="refundDate != null "> and refund_date = #{refundDate}</if>
<if test="refundManCode != null and refundManCode != ''"> and refund_man_code = #{refundManCode}</if>
<if test="refundSeq != null and refundSeq != ''"> and refund_seq = #{refundSeq}</if>
<if test="refundMode != null and refundMode != ''"> and refund_mode = #{refundMode}</if>
<if test="refundMoney != null "> and refund_money = #{refundMoney}</if>
<if test="refundReason != null and refundReason != ''"> and refund_reason like concat('%', #{refundReason}, '%')</if>
<if test="refundRemark != null and refundRemark != ''"> and refund_remark like concat('%', #{refundRemark}, '%')</if>
<if test="refundOpManCode != null and refundOpManCode != ''"> and refund_op_man_code = #{refundOpManCode}</if>
<if test="refundRegisterSiteCode != null and refundRegisterSiteCode != ''"> and refund_register_site_code = #{refundRegisterSiteCode}</if>
<if test="refundRegisterManCode != null and refundRegisterManCode != ''"> and refund_register_man_code = #{refundRegisterManCode}</if>
<if test="satisfyMoney != null "> and satisfy_money = #{satisfyMoney}</if>
<if test="satisfyReason != null and satisfyReason != ''"> and satisfy_reason like concat('%', #{satisfyReason}, '%')</if>
<if test="allowanceMoney != null "> and allowance_money = #{allowanceMoney}</if>
<if test="allowanceReason != null and allowanceReason != ''"> and allowance_reason = #{allowanceReason}</if>
<if test="deductionMoney != null "> and deduction_money = #{deductionMoney}</if>
<if test="deductionReason != null and deductionReason != ''"> and deduction_reason = #{deductionReason}</if>
<if test="otherMoney != null "> and other_money = #{otherMoney}</if>
<if test="otherReason != null and otherReason != ''"> and other_reason like concat('%', #{otherReason}, '%')</if>
<if test="tradeDate != null "> and trade_date = #{tradeDate}</if>
<if test="remark != null and remark != ''"> and remark like concat('%', #{remark}, '%')</if>
<if test="delFlag != null and delFlag != ''"> and del_flag like concat('%', #{delFlag}, '%')</if>
<if test="createBy != null and createBy != ''"> and create_by like concat('%', #{createBy}, '%')</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and update_by like concat('%', #{updateBy}, '%')</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
<if test="createSite != null and createSite != ''"> and create_site like concat('%', #{createSite}, '%')</if>
<if test="updateSite != null and updateSite != ''"> and update_site like concat('%', #{updateSite}, '%')</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != ''">
and create_time <![CDATA[ >= ]]> #{params.beginCreateTime}
</if>
<if test="params.endCreateTime != null and params.endCreateTime != ''">
and create_time <![CDATA[ <= ]]> #{params.endCreateTime}
</if>
<if test="params.beginTradeDate != null and params.beginTradeDate != ''">
and trade_date <![CDATA[ >= ]]> #{params.beginTradeDate}
</if>
<if test="params.endTradeDate != null and params.endTradeDate != ''">
and trade_date <![CDATA[ <= ]]> #{params.endTradeDate}
</if>
<if test="params.billCode != null and params.billCode != ''">
and pay_id in(
select pay_id from emis_settle_pay_rel espr
where espr.del_flag='0'
and FIND_IN_SET(espr.`bill_code`,#{params.billCode})
)
</if>
<if test="settleBillNo != null and settleBillNo != ''">
and pay_id in(
select pay_id from emis_settle_pay_bill_rel espbr
where espbr.del_flag='0'
and FIND_IN_SET(espbr.settle_bill_no,#{settleBillNo})
)
</if>
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
and settle_bill_no in(
select bill_no from emis_settle_sub_bill b where del_flag='0'
and (
b.salesmen=#{params.privEmpName}
or b.payee=#{params.privEmpName}
or b.salesmen in(
select salesmen from emis_salesmen_rel esr where esr.del_flag='0' and esr.bl_open='1' and now() <![CDATA[ >= ]]> esr.start_date and now() <![CDATA[ <= ]]> esr.end_date and esr.sales_ass=#{params.privEmpName}
)
)
)
</if>
</where>
</select>
<select id="selectEmisSettlePayRecordList" parameterType="EmisSettlePayRecord" resultMap="EmisSettlePayRecordResult">
<include refid="selectEmisSettlePayRecordVo"/>
<where>
del_flag='0'
<if test="id != null "> and id = #{id}</if>
<if test="payId != null and payId != ''"> and pay_id = #{payId}</if>
<if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
<if test="recType != null and recType != ''"> and rec_type = #{recType}</if>
<if test="payMan != null and payMan != ''"> and pay_man like concat('%', #{payMan}, '%')</if>
<if test="payManCode != null and payManCode != ''"> and pay_man_code like concat('%', #{payManCode}, '%')</if>
<if test="blAudit != null and blAudit != ''"> and bl_audit = #{blAudit}</if>
<if test="auditDate != null "> and audit_date = #{auditDate}</if>
<if test="auditManCode != null and auditManCode != ''"> and audit_man_code = #{auditManCode}</if>
<if test="auditSiteCode != null and auditSiteCode != ''"> and audit_site_code = #{auditSiteCode}</if>
<if test="customerCode != null and customerCode != ''"> and customer_code = #{customerCode}</if>
<if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
<if test="payMoney != null "> and pay_money = #{payMoney}</if>
<if test="payStatus != null and payStatus != ''"> and pay_status = #{payStatus}</if>
<if test="payStatusDesc != null and payStatusDesc != ''"> and pay_status_desc like concat('%', #{payStatusDesc}, '%')</if>
<if test="breakType != null and breakType != ''"> and break_type = #{breakType}</if>
<if test="breakReason != null and breakReason != ''"> and break_reason like concat('%', #{breakReason}, '%')</if>
<if test="breakEmpCode != null and breakEmpCode != ''"> and break_emp_code = #{breakEmpCode}</if>
<if test="recManCode != null and recManCode != ''"> and rec_man_code = #{recManCode}</if>
<if test="settleType != null and settleType != ''"> and settle_type = #{settleType}</if>
<if test="refundDate != null "> and refund_date = #{refundDate}</if>
<if test="refundManCode != null and refundManCode != ''"> and refund_man_code = #{refundManCode}</if>
<if test="refundSeq != null and refundSeq != ''"> and refund_seq = #{refundSeq}</if>
<if test="refundMode != null and refundMode != ''"> and refund_mode = #{refundMode}</if>
<if test="refundMoney != null "> and refund_money = #{refundMoney}</if>
<if test="refundReason != null and refundReason != ''"> and refund_reason like concat('%', #{refundReason}, '%')</if>
<if test="refundRemark != null and refundRemark != ''"> and refund_remark like concat('%', #{refundRemark}, '%')</if>
<if test="refundOpManCode != null and refundOpManCode != ''"> and refund_op_man_code = #{refundOpManCode}</if>
<if test="refundRegisterSiteCode != null and refundRegisterSiteCode != ''"> and refund_register_site_code = #{refundRegisterSiteCode}</if>
<if test="refundRegisterManCode != null and refundRegisterManCode != ''"> and refund_register_man_code = #{refundRegisterManCode}</if>
<if test="satisfyMoney != null "> and satisfy_money = #{satisfyMoney}</if>
<if test="satisfyReason != null and satisfyReason != ''"> and satisfy_reason like concat('%', #{satisfyReason}, '%')</if>
<if test="allowanceMoney != null "> and allowance_money = #{allowanceMoney}</if>
<if test="allowanceReason != null and allowanceReason != ''"> and allowance_reason = #{allowanceReason}</if>
<if test="deductionMoney != null "> and deduction_money = #{deductionMoney}</if>
<if test="deductionReason != null and deductionReason != ''"> and deduction_reason = #{deductionReason}</if>
<if test="otherMoney != null "> and other_money = #{otherMoney}</if>
<if test="otherReason != null and otherReason != ''"> and other_reason like concat('%', #{otherReason}, '%')</if>
<if test="tradeDate != null "> and trade_date = #{tradeDate}</if>
<if test="remark != null and remark != ''"> and remark like concat('%', #{remark}, '%')</if>
<if test="delFlag != null and delFlag != ''"> and del_flag like concat('%', #{delFlag}, '%')</if>
<if test="createBy != null and createBy != ''"> and create_by like concat('%', #{createBy}, '%')</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and update_by like concat('%', #{updateBy}, '%')</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
<if test="createSite != null and createSite != ''"> and create_site like concat('%', #{createSite}, '%')</if>
<if test="updateSite != null and updateSite != ''"> and update_site like concat('%', #{updateSite}, '%')</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != ''">
and create_time <![CDATA[ >= ]]> #{params.beginCreateTime}
</if>
<if test="params.endCreateTime != null and params.endCreateTime != ''">
and create_time <![CDATA[ <= ]]> #{params.endCreateTime}
</if>
<if test="params.beginTradeDate != null and params.beginTradeDate != ''">
and trade_date <![CDATA[ >= ]]> #{params.beginTradeDate}
</if>
<if test="params.endTradeDate != null and params.endTradeDate != ''">
and trade_date <![CDATA[ <= ]]> #{params.endTradeDate}
</if>
<if test="params.billCode != null and params.billCode != ''">
and pay_id in(
select pay_id from emis_settle_pay_rel espr
where espr.del_flag='0'
and FIND_IN_SET(espr.`bill_code`,#{params.billCode})
)
</if>
<if test="settleBillNo != null and settleBillNo != ''">
and pay_id in(
select pay_id from emis_settle_pay_bill_rel espbr
where espbr.del_flag='0'
and FIND_IN_SET(espbr.settle_bill_no,#{settleBillNo})
)
</if>
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
and settle_bill_no in(
select bill_no from emis_settle_sub_bill b where del_flag='0'
and (
b.salesmen=#{params.privEmpName}
or b.payee=#{params.privEmpName}
or b.salesmen in(
select salesmen from emis_salesmen_rel esr where esr.del_flag='0' and esr.bl_open='1' and now() <![CDATA[ >= ]]> esr.start_date and now() <![CDATA[ <= ]]> esr.end_date and esr.sales_ass=#{params.privEmpName}
)
)
)
</if>
</where>
order by create_time desc
</select>
<select id="selectSettlePayRecordListBySettleBillNo" parameterType="String" resultMap="EmisSettlePayRecordResult">
select id, pay_id, pay_type, rec_type, pay_man, pay_man_code, settle_bill_no, bl_audit, audit_date, audit_man_code, audit_site_code, customer_code, customer_name, pay_money, pay_status, pay_status_desc, break_type, break_reason, break_emp_code, rec_man_code, settle_type, refund_date, refund_man_code, refund_seq, refund_mode, refund_money, refund_reason, refund_remark, refund_op_man_code, refund_register_site_code, refund_register_man_code, satisfy_money, satisfy_reason, allowance_money, allowance_reason, deduction_money, deduction_reason, other_money, other_reason, trade_date, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_settle_pay_record a
where del_flag='0' and pay_id in(
select pay_id from emis_settle_pay_bill_rel espbr where espbr.del_flag='0' and espbr.settle_bill_no = #{settleBillNo}
)
</select>
<select id="queryPayBackRecordList" parameterType="EmisSettlePayRecord" resultMap="PayBackRecordDtlResult">
SELECT
a.settle_bill_no,
a.bill_code,
b.pay_id,
d.pay_money,
d.create_time
FROM
emis_settle_sub_bill a,
emis_settle_pay_record b,
emis_settle_pay_rel d
WHERE
d.del_flag = '0'
AND a.del_flag = '0'
AND b.del_flag = '0'
AND b.pay_id = d.pay_id
AND a.bill_no = d.bill_no
AND b.pay_id IN (
SELECT pay_id FROM emis_settle_pay_bill_rel espbr,emis_settle_bill esb
WHERE espbr.del_flag=0 and esb.del_flag=0
and espbr.settle_bill_no=esb.settle_bill_no
<if test="params.queryDataType != null and params.queryDataType == 1">
and b.trade_date <![CDATA[ <= ]]> esb.payment_due_date
</if>
<if test="params.queryDataType != null and params.queryDataType == 2">
and ( b.trade_date <![CDATA[ > ]]> esb.payment_due_date and b.trade_date <![CDATA[ < ]]> DATE_SUB( esb.payment_due_date, INTERVAL (esb.credit_period-60) DAY ) )
</if>
<if test="params.queryDataType != null and params.queryDataType == 3">
and b.trade_date <![CDATA[ >= ]]> DATE_SUB( esb.payment_due_date, INTERVAL - (esb.credit_period-60) DAY )
</if>
and FIND_IN_SET(espbr.settle_bill_no,#{settleBillNo})
)
order by b.create_time desc
</select>
<select id="queryNoPayBackRecordList" parameterType="EmisSettlePayRecord" resultMap="PayBackRecordDtlResult">
SELECT
a.settle_bill_no,
a.bill_code
FROM
emis_settle_sub_bill a
WHERE a.del_flag = '0'
and a.payment_status != '1'
and FIND_IN_SET(a.settle_bill_no,#{settleBillNo})
order by a.create_time desc
</select>
<select id="checkUnique" parameterType="EmisSettlePayRecord" resultType="int">
select count(1) from emis_settle_pay_record
where del_flag='0'
and id = #{id}
and pay_id = #{payId}
and pay_type = #{payType}
and rec_type = #{recType}
and pay_man = #{payMan}
and pay_man_code = #{payManCode}
and settle_bill_no = #{settleBillNo}
and bl_audit = #{blAudit}
and audit_date = #{auditDate}
and audit_man_code = #{auditManCode}
and audit_site_code = #{auditSiteCode}
and customer_code = #{customerCode}
and customer_name = #{customerName}
and pay_money = #{payMoney}
and pay_status = #{payStatus}
and pay_status_desc = #{payStatusDesc}
and break_type = #{breakType}
and break_reason = #{breakReason}
and break_emp_code = #{breakEmpCode}
and rec_man_code = #{recManCode}
and settle_type = #{settleType}
and refund_date = #{refundDate}
and refund_man_code = #{refundManCode}
and refund_seq = #{refundSeq}
and refund_mode = #{refundMode}
and refund_money = #{refundMoney}
and refund_reason = #{refundReason}
and refund_remark = #{refundRemark}
and refund_op_man_code = #{refundOpManCode}
and refund_register_site_code = #{refundRegisterSiteCode}
and refund_register_man_code = #{refundRegisterManCode}
and satisfy_money = #{satisfyMoney}
and satisfy_reason = #{satisfyReason}
and allowance_money = #{allowanceMoney}
and allowance_reason = #{allowanceReason}
and deduction_money = #{deductionMoney}
and deduction_reason = #{deductionReason}
and other_money = #{otherMoney}
and other_reason = #{otherReason}
and trade_date = #{tradeDate}
and remark = #{remark}
and del_flag = #{delFlag}
and create_by = #{createBy}
and create_time = #{createTime}
and update_by = #{updateBy}
and update_time = #{updateTime}
and create_site = #{createSite}
and update_site = #{updateSite}
limit 1
</select>
<select id="selectEmisSettlePayRecordById" parameterType="Long" resultMap="EmisSettlePayRecordResult">
select id, pay_id, pay_type, rec_type, pay_man, pay_man_code, settle_bill_no, bl_audit, audit_date, audit_man_code, audit_site_code, customer_code, customer_name, pay_money, pay_status, pay_status_desc, break_type, break_reason, break_emp_code, rec_man_code, settle_type, refund_date, refund_man_code, refund_seq, refund_mode, refund_money, refund_reason, refund_remark, refund_op_man_code, refund_register_site_code, refund_register_man_code, satisfy_money, satisfy_reason, allowance_money, allowance_reason, deduction_money, deduction_reason, other_money, other_reason, trade_date, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_settle_pay_record a
where a.id = #{id}
</select>
<select id="selectEmisSettlePayRecordByPayId" parameterType="Long" resultMap="EmisSettlePayRecordResult">
select id, pay_id, pay_type, rec_type, pay_man, pay_man_code, settle_bill_no, bl_audit, audit_date, audit_man_code, audit_site_code, customer_code, customer_name, pay_money, pay_status, pay_status_desc, break_type, break_reason, break_emp_code, rec_man_code, settle_type, refund_date, refund_man_code, refund_seq, refund_mode, refund_money, refund_reason, refund_remark, refund_op_man_code, refund_register_site_code, refund_register_man_code, satisfy_money, satisfy_reason, allowance_money, allowance_reason, deduction_money, deduction_reason, other_money, other_reason, trade_date, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_settle_pay_record a
where a.pay_id = #{payId} and a.del_flag='0'
</select>
<insert id="insertEmisSettlePayRecord" parameterType="EmisSettlePayRecord" useGeneratedKeys="true" keyProperty="id">
insert into emis_settle_pay_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="payId != null and payId != ''">pay_id,</if>
<if test="payType != null and payType != ''">pay_type,</if>
<if test="recType != null and recType != ''">rec_type,</if>
<if test="payMan != null and payMan != ''">pay_man,</if>
<if test="payManCode != null and payManCode != ''">pay_man_code,</if>
<if test="settleBillNo != null and settleBillNo != ''">settle_bill_no,</if>
<if test="blAudit != null and blAudit != ''">bl_audit,</if>
<if test="auditDate != null">audit_date,</if>
<if test="auditManCode != null and auditManCode != ''">audit_man_code,</if>
<if test="auditSiteCode != null and auditSiteCode != ''">audit_site_code,</if>
<if test="customerCode != null and customerCode != ''">customer_code,</if>
<if test="customerName != null and customerName != ''">customer_name,</if>
<if test="payMoney != null">pay_money,</if>
<if test="payStatus != null and payStatus != ''">pay_status,</if>
<if test="payStatusDesc != null and payStatusDesc != ''">pay_status_desc,</if>
<if test="breakType != null and breakType != ''">break_type,</if>
<if test="breakReason != null and breakReason != ''">break_reason,</if>
<if test="breakEmpCode != null and breakEmpCode != ''">break_emp_code,</if>
<if test="recManCode != null and recManCode != ''">rec_man_code,</if>
<if test="settleType != null and settleType != ''">settle_type,</if>
<if test="refundDate != null">refund_date,</if>
<if test="refundManCode != null and refundManCode != ''">refund_man_code,</if>
<if test="refundSeq != null and refundSeq != ''">refund_seq,</if>
<if test="refundMode != null and refundMode != ''">refund_mode,</if>
<if test="refundMoney != null">refund_money,</if>
<if test="refundReason != null and refundReason != ''">refund_reason,</if>
<if test="refundRemark != null and refundRemark != ''">refund_remark,</if>
<if test="refundOpManCode != null and refundOpManCode != ''">refund_op_man_code,</if>
<if test="refundRegisterSiteCode != null and refundRegisterSiteCode != ''">refund_register_site_code,</if>
<if test="refundRegisterManCode != null and refundRegisterManCode != ''">refund_register_man_code,</if>
<if test="satisfyMoney != null">satisfy_money,</if>
<if test="satisfyReason != null and satisfyReason != ''">satisfy_reason,</if>
<if test="allowanceMoney != null">allowance_money,</if>
<if test="allowanceReason != null and allowanceReason != ''">allowance_reason,</if>
<if test="deductionMoney != null">deduction_money,</if>
<if test="deductionReason != null and deductionReason != ''">deduction_reason,</if>
<if test="otherMoney != null">other_money,</if>
<if test="otherReason != null and otherReason != ''">other_reason,</if>
<if test="tradeDate != null">trade_date,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="createSite != null and createSite != ''">create_site,</if>
<if test="updateSite != null and updateSite != ''">update_site,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="payId != null and payId != ''">#{payId},</if>
<if test="payType != null and payType != ''">#{payType},</if>
<if test="recType != null and recType != ''">#{recType},</if>
<if test="payMan != null and payMan != ''">#{payMan},</if>
<if test="payManCode != null and payManCode != ''">#{payManCode},</if>
<if test="settleBillNo != null and settleBillNo != ''">#{settleBillNo},</if>
<if test="blAudit != null and blAudit != ''">#{blAudit},</if>
<if test="auditDate != null">#{auditDate},</if>
<if test="auditManCode != null and auditManCode != ''">#{auditManCode},</if>
<if test="auditSiteCode != null and auditSiteCode != ''">#{auditSiteCode},</if>
<if test="customerCode != null and customerCode != ''">#{customerCode},</if>
<if test="customerName != null and customerName != ''">#{customerName},</if>
<if test="payMoney != null">#{payMoney},</if>
<if test="payStatus != null and payStatus != ''">#{payStatus},</if>
<if test="payStatusDesc != null and payStatusDesc != ''">#{payStatusDesc},</if>
<if test="breakType != null and breakType != ''">#{breakType},</if>
<if test="breakReason != null and breakReason != ''">#{breakReason},</if>
<if test="breakEmpCode != null and breakEmpCode != ''">#{breakEmpCode},</if>
<if test="recManCode != null and recManCode != ''">#{recManCode},</if>
<if test="settleType != null and settleType != ''">#{settleType},</if>
<if test="refundDate != null">#{refundDate},</if>
<if test="refundManCode != null and refundManCode != ''">#{refundManCode},</if>
<if test="refundSeq != null and refundSeq != ''">#{refundSeq},</if>
<if test="refundMode != null and refundMode != ''">#{refundMode},</if>
<if test="refundMoney != null">#{refundMoney},</if>
<if test="refundReason != null and refundReason != ''">#{refundReason},</if>
<if test="refundRemark != null and refundRemark != ''">#{refundRemark},</if>
<if test="refundOpManCode != null and refundOpManCode != ''">#{refundOpManCode},</if>
<if test="refundRegisterSiteCode != null and refundRegisterSiteCode != ''">#{refundRegisterSiteCode},</if>
<if test="refundRegisterManCode != null and refundRegisterManCode != ''">#{refundRegisterManCode},</if>
<if test="satisfyMoney != null">#{satisfyMoney},</if>
<if test="satisfyReason != null and satisfyReason != ''">#{satisfyReason},</if>
<if test="allowanceMoney != null">#{allowanceMoney},</if>
<if test="allowanceReason != null and allowanceReason != ''">#{allowanceReason},</if>
<if test="deductionMoney != null">#{deductionMoney},</if>
<if test="deductionReason != null and deductionReason != ''">#{deductionReason},</if>
<if test="otherMoney != null">#{otherMoney},</if>
<if test="otherReason != null and otherReason != ''">#{otherReason},</if>
<if test="tradeDate != null">#{tradeDate},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createSite != null and createSite != ''">#{createSite},</if>
<if test="updateSite != null and updateSite != ''">#{updateSite},</if>
</trim>
</insert>
<update id="updateEmisSettlePayRecord" parameterType="EmisSettlePayRecord">
update emis_settle_pay_record
<trim prefix="SET" suffixOverrides=",">
<if test="payId != null and payId != ''">pay_id = #{payId},</if>
<if test="payType != null and payType != ''">pay_type = #{payType},</if>
<if test="recType != null and recType != ''">rec_type = #{recType},</if>
<if test="payMan != null and payMan != ''">pay_man = #{payMan},</if>
<if test="payManCode != null and payManCode != ''">pay_man_code = #{payManCode},</if>
<if test="settleBillNo != null and settleBillNo != ''">settle_bill_no = #{settleBillNo},</if>
<if test="blAudit != null and blAudit != ''">bl_audit = #{blAudit},</if>
<if test="auditDate != null">audit_date = #{auditDate},</if>
<if test="auditManCode != null and auditManCode != ''">audit_man_code = #{auditManCode},</if>
<if test="auditSiteCode != null and auditSiteCode != ''">audit_site_code = #{auditSiteCode},</if>
<if test="customerCode != null and customerCode != ''">customer_code = #{customerCode},</if>
<if test="customerName != null and customerName != ''">customer_name = #{customerName},</if>
<if test="payMoney != null">pay_money = #{payMoney},</if>
<if test="payStatus != null and payStatus != ''">pay_status = #{payStatus},</if>
<if test="payStatusDesc != null and payStatusDesc != ''">pay_status_desc = #{payStatusDesc},</if>
<if test="breakType != null and breakType != ''">break_type = #{breakType},</if>
<if test="breakReason != null and breakReason != ''">break_reason = #{breakReason},</if>
<if test="breakEmpCode != null and breakEmpCode != ''">break_emp_code = #{breakEmpCode},</if>
<if test="recManCode != null and recManCode != ''">rec_man_code = #{recManCode},</if>
<if test="settleType != null and settleType != ''">settle_type = #{settleType},</if>
<if test="refundDate != null">refund_date = #{refundDate},</if>
<if test="refundManCode != null and refundManCode != ''">refund_man_code = #{refundManCode},</if>
<if test="refundSeq != null and refundSeq != ''">refund_seq = #{refundSeq},</if>
<if test="refundMode != null and refundMode != ''">refund_mode = #{refundMode},</if>
<if test="refundMoney != null">refund_money = #{refundMoney},</if>
<if test="refundReason != null and refundReason != ''">refund_reason = #{refundReason},</if>
<if test="refundRemark != null and refundRemark != ''">refund_remark = #{refundRemark},</if>
<if test="refundOpManCode != null and refundOpManCode != ''">refund_op_man_code = #{refundOpManCode},</if>
<if test="refundRegisterSiteCode != null and refundRegisterSiteCode != ''">refund_register_site_code = #{refundRegisterSiteCode},</if>
<if test="refundRegisterManCode != null and refundRegisterManCode != ''">refund_register_man_code = #{refundRegisterManCode},</if>
<if test="satisfyMoney != null">satisfy_money = #{satisfyMoney},</if>
<if test="satisfyReason != null and satisfyReason != ''">satisfy_reason = #{satisfyReason},</if>
<if test="allowanceMoney != null">allowance_money = #{allowanceMoney},</if>
<if test="allowanceReason != null and allowanceReason != ''">allowance_reason = #{allowanceReason},</if>
<if test="deductionMoney != null">deduction_money = #{deductionMoney},</if>
<if test="deductionReason != null and deductionReason != ''">deduction_reason = #{deductionReason},</if>
<if test="otherMoney != null">other_money = #{otherMoney},</if>
<if test="otherReason != null and otherReason != ''">other_reason = #{otherReason},</if>
<if test="tradeDate != null">trade_date = #{tradeDate},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createSite != null and createSite != ''">create_site = #{createSite},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteEmisSettlePayRecordById" parameterType="Long">
update emis_settle_pay_record set del_flag='1' where id = #{id}
</delete>
<delete id="deleteEmisSettlePayRecordByIds" parameterType="String">
update emis_settle_pay_record set del_flag='1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="calculateRecedMoney" resultType="java.util.Map">
SELECT
DATE_FORMAT(trade_date, '%Y-%m-%d') as tradeDay,
SUM(IFNULL(pay_money, 0)) as payMoney
FROM
emis_settle_pay_record
WHERE
trade_date &gt;= #{beginTime}
AND trade_date &lt; #{endTime}
AND del_flag = '0'
GROUP BY
DATE_FORMAT(trade_date, '%Y-%m-%d')
ORDER BY
tradeDay
</select>
</mapper>