ItemBrokerageSequenceMapper.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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.dayou.mapper.ItemBrokerageSequenceMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.dayou.vo.BrokerageSequenceVO">
  6. <result column="id" property="id" />
  7. <result column="deleted" property="deleted" />
  8. <result column="created" property="created" />
  9. <result column="modified" property="modified" />
  10. <result column="user_id" property="userId" />
  11. <result column="userName" property="userName" />
  12. <result column="brokerage_amount" property="brokerageAmount" />
  13. <result column="embody" property="embody" />
  14. <result column="remark" property="remark" />
  15. <result column="cate" property="cate"/>
  16. <collection property="details" ofType="com.dayou.vo.BrokerageSequenceDetailVO" select="selectSequenceDetail" column="id"/>
  17. </resultMap>
  18. <!-- 通用查询结果列 -->
  19. <sql id="Base_Column_List">
  20. id,
  21. deleted,
  22. created,
  23. modified,
  24. user_id, brokerage_amount, embody, remark
  25. </sql>
  26. <select id="getPage" parameterType="com.dayou.vo.BrokerageSequenceVO" resultMap="BaseResultMap">
  27. select ibs.*,u.name as userName from item_brokerage_sequence ibs left join user u on u.id = ibs.user_id
  28. where u.deleted = 0 and ibs.deleted = 0
  29. <if test="vo!=null and vo.userName!=null and vo.userName!='' ">
  30. and u.name like concat ('%',#{vo.userName},'%')
  31. </if>
  32. <if test="vo!=null and vo.cate!=null and vo.cate!='' ">
  33. and ibs.cate =#{vo.cate}
  34. </if>
  35. <if test="vo!=null and vo.year!=null ">
  36. and ibs.year = #{vo.year}
  37. </if>
  38. <if test="vo!=null and vo.month!=null ">
  39. and ibs.month = #{vo.month}
  40. </if>
  41. <if test="vo!=null and vo.userIds!=null and vo.userIds.size!=0">
  42. and ibs.user_id in
  43. <foreach collection="vo.userIds" open="(" close=")" separator="," item="userId">
  44. #{userId}
  45. </foreach>
  46. </if>
  47. order by ibs.id DESC
  48. </select>
  49. <select id="selectSequenceDetail" parameterType="java.lang.Long" resultType="com.dayou.vo.BrokerageSequenceDetailVO">
  50. SELECT
  51. ibsd.*,
  52. ibd.predict_amount,
  53. ibd.brokerage_rule,
  54. ibd.brokerage_mode ,
  55. s.name as stageName,
  56. i.name as itemName,
  57. pc.amount as paymentAmount,
  58. pc.name as paymentName
  59. FROM
  60. item_brokerage_sequence_detail ibsd
  61. LEFT JOIN item_brokerage_detail ibd ON ibd.id = ibsd.brokerage_detail_id
  62. LEFT JOIN item_stage s ON s.id = ibd.brokerage_stage_id
  63. left join item_brokerage_general g on g.id = ibd.general_id
  64. left join item i on i.id = g.item_id
  65. left join payment_collection pc on ibsd.payment_id = pc.id
  66. WHERE
  67. ibsd.deleted = 0
  68. AND ibd.deleted = 0
  69. and g.deleted = 0
  70. and i.deleted = 0
  71. and ibsd.sequence_id = #{id}
  72. </select>
  73. <select id="deduction" parameterType="com.dayou.vo.BrokerageSequenceVO" resultType="com.dayou.vo.BrokerageSequenceVO">
  74. SELECT
  75. ibs.id,
  76. ibs.created,
  77. (case ibs.cate when 'DEFAULT_AHEAD' then
  78. - ibs.brokerage_amount when 'ONCE_SETTLE' then -ibs.brokerage_amount else ibs.brokerage_amount end) brokerageAmount,
  79. ibs.embody,
  80. ibs.cate,
  81. u.NAME AS userName from item_brokerage_sequence ibs left join user u on u.id = ibs.user_id
  82. where u.deleted = 0 and ibs.deleted = 0
  83. <if test="vo!=null and vo.userName!=null and vo.userName!='' ">
  84. and u.name like concat ('%',#{vo.userName},'%')
  85. </if>
  86. <if test="vo!=null and vo.cate!=null and vo.cate!='' ">
  87. and ibs.cate =#{vo.cate}
  88. </if>
  89. <if test="vo!=null and vo.userIds!=null and vo.userIds.size!=0">
  90. and ibs.user_id in
  91. <foreach collection="vo.userIds" open="(" close=")" separator="," item="userId">
  92. #{userId}
  93. </foreach>
  94. </if>
  95. order by ibs.id DESC
  96. </select>
  97. <select id="xList" parameterType="com.dayou.vo.BrokerageSequenceVO" resultType="com.dayou.vo.BrokerageSequenceVO">
  98. select ibs.*,u.name as userName from item_brokerage_sequence ibs left join user u on u.id = ibs.user_id
  99. where u.deleted = 0 and ibs.deleted = 0
  100. <if test="vo!=null and vo.userName!=null and vo.userName!='' ">
  101. and u.name like concat ('%',#{vo.userName},'%')
  102. </if>
  103. <if test="vo!=null and vo.cate!=null and vo.cate!='' ">
  104. and ibs.cate =#{vo.cate}
  105. </if>
  106. <if test="vo!=null and vo.year!=null ">
  107. and ibs.year = #{vo.year}
  108. </if>
  109. <if test="vo!=null and vo.month!=null ">
  110. and ibs.month = #{vo.month}
  111. </if>
  112. <if test="vo!=null and vo.userIds!=null and vo.userIds.size!=0">
  113. and ibs.user_id in
  114. <foreach collection="vo.userIds" open="(" close=")" separator="," item="userId">
  115. #{userId}
  116. </foreach>
  117. </if>
  118. order by ibs.id DESC
  119. </select>
  120. </mapper>