EkpBankGrantDetailMapper.xml 7.78 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~
  ~      Copyright (c) 2018-2025, lengleng All rights reserved.
  ~
  ~  Redistribution and use in source and binary forms, with or without
  ~  modification, are permitted provided that the following conditions are met:
  ~
  ~ Redistributions of source code must retain the above copyright notice,
  ~  this list of conditions and the following disclaimer.
  ~  Redistributions in binary form must reproduce the above copyright
  ~  notice, this list of conditions and the following disclaimer in the
  ~  documentation and/or other materials provided with the distribution.
  ~  Neither the name of the yifu4cloud.com developer nor the names of its
  ~  contributors may be used to endorse or promote products derived from
  ~  this software without specific prior written permission.
  ~  Author: lengleng (wangiegie@gmail.com)
  ~
  -->

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.yifu.cloud.plus.v1.ekp.mapper.EkpBankGrantDetailMapper">

  <resultMap id="ekpBankGrantDetailMap" type="com.yifu.cloud.plus.v1.ekp.entity.EkpBankGrantDetail">
    <id property="fdId" column="fd_id"/>
    <result property="fdSerialNumber" column="fd_serial_number"/>
    <result property="fdPayeeName" column="fd_payee_name"/>
    <result property="fdPayeeAccount" column="fd_payee_account"/>
    <result property="fdMoney" column="fd_money"/>
    <result property="fdRecipientBank" column="fd_recipient_bank"/>
    <result property="fdRemittancePurpose" column="fd_remittance_purpose"/>
    <result property="fdRemark" column="fd_remark"/>
    <result property="fdCreateTime" column="fd_create_time"/>
    <result property="fdFailureFeedback" column="fd_failure_feedback"/>
    <result property="fdGrantStatus" column="fd_grant_status"/>
    <result property="fdHandleStatus" column="fd_handle_status"/>
    <result property="fdHandleFailNo" column="fd_handle_fail_no"/>
    <result property="fdHandleFailId" column="fd_handle_fail_id"/>
    <result property="fdAttaId" column="fd_atta_id"/>
    <result property="fdAttaName" column="fd_atta_name"/>
    <result property="fdAttaSrc" column="fd_atta_src"/>
    <result property="fdDownloadNum" column="fd_download_num"/>
    <result property="fdFailNum" column="fd_fail_num"/>
    <result property="fdGrantNum" column="fd_grant_num"/>
47 48 49 50 51

    <result property="fdParentId" column="fd_parent_id"/>
    <result property="fdEmpPhone" column="fd_emp_phone"/>
    <result property="fdWxNo" column="fd_wx_no"/>
    <result property="fdMdCode" column="fd_md_dcode"/>
52
    <result property="fdSalaryId" column="fd_salary_id"/>
53 54 55 56 57 58 59 60 61 62 63 64
  </resultMap>

	<sql id="Base_Excel_Sql">
		select
			DATE_FORMAT(now(),'%Y%m%d') nowDate,
			'2' detailTag,
			a.fd_serial_number fdSerialNumber,
			'' baoXiaoNumber,
			'0' danJuNumber,
			m.fd_bank_name fdBankName,
			m.fd_bank_no fdBankNo,
			m.fd_bank_account fdBankAccount,
65
			ifnull(c.fd_recipient_bank,a.fd_recipient_bank) fdRecipientBank,
66
			'' fdRecipientAdress,
67
			c.fd_recipient_bank_code fdRecipientBankCode,
68 69 70
			'1' payType,
			a.fd_payee_account fdPayeeAccount,
			a.fd_payee_name fdPayeeName,
71
			concat('',round(a.fd_money * 100,0)) fdMoney,
72
			a.fd_remittance_purpose fdRemittancePurpose,
73
			ifnull(a.fd_remark,'工资') fdCoverRemark,
74 75 76
			a.fd_emp_phone fdEmpPhone
		from ekp_bank_grant_detail a
			left join ekp_bank_pay_task m on a.fd_parent_id=m.fd_id
77
			left join ekp_bank_code_set c on c.fd_payee_account=a.fd_payee_account
78
		where
79 80
	</sql>

81 82 83 84
	<!-- 查询待发放条数 -->
	<select id="getCountByIdAndMain" resultType="java.lang.Integer">
		select count(1)
		from ekp_bank_grant_detail a
85
		where (a.fd_handle_status is null or a.fd_handle_status = '待发放')
86 87 88
		and a.fd_parent_id = #{fdParentId}
	</select>

89 90 91
	<!-- 查询主表下的所有待发放数据 -->
	<select id="getEkpBankExcelVoByIdAndMain" resultType="com.yifu.cloud.plus.v1.ekp.vo.EkpBankExcelVo">
		<include refid="Base_Excel_Sql"/>
92
		(a.fd_handle_status is null or a.fd_handle_status = '待发放') and a.fd_parent_id = #{fdParentId}
93 94 95 96 97
	</select>

	<!-- 查询主表下的所有待发放数据 -->
	<select id="getEkpBankExcelVoByIdAndDetail" resultType="com.yifu.cloud.plus.v1.ekp.vo.EkpBankExcelVo">
		<include refid="Base_Excel_Sql"/>
98
		a.fd_handle_status = '待发放' and a.fd_id = #{fdId}
99 100
	</select>

101 102 103 104 105 106 107 108 109
	<!-- 查询编号是否重复 -->
	<select id="getWxNoByWxNo" resultType="java.lang.String">
		select a.fd_wx_no from (
		   select a.fd_wx_no from ekp_bank_grant_detail a where a.fd_wx_no = #{wxNo}
		   union all
		   select a.fd_wx_no from ekp_bank_pay_task a where a.fd_wx_no = #{wxNo}
	   ) a limit 1
	</select>

110 111 112 113 114
	<!-- 主表发放时,更新明细表的发放时间与状态 -->
	<update id="updateStatusByGrant">
		update ekp_bank_grant_detail a set a.fd_create_time = NOW(),a.fd_grant_status='发放中' where a.fd_parent_id = #{fdParentId}
	</update>

115 116 117 118 119 120 121
	<!-- 主表拒绝授权时,批量更新明细表为发放失败,原因为拒绝授权 -->
	<update id="updateStatusByGrantFail">
		update ekp_bank_grant_detail a set a.fd_grant_status='发放失败',a.fd_failure_feedback = '拒绝授权' where a.fd_parent_id = #{fdParentId}
	</update>
	
	<select id="getListByParentId" resultMap="ekpBankGrantDetailMap">
		select
hongguangwu's avatar
hongguangwu committed
122
			a.fd_id,a.fd_salary_id,a.fd_serial_number,a.fd_payee_name,a.fd_recipient_bank
123 124 125
		from ekp_bank_grant_detail a where a.fd_parent_id = #{fdParentId}
	</select>

126 127 128
	<!-- 发放失败,批量更新中信银行交易流水表fd_3b148bc0c28e48为失败,根据 工资明细fdId:fd_3b1fe00b0f5dde -->
	<update id="updateZhongXinStatus">
		update ekp_db4ed54e25543f4b7a9a a
hongguangwu's avatar
hongguangwu committed
129 130 131
		set a.fd_3b148bc0c28e48='失败',a.fd_tbankempid = #{detailId}
		where a.fd_3b1fe00b0f5dde = #{salaryId}

132 133 134 135 136 137
	</update>

	<!-- 发放失败,批量更新中信银行交易流水Model表fd_3b148bc0c28e48为失败,根据 工资明细fdId:fd_3b1fe00b0f5dde -->
	<update id="updateZhongXinMainStatus">
		UPDATE modeling_simple_main a
		JOIN ekp_db4ed54e25543f4b7a9a b on a.fd_id=b.fd_id
hongguangwu's avatar
hongguangwu committed
138 139 140
		SET a.extend_data_xml=JSON_SET(a.extend_data_xml,'$[1].fd_3b148bc0c28e48', '失败','$[1].fd_tbankempid', #{detailId})
		where b.fd_3b56782982b8b2 = #{salaryId}

141 142
	</update>

143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179

	<!-- 明细再次-发放失败,批量更新中信银行交易流水表fd_3b148bc0c28e48为失败,根据 工资明细fdId:fd_3b1fe00b0f5dde -->
	<update id="updateZhongXinStatusAndBankInfo">
		update ekp_db4ed54e25543f4b7a9a a
		left join ekp_bank_grant_detail d on a.fd_3b1fe00b0f5dde=d.fd_salary_id
		set a.fd_3b148bc0c28e48='失败',a.fd_3c754f2a7125a0 = '1183b0b84ee4f581bba001c47a78b2d9',a.fd_3c754a976ddde2=now(),
		a.fd_3afd45029541be=d.fd_payee_name,a.fd_3afd4500f91ae6=d.fd_payee_account,a.fd_3afd4502e34bc0=d.fd_recipient_bank
		where
		<if test="salaryIdList != null and salaryIdList.size() > 0">
			a.fd_3b1fe00b0f5dde in
			<foreach collection="salaryIdList" item="item" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
	</update>

	<!-- 明细再次-发放失败,批量更新中信银行交易流水Model表fd_3b148bc0c28e48为失败,根据 工资明细fdId:fd_3b1fe00b0f5dde -->
	<update id="updateZhongXinMainStatusAndBankInfo">
		UPDATE modeling_simple_main a
		JOIN ekp_db4ed54e25543f4b7a9a b on a.fd_id=b.fd_id
		left join ekp_bank_grant_detail d on b.fd_3b1fe00b0f5dde=d.fd_salary_id
		SET a.extend_data_xml=JSON_SET(a.extend_data_xml,'$[1].fd_3b148bc0c28e48', '失败'
		  , '$[1].fd_3c754f2a7125a0', '1183b0b84ee4f581bba001c47a78b2d9'
		  ,'$[1].fd_3c754a976ddde2', now()
		  ,'$[1].fd_3afd45029541be', d.fd_payee_name
		  ,'$[1].fd_3afd4500f91ae6', d.fd_payee_account
		  ,'$[1].fd_3afd4502e34bc0', d.fd_recipient_bank
		  )
		where
		<if test="salaryIdList != null and salaryIdList.size() > 0">
			b.fd_3b56782982b8b2 in
			<foreach collection="salaryIdList" item="item" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
	</update>

180
</mapper>