BizFinancialSalaryMapper.xml 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. </resultMap>
  9. <select id="getList" parameterType="BizFinancialSalary" resultMap="BizFinancialSalaryResult">
  10. SELECT t1.*, t2.name as company_name, t2.tax_type, t3.account_name as from_company_name
  11. FROM biz_financial_salary t1
  12. left join biz_company t2 on t2.id = t1.company_id
  13. left join biz_tenant t3 on t3.id = t1.tenant_id
  14. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  15. t1.deleted = 0
  16. <if test="isStop != null ">AND is_stop = #{isStop}</if>
  17. <if test="companyName != null ">AND t2.name like concat('%', #{companyName}, '%')</if>
  18. <if test="taxType != null and taxType != ''">
  19. AND t2.tax_type = #{taxType}
  20. </if>
  21. <if test="workOrderId != null">
  22. AND t1.work_order_id = #{workOrderId}
  23. </if>
  24. <if test="fromCompanyName != null and fromCompanyName != ''">
  25. AND (t3.account_name like concat('%', #{fromCompanyName}, '%'))
  26. </if>
  27. <if test="month != null and year != null">
  28. <if test="tenantId != null">
  29. AND exists (select 1 from biz_entrust eb
  30. where eb.deleted = 0
  31. and (eb.to_tenant_id = #{tenantId} or eb.from_tenant_id = #{tenantId})
  32. and date_format(eb.current_month, '%Y%m') = concat(#{year}, #{month})
  33. and eb.work_order_id = t1.work_order_id
  34. )
  35. </if>
  36. <if test="status != null and status != 0">
  37. AND exists (select 1 from biz_financial_salary_detail fsd where fsd.financial_salary_id = t1.id and
  38. fsd.month = #{month} and fsd.year = #{year} and fsd.status = #{status})
  39. </if>
  40. <if test="status != null and status == 0">
  41. AND not exists (select 1 from biz_financial_salary_detail fsd where fsd.financial_salary_id = t1.id and
  42. fsd.month = #{month} and fsd.year = #{year})
  43. </if>
  44. </if>
  45. </trim>
  46. </select>
  47. <delete id="physicalDelete">
  48. DELETE FROM biz_financial_salary
  49. <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
  50. <if test="id != null">
  51. id = #{id} AND
  52. </if>
  53. <!-- 删除条件为其他外键可以在这里加 -->
  54. </trim>
  55. </delete>
  56. <update id="updateByWorkOrderId"
  57. parameterType="java.util.List">
  58. update biz_financial_salary set is_stop=1
  59. WHERE work_order_id in
  60. <foreach collection="ids" item="id" index="index" open="(" separator="," close=")">
  61. #{id}
  62. </foreach>
  63. </update>
  64. </mapper>