DyoaRecordMapper.xml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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="getMaxRealAmountCreatedTime" resultType="java.util.Date">
  27. select max(order_datetime) from dyoa_record where mbs_type = 'REAL_AMOUNT'
  28. </select>
  29. <select id="getMaxClaimDate" resultType="java.util.Date">
  30. select max(order_datetime) from dyoa_record where mbs_type = 'REAL_AMOUNT_CLAIM'
  31. </select>
  32. <select id="selectOrderFundIdByDyoaOrderId" resultType="com.dayou.entity.DyoaRecord">
  33. SELECT
  34. m.dyoa_id,
  35. f.id as mbsId
  36. FROM
  37. (
  38. SELECT
  39. mbs_id,
  40. dyoa_id,
  41. ( CASE mbs_type WHEN 'MAJOR_ORDER' THEN 'MAJOR_BUSINESS' WHEN 'PERSONAL_ORDER' THEN 'PERSONAL_BUSINESS'
  42. WHEN 'ASSETS_ORDER' THEN 'ASSET_BUSINESS'
  43. END ) AS mbs_type
  44. FROM
  45. dyoa_record
  46. WHERE
  47. mbs_type IN ( 'MAJOR_ORDER','PERSONAL_ORDER','ASSETS_ORDER' )) m
  48. LEFT JOIN order_fund f ON (
  49. f.business_id = m.mbs_id
  50. AND f.business_type = m.mbs_type) where f.id is not null GROUP BY m.dyoa_id
  51. </select>
  52. <select id="getMaxFinanceInvoiceCreatedTime" resultType="java.util.Date">
  53. select max(order_datetime) from dyoa_record where mbs_type = 'FINANCE_INVOICE'
  54. </select>
  55. </mapper>