DyoaRecordMapper.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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.DyoaRecordMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.dayou.entity.DyoaRecord">
  6. <result column="id" property="id" />
  7. <result column="modified" property="modified" />
  8. <result column="created" property="created" />
  9. <result column="deleted" property="deleted" />
  10. <result column="mbs_type" property="mbsType" />
  11. <result column="mbs_id" property="mbsId" />
  12. <result column="dyoa_id" property="dyoaId" />
  13. <result column="user_id" property="userId" />
  14. </resultMap>
  15. <!-- 通用查询结果列 -->
  16. <sql id="Base_Column_List">
  17. id,
  18. modified,
  19. created,
  20. deleted,
  21. mbs_type, mbs_id, dyoa_id, user_id
  22. </sql>
  23. <select id="getMaxOrderTime" resultType="java.util.Date">
  24. select max(order_datetime) from dyoa_record where mbs_type = 'PERSONAL_ORDER'
  25. </select>
  26. <select id="getMaxPersonalTargetTime" resultType="java.util.Date">
  27. select max(order_datetime) from dyoa_record where mbs_type = 'PERSONAL_TARGET'
  28. </select>
  29. <select id="getMaxRealAmountCreatedTime" resultType="java.util.Date">
  30. select max(order_datetime) from dyoa_record where mbs_type = 'REAL_AMOUNT'
  31. </select>
  32. <select id="getMaxClaimDate" resultType="java.util.Date">
  33. select max(order_datetime) from dyoa_record where mbs_type = 'REAL_AMOUNT_CLAIM'
  34. </select>
  35. <select id="selectOrderFundIdByDyoaOrderId" resultType="com.dayou.entity.DyoaRecord">
  36. SELECT
  37. m.dyoa_id,
  38. f.id as mbsId
  39. FROM
  40. (
  41. SELECT
  42. mbs_id,
  43. dyoa_id,
  44. ( CASE mbs_type WHEN 'MAJOR_ORDER' THEN 'MAJOR_BUSINESS' WHEN 'PERSONAL_ORDER' THEN 'PERSONAL_BUSINESS'
  45. WHEN 'ASSETS_ORDER' THEN 'ASSET_BUSINESS'
  46. END ) AS mbs_type
  47. FROM
  48. dyoa_record
  49. WHERE
  50. mbs_type IN ( 'MAJOR_ORDER','PERSONAL_ORDER','ASSETS_ORDER' )) m
  51. LEFT JOIN order_fund f ON (
  52. f.business_id = m.mbs_id
  53. AND f.business_type = m.mbs_type) where f.id is not null GROUP BY m.dyoa_id
  54. </select>
  55. <select id="getMaxFinanceInvoiceCreatedTime" resultType="java.util.Date">
  56. select max(order_datetime) from dyoa_record where mbs_type = 'FINANCE_INVOICE'
  57. </select>
  58. <select id="getMbsIdByDyOAId" parameterType="java.lang.String" resultType="java.lang.Long">
  59. select mbs_id from dyoa_record where dyoa_id = #{id} and mbs_type = 'MAJOR_ORDER'
  60. </select>
  61. <select id="getMbsIdByDyOAIdForAssets" parameterType="java.lang.String" resultType="java.lang.Long">
  62. select mbs_id from dyoa_record where dyoa_id = #{id} and mbs_type = 'ASSETS_ORDER'
  63. </select>
  64. <select id="findPersonalProduction" resultType="com.dayou.dto.history.HisPersonalProduction">
  65. select id,bgInRepoTime,bgOutRepoTime from dy_order_loan
  66. where masterName IS NOT NULL
  67. and deleted = 0
  68. </select>
  69. <select id="getPersonalTargetId" parameterType="java.lang.String" resultType="java.lang.Long">
  70. select id from personal_target where personal_id = (select mbs_id from dyoa_record where dyoa_id = #{id})
  71. </select>
  72. <select id="findAssetsProduction" resultType="com.dayou.dto.history.HisPersonalProduction">
  73. select id,bgInTime as bgInRepoTime,bgOutTime as bgOutRepoTime,confirmTime from dy_assets
  74. where
  75. deleted = 0
  76. </select>
  77. <select id="getMbsIdByDyOAiDForInvoice" parameterType="java.lang.String" resultType="com.dayou.entity.FinanceInvoice">
  78. SELECT
  79. *
  80. FROM
  81. finance_invoice
  82. WHERE
  83. id = (
  84. SELECT
  85. mbs_id
  86. FROM
  87. dyoa_record
  88. WHERE
  89. dyoa_id = #{dyoaId}
  90. AND mbs_type = 'FINANCE_INVOICE')
  91. </select>
  92. <select id="getMbsRealAmountId" resultType="java.lang.Long">
  93. select mbs_id from dyoa_record where mbs_type = #{name} and dyoa_id = #{incomeId} and deleted = 0
  94. </select>
  95. <select id="getMembersAndSignerInDyoa" parameterType="java.lang.Long" resultType="java.lang.String">
  96. select dyoa_id from dyoa_record where mbs_type = 'ASSETS_ORDER' and mbs_id = #{id} and deleted = 0
  97. </select>
  98. <select id="getDyoaIdByMbsPersonalId" parameterType="java.lang.Long" resultType="java.lang.String">
  99. select dyoa_id from dyoa_record where deleted = 0 and mbs_type = 'PERSONAL_ORDER' and mbs_id = #{personalId}
  100. </select>
  101. </mapper>