BizArchiveInputMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="cn.ezhizao.project.business.order.mapper.BizArchiveInputMapper">
  6. <resultMap type="cn.ezhizao.project.business.order.domain.BizArchiveInput" id="BizArchiveInputResult">
  7. <id column="id" property="id"/>
  8. <result column="source_id" property="sourceId"/>
  9. <result column="referrer_data_source" property="referrerDataSource"/>
  10. <association property="sourceName"
  11. column="{ source_id = source_id, referrer_data_source = referrer_data_source }"
  12. select="getSourceName"/>
  13. <association property="alterNumber" column="{ id = id, from_id = from_id }" select="getAlterNumber"/>
  14. </resultMap>
  15. <select id="getSourceName" resultType="java.lang.String">
  16. <if test="referrer_data_source == null">
  17. select '' as name
  18. </if>
  19. <if test="referrer_data_source == 'company'">
  20. select name from biz_company where biz_company.id = #{source_id}
  21. </if>
  22. <if test="referrer_data_source == 'employee'">
  23. select nick_name from sys_user where sys_user.user_id = #{source_id}
  24. </if>
  25. <if test="referrer_data_source == 'channel'">
  26. select name from biz_channel where biz_channel.id = #{source_id}
  27. </if>
  28. <if test="referrer_data_source == ''">
  29. select '' as name
  30. </if>
  31. </select>
  32. <select id="getAlterNumber" resultType="java.lang.Integer">
  33. select count(1) from biz_archive_input t where t.deleted = 0
  34. <if test="from_id == 0">
  35. and t.from_id = #{id}
  36. </if>
  37. <if test="from_id != 0">
  38. and t.from_id = #{from_id} or t.id = #{from_id}
  39. </if>
  40. </select>
  41. <select id="getList" parameterType="InputVo" resultMap="BizArchiveInputResult">
  42. SELECT
  43. t1.*,
  44. t2.name as company_name,
  45. t2.social_credit_code as social_credit_code,
  46. t3.nick_name as signer_name,
  47. t4.title as source_category_name,
  48. t4.referrer_data_source
  49. FROM biz_archive_input t1
  50. left join biz_company t2 on t2.id = t1.company_id
  51. left join sys_user t3 on t3.user_id = t1.signer_id
  52. left join biz_source t4 on t4.id = t1.source_category_id
  53. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  54. t1.deleted = 0
  55. <if test="fromId != null">AND (t1.from_id = #{fromId} or t1.id = #{fromId})</if>
  56. <if test="id != null and id != ''">AND t1.id = #{id}</if>
  57. <if test="companyName != null and companyName != ''">AND t2.name like concat("%", #{companyName}, "%")</if>
  58. <if test="archiveTypeId != null">and archive_type_id = #{archiveTypeId}</if>
  59. <if test="companyId != null and companyId != ''">AND t1.company_id = #{companyId}</if>
  60. <if test="archiveCode != null and archiveCode != ''">AND t1.archive_code = #{archiveCode}</if>
  61. <if test="startMonth != null ">AND t1.start_month = #{startMonth}</if>
  62. <if test="endMonth != null ">AND t1.end_month = #{endMonth}</if>
  63. <if test="proofUrl != null and proofUrl != ''">AND t1.proof_url = #{proofUrl}</if>
  64. <if test="contractNo != null and contractNo != ''">AND t1.contract_no = #{contractNo}</if>
  65. <if test="formDate != null ">AND t1.form_date = #{formDate}</if>
  66. <if test="amount != null ">AND t1.amount = #{amount}</if>
  67. <if test="verifyStatus != null ">AND t1.verify_status = #{verifyStatus}</if>
  68. <if test="contractType != null ">AND t1.contract_type = #{contractType}</if>
  69. <if test="serviceType != null ">AND t1.service_type = #{serviceType}</if>
  70. <if test="outputDate != null ">AND t1.output_date = #{outputDate}</if>
  71. <if test="monthNum != null ">AND t1.month_num = #{monthNum}</if>
  72. <if test="companyName != null and companyName != '' ">AND t2.name like concat('%', #{companyName}, '%')</if>
  73. <if test="verifyRemark != null and verifyRemark != ''">AND t1.verify_remark = #{verifyRemark}</if>
  74. <if test="tenantId != null">AND t1.tenant_id = #{tenantId}</if>
  75. <if test="isKeepAccount != null">AND <if test="isKeepAccount == 0">not</if> exists (select 1 from
  76. biz_archive_input_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 1)
  77. </if>
  78. <if test="isSocialSecurity != null">AND <if test="isSocialSecurity == 0">not</if> exists (select 1 from
  79. biz_archive_input_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 2)
  80. </if>
  81. <if test="isHousingFund != null">AND <if test="isHousingFund == 0">not</if> exists (select 1 from
  82. biz_archive_input_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 3)
  83. </if>
  84. <if test="isReturnTax != null">AND <if test="isReturnTax == 0">not</if> exists (select 1 from
  85. biz_archive_input_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 4)
  86. </if>
  87. <if test="isRegister != null">AND <if test="isRegister == 0">not</if> exists (select 1 from
  88. biz_archive_input_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 5)
  89. </if>
  90. <if test="isAlter != null">AND <if test="isAlter == 0">not</if> exists (select 1 from
  91. biz_archive_input_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 6)
  92. </if>
  93. <if test="isLogout != null">AND <if test="isLogout == 0">not</if> exists (select 1 from
  94. biz_archive_input_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 7)
  95. </if>
  96. <if test="isQualified != null">AND <if test="isQualified == 0">not</if> exists (select 1 from
  97. biz_archive_input_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 8)
  98. </if>
  99. <if test="isOther != null">AND <if test="isOther == 0">not</if> exists (select 1 from
  100. biz_archive_input_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 9)
  101. </if>
  102. </trim>
  103. </select>
  104. <select id="getListByInput" parameterType="InputVo" resultMap="BizArchiveInputResult">
  105. SELECT
  106. t1.*,
  107. t2.name as company_name,
  108. t2.customer_label_id as customerLabelId,
  109. t5.lable as customerLabelName,
  110. t2.social_credit_code as social_credit_code,
  111. t3.nick_name as signer_name,
  112. t4.title as source_category_name,
  113. t4.referrer_data_source
  114. FROM biz_archive_input t1
  115. left join biz_company t2 on t2.id = t1.company_id
  116. left join sys_user t3 on t3.user_id = t1.signer_id
  117. left join biz_source t4 on t4.id = t1.source_category_id
  118. left join biz_lable t5 on t5.id = t2.customer_label_id
  119. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  120. t1.deleted = 0
  121. <if test="fromId != null">AND (t1.from_id = #{fromId} or t1.id = #{fromId})</if>
  122. <if test="id != null and id != ''">AND t1.id = #{id}</if>
  123. <if test="contractNo!=null and contractNo != '' ">AND t1.contract_no like concat("%",#{contractNo}, "%")</if>
  124. <if test="companyName != null and companyName != ''">AND t2.name like concat("%", #{companyName}, "%")</if>
  125. <if test="archiveTypeId != null">and archive_type_id = #{archiveTypeId}</if>
  126. <if test="companyId != null and companyId != ''">AND t1.company_id = #{companyId}</if>
  127. <if test="archiveCode != null and archiveCode != ''">AND t1.archive_code = #{archiveCode}</if>
  128. <if test="startMonth != null ">AND t1.start_month = #{startMonth}</if>
  129. <if test="endMonth != null ">AND t1.end_month = #{endMonth}</if>
  130. <if test="proofUrl != null and proofUrl != ''">AND t1.proof_url = #{proofUrl}</if>
  131. <if test="boss != null and boss != ''">AND t1.boss like concat("%",#{boss}, "%")</if>
  132. <if test="formDate!= null and formDate.size() ">
  133. AND (
  134. DATE_FORMAT(t1.form_date,'%Y-%m-%d') &gt;= #{formDate[0]}
  135. AND
  136. DATE_FORMAT(t1.form_date,'%Y-%m-%d') &lt;= #{formDate[1]}
  137. )
  138. </if>
  139. <if test="amount != null ">AND t1.amount = #{amount}</if>
  140. <if test="verifyStatus != null ">AND t1.verify_status = #{verifyStatus}</if>
  141. <if test="contractType != null ">AND t1.contract_type = #{contractType}</if>
  142. <if test="serviceType != null ">AND t1.service_type = #{serviceType}</if>
  143. <if test="outputDate != null ">AND t1.output_date = #{outputDate}</if>
  144. <if test="monthNum != null ">AND t1.month_num = #{monthNum}</if>
  145. <if test="companyName != null and companyName != '' ">AND t2.name like concat('%', #{companyName}, '%')</if>
  146. <if test="verifyRemark != null and verifyRemark != ''">AND t1.verify_remark = #{verifyRemark}</if>
  147. <if test="tenantId != null">AND t1.tenant_id = #{tenantId}</if>
  148. <if test="isKeepAccount != null">AND <if test="isKeepAccount == 0">not</if> exists (select 1 from
  149. biz_archive_input_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 1)
  150. </if>
  151. <if test="isSocialSecurity != null">AND <if test="isSocialSecurity == 0">not</if> exists (select 1 from
  152. biz_archive_input_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 2)
  153. </if>
  154. <if test="isHousingFund != null">AND <if test="isHousingFund == 0">not</if> exists (select 1 from
  155. biz_archive_input_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 3)
  156. </if>
  157. <if test="isReturnTax != null">AND <if test="isReturnTax == 0">not</if> exists (select 1 from
  158. biz_archive_input_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 4)
  159. </if>
  160. <if test="isRegister != null">AND <if test="isRegister == 0">not</if> exists (select 1 from
  161. biz_archive_input_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 5)
  162. </if>
  163. <if test="isAlter != null">AND <if test="isAlter == 0">not</if> exists (select 1 from
  164. biz_archive_input_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 6)
  165. </if>
  166. <if test="isLogout != null">AND <if test="isLogout == 0">not</if> exists (select 1 from
  167. biz_archive_input_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 7)
  168. </if>
  169. <if test="isQualified != null">AND <if test="isQualified == 0">not</if> exists (select 1 from
  170. biz_archive_input_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 8)
  171. </if>
  172. <if test="isOther != null">AND <if test="isOther == 0">not</if> exists (select 1 from
  173. biz_archive_input_detail t5 where t5.deleted = 0 and t5.contract_id = t1.id and t5.task_type_id = 9)
  174. </if>
  175. <if test="customerLabelId != null and customerLabelId.size() > 0">
  176. AND t2.customer_label_id IN
  177. <foreach collection="customerLabelId" index="index" item="item" separator="," open="(" close=")">
  178. #{item,jdbcType=BIGINT}
  179. </foreach>
  180. </if>
  181. </trim>
  182. </select>
  183. <update id="removeByIds">
  184. UPDATE biz_archive_input
  185. SET deleted=1
  186. WHERE id in
  187. <foreach collection="ids" item="id" index="index" open="(" separator="," close=")">
  188. #{id}
  189. </foreach>
  190. </update>
  191. <update id="deleteByDate">
  192. update biz_entrust entrust set entrust.deleted = 1,update_time = now(),updater_id = #{updaterId}
  193. where work_order_id = #{workOrderId}
  194. and task_type_id = #{taskTypeId}
  195. <![CDATA[and current_month > #{endDate} ]]>
  196. </update>
  197. <delete id="physicalDelete">
  198. DELETE FROM biz_archive_input
  199. <where>
  200. <if test="id != null">
  201. AND id = #{id}
  202. </if>
  203. <if test="tenantId != null">
  204. AND tenant_id = #{tenantId}
  205. </if>
  206. </where>
  207. </delete>
  208. </mapper>