You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

650 regels
21 KiB

  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.iformall.mapper.WxCouponMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCoupon">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  7. <result column="type" jdbcType="INTEGER" property="type"/>
  8. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  9. <result column="title" jdbcType="VARCHAR" property="title"/>
  10. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  11. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  12. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  13. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  14. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  15. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  16. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  17. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  18. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  19. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  20. <result column="price" jdbcType="INTEGER" property="price"/>
  21. <result column="unit" jdbcType="INTEGER" property="unit"/>
  22. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  23. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  24. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  25. <result column="status" jdbcType="INTEGER" property="status"/>
  26. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  27. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  28. <result column="business" jdbcType="INTEGER" property="business"/>
  29. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  30. <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
  31. <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
  32. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  33. <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
  34. </resultMap>
  35. <sql id="allColumns">
  36. `id`,`tenant_id`,`type`,`cover_img`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`send_type`,
  37. `valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`unit`,`remain_inventory`,`inventory`,
  38. `remark`,`status`,`create_date`,`update_date`,`business`,`support_transfer`,`subsidy_num`,`subsidy_type`,
  39. `press_limit_num`, `press_limit_hours`
  40. </sql>
  41. <sql id="dynamicWhereConditions">
  42. where 1 = 1
  43. <if test=" null != id ">
  44. and `id` = #{id}
  45. </if>
  46. <if test=" null != tenantId ">
  47. and `tenant_id` = #{tenantId}
  48. </if>
  49. <if test=" null != type ">
  50. and `type` = #{type}
  51. </if>
  52. <if test=" null != coverImg ">
  53. and `cover_img` like concat('%', #{coverImg},'%')
  54. </if>
  55. <if test=" null != title and ''!=title">
  56. and `title` like concat('%', #{title},'%')
  57. </if>
  58. <if test=" null != subTitle ">
  59. and `sub_title` like concat('%', #{subTitle},'%')
  60. </if>
  61. <if test=" null != salePrice ">
  62. and `sale_price` = #{salePrice}
  63. </if>
  64. <if test=" null != usePrice ">
  65. and `use_price` = #{usePrice}
  66. </if>
  67. <if test=" null != useLimitQuantity ">
  68. and `use_limit_quantity` = #{useLimitQuantity}
  69. </if>
  70. <if test=" null != sendType ">
  71. and `send_type` = #{sendType}
  72. </if>
  73. <if test=" null != validType ">
  74. and `valid_type` = #{validType}
  75. </if>
  76. <if test=" null != validStartDate ">
  77. and `valid_start_date` = #{validStartDate}
  78. </if>
  79. <if test=" null != validEndDate ">
  80. and `valid_end_date` = #{validEndDate}
  81. </if>
  82. <if test=" null != validDays ">
  83. and `valid_days` = #{validDays}
  84. </if>
  85. <if test=" null != detail ">
  86. and `detail` like concat('%', #{detail},'%')
  87. </if>
  88. <if test=" null != price ">
  89. and `price` = #{price}
  90. </if>
  91. <if test=" null != unit ">
  92. and `unit` = #{unit}
  93. </if>
  94. <if test=" null != remainInventory ">
  95. and `remain_inventory` = #{remainInventory}
  96. </if>
  97. <if test=" null != inventory ">
  98. and `inventory` = #{inventory}
  99. </if>
  100. <if test=" null != remark ">
  101. and `remark` like concat('%', #{remark},'%')
  102. </if>
  103. <if test=" null != status">
  104. and `status` = #{status}
  105. </if>
  106. <if test=" null != startdate and null!=enddate">
  107. and `create_date` between #{startdate} and #{enddate}
  108. </if>
  109. <if test=" null != updateDate ">
  110. and `update_date` = #{updateDate}
  111. </if>
  112. <if test=" null != business ">
  113. and `business` = #{business}
  114. </if>
  115. <if test=" null != supportTransfer ">
  116. and `support_transfer` = #{supportTransfer}
  117. </if>
  118. <if test=" null != subsidyType ">
  119. and `subsidy_type` = #{subsidyType}
  120. </if>
  121. <if test=" null != subsidyNum ">
  122. and `subsidy_num` = #{subsidyNum}
  123. </if>
  124. <if test=" null != pressLimitNum ">
  125. and `press_limit_num` = #{pressLimitNum}
  126. </if>
  127. <if test=" null != pressLimitHours ">
  128. and `press_limit_hours` = #{pressLimitHours}
  129. </if>
  130. <if test=" null != ids ">
  131. and id in
  132. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  133. #{idItem}
  134. </foreach>
  135. </if>
  136. <if test=" null != sortColumns">order by ${sortColumns}</if>
  137. </sql>
  138. <select id="findList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  139. select
  140. <include refid="allColumns"/>
  141. from wx_coupon
  142. <include refid="dynamicWhereConditions"/>
  143. </select>
  144. <sql id="dynamicWhereConditionsForCard">
  145. where `type` = 100
  146. <if test=" null != id ">
  147. and `id` = #{id}
  148. </if>
  149. <if test=" null != tenantId ">
  150. and `tenant_id` = #{tenantId}
  151. </if>
  152. <if test=" null != type ">
  153. and `type` = #{type}
  154. </if>
  155. <if test=" null != coverImg ">
  156. and `cover_img` like concat('%', #{coverImg},'%')
  157. </if>
  158. <if test=" null != title and ''!=title">
  159. and `title` like concat('%', #{title},'%')
  160. </if>
  161. <if test=" null != subTitle ">
  162. and `sub_title` like concat('%', #{subTitle},'%')
  163. </if>
  164. <if test=" null != salePrice ">
  165. and `sale_price` = #{salePrice}
  166. </if>
  167. <if test=" null != usePrice ">
  168. and `use_price` = #{usePrice}
  169. </if>
  170. <if test=" null != useLimitQuantity ">
  171. and `use_limit_quantity` = #{useLimitQuantity}
  172. </if>
  173. <if test=" null != sendType ">
  174. and `send_type` = #{sendType}
  175. </if>
  176. <if test=" null != validType ">
  177. and `valid_type` = #{validType}
  178. </if>
  179. <if test=" null != validStartDate ">
  180. and `valid_start_date` = #{validStartDate}
  181. </if>
  182. <if test=" null != validEndDate ">
  183. and `valid_end_date` = #{validEndDate}
  184. </if>
  185. <if test=" null != validDays ">
  186. and `valid_days` = #{validDays}
  187. </if>
  188. <if test=" null != detail ">
  189. and `detail` like concat('%', #{detail},'%')
  190. </if>
  191. <if test=" null != price ">
  192. and `price` = #{price}
  193. </if>
  194. <if test=" null != unit ">
  195. and `unit` = #{unit}
  196. </if>
  197. <if test=" null != remainInventory ">
  198. and `remain_inventory` = #{remainInventory}
  199. </if>
  200. <if test=" null != inventory ">
  201. and `inventory` = #{inventory}
  202. </if>
  203. <if test=" null != remark ">
  204. and `remark` like concat('%', #{remark},'%')
  205. </if>
  206. <if test=" null != status">
  207. and `status` = #{status}
  208. </if>
  209. <if test=" null != startdate and null!=enddate">
  210. and `create_date` between #{startdate} and #{enddate}
  211. </if>
  212. <if test=" null != updateDate ">
  213. and `update_date` = #{updateDate}
  214. </if>
  215. <if test=" null != business ">
  216. and `business` = #{business}
  217. </if>
  218. <if test=" null != supportTransfer ">
  219. and `support_transfer` = #{supportTransfer}
  220. </if>
  221. <if test=" null != subsidyType ">
  222. and `subsidy_type` = #{subsidyType}
  223. </if>
  224. <if test=" null != subsidyNum ">
  225. and `subsidy_num` = #{subsidyNum}
  226. </if>
  227. <if test=" null != pressLimitNum ">
  228. and `press_limit_num` = #{pressLimitNum}
  229. </if>
  230. <if test=" null != pressLimitHours ">
  231. and `press_limit_hours` = #{pressLimitHours}
  232. </if>
  233. <if test=" null != ids ">
  234. and id in
  235. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  236. #{idItem}
  237. </foreach>
  238. </if>
  239. <if test=" null != sortColumns">order by ${sortColumns}</if>
  240. </sql>
  241. <select id="findCardList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  242. select
  243. <include refid="allColumns"/>
  244. from wx_coupon
  245. <include refid="dynamicWhereConditionsForCard"/>
  246. </select>
  247. <sql id="dynamicWhereConditionsForCoupon">
  248. where `type` &lt; 7
  249. <if test=" null != id ">
  250. and `id` = #{id}
  251. </if>
  252. <if test=" null != tenantId ">
  253. and `tenant_id` = #{tenantId}
  254. </if>
  255. <if test=" null != type ">
  256. and `type` = #{type}
  257. </if>
  258. <if test=" null != coverImg ">
  259. and `cover_img` like concat('%', #{coverImg},'%')
  260. </if>
  261. <if test=" null != title and ''!=title">
  262. and `title` like concat('%', #{title},'%')
  263. </if>
  264. <if test=" null != subTitle ">
  265. and `sub_title` like concat('%', #{subTitle},'%')
  266. </if>
  267. <if test=" null != salePrice ">
  268. and `sale_price` = #{salePrice}
  269. </if>
  270. <if test=" null != usePrice ">
  271. and `use_price` = #{usePrice}
  272. </if>
  273. <if test=" null != useLimitQuantity ">
  274. and `use_limit_quantity` = #{useLimitQuantity}
  275. </if>
  276. <if test=" null != sendType ">
  277. and `send_type` = #{sendType}
  278. </if>
  279. <if test=" null != validType ">
  280. and `valid_type` = #{validType}
  281. </if>
  282. <if test=" null != validStartDate ">
  283. and `valid_start_date` = #{validStartDate}
  284. </if>
  285. <if test=" null != validEndDate ">
  286. and `valid_end_date` = #{validEndDate}
  287. </if>
  288. <if test=" null != validDays ">
  289. and `valid_days` = #{validDays}
  290. </if>
  291. <if test=" null != detail ">
  292. and `detail` like concat('%', #{detail},'%')
  293. </if>
  294. <if test=" null != price ">
  295. and `price` = #{price}
  296. </if>
  297. <if test=" null != unit ">
  298. and `unit` = #{unit}
  299. </if>
  300. <if test=" null != remainInventory ">
  301. and `remain_inventory` = #{remainInventory}
  302. </if>
  303. <if test=" null != inventory ">
  304. and `inventory` = #{inventory}
  305. </if>
  306. <if test=" null != remark ">
  307. and `remark` like concat('%', #{remark},'%')
  308. </if>
  309. <if test=" null != status">
  310. and `status` = #{status}
  311. </if>
  312. <if test=" null != startdate and null!=enddate">
  313. and `create_date` between #{startdate} and #{enddate}
  314. </if>
  315. <if test=" null != updateDate ">
  316. and `update_date` = #{updateDate}
  317. </if>
  318. <if test=" null != business ">
  319. and `business` = #{business}
  320. </if>
  321. <if test=" null != supportTransfer ">
  322. and `support_transfer` = #{supportTransfer}
  323. </if>
  324. <if test=" null != subsidyType ">
  325. and `subsidy_type` = #{subsidyType}
  326. </if>
  327. <if test=" null != subsidyNum ">
  328. and `subsidy_num` = #{subsidyNum}
  329. </if>
  330. <if test=" null != pressLimitNum ">
  331. and `press_limit_num` = #{pressLimitNum}
  332. </if>
  333. <if test=" null != pressLimitHours ">
  334. and `press_limit_hours` = #{pressLimitHours}
  335. </if>
  336. <if test=" null != ids ">
  337. and id in
  338. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  339. #{idItem}
  340. </foreach>
  341. </if>
  342. <if test=" null != sortColumns">order by ${sortColumns}</if>
  343. </sql>
  344. <select id="findCouponList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  345. select
  346. <include refid="allColumns"/>
  347. from wx_coupon
  348. <include refid="dynamicWhereConditionsForCoupon"/>
  349. </select>
  350. <sql id="dynamicWhereConditionsForPress">
  351. where `type` = 8
  352. <if test=" null != id ">
  353. and `id` = #{id}
  354. </if>
  355. <if test=" null != tenantId ">
  356. and `tenant_id` = #{tenantId}
  357. </if>
  358. <if test=" null != type ">
  359. and `type` = #{type}
  360. </if>
  361. <if test=" null != coverImg ">
  362. and `cover_img` like concat('%', #{coverImg},'%')
  363. </if>
  364. <if test=" null != title and ''!=title">
  365. and `title` like concat('%', #{title},'%')
  366. </if>
  367. <if test=" null != subTitle ">
  368. and `sub_title` like concat('%', #{subTitle},'%')
  369. </if>
  370. <if test=" null != salePrice ">
  371. and `sale_price` = #{salePrice}
  372. </if>
  373. <if test=" null != usePrice ">
  374. and `use_price` = #{usePrice}
  375. </if>
  376. <if test=" null != useLimitQuantity ">
  377. and `use_limit_quantity` = #{useLimitQuantity}
  378. </if>
  379. <if test=" null != sendType ">
  380. and `send_type` = #{sendType}
  381. </if>
  382. <if test=" null != validType ">
  383. and `valid_type` = #{validType}
  384. </if>
  385. <if test=" null != validStartDate ">
  386. and `valid_start_date` = #{validStartDate}
  387. </if>
  388. <if test=" null != validEndDate ">
  389. and `valid_end_date` = #{validEndDate}
  390. </if>
  391. <if test=" null != validDays ">
  392. and `valid_days` = #{validDays}
  393. </if>
  394. <if test=" null != detail ">
  395. and `detail` like concat('%', #{detail},'%')
  396. </if>
  397. <if test=" null != price ">
  398. and `price` = #{price}
  399. </if>
  400. <if test=" null != unit ">
  401. and `unit` = #{unit}
  402. </if>
  403. <if test=" null != remainInventory ">
  404. and `remain_inventory` = #{remainInventory}
  405. </if>
  406. <if test=" null != inventory ">
  407. and `inventory` = #{inventory}
  408. </if>
  409. <if test=" null != remark ">
  410. and `remark` like concat('%', #{remark},'%')
  411. </if>
  412. <if test=" null != status">
  413. and `status` = #{status}
  414. </if>
  415. <if test=" null != startdate and null!=enddate">
  416. and `create_date` between #{startdate} and #{enddate}
  417. </if>
  418. <if test=" null != updateDate ">
  419. and `update_date` = #{updateDate}
  420. </if>
  421. <if test=" null != business ">
  422. and `business` = #{business}
  423. </if>
  424. <if test=" null != supportTransfer ">
  425. and `support_transfer` = #{supportTransfer}
  426. </if>
  427. <if test=" null != subsidyType ">
  428. and `subsidy_type` = #{subsidyType}
  429. </if>
  430. <if test=" null != subsidyNum ">
  431. and `subsidy_num` = #{subsidyNum}
  432. </if>
  433. <if test=" null != pressLimitNum ">
  434. and `press_limit_num` = #{pressLimitNum}
  435. </if>
  436. <if test=" null != pressLimitHours ">
  437. and `press_limit_hours` = #{pressLimitHours}
  438. </if>
  439. <if test=" null != ids ">
  440. and id in
  441. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  442. #{idItem}
  443. </foreach>
  444. </if>
  445. <if test=" null != sortColumns">order by ${sortColumns}</if>
  446. </sql>
  447. <select id="findPressList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  448. select
  449. <include refid="allColumns"/>
  450. from wx_coupon
  451. <include refid="dynamicWhereConditionsForPress"/>
  452. </select>
  453. <resultMap id="WxCouponCVoMap" type="com.iformall.domain.vo.WxCouponCVo">
  454. <id column="id" jdbcType="BIGINT" property="id"/>
  455. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  456. <result column="type" jdbcType="INTEGER" property="type"/>
  457. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  458. <result column="title" jdbcType="VARCHAR" property="title"/>
  459. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  460. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  461. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  462. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  463. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  464. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  465. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  466. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  467. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  468. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  469. <result column="price" jdbcType="INTEGER" property="price"/>
  470. <result column="unit" jdbcType="INTEGER" property="unit"/>
  471. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  472. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  473. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  474. <result column="status" jdbcType="INTEGER" property="status"/>
  475. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  476. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  477. <result column="business" jdbcType="INTEGER" property="business"/>
  478. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  479. <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
  480. <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
  481. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  482. <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
  483. <collection column="{productId=id}" property="merchantVoList"
  484. ofType="com.iformall.domain.vo.WxMerchantVo"
  485. javaType="java.util.List"
  486. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantBaseList" >
  487. </collection>
  488. </resultMap>
  489. <select id="findVoDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMap">
  490. select
  491. <include refid="allColumns"/>
  492. from wx_coupon
  493. where id = #{id}
  494. </select>
  495. <update id="reduceInventory">
  496. update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory>= #{number}
  497. </update>
  498. <update id="offExpiriedCouponByValidDate">
  499. update wx_coupon SET status = 1, update_date = now()
  500. where status = 0 and valid_type = 1 and valid_end_date &lt; now()
  501. </update>
  502. <update id="offExpiriedCouponByMerchantStatus">
  503. update wx_coupon c
  504. SET c.status = 1, c.update_date = now()
  505. where c.status = 0 and
  506. (select count(*) from wx_coupon_merchant cm, wx_merchant m
  507. where m.id = cm.merchant_id
  508. and c.id = cm.product_id
  509. and cm.status = 0
  510. and m.status = 1) = 0
  511. </update>
  512. </mapper>