2024-07-03 19:17:36 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
< !DOCTYPE mapper
2024-07-09 22:42:16 +00:00
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
2024-07-03 19:17:36 +00:00
<mapper namespace= "com.xdadan.erp.emis.mapper.EmisSettleBillMapper" >
2024-07-09 22:42:16 +00:00
2024-07-25 12:20:10 +00:00
<resultMap type= "EmisSettleBill" id= "EmisSettleBillResult" extends= "com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult" >
2024-07-03 19:17:36 +00:00
<result property= "id" column= "id" />
<result property= "settleBillNo" column= "settle_bill_no" />
<result property= "settleBillName" column= "settle_bill_name" />
<result property= "settleType" column= "settle_type" />
<result property= "settleStartDate" column= "settle_start_date" />
<result property= "settleEndDate" column= "settle_end_date" />
<result property= "billMonth" column= "bill_month" />
<result property= "recMoney" column= "rec_money" />
<result property= "recedMoney" column= "reced_money" />
2024-09-02 22:11:17 +00:00
<result property= "invoicedMoney" column= "invoiced_money" />
2024-07-03 19:17:36 +00:00
<result property= "custNo" column= "cust_no" />
2024-07-26 00:26:10 +00:00
<result property= "custName" column= "cust_name" />
2024-07-03 19:17:36 +00:00
<result property= "customerCode" column= "customer_code" />
<result property= "customerName" column= "customer_name" />
<result property= "siteCode" column= "site_code" />
<result property= "siteName" column= "site_name" />
<result property= "satisfyMoney" column= "satisfy_money" />
<result property= "allowanceMoney" column= "allowance_money" />
<result property= "deductionMoney" column= "deduction_money" />
<result property= "otherMoney" column= "other_money" />
<result property= "satisfyReason" column= "satisfy_reason" />
<result property= "allowanceReason" column= "allowance_reason" />
<result property= "deductionReason" column= "deduction_reason" />
<result property= "otherReason" column= "other_reason" />
<result property= "openBillStatus" column= "open_bill_status" />
<result property= "paymentStatus" column= "payment_status" />
2024-07-09 22:42:16 +00:00
<result property= "chargeStatus" column= "charge_status" />
2024-07-03 19:17:36 +00:00
<result property= "sendPieceSum" column= "send_piece_sum" />
<result property= "pieceNumber" column= "piece_number" />
<result property= "feeWeight" column= "fee_weight" />
<result property= "uncollectedAmount" column= "uncollected_amount" />
<result property= "sendMoneySum" column= "send_money_sum" />
<result property= "refundAmount" column= "refund_amount" />
<result property= "refundMoney" column= "refund_money" />
2024-07-09 22:42:16 +00:00
<result property= "payee" column= "payee" />
<result property= "salesmen" column= "salesmen" />
2024-09-02 22:11:17 +00:00
<result property= "creditPeriod" column= "credit_period" />
<result property= "creditPeriodType" column= "credit_period_type" />
<result property= "settleDay" column= "settle_day" />
<result property= "paymentDueDate" column= "payment_due_date" />
2024-07-09 22:42:16 +00:00
<result property= "blSendOms" column= "bl_send_oms" />
<result property= "blConfirmCenter" column= "bl_confirm_center" />
<result property= "confirmCenterDate" column= "confirm_center_date" />
<result property= "confirmCenterNote" column= "confirm_center_note" />
<result property= "confirmCenterManCode" column= "confirm_center_man_code" />
<result property= "confirmCenterCode" column= "confirm_center_code" />
<result property= "blConfirmSite" column= "bl_confirm_site" />
<result property= "confirmSiteDate" column= "confirm_site_date" />
<result property= "confirmSiteManCode" column= "confirm_site_man_code" />
<result property= "confirmSiteNote" column= "confirm_site_note" />
<result property= "confirmSiteCode" column= "confirm_site_code" />
2024-08-09 10:15:28 +00:00
<association property= "confirmCenterManName" column= "confirm_center_man_code" select= "com.xdadan.erp.emis.mapper.EmisBaseMapper.selectEmpNameByCode" />
<association property= "confirmCenterName" column= "confirm_center_code" select= "com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode" />
<association property= "confirmSiteManName" column= "confirm_site_man_code" select= "com.xdadan.erp.emis.mapper.EmisBaseMapper.selectEmpNameByCode" />
<association property= "confirmSiteName" column= "confirm_site_code" select= "com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode" />
2024-07-03 19:17:36 +00:00
</resultMap>
2024-08-09 10:15:28 +00:00
2024-09-26 14:36:05 +00:00
<resultMap type= "BillPayStatInfo" id= "BillPayStatInfoResult" >
<result property= "salesmen" column= "salesmen" />
<result property= "billMonth" column= "billMonth" />
<result property= "recPayMoney" column= "recPayMoney" />
<result property= "totalBillCount" column= "totalBillCount" />
<result property= "hasPayBillCount" column= "hasPayBillCount" />
<result property= "somePayBillCount" column= "somePayBillCount" />
<result property= "noPayBillCount" column= "noPayBillCount" />
<result property= "recdPayMoney" column= "recdPayMoney" />
<result property= "noRecdPayMoney" column= "noRecdPayMoney" />
<result property= "expiredRecdPayMoney" column= "expiredRecdPayMoney" />
<result property= "expiredNoRecdPayMoney" column= "expiredNoRecdPayMoney" />
<result property= "billPayRate" column= "billPayRate" />
<result property= "expireBillPayRate" column= "expireBillPayRate" />
<result property= "expireBillNoPayRate" column= "expireBillNoPayRate" />
2024-09-27 09:42:52 +00:00
</resultMap>
<resultMap type= "OpenBillStatInfo" id= "OpenBillStatInfoResult" >
<result property= "salesmen" column= "salesmen" />
<result property= "billMonth" column= "billMonth" />
<result property= "totalBillCount" column= "totalBillCount" />
<result property= "hasOpenBillCount" column= "hasOpenBillCount" />
<result property= "someOpenBillCount" column= "someOpenBillCount" />
<result property= "noOpenBillCount" column= "noOpenBillCount" />
<result property= "noNeedOpenBillCount" column= "noNeedOpenBillCount" />
<result property= "normalOpenBillCount" column= "normalOpenBillCount" />
<result property= "expiredOpenBillCount" column= "expiredOpenBillCount" />
<result property= "expiredNoOpenBillCount" column= "expiredNoOpenBillCount" />
<result property= "normalOpenBillRate" column= "normalOpenBillRate" />
<result property= "expireOpenBillRate" column= "expireOpenBillRate" />
2024-09-26 14:36:05 +00:00
</resultMap>
<select id= "selectBillPayStatInfoList" parameterType= "EmisSettleBill" resultMap= "BillPayStatInfoResult" >
select tba.salesmen,
tba.billMonth,
tba.recPayMoney,
tba.totalBillCount,
2024-09-26 22:19:39 +00:00
tba.hasRecdPayMoney,
tbb.hasPayBillCount,
tbb.somePayBillCount,
tbb.noPayBillCount,
2024-09-26 22:24:26 +00:00
ifnull(tbc.recdPayMoney,0) as recdPayMoney,
(tba.recPayMoney-ifnull(tbc.recdPayMoney,0)) as noRecdPayMoney,
ifnull(tbd.expiredRecdPayMoney,0) as expiredRecdPayMoney,
(tba.recPayMoney-ifnull(tbd.expiredRecdPayMoney,0)) as expiredNoRecdPayMoney
2024-09-26 14:36:05 +00:00
from (
select salesmen,bill_month as billMonth,
ROUND(sum(rec_money),2) as recPayMoney,
2024-09-27 09:42:52 +00:00
count(1) as totalBillCount,
2024-09-26 14:36:05 +00:00
ROUND(sum(reced_money),2) as hasRecdPayMoney
from emis_settle_bill a
<where >
a.del_flag='0'
2024-09-27 00:29:29 +00:00
<if test= "salesmen != null and salesmen!='' " > and a.salesmen = #{salesmen}</if>
2024-09-26 14:36:05 +00:00
<if test= "billMonth != null and billMonth!='' " > and a.bill_month = #{billMonth}</if>
<if test= "openBillStatus != null and openBillStatus != ''" > and a.open_bill_status = #{openBillStatus}</if>
<if test= "paymentStatus != null and paymentStatus != ''" > and a.payment_status = #{paymentStatus}</if>
<if test= "params.privSiteCode != null and params.privSiteCode != '88888'" >
and (
a.salesmen=#{params.privEmpName}
or a.payee=#{params.privEmpName}
or a.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>
group by salesmen,bill_month
) tba
2024-09-26 22:19:39 +00:00
left join (
select salesmen,bill_month as billMonth,
sum(IF(payment_status='1',1,0)) as hasPayBillCount,
sum(IF(payment_status='2',1,0)) as somePayBillCount,
sum(IF(payment_status='0',1,0)) as noPayBillCount
from emis_settle_bill a
<where >
a.del_flag='0'
2024-09-27 00:29:29 +00:00
<if test= "salesmen != null and salesmen!='' " > and a.salesmen = #{salesmen}</if>
2024-09-26 22:19:39 +00:00
<if test= "billMonth != null and billMonth!='' " > and a.bill_month = #{billMonth}</if>
<if test= "openBillStatus != null and openBillStatus != ''" > and a.open_bill_status = #{openBillStatus}</if>
<if test= "paymentStatus != null and paymentStatus != ''" > and a.payment_status = #{paymentStatus}</if>
<if test= "params.privSiteCode != null and params.privSiteCode != '88888'" >
and (
a.salesmen=#{params.privEmpName}
or a.payee=#{params.privEmpName}
or a.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>
group by salesmen,bill_month
) tbb on tba.salesmen=tbb.salesmen and tba.billMonth=tbb.billMonth
left join (
select a.salesmen,a.bill_month as billMonth,
sum(b.pay_money) as recdPayMoney
from emis_settle_bill a,emis_settle_pay_record b
<where >
a.del_flag='0' and b.del_flag='0' and a.settle_bill_no=b.settle_bill_no and b.create_time <![CDATA[ <= ]]> a.payment_due_date
2024-09-27 00:29:29 +00:00
<if test= "salesmen != null and salesmen!='' " > and a.salesmen = #{salesmen}</if>
2024-09-26 22:19:39 +00:00
<if test= "billMonth != null and billMonth!='' " > and a.bill_month = #{billMonth}</if>
<if test= "openBillStatus != null and openBillStatus != ''" > and a.open_bill_status = #{openBillStatus}</if>
<if test= "paymentStatus != null and paymentStatus != ''" > and a.payment_status = #{paymentStatus}</if>
<if test= "params.privSiteCode != null and params.privSiteCode != '88888'" >
and (
a.salesmen=#{params.privEmpName}
or a.payee=#{params.privEmpName}
or a.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>
group by salesmen,bill_month
) tbc on tba.salesmen=tbc.salesmen and tba.billMonth=tbc.billMonth
left join (
select a.salesmen,a.bill_month as billMonth,
sum(b.pay_money) as expiredRecdPayMoney
from emis_settle_bill a,emis_settle_pay_record b
<where >
a.del_flag='0' and b.del_flag='0' and a.settle_bill_no=b.settle_bill_no and b.create_time <![CDATA[ > ]]> a.payment_due_date
2024-09-27 00:29:29 +00:00
<if test= "salesmen != null and salesmen!='' " > and a.salesmen = #{salesmen}</if>
2024-09-26 22:19:39 +00:00
<if test= "billMonth != null and billMonth!='' " > and a.bill_month = #{billMonth}</if>
<if test= "openBillStatus != null and openBillStatus != ''" > and a.open_bill_status = #{openBillStatus}</if>
<if test= "paymentStatus != null and paymentStatus != ''" > and a.payment_status = #{paymentStatus}</if>
<if test= "params.privSiteCode != null and params.privSiteCode != '88888'" >
and (
a.salesmen=#{params.privEmpName}
or a.payee=#{params.privEmpName}
or a.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>
group by salesmen,bill_month
) tbd on tba.salesmen=tbd.salesmen and tba.billMonth=tbd.billMonth
2024-09-26 14:36:05 +00:00
</select>
2024-09-27 09:42:52 +00:00
<select id= "selectOpenBillStatInfoList" parameterType= "EmisSettleBill" resultMap= "OpenBillStatInfoResult" >
select tba.salesmen,
tba.billMonth,
tba.totalBillCount,
tbb.hasOpenBillCount,
tbb.someOpenBillCount,
tbb.noOpenBillCount,
tbb.noNeedOpenBillCount,
ifnull(tbc.normalOpenBillCount,0) as normalOpenBillCount,
ifnull(tbd.expiredOpenBillCount,0) as expiredOpenBillCount,
tbb.noOpenBillCount as expiredNoOpenBillCount
from (
select salesmen,bill_month as billMonth,
count(1) as totalBillCount
from emis_settle_bill a
<where >
a.del_flag='0'
<if test= "salesmen != null and salesmen!='' " > and a.salesmen = #{salesmen}</if>
<if test= "billMonth != null and billMonth!='' " > and a.bill_month = #{billMonth}</if>
<if test= "openBillStatus != null and openBillStatus != ''" > and a.open_bill_status = #{openBillStatus}</if>
<if test= "paymentStatus != null and paymentStatus != ''" > and a.payment_status = #{paymentStatus}</if>
<if test= "params.privSiteCode != null and params.privSiteCode != '88888'" >
and (
a.salesmen=#{params.privEmpName}
or a.payee=#{params.privEmpName}
or a.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>
group by salesmen,bill_month
) tba
left join (
select salesmen,bill_month as billMonth,
sum(IF(open_bill_status='1',1,0)) as hasOpenBillCount,
sum(IF(open_bill_status='2',1,0)) as someOpenBillCount,
sum(IF(open_bill_status='3',1,0)) as noNeedOpenBillCount,
sum(IF(open_bill_status='0',1,0)) as noOpenBillCount
from emis_settle_bill a
<where >
a.del_flag='0'
<if test= "salesmen != null and salesmen!='' " > and a.salesmen = #{salesmen}</if>
<if test= "billMonth != null and billMonth!='' " > and a.bill_month = #{billMonth}</if>
<if test= "openBillStatus != null and openBillStatus != ''" > and a.open_bill_status = #{openBillStatus}</if>
<if test= "paymentStatus != null and paymentStatus != ''" > and a.payment_status = #{paymentStatus}</if>
<if test= "params.privSiteCode != null and params.privSiteCode != '88888'" >
and (
a.salesmen=#{params.privEmpName}
or a.payee=#{params.privEmpName}
or a.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>
group by salesmen,bill_month
) tbb on tba.salesmen=tbb.salesmen and tba.billMonth=tbb.billMonth
left join (
select a.salesmen,a.bill_month as billMonth,
count(1) as normalOpenBillCount
from emis_settle_bill a,emis_settle_invoice_record b
<where >
a.del_flag='0' and b.del_flag='0' and FIND_IN_SET(a.settle_bill_no,b.settle_bill_no) and b.create_time <![CDATA[ <= ]]> a.payment_due_date
<if test= "salesmen != null and salesmen!='' " > and a.salesmen = #{salesmen}</if>
<if test= "billMonth != null and billMonth!='' " > and a.bill_month = #{billMonth}</if>
<if test= "openBillStatus != null and openBillStatus != ''" > and a.open_bill_status = #{openBillStatus}</if>
<if test= "paymentStatus != null and paymentStatus != ''" > and a.payment_status = #{paymentStatus}</if>
<if test= "params.privSiteCode != null and params.privSiteCode != '88888'" >
and (
a.salesmen=#{params.privEmpName}
or a.payee=#{params.privEmpName}
or a.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>
group by salesmen,bill_month
) tbc on tba.salesmen=tbc.salesmen and tba.billMonth=tbc.billMonth
left join (
select a.salesmen,a.bill_month as billMonth,
count(1) as expiredOpenBillCount
from emis_settle_bill a,emis_settle_invoice_record b
<where >
a.del_flag='0' and b.del_flag='0' and FIND_IN_SET(a.settle_bill_no,b.settle_bill_no) and b.create_time <![CDATA[ > ]]> a.payment_due_date
<if test= "salesmen != null and salesmen!='' " > and a.salesmen = #{salesmen}</if>
<if test= "billMonth != null and billMonth!='' " > and a.bill_month = #{billMonth}</if>
<if test= "openBillStatus != null and openBillStatus != ''" > and a.open_bill_status = #{openBillStatus}</if>
<if test= "paymentStatus != null and paymentStatus != ''" > and a.payment_status = #{paymentStatus}</if>
<if test= "params.privSiteCode != null and params.privSiteCode != '88888'" >
and (
a.salesmen=#{params.privEmpName}
or a.payee=#{params.privEmpName}
or a.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>
group by salesmen,bill_month
) tbd on tba.salesmen=tbd.salesmen and tba.billMonth=tbd.billMonth
</select>
2024-09-26 14:36:05 +00:00
2024-07-03 19:17:36 +00:00
<sql id= "selectEmisSettleBillVo" >
2024-09-03 01:19:55 +00:00
select id, settle_bill_no, settle_bill_name, settle_type, settle_start_date, settle_end_date, bill_month, rec_money, reced_money, invoiced_money, cust_no, cust_name, customer_code, customer_name, site_code, site_name, satisfy_money, allowance_money, deduction_money, other_money, satisfy_reason, allowance_reason, deduction_reason, other_reason, open_bill_status, payment_status, charge_status, send_piece_sum, piece_number, fee_weight, uncollected_amount, send_money_sum, refund_amount, refund_money, payee, salesmen, credit_period, credit_period_type, settle_day, payment_due_date, bl_send_oms, bl_confirm_center, confirm_center_date, confirm_center_note, confirm_center_man_code, confirm_center_code, bl_confirm_site, confirm_site_date, confirm_site_man_code, confirm_site_note, confirm_site_code, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_settle_bill a
2024-07-03 19:17:36 +00:00
</sql>
<select id= "selectEmisSettleBillList" parameterType= "EmisSettleBill" resultMap= "EmisSettleBillResult" >
<include refid= "selectEmisSettleBillVo" />
2024-07-09 22:42:16 +00:00
<where >
del_flag='0'
2024-07-03 19:17:36 +00:00
<if test= "id != null " > and id = #{id}</if>
2024-07-26 00:26:10 +00:00
<if test= "settleBillNo != null and settleBillNo != ''" > and FIND_IN_SET(a.`settle_bill_no`,#{settleBillNo})</if>
2024-07-03 19:17:36 +00:00
<if test= "settleBillName != null and settleBillName != ''" > and settle_bill_name like concat('%', #{settleBillName}, '%')</if>
2024-08-16 07:57:22 +00:00
<if test= "settleType != null and settleType != ''" > and settle_type= #{settleType}</if>
2024-07-03 19:17:36 +00:00
<if test= "settleStartDate != null " > and settle_start_date = #{settleStartDate}</if>
<if test= "settleEndDate != null " > and settle_end_date = #{settleEndDate}</if>
2024-07-09 22:42:16 +00:00
<if test= "billMonth != null and billMonth != ''" > and bill_month = #{billMonth}</if>
2024-07-03 19:17:36 +00:00
<if test= "recMoney != null " > and rec_money = #{recMoney}</if>
<if test= "recedMoney != null " > and reced_money = #{recedMoney}</if>
2024-07-09 22:42:16 +00:00
<if test= "custNo != null and custNo != ''" > and cust_no = #{custNo}</if>
2024-07-26 00:26:10 +00:00
<if test= "custName != null and custName != ''" > and cust_name like concat('%', #{custName}, '%')</if>
2024-07-09 22:42:16 +00:00
<if test= "customerCode != null and customerCode != ''" > and customer_code = #{customerCode}</if>
2024-07-03 19:17:36 +00:00
<if test= "customerName != null and customerName != ''" > and customer_name like concat('%', #{customerName}, '%')</if>
2024-07-09 22:42:16 +00:00
<if test= "siteCode != null and siteCode != ''" > and site_code = #{siteCode}</if>
2024-07-03 19:17:36 +00:00
<if test= "siteName != null and siteName != ''" > and site_name like concat('%', #{siteName}, '%')</if>
<if test= "satisfyMoney != null " > and satisfy_money = #{satisfyMoney}</if>
<if test= "allowanceMoney != null " > and allowance_money = #{allowanceMoney}</if>
<if test= "deductionMoney != null " > and deduction_money = #{deductionMoney}</if>
<if test= "otherMoney != null " > and other_money = #{otherMoney}</if>
2024-07-09 22:42:16 +00:00
<if test= "satisfyReason != null and satisfyReason != ''" > and satisfy_reason = #{satisfyReason}</if>
<if test= "allowanceReason != null and allowanceReason != ''" > and allowance_reason = #{allowanceReason}</if>
<if test= "deductionReason != null and deductionReason != ''" > and deduction_reason = #{deductionReason}</if>
<if test= "otherReason != null and otherReason != ''" > and other_reason = #{otherReason}</if>
<if test= "openBillStatus != null and openBillStatus != ''" > and open_bill_status = #{openBillStatus}</if>
<if test= "paymentStatus != null and paymentStatus != ''" > and payment_status = #{paymentStatus}</if>
<if test= "chargeStatus != null and chargeStatus != ''" > and charge_status = #{chargeStatus}</if>
2024-07-03 19:17:36 +00:00
<if test= "sendPieceSum != null " > and send_piece_sum = #{sendPieceSum}</if>
<if test= "pieceNumber != null " > and piece_number = #{pieceNumber}</if>
<if test= "feeWeight != null " > and fee_weight = #{feeWeight}</if>
<if test= "uncollectedAmount != null " > and uncollected_amount = #{uncollectedAmount}</if>
<if test= "sendMoneySum != null " > and send_money_sum = #{sendMoneySum}</if>
<if test= "refundAmount != null " > and refund_amount = #{refundAmount}</if>
<if test= "refundMoney != null " > and refund_money = #{refundMoney}</if>
2024-07-09 22:42:16 +00:00
<if test= "payee != null and payee != ''" > and payee = #{payee}</if>
<if test= "salesmen != null and salesmen != ''" > and salesmen = #{salesmen}</if>
<if test= "blSendOms != null and blSendOms != ''" > and bl_send_oms = #{blSendOms}</if>
<if test= "blConfirmCenter != null and blConfirmCenter != ''" > and bl_confirm_center = #{blConfirmCenter}</if>
<if test= "confirmCenterDate != null " > and confirm_center_date = #{confirmCenterDate}</if>
<if test= "confirmCenterNote != null and confirmCenterNote != ''" > and confirm_center_note = #{confirmCenterNote}</if>
<if test= "confirmCenterManCode != null and confirmCenterManCode != ''" > and confirm_center_man_code = #{confirmCenterManCode}</if>
<if test= "confirmCenterCode != null and confirmCenterCode != ''" > and confirm_center_code = #{confirmCenterCode}</if>
<if test= "blConfirmSite != null and blConfirmSite != ''" > and bl_confirm_site = #{blConfirmSite}</if>
<if test= "confirmSiteDate != null " > and confirm_site_date = #{confirmSiteDate}</if>
<if test= "confirmSiteManCode != null and confirmSiteManCode != ''" > and confirm_site_man_code = #{confirmSiteManCode}</if>
<if test= "confirmSiteNote != null and confirmSiteNote != ''" > and confirm_site_note like concat('%', #{confirmSiteNote}, '%')</if>
<if test= "confirmSiteCode != null and confirmSiteCode != ''" > and confirm_site_code = #{confirmSiteCode}</if>
2024-07-03 19:17:36 +00:00
<if test= "remark != null and remark != ''" > and remark like concat('%', #{remark}, '%')</if>
2024-07-09 22:42:16 +00:00
<if test= "delFlag != null and delFlag != ''" > and del_flag = #{delFlag}</if>
<if test= "createBy != null and createBy != ''" > and create_by = #{createBy}</if>
2024-07-03 19:17:36 +00:00
<if test= "createTime != null " > and create_time = #{createTime}</if>
2024-07-09 22:42:16 +00:00
<if test= "updateBy != null and updateBy != ''" > and update_by = #{updateBy}</if>
2024-07-03 19:17:36 +00:00
<if test= "updateTime != null " > and update_time = #{updateTime}</if>
2024-07-09 22:42:16 +00:00
<if test= "createSite != null and createSite != ''" > and create_site = #{createSite}</if>
<if test= "updateSite != null and updateSite != ''" > and update_site = #{updateSite}</if>
2024-07-26 00:26:10 +00:00
2024-09-02 22:11:17 +00:00
<if test= "creditPeriod != null " > and credit_period = #{creditPeriod}</if>
<if test= "creditPeriodType != null and creditPeriodType != ''" > and credit_period_type=#{creditPeriodType}</if>
<if test= "settleDay != null " > and settle_day = #{settleDay}</if>
<if test= "paymentDueDate != null " > and payment_due_date = #{paymentDueDate}</if>
2024-08-10 05:51:59 +00:00
<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>
2024-08-06 08:59:13 +00:00
<if test= "params.canOpenBill != null and params.canOpenBill == 1" >
and open_bill_status != '1'
</if>
2024-09-27 08:20:27 +00:00
<if test= "params.noPayBill != null and params.noPayBill == 1" >
and payment_status != '1'
</if>
2024-07-26 00:26:10 +00:00
<if test= "params.billCode != null and params.billCode != ''" >
and exists (
select 1 from emis_settle_sub_bill b
where a.settle_bill_no=b.settle_bill_no
and ( FIND_IN_SET(b.`bill_code`,#{params.billCode}) or b.bill_code like concat('%', #{params.billCode}, '%') )
)
</if>
2024-08-07 14:04:09 +00:00
2024-07-26 00:26:10 +00:00
<if test= "params.privSiteCode != null and params.privSiteCode != '88888'" >
2024-08-07 14:04:09 +00:00
and (
a.salesmen=#{params.privEmpName}
or a.payee=#{params.privEmpName}
or a.salesmen in(
2024-09-18 10:13:27 +00:00
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}
2024-08-07 14:04:09 +00:00
)
2024-07-26 00:26:10 +00:00
)
</if>
2024-07-03 19:17:36 +00:00
</where>
order by create_time desc
</select>
<select id= "checkUnique" parameterType= "EmisSettleBill" resultType= "int" >
2024-09-03 01:19:55 +00:00
select count(1) from emis_settle_bill a
2024-08-30 12:00:17 +00:00
where del_flag='0' and settle_bill_name = #{settleBillName} limit 1
2024-07-03 19:17:36 +00:00
</select>
2024-07-09 22:42:16 +00:00
2024-07-03 19:17:36 +00:00
<select id= "selectEmisSettleBillById" parameterType= "Long" resultMap= "EmisSettleBillResult" >
2024-09-02 22:11:17 +00:00
select id, settle_bill_no, settle_bill_name, settle_type, settle_start_date, settle_end_date, bill_month, rec_money, reced_money, invoiced_money, cust_no, cust_name, customer_code, customer_name, site_code, site_name, satisfy_money, allowance_money, deduction_money, other_money, satisfy_reason, allowance_reason, deduction_reason, other_reason, open_bill_status, payment_status, charge_status, send_piece_sum, piece_number, fee_weight, uncollected_amount, send_money_sum, refund_amount, refund_money, payee, salesmen, credit_period, credit_period_type, settle_day, payment_due_date, bl_send_oms, bl_confirm_center, confirm_center_date, confirm_center_note, confirm_center_man_code, confirm_center_code, bl_confirm_site, confirm_site_date, confirm_site_man_code, confirm_site_note, confirm_site_code, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
2024-07-03 19:17:36 +00:00
from emis_settle_bill a
where a.id = #{id}
</select>
2024-07-09 22:42:16 +00:00
2024-07-10 03:37:56 +00:00
<select id= "selectSettleBillBySettleBillNo" parameterType= "String" resultMap= "EmisSettleBillResult" >
2024-09-02 22:11:17 +00:00
select id, settle_bill_no, settle_bill_name, settle_type, settle_start_date, settle_end_date, bill_month, rec_money, reced_money, invoiced_money, cust_no, cust_name, customer_code, customer_name, site_code, site_name, satisfy_money, allowance_money, deduction_money, other_money, satisfy_reason, allowance_reason, deduction_reason, other_reason, open_bill_status, payment_status, charge_status, send_piece_sum, piece_number, fee_weight, uncollected_amount, send_money_sum, refund_amount, refund_money, payee, salesmen, credit_period, credit_period_type, settle_day, payment_due_date, bl_send_oms, bl_confirm_center, confirm_center_date, confirm_center_note, confirm_center_man_code, confirm_center_code, bl_confirm_site, confirm_site_date, confirm_site_man_code, confirm_site_note, confirm_site_code, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
2024-07-10 03:37:56 +00:00
from emis_settle_bill a
2024-07-26 00:26:10 +00:00
where a.settle_bill_no = #{settleBillNo} and del_flag='0'
2024-07-10 03:37:56 +00:00
</select>
2024-07-03 19:17:36 +00:00
<insert id= "insertEmisSettleBill" parameterType= "EmisSettleBill" useGeneratedKeys= "true" keyProperty= "id" >
insert into emis_settle_bill
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "settleBillNo != null and settleBillNo != ''" > settle_bill_no,</if>
<if test= "settleBillName != null and settleBillName != ''" > settle_bill_name,</if>
<if test= "settleType != null and settleType != ''" > settle_type,</if>
<if test= "settleStartDate != null" > settle_start_date,</if>
<if test= "settleEndDate != null" > settle_end_date,</if>
<if test= "billMonth != null and billMonth != ''" > bill_month,</if>
<if test= "recMoney != null" > rec_money,</if>
<if test= "recedMoney != null" > reced_money,</if>
2024-09-02 22:11:17 +00:00
<if test= "invoicedMoney != null" > invoiced_money,</if>
2024-07-03 19:17:36 +00:00
<if test= "custNo != null and custNo != ''" > cust_no,</if>
2024-07-26 00:26:10 +00:00
<if test= "custName != null and custName != ''" > cust_name,</if>
2024-07-03 19:17:36 +00:00
<if test= "customerCode != null and customerCode != ''" > customer_code,</if>
<if test= "customerName != null and customerName != ''" > customer_name,</if>
<if test= "siteCode != null and siteCode != ''" > site_code,</if>
<if test= "siteName != null and siteName != ''" > site_name,</if>
<if test= "satisfyMoney != null" > satisfy_money,</if>
<if test= "allowanceMoney != null" > allowance_money,</if>
<if test= "deductionMoney != null" > deduction_money,</if>
<if test= "otherMoney != null" > other_money,</if>
<if test= "satisfyReason != null and satisfyReason != ''" > satisfy_reason,</if>
<if test= "allowanceReason != null and allowanceReason != ''" > allowance_reason,</if>
<if test= "deductionReason != null and deductionReason != ''" > deduction_reason,</if>
<if test= "otherReason != null and otherReason != ''" > other_reason,</if>
<if test= "openBillStatus != null and openBillStatus != ''" > open_bill_status,</if>
<if test= "paymentStatus != null and paymentStatus != ''" > payment_status,</if>
2024-07-09 22:42:16 +00:00
<if test= "chargeStatus != null and chargeStatus != ''" > charge_status,</if>
2024-07-03 19:17:36 +00:00
<if test= "sendPieceSum != null" > send_piece_sum,</if>
<if test= "pieceNumber != null" > piece_number,</if>
<if test= "feeWeight != null" > fee_weight,</if>
<if test= "uncollectedAmount != null" > uncollected_amount,</if>
<if test= "sendMoneySum != null" > send_money_sum,</if>
<if test= "refundAmount != null" > refund_amount,</if>
<if test= "refundMoney != null" > refund_money,</if>
2024-07-09 22:42:16 +00:00
<if test= "payee != null and payee != ''" > payee,</if>
<if test= "salesmen != null and salesmen != ''" > salesmen,</if>
2024-09-02 22:11:17 +00:00
<if test= "creditPeriod != null" > credit_period,</if>
<if test= "creditPeriodType != null and creditPeriodType != ''" > credit_period_type,</if>
<if test= "settleDay != null" > settle_day,</if>
<if test= "paymentDueDate != null" > payment_due_date,</if>
2024-07-09 22:42:16 +00:00
<if test= "blSendOms != null and blSendOms != ''" > bl_send_oms,</if>
<if test= "blConfirmCenter != null and blConfirmCenter != ''" > bl_confirm_center,</if>
<if test= "confirmCenterDate != null" > confirm_center_date,</if>
<if test= "confirmCenterNote != null and confirmCenterNote != ''" > confirm_center_note,</if>
<if test= "confirmCenterManCode != null and confirmCenterManCode != ''" > confirm_center_man_code,</if>
<if test= "confirmCenterCode != null and confirmCenterCode != ''" > confirm_center_code,</if>
<if test= "blConfirmSite != null and blConfirmSite != ''" > bl_confirm_site,</if>
<if test= "confirmSiteDate != null" > confirm_site_date,</if>
<if test= "confirmSiteManCode != null and confirmSiteManCode != ''" > confirm_site_man_code,</if>
<if test= "confirmSiteNote != null and confirmSiteNote != ''" > confirm_site_note,</if>
<if test= "confirmSiteCode != null and confirmSiteCode != ''" > confirm_site_code,</if>
2024-07-03 19:17:36 +00:00
<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>
2024-07-09 22:42:16 +00:00
</trim>
2024-07-03 19:17:36 +00:00
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "settleBillNo != null and settleBillNo != ''" > #{settleBillNo},</if>
<if test= "settleBillName != null and settleBillName != ''" > #{settleBillName},</if>
<if test= "settleType != null and settleType != ''" > #{settleType},</if>
<if test= "settleStartDate != null" > #{settleStartDate},</if>
<if test= "settleEndDate != null" > #{settleEndDate},</if>
<if test= "billMonth != null and billMonth != ''" > #{billMonth},</if>
<if test= "recMoney != null" > #{recMoney},</if>
<if test= "recedMoney != null" > #{recedMoney},</if>
2024-09-02 22:11:17 +00:00
<if test= "invoicedMoney != null" > #{invoicedMoney},</if>
2024-07-03 19:17:36 +00:00
<if test= "custNo != null and custNo != ''" > #{custNo},</if>
2024-07-26 00:26:10 +00:00
<if test= "custName != null and custName != ''" > #{custName},</if>
2024-07-03 19:17:36 +00:00
<if test= "customerCode != null and customerCode != ''" > #{customerCode},</if>
<if test= "customerName != null and customerName != ''" > #{customerName},</if>
<if test= "siteCode != null and siteCode != ''" > #{siteCode},</if>
<if test= "siteName != null and siteName != ''" > #{siteName},</if>
<if test= "satisfyMoney != null" > #{satisfyMoney},</if>
<if test= "allowanceMoney != null" > #{allowanceMoney},</if>
<if test= "deductionMoney != null" > #{deductionMoney},</if>
<if test= "otherMoney != null" > #{otherMoney},</if>
<if test= "satisfyReason != null and satisfyReason != ''" > #{satisfyReason},</if>
<if test= "allowanceReason != null and allowanceReason != ''" > #{allowanceReason},</if>
<if test= "deductionReason != null and deductionReason != ''" > #{deductionReason},</if>
<if test= "otherReason != null and otherReason != ''" > #{otherReason},</if>
<if test= "openBillStatus != null and openBillStatus != ''" > #{openBillStatus},</if>
<if test= "paymentStatus != null and paymentStatus != ''" > #{paymentStatus},</if>
2024-07-09 22:42:16 +00:00
<if test= "chargeStatus != null and chargeStatus != ''" > #{chargeStatus},</if>
2024-07-03 19:17:36 +00:00
<if test= "sendPieceSum != null" > #{sendPieceSum},</if>
<if test= "pieceNumber != null" > #{pieceNumber},</if>
<if test= "feeWeight != null" > #{feeWeight},</if>
<if test= "uncollectedAmount != null" > #{uncollectedAmount},</if>
<if test= "sendMoneySum != null" > #{sendMoneySum},</if>
<if test= "refundAmount != null" > #{refundAmount},</if>
<if test= "refundMoney != null" > #{refundMoney},</if>
2024-07-09 22:42:16 +00:00
<if test= "payee != null and payee != ''" > #{payee},</if>
<if test= "salesmen != null and salesmen != ''" > #{salesmen},</if>
2024-09-02 22:11:17 +00:00
<if test= "creditPeriod != null" > #{creditPeriod},</if>
<if test= "creditPeriodType != null and creditPeriodType != ''" > #{creditPeriodType},</if>
<if test= "settleDay != null" > #{settleDay},</if>
<if test= "paymentDueDate != null" > #{paymentDueDate},</if>
2024-07-09 22:42:16 +00:00
<if test= "blSendOms != null and blSendOms != ''" > #{blSendOms},</if>
<if test= "blConfirmCenter != null and blConfirmCenter != ''" > #{blConfirmCenter},</if>
<if test= "confirmCenterDate != null" > #{confirmCenterDate},</if>
<if test= "confirmCenterNote != null and confirmCenterNote != ''" > #{confirmCenterNote},</if>
<if test= "confirmCenterManCode != null and confirmCenterManCode != ''" > #{confirmCenterManCode},</if>
<if test= "confirmCenterCode != null and confirmCenterCode != ''" > #{confirmCenterCode},</if>
<if test= "blConfirmSite != null and blConfirmSite != ''" > #{blConfirmSite},</if>
<if test= "confirmSiteDate != null" > #{confirmSiteDate},</if>
<if test= "confirmSiteManCode != null and confirmSiteManCode != ''" > #{confirmSiteManCode},</if>
<if test= "confirmSiteNote != null and confirmSiteNote != ''" > #{confirmSiteNote},</if>
<if test= "confirmSiteCode != null and confirmSiteCode != ''" > #{confirmSiteCode},</if>
2024-07-03 19:17:36 +00:00
<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>
2024-07-09 22:42:16 +00:00
</trim>
2024-07-03 19:17:36 +00:00
</insert>
<update id= "updateEmisSettleBill" parameterType= "EmisSettleBill" >
update emis_settle_bill
<trim prefix= "SET" suffixOverrides= "," >
<if test= "settleBillName != null and settleBillName != ''" > settle_bill_name = #{settleBillName},</if>
<if test= "settleType != null and settleType != ''" > settle_type = #{settleType},</if>
<if test= "settleStartDate != null" > settle_start_date = #{settleStartDate},</if>
<if test= "settleEndDate != null" > settle_end_date = #{settleEndDate},</if>
<if test= "billMonth != null and billMonth != ''" > bill_month = #{billMonth},</if>
<if test= "recMoney != null" > rec_money = #{recMoney},</if>
<if test= "recedMoney != null" > reced_money = #{recedMoney},</if>
2024-09-02 22:11:17 +00:00
<if test= "invoicedMoney != null" > invoiced_money = #{invoicedMoney},</if>
2024-07-03 19:17:36 +00:00
<if test= "custNo != null and custNo != ''" > cust_no = #{custNo},</if>
2024-07-26 00:26:10 +00:00
<if test= "custName != null and custName != ''" > cust_name = #{custName},</if>
2024-07-03 19:17:36 +00:00
<if test= "customerCode != null and customerCode != ''" > customer_code = #{customerCode},</if>
<if test= "customerName != null and customerName != ''" > customer_name = #{customerName},</if>
<if test= "siteCode != null and siteCode != ''" > site_code = #{siteCode},</if>
<if test= "siteName != null and siteName != ''" > site_name = #{siteName},</if>
<if test= "satisfyMoney != null" > satisfy_money = #{satisfyMoney},</if>
<if test= "allowanceMoney != null" > allowance_money = #{allowanceMoney},</if>
<if test= "deductionMoney != null" > deduction_money = #{deductionMoney},</if>
<if test= "otherMoney != null" > other_money = #{otherMoney},</if>
<if test= "satisfyReason != null and satisfyReason != ''" > satisfy_reason = #{satisfyReason},</if>
<if test= "allowanceReason != null and allowanceReason != ''" > allowance_reason = #{allowanceReason},</if>
<if test= "deductionReason != null and deductionReason != ''" > deduction_reason = #{deductionReason},</if>
<if test= "otherReason != null and otherReason != ''" > other_reason = #{otherReason},</if>
<if test= "openBillStatus != null and openBillStatus != ''" > open_bill_status = #{openBillStatus},</if>
<if test= "paymentStatus != null and paymentStatus != ''" > payment_status = #{paymentStatus},</if>
2024-07-09 22:42:16 +00:00
<if test= "chargeStatus != null and chargeStatus != ''" > charge_status = #{chargeStatus},</if>
2024-07-03 19:17:36 +00:00
<if test= "sendPieceSum != null" > send_piece_sum = #{sendPieceSum},</if>
<if test= "pieceNumber != null" > piece_number = #{pieceNumber},</if>
<if test= "feeWeight != null" > fee_weight = #{feeWeight},</if>
<if test= "uncollectedAmount != null" > uncollected_amount = #{uncollectedAmount},</if>
<if test= "sendMoneySum != null" > send_money_sum = #{sendMoneySum},</if>
<if test= "refundAmount != null" > refund_amount = #{refundAmount},</if>
<if test= "refundMoney != null" > refund_money = #{refundMoney},</if>
2024-07-09 22:42:16 +00:00
<if test= "payee != null and payee != ''" > payee = #{payee},</if>
<if test= "salesmen != null and salesmen != ''" > salesmen = #{salesmen},</if>
2024-09-02 22:11:17 +00:00
<if test= "creditPeriod != null" > credit_period = #{creditPeriod},</if>
<if test= "creditPeriodType != null and creditPeriodType != ''" > credit_period_type = #{creditPeriodType},</if>
<if test= "settleDay != null" > settle_day = #{settleDay},</if>
<if test= "paymentDueDate != null" > payment_due_date = #{paymentDueDate},</if>
2024-07-09 22:42:16 +00:00
<if test= "blSendOms != null and blSendOms != ''" > bl_send_oms = #{blSendOms},</if>
<if test= "blConfirmCenter != null and blConfirmCenter != ''" > bl_confirm_center = #{blConfirmCenter},</if>
<if test= "confirmCenterDate != null" > confirm_center_date = #{confirmCenterDate},</if>
<if test= "confirmCenterNote != null and confirmCenterNote != ''" > confirm_center_note = #{confirmCenterNote},</if>
<if test= "confirmCenterManCode != null and confirmCenterManCode != ''" > confirm_center_man_code = #{confirmCenterManCode},</if>
<if test= "confirmCenterCode != null and confirmCenterCode != ''" > confirm_center_code = #{confirmCenterCode},</if>
<if test= "blConfirmSite != null and blConfirmSite != ''" > bl_confirm_site = #{blConfirmSite},</if>
<if test= "confirmSiteDate != null" > confirm_site_date = #{confirmSiteDate},</if>
<if test= "confirmSiteManCode != null and confirmSiteManCode != ''" > confirm_site_man_code = #{confirmSiteManCode},</if>
<if test= "confirmSiteNote != null and confirmSiteNote != ''" > confirm_site_note = #{confirmSiteNote},</if>
<if test= "confirmSiteCode != null and confirmSiteCode != ''" > confirm_site_code = #{confirmSiteCode},</if>
2024-07-03 19:17:36 +00:00
<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= "deleteEmisSettleBillById" parameterType= "Long" >
2024-08-06 06:05:40 +00:00
update emis_settle_bill set del_flag='1' where id = #{id}
2024-07-03 19:17:36 +00:00
</delete>
<delete id= "deleteEmisSettleBillByIds" parameterType= "String" >
2024-08-06 06:05:40 +00:00
update emis_settle_bill set del_flag='1' where id in
2024-07-03 19:17:36 +00:00
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
</mapper>