ElectronicMembershipCardMapper.xml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  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="mina_openid" jdbcType="VARCHAR" property="minaOpenid" />
  10. <result column="customer_no" jdbcType="VARCHAR" property="customerNo" />
  11. <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
  12. <result column="mobile_phone" jdbcType="VARCHAR" property="mobilePhone" />
  13. <result column="amt" jdbcType="DECIMAL" property="amt" />
  14. <result column="card_oils_type" jdbcType="VARCHAR" property="cardOilsType" />
  15. <result column="station_id" jdbcType="INTEGER" property="stationId" />
  16. <result column="station_name" jdbcType="VARCHAR" property="stationName" />
  17. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  18. <result column="recently_time" jdbcType="TIMESTAMP" property="recentlyTime" />
  19. </resultMap>
  20. <!--储蓄卡使用记录返回结果-->
  21. <resultMap id="CardRecordBaseResultMap" type="com.platform.yijia.pojo.CustomerCardUseRecord">
  22. <id column="id" jdbcType="INTEGER" property="id" />
  23. <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
  24. <result column="union_id" jdbcType="VARCHAR" property="unionId" />
  25. <result column="customer_no" jdbcType="VARCHAR" property="customerNo" />
  26. <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
  27. <result column="usage_type" jdbcType="VARCHAR" property="usageType" />
  28. <result column="pay_type" jdbcType="VARCHAR" property="payType" />
  29. <result column="card_oils_type" jdbcType="VARCHAR" property="cardOilsType" />
  30. <result column="amt" jdbcType="DECIMAL" property="amt" />
  31. <result column="present_amt" jdbcType="DECIMAL" property="presentAmt" />
  32. <result column="balance" jdbcType="DECIMAL" property="balance" />
  33. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  34. <result column="station_id" jdbcType="INTEGER" property="stationId" />
  35. <result column="station_name" jdbcType="VARCHAR" property="stationName" />
  36. <result column="status" jdbcType="VARCHAR" property="status" />
  37. </resultMap>
  38. <!--储蓄卡充值规则返回结果-->
  39. <resultMap id="CardSettingBaseResultMap" type="com.platform.yijia.pojo.CustomerCardSetting">
  40. <id column="id" jdbcType="INTEGER" property="id" />
  41. <result column="card_oils_type" jdbcType="VARCHAR" property="cardOilsType" />
  42. <result column="discount_time_setting" jdbcType="VARCHAR" property="discountTimeSetting" />
  43. <result column="discount_time_type" jdbcType="VARCHAR" property="discountTimeType" />
  44. <result column="discount_time" jdbcType="VARCHAR" property="discountTime" />
  45. <result column="present_scale" jdbcType="VARCHAR" property="presentScale" />
  46. <result column="is_discount_coupon" jdbcType="VARCHAR" property="isDiscountCoupon" />
  47. <result column="enjoy_integral_multiple" jdbcType="DATE" property="enjoyIntegralMultiple" />
  48. <result column="station_id" jdbcType="INTEGER" property="stationId" />
  49. <result column="station_name" jdbcType="VARCHAR" property="stationName" />
  50. <result column="create_time" jdbcType="VARCHAR" property="createTime" />
  51. <collection property="customerCardSettingDetailList" resultMap="CardSettingDetailResultMap"/>
  52. </resultMap>
  53. <!--储蓄卡充值规则明细表-->
  54. <resultMap id="CardSettingDetailResultMap" type="com.platform.yijia.pojo.CustomerCardSettingDetail">
  55. <id column="cardSettingDetailId" jdbcType="INTEGER" property="cardSettingDetailId" />
  56. <result column="parent_id" jdbcType="INTEGER" property="parentId"/>
  57. <result column="setting_rule_type" jdbcType="VARCHAR" property="settingRuleType" />
  58. <result column="discount_amt_start" jdbcType="DECIMAL" property="discountAmtStart" />
  59. <result column="discount_amt_end" jdbcType="DECIMAL" property="discountAmtEnd" />
  60. <result column="present_amt" jdbcType="DECIMAL" property="presentAmt"/>
  61. <result column="oil_name" jdbcType="VARCHAR" property="oilName" />
  62. </resultMap>
  63. <!--查询油站电子会员卡(储蓄卡)充值设置规则-->
  64. <select id="getCardRechargeSettingList" parameterType="com.platform.yijia.pojo.CustomerCardSetting" resultMap="CardSettingBaseResultMap">
  65. SELECT
  66. T1.id,
  67. T1.card_oils_type,
  68. T1.discount_time_setting,
  69. T1.discount_time_type,
  70. T1.discount_time,
  71. T1.present_scale,
  72. T1.is_discount_coupon,
  73. T1.enjoy_integral_multiple,
  74. T1.station_id,
  75. T1.station_name,
  76. T1.create_time,
  77. T2.id AS cardSettingDetailId,
  78. T2.parent_id,
  79. T2.setting_rule_type,
  80. T2.discount_amt_start,
  81. T2.discount_amt_end,
  82. T2.present_amt,
  83. T2.oil_name
  84. FROM
  85. customer_card_setting AS T1 LEFT JOIN customer_card_setting_detail AS T2 ON T1.id = T2.parent_id
  86. <where>
  87. <if test="stationId !=null">
  88. T1.station_id = #{stationId}
  89. </if>
  90. <if test="cardOilsType !=null">
  91. AND FIND_IN_SET(#{cardOilsType}, T1.card_oils_type)
  92. </if>
  93. <if test="cardOilsType !=null">
  94. AND T2.oil_name = #{cardOilsType}
  95. </if>
  96. </where>
  97. <if test="orderBy !=null and orderBy !=''">
  98. ORDER BY T2.discount_amt_end ${orderBy}
  99. </if>
  100. </select>
  101. <!--查询客户充值的订单信息-->
  102. <select id="getCardRecordByOrderNo" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord" resultMap="CardRecordBaseResultMap">
  103. SELECT
  104. id,
  105. order_no,
  106. union_id,
  107. customer_name,
  108. usage_type,
  109. pay_type,
  110. card_oils_type,
  111. amt,
  112. present_amt,
  113. create_time,
  114. station_id,
  115. station_name,
  116. status
  117. FROM
  118. customer_card_use_record
  119. <where>
  120. <if test=" orderNo !=null and orderNo !=''">
  121. order_no = #{orderNo}
  122. </if>
  123. </where>
  124. </select>
  125. <!--根据订单号更新用户充值记录的状态-->
  126. <update id="updateCardRecordStatusByOrderNo" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  127. UPDATE
  128. customer_card_use_record
  129. <set>
  130. <if test="status !=null">
  131. status = #{status}
  132. </if>
  133. </set>
  134. <where>
  135. <if test=" orderNo !=null and orderNo !=''">
  136. order_no = #{orderNo}
  137. </if>
  138. </where>
  139. </update>
  140. <!--插入用户电子会员卡的使用记录-->
  141. <insert id="insetCardUseRecord" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord">
  142. INSERT INTO
  143. customer_card_use_record
  144. <trim prefix="(" suffix=")" suffixOverrides=",">
  145. <if test="orderNo !=null">
  146. order_no,
  147. </if>
  148. <if test="unionId !=null">
  149. union_id,
  150. </if>
  151. <if test="customerNo !=null">
  152. customer_no,
  153. </if>
  154. <if test="customerName !=null">
  155. customer_name,
  156. </if>
  157. <if test="usageType !=null">
  158. usage_type,
  159. </if>
  160. <if test="payType !=null">
  161. pay_type,
  162. </if>
  163. <if test="cardOilsType !=null">
  164. card_oils_type,
  165. </if>
  166. <if test="amt !=null">
  167. amt,
  168. </if>
  169. <if test="presentAmt !=null">
  170. present_amt,
  171. </if>
  172. <if test="balance !=null">
  173. balance,
  174. </if>
  175. <if test="createTime !=null">
  176. create_time,
  177. </if>
  178. <if test="stationId !=null">
  179. station_id,
  180. </if>
  181. <if test="stationName !=null">
  182. station_name,
  183. </if>
  184. <if test="status !=null">
  185. status,
  186. </if>
  187. </trim>
  188. <trim prefix="values (" suffix=")" suffixOverrides=",">
  189. <if test="orderNo !=null">
  190. #{orderNo},
  191. </if>
  192. <if test="unionId !=null">
  193. #{unionId},
  194. </if>
  195. <if test="customerNo !=null">
  196. #{customerNo},
  197. </if>
  198. <if test="customerName !=null">
  199. #{customerName},
  200. </if>
  201. <if test="usageType !=null">
  202. #{usageType},
  203. </if>
  204. <if test="payType !=null">
  205. #{payType},
  206. </if>
  207. <if test="cardOilsType !=null">
  208. #{cardOilsType},
  209. </if>
  210. <if test="amt !=null">
  211. #{amt},
  212. </if>
  213. <if test="presentAmt !=null">
  214. #{presentAmt},
  215. </if>
  216. <if test="balance !=null">
  217. #{balance},
  218. </if>
  219. <if test="createTime !=null">
  220. #{createTime},
  221. </if>
  222. <if test="stationId !=null">
  223. #{stationId},
  224. </if>
  225. <if test="stationName !=null">
  226. #{stationName},
  227. </if>
  228. <if test="status !=null">
  229. #{status},
  230. </if>
  231. </trim>
  232. </insert>
  233. <!--查询客户电子会员卡的使用记录-->
  234. <select id="getCardUseRecordList" resultMap="CardRecordBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord">
  235. SELECT
  236. id,
  237. order_no,
  238. union_id,
  239. customer_no,
  240. customer_name,
  241. usage_type,
  242. pay_type,
  243. card_oils_type,
  244. amt,
  245. present_amt,
  246. balance,
  247. create_time,
  248. station_id,
  249. station_name,
  250. status
  251. FROM
  252. customer_card_use_record
  253. <where>
  254. status ="1"
  255. <if test=" usageType !=null and usageType !=''">
  256. AND usage_type = #{usageType}
  257. </if>
  258. <if test="stationId !=null and stationId !=''">
  259. AND station_id = #{stationId}
  260. </if>
  261. <if test="unionId !=null and unionId !=''">
  262. AND union_id = #{unionId}
  263. </if>
  264. </where>
  265. ORDER BY create_time DESC
  266. </select>
  267. <!--查询用户所拥有的储蓄卡-->
  268. <select id="getElectronicCardList" resultMap="CardBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  269. SELECT
  270. id,
  271. union_id,
  272. blog_openid,
  273. mina_openid,
  274. customer_no,
  275. customer_name,
  276. amt,
  277. card_oils_type,
  278. station_id,
  279. station_name,
  280. create_time,
  281. recently_time
  282. FROM
  283. customer_electronic_card
  284. <where>
  285. <if test="stationId !=null and stationId !=''">
  286. station_id = #{stationId}
  287. </if>
  288. <if test="unionId !=null and unionId !=''">
  289. AND union_id = #{unionId}
  290. </if>
  291. <if test="cardOilsType !=null and cardOilsType !=''">
  292. AND card_oils_type = #{cardOilsType}
  293. </if>
  294. </where>
  295. </select>
  296. <!--插入用户电子会员卡-->
  297. <insert id="insetElectronicCard" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  298. INSERT INTO
  299. customer_electronic_card
  300. <trim prefix="(" suffix=")" suffixOverrides=",">
  301. <if test="unionId !=null">
  302. union_id,
  303. </if>
  304. <if test="blogOpenid !=null">
  305. blog_openid,
  306. </if>
  307. <if test="minaOpenid !=null">
  308. mina_openid,
  309. </if>
  310. <if test="customerNo !=null">
  311. customer_no,
  312. </if>
  313. <if test="customerName !=null">
  314. customer_name,
  315. </if>
  316. <if test="mobilePhone !=null">
  317. mobile_phone,
  318. </if>
  319. <if test="amt !=null">
  320. amt,
  321. </if>
  322. <if test="cardOilsType !=null">
  323. card_oils_type,
  324. </if>
  325. <if test="stationId !=null">
  326. station_id,
  327. </if>
  328. <if test="stationName !=null">
  329. station_name,
  330. </if>
  331. <if test="createTime !=null">
  332. create_time,
  333. </if>
  334. <if test="recentlyTime !=null">
  335. recently_time,
  336. </if>
  337. </trim>
  338. <trim prefix="values (" suffix=")" suffixOverrides=",">
  339. <if test="unionId !=null">
  340. #{unionId},
  341. </if>
  342. <if test="blogOpenid !=null">
  343. #{blogOpenid},
  344. </if>
  345. <if test="minaOpenid !=null">
  346. #{minaOpenid},
  347. </if>
  348. <if test="customerNo !=null">
  349. #{customerNo},
  350. </if>
  351. <if test="customerName !=null">
  352. #{customerName},
  353. </if>
  354. <if test="mobilePhone !=null">
  355. #{mobilePhone},
  356. </if>
  357. <if test="amt !=null">
  358. #{amt},
  359. </if>
  360. <if test="cardOilsType !=null">
  361. #{cardOilsType},
  362. </if>
  363. <if test="stationId !=null">
  364. #{stationId},
  365. </if>
  366. <if test="stationName !=null">
  367. #{stationName},
  368. </if>
  369. <if test="createTime !=null">
  370. #{createTime},
  371. </if>
  372. <if test="recentlyTime !=null">
  373. #{recentlyTime},
  374. </if>
  375. </trim>
  376. </insert>
  377. <!--根据unionId获取用户用要充值电子会员卡(储蓄卡)信息-->
  378. <select id="getElectronicCardInfoByUnionId" resultMap="CardBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  379. SELECT
  380. id,
  381. union_id,
  382. blog_openid,
  383. mina_openid,
  384. customer_no,
  385. customer_name,
  386. amt,
  387. card_oils_type,
  388. station_id,
  389. station_name,
  390. create_time,
  391. recently_time
  392. FROM
  393. customer_electronic_card
  394. <where>
  395. <if test="stationId !='' and stationId != null" >
  396. station_id = #{stationId}
  397. </if>
  398. <if test="unionId !=null and unionId !=''">
  399. AND union_id = #{unionId}
  400. </if>
  401. <!-- <if test="blogOpenid !=null and blogOpenid !=''">-->
  402. <!-- AND blog_openid = #{blogOpenid}-->
  403. <!-- </if>-->
  404. <!-- <if test="minaOpenid !=null and minaOpenid !=''">-->
  405. <!-- AND mina_openid = #{minaOpenid}-->
  406. <!-- </if>-->
  407. <if test="cardOilsType !=null and cardOilsType !=''">
  408. AND card_oils_type = #{cardOilsType}
  409. </if>
  410. </where>
  411. </select>
  412. <!--获取用户用要充值电子会员卡(储蓄卡)信息-->
  413. <select id="getElectronicCardInfo" resultMap="CardBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  414. SELECT
  415. id,
  416. union_id,
  417. blog_openid,
  418. mina_openid,
  419. customer_no,
  420. customer_name,
  421. amt,
  422. card_oils_type,
  423. station_id,
  424. station_name,
  425. create_time,
  426. recently_time
  427. FROM
  428. customer_electronic_card
  429. <where>
  430. <if test="id !=null and id !=''">
  431. id = #{id}
  432. </if>
  433. </where>
  434. </select>
  435. <!--更新用户的电子会员卡的信息-->
  436. <update id="updateElectronicCardInfo" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  437. UPDATE
  438. customer_electronic_card
  439. <set>
  440. <if test="amt !=null">
  441. amt = #{amt},
  442. </if>
  443. <if test="recentlyTime !=null">
  444. recently_time = #{recentlyTime}
  445. </if>
  446. </set>
  447. <where>
  448. <if test="id !=null and id != ''">
  449. id = #{id}
  450. </if>
  451. </where>
  452. </update>
  453. <!--根据unionId更新用户的电子会员卡的信息-->
  454. <update id="updateElectronicCardInfoByUnionId" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  455. UPDATE customer_electronic_card
  456. <set>
  457. <if test="unionId !=null">
  458. union_id = #{unionId},
  459. </if>
  460. <if test="blogOpenid !=null">
  461. blog_openid = #{blogOpenid},
  462. </if>
  463. <if test="minaOpenid !=null">
  464. mina_openid = #{minaOpenid},
  465. </if>
  466. <if test="customerNo !=null">
  467. customer_no = #{customerNo},
  468. </if>
  469. <if test="customerName !=null">
  470. customer_name = #{customerName},
  471. </if>
  472. <if test="mobilePhone !=null">
  473. mobile_phone = #{mobilePhone},
  474. </if>
  475. <if test="amt !=null">
  476. amt = #{amt},
  477. </if>
  478. <if test="cardOilsType !=null">
  479. card_oils_type = #{cardOilsType},
  480. </if>
  481. <if test="stationId !=null">
  482. station_id = #{stationId},
  483. </if>
  484. <if test="stationName !=null">
  485. station_name = #{stationName},
  486. </if>
  487. <if test="createTime !=null">
  488. create_time = #{createTime},
  489. </if>
  490. <if test="recentlyTime !=null">
  491. recently_time = #{recentlyTime}
  492. </if>
  493. </set>
  494. <where>
  495. <if test="stationId !='' and stationId != null" >
  496. station_id = #{stationId}
  497. </if>
  498. <!-- <if test="blogOpenid !=null and blogOpenid !=''">-->
  499. <!-- AND blog_openid = #{blogOpenid}-->
  500. <!-- </if>-->
  501. <!-- <if test="minaOpenid !=null and minaOpenid !=''">-->
  502. <!-- AND mina_openid = #{minaOpenid}-->
  503. <!-- </if>-->
  504. <if test="unionId !=null and unionId != ''">
  505. AND union_id = #{unionId}
  506. </if>
  507. <if test="cardOilsType !='' and cardOilsType != null" >
  508. AND card_oils_type = #{cardOilsType}
  509. </if>
  510. </where>
  511. </update>
  512. <!--查询油站的会员卡启用标识 (1、启动 2,停用)-->
  513. <select id="getStationCardEnabledFlag" parameterType="Integer" resultType="String">
  514. SELECT
  515. card_enabled_flag AS cardEnabledFlag
  516. FROM
  517. station_pay
  518. <where>
  519. <if test="stationId !='' and stationId != null" >
  520. station_id = #{stationId}
  521. </if>
  522. </where>
  523. </select>
  524. <!--根据小程序用户openId查询客户电子会员卡信息-->
  525. <select id="getElectronicCardInfoByMinaOpenId" resultMap="CardBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  526. SELECT
  527. id,
  528. union_id,
  529. blog_openid,
  530. mina_openid,
  531. customer_no,
  532. customer_name,
  533. amt,
  534. card_oils_type,
  535. station_id,
  536. station_name,
  537. create_time,
  538. recently_time
  539. FROM
  540. customer_electronic_card
  541. <where>
  542. <if test="stationId !='' and stationId != null" >
  543. station_id = #{stationId}
  544. </if>
  545. <if test="minaOpenid !='' and minaOpenid != null" >
  546. AND mina_openid = #{minaOpenid}
  547. </if>
  548. <if test="cardOilsType !='' and cardOilsType != null" >
  549. AND card_oils_type = #{cardOilsType}
  550. </if>
  551. </where>
  552. </select>
  553. </mapper>