BizFinancialKeepAccountMapper.xml 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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="cn.ezhizao.project.business.keepAccounts.mapper.BizFinancialKeepAccountMapper">
  4. <!-- 基础的返回map 多表复杂的 自行组合 -->
  5. <resultMap id="BaseResultMap" type="cn.ezhizao.project.business.keepAccounts.domain.BizFinancialKeepAccount" >
  6. <result column="company_id" jdbcType="BIGINT" property="companyId"/>
  7. </resultMap>
  8. <!--带条件的List查询-->
  9. <select id="getList" resultMap="BaseResultMap">
  10. <include refid="getListSql" />
  11. </select>
  12. <!--带条件的List查询 数据总条数-->
  13. <select id="getTotal" resultType="java.lang.Integer">
  14. SELECT COUNT(1) FROM (<include refid="getListSql" />) AS t
  15. </select>
  16. <sql id="getListSql">
  17. SELECT
  18. t1.*, t2.name as company_name,
  19. t3.account_name as from_company_name, t2.tax_type
  20. from biz_financial_keep_account t1
  21. left join biz_company t2 on t2.id = t1.company_id
  22. left join biz_tenant t3 on t3.id = t1.tenant_id
  23. WHERE
  24. t1.deleted = 0
  25. <if test="id != null">
  26. AND t1.id = #{id}
  27. </if>
  28. <if test="keyword != null and keyword != ''">
  29. AND (t2.name like concat('%', #{keyword}, '%') or t2.code like concat('%', #{keyword}, '%'))
  30. </if>
  31. <if test="workOrderId != null and workOrderId != ''">
  32. AND t1.work_order_id = #{workOrderId}
  33. </if>
  34. <if test="taxType != null and taxType != ''">
  35. AND t2.tax_type = #{taxType}
  36. </if>
  37. <if test="fromCompanyName != null and fromCompanyName != ''">
  38. AND (t3.account_name like concat('%', #{fromCompanyName}, '%'))
  39. </if>
  40. <if test="month != null and year != null">
  41. <if test="tenantId != null">
  42. AND exists (select 1 from biz_entrust eb
  43. where eb.deleted = 0
  44. and (eb.to_tenant_id = #{tenantId} or eb.from_tenant_id = #{tenantId})
  45. and date_format(eb.current_month, '%Y%m') = concat(#{year}, #{month})
  46. and eb.work_order_id = t1.work_order_id
  47. )
  48. </if>
  49. <if test="status != null and status != 0">
  50. AND exists (select 1 from biz_financial_keep_account_detail fsd where fsd.financial_keep_account_id = t1.id and
  51. fsd.month = #{month} and fsd.year = #{year} and fsd.status = #{status})
  52. </if>
  53. <if test="status != null and status == 0">
  54. AND not exists (select 1 from biz_financial_keep_account_detail fsd where fsd.financial_keep_account_id = t1.id and
  55. fsd.month = #{month} and fsd.year = #{year})
  56. </if>
  57. </if>
  58. </sql>
  59. <update id="updateByWorkOrderId"
  60. parameterType="java.util.List">
  61. update biz_financial_keep_account set is_stop=1
  62. WHERE work_order_id in
  63. <foreach collection="ids" item="id" index="index" open="(" separator="," close=")">
  64. #{id}
  65. </foreach>
  66. </update>
  67. </mapper>