TicketAwardsPrizeMapper.xml 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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.qs.mp.admin.mapper.TicketAwardsPrizeMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.qs.mp.admin.domain.TicketAwardsPrize">
  6. <id column="prize_id" property="prizeId" />
  7. <result column="box_id" property="boxId" />
  8. <result column="awards_id" property="awardsId" />
  9. <result column="ref_id" property="refId" />
  10. <result column="title" property="title" />
  11. <result column="pic_url" property="picUrl" />
  12. <result column="prize_type" property="prizeType" />
  13. <result column="quantity" property="quantity" />
  14. <result column="cashed_qty" property="cashedQty" />
  15. <result column="remain_qty" property="remainQty" />
  16. <result column="value" property="value" />
  17. <result column="sort_weight" property="sortWeight" />
  18. <result column="is_deleted" property="isDeleted" />
  19. <result column="created_time" property="createdTime" />
  20. <result column="updated_time" property="updatedTime" />
  21. </resultMap>
  22. <!-- 通用查询结果列 -->
  23. <sql id="Base_Column_List">
  24. prize_id, box_id, awards_id, ref_id, title, pic_url, prize_type, quantity, cashed_qty, remain_qty, value, sort_weight, is_deleted, created_time, updated_time
  25. </sql>
  26. <select id="listPrizeVO" resultType="com.qs.mp.admin.domain.vo.TicketAwardsPrizeVO">
  27. select
  28. case t2.prize_type
  29. when 'goods' then if(t3.title is not null, t3.title, t2.title)
  30. when 'coupon' then if(t4.title is not null, t4.title, t2.title)
  31. else t2.title
  32. end as title,
  33. if(t2.prize_type = 'goods' AND t3.title is not null,t3.pic_url,t2.pic_url) as pic_url,
  34. if(t2.prize_type = 'goods' AND t3.value is not null,t3.value,t2.value) as value,
  35. if(t4.coupon_detail is not null, t4.coupon_detail, '') as coupon_detail,
  36. t1.*,
  37. t2.*
  38. from mp_ticket_awards t1
  39. left join mp_ticket_awards_prize t2 on t1.awards_id = t2.awards_id
  40. left join mp_goods t3 on t2.ref_id = t3.goods_id
  41. left join mp_coupon t4 on t2.ref_id = t4.coupon_id
  42. ${ew.customSqlSegment}
  43. </select>
  44. <select id="listByQueryWrapper" resultType="com.qs.mp.admin.domain.TicketAwardsPrize">
  45. select
  46. case t1.prize_type
  47. when 'goods' then if(t2.title is not null, t2.title, t1.title)
  48. when 'coupon' then if(t3.title is not null, t3.title, t1.title)
  49. when 'coupon_pkg' then if(t4.title is not null, t4.title, t1.title)
  50. else t1.title
  51. end as title,
  52. case t1.prize_type
  53. when 'goods' then if(t2.pic_url is not null, t2.pic_url, t1.pic_url)
  54. when 'coupon' then if(t3.pic_url is not null, t3.pic_url, t1.pic_url)
  55. when 'coupon_pkg' then if(t4.pic_url is not null, t4.pic_url, t1.pic_url)
  56. else t1.pic_url
  57. end as pic_url,
  58. case t1.prize_type
  59. when 'goods' then if(t2.value is not null, t2.value, t1.value)
  60. when 'coupon' then if(t3.discount is not null, t3.discount, t1.value)
  61. when 'coupon_pkg' then if(t4.face_price is not null, t4.face_price, t1.value)
  62. else t1.value
  63. end as value,
  64. case t1.prize_type
  65. when 'goods' then if(t2.cost is not null, t2.cost, 0)
  66. else 0
  67. end as cost,
  68. if(t3.coupon_detail is not null, t3.coupon_detail, '') as coupon_detail,
  69. t1.*
  70. from mp_ticket_awards_prize t1
  71. left join mp_goods t2 on t1.ref_id = t2.goods_id
  72. left join mp_coupon t3 on t1.ref_id = t3.coupon_id
  73. left join mp_coupon_pkg t4 on t1.ref_id = t4.id
  74. ${ew.customSqlSegment}
  75. </select>
  76. <select id="listTicketDetailRelGoodsId" resultType="com.qs.mp.admin.domain.TicketBox">
  77. select
  78. DISTINCT t1.box_id,t1.title,t1.status
  79. from mp_ticket_box t1 left join mp_ticket_awards_prize t2 on t1.box_id = t2.box_id
  80. ${ew.customSqlSegment}
  81. </select>
  82. </mapper>