ghy-all/ghy-payment/src/main/resources/mapper/financial/FinancialDetailMapper.xml

140 lines
7.1 KiB
XML
Raw Normal View History

<?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.ghy.payment.mapper.FinancialDetailMapper">
<resultMap id="FinancialDetailResult" type="com.ghy.payment.domain.FinancialDetail">
<id property="id" column="id"/>
2022-05-24 22:26:26 +08:00
<result property="deptId" column="dept_id"/>
<result property="code" column="code"/>
2022-05-24 22:26:26 +08:00
<result property="financialMasterId" column="financial_master_id"/>
<result property="orderDetailId" column="order_detail_id"/>
<result property="orderDetailCode" column="order_detail_code"/>
<result property="totalMoney" column="total_money"/>
<result property="discountMoney" column="discount_money"/>
<result property="payMoney" column="pay_money"/>
2022-05-24 22:26:26 +08:00
<result property="financialDetailType" column="financial_detail_type"/>
<result property="payeeId" column="payee_id"/>
<result property="payType" column="pay_type"/>
<result property="payStatus" column="pay_status"/>
<result property="payTime" column="pay_time"/>
<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"/>
</resultMap>
<sql id="selectFinancialDetail">
SELECT id,
code,
order_master_id,
order_master_code,
total_money,
discount_money,
pay_money,
pay_type,
pay_status,
pay_time,
financial_detail_type,
create_by,
create_time,
remark
FROM financial_detail
</sql>
<select id="selectFinancialDetailList" parameterType="com.ghy.payment.domain.FinancialDetail"
resultMap="FinancialDetailResult">
<include refid="selectFinancialDetail"/>
<where>
<if test="orderMasterId != null and orderMasterId != 0">
AND order_master_id = #{orderMasterId}
</if>
<if test="orderMasterCode != null and orderMasterCode != ''">
AND order_master_code LIKE concat('%', #{orderMasterCode}, '%')
</if>
<if test="payType != null and payType != 0">
AND pay_type = #{payType}
</if>
<if test="payStatus != null and payStatus != 0">
AND pay_status = #{payStatus}
</if>
<if test="financialDetailType != null and financialDetailType != 0">
AND financial_detail_type = #{financialDetailType}
</if>
</where>
</select>
<select id="selectById" parameterType="long" resultMap="FinancialDetailResult">
<include refid="selectFinancialDetail"/>
<where>
<if test="financialDetailId != null and financialDetailId != 0">
AND id = #{financialDetailId}
</if>
</where>
</select>
<delete id="deleteFinancialDetailByIds" parameterType="Long">
DELETE FROM financial_detail WHERE id IN
<foreach collection="array" item="financialDetailId" open="(" separator="," close=")">
#{financialDetailId}
</foreach>
</delete>
<update id="updateFinancialDetail" parameterType="com.ghy.payment.domain.FinancialDetail">
UPDATE financial_detail
<set>
<if test="code != null and code != 0">code = #{code},</if>
<if test="orderMasterId != null and orderMasterId != ''">order_master_id = #{orderMasterId},</if>
<if test="orderMasterCode != null and orderMasterCode != ''">order_master_code = #{orderMasterCode},</if>
<if test="totalMoney != null and totalMoney != ''">total_money = #{totalMoney},</if>
<if test="discountMoney != null and discountMoney != ''">discount_money = #{discountMoney},</if>
<if test="payType != null and payType != ''">pay_type = #{payType},</if>
<if test="payStatus != null and payStatus != ''">pay_status = #{payStatus},</if>
<if test="payTime != null and payTime != ''">pay_time = #{payTime},</if>
<if test="payMoney != null and payMoney != ''">pay_money = #{payMoney},</if>
<if test="financialDetailType != null and financialDetailType != 0">financial_detail_type = #{financialDetailType},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = SYSDATE()
</set>
WHERE id = #{id}
</update>
<insert id="insertFinancialDetail" parameterType="com.ghy.payment.domain.FinancialDetail" useGeneratedKeys="true"
keyProperty="id">
INSERT INTO financial_detail(
<if test="code != null and code != 0">code,</if>
<if test="orderMasterId != null and orderMasterId != 0">order_master_id,</if>
<if test="orderMasterCode != null and orderMasterCode != ''">order_master_code,</if>
<if test="totalMoney != null and totalMoney != ''">total_money,</if>
<if test="discountMoney != null and discountMoney != ''">discount_money,</if>
<if test="payType != null and payType != ''">pay_type,</if>
<if test="payStatus != null and payStatus != ''">pay_status,</if>
<if test="payTime != null and payTime != ''">pay_time,</if>
<if test="payMoney != null and payMoney != ''">pay_money,</if>
<if test="financialDetailType != null and financialDetailType != ''">financial_detail_type,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)VALUES(
<if test="code != null and code != 0">#{code},</if>
<if test="orderMasterId != null and orderMasterId != 0">#{orderMasterId},</if>
<if test="orderMasterCode != null and orderMasterCode != ''">#{orderMasterCode},</if>
<if test="totalMoney != null and totalMoney != ''">#{totalMoney},</if>
<if test="discountMoney != null and discountMoney != ''">#{discountMoney},</if>
<if test="payType != null and payType != ''">#{payType},</if>
<if test="payStatus != null and payStatus != ''">#{payStatus},</if>
<if test="payTime != null and payTime != ''">#{payTime},</if>
<if test="payMoney != null and payMoney != ''">#{payMoney},</if>
<if test="financialDetailType != null and financialDetailType != ''">#{financialDetailType},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
SYSDATE()
)
</insert>
<select id="checkFinancialDetailCodeUnique" parameterType="String" resultMap="FinancialDetailResult">
<include refid="selectFinancialDetail"/>
WHERE `code` =#{financialDetailCode} LIMIT 1
</select>
</mapper>