ElectronicMembershipCardMapper.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  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="blog_openid" jdbcType="VARCHAR" property="blogOpenid" />
  25. <result column="mina_openid" jdbcType="VARCHAR" property="minaOpenid" />
  26. <result column="union_id" jdbcType="VARCHAR" property="unionId" />
  27. <result column="ali_id" jdbcType="VARCHAR" property="aliId" />
  28. <result column="customer_no" jdbcType="VARCHAR" property="customerNo" />
  29. <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
  30. <result column="mobile_phone" jdbcType="VARCHAR" property="mobilePhone" />
  31. <result column="usage_type" jdbcType="VARCHAR" property="usageType" />
  32. <result column="pay_type" jdbcType="VARCHAR" property="payType" />
  33. <result column="card_oils_type" jdbcType="VARCHAR" property="cardOilsType" />
  34. <result column="amt" jdbcType="DECIMAL" property="amt" />
  35. <result column="present_amt" jdbcType="DECIMAL" property="presentAmt" />
  36. <result column="balance" jdbcType="DECIMAL" property="balance" />
  37. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  38. <result column="station_id" jdbcType="INTEGER" property="stationId" />
  39. <result column="station_name" jdbcType="INTEGER" property="stationName" />
  40. <result column="status" jdbcType="VARCHAR" property="status" />
  41. <result column="oilsCardName" jdbcType="VARCHAR" property="oilsCardName" />
  42. </resultMap>
  43. <!--储蓄卡充值规则返回结果-->
  44. <resultMap id="CardSettingBaseResultMap" type="com.platform.yijia.pojo.CustomerCardSetting">
  45. <id column="id" jdbcType="INTEGER" property="id" />
  46. <result column="card_oils_type" jdbcType="VARCHAR" property="cardOilsType" />
  47. <result column="discount_time_setting" jdbcType="VARCHAR" property="discountTimeSetting" />
  48. <result column="discount_time_type" jdbcType="VARCHAR" property="discountTimeType" />
  49. <result column="discount_time" jdbcType="VARCHAR" property="discountTime" />
  50. <result column="present_scale" jdbcType="VARCHAR" property="presentScale" />
  51. <result column="is_discount_coupon" jdbcType="VARCHAR" property="isDiscountCoupon" />
  52. <result column="enjoy_integral_multiple" jdbcType="DATE" property="enjoyIntegralMultiple" />
  53. <result column="station_id" jdbcType="INTEGER" property="stationId" />
  54. <result column="create_time" jdbcType="VARCHAR" property="createTime" />
  55. <result column="is_market" jdbcType="VARCHAR" property="isMarket" />
  56. <result column="is_grade_setting" jdbcType="VARCHAR" property="isGradeSetting" />
  57. <collection property="customerCardSettingDetailList" resultMap="CardSettingDetailResultMap"/>
  58. </resultMap>
  59. <!--储蓄卡充值规则明细表-->
  60. <resultMap id="CardSettingDetailResultMap" type="com.platform.yijia.pojo.CustomerCardSettingDetail">
  61. <id column="cardSettingDetailId" jdbcType="INTEGER" property="cardSettingDetailId" />
  62. <result column="parent_id" jdbcType="INTEGER" property="parentId"/>
  63. <result column="setting_rule_type" jdbcType="VARCHAR" property="settingRuleType" />
  64. <result column="discount_amt_start" jdbcType="DECIMAL" property="discountAmtStart" />
  65. <result column="discount_amt_end" jdbcType="DECIMAL" property="discountAmtEnd" />
  66. <result column="present_amt" jdbcType="DECIMAL" property="presentAmt"/>
  67. <result column="card_type" jdbcType="VARCHAR" property="cardType"/>
  68. <result column="status" jdbcType="VARCHAR" property="status" />
  69. </resultMap>
  70. <!--查询油站电子会员卡(储蓄卡)充值设置规则-->
  71. <select id="getCardRechargeSettingList" parameterType="com.platform.yijia.pojo.CustomerCardSetting" resultMap="CardSettingBaseResultMap">
  72. SELECT
  73. T1.id,
  74. T1.card_oils_type,
  75. T1.discount_time_setting,
  76. T1.discount_time_type,
  77. T1.discount_time,
  78. T1.present_scale,
  79. T1.is_discount_coupon,
  80. T1.enjoy_integral_multiple,
  81. T1.station_id,
  82. T1.create_time,
  83. T1.is_market,
  84. T1.is_grade_setting,
  85. T2.id AS cardSettingDetailId,
  86. T2.parent_id,
  87. T2.setting_rule_type,
  88. T2.discount_amt_start,
  89. T2.discount_amt_end,
  90. T2.present_amt,
  91. T2.card_type,
  92. T2.status
  93. FROM
  94. customer_card_setting AS T1 LEFT JOIN customer_card_setting_detail AS T2 ON T1.id = T2.parent_id
  95. <where>
  96. T2.del_flag ="0"
  97. <if test="stationId !=null">
  98. AND T1.station_id = #{stationId}
  99. </if>
  100. <if test="cardOilsType !=null">
  101. AND FIND_IN_SET(#{cardOilsType}, T1.card_oils_type)
  102. </if>
  103. <if test="cardOilsType !=null">
  104. AND T2.card_type = #{cardOilsType}
  105. </if>
  106. </where>
  107. <if test="orderBy !=null and orderBy !=''">
  108. ORDER BY T2.discount_amt_start ${orderBy}
  109. </if>
  110. </select>
  111. <!--查询客户充值的订单信息-->
  112. <select id="getCardRecordByOrderNo" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord" resultMap="CardRecordBaseResultMap">
  113. SELECT
  114. T1.id,
  115. T1.order_no,
  116. T1.union_id,
  117. T1.ali_id,
  118. T2.blog_nick_name AS customer_name,
  119. T2.blog_openid,
  120. T2.mina_openid,
  121. T2.mobile_phone,
  122. T1.usage_type,
  123. T1.pay_type,
  124. T1.card_oils_type,
  125. T1.amt,
  126. T1.balance,
  127. T1.present_amt,
  128. T1.create_time,
  129. T1.station_id,
  130. T1.status,
  131. T3.dept_name AS station_name,
  132. T4.dict_label AS oilsCardName
  133. FROM
  134. customer_card_use_record AS T1
  135. LEFT JOIN app_user_info AS T2 ON T1.station_id = T2.station_id AND T1.union_id =T2.union_id
  136. LEFT JOIN sys_dept AS T3 ON T1.station_id = T3.dept_id
  137. LEFT JOIN sys_dict_data AS T4 ON T1.card_oils_type = T4.dict_value
  138. <where>
  139. T4.dict_type ="oil"
  140. <if test=" orderNo !=null and orderNo !=''">
  141. AND T1.order_no = #{orderNo}
  142. </if>
  143. </where>
  144. </select>
  145. <!--根据订单号更新用户充值记录的状态-->
  146. <update id="updateCardRecordStatusByOrderNo" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord">
  147. UPDATE
  148. customer_card_use_record
  149. <set>
  150. <if test="status !=null">
  151. status = #{status},
  152. </if>
  153. <if test="payType !=null">
  154. pay_type = #{payType},
  155. </if>
  156. <if test="balance !=null">
  157. balance = #{balance}
  158. </if>
  159. </set>
  160. <where>
  161. <if test=" orderNo !=null and orderNo !=''">
  162. order_no = #{orderNo}
  163. </if>
  164. </where>
  165. </update>
  166. <!--插入用户电子会员卡的充值使用记录-->
  167. <insert id="insetCardUseRecordRecharge" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord">
  168. INSERT INTO customer_card_use_record
  169. <trim prefix="(" suffix=")" suffixOverrides=",">
  170. <if test="orderNo !=null">
  171. order_no,
  172. </if>
  173. <if test="unionId !=null">
  174. union_id,
  175. </if>
  176. <if test="aliId !=null">
  177. ali_id,
  178. </if>
  179. <if test="customerNo !=null">
  180. customer_no,
  181. </if>
  182. <if test="customerName !=null">
  183. customer_name,
  184. </if>
  185. <if test="usageType !=null">
  186. usage_type,
  187. </if>
  188. <if test="payType !=null">
  189. pay_type,
  190. </if>
  191. <if test="cardOilsType !=null">
  192. card_oils_type,
  193. </if>
  194. <if test="amt !=null">
  195. amt,
  196. </if>
  197. <if test="presentAmt !=null">
  198. present_amt,
  199. </if>
  200. <if test="balance !=null">
  201. balance,
  202. </if>
  203. <if test="createTime !=null">
  204. create_time,
  205. </if>
  206. <if test="stationId !=null">
  207. station_id,
  208. </if>
  209. <if test="status !=null">
  210. status,
  211. </if>
  212. </trim>
  213. <trim prefix="values (" suffix=")" suffixOverrides=",">
  214. <if test="orderNo !=null">
  215. #{orderNo},
  216. </if>
  217. <if test="unionId !=null">
  218. #{unionId},
  219. </if>
  220. <if test="aliId !=null">
  221. #{aliId},
  222. </if>
  223. <if test="customerNo !=null">
  224. #{customerNo},
  225. </if>
  226. <if test="customerName !=null">
  227. #{customerName},
  228. </if>
  229. <if test="usageType !=null">
  230. #{usageType},
  231. </if>
  232. <if test="payType !=null">
  233. #{payType},
  234. </if>
  235. <if test="cardOilsType !=null">
  236. #{cardOilsType},
  237. </if>
  238. <if test="amt !=null">
  239. #{amt},
  240. </if>
  241. <if test="presentAmt !=null">
  242. #{presentAmt},
  243. </if>
  244. <if test="balance !=null">
  245. #{balance},
  246. </if>
  247. <if test="createTime !=null">
  248. #{createTime},
  249. </if>
  250. <if test="stationId !=null">
  251. #{stationId},
  252. </if>
  253. <if test="status !=null">
  254. #{status},
  255. </if>
  256. </trim>
  257. </insert>
  258. <!--插入用户电子会员卡的消费使用记录-->
  259. <insert id="insetCardUseRecordConsumption" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord">
  260. INSERT INTO customer_card_use_record
  261. <trim prefix="(" suffix=")" suffixOverrides=",">
  262. <if test="orderNo !=null">
  263. order_no,
  264. </if>
  265. <if test="unionId !=null">
  266. union_id,
  267. </if>
  268. <if test="customerNo !=null">
  269. customer_no,
  270. </if>
  271. <if test="customerName !=null">
  272. customer_name,
  273. </if>
  274. <if test="usageType !=null">
  275. usage_type,
  276. </if>
  277. <if test="payType !=null">
  278. pay_type,
  279. </if>
  280. <if test="cardOilsType !=null">
  281. card_oils_type,
  282. </if>
  283. <if test="amt !=null">
  284. amt,
  285. </if>
  286. <if test="balance !=null">
  287. balance,
  288. </if>
  289. <if test="createTime !=null">
  290. create_time,
  291. </if>
  292. <if test="stationId !=null">
  293. station_id,
  294. </if>
  295. <if test="status !=null">
  296. status,
  297. </if>
  298. </trim>
  299. <trim prefix="values (" suffix=")" suffixOverrides=",">
  300. <if test="orderNo !=null">
  301. #{orderNo},
  302. </if>
  303. <if test="unionId !=null">
  304. #{unionId},
  305. </if>
  306. <if test="customerNo !=null">
  307. #{customerNo},
  308. </if>
  309. <if test="customerName !=null">
  310. #{customerName},
  311. </if>
  312. <if test="usageType !=null">
  313. #{usageType},
  314. </if>
  315. <if test="payType !=null">
  316. #{payType},
  317. </if>
  318. <if test="cardOilsType !=null">
  319. #{cardOilsType},
  320. </if>
  321. <if test="amt !=null">
  322. #{amt},
  323. </if>
  324. <if test="balance !=null">
  325. #{balance},
  326. </if>
  327. <if test="createTime !=null">
  328. #{createTime},
  329. </if>
  330. <if test="stationId !=null">
  331. #{stationId},
  332. </if>
  333. <if test="status !=null">
  334. #{status},
  335. </if>
  336. </trim>
  337. </insert>
  338. <!--充值-->
  339. <sql id="Base_Column_List_recharge">
  340. SELECT
  341. id,
  342. order_no,
  343. union_id,
  344. customer_no,
  345. customer_name,
  346. usage_type,
  347. pay_type,
  348. card_oils_type,
  349. amt,
  350. present_amt,
  351. balance,
  352. create_time,
  353. station_id,
  354. status
  355. FROM
  356. customer_card_record_recharge
  357. <where>
  358. status ="1"
  359. <if test="stationId !=null and stationId !=''">
  360. AND station_id = #{stationId}
  361. </if>
  362. <if test="unionId !=null and unionId !=''">
  363. AND union_id = #{unionId}
  364. </if>
  365. </where>
  366. ORDER BY create_time DESC
  367. </sql>
  368. <!--消费-->
  369. <sql id="Base_Column_List_consumption">
  370. SELECT
  371. id,
  372. order_no,
  373. union_id,
  374. customer_no,
  375. customer_name,
  376. usage_type,
  377. pay_type,
  378. card_oils_type,
  379. amt,
  380. balance,
  381. create_time,
  382. station_id,
  383. status
  384. FROM
  385. customer_card_record_consumption
  386. <where>
  387. <if test="stationId !=null and stationId !=''">
  388. AND station_id = #{stationId}
  389. </if>
  390. <if test="unionId !=null and unionId !=''">
  391. AND union_id = #{unionId}
  392. </if>
  393. </where>
  394. ORDER BY create_time DESC
  395. </sql>
  396. <!--全部-->
  397. <sql id="Base_Column_List">
  398. SELECT
  399. union_id, station_id, amt, present_amt, balance, card_oils_type, usage_type, create_time, `status`
  400. FROM customer_card_record_recharge
  401. <where>
  402. status ="1"
  403. <if test="stationId !=null and stationId !=''">
  404. AND station_id = #{stationId}
  405. </if>
  406. <if test="unionId !=null and unionId !=''">
  407. AND union_id = #{unionId}
  408. </if>
  409. </where>
  410. UNION ALL
  411. SELECT
  412. union_id, station_id, amt, "0" AS present_amt, balance, card_oils_type, usage_type,create_time, `status`
  413. FROM customer_card_record_consumption
  414. <where>
  415. status ="1"
  416. <if test="stationId !=null and stationId !=''">
  417. AND station_id = #{stationId}
  418. </if>
  419. <if test="unionId !=null and unionId !=''">
  420. AND union_id = #{unionId}
  421. </if>
  422. </where>
  423. ORDER BY create_time DESC
  424. </sql>
  425. <!--查询客户电子会员卡的使用记录-->
  426. <select id="getCardUseRecordList" resultMap="CardRecordBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord">
  427. SELECT
  428. union_id, station_id, amt, present_amt, usage_type, balance, card_oils_type, usage_type, create_time, `status`
  429. FROM customer_card_use_record
  430. <where>
  431. status ="1"
  432. <if test="stationId !=null and stationId !=''">
  433. AND station_id = #{stationId}
  434. </if>
  435. <if test="unionId !=null and unionId !=''">
  436. AND union_id = #{unionId}
  437. </if>
  438. <if test="usageType !=null and usageType !=''">
  439. AND usage_type = #{usageType}
  440. </if>
  441. </where>
  442. ORDER BY create_time DESC
  443. </select>
  444. <!-- 根据设置的卡规则来查询用户所拥有的储蓄卡 -->
  445. <select id="getElectronicCardListBycardOilsTypeArray" resultMap="CardBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  446. SELECT
  447. id,
  448. union_id,
  449. customer_no,
  450. customer_name,
  451. amt,
  452. card_oils_type,
  453. station_id,
  454. create_time,
  455. recently_time
  456. FROM customer_electronic_card
  457. <where>
  458. <if test="stationId !=null and stationId !=''">
  459. station_id = #{stationId}
  460. </if>
  461. <if test="unionId !=null and unionId !=''">
  462. AND union_id = #{unionId}
  463. </if>
  464. <if test="cardOilsTypeArray !=null and cardOilsTypeArray !=''">
  465. AND card_oils_type IN
  466. <foreach collection="cardOilsTypeArray" item="item" index="index" open="(" close=")" separator=",">
  467. #{item}
  468. </foreach>
  469. </if>
  470. </where>
  471. ORDER BY (CASE WHEN card_oils_type = 3 THEN 100 ELSE 0 END), card_oils_type
  472. </select>
  473. <!--查询用户所拥有的储蓄卡-->
  474. <select id="getElectronicCardList" resultMap="CardBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  475. SELECT
  476. id,
  477. union_id,
  478. customer_no,
  479. customer_name,
  480. amt,
  481. card_oils_type,
  482. station_id,
  483. create_time,
  484. recently_time
  485. FROM
  486. customer_electronic_card
  487. <where>
  488. <if test="stationId !=null and stationId !=''">
  489. station_id = #{stationId}
  490. </if>
  491. <if test="unionId !=null and unionId !=''">
  492. AND union_id = #{unionId}
  493. </if>
  494. <if test="cardOilsType !=null and cardOilsType !=''">
  495. AND card_oils_type = #{cardOilsType}
  496. </if>
  497. </where>
  498. </select>
  499. <!--插入用户电子会员卡-->
  500. <insert id="insetElectronicCard" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  501. INSERT INTO
  502. customer_electronic_card
  503. <trim prefix="(" suffix=")" suffixOverrides=",">
  504. <if test="unionId !=null">
  505. union_id,
  506. </if>
  507. <if test="customerNo !=null">
  508. customer_no,
  509. </if>
  510. <if test="customerName !=null">
  511. customer_name,
  512. </if>
  513. <if test="mobilePhone !=null">
  514. mobile_phone,
  515. </if>
  516. <if test="amt !=null">
  517. amt,
  518. </if>
  519. <if test="cardOilsType !=null">
  520. card_oils_type,
  521. </if>
  522. <if test="stationId !=null">
  523. station_id,
  524. </if>
  525. <if test="createTime !=null">
  526. create_time,
  527. </if>
  528. <if test="recentlyTime !=null">
  529. recently_time,
  530. </if>
  531. </trim>
  532. <trim prefix="values (" suffix=")" suffixOverrides=",">
  533. <if test="unionId !=null">
  534. #{unionId},
  535. </if>
  536. <if test="customerNo !=null">
  537. #{customerNo},
  538. </if>
  539. <if test="customerName !=null">
  540. #{customerName},
  541. </if>
  542. <if test="mobilePhone !=null">
  543. #{mobilePhone},
  544. </if>
  545. <if test="amt !=null">
  546. #{amt},
  547. </if>
  548. <if test="cardOilsType !=null">
  549. #{cardOilsType},
  550. </if>
  551. <if test="stationId !=null">
  552. #{stationId},
  553. </if>
  554. <if test="createTime !=null">
  555. #{createTime},
  556. </if>
  557. <if test="recentlyTime !=null">
  558. #{recentlyTime},
  559. </if>
  560. </trim>
  561. </insert>
  562. <!--根据unionId获取用户用要充值电子会员卡(储蓄卡)信息-->
  563. <select id="getElectronicCardInfoByUnionId" resultMap="CardBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  564. SELECT
  565. id,
  566. union_id,
  567. customer_no,
  568. customer_name,
  569. amt,
  570. card_oils_type,
  571. station_id,
  572. create_time,
  573. recently_time
  574. FROM
  575. customer_electronic_card
  576. <where>
  577. <if test="stationId != null" >
  578. station_id = #{stationId}
  579. </if>
  580. <if test="unionId !=null and unionId !=''">
  581. AND union_id = #{unionId}
  582. </if>
  583. <!-- <if test="blogOpenid !=null and blogOpenid !=''">-->
  584. <!-- AND blog_openid = #{blogOpenid}-->
  585. <!-- </if>-->
  586. <!-- <if test="minaOpenid !=null and minaOpenid !=''">-->
  587. <!-- AND mina_openid = #{minaOpenid}-->
  588. <!-- </if>-->
  589. <if test="cardOilsType !=null and cardOilsType !=''">
  590. AND card_oils_type = #{cardOilsType}
  591. </if>
  592. </where>
  593. </select>
  594. <!--获取用户用要充值电子会员卡(储蓄卡)信息-->
  595. <select id="getElectronicCardInfo" resultMap="CardBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  596. SELECT
  597. id,
  598. union_id,
  599. customer_no,
  600. customer_name,
  601. amt,
  602. card_oils_type,
  603. station_id,
  604. create_time,
  605. recently_time
  606. FROM
  607. customer_electronic_card
  608. <where>
  609. <if test="id !=null and id !=''">
  610. id = #{id}
  611. </if>
  612. </where>
  613. </select>
  614. <!--更新用户的电子会员卡的信息-->
  615. <update id="updateElectronicCardInfo" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  616. UPDATE
  617. customer_electronic_card
  618. <set>
  619. <if test="amt !=null">
  620. amt = #{amt},
  621. </if>
  622. <if test="recentlyTime !=null">
  623. recently_time = #{recentlyTime}
  624. </if>
  625. </set>
  626. <where>
  627. <if test="id !=null and id != ''">
  628. id = #{id}
  629. </if>
  630. </where>
  631. </update>
  632. <!--根据unionId更新用户的电子会员卡的信息-->
  633. <update id="updateElectronicCardInfoByUnionId" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  634. UPDATE customer_electronic_card
  635. <set>
  636. <if test="unionId !=null">
  637. union_id = #{unionId},
  638. </if>
  639. <if test="customerNo !=null">
  640. customer_no = #{customerNo},
  641. </if>
  642. <if test="customerName !=null">
  643. customer_name = #{customerName},
  644. </if>
  645. <if test="mobilePhone !=null">
  646. mobile_phone = #{mobilePhone},
  647. </if>
  648. <if test="amt !=null">
  649. amt = #{amt},
  650. </if>
  651. <if test="cardOilsType !=null">
  652. card_oils_type = #{cardOilsType},
  653. </if>
  654. <if test="stationId !=null">
  655. station_id = #{stationId},
  656. </if>
  657. <if test="createTime !=null">
  658. create_time = #{createTime},
  659. </if>
  660. <if test="recentlyTime !=null">
  661. recently_time = #{recentlyTime}
  662. </if>
  663. </set>
  664. <where>
  665. <if test="stationId !='' and stationId != null" >
  666. station_id = #{stationId}
  667. </if>
  668. <!-- <if test="blogOpenid !=null and blogOpenid !=''">-->
  669. <!-- AND blog_openid = #{blogOpenid}-->
  670. <!-- </if>-->
  671. <!-- <if test="minaOpenid !=null and minaOpenid !=''">-->
  672. <!-- AND mina_openid = #{minaOpenid}-->
  673. <!-- </if>-->
  674. <if test="unionId !=null and unionId != ''">
  675. AND union_id = #{unionId}
  676. </if>
  677. <if test="cardOilsType !='' and cardOilsType != null" >
  678. AND card_oils_type = #{cardOilsType}
  679. </if>
  680. </where>
  681. </update>
  682. <!--查询油站的会员卡启用标识 (1、启动 2,停用)-->
  683. <select id="getStationCardEnabledFlag" parameterType="Integer" resultType="String">
  684. SELECT
  685. card_enabled_flag AS cardEnabledFlag
  686. FROM
  687. sys_dept
  688. <where>
  689. <if test="stationId !='' and stationId != null" >
  690. dept_id = #{stationId}
  691. </if>
  692. </where>
  693. </select>
  694. <!--根据小程序用户openId查询客户电子会员卡信息-->
  695. <select id="getElectronicCardInfoByMinaOpenId" resultMap="CardBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
  696. SELECT
  697. id,
  698. union_id,
  699. customer_no,
  700. customer_name,
  701. amt,
  702. card_oils_type,
  703. station_id,
  704. create_time,
  705. recently_time
  706. FROM
  707. customer_electronic_card
  708. <where>
  709. <if test="stationId !='' and stationId != null" >
  710. station_id = #{stationId}
  711. </if>
  712. <if test="minaOpenid !='' and minaOpenid != null" >
  713. AND mina_openid = #{minaOpenid}
  714. </if>
  715. <if test="cardOilsType !='' and cardOilsType != null" >
  716. AND card_oils_type = #{cardOilsType}
  717. </if>
  718. </where>
  719. </select>
  720. </mapper>