TicketAwardsPrizeMapper.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. if(t2.prize_type = 'goods' AND t3.title is not null,t3.title,t2.title) as title,
  29. if(t2.prize_type = 'goods' AND t3.title is not null,t3.pic_url,t2.pic_url) as pic_url,
  30. if(t2.prize_type = 'goods' AND t3.value is not null,t3.value,t2.value) as value,
  31. if(t4.coupon_detail is not null, t4.coupon_detail, '') as coupon_detail,
  32. t1.*,
  33. t2.*
  34. from mp_ticket_awards t1
  35. left join mp_ticket_awards_prize t2 on t1.awards_id = t2.awards_id
  36. left join mp_goods t3 on t2.ref_id = t3.goods_id
  37. left join mp_coupon t4 on t2.ref_id = t4.coupon_id
  38. ${ew.customSqlSegment}
  39. </select>
  40. <select id="listByQueryWrapper" resultType="com.qs.mp.admin.domain.TicketAwardsPrize">
  41. select
  42. case t1.prize_type
  43. when 'goods' then if(t2.title is not null, t2.title, t1.title)
  44. when 'coupon' then if(t3.title is not null, t3.title, t1.title)
  45. when 'coupon_pkg' then if(t4.title is not null, t4.title, t1.title)
  46. else t1.title
  47. end as title,
  48. case t1.prize_type
  49. when 'goods' then if(t2.pic_url is not null, t2.pic_url, t1.pic_url)
  50. when 'coupon' then if(t3.pic_url is not null, t3.pic_url, t1.pic_url)
  51. when 'coupon_pkg' then if(t4.pic_url is not null, t4.pic_url, t1.pic_url)
  52. else t1.pic_url
  53. end as pic_url,
  54. case t1.prize_type
  55. when 'goods' then if(t2.value is not null, t2.value, t1.value)
  56. when 'coupon' then if(t3.discount is not null, t3.discount, t1.value)
  57. when 'coupon_pkg' then if(t4.face_price is not null, t4.face_price, t1.value)
  58. else t1.value
  59. end as value,
  60. case t1.prize_type
  61. when 'goods' then if(t2.cost is not null, t2.cost, 0)
  62. else 0
  63. end as cost,
  64. if(t3.coupon_detail is not null, t3.coupon_detail, '') as coupon_detail,
  65. t1.*
  66. from mp_ticket_awards_prize t1
  67. left join mp_goods t2 on t1.ref_id = t2.goods_id
  68. left join mp_coupon t3 on t1.ref_id = t3.coupon_id
  69. left join mp_coupon_pkg t4 on t1.ref_id = t4.id
  70. ${ew.customSqlSegment}
  71. </select>
  72. <select id="listTicketDetailRelGoodsId" resultType="com.qs.mp.admin.domain.TicketBox">
  73. select
  74. t1.box_id,t1.title,t1.status
  75. from mp_ticket_box t1 left join mp_ticket_awards_prize t2 on t1.box_id = t2.box_id
  76. ${ew.customSqlSegment}
  77. </select>
  78. </mapper>