CustomerMapper.xml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.minpay.db.table.own.mapper.CustomerMapper">
  4. <select id="queryCustomer" resultType="hashmap" parameterType="hashmap">
  5. SELECT
  6. CIF_ID userId,
  7. CIF_CERT_NO certNo,
  8. CIF_BUSINESS_TERM businessTerm,
  9. CIF_BUSINESS_SCOPE businessScope,
  10. CIF_REG_CAPITAL regCapital,
  11. CIF_REG_DATE regDate,
  12. CIF_REG_ADDRESS address,
  13. CIF_COR_NAME corName,
  14. CIF_COR_MOBILE corMobile,
  15. CIF_COR_ID_NUM corIdNum,
  16. CIF_COR_ID_HEADS idHead,
  17. CIF_COR_ID_TAILS idTails,
  18. CIF_COR_ID_TERMBEG corIdTermbeg,
  19. CIF_COR_ID_TERMEND corIdTermend,
  20. CIF_ACC_NO accNo,
  21. CIF_ACC_BANK accBank,
  22. CIF_CONTACTS contacts,
  23. CIF_CONTACTS_MOBILE contactsMobile,
  24. a.usr_id usrId,
  25. a.USR_PHONE userName,
  26. CIF_NAME companyName,
  27. CIF_GRADE_LEVEL gradeLevel,
  28. cast(IFNULL(CIF_CREDITS_BALANCE,"0") as DECIMAL(20,6)) balance,
  29. SUBSTR(a.USR_CREATEDATE, 1, 8) createTime,
  30. SUBSTR(CIF_CREATE_TIME, 1, 8) corCreateTime,
  31. b.USR_NAME customerName,
  32. b.USR_ID customerId,
  33. cast(CIF_CREDITS as DECIMAL(20,6)) creditLine,
  34. cast((CIF_CREDITS - CIF_CREDITS_BALANCE) as DECIMAL(20,6)) remainingMargin,
  35. CIF_STT state,
  36. IFNULL(CAP_APPLY_NO, '') 'applyNo',
  37. a.USR_STT stt
  38. FROM
  39. tp_company_info
  40. left join im_user a on a.USR_COMID = CIF_ID
  41. left join im_user b on b.USR_ID = CIF_MANAGER_NO
  42. left join tp_credit_apply on CAP_COM_ID = CIF_ID and CAP_STT ='00'
  43. WHERE 1=1
  44. <if test="userName != null and userName != ''">
  45. and a.USR_PHONE like CONCAT('%',#{userName, jdbcType=VARCHAR},'%')
  46. </if>
  47. <if test="userId != null and userId != ''">
  48. and CIF_ID like CONCAT('%',#{userId, jdbcType=VARCHAR},'%')
  49. </if>
  50. <if test="companyName != null and companyName != ''">
  51. and CIF_NAME like CONCAT('%',#{companyName, jdbcType=VARCHAR},'%')
  52. </if>
  53. <if test="beginDate != null and beginDate != ''">
  54. and CIF_REG_DATE &gt;= #{beginDate, jdbcType=VARCHAR}
  55. </if>
  56. <if test="endDate != null and endDate != ''">
  57. and CIF_REG_DATE &lt;= #{endDate, jdbcType=VARCHAR}
  58. </if>
  59. <if test="state != null and state != ''">
  60. and CIF_STT = #{state, jdbcType=VARCHAR}
  61. </if>
  62. <if test="imUserId != null and imUserId != ''">
  63. and CIF_MANAGER_NO = #{imUserId, jdbcType=VARCHAR}
  64. </if>
  65. order by CIF_CREATE_TIME desc
  66. </select>
  67. <select id="queryAccInfManage" resultType="hashmap" parameterType="hashmap">
  68. SELECT
  69. ACF_NO userId,
  70. ACF_NAME companyName,
  71. cast(ACF_AMT as DECIMAL(20,6)) creditLine,
  72. cast((ACF_AMT - (select ifnull(sum(ADL_TRXAMOUT),0) from tp_acc_detail where ADL_ACCNO = ACF_NO)) as DECIMAL(20,6)) balance,
  73. cast((select IFNULL(SUM(ADL_TRXAMOUT),0) from tp_acc_detail where ADL_ACCNO = ACF_NO) as DECIMAL(20,6)) remainingMargin,
  74. ACF_CREATE_TIME createTime
  75. FROM
  76. tp_acc_inf
  77. WHERE 1=1
  78. <if test="userId != null and userId != ''">
  79. and ACF_NO like CONCAT('%',#{userId, jdbcType=VARCHAR},'%')
  80. </if>
  81. <if test="companyName != null and companyName != ''">
  82. and ACF_NAME like CONCAT('%',#{companyName, jdbcType=VARCHAR},'%')
  83. </if>
  84. <if test="beginDate != null and beginDate != ''">
  85. and SUBSTR(ACF_CREATE_TIME,1,8) &gt;= #{beginDate, jdbcType=VARCHAR}
  86. </if>
  87. <if test="endDate != null and endDate != ''">
  88. and SUBSTR(ACF_CREATE_TIME,1,8) &lt;= #{endDate, jdbcType=VARCHAR}
  89. </if>
  90. order by ACF_CREATE_TIME desc
  91. </select>
  92. <select id="queryAccInfDetail" resultType="hashmap" parameterType="hashmap">
  93. SELECT
  94. cast(ADL_TRXAMOUT as DECIMAL(20,6)) loaningAmt,
  95. ADL_CREATE_TIME applyDate,
  96. ADL_REL_NO orderno,
  97. CIF_NAME corName
  98. FROM
  99. tp_acc_detail,
  100. tp_order_inf,
  101. tp_company_info
  102. WHERE OIF_ORDERNO = ADL_REL_NO
  103. and OIF_COM_ID = CIF_ID
  104. and ADL_ACCNO = #{accNo, jdbcType=VARCHAR}
  105. <if test="corName != null and corName != ''">
  106. and CIF_NAME like CONCAT('%',#{corName, jdbcType=VARCHAR},'%')
  107. </if>
  108. <if test="beginDate != null and beginDate != ''">
  109. and SUBSTR(ADL_CREATE_TIME,1,8) &gt;= #{beginDate, jdbcType=VARCHAR}
  110. </if>
  111. <if test="endDate != null and endDate != ''">
  112. and SUBSTR(ADL_CREATE_TIME,1,8) &lt;= #{endDate, jdbcType=VARCHAR}
  113. </if>
  114. order by ADL_CREATE_TIME desc
  115. </select>
  116. <select id = "cregitQuery" resultType="hashmap" parameterType="hashmap">
  117. select
  118. a.CAP_APPLY_NO id,
  119. c.CIF_ID userId,
  120. u.USR_PHONE userName,
  121. c.CIF_NAME companyName,
  122. c.CIF_GRADE_LEVEL gradeLevel,
  123. cast(a.CAP_QUOTA as DECIMAL(20,6)) balance,
  124. c.CIF_REG_DATE createTime,
  125. b.USR_NAME customerName,
  126. ifnull(a.CAP_APPROVER, '00') approver
  127. from
  128. tp_credit_apply a,im_user u,tp_company_info c
  129. LEFT JOIN im_user b ON b.USR_ID = c.CIF_MANAGER_NO
  130. where
  131. a.CAP_COM_ID = c.CIF_ID
  132. and u.USR_ID = a.CAP_USER
  133. and CAP_STT in ('01','02')
  134. <if test="approverType != null and approverType != ''">
  135. and ifnull(a.CAP_APPROVER, '00') = #{approverType, jdbcType=VARCHAR}
  136. </if>
  137. </select>
  138. <select id = "queryCreditApplyFlow" resultType="hashmap" parameterType="hashmap">
  139. SELECT
  140. AAH_STT stt,
  141. AAH_RESULT result,
  142. USR_NAME userName,
  143. AAH_AUTHTIME authTime,
  144. AAH_OPINION opinion
  145. FROM
  146. tp_approve_auth,
  147. im_user u
  148. WHERE 1=1
  149. AND AAH_USER = u.USR_ID
  150. AND AAH_APPLYNO = #{applyNo, jdbcType=VARCHAR}
  151. </select>
  152. <select id = "queryCreditApply" resultType="hashmap" parameterType="hashmap">
  153. SELECT
  154. CAP_QUOTA quota,
  155. CAP_APPLY_NO applyNo,
  156. CAP_BEGIN begin,
  157. CAP_END end,
  158. CAP_CREATETIME createTime,
  159. CAP_STT stt,
  160. CAP_REMARK remark
  161. FROM
  162. tp_credit_apply
  163. WHERE 1=1
  164. and CAP_COM_ID = #{userId, jdbcType=VARCHAR}
  165. and CAP_STT ='00'
  166. ORDER BY CAP_CREATETIME DESC
  167. </select>
  168. <select id="queryUserList" parameterType="hashmap" resultType="com.minpay.common.bean.UserModel">
  169. SELECT
  170. iu.USR_COMID AS 'userId',
  171. iu.USR_LOGONNAME AS 'userName',
  172. tci.CIF_REG_DATE AS 'regDate',
  173. tci.CIF_NAME AS 'companyName',
  174. tci.CIF_GRADE_LEVEL AS 'gradeLevel',
  175. tci.CIF_CREDITS_BALANCE AS 'creditsBalance',
  176. iuu.USR_NAME AS 'managerName',
  177. (
  178. CASE tci.CIF_STT
  179. WHEN '01' THEN
  180. '未实名'
  181. WHEN '02' THEN
  182. '实名认证中'
  183. WHEN '03' THEN
  184. '已申请'
  185. WHEN '04' THEN
  186. '已提交'
  187. WHEN '05' THEN
  188. '审批中'
  189. WHEN '06' THEN
  190. '审批通过'
  191. WHEN '07' THEN
  192. '审批未通过'
  193. END
  194. ) AS 'stt'
  195. FROM
  196. im_user iu
  197. INNER JOIN tp_company_info tci ON iu.USR_COMID = tci.CIF_ID
  198. INNER JOIN im_user iuu ON iuu.USR_ID = tci.CIF_MANAGER_NO
  199. <where>
  200. <if test="userId != null and userId != ''">
  201. iu.USR_COMID like CONCAT('%',#{userId},'%')
  202. </if>
  203. <if test="userName != null and userName != ''">
  204. and iu.USR_LOGONNAME like CONCAT('%',#{userName},'%')
  205. </if>
  206. <if test="companyName != null and companyName != ''">
  207. and tci.CIF_NAME like CONCAT('%',#{companyName},'%')
  208. </if>
  209. <if test="beginDate != null and beginDate != ''">
  210. <![CDATA[and tci.CIF_REG_DATE >= #{beginDate}]]>
  211. </if>
  212. <if test="endDate != null and endDate != ''">
  213. <![CDATA[and tci.CIF_REG_DATE <= #{endDate}]]>
  214. </if>
  215. <if test="state != null and state != ''">
  216. and CIF_STT = #{state}
  217. </if>
  218. </where>
  219. </select>
  220. </mapper>