system-operator-plugin/src/main/resources/mybatis/mapper-operator/accountrecharge/account-recharge-mapper.xml
2025-04-14 16:35:19 +08:00

703 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="cn.com.tenlion.operator.daoother.operator.IAccountRechargeDao">
<resultMap id="accountRechargeInvoiceDTO" type="cn.com.tenlion.operator.pojo.dtos.accountrecharge.AccountRechargeInvoiceDTO">
<result column="account_recharge_id" property="accountRechargeId"/>
<result column="account_id" property="accountId"/>
<result column="recharge_money" property="rechargeMoney"/>
<result column="recharge_type" property="rechargeType"/>
<result column="third_party" property="thirdParty"/>
<result column="third_party_no" property="thirdPartyNo"/>
<result column="recharge_voucher" property="rechargeVoucher"/>
<result column="recharge_check" property="rechargeCheck"/>
<result column="recharge_check_remark" property="rechargeCheckRemark"/>
<result column="recharge_final_time" property="rechargeFinalTime"/>
<result column="reconciliation_status" property="reconciliationStatus"/>
<result column="reconciliation_time" property="reconciliationTime"/>
<result column="account_item_id" property="accountItemId"/>
<result column="package_info_id" property="packageInfoId"/>
<result column="recharge_remark" property="rechargeRemark"/>
<result column="org_name" property="orgName"/>
<result column="org_bank" property="orgBank"/>
<result column="org_number" property="orgNumber"/>
<result column="self_data" property="selfData"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
</resultMap>
<resultMap id="accountRechargeDTO" type="cn.com.tenlion.operator.pojo.dtos.accountrecharge.AccountRechargeDTO">
<result column="account_recharge_id" property="accountRechargeId"/>
<result column="account_id" property="accountId"/>
<result column="recharge_money" property="rechargeMoney"/>
<result column="recharge_type" property="rechargeType"/>
<result column="third_party" property="thirdParty"/>
<result column="third_party_no" property="thirdPartyNo"/>
<result column="recharge_voucher" property="rechargeVoucher"/>
<result column="recharge_check" property="rechargeCheck"/>
<result column="recharge_check_remark" property="rechargeCheckRemark"/>
<result column="recharge_final_time" property="rechargeFinalTime"/>
<result column="reconciliation_status" property="reconciliationStatus"/>
<result column="reconciliation_time" property="reconciliationTime"/>
<result column="account_item_id" property="accountItemId"/>
<result column="package_info_id" property="packageInfoId"/>
<result column="org_name" property="orgName"/>
<result column="org_bank" property="orgBank"/>
<result column="org_number" property="orgNumber"/>
<result column="self_data" property="selfData"/>
<result column="recharge_remark" property="rechargeRemark"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
<resultMap id="accountRechargeBO" type="cn.com.tenlion.operator.pojo.bos.accountrecharge.AccountRechargeBO">
<result column="account_recharge_id" property="accountRechargeId"/>
<result column="recharge_type" property="rechargeType"/>
<result column="third_party" property="thirdParty"/>
<result column="third_party_no" property="thirdPartyNo"/>
<result column="reconciliation_status" property="reconciliationStatus"/>
<result column="reconciliation_time" property="reconciliationTime"/>
</resultMap>
<resultMap id="accountRechargePO" type="cn.com.tenlion.operator.pojo.pos.accountrecharge.AccountRechargePO">
<result column="account_recharge_id" property="accountRechargeId"/>
<result column="account_id" property="accountId"/>
<result column="recharge_type" property="rechargeType"/>
<result column="third_party" property="thirdParty"/>
<result column="third_party_no" property="thirdPartyNo"/>
<result column="recharge_voucher" property="rechargeVoucher"/>
<result column="recharge_check" property="rechargeCheck"/>
<result column="recharge_check_remark" property="rechargeCheckRemark"/>
<result column="recharge_final_time" property="rechargeFinalTime"/>
<result column="reconciliation_status" property="reconciliationStatus"/>
<result column="reconciliation_time" property="reconciliationTime"/>
<result column="account_item_id" property="accountItemId"/>
<result column="recharge_money" property="rechargeMoney"/>
<result column="recharge_remark" property="rechargeRemark"/>
<result column="org_name" property="orgName"/>
<result column="org_bank" property="orgBank"/>
<result column="org_number" property="orgNumber"/>
<result column="self_data" property="selfData"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
<select id="getCanIsSueInvoices" parameterType="map" resultMap="accountRechargeInvoiceDTO">
SELECT
t1.account_id,
t1.recharge_type,
t1.third_party,
t1.third_party_no,
t1.recharge_voucher,
t1.recharge_check,
t1.recharge_check_remark,
t1.recharge_final_time,
t1.reconciliation_status,
t1.reconciliation_time,
t1.account_item_id,
t1.account_recharge_id,
t1.package_info_id,
t1.recharge_money,
t1.org_name,
t1.org_bank,
t1.org_number,
t1.self_data,
t1.recharge_remark,
t1.creator,
t1.gmt_create
FROM
operator_account_recharge t1
WHERE
t1.is_delete = 0 AND t1.account_id = #{userId} AND t1.third_party != '系统' AND t1.reconciliation_status = '1' AND t1.recharge_check = '2'
<if test="accountRechargeIds != null and accountRechargeIds.size > 0 and status == 'yes' ">
AND
t1.account_recharge_id IN
<foreach collection="accountRechargeIds" index="index" open="(" separator="," close=")">
#{accountRechargeIds[${index}]}
</foreach>
</if>
<if test="accountRechargeIds != null and accountRechargeIds.size > 0 and status == 'not' ">
AND
t1.account_recharge_id NOT IN
<foreach collection="accountRechargeIds" index="index" open="(" separator="," close=")">
#{accountRechargeIds[${index}]}
</foreach>
</if>
<if test="selectedRechargeIds != null and selectedRechargeIds.size > 0">
AND
t1.account_recharge_id IN
<foreach collection="selectedRechargeIds" index="index" open="(" separator="," close=")">
#{selectedRechargeIds[${index}]}
</foreach>
</if>
<if test="thirdParty != null and thirdParty != ''">
AND t1.third_party = #{thirdParty}
</if>
<if test="startTime != null and startTime != ''">
AND LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
ORDER BY
t1.id DESC
</select>
<!-- 新增账户充值 -->
<insert id="save" parameterType="map">
INSERT INTO operator_account_recharge(
account_recharge_id,
account_id,
recharge_money,
recharge_type,
third_party,
third_party_no,
recharge_voucher,
recharge_check,
recharge_check_remark,
recharge_final_time,
reconciliation_status,
reconciliation_time,
account_item_id,
org_name,
org_bank,
org_number,
self_data,
recharge_remark,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{accountRechargeId},
#{accountId},
#{rechargeMoney},
#{rechargeType},
#{thirdParty},
#{thirdPartyNo},
#{rechargeVoucher},
#{rechargeCheck},
#{rechargeCheckRemark},
#{rechargeFinalTime},
#{reconciliationStatus},
#{reconciliationTime},
#{accountItemId},
#{orgName},
#{orgBank},
#{orgNumber},
#{selfData},
#{rechargeRemark},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除账户充值 -->
<update id="remove" parameterType="map">
UPDATE
operator_account_recharge
SET
gmt_modified = #{gmtModified},
modifier = #{modifier},
is_delete = 1
WHERE
reconciliation_status != 1 AND recharge_check != 2 AND account_recharge_id IN
<foreach collection="accountRechargeIds" index="index" open="(" separator="," close=")">
#{accountRechargeIds[${index}]}
</foreach>
</update>
<!-- 删除账户充值(物理) -->
<update id="delete" parameterType="map">
DELETE FROM
operator_account_recharge
WHERE
account_recharge_id IN
<foreach collection="accountRechargeIds" index="index" open="(" separator="," close=")">
#{accountRechargeIds[${index}]}
</foreach>
</update>
<update id="updateRemark" parameterType="map">
UPDATE
operator_account_recharge
SET
recharge_remark = #{rechargeRemark},
gmt_modified = #{gmtModified},
modifier = #{modifier}
WHERE
account_recharge_id = #{accountRechargeId}
</update>
<update id="updateCheck" parameterType="map">
UPDATE
operator_account_recharge
SET
<if test="thirdPartyNo != null and thirdPartyNo != ''">
third_party_no = #{thirdPartyNo},
</if>
<if test="rechargeCheck != null and rechargeCheck != ''">
recharge_check = #{rechargeCheck},
</if>
<if test="rechargeCheckRemark != null and rechargeCheckRemark != ''">
recharge_check_remark = #{rechargeCheckRemark},
</if>
<if test="rechargeFinalTime != null and rechargeFinalTime != ''">
recharge_final_time = #{rechargeFinalTime},
</if>
<if test="accountItemId != null and accountItemId != ''">
account_item_id = #{accountItemId},
</if>
<if test="reconciliationStatus != null and reconciliationStatus != ''">
reconciliation_status = #{reconciliationStatus},
</if>
<if test="reconciliationTime != null and reconciliationTime != ''">
reconciliation_time = #{reconciliationTime},
</if>
gmt_modified = #{gmtModified}
WHERE
<if test="accountRechargeId != null and accountRechargeId != ''">
account_recharge_id = #{accountRechargeId}
</if>
<if test="accountRechargeIds != null and accountRechargeIds.size > 0">
account_recharge_id IN
<foreach collection="accountRechargeIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</update>
<!-- 修改账户充值 -->
<update id="update" parameterType="map">
UPDATE
operator_account_recharge
SET
<if test="accountId != null and accountId != ''">
account_id = #{accountId},
</if>
<if test="rechargeMoney != null and rechargeMoney != ''">
recharge_money = #{rechargeMoney},
</if>
<if test="rechargeType != null and rechargeType != ''">
recharge_type = #{rechargeType},
</if>
<if test="thirdParty != null and thirdParty != ''">
third_party = #{thirdParty},
</if>
<if test="thirdPartyNo != null and thirdPartyNo != ''">
third_party_no = #{thirdPartyNo},
</if>
<if test="rechargeVoucher != null and rechargeVoucher != ''">
recharge_voucher = #{rechargeVoucher},
</if>
<if test="rechargeCheck != null and rechargeCheck != ''">
recharge_check = #{rechargeCheck},
</if>
<if test="rechargeCheckRemark != null and rechargeCheckRemark != ''">
recharge_check_remark = #{rechargeCheckRemark},
</if>
<if test="rechargeFinalTime != null and rechargeFinalTime != ''">
recharge_final_time = #{rechargeFinalTime},
</if>
<if test="reconciliationStatus != null and reconciliationStatus != ''">
reconciliation_status = #{reconciliationStatus},
</if>
<if test="reconciliationTime != null and reconciliationTime != ''">
reconciliation_time = #{reconciliationTime},
</if>
<if test="accountItemId != null and accountItemId != ''">
account_item_id = #{accountItemId},
</if>
<if test="orgName != null and orgName != ''">
org_name = #{orgName},
</if>
<if test="orgBank != null and orgBank != ''">
org_bank = #{orgBank},
</if>
<if test="orgNumber != null and orgNumber != ''">
org_number = #{orgNumber},
</if>
<if test="selfData != null and selfData != ''">
self_data = #{selfData},
</if>
<if test="rechargeRemark != null and rechargeRemark != ''">
recharge_remark = #{rechargeRemark},
</if>
gmt_modified = #{gmtModified},
modifier = #{modifier},
account_recharge_id = account_recharge_id
WHERE
account_recharge_id = #{accountRechargeId}
</update>
<!-- 账户充值详情 -->
<select id="get" parameterType="map" resultMap="accountRechargeDTO">
SELECT
t1.account_id,
t1.recharge_type,
t1.third_party,
t1.third_party_no,
t1.recharge_voucher,
t1.recharge_check,
t1.recharge_check_remark,
t1.recharge_final_time,
t1.reconciliation_status,
t1.reconciliation_time,
t1.account_item_id,
t1.account_recharge_id,
t1.package_info_id,
t1.recharge_money,
t1.org_name,
t1.org_bank,
t1.org_number,
t1.self_data,
t1.recharge_remark,
t1.creator
FROM
operator_account_recharge t1
WHERE
t1.is_delete = 0
<if test="accountRechargeId != null and accountRechargeId != ''">
AND
t1.account_recharge_id = #{accountRechargeId}
</if>
</select>
<!-- 账户充值详情 -->
<select id="getBO" parameterType="map" resultMap="accountRechargeBO">
SELECT
t1.account_recharge_id,
t1.account_id,
t1.recharge_type,
t1.third_party,
t1.third_party_no,
t1.recharge_voucher,
t1.recharge_check,
t1.recharge_check_remark,
t1.recharge_final_time,
t1.reconciliation_status,
t1.reconciliation_time,
t1.account_item_id,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
operator_account_recharge t1
WHERE
t1.is_delete = 0
<if test="accountRechargeId != null and accountRechargeId != ''">
AND
t1.account_recharge_id = #{accountRechargeId}
</if>
</select>
<!-- 账户充值详情 -->
<select id="getPO" parameterType="map" resultMap="accountRechargePO">
SELECT
t1.account_recharge_id,
t1.account_id,
t1.recharge_type,
t1.third_party,
t1.third_party_no,
t1.recharge_voucher,
t1.recharge_check,
t1.recharge_check_remark,
t1.recharge_final_time,
t1.reconciliation_status,
t1.reconciliation_time,
t1.account_item_id,
t1.recharge_money,
t1.recharge_remark,
t1.org_name,
t1.org_bank,
t1.org_number,
t1.self_data,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
operator_account_recharge t1
WHERE
t1.is_delete = 0
<if test="accountRechargeId != null and accountRechargeId != ''">
AND
t1.account_recharge_id = #{accountRechargeId}
</if>
</select>
<select id="getNotCloseRechargeList" parameterType="map" resultMap="accountRechargeDTO">
SELECT
t1.account_recharge_id,
t1.account_id,
t1.recharge_type,
t1.third_party,
t1.third_party_no,
t1.recharge_voucher,
t1.recharge_check,
t1.recharge_check_remark,
t1.recharge_final_time,
t1.reconciliation_status,
t1.reconciliation_time,
t1.account_item_id,
t1.recharge_money,
t1.org_name,
t1.org_bank,
t1.org_number,
t1.self_data,
t1.recharge_remark
FROM
operator_account_recharge t1
WHERE
t1.is_delete = 0
AND
t1.recharge_check = '0'
AND
NOW() - INTERVAL 10 MINUTE > t1.recharge_final_time
<if test="thirdParty != null and thirdParty != ''">
AND
t1.third_party = #{thirdParty}
</if>
</select>
<select id="getNotCheckRechargeList" parameterType="map" resultMap="accountRechargeDTO">
SELECT
t1.account_recharge_id,
t1.account_id,
t1.recharge_type,
t1.third_party,
t1.third_party_no,
t1.recharge_voucher,
t1.recharge_check,
t1.recharge_check_remark,
t1.recharge_final_time,
t1.reconciliation_status,
t1.reconciliation_time,
t1.account_item_id,
t1.recharge_money,
t1.org_name,
t1.org_bank,
t1.org_number,
t1.self_data,
t1.recharge_remark
FROM
operator_account_recharge t1
WHERE
t1.is_delete = 0 AND t1.recharge_type = '2' AND t1.recharge_check = '0' AND t1.recharge_final_time > NOW() - INTERVAL 10 MINUTE AND t1.third_party = #{thirdParty}
ORDER BY
t1.id DESC
</select>
<!-- 账户充值列表 -->
<select id="list" parameterType="map" resultMap="accountRechargeDTO">
SELECT
t1.account_recharge_id,
t1.account_id,
t1.recharge_type,
t1.third_party,
t1.third_party_no,
t1.recharge_voucher,
t1.recharge_check,
t1.recharge_check_remark,
t1.recharge_final_time,
t1.reconciliation_status,
t1.reconciliation_time,
t1.account_item_id,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete,
t1.recharge_money,
t1.org_name,
t1.org_bank,
t1.org_number,
t1.self_data,
t1.recharge_remark
FROM
operator_account_recharge t1
WHERE
t1.is_delete = 0
<if test="accountId != null and accountId != ''">
AND t1.account_id = #{accountId}
</if>
<if test="rechargeType != null and rechargeType != ''">
AND t1.recharge_type = #{rechargeType}
</if>
<if test="thirdParty != null and thirdParty != ''">
AND t1.third_party = #{thirdParty}
</if>
<if test="thirdPartyNo != null and thirdPartyNo != ''">
AND t1.third_party_no LIKE CONCAT('%', #{thirdPartyNo}, '%')
</if>
<if test="reconciliationStatus != null and reconciliationStatus != ''">
AND t1.reconciliation_status = #{reconciliationStatus}
</if>
<if test="rechargeCheck != null and rechargeCheck != ''">
AND t1.recharge_check = #{rechargeCheck}
</if>
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.recharge_check_remark LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="accountRechargeIds != null and accountRechargeIds.size > 0">
AND
t1.account_recharge_id IN
<foreach collection="accountRechargeIds" index="index" open="(" separator="," close=")">
#{accountRechargeIds[${index}]}
</foreach>
</if>
ORDER BY
<if test="selectedRechargeIds != null and selectedRechargeIds.size > 0">
<foreach collection="selectedRechargeIds" index="index" open=" FIELD (t1.account_recharge_id , " separator="," close=") DESC ,">
#{selectedRechargeIds[${index}]}
</foreach>
</if>
t1.id DESC
</select>
<!-- 账户充值列表 -->
<select id="listBO" parameterType="map" resultMap="accountRechargeBO">
SELECT
t1.account_recharge_id,
t1.recharge_type,
t1.third_party,
t1.third_party_no,
t1.reconciliation_status,
t1.reconciliation_time
FROM
operator_account_recharge t1
WHERE
t1.is_delete = 0 AND t1.reconciliation_status = '1' AND t1.account_id = #{accountId}
ORDER BY
t1.reconciliation_time DESC
</select>
<!-- 账户充值列表 -->
<select id="listPO" parameterType="map" resultMap="accountRechargePO">
SELECT
t1.account_recharge_id,
t1.account_id,
t1.recharge_money,
t1.recharge_type,
t1.third_party,
t1.third_party_no,
t1.recharge_voucher,
t1.recharge_check,
t1.recharge_check_remark,
t1.recharge_final_time,
t1.reconciliation_status,
t1.reconciliation_time,
t1.account_item_id,
t1.recharge_remark,
t1.org_name,
t1.org_bank,
t1.org_number,
t1.self_data,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
operator_account_recharge t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="accountId != null and accountId != ''">
AND t1.account_id = #{accountId}
</if>
<if test="rechargeType != null and rechargeType != ''">
AND t1.recharge_type = #{rechargeType}
</if>
<if test="thirdParty != null and thirdParty != ''">
AND t1.third_party = #{thirdParty}
</if>
<if test="reconciliationStatus != null and reconciliationStatus != ''">
AND t1.reconciliation_status = #{reconciliationStatus}
</if>
<if test="rechargeCheck != null and rechargeCheck != ''">
AND t1.recharge_check = #{rechargeCheck}
</if>
<if test="accountRechargeIds != null and accountRechargeIds.size > 0">
AND
t1.account_recharge_id IN
<foreach collection="accountRechargeIds" index="index" open="(" separator="," close=")">
#{accountRechargeIds[${index}]}
</foreach>
</if>
</select>
<!-- 账户充值统计 -->
<select id="count" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
operator_account_recharge t1
WHERE
t1.is_delete = 0
<if test="thirdParty != null and thirdParty != ''">
AND t1.third_party = #{thirdParty}
</if>
<if test="rechargeType != null and rechargeType != ''">
AND t1.recharge_type = #{rechargeType}
</if>
<if test="rechargeCheck != null and rechargeCheck != ''">
AND t1.recharge_check = #{rechargeCheck}
</if>
<if test="queryMode != null and queryMode != ''">
<if test="queryMode == 'HOUR' ">
AND HOUR(t1.gmt_create) = HOUR(CURRENT_TIMESTAMP) AND DATE(t1.gmt_create) = CURDATE()
</if>
<if test="queryMode == 'DAY' ">
AND DATE(t1.gmt_create) = CURDATE()
</if>
</if>
</select>
<select id="getTodayByAccountId" parameterType="java.lang.String" resultType="Integer">
SELECT
COUNT(*)
FROM
operator_account_recharge t1
WHERE
t1.is_delete = 0 AND t1.account_id = #{accountId} AND DATE(t1.gmt_create) = CURDATE()
</select>
</mapper>