2025-09-17 01:26:59 +00:00
<?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.EmisWriteoffApplyMapper" >
2025-09-18 03:48:35 +00:00
<resultMap type= "EmisWriteoffApply" id= "EmisWriteoffApplyResult" extends= "com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult" >
2025-09-17 01:26:59 +00:00
<result property= "id" column= "id" />
<result property= "applyNo" column= "apply_no" />
<result property= "applyManCode" column= "apply_man_code" />
<result property= "applyManName" column= "apply_man_name" />
<result property= "applySiteCode" column= "apply_site_code" />
<result property= "applySiteName" column= "apply_site_name" />
<result property= "applyDate" column= "apply_date" />
<result property= "writeoffAmount" column= "writeoff_amount" />
<result property= "payType" column= "pay_type" />
<result property= "tradeDate" column= "trade_date" />
<result property= "recipient" column= "recipient" />
<result property= "applyMemo" column= "apply_memo" />
2025-10-11 03:51:47 +00:00
<result property= "payId" column= "pay_id" />
2025-09-17 01:26:59 +00:00
<result property= "blCenterConfirmed" column= "bl_center_confirmed" />
<result property= "centerConfirmManCode" column= "center_confirm_man_code" />
<result property= "centerConfirmManName" column= "center_confirm_man_name" />
<result property= "centerConfirmDate" column= "center_confirm_date" />
<result property= "centerConfirmNote" column= "center_confirm_note" />
<result property= "centerRejectReason" column= "center_reject_reason" />
<result property= "blHeadquartersConfirmed" column= "bl_headquarters_confirmed" />
<result property= "headquartersConfirmManCode" column= "headquarters_confirm_man_code" />
<result property= "headquartersConfirmManName" column= "headquarters_confirm_man_name" />
<result property= "headquartersConfirmDate" column= "headquarters_confirm_date" />
<result property= "headquartersConfirmNote" column= "headquarters_confirm_note" />
<result property= "headquartersRejectReason" column= "headquarters_reject_reason" />
<result property= "revokeDate" column= "revoke_date" />
<result property= "revokeManCode" column= "revoke_man_code" />
<result property= "revokeManName" column= "revoke_man_name" />
<result property= "revokeReason" column= "revoke_reason" />
<!-- 关联明细列表 -->
<collection property= "detailList" ofType= "EmisWriteoffApplyDetail"
select="com.xdadan.erp.emis.mapper.EmisWriteoffApplyDetailMapper.selectEmisWriteoffApplyDetailListByApplyId"
column="id"/>
<!-- 关联图片列表 -->
<collection property= "imageList" ofType= "EmisWriteoffApplyImage"
select="com.xdadan.erp.emis.mapper.EmisWriteoffApplyImageMapper.selectEmisWriteoffApplyImageListByApplyId"
column="id"/>
</resultMap>
<sql id= "selectEmisWriteoffApplyVo" >
2025-10-11 03:51:47 +00:00
select id, apply_no, apply_man_code, apply_man_name, apply_site_code, apply_site_name, apply_date, writeoff_amount, pay_type, trade_date, recipient, apply_memo, pay_id, bl_center_confirmed, center_confirm_man_code, center_confirm_man_name, center_confirm_date, center_confirm_note, center_reject_reason, bl_headquarters_confirmed, headquarters_confirm_man_code, headquarters_confirm_man_name, headquarters_confirm_date, headquarters_confirm_note, headquarters_reject_reason, revoke_date, revoke_man_code, revoke_man_name, revoke_reason, del_flag, create_by, create_time, update_by, update_time, remark from emis_writeoff_apply
2025-09-17 01:26:59 +00:00
</sql>
<select id= "selectEmisWriteoffApplyList" parameterType= "EmisWriteoffApply" resultMap= "EmisWriteoffApplyResult" >
select distinct wa.id, wa.apply_no, wa.apply_man_code, wa.apply_man_name, wa.apply_site_code, wa.apply_site_name,
2025-10-11 03:51:47 +00:00
wa.apply_date, wa.writeoff_amount, wa.pay_type, wa.trade_date, wa.recipient, wa.apply_memo, wa.pay_id,
2025-09-17 01:26:59 +00:00
wa.bl_center_confirmed, wa.center_confirm_man_code, wa.center_confirm_man_name, wa.center_confirm_date,
wa.center_confirm_note, wa.center_reject_reason, wa.bl_headquarters_confirmed, wa.headquarters_confirm_man_code,
wa.headquarters_confirm_man_name, wa.headquarters_confirm_date, wa.headquarters_confirm_note,
wa.headquarters_reject_reason, wa.revoke_date, wa.revoke_man_code, wa.revoke_man_name, wa.revoke_reason,
2025-09-18 03:48:35 +00:00
wa.del_flag, wa.create_by, wa.create_time, wa.update_by, wa.update_time, wa.remark
2025-09-17 01:26:59 +00:00
from emis_writeoff_apply wa
<if test= "(params != null and params.queryParams != null and params.queryParams != '') or (settleBillName != null and settleBillName != '')" >
2025-09-18 03:20:54 +00:00
left join emis_writeoff_apply_detail wad on wa.id = wad.apply_id and wad.del_flag = '0'
2025-09-17 01:26:59 +00:00
</if>
<if test= "settleBillName != null and settleBillName != ''" >
2025-09-18 03:20:54 +00:00
left join emis_settle_bill sb on wad.settle_bill_no = sb.settle_bill_no and sb.del_flag = '0'
2025-09-17 01:26:59 +00:00
</if>
<where >
2025-09-18 03:48:35 +00:00
wa.del_flag = '0'
2025-09-17 01:26:59 +00:00
<if test= "applyNo != null and applyNo != ''" > and wa.apply_no = #{applyNo}</if>
<if test= "applyManCode != null and applyManCode != ''" > and wa.apply_man_code = #{applyManCode}</if>
<if test= "applyManName != null and applyManName != ''" > and wa.apply_man_name like concat('%', #{applyManName}, '%')</if>
<if test= "applySiteCode != null and applySiteCode != ''" > and wa.apply_site_code = #{applySiteCode}</if>
<if test= "applySiteName != null and applySiteName != ''" > and wa.apply_site_name like concat('%', #{applySiteName}, '%')</if>
<if test= "applyDate != null " > and wa.apply_date = #{applyDate}</if>
2025-09-17 05:16:12 +00:00
<if test= "applyDateStart != null " > and wa.apply_date > = #{applyDateStart}</if>
<if test= "applyDateEnd != null " > and wa.apply_date < = #{applyDateEnd}</if>
2025-09-17 01:26:59 +00:00
<if test= "writeoffAmount != null " > and wa.writeoff_amount = #{writeoffAmount}</if>
<if test= "applyMemo != null and applyMemo != ''" > and wa.apply_memo like concat('%', #{applyMemo}, '%')</if>
<if test= "blCenterConfirmed != null and blCenterConfirmed != ''" > and wa.bl_center_confirmed = #{blCenterConfirmed}</if>
<if test= "centerConfirmManCode != null and centerConfirmManCode != ''" > and wa.center_confirm_man_code = #{centerConfirmManCode}</if>
<if test= "centerConfirmManName != null and centerConfirmManName != ''" > and wa.center_confirm_man_name like concat('%', #{centerConfirmManName}, '%')</if>
<if test= "centerConfirmDate != null " > and wa.center_confirm_date = #{centerConfirmDate}</if>
<if test= "centerConfirmNote != null and centerConfirmNote != ''" > and wa.center_confirm_note like concat('%', #{centerConfirmNote}, '%')</if>
<if test= "centerRejectReason != null and centerRejectReason != ''" > and wa.center_reject_reason like concat('%', #{centerRejectReason}, '%')</if>
<if test= "blHeadquartersConfirmed != null and blHeadquartersConfirmed != ''" > and wa.bl_headquarters_confirmed = #{blHeadquartersConfirmed}</if>
<if test= "headquartersConfirmManCode != null and headquartersConfirmManCode != ''" > and wa.headquarters_confirm_man_code = #{headquartersConfirmManCode}</if>
<if test= "headquartersConfirmManName != null and headquartersConfirmManName != ''" > and wa.headquarters_confirm_man_name like concat('%', #{headquartersConfirmManName}, '%')</if>
<if test= "headquartersConfirmDate != null " > and wa.headquarters_confirm_date = #{headquartersConfirmDate}</if>
<if test= "headquartersConfirmNote != null and headquartersConfirmNote != ''" > and wa.headquarters_confirm_note like concat('%', #{headquartersConfirmNote}, '%')</if>
<if test= "headquartersRejectReason != null and headquartersRejectReason != ''" > and wa.headquarters_reject_reason like concat('%', #{headquartersRejectReason}, '%')</if>
<if test= "revokeDate != null " > and wa.revoke_date = #{revokeDate}</if>
<if test= "revokeManCode != null and revokeManCode != ''" > and wa.revoke_man_code = #{revokeManCode}</if>
<if test= "revokeManName != null and revokeManName != ''" > and wa.revoke_man_name like concat('%', #{revokeManName}, '%')</if>
<if test= "revokeReason != null and revokeReason != ''" > and wa.revoke_reason like concat('%', #{revokeReason}, '%')</if>
<if test= "settleBillName != null and settleBillName != ''" > and sb.settle_bill_name like concat('%', #{settleBillName}, '%')</if>
<if test= "params != null and params.queryParams != null and params.queryParams != ''" >
and (
wad.bill_code in
<foreach collection= "params.queryParams.split('\n')" item= "param" open= "(" separator= "," close= ")" >
#{param}
</foreach>
or wad.settle_bill_no in
<foreach collection= "params.queryParams.split('\n')" item= "param" open= "(" separator= "," close= ")" >
#{param}
</foreach>
)
</if>
</where>
order by wa.create_time desc
</select>
<select id= "selectEmisWriteoffApplyById" parameterType= "Long" resultMap= "EmisWriteoffApplyResult" >
<include refid= "selectEmisWriteoffApplyVo" />
where id = #{id}
</select>
<insert id= "insertEmisWriteoffApply" parameterType= "EmisWriteoffApply" useGeneratedKeys= "true" keyProperty= "id" >
insert into emis_writeoff_apply
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "applyNo != null and applyNo != ''" > apply_no,</if>
<if test= "applyManCode != null and applyManCode != ''" > apply_man_code,</if>
<if test= "applyManName != null and applyManName != ''" > apply_man_name,</if>
<if test= "applySiteCode != null and applySiteCode != ''" > apply_site_code,</if>
<if test= "applySiteName != null and applySiteName != ''" > apply_site_name,</if>
<if test= "applyDate != null" > apply_date,</if>
<if test= "writeoffAmount != null" > writeoff_amount,</if>
<if test= "payType != null and payType != ''" > pay_type,</if>
<if test= "tradeDate != null" > trade_date,</if>
<if test= "recipient != null and recipient != ''" > recipient,</if>
<if test= "applyMemo != null and applyMemo != ''" > apply_memo,</if>
2025-10-11 03:51:47 +00:00
<if test= "payId != null and payId != ''" > pay_id,</if>
2025-09-17 01:26:59 +00:00
<if test= "blCenterConfirmed != null and blCenterConfirmed != ''" > bl_center_confirmed,</if>
<if test= "centerConfirmManCode != null and centerConfirmManCode != ''" > center_confirm_man_code,</if>
<if test= "centerConfirmManName != null and centerConfirmManName != ''" > center_confirm_man_name,</if>
<if test= "centerConfirmDate != null" > center_confirm_date,</if>
<if test= "centerConfirmNote != null and centerConfirmNote != ''" > center_confirm_note,</if>
<if test= "centerRejectReason != null and centerRejectReason != ''" > center_reject_reason,</if>
<if test= "blHeadquartersConfirmed != null and blHeadquartersConfirmed != ''" > bl_headquarters_confirmed,</if>
<if test= "headquartersConfirmManCode != null and headquartersConfirmManCode != ''" > headquarters_confirm_man_code,</if>
<if test= "headquartersConfirmManName != null and headquartersConfirmManName != ''" > headquarters_confirm_man_name,</if>
<if test= "headquartersConfirmDate != null" > headquarters_confirm_date,</if>
<if test= "headquartersConfirmNote != null and headquartersConfirmNote != ''" > headquarters_confirm_note,</if>
<if test= "headquartersRejectReason != null and headquartersRejectReason != ''" > headquarters_reject_reason,</if>
<if test= "revokeDate != null" > revoke_date,</if>
<if test= "revokeManCode != null and revokeManCode != ''" > revoke_man_code,</if>
<if test= "revokeManName != null and revokeManName != ''" > revoke_man_name,</if>
<if test= "revokeReason != null and revokeReason != ''" > revoke_reason,</if>
2025-09-18 03:48:35 +00:00
<if test= "delFlag != null and delFlag != ''" > del_flag,</if>
2025-09-17 01:26:59 +00:00
<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= "remark != null and remark != ''" > remark,</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "applyNo != null and applyNo != ''" > #{applyNo},</if>
<if test= "applyManCode != null and applyManCode != ''" > #{applyManCode},</if>
<if test= "applyManName != null and applyManName != ''" > #{applyManName},</if>
<if test= "applySiteCode != null and applySiteCode != ''" > #{applySiteCode},</if>
<if test= "applySiteName != null and applySiteName != ''" > #{applySiteName},</if>
<if test= "applyDate != null" > #{applyDate},</if>
<if test= "writeoffAmount != null" > #{writeoffAmount},</if>
<if test= "payType != null and payType != ''" > #{payType},</if>
<if test= "tradeDate != null" > #{tradeDate},</if>
<if test= "recipient != null and recipient != ''" > #{recipient},</if>
<if test= "applyMemo != null and applyMemo != ''" > #{applyMemo},</if>
2025-10-11 03:51:47 +00:00
<if test= "payId != null and payId != ''" > #{payId},</if>
2025-09-17 01:26:59 +00:00
<if test= "blCenterConfirmed != null and blCenterConfirmed != ''" > #{blCenterConfirmed},</if>
<if test= "centerConfirmManCode != null and centerConfirmManCode != ''" > #{centerConfirmManCode},</if>
<if test= "centerConfirmManName != null and centerConfirmManName != ''" > #{centerConfirmManName},</if>
<if test= "centerConfirmDate != null" > #{centerConfirmDate},</if>
<if test= "centerConfirmNote != null and centerConfirmNote != ''" > #{centerConfirmNote},</if>
<if test= "centerRejectReason != null and centerRejectReason != ''" > #{centerRejectReason},</if>
<if test= "blHeadquartersConfirmed != null and blHeadquartersConfirmed != ''" > #{blHeadquartersConfirmed},</if>
<if test= "headquartersConfirmManCode != null and headquartersConfirmManCode != ''" > #{headquartersConfirmManCode},</if>
<if test= "headquartersConfirmManName != null and headquartersConfirmManName != ''" > #{headquartersConfirmManName},</if>
<if test= "headquartersConfirmDate != null" > #{headquartersConfirmDate},</if>
<if test= "headquartersConfirmNote != null and headquartersConfirmNote != ''" > #{headquartersConfirmNote},</if>
<if test= "headquartersRejectReason != null and headquartersRejectReason != ''" > #{headquartersRejectReason},</if>
<if test= "revokeDate != null" > #{revokeDate},</if>
<if test= "revokeManCode != null and revokeManCode != ''" > #{revokeManCode},</if>
<if test= "revokeManName != null and revokeManName != ''" > #{revokeManName},</if>
<if test= "revokeReason != null and revokeReason != ''" > #{revokeReason},</if>
2025-09-18 03:48:35 +00:00
<if test= "delFlag != null and delFlag != ''" > #{delFlag},</if>
2025-09-17 01:26:59 +00:00
<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= "remark != null and remark != ''" > #{remark},</if>
</trim>
</insert>
<update id= "updateEmisWriteoffApply" parameterType= "EmisWriteoffApply" >
update emis_writeoff_apply
<trim prefix= "SET" suffixOverrides= "," >
<if test= "applyNo != null and applyNo != ''" > apply_no = #{applyNo},</if>
<if test= "applyManCode != null and applyManCode != ''" > apply_man_code = #{applyManCode},</if>
<if test= "applyManName != null and applyManName != ''" > apply_man_name = #{applyManName},</if>
<if test= "applySiteCode != null and applySiteCode != ''" > apply_site_code = #{applySiteCode},</if>
<if test= "applySiteName != null and applySiteName != ''" > apply_site_name = #{applySiteName},</if>
<if test= "applyDate != null" > apply_date = #{applyDate},</if>
<if test= "writeoffAmount != null" > writeoff_amount = #{writeoffAmount},</if>
<if test= "applyMemo != null and applyMemo != ''" > apply_memo = #{applyMemo},</if>
2025-10-11 03:51:47 +00:00
<if test= "payId != null and payId != ''" > pay_id = #{payId},</if>
2025-09-17 01:26:59 +00:00
<if test= "blCenterConfirmed != null and blCenterConfirmed != ''" > bl_center_confirmed = #{blCenterConfirmed},</if>
<if test= "centerConfirmManCode != null and centerConfirmManCode != ''" > center_confirm_man_code = #{centerConfirmManCode},</if>
<if test= "centerConfirmManName != null and centerConfirmManName != ''" > center_confirm_man_name = #{centerConfirmManName},</if>
<if test= "centerConfirmDate != null" > center_confirm_date = #{centerConfirmDate},</if>
<if test= "centerConfirmNote != null and centerConfirmNote != ''" > center_confirm_note = #{centerConfirmNote},</if>
<if test= "centerRejectReason != null and centerRejectReason != ''" > center_reject_reason = #{centerRejectReason},</if>
<if test= "blHeadquartersConfirmed != null and blHeadquartersConfirmed != ''" > bl_headquarters_confirmed = #{blHeadquartersConfirmed},</if>
<if test= "headquartersConfirmManCode != null and headquartersConfirmManCode != ''" > headquarters_confirm_man_code = #{headquartersConfirmManCode},</if>
<if test= "headquartersConfirmManName != null and headquartersConfirmManName != ''" > headquarters_confirm_man_name = #{headquartersConfirmManName},</if>
<if test= "headquartersConfirmDate != null" > headquarters_confirm_date = #{headquartersConfirmDate},</if>
<if test= "headquartersConfirmNote != null and headquartersConfirmNote != ''" > headquarters_confirm_note = #{headquartersConfirmNote},</if>
<if test= "headquartersRejectReason != null and headquartersRejectReason != ''" > headquarters_reject_reason = #{headquartersRejectReason},</if>
<if test= "revokeDate != null" > revoke_date = #{revokeDate},</if>
<if test= "revokeManCode != null and revokeManCode != ''" > revoke_man_code = #{revokeManCode},</if>
<if test= "revokeManName != null and revokeManName != ''" > revoke_man_name = #{revokeManName},</if>
<if test= "revokeReason != null and revokeReason != ''" > revoke_reason = #{revokeReason},</if>
<if test= "salesmen != null and salesmen != ''" > salesmen = #{salesmen},</if>
<if test= "payee != null and payee != ''" > payee = #{payee},</if>
<if test= "updateBy != null and updateBy != ''" > update_by = #{updateBy},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
<if test= "remark != null and remark != ''" > remark = #{remark},</if>
</trim>
where id = #{id}
</update>
2025-09-18 03:48:35 +00:00
<update id= "deleteEmisWriteoffApplyById" parameterType= "Long" >
update emis_writeoff_apply set del_flag = '2' where id = #{id}
</update>
2025-09-17 01:26:59 +00:00
2025-09-18 03:48:35 +00:00
<update id= "deleteEmisWriteoffApplyByIds" parameterType= "String" >
update emis_writeoff_apply set del_flag = '2' where id in
2025-09-17 01:26:59 +00:00
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
2025-09-18 03:48:35 +00:00
</update>
2025-09-17 01:26:59 +00:00
<update id= "auditCenterPass" parameterType= "EmisWriteoffApply" >
update emis_writeoff_apply set
bl_center_confirmed = #{blCenterConfirmed},
center_confirm_man_code = #{centerConfirmManCode},
center_confirm_man_name = #{centerConfirmManName},
center_confirm_date = #{centerConfirmDate},
center_confirm_note = #{centerConfirmNote},
2025-10-11 03:51:47 +00:00
pay_id = #{payId},
2025-09-17 01:26:59 +00:00
update_by = #{updateBy},
update_time = #{updateTime}
where id = #{id}
</update>
<update id= "auditCenterReject" parameterType= "EmisWriteoffApply" >
update emis_writeoff_apply set
bl_center_confirmed = #{blCenterConfirmed},
center_confirm_man_code = #{centerConfirmManCode},
center_confirm_man_name = #{centerConfirmManName},
center_confirm_date = #{centerConfirmDate},
center_reject_reason = #{centerRejectReason},
update_by = #{updateBy},
update_time = #{updateTime}
where id = #{id}
</update>
<update id= "auditHeadquartersConfirm" parameterType= "EmisWriteoffApply" >
update emis_writeoff_apply set
bl_headquarters_confirmed = #{blHeadquartersConfirmed},
headquarters_confirm_man_code = #{headquartersConfirmManCode},
headquarters_confirm_man_name = #{headquartersConfirmManName},
headquarters_confirm_date = #{headquartersConfirmDate},
headquarters_confirm_note = #{headquartersConfirmNote},
update_by = #{updateBy},
update_time = #{updateTime}
where id = #{id}
</update>
<update id= "auditHeadquartersReject" parameterType= "EmisWriteoffApply" >
update emis_writeoff_apply set
bl_headquarters_confirmed = #{blHeadquartersConfirmed},
headquarters_confirm_man_code = #{headquartersConfirmManCode},
headquarters_confirm_man_name = #{headquartersConfirmManName},
headquarters_confirm_date = #{headquartersConfirmDate},
headquarters_reject_reason = #{headquartersRejectReason},
update_by = #{updateBy},
update_time = #{updateTime}
where id = #{id}
</update>
<update id= "revokeApply" parameterType= "EmisWriteoffApply" >
update emis_writeoff_apply set
bl_center_confirmed = #{blCenterConfirmed},
revoke_man_code = #{revokeManCode},
revoke_man_name = #{revokeManName},
revoke_date = #{revokeDate},
revoke_reason = #{revokeReason},
update_by = #{updateBy},
update_time = #{updateTime}
where id = #{id}
</update>
<update id= "reapply" parameterType= "EmisWriteoffApply" >
update emis_writeoff_apply set
bl_center_confirmed = #{blCenterConfirmed},
bl_headquarters_confirmed = #{blHeadquartersConfirmed},
center_confirm_man_code = null,
center_confirm_man_name = null,
center_confirm_date = null,
center_confirm_note = null,
center_reject_reason = null,
headquarters_confirm_man_code = null,
headquarters_confirm_man_name = null,
headquarters_confirm_date = null,
headquarters_confirm_note = null,
headquarters_reject_reason = null,
revoke_man_code = null,
revoke_man_name = null,
revoke_date = null,
revoke_reason = null,
update_by = #{updateBy},
update_time = #{updateTime}
where id = #{id}
</update>
<!-- 根据运单号查询运单、结算账单、结算子账单信息的ResultMap -->
<resultMap type= "EmisWriteoffApplyDetail" id= "EmisWriteoffApplyDetailWithDetailsResult" >
<id property= "id" column= "id" />
<result property= "applyId" column= "apply_id" />
<result property= "applyNo" column= "apply_no" />
<result property= "billCode" column= "bill_code" />
<result property= "applyMoney" column= "apply_money" />
<result property= "settleBillNo" column= "settle_bill_no" />
2025-09-18 02:43:01 +00:00
<result property= "expressType" column= "express_type" />
2025-09-17 01:26:59 +00:00
<result property= "createBy" column= "create_by" />
<result property= "createTime" column= "create_time" />
<result property= "updateBy" column= "update_by" />
<result property= "updateTime" column= "update_time" />
<result property= "remark" column= "remark" />
<!-- 关联运单信息 -->
<association property= "emisWaybill" javaType= "EmisWaybill" >
<result property= "id" column= "w_id" />
<result property= "orderSn" column= "w_order_sn" />
<result property= "custOrderId" column= "w_cust_order_id" />
<result property= "billCode" column= "w_bill_code" />
<result property= "billCodeSub" column= "w_bill_code_sub" />
<result property= "orderStatus" column= "w_order_status" />
<result property= "waybillStatus" column= "w_waybill_status" />
<result property= "orderType" column= "w_order_type" />
<result property= "orderDate" column= "w_order_date" />
<result property= "userId" column= "w_user_id" />
<result property= "customerCode" column= "w_customer_code" />
<result property= "customerName" column= "w_customer_name" />
<result property= "openId" column= "w_open_id" />
<result property= "receiveName" column= "w_receive_name" />
<result property= "receiveCompany" column= "w_receive_company" />
<result property= "receiveMobile" column= "w_receive_mobile" />
<result property= "receiveTel" column= "w_receive_tel" />
<result property= "receiveCountry" column= "w_receive_country" />
<result property= "receiveProvince" column= "w_receive_province" />
<result property= "receiveCity" column= "w_receive_city" />
<result property= "receiveAddress" column= "w_receive_address" />
<result property= "receivePostcode" column= "w_receive_postcode" />
<result property= "sendName" column= "w_send_name" />
<result property= "sendCompany" column= "w_send_company" />
<result property= "sendMobile" column= "w_send_mobile" />
<result property= "sendTel" column= "w_send_tel" />
<result property= "sendCountry" column= "w_send_country" />
<result property= "sendProvince" column= "w_send_province" />
<result property= "sendCity" column= "w_send_city" />
<result property= "sendAddress" column= "w_send_address" />
<result property= "sendPostcode" column= "w_send_postcode" />
<result property= "freight" column= "w_freight" />
<result property= "salesmen" column= "w_salesmen" />
<result property= "payee" column= "w_payee" />
<result property= "paymentType" column= "w_payment_type" />
2025-09-18 02:43:01 +00:00
<result property= "sendDate" column= "w_send_date" />
<result property= "productType" column= "w_product_type" />
<result property= "productTypeName" column= "w_product_type_name" />
<result property= "parcelQty" column= "w_parcel_qty" />
<result property= "settlementWeight" column= "w_settlement_weight" />
2025-09-17 01:26:59 +00:00
<result property= "createBy" column= "w_create_by" />
<result property= "createTime" column= "w_create_time" />
<result property= "updateBy" column= "w_update_by" />
<result property= "updateTime" column= "w_update_time" />
<result property= "remark" column= "w_remark" />
</association>
<!-- 关联结算账单信息 -->
<association property= "emisSettleBill" javaType= "EmisSettleBill" >
<result property= "id" column= "sb_id" />
<result property= "settleBillNo" column= "sb_settle_bill_no" />
<result property= "settleBillName" column= "sb_settle_bill_name" />
<result property= "settleType" column= "sb_settle_type" />
<result property= "settleStartDate" column= "sb_settle_start_date" />
<result property= "settleEndDate" column= "sb_settle_end_date" />
<result property= "billMonth" column= "sb_bill_month" />
<result property= "recMoney" column= "sb_rec_money" />
<result property= "recedMoney" column= "sb_reced_money" />
<result property= "invoicedMoney" column= "sb_invoiced_money" />
<result property= "custNo" column= "sb_cust_no" />
<result property= "custName" column= "sb_cust_name" />
<result property= "customerCode" column= "sb_customer_code" />
<result property= "customerName" column= "sb_customer_name" />
<result property= "siteCode" column= "sb_site_code" />
<result property= "siteName" column= "sb_site_name" />
<result property= "satisfyMoney" column= "sb_satisfy_money" />
<result property= "allowanceMoney" column= "sb_allowance_money" />
<result property= "deductionMoney" column= "sb_deduction_money" />
<result property= "otherMoney" column= "sb_other_money" />
<result property= "satisfyReason" column= "sb_satisfy_reason" />
<result property= "allowanceReason" column= "sb_allowance_reason" />
<result property= "deductionReason" column= "sb_deduction_reason" />
<result property= "otherReason" column= "sb_other_reason" />
<result property= "openBillStatus" column= "sb_open_bill_status" />
<result property= "paymentStatus" column= "sb_payment_status" />
<result property= "chargeStatus" column= "sb_charge_status" />
<result property= "sendPieceSum" column= "sb_send_piece_sum" />
<result property= "pieceNumber" column= "sb_piece_number" />
<result property= "feeWeight" column= "sb_fee_weight" />
<result property= "uncollectedAmount" column= "sb_uncollected_amount" />
<result property= "sendMoneySum" column= "sb_send_money_sum" />
<result property= "refundAmount" column= "sb_refund_amount" />
<result property= "refundMoney" column= "sb_refund_money" />
<result property= "payee" column= "sb_payee" />
<result property= "salesmen" column= "sb_salesmen" />
<result property= "creditPeriod" column= "sb_credit_period" />
2025-09-18 08:28:16 +00:00
<result property= "blConfirmCenter" column= "sb_bl_confirm_center" />
<result property= "blConfirmSite" column= "sb_bl_confirm_site" />
2025-09-17 01:26:59 +00:00
<result property= "createBy" column= "sb_create_by" />
<result property= "createTime" column= "sb_create_time" />
<result property= "updateBy" column= "sb_update_by" />
<result property= "updateTime" column= "sb_update_time" />
<result property= "remark" column= "sb_remark" />
</association>
<!-- 关联结算子账单信息 -->
<association property= "emisSettleSubBill" javaType= "EmisSettleSubBill" >
<result property= "id" column= "ssb_id" />
<result property= "billNo" column= "ssb_bill_no" />
<result property= "parentBillNo" column= "ssb_parent_bill_no" />
<result property= "settleBillNo" column= "ssb_settle_bill_no" />
<result property= "billCode" column= "ssb_bill_code" />
<result property= "billDate" column= "ssb_bill_date" />
<result property= "billFee" column= "ssb_bill_fee" />
<result property= "currency" column= "ssb_currency" />
<result property= "settleType" column= "ssb_settle_type" />
<result property= "blSplit" column= "ssb_bl_split" />
<result property= "blMerge" column= "ssb_bl_merge" />
<result property= "billMonth" column= "ssb_bill_month" />
<result property= "custNo" column= "ssb_cust_no" />
<result property= "custName" column= "ssb_cust_name" />
<result property= "customerCode" column= "ssb_customer_code" />
<result property= "customerName" column= "ssb_customer_name" />
<result property= "invoicedMoney" column= "ssb_invoiced_money" />
<result property= "recedMoney" column= "ssb_reced_money" />
<result property= "satisfyMoney" column= "ssb_satisfy_money" />
<result property= "allowanceMoney" column= "ssb_allowance_money" />
<result property= "deductionMoney" column= "ssb_deduction_money" />
<result property= "otherMoney" column= "ssb_other_money" />
<result property= "satisfyReason" column= "ssb_satisfy_reason" />
<result property= "allowanceReason" column= "ssb_allowance_reason" />
<result property= "deductionReason" column= "ssb_deduction_reason" />
<result property= "otherReason" column= "ssb_other_reason" />
2025-09-18 08:28:16 +00:00
<result property= "blConfirmCenter" column= "ssb_bl_confirm_center" />
<result property= "blConfirmSite" column= "ssb_bl_confirm_site" />
2025-09-17 01:26:59 +00:00
<result property= "createBy" column= "ssb_create_by" />
<result property= "createTime" column= "ssb_create_time" />
<result property= "updateBy" column= "ssb_update_by" />
<result property= "updateTime" column= "ssb_update_time" />
</association>
</resultMap>
<!-- 根据运单号查询运单、结算账单、结算子账单信息 -->
<select id= "selectEmisWriteoffApplyDetailListByBillCodes" parameterType= "java.util.List" resultMap= "EmisWriteoffApplyDetailWithDetailsResult" >
select distinct
-- EmisWriteoffApplyDetail 基本信息
w.bill_code as bill_code,
0.00 as apply_money,
ssb.settle_bill_no as settle_bill_no,
-- 运单信息
w.id as w_id, w.order_sn as w_order_sn, w.cust_order_id as w_cust_order_id, w.bill_code as w_bill_code,
w.bill_code_sub as w_bill_code_sub, w.order_status as w_order_status, w.waybill_status as w_waybill_status,
w.order_type as w_order_type, w.order_date as w_order_date, w.user_id as w_user_id, w.customer_code as w_customer_code,
w.customer_name as w_customer_name, w.open_id as w_open_id, w.receive_name as w_receive_name,
w.receive_company as w_receive_company, w.receive_mobile as w_receive_mobile, w.receive_tel as w_receive_tel,
w.receive_country as w_receive_country, w.receive_province as w_receive_province, w.receive_city as w_receive_city,
w.receive_address as w_receive_address, w.receive_postcode as w_receive_postcode, w.send_name as w_send_name,
w.send_company as w_send_company, w.send_mobile as w_send_mobile, w.send_tel as w_send_tel,
w.send_country as w_send_country, w.send_province as w_send_province, w.send_city as w_send_city,
w.send_address as w_send_address, w.send_postcode as w_send_postcode, w.freight as w_freight,
w.salesmen as w_salesmen, w.payee as w_payee, w.payment_type as w_payment_type, w.create_by as w_create_by,
w.create_time as w_create_time, w.update_by as w_update_by, w.update_time as w_update_time, w.remark as w_remark,
2025-09-18 02:43:01 +00:00
-- 新增运单字段:寄件日期、产品类型、件数、结算重量
w.send_date as w_send_date, w.product_type as w_product_type, w.parcel_qty as w_parcel_qty, w.settlement_weight as w_settlement_weight,
-- 快件类型(寄件网点-目的网点)
CONCAT(COALESCE(send_site.size_code2, ''), '-', COALESCE(dest_site.size_code2, '')) as express_type,tp.prod_name as w_product_type_name,
2025-09-17 01:26:59 +00:00
-- 结算账单信息
sb.id as sb_id, sb.settle_bill_no as sb_settle_bill_no, sb.settle_bill_name as sb_settle_bill_name,
sb.settle_type as sb_settle_type, sb.settle_start_date as sb_settle_start_date, sb.settle_end_date as sb_settle_end_date,
sb.bill_month as sb_bill_month, sb.rec_money as sb_rec_money, sb.reced_money as sb_reced_money,
sb.invoiced_money as sb_invoiced_money, sb.cust_no as sb_cust_no, sb.cust_name as sb_cust_name,
sb.customer_code as sb_customer_code, sb.customer_name as sb_customer_name, sb.site_code as sb_site_code,
sb.site_name as sb_site_name, sb.satisfy_money as sb_satisfy_money, sb.allowance_money as sb_allowance_money,
sb.deduction_money as sb_deduction_money, sb.other_money as sb_other_money, sb.satisfy_reason as sb_satisfy_reason,
sb.allowance_reason as sb_allowance_reason, sb.deduction_reason as sb_deduction_reason, sb.other_reason as sb_other_reason,
sb.open_bill_status as sb_open_bill_status, sb.payment_status as sb_payment_status, sb.charge_status as sb_charge_status,
sb.send_piece_sum as sb_send_piece_sum, sb.piece_number as sb_piece_number, sb.fee_weight as sb_fee_weight,
sb.uncollected_amount as sb_uncollected_amount, sb.send_money_sum as sb_send_money_sum, sb.refund_amount as sb_refund_amount,
2025-09-18 08:28:16 +00:00
sb.refund_money as sb_refund_money, sb.payee as sb_payee, sb.salesmen as sb_salesmen, sb.credit_period as sb_credit_period,
sb.bl_confirm_center as sb_bl_confirm_center, sb.bl_confirm_site as sb_bl_confirm_site,
2025-09-17 01:26:59 +00:00
sb.create_by as sb_create_by, sb.create_time as sb_create_time, sb.update_by as sb_update_by,
sb.update_time as sb_update_time, sb.remark as sb_remark,
-- 结算子账单信息
ssb.id as ssb_id, ssb.bill_no as ssb_bill_no, ssb.parent_bill_no as ssb_parent_bill_no,
ssb.settle_bill_no as ssb_settle_bill_no, ssb.bill_code as ssb_bill_code, ssb.bill_date as ssb_bill_date,
ssb.bill_fee as ssb_bill_fee, ssb.currency as ssb_currency, ssb.settle_type as ssb_settle_type,
ssb.bl_split as ssb_bl_split, ssb.bl_merge as ssb_bl_merge, ssb.bill_month as ssb_bill_month,
ssb.cust_no as ssb_cust_no, ssb.cust_name as ssb_cust_name, ssb.customer_code as ssb_customer_code,
ssb.customer_name as ssb_customer_name, ssb.invoiced_money as ssb_invoiced_money, ssb.reced_money as ssb_reced_money,
ssb.satisfy_money as ssb_satisfy_money, ssb.allowance_money as ssb_allowance_money, ssb.deduction_money as ssb_deduction_money,
2025-09-18 08:28:16 +00:00
ssb.other_money as ssb_other_money, ssb.satisfy_reason as ssb_satisfy_reason, ssb.allowance_reason as ssb_allowance_reason,
ssb.deduction_reason as ssb_deduction_reason, ssb.other_reason as ssb_other_reason,
ssb.bl_confirm_center as ssb_bl_confirm_center, ssb.bl_confirm_site as ssb_bl_confirm_site,
ssb.create_by as ssb_create_by, ssb.create_time as ssb_create_time, ssb.update_by as ssb_update_by,
ssb.update_time as ssb_update_time
2025-09-17 01:26:59 +00:00
from emis_waybill w
2025-09-18 03:20:54 +00:00
left join emis_settle_sub_bill ssb on w.bill_code = ssb.bill_code and ssb.del_flag = '0'
left join emis_settle_bill sb on ssb.settle_bill_no = sb.settle_bill_no and sb.del_flag = '0'
left join emis_site send_site on w.send_site_code = send_site.site_code and send_site.del_flag = '0'
left join emis_site dest_site on w.dispatch_underling_site_code = dest_site.site_code and dest_site.del_flag = '0'
left join emis_trans_product tp on w.product_type = tp.prod_code and tp.del_flag = '0'
where
w.del_flag = '0'
and w.bill_code in
2025-09-17 01:26:59 +00:00
<foreach collection= "list" item= "billCode" open= "(" separator= "," close= ")" >
#{billCode}
</foreach>
2025-09-18 03:20:54 +00:00
and w.order_status != '0'
and w.order_status != '2'
2025-09-17 01:26:59 +00:00
order by w.create_time desc
</select>
</mapper>