ElectronicMembershipCardMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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.ElectronicMembershipCardMapper">
  4. <!--储蓄卡返回结果-->
  5. <resultMap id="CardBaseResultMap" type="com.platform.yijia.pojo.CustomerElectronicCard">
  6. <id column="id" jdbcType="INTEGER" property="id" />
  7. <result column="union_id" jdbcType="VARCHAR" property="unionId" />
  8. <result column="blog_openid" jdbcType="VARCHAR" property="blogOpenid" />
  9. <result column="customer_no" jdbcType="VARCHAR" property="customerNo" />
  10. <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
  11. <result column="amt" jdbcType="DECIMAL" property="amt" />
  12. <result column="card_oils_type" jdbcType="VARCHAR" property="cardOilsType" />
  13. <result column="station_id" jdbcType="INTEGER" property="stationId" />
  14. <result column="station_name" jdbcType="VARCHAR" property="stationName" />
  15. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  16. <result column="recently_time" jdbcType="TIMESTAMP" property="recentlyTime" />
  17. </resultMap>
  18. <!--储蓄卡使用记录返回结果-->
  19. <resultMap id="CardRecordBaseResultMap" type="com.platform.yijia.pojo.CustomerCardUseRecord">
  20. <id column="id" jdbcType="INTEGER" property="id" />
  21. <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
  22. <result column="union_id" jdbcType="VARCHAR" property="unionId" />
  23. <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
  24. <result column="usage_type" jdbcType="VARCHAR" property="usageType" />
  25. <result column="pay_type" jdbcType="VARCHAR" property="payType" />
  26. <result column="card_oils_type" jdbcType="VARCHAR" property="cardOilsType" />
  27. <result column="amt" jdbcType="DECIMAL" property="amt" />
  28. <result column="present_amt" jdbcType="DECIMAL" property="presentAmt" />
  29. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  30. <result column="station_id" jdbcType="INTEGER" property="stationId" />
  31. <result column="station_name" jdbcType="VARCHAR" property="stationName" />
  32. <result column="status" jdbcType="VARCHAR" property="status" />
  33. </resultMap>
  34. <!--储蓄卡充值规则返回结果-->
  35. <resultMap id="CardSettingBaseResultMap" type="com.platform.yijia.pojo.CustomerCardSetting">
  36. <id column="id" jdbcType="INTEGER" property="id" />
  37. <result column="card_oils_type" jdbcType="VARCHAR" property="cardOilsType" />
  38. <result column="discount_time" jdbcType="VARCHAR" property="discountTime" />
  39. <result column="present_scale" jdbcType="VARCHAR" property="presentScale" />
  40. <result column="is_discount_coupon" jdbcType="VARCHAR" property="isDiscountCoupon" />
  41. <result column="enjoy_integral_multiple" jdbcType="DATE" property="enjoyIntegralMultiple" />
  42. <result column="station_id" jdbcType="INTEGER" property="stationId" />
  43. <result column="station_name" jdbcType="VARCHAR" property="stationName" />
  44. <result column="create_time" jdbcType="VARCHAR" property="createTime" />
  45. <collection property="customerCardSettingDetailList" resultMap="CardSettingDetailResultMap"/>
  46. </resultMap>
  47. <!--储蓄卡充值规则明细表-->
  48. <resultMap id="CardSettingDetailResultMap" type="com.platform.yijia.pojo.CustomerCardSettingDetail">
  49. <id column="cardSettingDetailId" jdbcType="INTEGER" property="cardSettingDetailId" />
  50. <result column="parent_id" jdbcType="INTEGER" property="parentId"/>
  51. <result column="setting_rule_type" jdbcType="VARCHAR" property="settingRuleType" />
  52. <result column="discount_amt_term" jdbcType="DECIMAL" property="discountAmtTerm" />
  53. <result column="present_amt" jdbcType="DECIMAL" property="presentAmt"/>
  54. </resultMap>
  55. <!--查询油站电子会员卡(储蓄卡)充值设置规则-->
  56. <select id="getCardRechargeSettingList" parameterType="com.platform.yijia.pojo.CustomerCardSetting" resultMap="CardSettingBaseResultMap">
  57. SELECT
  58. T1.id,
  59. T1.card_oils_type,
  60. T1.discount_time,
  61. T1.present_scale,
  62. T1.is_discount_coupon,
  63. T1.enjoy_integral_multiple,
  64. T1.station_id,
  65. T1.station_name,
  66. T1.create_time,
  67. T2.id AS cardSettingDetailId,
  68. T2.parent_id,
  69. T2.setting_rule_type,
  70. T2.discount_amt_term,
  71. T2.present_amt
  72. FROM
  73. customer_card_setting AS T1 LEFT JOIN customer_card_setting_detail AS T2 ON T1.id = T2.parent_id
  74. <where>
  75. <if test="stationId !=null">
  76. T1.station_id = #{stationId}
  77. </if>
  78. <if test="cardOilsType !=null">
  79. AND T1.card_oils_type = #{cardOilsType}
  80. </if>
  81. </where>
  82. <if test="orderBy !=null and orderBy !=''">
  83. ORDER BY discount_amt_term ${orderBy}
  84. </if>
  85. </select>
  86. <!--查询客户充值的订单信息-->
  87. <select id="getCardRecordByOrderNo" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord" resultMap="CardRecordBaseResultMap">
  88. SELECT
  89. id,
  90. order_no,
  91. union_id,
  92. customer_name,
  93. usage_type,
  94. pay_type,
  95. card_oils_type,
  96. amt,
  97. present_amt,
  98. create_time,
  99. station_id,
  100. station_name,
  101. status
  102. FROM
  103. customer_card_use_record
  104. <where>
  105. <if test=" orderNo !=null and orderNo !=''">
  106. order_no = #{orderNo}
  107. </if>
  108. </where>
  109. </select>
  110. <!--根据订单号更新用户充值记录的状态-->
  111. <update id="updateCardRecordStatusByOrderNo" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  112. UPDATE
  113. customer_card_use_record
  114. <set>
  115. <if test="status !=null">
  116. status = #{status}
  117. </if>
  118. </set>
  119. <where>
  120. <if test=" orderNo !=null and orderNo !=''">
  121. order_no = #{orderNo}
  122. </if>
  123. </where>
  124. </update>
  125. <!--插入用户电子会员卡的使用记录-->
  126. <insert id="insetCardUseRecord" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord">
  127. INSERT INTO
  128. customer_card_use_record
  129. <trim prefix="(" suffix=")" suffixOverrides=",">
  130. <if test="orderNo !=null">
  131. order_no,
  132. </if>
  133. <if test="unionId !=null">
  134. union_id,
  135. </if>
  136. <if test="customerName !=null">
  137. customer_name,
  138. </if>
  139. <if test="usageType !=null">
  140. usage_type,
  141. </if>
  142. <if test="payType !=null">
  143. pay_type,
  144. </if>
  145. <if test="cardOilsType !=null">
  146. card_oils_type,
  147. </if>
  148. <if test="amt !=null">
  149. amt,
  150. </if>
  151. <if test="presentAmt !=null">
  152. present_amt,
  153. </if>
  154. <if test="createTime !=null">
  155. create_time,
  156. </if>
  157. <if test="stationId !=null">
  158. station_id,
  159. </if>
  160. <if test="stationName !=null">
  161. station_name,
  162. </if>
  163. <if test="status !=null">
  164. status,
  165. </if>
  166. </trim>
  167. <trim prefix="values (" suffix=")" suffixOverrides=",">
  168. <if test="orderNo !=null">
  169. #{orderNo},
  170. </if>
  171. <if test="unionId !=null">
  172. #{unionId},
  173. </if>
  174. <if test="customerName !=null">
  175. #{customerName},
  176. </if>
  177. <if test="usageType !=null">
  178. #{usageType},
  179. </if>
  180. <if test="payType !=null">
  181. #{payType},
  182. </if>
  183. <if test="cardOilsType !=null">
  184. #{cardOilsType},
  185. </if>
  186. <if test="amt !=null">
  187. #{amt},
  188. </if>
  189. <if test="presentAmt !=null">
  190. #{presentAmt},
  191. </if>
  192. <if test="createTime !=null">
  193. #{createTime},
  194. </if>
  195. <if test="stationId !=null">
  196. #{stationId},
  197. </if>
  198. <if test="stationName !=null">
  199. #{stationName},
  200. </if>
  201. <if test="status !=null">
  202. #{status},
  203. </if>
  204. </trim>
  205. </insert>
  206. <!--查询客户电子会员卡的使用记录-->
  207. <select id="getCardUseRecordList" resultMap="CardRecordBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord">
  208. SELECT
  209. id,
  210. order_no,
  211. union_id,
  212. customer_name,
  213. usage_type,
  214. pay_type,
  215. card_oils_type,
  216. amt,
  217. present_amt,
  218. create_time,
  219. station_id,
  220. station_name,
  221. status
  222. FROM
  223. customer_card_use_record
  224. <where>
  225. status ="1"
  226. <if test=" usageType !=null and usageType !=''">
  227. AND usage_type = #{usageType}
  228. </if>
  229. <if test="stationId !=null and stationId !=''">
  230. AND station_id = #{stationId}
  231. </if>
  232. <if test="unionId !=null and unionId !=''">
  233. AND union_id = #{unionId}
  234. </if>
  235. </where>
  236. ORDER BY create_time DESC
  237. </select>
  238. <!--查询用户所拥有的储蓄卡-->
  239. <select id="getElectronicCardList" resultMap="CardBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  240. SELECT
  241. id,
  242. union_id,
  243. blog_openid,
  244. customer_no,
  245. customer_name,
  246. amt,
  247. card_oils_type,
  248. station_id,
  249. station_name,
  250. create_time,
  251. recently_time
  252. FROM
  253. customer_electronic_card
  254. <where>
  255. <if test="stationId !=null and stationId !=''">
  256. station_id = #{stationId}
  257. </if>
  258. <if test="unionId !=null and unionId !=''">
  259. AND union_id = #{unionId}
  260. </if>
  261. <if test="cardOilsType !=null and cardOilsType !=''">
  262. AND card_oils_type = #{cardOilsType}
  263. </if>
  264. </where>
  265. </select>
  266. <!--获取用户用要充值电子会员卡(储蓄卡)信息-->
  267. <select id="getElectronicCardInfo" resultMap="CardBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  268. SELECT
  269. id,
  270. union_id,
  271. blog_openid,
  272. customer_no,
  273. customer_name,
  274. amt,
  275. card_oils_type,
  276. station_id,
  277. station_name,
  278. create_time,
  279. recently_time
  280. FROM
  281. customer_electronic_card
  282. <where>
  283. <if test="id !=null and id !=''">
  284. id = #{id}
  285. </if>
  286. </where>
  287. </select>
  288. <!--更新用户的电子会员卡的信息-->
  289. <update id="updateElectronicCardInfo" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  290. UPDATE
  291. customer_electronic_card
  292. <set>
  293. <if test="amt !=null">
  294. amt = #{amt},
  295. </if>
  296. <if test="recentlyTime !=null">
  297. recently_time = #{recentlyTime}
  298. </if>
  299. </set>
  300. <where>
  301. <if test="id !=null and id != ''">
  302. id = #{id}
  303. </if>
  304. </where>
  305. </update>
  306. <!--根据unionId更新用户的电子会员卡的信息-->
  307. <update id="updateElectronicCardInfoByUnionId" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  308. UPDATE customer_electronic_card
  309. <set>
  310. <if test="amt !=null">
  311. amt = #{amt},
  312. </if>
  313. <if test="recentlyTime !=null">
  314. recently_time = #{recentlyTime}
  315. </if>
  316. </set>
  317. <where>
  318. <if test="unionId !=null and unionId != ''">
  319. union_id = #{unionId}
  320. </if>
  321. </where>
  322. </update>
  323. <!--查询油站的会员卡启用标识 (1、启动 2,停用)-->
  324. <select id="getStationCardEnabledFlag" parameterType="Integer" resultType="String">
  325. SELECT
  326. card_enabled_flag AS cardEnabledFlag
  327. FROM
  328. station_pay
  329. <where>
  330. <if test="stationId !='' and stationId != null" >
  331. station_id = #{stationId}
  332. </if>
  333. </where>
  334. </select>
  335. </mapper>