CustomerGradeMapper.xml 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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.platform.yijia.dao.CustomerGradeMapper">
  4. <!--根据油站ID查询该油站会员成长规则-->
  5. <select id="customerGrouthRuleByStationId" parameterType="String" resultType="map">
  6. SELECT
  7. grouth_value_name AS grouthValueName,
  8. grouth_value_consume AS grouthValueConsume,
  9. grouth_value AS grouthValue
  10. FROM
  11. customer_grouth_rule
  12. <where>
  13. <if test="stationId != null and stationId != ''">
  14. station_id = #{stationId}
  15. </if>
  16. </where>
  17. </select>
  18. <!-- 查询立减满减优惠方案 -->
  19. <select id="getCustomerMarkertPlanList" resultType="map" parameterType="map">
  20. SELECT
  21. id AS id,
  22. grade AS grade,
  23. discount_term AS discountTerm,
  24. discount_amt AS discountAmt,
  25. station_id AS stationId,
  26. vip_discounty_plus AS vipDiscountyPlus,
  27. coupon_plus AS couponPlus,
  28. discount_plan_type AS discountWay,
  29. station_name AS stationName,
  30. oil_name AS oilName
  31. FROM markert_plan
  32. <where>
  33. <if test="stationId != null and stationId != ''">
  34. station_id = #{stationId}
  35. </if>
  36. <if test="oilName != null and oilName != ''">
  37. AND oil_name = #{oilName}
  38. </if>
  39. </where>
  40. ORDER BY discount_amt DESC
  41. </select>
  42. <!-- 查询直降优惠方案 -->
  43. <select id="getCustomerGradeList" resultType="map" parameterType="map">
  44. SELECT
  45. id AS id,
  46. grade AS grade,
  47. discount_way AS discountWay,
  48. gasoil_discount_litre AS gasoilDiscountLitre,
  49. gasoil_discount_litre AS dieseloilDiscountLitre,
  50. member_condit AS memberCondit,
  51. station_id AS stationId,
  52. member_condit_start AS memberConditStart,
  53. member_condit_end AS memberConditEnd,
  54. station_name AS stationName,
  55. oil_name AS oilName
  56. FROM customer_grade_setting
  57. <where>
  58. <if test="stationId != null and stationId != ''">
  59. station_id = #{stationId}
  60. </if>
  61. <if test="oilName != null and oilName != ''">
  62. AND oil_name = #{oilName}
  63. </if>
  64. </where>
  65. </select>
  66. <!--查询客户等级直降信息-->
  67. <select id="getCustomerGradeInfo" parameterType="map" resultType="map">
  68. SELECT
  69. T2.station_name AS stationName,
  70. T2.member_grade AS memberGradeId,
  71. T3.grade AS grade,
  72. T3.discount_way AS discountWay,
  73. T3.oil_name AS oilName,
  74. T3.gasoil_discount_litre AS gasoilDiscountLitre,
  75. T3.member_condit_start AS memberConditStart,
  76. T3.member_condit_end AS memberConditEnd,
  77. T3.member_condit AS memberCondit
  78. FROM
  79. app_user_info AS T1
  80. LEFT JOIN customer_manage AS T2 ON T1.mobile_phone = T2.phone_number
  81. LEFT JOIN customer_grade_setting AS T3 ON T2.station_id = T3.station_id AND T2.oil_name = T3.oil_name
  82. <!-- <if test="grade !=null and grade != ''"> AND T3.id = T2.member_grade </if>-->
  83. <where>
  84. <if test="mobilePhone != null and mobilePhone !=''">
  85. T1.mobile_phone = #{mobilePhone}
  86. </if>
  87. <if test="userType != null and userType !=''">
  88. AND T1.user_type = #{userType}
  89. </if>
  90. <if test="oilName != null and oilName !=''">
  91. AND T2.oil_name = #{oilName}
  92. </if>
  93. <if test="stationId != null and stationId != ''">
  94. AND T2.station_id = #{stationId}
  95. </if>
  96. <if test="blogOpenid != null and blogOpenid != ''">
  97. AND T1.blog_openid = #{blogOpenid}
  98. </if>
  99. <if test="minaOpenid != null and minaOpenid != ''">
  100. AND T1.mina_openid = #{minaOpenid}
  101. </if>
  102. <if test="grade != null and grade != ''">
  103. AND T3.id = #{grade}
  104. </if>
  105. </where>
  106. ORDER BY T3.member_condit_end ASC
  107. </select>
  108. <!--查询客户等级优惠信息-->
  109. <select id="getCustomerGradeInfoByYouHui" parameterType="map" resultType="map">
  110. SELECT
  111. T2.station_name AS stationName,
  112. T3.oil_name AS oilName,
  113. T2.member_grade AS memberGradeId,
  114. T3.grade AS grade,
  115. T3.discount_term AS discountTerm,
  116. T3.gasoil_discount_amt AS gasoilDiscountAmt,
  117. T3.discount_amt AS discountAmt,
  118. T3.vip_discounty_plus AS vipDiscountyPlus,
  119. T3.coupon_plus AS couponPlus,
  120. T3.discount_plan_type AS discountWay
  121. FROM
  122. app_user_info AS T1
  123. LEFT JOIN customer_manage AS T2 ON T1.mobile_phone = T2.phone_number
  124. LEFT JOIN markert_plan AS T3 ON T3.station_id = T2.station_id AND T3.oil_name = T2.oil_name
  125. <!-- <if test="grade !=null and grade != ''"> AND T3.id = T2.member_grade </if>-->
  126. <where>
  127. <if test="mobilePhone != null and mobilePhone !=''">
  128. T1.mobile_phone = #{mobilePhone}
  129. </if>
  130. <if test="userType != null and userType !=''">
  131. AND T1.user_type = #{userType}
  132. </if>
  133. <if test="oilName != null and oilName !=''">
  134. AND T2.oil_name = #{oilName}
  135. </if>
  136. <if test="discountPlanType != null and discountPlanType !=''">
  137. AND T3.discount_plan_type = #{discountPlanType}
  138. </if>
  139. <if test="stationId != null and stationId != ''">
  140. AND T2.station_id = #{stationId}
  141. </if>
  142. <if test="blogOpenid != null and blogOpenid != ''">
  143. AND T1.blog_openid = #{blogOpenid}
  144. </if>
  145. <if test="minaOpenid != null and minaOpenid != ''">
  146. AND T1.mina_openid = #{minaOpenid}
  147. </if>
  148. <if test="grade != null and grade != ''">
  149. AND T3.id = #{grade}
  150. </if>
  151. </where>
  152. ORDER BY T3.discount_amt ASC
  153. </select>
  154. <!-- 判断客户表是否已存在-->
  155. <select id="isExistCustomerByStationIdAndPhoneNumber" parameterType="com.platform.yijia.pojo.CustomerManage" resultType="com.platform.yijia.pojo.CustomerManage">
  156. SELECT
  157. id AS id,
  158. member_id AS memberId,
  159. member_grade AS memberGrade,
  160. phone_number AS phoneNumber,
  161. regtime AS regtime,
  162. station_name AS stationName,
  163. oil_name AS oilName,
  164. liters AS liters,
  165. amt AS amt
  166. FROM
  167. customer_manage
  168. <where>
  169. <if test="phoneNumber !=null and phoneNumber !='' ">
  170. phone_number = #{phoneNumber}
  171. </if>
  172. <if test="stationId !=null and stationId !='' ">
  173. AND station_id = #{stationId}
  174. </if>
  175. <if test="oilName !=null and oilName !='' ">
  176. AND oil_name = #{oilName}
  177. </if>
  178. </where>
  179. </select>
  180. <!-- 营销立减-->
  181. <select id="getMarkertPlanListByDiscountPlanType" resultType="map">
  182. SELECT
  183. id AS id,
  184. grade AS grade,
  185. discount_term AS discountWay,
  186. discount_amt AS discountAmt,
  187. gasoil_discount_amt AS gasoilDiscountAmt,
  188. dieseloil_discount_amt AS dieseloilDiscountAmt,
  189. vip_discounty_plus AS vipDiscountyPlus,
  190. coupon_plus AS couponPlus,
  191. discount_plan_type AS discountPlanType
  192. FROM
  193. markert_plan
  194. <where>
  195. discount_plan_type = "2"
  196. </where>
  197. </select>
  198. </mapper>