2022-04-14 17:00:00 +08:00

157 lines
6.9 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.xhpc.clearing.mapper.XhpcClearingCheckoutMapper">
<resultMap id="BaseResultMap" type="com.xhpc.clearing.domain.XhpcClearingCheckoutDomain">
<id column="clearing_checkout_id" jdbcType="BIGINT" property="clearingCheckoutId" />
<result column="clearing_bank_id" jdbcType="BIGINT" property="clearingBankId" />
<result column="apply_amount" jdbcType="DECIMAL" property="applyAmount" />
<result column="handling_fee" jdbcType="DECIMAL" property="handlingFee" />
<result column="bank_fee" jdbcType="DECIMAL" property="bankFee" />
<result column="received_amount" jdbcType="DECIMAL" property="receivedAmount" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="del_flag" jdbcType="INTEGER" property="delFlag" />
<result column="operator_id" jdbcType="BIGINT" property="operatorId" />
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="check_by" jdbcType="VARCHAR" property="checkBy" />
<result column="check_time" jdbcType="TIMESTAMP" property="checkTime" />
</resultMap>
<sql id="Base_Column_List">
cc.clearing_checkout_id, cc.clearing_bank_id, cc.apply_amount, cc.handling_fee, cc.received_amount, cc.bank_fee, cc.del_flag,
cc.`status`, cc.operator_id, cc.tenant_id, cc.create_by, cc.create_time, cc.update_by, cc.update_time, cc.check_by, cc.check_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultType="com.xhpc.clearing.domain.XhpcClearingCheckoutDomain">
select
<include refid="Base_Column_List" />, xo.name as 'operator_name'
from xhpc_clearing_checkout cc
left join xhpc_operator xo on xo.operator_id = cc.operator_id
where cc.clearing_checkout_id = #{clearingCheckoutId,jdbcType=BIGINT}
</select>
<select id="selectByParams" resultType="com.xhpc.clearing.domain.XhpcClearingCheckoutDomain">
select
<include refid="Base_Column_List" />, xo.name as 'operator_name'
from xhpc_clearing_checkout cc
left join xhpc_operator xo on xo.operator_id = cc.operator_id
where cc.del_flag =0
<if test="params.status!=null and params.status!=''">
and cc.status=#{params.status}
</if>
<if test="params.tenantId!=null and params.tenantId!=''">
and cc.tenant_id=#{params.tenantId}
</if>
<if test="params.operatorId!=null and params.operatorId!='' ">
and cc.operator_id=#{params.operatorId}
</if>
<if test="params.startTime!=null and params.startTime!=''">
and cc.create_time <![CDATA[ >= ]]> #{params.startTime}
</if>
<if test="params.endTime!=null and params.endTime!=''">
and cc.create_time <![CDATA[ <= ]]> #{params.endTime}
</if>
</select>
<select id="selectAmountByStatus" resultType="java.math.BigDecimal">
select ifnull(sum(apply_amount), 0) from xhpc_clearing_checkout where del_flag =0 and tenant_id=#{tenantId} and operator_id=#{operatorId} and status=#{status}
</select>
<select id="selectOrderMapByCheckoutIds" resultType="com.xhpc.clearing.vo.CheckoutBankVo">
select
'RMB' as 'curreyType',
date_format(now(), '%Y%m%d') as 'date',
'' as 'detailFlag',
cc.clearing_checkout_id as 'index',
'' as 'payBank',
'' as 'payBankAccount',
'' as 'payBankName',
cb.bank_name as 'receiveBank',
'' as 'receiveProvice',
'' as 'receiveCity',
'' as 'receiveCode',
cb.bank_no as 'receiveAccount',
cb.operator_account as 'receiveName',
sum(cc.received_amount) as 'amount',
'' as 'purposes',
'' as 'remark',
'0' as 'transType',
'' as 'mobile',
'' as 'customeIndex',
'' as 'applyCheckNo'
from xhpc_clearing_checkout cc
left join xhpc_clearing_bank cb on cb.clearing_bank_id=cc.clearing_bank_id
where find_in_set(cc.clearing_checkout_id, #{checkoutIds})
group by cc.clearing_bank_id, cc.operator_id
</select>
<update id="deleteLogicByPrimaryKey" parameterType="java.lang.Long">
update xhpc_clearing_checkout set del_flag=2
where clearing_checkout_id = #{clearingCheckoutId,jdbcType=BIGINT}
</update>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from xhpc_clearing_checkout
where clearing_checkout_id = #{clearingCheckoutId,jdbcType=BIGINT}
</delete>
<insert id="insert" keyColumn="clearing_checkout_id" keyProperty="clearingCheckoutId" parameterType="com.xhpc.clearing.domain.XhpcClearingCheckoutDomain" useGeneratedKeys="true">
insert into xhpc_clearing_checkout (clearing_bank_id, apply_amount, handling_fee, bank_fee,
received_amount, del_flag, `status`, operator_id, tenant_id,
create_by, create_time,
update_by,update_time, check_by, check_time)
values (#{clearingBankId,jdbcType=BIGINT}, #{applyAmount,jdbcType=DECIMAL}, #{handlingFee,jdbcType=DECIMAL}, #{bankFee},
#{receivedAmount,jdbcType=DECIMAL}, 0, #{status}, #{operatorId}, #{tenantId,jdbcType=VARCHAR},
#{createBy,jdbcType=VARCHAR}, sysdate(), #{updateBy,jdbcType=VARCHAR},
sysdate(), #{checkBy}, sysdate())
</insert>
<update id="updateByPrimaryKey" parameterType="com.xhpc.clearing.domain.XhpcClearingCheckoutDomain">
update xhpc_clearing_checkout
set clearing_bank_id = #{clearingBankId,jdbcType=BIGINT},
apply_amount = #{applyAmount,jdbcType=DECIMAL},
handling_fee = #{handlingFee,jdbcType=DECIMAL},
bank_fee = #{bankFee},
received_amount = #{receivedAmount,jdbcType=DECIMAL},
`status` = #{status,jdbcType=INTEGER},
update_by = #{updateBy,jdbcType=VARCHAR},
update_time = sysdate()
where clearing_checkout_id = #{clearingCheckoutId,jdbcType=BIGINT}
</update>
<update id="checkByPrimaryKey">
update xhpc_clearing_checkout
set `status` = #{status,jdbcType=INTEGER},
check_by = #{updateBy,jdbcType=VARCHAR},
check_time = #{updateTime,jdbcType=TIMESTAMP}
where clearing_checkout_id = #{clearingCheckoutId,jdbcType=BIGINT}
</update>
<update id="updateStatusByPrimaryKey">
update xhpc_clearing_checkout
set `status` = #{status,jdbcType=INTEGER},
update_by = #{updateBy,jdbcType=VARCHAR},
update_time = sysdate()
where clearing_checkout_id = #{clearingCheckoutId,jdbcType=BIGINT}
</update>
<update id="updateStatusByIds">
update xhpc_clearing_checkout
set `status` = #{status}
where find_in_set(clearing_checkout_id, #{checkoutIds})
</update>
</mapper>