客户余额记录
This commit is contained in:
@@ -0,0 +1,322 @@
|
||||
<?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.ruoyi.customer.customermoney.mapper.CustomerMoneyMapper">
|
||||
|
||||
<!-- ================= 客户余额账户 ================= -->
|
||||
<resultMap type="com.ruoyi.customer.customermoney.domain.CustomerAccount" id="CustomerAccountResult">
|
||||
<id property="id" column="id" />
|
||||
<result property="customerId" column="customer_id" />
|
||||
<result property="currency" column="currency" />
|
||||
<result property="balance" column="balance" />
|
||||
<result property="frozenBalance" column="frozen_balance" />
|
||||
<result property="totalCredit" column="total_credit" />
|
||||
<result property="extraCredit" column="extra_credit" />
|
||||
<result property="usedCredit" column="used_credit" />
|
||||
<result property="tax" column="tax" />
|
||||
<result property="version" column="version" />
|
||||
<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" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCustomerAccountVo">
|
||||
select id, customer_id, currency, balance, frozen_balance, total_credit, extra_credit, used_credit,
|
||||
tax, version, create_by, create_time, update_by, update_time, remark, del_flag
|
||||
from customer_account
|
||||
</sql>
|
||||
|
||||
<select id="selectAccountByCustomerCurrency" resultMap="CustomerAccountResult">
|
||||
<include refid="selectCustomerAccountVo"/>
|
||||
where customer_id = #{customerId} and currency = #{currency} and del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectAccountForUpdate" resultMap="CustomerAccountResult">
|
||||
<include refid="selectCustomerAccountVo"/>
|
||||
where customer_id = #{customerId} and currency = #{currency} and del_flag = '0'
|
||||
for update
|
||||
</select>
|
||||
|
||||
<select id="selectAccountListByCustomerId" resultMap="CustomerAccountResult">
|
||||
<include refid="selectCustomerAccountVo"/>
|
||||
where customer_id = #{customerId} and del_flag = '0'
|
||||
</select>
|
||||
|
||||
<insert id="insertAccount" parameterType="com.ruoyi.customer.customermoney.domain.CustomerAccount"
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
insert into customer_account
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="customerId != null">customer_id,</if>
|
||||
<if test="currency != null">currency,</if>
|
||||
<if test="balance != null">balance,</if>
|
||||
<if test="frozenBalance != null">frozen_balance,</if>
|
||||
<if test="totalCredit != null">total_credit,</if>
|
||||
<if test="extraCredit != null">extra_credit,</if>
|
||||
<if test="usedCredit != null">used_credit,</if>
|
||||
<if test="tax != null">tax,</if>
|
||||
<if test="version != null">version,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
del_flag,
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="customerId != null">#{customerId},</if>
|
||||
<if test="currency != null">#{currency},</if>
|
||||
<if test="balance != null">#{balance},</if>
|
||||
<if test="frozenBalance != null">#{frozenBalance},</if>
|
||||
<if test="totalCredit != null">#{totalCredit},</if>
|
||||
<if test="extraCredit != null">#{extraCredit},</if>
|
||||
<if test="usedCredit != null">#{usedCredit},</if>
|
||||
<if test="tax != null">#{tax},</if>
|
||||
<if test="version != null">#{version},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
'0',
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateAccountBalance">
|
||||
update customer_account
|
||||
set balance = #{balance},
|
||||
frozen_balance = #{frozenBalance},
|
||||
used_credit = #{usedCredit},
|
||||
version = version + 1,
|
||||
update_by = #{updateBy},
|
||||
update_time = now()
|
||||
where id = #{id} and version = #{version} and del_flag = '0'
|
||||
</update>
|
||||
|
||||
<!-- ================= 客户收款 ================= -->
|
||||
<resultMap type="com.ruoyi.customer.customermoney.domain.CustomerReceipt" id="CustomerReceiptResult">
|
||||
<id property="id" column="id" />
|
||||
<result property="receiptNo" column="receipt_no" />
|
||||
<result property="customerId" column="customer_id" />
|
||||
<result property="accountId" column="account_id" />
|
||||
<result property="receiptType" column="receipt_type" />
|
||||
<result property="amount" column="amount" />
|
||||
<result property="allocatedAmount" column="allocated_amount" />
|
||||
<result property="unallocatedAmount" column="unallocated_amount" />
|
||||
<result property="currency" column="currency" />
|
||||
<result property="payMethod" column="pay_method" />
|
||||
<result property="bankTransactionNo" column="bank_transaction_no" />
|
||||
<result property="receivedAt" column="received_at" />
|
||||
<result property="status" column="status" />
|
||||
<result property="confirmedAt" column="confirmed_at" />
|
||||
<result property="confirmedBy" column="confirmed_by" />
|
||||
<result property="invoiceStatus" column="invoice_status" />
|
||||
<result property="version" column="version" />
|
||||
<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" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="attachmentCount" column="attachment_count" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCustomerReceiptVo">
|
||||
select r.id, r.receipt_no, r.customer_id, r.account_id, r.receipt_type, r.amount, r.allocated_amount,
|
||||
r.unallocated_amount, r.currency, r.pay_method, r.bank_transaction_no, r.received_at, r.status,
|
||||
r.confirmed_at, r.confirmed_by, r.invoice_status, r.version, r.create_by, r.create_time,
|
||||
r.update_by, r.update_time, r.remark, r.del_flag,
|
||||
(select count(1) from bms_customer_attachment a
|
||||
where a.biz_id = r.id and a.attachment_type = '3' and a.del_flag = '0') as attachment_count
|
||||
from customer_receipt r
|
||||
</sql>
|
||||
|
||||
<select id="selectReceiptList" parameterType="com.ruoyi.customer.customermoney.domain.CustomerReceipt"
|
||||
resultMap="CustomerReceiptResult">
|
||||
<include refid="selectCustomerReceiptVo"/>
|
||||
<where>
|
||||
r.del_flag = '0'
|
||||
<if test="customerId != null"> and r.customer_id = #{customerId}</if>
|
||||
|
||||
<if test="receiptNo != null and receiptNo != ''"> and r.receipt_no like concat('%', #{receiptNo}, '%')</if>
|
||||
<if test="receiptType != null and receiptType != ''"> and r.receipt_type = #{receiptType}</if>
|
||||
<if test="status != null and status != ''"> and r.status = #{status}</if>
|
||||
<if test="currency != null and currency != ''"> and r.currency = #{currency}</if>
|
||||
<if test="payMethod != null and payMethod != ''"> and r.pay_method = #{payMethod}</if>
|
||||
<if test="bankTransactionNo != null and bankTransactionNo != ''">
|
||||
and r.bank_transaction_no like concat('%', #{bankTransactionNo}, '%')
|
||||
</if>
|
||||
<if test="params != null and params.beginTime != null and params.beginTime != ''">
|
||||
and date_format(r.received_at,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params != null and params.endTime != null and params.endTime != ''">
|
||||
and date_format(r.received_at,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
</where>
|
||||
order by r.received_at desc, r.id desc
|
||||
</select>
|
||||
|
||||
<select id="selectReceiptById" resultMap="CustomerReceiptResult">
|
||||
<include refid="selectCustomerReceiptVo"/>
|
||||
where r.id = #{id} and r.del_flag = '0'
|
||||
</select>
|
||||
|
||||
<insert id="insertReceipt" parameterType="com.ruoyi.customer.customermoney.domain.CustomerReceipt"
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
insert into customer_receipt
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="receiptNo != null">receipt_no,</if>
|
||||
<if test="customerId != null">customer_id,</if>
|
||||
<if test="accountId != null">account_id,</if>
|
||||
<if test="receiptType != null">receipt_type,</if>
|
||||
<if test="amount != null">amount,</if>
|
||||
<if test="allocatedAmount != null">allocated_amount,</if>
|
||||
<if test="unallocatedAmount != null">unallocated_amount,</if>
|
||||
<if test="currency != null">currency,</if>
|
||||
<if test="payMethod != null">pay_method,</if>
|
||||
<if test="bankTransactionNo != null">bank_transaction_no,</if>
|
||||
<if test="receivedAt != null">received_at,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="confirmedAt != null">confirmed_at,</if>
|
||||
<if test="confirmedBy != null">confirmed_by,</if>
|
||||
<if test="invoiceStatus != null">invoice_status,</if>
|
||||
<if test="version != null">version,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
del_flag,
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="receiptNo != null">#{receiptNo},</if>
|
||||
<if test="customerId != null">#{customerId},</if>
|
||||
<if test="accountId != null">#{accountId},</if>
|
||||
<if test="receiptType != null">#{receiptType},</if>
|
||||
<if test="amount != null">#{amount},</if>
|
||||
<if test="allocatedAmount != null">#{allocatedAmount},</if>
|
||||
<if test="unallocatedAmount != null">#{unallocatedAmount},</if>
|
||||
<if test="currency != null">#{currency},</if>
|
||||
<if test="payMethod != null">#{payMethod},</if>
|
||||
<if test="bankTransactionNo != null">#{bankTransactionNo},</if>
|
||||
<if test="receivedAt != null">#{receivedAt},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="confirmedAt != null">#{confirmedAt},</if>
|
||||
<if test="confirmedBy != null">#{confirmedBy},</if>
|
||||
<if test="invoiceStatus != null">#{invoiceStatus},</if>
|
||||
<if test="version != null">#{version},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
'0',
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="confirmReceipt" parameterType="com.ruoyi.customer.customermoney.domain.CustomerReceipt">
|
||||
update customer_receipt
|
||||
set status = 'CONFIRMED',
|
||||
confirmed_at = #{confirmedAt},
|
||||
confirmed_by = #{confirmedBy},
|
||||
version = version + 1,
|
||||
update_by = #{updateBy},
|
||||
update_time = now()
|
||||
where id = #{id} and status = 'PENDING' and version = #{version} and del_flag = '0'
|
||||
</update>
|
||||
|
||||
<update id="cancelReceipt">
|
||||
update customer_receipt
|
||||
set status = 'CANCELLED',
|
||||
update_by = #{updateBy},
|
||||
update_time = now()
|
||||
where id = #{id} and status = 'PENDING' and del_flag = '0'
|
||||
</update>
|
||||
|
||||
<!-- ================= 余额流水 ================= -->
|
||||
<resultMap type="com.ruoyi.customer.customermoney.domain.CustomerBalanceFlow" id="CustomerBalanceFlowResult">
|
||||
<id property="id" column="id" />
|
||||
<result property="flowNo" column="flow_no" />
|
||||
<result property="customerId" column="customer_id" />
|
||||
<result property="accountId" column="account_id" />
|
||||
<result property="currency" column="currency" />
|
||||
<result property="bizType" column="biz_type" />
|
||||
<result property="bizId" column="biz_id" />
|
||||
<result property="bizNo" column="biz_no" />
|
||||
<result property="direction" column="direction" />
|
||||
<result property="amount" column="amount" />
|
||||
<result property="beforeBalance" column="before_balance" />
|
||||
<result property="afterBalance" column="after_balance" />
|
||||
<result property="beforeFrozenBalance" column="before_frozen_balance" />
|
||||
<result property="afterFrozenBalance" column="after_frozen_balance" />
|
||||
<result property="operatorId" column="operator_id" />
|
||||
<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" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCustomerBalanceFlowVo">
|
||||
select id, flow_no, customer_id, account_id, currency, biz_type, biz_id, biz_no, direction, amount,
|
||||
before_balance, after_balance, before_frozen_balance, after_frozen_balance, operator_id,
|
||||
create_by, create_time, update_by, update_time, remark, del_flag
|
||||
from customer_balance_flow
|
||||
</sql>
|
||||
|
||||
<select id="selectFlowList" parameterType="com.ruoyi.customer.customermoney.domain.CustomerBalanceFlow"
|
||||
resultMap="CustomerBalanceFlowResult">
|
||||
<include refid="selectCustomerBalanceFlowVo"/>
|
||||
<where>
|
||||
del_flag = '0'
|
||||
<if test="customerId != null"> and customer_id = #{customerId}</if>
|
||||
<if test="accountId != null"> and account_id = #{accountId}</if>
|
||||
<if test="bizType != null and bizType != ''"> and biz_type = #{bizType}</if>
|
||||
<if test="direction != null"> and direction = #{direction}</if>
|
||||
<if test="currency != null and currency != ''"> and currency = #{currency}</if>
|
||||
<if test="bizNo != null and bizNo != ''"> and biz_no like concat('%', #{bizNo}, '%')</if>
|
||||
<if test="params != null and params.beginTime != null and params.beginTime != ''">
|
||||
and date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params != null and params.endTime != null and params.endTime != ''">
|
||||
and date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc, id desc
|
||||
</select>
|
||||
|
||||
<insert id="insertFlow" parameterType="com.ruoyi.customer.customermoney.domain.CustomerBalanceFlow"
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
insert into customer_balance_flow
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="flowNo != null">flow_no,</if>
|
||||
<if test="customerId != null">customer_id,</if>
|
||||
<if test="accountId != null">account_id,</if>
|
||||
<if test="currency != null">currency,</if>
|
||||
<if test="bizType != null">biz_type,</if>
|
||||
<if test="bizId != null">biz_id,</if>
|
||||
<if test="bizNo != null">biz_no,</if>
|
||||
<if test="direction != null">direction,</if>
|
||||
<if test="amount != null">amount,</if>
|
||||
<if test="beforeBalance != null">before_balance,</if>
|
||||
<if test="afterBalance != null">after_balance,</if>
|
||||
<if test="beforeFrozenBalance != null">before_frozen_balance,</if>
|
||||
<if test="afterFrozenBalance != null">after_frozen_balance,</if>
|
||||
<if test="operatorId != null">operator_id,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
del_flag,
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="flowNo != null">#{flowNo},</if>
|
||||
<if test="customerId != null">#{customerId},</if>
|
||||
<if test="accountId != null">#{accountId},</if>
|
||||
<if test="currency != null">#{currency},</if>
|
||||
<if test="bizType != null">#{bizType},</if>
|
||||
<if test="bizId != null">#{bizId},</if>
|
||||
<if test="bizNo != null">#{bizNo},</if>
|
||||
<if test="direction != null">#{direction},</if>
|
||||
<if test="amount != null">#{amount},</if>
|
||||
<if test="beforeBalance != null">#{beforeBalance},</if>
|
||||
<if test="afterBalance != null">#{afterBalance},</if>
|
||||
<if test="beforeFrozenBalance != null">#{beforeFrozenBalance},</if>
|
||||
<if test="afterFrozenBalance != null">#{afterFrozenBalance},</if>
|
||||
<if test="operatorId != null">#{operatorId},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
'0',
|
||||
</trim>
|
||||
</insert>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user