CmSvipHistoryDao.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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.caimei365.manager.dao.svip.CmSvipHistoryDao">
  4. <select id="superFind" resultType="com.caimei365.manager.entity.caimei.svip.CmSvipHistory">
  5. SELECT u.name as clubName, u.username as linkMan, u.bindMobile as mobile,
  6. cs.userId,cs.beginTime,cs.endTime,cs.packageId
  7. FROM cm_svip_history cs
  8. LEFT JOIN club cb ON cs.userId = cb.userId
  9. LEFT JOIN cm_svip_user cu ON cs.userId = cu.userId
  10. left join user u on cs.userId = u.userID
  11. left join cm_svip_package cp on cp.id = cs.packageId
  12. <where>
  13. AND cs.payStatus = '1'
  14. <if test="clubName != null and clubName != ''">
  15. and u.name like concat('%',#{clubName},'%')
  16. </if>
  17. <if test="linkMan != null and linkMan != ''">
  18. and u.username like concat('%',#{linkMan},'%')
  19. </if>
  20. <if test="mobile != null and mobile != ''">
  21. and u.bindMobile LIKE concat('%',#{mobile},'%')
  22. </if>
  23. <if test="startPayTime !=null and startPayTime != '' and endPayTime !=null and endPayTime!=''">
  24. and (cs.payTime between #{startPayTime} and #{endPayTime})
  25. </if>
  26. <if test="startEndTime !=null and startEndTime!='' and endEndTime!=null and endEndTime!=''">
  27. and (cu.endTime between #{startEndTime} and #{endEndTime})
  28. </if>
  29. <if test="packageId !=null and packageId != '' and packageId != 0">
  30. and cp.duration = #{packageId}
  31. </if>
  32. <if test="packageId == 0">
  33. and cs.packageId = 0
  34. </if>
  35. <if test='status == "1"'>
  36. and cu.endTime > NOW()
  37. </if>
  38. <if test='status == "2"'>
  39. and now() > cu.endTime
  40. </if>
  41. </where>
  42. group by cs.userId
  43. order by cs.payTime DESC
  44. </select>
  45. <select id="findEndTime" resultType="com.caimei365.manager.entity.caimei.svip.CmSvipHistory">
  46. select beginTime, endTime, updateTime
  47. from cm_svip_user
  48. where userId = #{userId}
  49. and endTime > now()
  50. </select>
  51. <select id="findProductList" resultType="com.caimei365.manager.entity.caimei.svip.CmSvipProduct">
  52. SELECT
  53. a.id AS "id",
  54. a.productId AS "productId",
  55. a.sort AS "sort",
  56. a.addTime AS "addTime",
  57. a.status as "status",
  58. p.mainImage as "productImage",
  59. p.name as "productName",
  60. s.name as "shopName",
  61. p.includedTax,
  62. p.invoiceType,
  63. p.taxPoint,
  64. p.supplierTaxPoint
  65. FROM cm_svip_product a
  66. left join product p on a.productId = p.productID
  67. left join shop s on s.shopID = p.shopID
  68. <where>
  69. <if test="productId != null and productId != ''">
  70. AND a.productId = #{productId}
  71. </if>
  72. <if test="productName != null and productId != ''">
  73. AND p.name like concat('%',#{productName},'%')
  74. </if>
  75. <if test="shopName != null and productId != ''">
  76. AND s.name like concat('%',#{shopName},'%')
  77. </if>
  78. <if test="status !=null and status == 0">
  79. and a.status=0
  80. </if>
  81. <if test="status !=null and status !='' and status == 1">
  82. and a.status=1
  83. </if>
  84. </where>
  85. order by -sort desc,addTime desc
  86. </select>
  87. <select id="findSku" resultType="com.caimei365.manager.entity.caimei.svip.CmSku">
  88. select price, costPrice, costCheckFlag, costProportional, normalPrice
  89. from cm_sku
  90. where productId = #{productId}
  91. order by price asc
  92. limit 1
  93. </select>
  94. <select id="findSvipSku" resultType="com.caimei365.manager.entity.caimei.svip.CmSku">
  95. select ifnull(discountPrice, 0) as "discountPrice",
  96. ifnull(discount, 0) as "discount",
  97. ifnull(priceType, 0) as "priceType"
  98. from cm_svip_product_sku csps
  99. left join cm_sku cs on cs.productId = csps.productId
  100. where csps.productId = #{productId}
  101. order by cs.price asc
  102. limit 1
  103. </select>
  104. <select id="findPackage" resultType="com.caimei365.manager.entity.caimei.svip.CmSvipPackage">
  105. select price, duration, proportion
  106. from cm_svip_package
  107. </select>
  108. <update id="updatePrice">
  109. update cm_svip_package
  110. set
  111. <if test="price != null">
  112. price = #{price},
  113. </if>
  114. <if test="proportion != null">
  115. proportion = #{proportion}
  116. </if>
  117. where duration = #{duration}
  118. </update>
  119. </mapper>