CustomerGradeMapper.xml 8.4 KB

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