emis-service/emis-biz/src/main/resources/mapper/EmisCommissionDtlMapper.xml
2025-06-10 14:45:55 +08:00

378 lines
26 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.EmisCommissionDtlMapper">
<resultMap type="EmisCommissionDtl" id="BaseEmisCommissionDtlResult">
<result property="id" column="id" />
<result property="feeType" column="fee_type" />
<result property="money" column="money" />
<result property="billMonth" column="bill_month" />
<result property="billType" column="bill_type" />
<result property="billCode" column="bill_code" />
<result property="quoteId" column="quote_id" />
<result property="quoteName" column="quote_name" />
<result property="exprId" column="expr_id" />
<result property="calcExpr" column="calc_expr" />
<result property="feeRemark" column="fee_remark" />
<result property="empCode" column="emp_code" />
<result property="empName" column="emp_name" />
<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="EmisCommissionDtlResult" type="EmisCommissionDtl" extends="BaseEmisCommissionDtlResult" >
<association property="waybillDetail"
column="bill_code"
select="com.xdadan.erp.emis.mapper.EmisWaybillMapper.selectWaybillBaseInfoByBillCode"
fetchType="lazy"
/>
</resultMap>
<resultMap id="EmisBatchCommissionDtlResult" type="EmisCommissionDtl" extends="BaseEmisCommissionDtlResult" >
<association property="batchDetail"
column="bill_code"
select="com.xdadan.erp.emis.mapper.EmisTmsSiteBatchMapper.selectTmsSiteBatchByBatchNo"
fetchType="lazy"
/>
</resultMap>
<sql id="selectEmisCommissionDtlVo">
select id, fee_type, money, bill_month, bill_type, bill_code, quote_id, quote_name, expr_id, calc_expr, fee_remark, emp_code, emp_name, 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_commission_dtl
</sql>
<select id="selectEmisCommissionDtlList" parameterType="EmisCommissionDtl" resultMap="EmisCommissionDtlResult">
<include refid="selectEmisCommissionDtlVo"/>
<where>
del_flag='0' and bill_type='1'
<if test="id != null "> and id = #{id}</if>
<if test="feeType != null and feeType != ''"> and fee_type=#{feeType}</if>
<if test="money != null "> and money = #{money}</if>
<if test="billMonth != null and billMonth != ''"> and bill_month=#{billMonth} </if>
<if test="billCode != null and billCode != ''"> and ( FIND_IN_SET(bill_code,#{billCode}) or bill_code like concat('%', #{billCode}, '%') )</if>
<if test="feeRemark != null and feeRemark != ''"> and fee_remark like concat('%', #{feeRemark}, '%')</if>
<if test="empCode != null and empCode != ''"> and emp_code=#{empCode}</if>
<if test="empName != null and empName != ''"> and emp_name=#{empName}</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 like concat('%', #{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>
<if test="remark != null and remark != ''"> and remark like concat('%', #{remark}, '%')</if>
<if test="delFlag != null and delFlag != ''"> and del_flag like concat('%', #{delFlag}, '%')</if>
<if test="createBy != null and createBy != ''"> and create_by like concat('%', #{createBy}, '%')</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and update_by like concat('%', #{updateBy}, '%')</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
<if test="createSite != null and createSite != ''"> and create_site like concat('%', #{createSite}, '%')</if>
<if test="updateSite != null and updateSite != ''"> and update_site like concat('%', #{updateSite}, '%')</if>
</where>
order by create_time desc
</select>
<select id="selectCommissionDtlMapList" parameterType="EmisCommissionDtl" resultType="map">
SELECT
a.id,
a.fee_type AS feeType,
a.money,
a.bill_month AS billMonth,
a.bill_type AS billType,
a.bill_code AS billCode,
a.quote_id AS quoteId,
a.quote_name AS quoteName,
a.expr_id AS exprId,
a.calc_expr AS calcExpr,
a.fee_remark AS feeRemark,
a.emp_code AS empCode,
a.emp_name AS empName,
a.remark,
a.del_flag AS delFlag,
a.create_time AS createTime,
b.payment_type AS paymentType,
b.send_date AS sendDate,
b.send_company AS sendCompany,
b.time_type AS timeType,
b.send_name AS sendName,
b.parcel_qty AS parcelQty,
b.bill_weight AS billWeight,
b.total_volume AS totalVolume,
b.volume_weight AS volumeWeight,
b.settlement_weight AS settlementWeight,
b.real_fee AS realFee,
b.freight,
b.payment_status AS paymentStatus,
b.fee_remark AS waybillFeeRemark,
b.remark as waybillRemark,
b.cust_name as custName,
b.payee,
b.salesmen,
c.site_name AS sendSiteName,
d.site_name AS dispatchUnderlingSiteName,
e.NAME AS sendCountryName,
f.NAME AS receiveCountryName,
g.line_name AS transLineTypeName,
h.prod_name AS productTypeName
FROM
emis_commission_dtl a,
emis_waybill b
LEFT JOIN emis_site c ON b.send_site_code = c.site_code AND c.del_flag = '0'
LEFT JOIN emis_site d ON b.destination_center_code = d.site_code AND d.del_flag = '0'
LEFT JOIN emis_country e ON b.send_country = e.CODE AND e.del_flag = '0'
LEFT JOIN emis_country f ON b.receive_country = f.CODE AND f.del_flag = '0'
LEFT JOIN emis_trans_line g ON b.trans_line_type = g.line_code AND g.del_flag = '0'
LEFT JOIN emis_trans_product h ON b.product_type = h.prod_code AND h.del_flag = '0'
<where>
a.del_flag='0' and a.bill_code=b.bill_code and bill_type='1'
<if test="id != null "> and a.id = #{id}</if>
<if test="feeType != null and feeType != ''"> and a.fee_type=#{feeType}</if>
<if test="money != null "> and a.money = #{money}</if>
<if test="billMonth != null and billMonth != ''"> and a.bill_month=#{billMonth} </if>
<if test="billCode != null and billCode != ''"> and ( FIND_IN_SET(a.bill_code,#{billCode}) or a.bill_code like concat('%', #{billCode}, '%') )</if>
<if test="feeRemark != null and feeRemark != ''"> and a.fee_remark like concat('%', #{feeRemark}, '%')</if>
<if test="empCode != null and empCode != ''"> and a.emp_code=#{empCode}</if>
<if test="empName != null and empName != ''"> and a.emp_name=#{empName}</if>
<if test="blConfirmCenter != null and blConfirmCenter != ''"> and a.bl_confirm_center=#{blConfirmCenter}</if>
<if test="confirmCenterDate != null "> and a.confirm_center_date = #{confirmCenterDate}</if>
<if test="confirmCenterNote != null and confirmCenterNote != ''"> and a.confirm_center_note like concat('%', #{confirmCenterNote}, '%')</if>
<if test="confirmCenterManCode != null and confirmCenterManCode != ''"> and a.confirm_center_man_code= #{confirmCenterManCode}</if>
<if test="confirmCenterCode != null and confirmCenterCode != ''"> and a.confirm_center_code=#{confirmCenterCode}</if>
<if test="blConfirmSite != null and blConfirmSite != ''"> and a.bl_confirm_site=#{blConfirmSite}</if>
<if test="confirmSiteDate != null "> and a.confirm_site_date = #{confirmSiteDate}</if>
<if test="confirmSiteManCode != null and confirmSiteManCode != ''"> and a.confirm_site_man_code=#{confirmSiteManCode}</if>
<if test="confirmSiteNote != null and confirmSiteNote != ''"> and a.confirm_site_note like concat('%', #{confirmSiteNote}, '%')</if>
<if test="confirmSiteCode != null and confirmSiteCode != ''"> and a.confirm_site_code=#{confirmSiteCode}</if>
<if test="remark != null and remark != ''"> and a.remark like concat('%', #{remark}, '%')</if>
<if test="delFlag != null and delFlag != ''"> and a.del_flag like concat('%', #{delFlag}, '%')</if>
<if test="createBy != null and createBy != ''"> and a.create_by like concat('%', #{createBy}, '%')</if>
<if test="createTime != null "> and a.create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and a.update_by like concat('%', #{updateBy}, '%')</if>
<if test="updateTime != null "> and a.update_time = #{updateTime}</if>
<if test="createSite != null and createSite != ''"> and a.create_site like concat('%', #{createSite}, '%')</if>
<if test="updateSite != null and updateSite != ''"> and a.update_site like concat('%', #{updateSite}, '%')</if>
<if test="params.beginSendDate != null and params.beginSendDate != ''">
and b.send_date <![CDATA[ >= ]]> #{params.beginSendDate}
</if>
<if test="params.endSendDate != null and params.endSendDate != ''">
and b.send_date <![CDATA[ <= ]]> #{params.endSendDate}
</if>
</where>
order by a.create_time desc
</select>
<select id="selectBatchCommissionDtlList" parameterType="EmisCommissionDtl" resultMap="EmisBatchCommissionDtlResult">
<include refid="selectEmisCommissionDtlVo"/>
<where>
del_flag='0' and bill_type='2'
<if test="id != null "> and id = #{id}</if>
<if test="feeType != null and feeType != ''"> and fee_type=#{feeType}</if>
<if test="money != null "> and money = #{money}</if>
<if test="billMonth != null and billMonth != ''"> and bill_month=#{billMonth} </if>
<if test="billCode != null and billCode != ''"> and ( FIND_IN_SET(bill_code,#{billCode}) or bill_code like concat('%', #{billCode}, '%') )</if>
<if test="feeRemark != null and feeRemark != ''"> and fee_remark like concat('%', #{feeRemark}, '%')</if>
<if test="empCode != null and empCode != ''"> and emp_code=#{empCode}</if>
<if test="empName != null and empName != ''"> and emp_name=#{empName}</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 like concat('%', #{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>
<if test="remark != null and remark != ''"> and remark like concat('%', #{remark}, '%')</if>
<if test="delFlag != null and delFlag != ''"> and del_flag like concat('%', #{delFlag}, '%')</if>
<if test="createBy != null and createBy != ''"> and create_by like concat('%', #{createBy}, '%')</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and update_by like concat('%', #{updateBy}, '%')</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
<if test="createSite != null and createSite != ''"> and create_site like concat('%', #{createSite}, '%')</if>
<if test="updateSite != null and updateSite != ''"> and update_site like concat('%', #{updateSite}, '%')</if>
</where>
order by create_time desc
</select>
<select id="checkUnique" parameterType="EmisCommissionDtl" resultType="int">
select count(1) from emis_commission_dtl
where del_flag='0'
and id = #{id}
and fee_type = #{feeType}
and money = #{money}
and bill_month = #{billMonth}
and bill_code = #{billCode}
and fee_remark = #{feeRemark}
and emp_code = #{empCode}
and emp_name = #{empName}
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 remark = #{remark}
and del_flag = #{delFlag}
and create_by = #{createBy}
and create_time = #{createTime}
and update_by = #{updateBy}
and update_time = #{updateTime}
and create_site = #{createSite}
and update_site = #{updateSite}
limit 1
</select>
<select id="selectEmisCommissionDtlById" parameterType="Long" resultMap="EmisCommissionDtlResult">
select id, fee_type, money, bill_month, bill_type, bill_code, quote_id, quote_name, expr_id, calc_expr, fee_remark, emp_code, emp_name, 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_commission_dtl a
where a.id = #{id}
</select>
<insert id="insertEmisCommissionDtl" parameterType="EmisCommissionDtl" useGeneratedKeys="true" keyProperty="id">
insert into emis_commission_dtl
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="feeType != null and feeType != ''">fee_type,</if>
<if test="money != null">money,</if>
<if test="billMonth != null and billMonth != ''">bill_month,</if>
<if test="billType != null and billType != ''">bill_type,</if>
<if test="billCode != null and billCode != ''">bill_code,</if>
<if test="quoteId != null">quote_id,</if>
<if test="quoteName != null and quoteName != ''">quote_name,</if>
<if test="exprId != null">expr_id,</if>
<if test="calcExpr != null and calcExpr != ''">calc_expr,</if>
<if test="feeRemark != null and feeRemark != ''">fee_remark,</if>
<if test="empCode != null and empCode != ''">emp_code,</if>
<if test="empName != null and empName != ''">emp_name,</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="remark != null and remark != ''">remark,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="createSite != null and createSite != ''">create_site,</if>
<if test="updateSite != null and updateSite != ''">update_site,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="feeType != null and feeType != ''">#{feeType},</if>
<if test="money != null">#{money},</if>
<if test="billMonth != null and billMonth != ''">#{billMonth},</if>
<if test="billType != null and billType != ''">#{billType},</if>
<if test="billCode != null and billCode != ''">#{billCode},</if>
<if test="quoteId != null">#{quoteId},</if>
<if test="quoteName != null and quoteName != ''">#{quoteName},</if>
<if test="exprId != null">#{exprId},</if>
<if test="calcExpr != null and calcExpr != ''">#{calcExpr},</if>
<if test="feeRemark != null and feeRemark != ''">#{feeRemark},</if>
<if test="empCode != null and empCode != ''">#{empCode},</if>
<if test="empName != null and empName != ''">#{empName},</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="remark != null and remark != ''">#{remark},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createSite != null and createSite != ''">#{createSite},</if>
<if test="updateSite != null and updateSite != ''">#{updateSite},</if>
</trim>
</insert>
<update id="updateEmisCommissionDtl" parameterType="EmisCommissionDtl">
update emis_commission_dtl
<trim prefix="SET" suffixOverrides=",">
<if test="feeType != null and feeType != ''">fee_type = #{feeType},</if>
<if test="money != null">money = #{money},</if>
<if test="billMonth != null and billMonth != ''">bill_month = #{billMonth},</if>
<if test="billType != null and billType != ''">bill_type = #{billType},</if>
<if test="billCode != null and billCode != ''">bill_code = #{billCode},</if>
<if test="quoteId != null">quote_id = #{quoteId},</if>
<if test="quoteName != null and quoteName != ''">quote_name = #{quoteName},</if>
<if test="exprId != null">expr_id = #{exprId},</if>
<if test="calcExpr != null and calcExpr != ''">calc_expr = #{calcExpr},</if>
<if test="feeRemark != null and feeRemark != ''">fee_remark = #{feeRemark},</if>
<if test="empCode != null and empCode != ''">emp_code = #{empCode},</if>
<if test="empName != null and empName != ''">emp_name = #{empName},</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="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="deleteEmisCommissionDtlByBillCode" parameterType="String">
update emis_commission_dtl set del_flag='1' where bill_code = #{billCode} and bill_type='1'
</delete>
<delete id="deleteEmisCommissionDtlByBatchNo" parameterType="String">
update emis_commission_dtl set del_flag='1' where bill_code = #{batchNo} and bill_type='2'
</delete>
<delete id="deleteEmisCommissionDtlById" parameterType="Long">
update emis_commission_dtl set del_flag='1' where id = #{id}
</delete>
<delete id="deleteEmisCommissionDtlByIds" parameterType="String">
update emis_commission_dtl set del_flag='1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>