emis-service/emis-biz/src/main/resources/mapper/EmisSettleSubBillMapper.xml
2024-11-24 12:41:45 +08:00

1007 lines
58 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.EmisSettleSubBillMapper">
<resultMap type="EmisSettleSubBill" id="BaseEmisSettleSubBillResult" extends="com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult">
<result property="id" column="id" />
<result property="billNo" column="bill_no" />
<result property="parentBillNo" column="parent_bill_no" />
<result property="settleBillNo" column="settle_bill_no" />
<result property="billCode" column="bill_code" />
<result property="billDate" column="bill_date" />
<result property="billFee" column="bill_fee" />
<result property="currency" column="currency" />
<result property="settleType" column="settle_type" />
<result property="blSplit" column="bl_split" />
<result property="blMerge" column="bl_merge" />
<result property="billMonth" column="bill_month" />
<result property="custNo" column="cust_no" />
<result property="custName" column="cust_name" />
<result property="customerCode" column="customer_code" />
<result property="customerName" column="customer_name" />
<result property="invoicedMoney" column="invoiced_money" />
<result property="recedMoney" column="reced_money" />
<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" />
<result property="chargeStatus" column="charge_status" />
<result property="payee" column="payee" />
<result property="salesmen" column="salesmen" />
<result property="blSpecialQuote" column="bl_special_quote" />
<result property="blSensitive" column="bl_sensitive" />
<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" />
</resultMap>
<!--列表模式-->
<resultMap id="EmisSettleSubBillListResult" type="EmisSettleSubBill" extends="BaseEmisSettleSubBillResult" >
<association property="waybillDetail"
column="bill_code"
select="com.xdadan.erp.emis.mapper.EmisWaybillMapper.selectWaybillBaseInfoByBillCode"
fetchType="lazy"
/>
<association property="feeitemList"
column="bill_no"
select="com.xdadan.erp.emis.mapper.EmisSettleSubBillFeeitemMapper.selectFeeitemListBySubBillNo"
fetchType="lazy"
/>
<association property="confirmCenterManName" column="confirm_center_man_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectEmpNameByCode"/>
<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"/>
</resultMap>
<resultMap id="EmisSettleSubBillResult" type="EmisSettleSubBill" extends="BaseEmisSettleSubBillResult" >
<association property="waybillDetail"
column="bill_code"
select="com.xdadan.erp.emis.mapper.EmisWaybillMapper.selectWaybillBaseInfoByBillCode"
fetchType="lazy"
/>
<association property="feeitemList"
column="bill_no"
select="com.xdadan.erp.emis.mapper.EmisSettleSubBillFeeitemMapper.selectFeeitemListBySubBillNo"
fetchType="lazy"
/>
<association property="confirmCenterManName" column="confirm_center_man_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectEmpNameByCode"/>
<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"/>
</resultMap>
<sql id="selectEmisSettleSubBillVo">
select id, bill_no, parent_bill_no, settle_bill_no, bill_code, bill_date, bill_fee, currency, settle_type, bl_split, bl_merge, bill_month, cust_no, cust_name, customer_code, customer_name, invoiced_money, reced_money, satisfy_money, allowance_money, deduction_money, other_money, satisfy_reason, allowance_reason, deduction_reason, other_reason, open_bill_status, payment_status, charge_status, payee, salesmen, bl_special_quote, bl_sensitive, 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, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_settle_sub_bill
</sql>
<select id="selectEmisSettleSubBillList" parameterType="EmisSettleSubBill" resultMap="EmisSettleSubBillListResult">
select b.id, b.bill_no, b.parent_bill_no, b.settle_bill_no, b.bill_code, b.bill_date,
b.bill_fee, b.currency, b.settle_type, b.bl_split, b.bl_merge, b.bill_month, b.cust_no,b.cust_name,
b.customer_code, b.customer_name,
b.invoiced_money, b.reced_money,
b.satisfy_money, b.allowance_money, b.deduction_money, b.other_money,
b.satisfy_reason, b.allowance_reason, b.deduction_reason, b.other_reason,
b.open_bill_status, b.payment_status, b.charge_status,
b.payee, b.salesmen, b.bl_special_quote, b.bl_sensitive,
b.bl_confirm_center, b.confirm_center_date, b.confirm_center_note, b.confirm_center_man_code,
b.confirm_center_code, b.bl_confirm_site, b.confirm_site_date, b.confirm_site_man_code,
b.confirm_site_note, b.confirm_site_code, b.del_flag, b.create_by, b.create_time, b.update_by,
b.update_time, b.create_site, b.update_site,
a.bl_special_quote,a.calc_fee_type,a.send_date,a.send_company,
a.cust_no,a.cust_name,a.payment_type,a.time_type,
a.send_name,a.parcel_qty,a.bill_weight,a.total_volume,a.volume_weight,a.settlement_weight,
a.freight,real_fee,a.fee_remark,a.payment_type,a.remark,
a.payee,a.salesmen,a.bl_is_question,a.problem_cause,
j.prod_name as product_type_name,
k.line_name as trans_line_type_name,
l.site_name as send_site_name,
m.site_name as dispatch_underling_site_name,
z.type_name as problem_type_name
from emis_settle_sub_bill b ,emis_waybill a
left join emis_trans_product j on a.product_type=j.prod_code and j.del_flag='0'
left join emis_trans_line k on a.trans_line_type=k.line_code and k.del_flag='0'
left join emis_site l on a.send_site_code=l.site_code and l.del_flag=0 and l.del_flag='0'
left join emis_site m on a.dispatch_underling_site_code=m.site_code and m.del_flag=0
left join emis_problem_type z on a.problem_type=z.id and z.del_flag='0'
<where>
a.bill_code=b.bill_code and a.del_flag='0' and b.del_flag='0'
<if test="id != null "> and b.id = #{id}</if>
<if test="billNo != null and billNo != ''"> and FIND_IN_SET(b.`bill_no`,#{billNo}) </if>
<if test="parentBillNo != null and parentBillNo != ''"> and b.parent_bill_no=#{parentBillNo}</if>
<if test="settleBillNo != null and settleBillNo != ''"> and FIND_IN_SET(b.`settle_bill_no`,#{settleBillNo})</if>
<if test="billCode != null and billCode != ''"> and ( FIND_IN_SET(b.`bill_code`,#{billCode}) or b.bill_code like concat('%', #{billCode}, '%') ) </if>
<if test="billDate != null "> and bill_date = #{billDate}</if>
<if test="billFee != null "> and bill_fee = #{billFee}</if>
<if test="currency != null and currency != ''"> and currency= #{currency}</if>
<if test="settleType != null and settleType != ''"> and settle_type=#{settleType}</if>
<if test="blSplit != null and blSplit != ''"> and bl_split=#{blSplit}</if>
<if test="billMonth != null and billMonth != ''"> and bill_month=#{billMonth}</if>
<if test="custNo != null and custNo != ''"> and b.cust_no=#{custNo}</if>
<if test="custName != null and custName != ''"> and b.cust_name like concat('%', #{custName}, '%')</if>
<if test="customerCode != null and customerCode != ''"> and b.customer_code=#{customerCode}</if>
<if test="customerName != null and customerName != ''"> and b.customer_name like concat('%', #{customerName}, '%')</if>
<if test="blConfirmCenter != null and blConfirmCenter != ''"> and b.bl_confirm_center = #{blConfirmCenter}</if>
<if test="confirmCenterDate != null "> and b.confirm_center_date = #{confirmCenterDate}</if>
<if test="confirmCenterNote != null and confirmCenterNote != ''"> and b.confirm_center_note = #{confirmCenterNote}</if>
<if test="confirmCenterManCode != null and confirmCenterManCode != ''"> and b.confirm_center_man_code = #{confirmCenterManCode}</if>
<if test="confirmCenterCode != null and confirmCenterCode != ''"> and b.confirm_center_code = #{confirmCenterCode}</if>
<if test="blConfirmSite != null and blConfirmSite != ''"> and b.bl_confirm_site = #{blConfirmSite}</if>
<if test="confirmSiteDate != null "> and b.confirm_site_date = #{confirmSiteDate}</if>
<if test="confirmSiteManCode != null and confirmSiteManCode != ''"> and b.confirm_site_man_code = #{confirmSiteManCode}</if>
<if test="confirmSiteNote != null and confirmSiteNote != ''"> and b.confirm_site_note = #{confirmSiteNote}</if>
<if test="confirmSiteCode != null and confirmSiteCode != ''"> and b.confirm_site_code = #{confirmSiteCode}</if>
<!-- 过滤掉虚拟单 -->
and ( a.problem_type is null or (a.problem_type is not null and (a.problem_type != 173 and a.problem_type != 170 and a.problem_type != 151) ) )
<if test="params.sendSiteCode != null and params.sendSiteCode != ''">
and a.send_site_code = #{params.sendSiteCode}
</if>
<if test="params.dispatchUnderlingSiteCode != null and params.dispatchUnderlingSiteCode != ''">
and a.dispatch_underling_site_code = #{params.dispatchUnderlingSiteCode}
</if>
<if test="params.problemQueryType != null and params.problemQueryType == 1 and params.problemQueryIds != null and params.problemQueryIds !=''">
and a.bill_code in (
select bill_code from emis_waybill_problem_info ewpi where ewpi.del_flag='0' and FIND_IN_SET( ewpi.`problem_type`, #{params.problemQueryIds} )
)
</if>
<if test="params.problemQueryType != null and params.problemQueryType == 2 and params.problemQueryIds != null and params.problemQueryIds !=''">
and a.bill_code not in (
select bill_code from emis_waybill_problem_info ewpi where ewpi.del_flag='0' and FIND_IN_SET( ewpi.`problem_type`, #{params.problemQueryIds} )
)
</if>
<if test="params.receiveCompany != null and params.receiveCompany != ''">
and a.receive_company like concat('%', #{params.receiveCompany}, '%')
</if>
<if test="params.sendCompany != null and params.sendCompany != ''">
and a.send_company like concat('%', #{params.sendCompany}, '%')
</if>
<if test="blMerge != null and blMerge != ''"> and b.bl_merge=#{blMerge}</if>
<if test="paymentStatus != null and paymentStatus != ''">
and b.payment_status=#{paymentStatus}
</if>
<if test="openBillStatus != null and openBillStatus != ''">
and b.open_bill_status=#{openBillStatus}
</if>
<if test="params.mergeStatus != null and params.mergeStatus == 1">
and b.bl_merge='0'
and b.bl_confirm_center='1'
and b.bl_confirm_site='1'
</if>
<if test="params.mergeStatus != null and params.mergeStatus == 2">
and b.bl_merge='1'
and b.bl_confirm_center='1'
and b.bl_confirm_site='1'
</if>
<if test="params.transLineType != null and params.transLineType != ''">
and a.trans_line_type = #{params.transLineType}
</if>
<if test="params.productType != null and params.productType != ''">
and a.product_type = #{params.productType}
</if>
<if test="params.payee != null and params.payee != ''">
and a.payee = #{params.payee}
</if>
<if test="params.salesmen != null and params.salesmen != ''">
and a.salesmen = #{params.salesmen}
</if>
<if test="params.paymentType != null and params.paymentType != ''">
and a.payment_type = #{params.paymentType}
</if>
<if test="params.blSpecialQuote != null and params.blSpecialQuote != ''">
and a.bl_special_quote = #{params.blSpecialQuote}
</if>
<if test="params.calcFeeType != null and params.calcFeeType != ''">
and a.calc_fee_type = #{params.calcFeeType}
</if>
<if test="params.beginSendDate != null and params.beginSendDate != ''">
and a.send_date <![CDATA[ >= ]]> #{params.beginSendDate}
</if>
<if test="params.endSendDate != null and params.endSendDate != ''">
and a.send_date <![CDATA[ <= ]]> #{params.endSendDate}
</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != ''">
and b.create_time <![CDATA[ >= ]]> #{params.beginCreateTime}
</if>
<if test="params.endCreateTime != null and params.endCreateTime != ''">
and b.create_time <![CDATA[ <= ]]> #{params.endCreateTime}
</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>
order by b.create_time desc
</select>
<select id="getQueryStatInfoMap" parameterType="EmisSettleSubBill" resultType="map">
select
count(distinct a.bill_code) as totalNum,
round(sum(b.bill_fee),2) as totalBillFee
from emis_settle_sub_bill b ,emis_waybill a
<where>
a.bill_code=b.bill_code and a.del_flag='0' and b.del_flag='0'
<if test="id != null "> and b.id = #{id}</if>
<if test="billNo != null and billNo != ''"> and FIND_IN_SET(b.`bill_no`,#{billNo}) </if>
<if test="parentBillNo != null and parentBillNo != ''"> and b.parent_bill_no=#{parentBillNo}</if>
<if test="settleBillNo != null and settleBillNo != ''"> and FIND_IN_SET(b.`settle_bill_no`,#{settleBillNo})</if>
<if test="billCode != null and billCode != ''"> and ( FIND_IN_SET(b.`bill_code`,#{billCode}) or b.bill_code like concat('%', #{billCode}, '%') ) </if>
<if test="billDate != null "> and bill_date = #{billDate}</if>
<if test="billFee != null "> and bill_fee = #{billFee}</if>
<if test="currency != null and currency != ''"> and currency= #{currency}</if>
<if test="settleType != null and settleType != ''"> and settle_type=#{settleType}</if>
<if test="blSplit != null and blSplit != ''"> and bl_split=#{blSplit}</if>
<if test="billMonth != null and billMonth != ''"> and bill_month=#{billMonth}</if>
<if test="custNo != null and custNo != ''"> and b.cust_no=#{custNo}</if>
<if test="custName != null and custName != ''"> and b.cust_name like concat('%', #{custName}, '%')</if>
<if test="customerCode != null and customerCode != ''"> and b.customer_code=#{customerCode}</if>
<if test="customerName != null and customerName != ''"> and b.customer_name like concat('%', #{customerName}, '%')</if>
<if test="blConfirmCenter != null and blConfirmCenter != ''"> and b.bl_confirm_center = #{blConfirmCenter}</if>
<if test="confirmCenterDate != null "> and b.confirm_center_date = #{confirmCenterDate}</if>
<if test="confirmCenterNote != null and confirmCenterNote != ''"> and b.confirm_center_note = #{confirmCenterNote}</if>
<if test="confirmCenterManCode != null and confirmCenterManCode != ''"> and b.confirm_center_man_code = #{confirmCenterManCode}</if>
<if test="confirmCenterCode != null and confirmCenterCode != ''"> and b.confirm_center_code = #{confirmCenterCode}</if>
<if test="blConfirmSite != null and blConfirmSite != ''"> and b.bl_confirm_site = #{blConfirmSite}</if>
<if test="confirmSiteDate != null "> and b.confirm_site_date = #{confirmSiteDate}</if>
<if test="confirmSiteManCode != null and confirmSiteManCode != ''"> and b.confirm_site_man_code = #{confirmSiteManCode}</if>
<if test="confirmSiteNote != null and confirmSiteNote != ''"> and b.confirm_site_note = #{confirmSiteNote}</if>
<if test="confirmSiteCode != null and confirmSiteCode != ''"> and b.confirm_site_code = #{confirmSiteCode}</if>
<!-- 过滤掉虚拟单 -->
and ( a.problem_type is null or (a.problem_type is not null and (a.problem_type != 173 and a.problem_type != 170 and a.problem_type != 151) ) )
<if test="params.sendSiteCode != null and params.sendSiteCode != ''">
and a.send_site_code = #{params.sendSiteCode}
</if>
<if test="params.dispatchUnderlingSiteCode != null and params.dispatchUnderlingSiteCode != ''">
and a.dispatch_underling_site_code = #{params.dispatchUnderlingSiteCode}
</if>
<if test="params.problemQueryType != null and params.problemQueryType == 1 and params.problemQueryIds != null and params.problemQueryIds !=''">
and a.bill_code in (
select bill_code from emis_waybill_problem_info ewpi where ewpi.del_flag='0' and FIND_IN_SET( ewpi.`problem_type`, #{params.problemQueryIds} )
)
</if>
<if test="params.problemQueryType != null and params.problemQueryType == 2 and params.problemQueryIds != null and params.problemQueryIds !=''">
and a.bill_code not in (
select bill_code from emis_waybill_problem_info ewpi where ewpi.del_flag='0' and FIND_IN_SET( ewpi.`problem_type`, #{params.problemQueryIds} )
)
</if>
<if test="params.receiveCompany != null and params.receiveCompany != ''">
and a.receive_company like concat('%', #{params.receiveCompany}, '%')
</if>
<if test="params.sendCompany != null and params.sendCompany != ''">
and a.send_company like concat('%', #{params.sendCompany}, '%')
</if>
<if test="blMerge != null and blMerge != ''"> and b.bl_merge=#{blMerge}</if>
<if test="paymentStatus != null and paymentStatus != ''">
and b.payment_status=#{paymentStatus}
</if>
<if test="openBillStatus != null and openBillStatus != ''">
and b.open_bill_status=#{openBillStatus}
</if>
<if test="params.mergeStatus != null and params.mergeStatus == 1">
and b.bl_merge='0'
and b.bl_confirm_center='1'
and b.bl_confirm_site='1'
</if>
<if test="params.mergeStatus != null and params.mergeStatus == 2">
and b.bl_merge='1'
and b.bl_confirm_center='1'
and b.bl_confirm_site='1'
</if>
<if test="params.transLineType != null and params.transLineType != ''">
and a.trans_line_type = #{params.transLineType}
</if>
<if test="params.productType != null and params.productType != ''">
and a.product_type = #{params.productType}
</if>
<if test="params.payee != null and params.payee != ''">
and a.payee = #{params.payee}
</if>
<if test="params.salesmen != null and params.salesmen != ''">
and a.salesmen = #{params.salesmen}
</if>
<if test="params.paymentType != null and params.paymentType != ''">
and a.payment_type = #{params.paymentType}
</if>
<if test="params.blSpecialQuote != null and params.blSpecialQuote != ''">
and a.bl_special_quote = #{params.blSpecialQuote}
</if>
<if test="params.calcFeeType != null and params.calcFeeType != ''">
and a.calc_fee_type = #{params.calcFeeType}
</if>
<if test="params.beginSendDate != null and params.beginSendDate != ''">
and a.send_date <![CDATA[ >= ]]> #{params.beginSendDate}
</if>
<if test="params.endSendDate != null and params.endSendDate != ''">
and a.send_date <![CDATA[ <= ]]> #{params.endSendDate}
</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != ''">
and b.create_time <![CDATA[ >= ]]> #{params.beginCreateTime}
</if>
<if test="params.endCreateTime != null and params.endCreateTime != ''">
and b.create_time <![CDATA[ <= ]]> #{params.endCreateTime}
</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>
</select>
<select id="getNoNeedOpenBillSum" parameterType="String" resultType="map">
select
round(sum(bill_fee),2) as totalNoNeed,count(1) as totalCnt
from emis_settle_sub_bill
where del_flag='0' and open_bill_status='3' and invoiced_money=0 and `settle_bill_no`=#{settleBillNo}
</select>
<select id="getMonthBillStatInfoMapList" parameterType="EmisSettleSubBill" resultType="map">
select
count(a.bill_code) as totalNum,
round(sum(b.bill_fee),2) as totalBillFee,
b.cust_no as custNo,
max(b.cust_name) as custName,
sum(a.parcel_qty) as parcelQty,
sum(a.bill_weight) as totalBillWeight,
sum(a.total_volume) as totalVolume,
sum(a.volume_weight) as totalVolumeWeight,
sum(a.settlement_weight) as totalSettlementWeight,
sum(a.freight) as totalFreight
from emis_settle_sub_bill b ,emis_waybill a
<where>
a.bill_code=b.bill_code and a.del_flag='0' and b.del_flag='0'
and b.settle_type='2'
<if test="id != null "> and b.id = #{id}</if>
<if test="billNo != null and billNo != ''"> and FIND_IN_SET(b.`bill_no`,#{billNo}) </if>
<if test="parentBillNo != null and parentBillNo != ''"> and b.parent_bill_no=#{parentBillNo}</if>
<if test="settleBillNo != null and settleBillNo != ''"> and FIND_IN_SET(b.`settle_bill_no`,#{settleBillNo})</if>
<if test="billCode != null and billCode != ''"> and ( FIND_IN_SET(b.`bill_code`,#{billCode}) or b.bill_code like concat('%', #{billCode}, '%') ) </if>
<if test="billDate != null "> and bill_date = #{billDate}</if>
<if test="billFee != null "> and bill_fee = #{billFee}</if>
<if test="currency != null and currency != ''"> and currency= #{currency}</if>
<if test="settleType != null and settleType != ''"> and settle_type=#{settleType}</if>
<if test="blSplit != null and blSplit != ''"> and bl_split=#{blSplit}</if>
<if test="billMonth != null and billMonth != ''"> and bill_month=#{billMonth}</if>
<if test="custNo != null and custNo != ''"> and b.cust_no=#{custNo}</if>
<if test="custName != null and custName != ''"> and b.cust_name like concat('%', #{custName}, '%')</if>
<if test="customerCode != null and customerCode != ''"> and b.customer_code=#{customerCode}</if>
<if test="customerName != null and customerName != ''"> and b.customer_name like concat('%', #{customerName}, '%')</if>
<if test="blConfirmCenter != null and blConfirmCenter != ''"> and b.bl_confirm_center = #{blConfirmCenter}</if>
<if test="confirmCenterDate != null "> and b.confirm_center_date = #{confirmCenterDate}</if>
<if test="confirmCenterNote != null and confirmCenterNote != ''"> and b.confirm_center_note = #{confirmCenterNote}</if>
<if test="confirmCenterManCode != null and confirmCenterManCode != ''"> and b.confirm_center_man_code = #{confirmCenterManCode}</if>
<if test="confirmCenterCode != null and confirmCenterCode != ''"> and b.confirm_center_code = #{confirmCenterCode}</if>
<if test="blConfirmSite != null and blConfirmSite != ''"> and b.bl_confirm_site = #{blConfirmSite}</if>
<if test="confirmSiteDate != null "> and b.confirm_site_date = #{confirmSiteDate}</if>
<if test="confirmSiteManCode != null and confirmSiteManCode != ''"> and b.confirm_site_man_code = #{confirmSiteManCode}</if>
<if test="confirmSiteNote != null and confirmSiteNote != ''"> and b.confirm_site_note = #{confirmSiteNote}</if>
<if test="confirmSiteCode != null and confirmSiteCode != ''"> and b.confirm_site_code = #{confirmSiteCode}</if>
and ( a.problem_type is null or (a.problem_type is not null and (a.problem_type != 173 and a.problem_type != 170 and a.problem_type != 151) ) )
<if test="params.sendSiteCode != null and params.sendSiteCode != ''">
and a.send_site_code = #{params.sendSiteCode}
</if>
<if test="params.dispatchUnderlingSiteCode != null and params.dispatchUnderlingSiteCode != ''">
and a.dispatch_underling_site_code = #{params.dispatchUnderlingSiteCode}
</if>
<if test="blMerge != null and blMerge != ''"> and b.bl_merge=#{blMerge}</if>
<if test="paymentStatus != null and paymentStatus != ''">
and b.payment_status=#{paymentStatus}
</if>
<if test="openBillStatus != null and openBillStatus != ''">
and b.open_bill_status=#{openBillStatus}
</if>
<if test="params.mergeStatus != null and params.mergeStatus == 1">
and b.bl_merge='0'
and b.bl_confirm_center='1'
and b.bl_confirm_site='1'
</if>
<if test="params.mergeStatus != null and params.mergeStatus == 2">
and b.bl_merge='1'
and b.bl_confirm_center='1'
and b.bl_confirm_site='1'
</if>
<if test="params.payee != null and params.payee != ''">
and a.payee = #{params.payee}
</if>
<if test="params.salesmen != null and params.salesmen != ''">
and a.salesmen = #{params.salesmen}
</if>
<if test="params.paymentType != null and params.paymentType != ''">
and a.payment_type = #{params.paymentType}
</if>
<if test="params.blSpecialQuote != null and params.blSpecialQuote != ''">
and a.bl_special_quote = #{params.blSpecialQuote}
</if>
<if test="params.calcFeeType != null and params.calcFeeType != ''">
and a.calc_fee_type = #{params.calcFeeType}
</if>
<if test="params.beginSendDate != null and params.beginSendDate != ''">
and a.send_date <![CDATA[ >= ]]> #{params.beginSendDate}
</if>
<if test="params.endSendDate != null and params.endSendDate != ''">
and a.send_date <![CDATA[ <= ]]> #{params.endSendDate}
</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 b.cust_no
</select>
<select id="checkUnique" parameterType="EmisSettleSubBill" resultType="int">
select count(1) from emis_settle_sub_bill
where del_flag='0'
and id = #{id}
and bill_no = #{billNo}
and parent_bill_no = #{parentBillNo}
and settle_bill_no = #{settleBillNo}
and bill_code = #{billCode}
and bill_date = #{billDate}
and bill_fee = #{billFee}
and currency = #{currency}
and settle_type = #{settleType}
and bl_split = #{blSplit}
and bl_merge = #{blMerge}
and bill_month = #{billMonth}
and cust_no = #{custNo}
and customer_code = #{customerCode}
and customer_name = #{customerName}
and payee = #{payee}
and salesmen = #{salesmen}
and bl_special_quote = #{blSpecialQuote}
and bl_sensitive = #{blSensitive}
and bl_confirm_center = #{blConfirmCenter}
and confirm_center_date = #{confirmCenterDate}
and confirm_center_note = #{confirmCenterNote}
and confirm_center_man_code = #{confirmCenterManCode}
and confirm_center_code = #{confirmCenterCode}
and bl_confirm_site = #{blConfirmSite}
and confirm_site_date = #{confirmSiteDate}
and confirm_site_man_code = #{confirmSiteManCode}
and confirm_site_note = #{confirmSiteNote}
and confirm_site_code = #{confirmSiteCode}
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="selectEmisSettleSubBillById" parameterType="Long" resultMap="EmisSettleSubBillResult">
select id, bill_no, parent_bill_no, settle_bill_no, bill_code, bill_date, bill_fee, currency, settle_type, bl_split, bl_merge, bill_month, cust_no, cust_name, customer_code, customer_name, invoiced_money, reced_money, satisfy_money, allowance_money, deduction_money, other_money, satisfy_reason, allowance_reason, deduction_reason, other_reason, open_bill_status, payment_status, charge_status, payee, salesmen, bl_special_quote, bl_sensitive, 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, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_settle_sub_bill a
where a.id = #{id}
</select>
<select id="selectSettleSubBillListByBillCode" parameterType="String" resultMap="EmisSettleSubBillResult">
select id, bill_no, parent_bill_no, settle_bill_no, bill_code, bill_date, bill_fee, currency, settle_type, bl_split, bl_merge, bill_month, cust_no, cust_name, customer_code, customer_name, invoiced_money, reced_money, satisfy_money, allowance_money, deduction_money, other_money, satisfy_reason, allowance_reason, deduction_reason, other_reason, open_bill_status, payment_status, charge_status, payee, salesmen, bl_special_quote, bl_sensitive, 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, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_settle_sub_bill a
where a.del_flag='0' and a.bill_code = #{billCode}
</select>
<select id="selectSubBillListBySettleBillNo" parameterType="String" resultMap="EmisSettleSubBillResult">
select id, bill_no, parent_bill_no, settle_bill_no, bill_code, bill_date, bill_fee, currency, settle_type, bl_split, bl_merge, bill_month, cust_no, cust_name, customer_code, customer_name, invoiced_money, reced_money, satisfy_money, allowance_money, deduction_money, other_money, satisfy_reason, allowance_reason, deduction_reason, other_reason, open_bill_status, payment_status, charge_status, payee, salesmen, bl_special_quote, bl_sensitive, 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, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_settle_sub_bill a
where a.settle_bill_no = #{settleBillNo} and del_flag='0'
</select>
<select id="selectSettleSubBillBySubBillNo" parameterType="String" resultMap="EmisSettleSubBillResult">
select id, bill_no, parent_bill_no, settle_bill_no, bill_code, bill_date, bill_fee, currency, settle_type, bl_split, bl_merge, bill_month, cust_no, cust_name, customer_code, customer_name, invoiced_money, reced_money, satisfy_money, allowance_money, deduction_money, other_money, satisfy_reason, allowance_reason, deduction_reason, other_reason, open_bill_status, payment_status, charge_status, payee, salesmen, bl_special_quote, bl_sensitive, 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, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_settle_sub_bill a
where a.del_flag='0' and a.bill_no = #{subBillNo} limit 1
</select>
<insert id="insertEmisSettleSubBill" parameterType="EmisSettleSubBill" useGeneratedKeys="true" keyProperty="id">
insert into emis_settle_sub_bill
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="billNo != null and billNo != ''">bill_no,</if>
<if test="parentBillNo != null and parentBillNo != ''">parent_bill_no,</if>
<if test="settleBillNo != null and settleBillNo != ''">settle_bill_no,</if>
<if test="billCode != null and billCode != ''">bill_code,</if>
<if test="billDate != null">bill_date,</if>
<if test="billFee != null">bill_fee,</if>
<if test="currency != null and currency != ''">currency,</if>
<if test="settleType != null and settleType != ''">settle_type,</if>
<if test="blSplit != null and blSplit != ''">bl_split,</if>
<if test="blMerge != null and blMerge != ''">bl_merge,</if>
<if test="billMonth != null and billMonth != ''">bill_month,</if>
<if test="custNo != null and custNo != ''">cust_no,</if>
<if test="custName != null and custName != ''">cust_name,</if>
<if test="customerCode != null and customerCode != ''">customer_code,</if>
<if test="customerName != null and customerName != ''">customer_name,</if>
<if test="invoicedMoney != null">invoiced_money,</if>
<if test="recedMoney != null">reced_money,</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>
<if test="chargeStatus != null and chargeStatus != ''">charge_status,</if>
<if test="payee != null and payee != ''">payee,</if>
<if test="salesmen != null and salesmen != ''">salesmen,</if>
<if test="blSpecialQuote != null and blSpecialQuote != ''">bl_special_quote,</if>
<if test="blSensitive != null and blSensitive != ''">bl_sensitive,</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>
<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="billNo != null and billNo != ''">#{billNo},</if>
<if test="parentBillNo != null and parentBillNo != ''">#{parentBillNo},</if>
<if test="settleBillNo != null and settleBillNo != ''">#{settleBillNo},</if>
<if test="billCode != null and billCode != ''">#{billCode},</if>
<if test="billDate != null">#{billDate},</if>
<if test="billFee != null">#{billFee},</if>
<if test="currency != null and currency != ''">#{currency},</if>
<if test="settleType != null and settleType != ''">#{settleType},</if>
<if test="blSplit != null and blSplit != ''">#{blSplit},</if>
<if test="blMerge != null and blMerge != ''">#{blMerge},</if>
<if test="billMonth != null and billMonth != ''">#{billMonth},</if>
<if test="custNo != null and custNo != ''">#{custNo},</if>
<if test="custName != null and custName != ''">#{custName},</if>
<if test="customerCode != null and customerCode != ''">#{customerCode},</if>
<if test="customerName != null and customerName != ''">#{customerName},</if>
<if test="invoicedMoney != null">#{invoicedMoney},</if>
<if test="recedMoney != null">#{recedMoney},</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>
<if test="chargeStatus != null and chargeStatus != ''">#{chargeStatus},</if>
<if test="payee != null and payee != ''">#{payee},</if>
<if test="salesmen != null and salesmen != ''">#{salesmen},</if>
<if test="blSpecialQuote != null and blSpecialQuote != ''">#{blSpecialQuote},</if>
<if test="blSensitive != null and blSensitive != ''">#{blSensitive},</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>
<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="updateEmisSettleSubBill" parameterType="EmisSettleSubBill">
update emis_settle_sub_bill
<trim prefix="SET" suffixOverrides=",">
<if test="parentBillNo != null and parentBillNo != ''">parent_bill_no = #{parentBillNo},</if>
<if test="settleBillNo != null and settleBillNo != ''">settle_bill_no = #{settleBillNo},</if>
<if test="billCode != null and billCode != ''">bill_code = #{billCode},</if>
<if test="billDate != null">bill_date = #{billDate},</if>
<if test="billFee != null">bill_fee = #{billFee},</if>
<if test="currency != null and currency != ''">currency = #{currency},</if>
<if test="settleType != null and settleType != ''">settle_type = #{settleType},</if>
<if test="blSplit != null and blSplit != ''">bl_split = #{blSplit},</if>
<if test="blMerge != null and blMerge != ''">bl_merge = #{blMerge},</if>
<if test="billMonth != null and billMonth != ''">bill_month = #{billMonth},</if>
<if test="custNo != null and custNo != ''">cust_no = #{custNo},</if>
<if test="custName != null and custName != ''">cust_name = #{custName},</if>
<if test="customerCode != null and customerCode != ''">customer_code = #{customerCode},</if>
<if test="customerName != null and customerName != ''">customer_name = #{customerName},</if>
<if test="invoicedMoney != null">invoiced_money = #{invoicedMoney},</if>
<if test="recedMoney != null">reced_money = #{recedMoney},</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>
<if test="chargeStatus != null and chargeStatus != ''">charge_status = #{chargeStatus},</if>
<if test="payee != null and payee != ''">payee = #{payee},</if>
<if test="salesmen != null and salesmen != ''">salesmen = #{salesmen},</if>
<if test="blSpecialQuote != null and blSpecialQuote != ''">bl_special_quote = #{blSpecialQuote},</if>
<if test="blSensitive != null and blSensitive != ''">bl_sensitive = #{blSensitive},</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>
<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>
<!-- 更新合账单 -->
<update id="addToSettleBill" parameterType="EmisSettleSubBill">
update emis_settle_sub_bill
<trim prefix="SET" suffixOverrides=",">
settle_bill_no = #{settleBillNo},
bl_merge = '1',
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where id = #{id} and del_flag='0'
</update>
<!-- 更新合账单 -->
<update id="removeFromMainSettleBill" parameterType="EmisSettleSubBill">
update emis_settle_sub_bill
<trim prefix="SET" suffixOverrides=",">
settle_bill_no = null,
bl_merge = '0',
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where id = #{id} and del_flag='0'
</update>
<update id="batchUpdateMainSettleBillNo" parameterType="String">
update emis_settle_sub_bill
<trim prefix="SET" suffixOverrides=",">
settle_bill_no = #{settleBillNo},
bl_merge = '1',
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where del_flag='0' and id in
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<!-- 中心确认 -->
<update id="confirmBillByCenter" parameterType="EmisSettleSubBill">
update emis_settle_sub_bill
<trim prefix="SET" suffixOverrides=",">
bl_confirm_center = '1',
confirm_center_date = now(),
confirm_center_man_code = #{confirmCenterManCode},
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where id = #{id} and del_flag='0'
</update>
<!-- 中心取消确认 -->
<update id="cancelConfirmBillByCenter" parameterType="EmisSettleSubBill">
update emis_settle_sub_bill
<trim prefix="SET" suffixOverrides=",">
bl_confirm_center = '0',
confirm_center_date = null,
confirm_center_man_code =null,
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where id = #{id} and del_flag='0'
</update>
<!-- 中心确认不出账 2-->
<update id="confirmNoBillByCenter" parameterType="EmisSettleSubBill">
update emis_settle_sub_bill
<trim prefix="SET" suffixOverrides=",">
bl_confirm_center = '2',
confirm_center_date = now(),
confirm_center_man_code = #{confirmCenterManCode},
confirm_center_note = #{confirmCenterNote},
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where id = #{id} and del_flag='0'
</update>
<!-- 中心账单设置异常 3 -->
<update id="setBillErrorByCenter" parameterType="EmisSettleSubBill">
update emis_settle_sub_bill
<trim prefix="SET" suffixOverrides=",">
bl_confirm_center = '3',
confirm_center_date = now(),
confirm_center_man_code = #{confirmCenterManCode},
confirm_center_note = #{confirmCenterNote},
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where id = #{id} and del_flag='0'
</update>
<!-- 站点业务确认 -->
<update id="confirmBillBySite" parameterType="EmisSettleSubBill">
update emis_settle_sub_bill
<trim prefix="SET" suffixOverrides=",">
bl_confirm_site = '1',
confirm_site_date = now(),
confirm_site_code = #{confirmSiteCode},
confirm_site_man_code = #{confirmSiteManCode},
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where id = #{id} and del_flag='0'
</update>
<!-- 站点取消确认 -->
<update id="cancelConfirmBillBySite" parameterType="EmisSettleSubBill">
update emis_settle_sub_bill
<trim prefix="SET" suffixOverrides=",">
bl_confirm_site = '0',
confirm_site_date = null,
confirm_site_man_code =null,
confirm_site_code = null,
confirm_site_note = null,
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where id = #{id} and del_flag='0'
</update>
<!-- 站点确认不出账 2-->
<update id="confirmNoBillBySite" parameterType="EmisSettleSubBill">
update emis_settle_sub_bill
<trim prefix="SET" suffixOverrides=",">
bl_confirm_site = '2',
confirm_site_date = now(),
confirm_site_man_code = #{confirmSiteManCode},
confirm_site_code = #{confirmSiteCode},
confirm_site_note = #{confirmSiteNote},
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where id = #{id} and del_flag='0'
</update>
<!-- 站点账单设置异常 3 -->
<update id="setBillErrorBySite" parameterType="EmisSettleSubBill">
update emis_settle_sub_bill
<trim prefix="SET" suffixOverrides=",">
bl_confirm_site = '3',
confirm_site_date = now(),
confirm_site_man_code = #{confirmSiteManCode},
confirm_site_code = #{confirmSiteCode},
confirm_site_note = #{confirmSiteNote},
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
</trim>
where id = #{id} and del_flag='0'
</update>
<update id="updatePayedStatus" parameterType="EmisSettleSubBill">
update emis_settle_sub_bill
set payment_status=#{paymentStatus},reced_money=#{recedMoney}
where bill_code=#{billCode}
</update>
<update id="setNoNeedOpenBill" parameterType="EmisSettleSubBill">
update emis_settle_sub_bill
set open_bill_status='3'
where id=#{id}
</update>
<update id="setCompleteOpenBill" parameterType="EmisSettleSubBill">
update emis_settle_sub_bill
set open_bill_status='4'
where id=#{id}
</update>
<update id="updateOpenBillStatus" parameterType="EmisSettleSubBill">
update emis_settle_sub_bill
set open_bill_status=#{openBillStatus},invoiced_money=#{invoicedMoney}
where bill_code=#{billCode}
</update>
<delete id="deleteEmisSettleSubBillByBillCode" parameterType="String">
update emis_settle_sub_bill set del_flag='1' where bill_code = #{billCode} and del_flag='0'
</delete>
<delete id="deleteEmisSettleSubBillById" parameterType="Long">
update emis_settle_sub_bill set del_flag='1' where id = #{id}
</delete>
<delete id="deleteEmisSettleSubBillByIds" parameterType="String">
update emis_settle_sub_bill set del_flag='1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>