BizFinancialSalaryMapper.xml 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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.salary.mapper.BizFinancialSalaryMapper">
  6. <resultMap type="cn.ezhizao.project.business.salary.domain.BizFinancialSalary" id="BizFinancialSalaryResult">
  7. <id column="id" property="id"/>
  8. <result column="company_id" jdbcType="BIGINT" property="companyId"/>
  9. <association property="serviceName" select="getServiceName" column="company_id"></association>
  10. </resultMap>
  11. <select id="getList" parameterType="BizFinancialSalary" resultMap="BizFinancialSalaryResult">
  12. SELECT t1.*, t2.name as company_name,t2.tax_type, t3.account_name as from_company_name
  13. FROM biz_financial_salary t1
  14. left join biz_company t2 on t2.id = t1.company_id
  15. left join biz_tenant t3 on t3.id = t1.tenant_id
  16. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  17. t1.deleted = 0
  18. <if test="isStop != null ">AND is_stop = #{isStop}</if>
  19. <if test="companyName != null ">AND t2.name like concat('%', #{companyName}, '%')</if>
  20. <if test="taxType != null and taxType != ''">
  21. AND t2.tax_type = #{taxType}
  22. </if>
  23. <if test="isZero != null">
  24. AND t2.is_zero = #{isZero}
  25. </if>
  26. <if test="fromCompanyName != null and fromCompanyName != ''">
  27. AND (t3.account_name like concat('%', #{fromCompanyName}, '%'))
  28. </if>
  29. <if test="principal != null and principal != ''">
  30. AND (t2.leader_id=#{principal} OR t2.adviser_id=#{principal})
  31. </if>
  32. <if test="month != null and year != null">
  33. <if test="tenantId != null">
  34. AND exists (select 1 from biz_entrust eb
  35. where eb.deleted = 0
  36. and (eb.to_tenant_id = #{tenantId} or eb.from_tenant_id = #{tenantId})
  37. and date_format(eb.current_month, '%Y%m') = concat(#{year}, #{month})
  38. and eb.work_order_id = t1.work_order_id
  39. )
  40. </if>
  41. <if test="status != null and status != 0">
  42. AND exists (select 1 from biz_financial_salary_detail fsd where fsd.financial_salary_id = t1.id and
  43. fsd.month = #{month} and fsd.year = #{year} and fsd.status = #{status})
  44. </if>
  45. <if test="status != null and status == 0">
  46. AND not exists (select 1 from biz_financial_salary_detail fsd where fsd.financial_salary_id = t1.id and
  47. fsd.month = #{month} and fsd.year = #{year})
  48. </if>
  49. <if test="hasIndividualIncomeTax != null">
  50. AND exists (select 1 from biz_financial_salary_detail fsd where fsd.financial_salary_id = t1.id and
  51. has_individual_income_tax=#{hasIndividualIncomeTax} and fsd.month = #{month} and fsd.year = #{year})
  52. </if>
  53. </if>
  54. </trim>
  55. </select>
  56. <select id="getServiceName" resultType="String">
  57. SELECT s.nick_name FROM sys_user s
  58. WHERE s.user_id =(SELECT leader_id FROM biz_company WHERE id=#{company_id})
  59. </select>
  60. <delete id="physicalDelete">
  61. DELETE FROM biz_financial_salary
  62. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  63. <if test="id != null">
  64. id = #{id} AND
  65. </if>
  66. <!-- 删除条件为其他外键可以在这里加 -->
  67. </trim>
  68. </delete>
  69. </mapper>