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.
 
 
 
 
 

940 rivejä
34 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. <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
  35. <result column="sale_count" property="saleCount"/>
  36. <result column="transfer_count" property="transferCount"/>
  37. <result column="sale_amount" property="saleAmount"/>
  38. <result column="sum_payment" property="sumPayment"/>
  39. <result column="press_count" property="pressSendCount"/>
  40. <result column="press_succ_count" property="pressSuccCount"/>
  41. <result column="join_count" property="pressJoinCount"/>
  42. <result column="sum_subsidy" property="sumSubsidy"/>
  43. <result column="payment_rate" property="paymentRate"/>
  44. </resultMap>
  45. <sql id="allColumns">
  46. `id`,`tenant_id`,`type`,`cover_img`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`send_type`,
  47. `valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`unit`,`remain_inventory`,`inventory`,
  48. `remark`,`status`,`create_date`,`update_date`,`business`,`support_transfer`,`subsidy_num`,`subsidy_type`,
  49. `press_limit_num`, `press_limit_hours`, `auto_refund`
  50. </sql>
  51. <sql id="dynamicWhereConditions">
  52. where 1 = 1
  53. <if test=" null != id ">
  54. and `id` = #{id}
  55. </if>
  56. <if test=" null != tenantId ">
  57. and `tenant_id` = #{tenantId}
  58. </if>
  59. <if test=" null != type ">
  60. and `type` = #{type}
  61. </if>
  62. <if test=" null != coverImg ">
  63. and `cover_img` like concat('%', #{coverImg},'%')
  64. </if>
  65. <if test=" null != title and ''!=title">
  66. and `title` like concat('%', #{title},'%')
  67. </if>
  68. <if test=" null != subTitle ">
  69. and `sub_title` like concat('%', #{subTitle},'%')
  70. </if>
  71. <if test=" null != salePrice ">
  72. and `sale_price` = #{salePrice}
  73. </if>
  74. <if test=" null != usePrice ">
  75. and `use_price` = #{usePrice}
  76. </if>
  77. <if test=" null != useLimitQuantity ">
  78. and `use_limit_quantity` = #{useLimitQuantity}
  79. </if>
  80. <if test=" null != sendType ">
  81. and `send_type` = #{sendType}
  82. </if>
  83. <if test=" null != validType ">
  84. and `valid_type` = #{validType}
  85. </if>
  86. <if test=" null != validStartDate ">
  87. and `valid_start_date` = #{validStartDate}
  88. </if>
  89. <if test=" null != validEndDate ">
  90. and `valid_end_date` = #{validEndDate}
  91. </if>
  92. <if test=" null != validDays ">
  93. and `valid_days` = #{validDays}
  94. </if>
  95. <if test=" null != detail ">
  96. and `detail` like concat('%', #{detail},'%')
  97. </if>
  98. <if test=" null != price ">
  99. and `price` = #{price}
  100. </if>
  101. <if test=" null != unit ">
  102. and `unit` = #{unit}
  103. </if>
  104. <if test=" null != remainInventory ">
  105. and `remain_inventory` = #{remainInventory}
  106. </if>
  107. <if test=" null != inventory ">
  108. and `inventory` = #{inventory}
  109. </if>
  110. <if test=" null != remark ">
  111. and `remark` like concat('%', #{remark},'%')
  112. </if>
  113. <if test=" null != status">
  114. and `status` = #{status}
  115. </if>
  116. <if test=" null != startdate and null!=enddate">
  117. and `create_date` between #{startdate} and #{enddate}
  118. </if>
  119. <if test=" null != updateDate ">
  120. and `update_date` = #{updateDate}
  121. </if>
  122. <if test=" null != business ">
  123. and `business` = #{business}
  124. </if>
  125. <if test=" null != supportTransfer ">
  126. and `support_transfer` = #{supportTransfer}
  127. </if>
  128. <if test=" null != subsidyType ">
  129. and `subsidy_type` = #{subsidyType}
  130. </if>
  131. <if test=" null != subsidyNum ">
  132. and `subsidy_num` = #{subsidyNum}
  133. </if>
  134. <if test=" null != pressLimitNum ">
  135. and `press_limit_num` = #{pressLimitNum}
  136. </if>
  137. <if test=" null != pressLimitHours ">
  138. and `press_limit_hours` = #{pressLimitHours}
  139. </if>
  140. <if test=" null != autoRefund ">
  141. and `auto_refund` = #{autoRefund}
  142. </if>
  143. <if test=" null != ids ">
  144. and id in
  145. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  146. #{idItem}
  147. </foreach>
  148. </if>
  149. <if test=" null != notinTypes ">
  150. and type not in
  151. <foreach collection="notinTypes" index="index" item="typeItem" open="(" separator="," close=")">
  152. #{typeItem}
  153. </foreach>
  154. </if>
  155. <if test=" null != sortColumns">order by ${sortColumns}</if>
  156. </sql>
  157. <select id="findList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  158. select
  159. <include refid="allColumns"/>
  160. from wx_coupon
  161. <include refid="dynamicWhereConditions"/>
  162. </select>
  163. <sql id="dynamicWhereConditionsForCard">
  164. where `type` = 100
  165. <if test=" null != id ">
  166. and `id` = #{id}
  167. </if>
  168. <if test=" null != tenantId ">
  169. and `tenant_id` = #{tenantId}
  170. </if>
  171. <if test=" null != type ">
  172. and `type` = #{type}
  173. </if>
  174. <if test=" null != coverImg ">
  175. and `cover_img` like concat('%', #{coverImg},'%')
  176. </if>
  177. <if test=" null != title and ''!=title">
  178. and `title` like concat('%', #{title},'%')
  179. </if>
  180. <if test=" null != subTitle ">
  181. and `sub_title` like concat('%', #{subTitle},'%')
  182. </if>
  183. <if test=" null != salePrice ">
  184. and `sale_price` = #{salePrice}
  185. </if>
  186. <if test=" null != usePrice ">
  187. and `use_price` = #{usePrice}
  188. </if>
  189. <if test=" null != useLimitQuantity ">
  190. and `use_limit_quantity` = #{useLimitQuantity}
  191. </if>
  192. <if test=" null != sendType ">
  193. and `send_type` = #{sendType}
  194. </if>
  195. <if test=" null != validType ">
  196. and `valid_type` = #{validType}
  197. </if>
  198. <if test=" null != validStartDate ">
  199. and `valid_start_date` = #{validStartDate}
  200. </if>
  201. <if test=" null != validEndDate ">
  202. and `valid_end_date` = #{validEndDate}
  203. </if>
  204. <if test=" null != validDays ">
  205. and `valid_days` = #{validDays}
  206. </if>
  207. <if test=" null != detail ">
  208. and `detail` like concat('%', #{detail},'%')
  209. </if>
  210. <if test=" null != price ">
  211. and `price` = #{price}
  212. </if>
  213. <if test=" null != unit ">
  214. and `unit` = #{unit}
  215. </if>
  216. <if test=" null != remainInventory ">
  217. and `remain_inventory` = #{remainInventory}
  218. </if>
  219. <if test=" null != inventory ">
  220. and `inventory` = #{inventory}
  221. </if>
  222. <if test=" null != remark ">
  223. and `remark` like concat('%', #{remark},'%')
  224. </if>
  225. <if test=" null != status">
  226. and `status` = #{status}
  227. </if>
  228. <if test=" null != startdate and null!=enddate">
  229. and `create_date` between #{startdate} and #{enddate}
  230. </if>
  231. <if test=" null != updateDate ">
  232. and `update_date` = #{updateDate}
  233. </if>
  234. <if test=" null != business ">
  235. and `business` = #{business}
  236. </if>
  237. <if test=" null != supportTransfer ">
  238. and `support_transfer` = #{supportTransfer}
  239. </if>
  240. <if test=" null != subsidyType ">
  241. and `subsidy_type` = #{subsidyType}
  242. </if>
  243. <if test=" null != subsidyNum ">
  244. and `subsidy_num` = #{subsidyNum}
  245. </if>
  246. <if test=" null != pressLimitNum ">
  247. and `press_limit_num` = #{pressLimitNum}
  248. </if>
  249. <if test=" null != pressLimitHours ">
  250. and `press_limit_hours` = #{pressLimitHours}
  251. </if>
  252. <if test=" null != ids ">
  253. and id in
  254. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  255. #{idItem}
  256. </foreach>
  257. </if>
  258. <if test=" null != sortColumns">order by ${sortColumns}</if>
  259. </sql>
  260. <select id="findCardList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  261. select
  262. <include refid="allColumns"/>
  263. from wx_coupon
  264. <include refid="dynamicWhereConditionsForCard"/>
  265. </select>
  266. <sql id="dynamicWhereConditionsForCoupon">
  267. where `type` &lt; 7
  268. <if test=" null != id ">
  269. and `id` = #{id}
  270. </if>
  271. <if test=" null != tenantId ">
  272. and `tenant_id` = #{tenantId}
  273. </if>
  274. <if test=" null != type ">
  275. and `type` = #{type}
  276. </if>
  277. <if test=" null != coverImg ">
  278. and `cover_img` like concat('%', #{coverImg},'%')
  279. </if>
  280. <if test=" null != title and ''!=title">
  281. and `title` like concat('%', #{title},'%')
  282. </if>
  283. <if test=" null != subTitle ">
  284. and `sub_title` like concat('%', #{subTitle},'%')
  285. </if>
  286. <if test=" null != salePrice ">
  287. and `sale_price` = #{salePrice}
  288. </if>
  289. <if test=" null != usePrice ">
  290. and `use_price` = #{usePrice}
  291. </if>
  292. <if test=" null != useLimitQuantity ">
  293. and `use_limit_quantity` = #{useLimitQuantity}
  294. </if>
  295. <if test=" null != sendType ">
  296. and `send_type` = #{sendType}
  297. </if>
  298. <if test=" null != validType ">
  299. and `valid_type` = #{validType}
  300. </if>
  301. <if test=" null != validStartDate ">
  302. and `valid_start_date` = #{validStartDate}
  303. </if>
  304. <if test=" null != validEndDate ">
  305. and `valid_end_date` = #{validEndDate}
  306. </if>
  307. <if test=" null != validDays ">
  308. and `valid_days` = #{validDays}
  309. </if>
  310. <if test=" null != detail ">
  311. and `detail` like concat('%', #{detail},'%')
  312. </if>
  313. <if test=" null != price ">
  314. and `price` = #{price}
  315. </if>
  316. <if test=" null != unit ">
  317. and `unit` = #{unit}
  318. </if>
  319. <if test=" null != remainInventory ">
  320. and `remain_inventory` = #{remainInventory}
  321. </if>
  322. <if test=" null != inventory ">
  323. and `inventory` = #{inventory}
  324. </if>
  325. <if test=" null != remark ">
  326. and `remark` like concat('%', #{remark},'%')
  327. </if>
  328. <if test=" null != status">
  329. and `status` = #{status}
  330. </if>
  331. <if test=" null != startdate and null!=enddate">
  332. and `create_date` between #{startdate} and #{enddate}
  333. </if>
  334. <if test=" null != updateDate ">
  335. and `update_date` = #{updateDate}
  336. </if>
  337. <if test=" null != business ">
  338. and `business` = #{business}
  339. </if>
  340. <if test=" null != supportTransfer ">
  341. and `support_transfer` = #{supportTransfer}
  342. </if>
  343. <if test=" null != subsidyType ">
  344. and `subsidy_type` = #{subsidyType}
  345. </if>
  346. <if test=" null != subsidyNum ">
  347. and `subsidy_num` = #{subsidyNum}
  348. </if>
  349. <if test=" null != pressLimitNum ">
  350. and `press_limit_num` = #{pressLimitNum}
  351. </if>
  352. <if test=" null != pressLimitHours ">
  353. and `press_limit_hours` = #{pressLimitHours}
  354. </if>
  355. <if test=" null != ids ">
  356. and id in
  357. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  358. #{idItem}
  359. </foreach>
  360. </if>
  361. <if test=" null != sortColumns">order by ${sortColumns}</if>
  362. </sql>
  363. <select id="findCouponList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  364. select
  365. <include refid="allColumns"/>
  366. from wx_coupon
  367. <include refid="dynamicWhereConditionsForCoupon"/>
  368. </select>
  369. <sql id="dynamicWhereConditionsForPress">
  370. where `type` = 8
  371. <if test=" null != id ">
  372. and `id` = #{id}
  373. </if>
  374. <if test=" null != tenantId ">
  375. and `tenant_id` = #{tenantId}
  376. </if>
  377. <if test=" null != type ">
  378. and `type` = #{type}
  379. </if>
  380. <if test=" null != coverImg ">
  381. and `cover_img` like concat('%', #{coverImg},'%')
  382. </if>
  383. <if test=" null != title and ''!=title">
  384. and `title` like concat('%', #{title},'%')
  385. </if>
  386. <if test=" null != subTitle ">
  387. and `sub_title` like concat('%', #{subTitle},'%')
  388. </if>
  389. <if test=" null != salePrice ">
  390. and `sale_price` = #{salePrice}
  391. </if>
  392. <if test=" null != usePrice ">
  393. and `use_price` = #{usePrice}
  394. </if>
  395. <if test=" null != useLimitQuantity ">
  396. and `use_limit_quantity` = #{useLimitQuantity}
  397. </if>
  398. <if test=" null != sendType ">
  399. and `send_type` = #{sendType}
  400. </if>
  401. <if test=" null != validType ">
  402. and `valid_type` = #{validType}
  403. </if>
  404. <if test=" null != validStartDate ">
  405. and `valid_start_date` = #{validStartDate}
  406. </if>
  407. <if test=" null != validEndDate ">
  408. and `valid_end_date` = #{validEndDate}
  409. </if>
  410. <if test=" null != validDays ">
  411. and `valid_days` = #{validDays}
  412. </if>
  413. <if test=" null != detail ">
  414. and `detail` like concat('%', #{detail},'%')
  415. </if>
  416. <if test=" null != price ">
  417. and `price` = #{price}
  418. </if>
  419. <if test=" null != unit ">
  420. and `unit` = #{unit}
  421. </if>
  422. <if test=" null != remainInventory ">
  423. and `remain_inventory` = #{remainInventory}
  424. </if>
  425. <if test=" null != inventory ">
  426. and `inventory` = #{inventory}
  427. </if>
  428. <if test=" null != remark ">
  429. and `remark` like concat('%', #{remark},'%')
  430. </if>
  431. <if test=" null != status">
  432. and `status` = #{status}
  433. </if>
  434. <if test=" null != startdate and null!=enddate">
  435. and `create_date` between #{startdate} and #{enddate}
  436. </if>
  437. <if test=" null != updateDate ">
  438. and `update_date` = #{updateDate}
  439. </if>
  440. <if test=" null != business ">
  441. and `business` = #{business}
  442. </if>
  443. <if test=" null != supportTransfer ">
  444. and `support_transfer` = #{supportTransfer}
  445. </if>
  446. <if test=" null != subsidyType ">
  447. and `subsidy_type` = #{subsidyType}
  448. </if>
  449. <if test=" null != subsidyNum ">
  450. and `subsidy_num` = #{subsidyNum}
  451. </if>
  452. <if test=" null != pressLimitNum ">
  453. and `press_limit_num` = #{pressLimitNum}
  454. </if>
  455. <if test=" null != pressLimitHours ">
  456. and `press_limit_hours` = #{pressLimitHours}
  457. </if>
  458. <if test=" null != ids ">
  459. and id in
  460. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  461. #{idItem}
  462. </foreach>
  463. </if>
  464. <if test=" null != sortColumns">order by ${sortColumns}</if>
  465. </sql>
  466. <select id="findPressList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  467. select
  468. <include refid="allColumns"/>
  469. from wx_coupon
  470. <include refid="dynamicWhereConditionsForPress"/>
  471. </select>
  472. <resultMap id="WxCouponCVoMap" type="com.iformall.domain.vo.WxCouponCVo">
  473. <id column="id" jdbcType="BIGINT" property="id"/>
  474. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  475. <result column="type" jdbcType="INTEGER" property="type"/>
  476. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  477. <result column="title" jdbcType="VARCHAR" property="title"/>
  478. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  479. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  480. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  481. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  482. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  483. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  484. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  485. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  486. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  487. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  488. <result column="price" jdbcType="INTEGER" property="price"/>
  489. <result column="unit" jdbcType="INTEGER" property="unit"/>
  490. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  491. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  492. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  493. <result column="status" jdbcType="INTEGER" property="status"/>
  494. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  495. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  496. <result column="business" jdbcType="INTEGER" property="business"/>
  497. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  498. <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
  499. <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
  500. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  501. <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
  502. <result column="xtime" property="xtime"/>
  503. <result column="xcount" property="xcount"/>
  504. <result column="sale_count" property="saleCount"/>
  505. <result column="transfer_count" property="transferCount"/>
  506. <result column="sale_amount" property="saleAmount"/>
  507. <result column="sum_payment" property="sumPayment"/>
  508. <result column="backpay_count" property="backpayCount"/>
  509. <collection column="{productId=id}" property="merchantVoList"
  510. ofType="com.iformall.domain.vo.WxMerchantVo"
  511. javaType="java.util.List"
  512. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantBaseList" >
  513. </collection>
  514. </resultMap>
  515. <select id="findVoDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMap">
  516. select
  517. <include refid="allColumns"/>
  518. from wx_coupon
  519. where id = #{id}
  520. </select>
  521. <update id="reduceInventory">
  522. update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory>= #{number}
  523. </update>
  524. <update id="offExpiriedCouponByValidDate">
  525. update wx_coupon SET status = 1, update_date = now()
  526. where status = 0 and valid_type = 1 and valid_end_date &lt; now()
  527. </update>
  528. <update id="offExpiriedCouponByMerchantStatus">
  529. update wx_coupon c
  530. SET c.status = 1, c.update_date = now()
  531. where c.status = 0 and
  532. (select count(*) from wx_coupon_merchant cm, wx_merchant m
  533. where m.id = cm.merchant_id
  534. and c.id = cm.product_id
  535. and cm.status = 0
  536. and m.status = 1) = 0
  537. </update>
  538. <select id="findSaleMoneyByDate" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  539. select DATE_FORMAT(ci.create_date,'%Y-%m-%d') xtime,sum(round(ci.sale_amount/100,2)) xcount from wx_card_info ci
  540. left join wx_coupon c on c.id = ci.coupon_id
  541. where c.type = 100
  542. and ci.create_date between #{startdate} and #{enddate}
  543. group by xtime
  544. </select>
  545. <select id="findPaymentByDate" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  546. select DATE_FORMAT(wcs.create_date,'%Y-%m-%d') xtime,sum(round(wcs.real_payment/100,2)) xcount from wx_card_info ci
  547. left join wx_coupon c on c.id = ci.coupon_id
  548. left join wx_card_spend wcs on wcs.card_id = ci.id
  549. where c.type = 100
  550. and wcs.create_date between #{startdate} and #{enddate}
  551. group by xtime
  552. </select>
  553. <select id="findSaleCardCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
  554. select count(co.id)
  555. from wx_card_info ci
  556. left join wx_coupon c on c.id = ci.coupon_id
  557. left join wx_coupon_order co on co.id = ci.id
  558. where c.type = 100
  559. and c.create_date between #{startdate} and #{enddate}
  560. </select>
  561. <select id="findTranCardCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
  562. select count(distinct wcs.coupon_order_id) from wx_card_info ci
  563. left join wx_coupon c on c.id = ci.coupon_id
  564. left join wx_card_transfer_info wcs on wcs.coupon_order_id = ci.id
  565. where c.type = 100 and c.create_date between #{startdate} and #{enddate}
  566. </select>
  567. <select id="findSubsidyMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
  568. select sum(round(sc.subsidy/100,2)) from wx_card_info ci
  569. left join wx_coupon c on c.id = ci.coupon_id
  570. left join wx_merchant_subsidy sc on sc.coupon_order_id = ci.id
  571. where c.type = 100 and c.create_date between #{startdate} and #{enddate}
  572. </select>
  573. <select id="findCountData" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  574. select c.*,
  575. (select count(wco.id) from wx_coupon wc
  576. left join wx_coupon_order wco on wc.id = wco.coupon_id
  577. where wc.id = c.id) as sale_count,
  578. (select count(distinct wcs.coupon_order_id) from wx_card_info ci
  579. left join wx_coupon wc on wc.id = ci.coupon_id
  580. left join wx_card_transfer_info wcs on wcs.coupon_order_id = ci.id
  581. where wc.id = c.id) as transfer_count,
  582. (select sum(round(ci.sale_amount/100,2)) from wx_card_info ci
  583. left join wx_coupon wc on wc.id = ci.coupon_id
  584. where wc.id = c.id) as sale_amount,
  585. (select sum(round(wcs.real_payment/100,2)) from wx_card_info ci
  586. left join wx_coupon wc on wc.id = ci.coupon_id
  587. left join wx_card_spend wcs on wcs.card_id = ci.id
  588. where wc.id = c.id) as sum_payment,
  589. (select sum(round(sc.subsidy/100,2)) from wx_card_info ci
  590. left join wx_coupon wc on wc.id = ci.coupon_id
  591. left join wx_merchant_subsidy sc on sc.coupon_order_id = ci.id
  592. where wc.id = c.id) as sum_subsidy
  593. from wx_coupon c where c.type = 100
  594. <if test="title != null">
  595. and c.title = concat('%', #{title},'%')
  596. </if>
  597. <if test="id != null">
  598. and c.id = #{id}
  599. </if>
  600. order by c.status asc,c.create_date desc
  601. </select>
  602. <select id="findCouponData" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  603. select c.*,
  604. (select count(wco.id) from wx_coupon_order wco where wco.coupon_id = c.id) as sale_count,
  605. (select count(wco.id) from wx_coupon wc,wx_coupon_order wco where wco.coupon_id = wc.id and wco.coupon_order_status = 1 and wc.id = c.id) as sum_payment,
  606. (select count(wco.id) from wx_coupon wc,wx_coupon_order wco where wco.coupon_id = wc.id and wco.coupon_order_status = 3 and wc.id = c.id) as backpay_count,
  607. (select sum(round(sc.subsidy/100,2)) from wx_coupon wc
  608. left join wx_coupon_order wo on wo.coupon_id = wc.id
  609. left join wx_merchant_subsidy sc on sc.coupon_order_id = wo.id
  610. where wc.id = c.id) as sum_subsidy
  611. from wx_coupon c where c.type not in(8,9,100)
  612. <if test=" 1 == type ">
  613. and c.sale_price > 0
  614. </if>
  615. <if test=" 2 == type ">
  616. and c.sale_price = 0
  617. </if>
  618. <if test="title != null">
  619. and c.title = concat('%', #{title},'%')
  620. </if>
  621. <if test="id != null">
  622. and c.id = #{id}
  623. </if>
  624. order by c.status asc,c.create_date desc
  625. </select>
  626. <select id="findPressData" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  627. select c.*
  628. ,(select count(wop.id) from wx_coupon wc
  629. left join wx_order wo on wo.product_id = wc.id
  630. left join wx_order_press wop on wop.order_id = wo.id
  631. where wop.first = 1 and wc.id = c.id) as press_count,
  632. (select count(wo.id) from wx_coupon wc
  633. left join wx_order wo on wo.product_id = wc.id
  634. where wo.order_status = 7 and wc.id = c.id) as press_succ_count,
  635. (select count(wop.id) from wx_coupon wc
  636. left join wx_order wo on wo.product_id = wc.id
  637. left join wx_order_press wop on wop.order_id = wo.id
  638. where wc.id = c.id) as join_count,
  639. round(
  640. (select count(wco.id) xcount from wx_coupon wc
  641. left join wx_coupon_order wco on wco.coupon_id = wc.id
  642. where wc.type = 8 and wco.coupon_order_status = 1
  643. and wc.id = c.id)
  644. /
  645. (select count(wop.id) from wx_coupon wc
  646. left join wx_order wo on wo.product_id = wc.id
  647. left join wx_order_press wop on wop.order_id = wo.id
  648. where wop.first = 1 and wc.id = c.id)
  649. *100,2) as payment_rate
  650. from wx_coupon c where c.type = 8
  651. <if test="id != null">
  652. and c.id = #{id}
  653. </if>
  654. <if test="title != null">
  655. and c.title = concat('%', #{title},'%')
  656. </if>
  657. order by c.status asc,c.create_date desc
  658. </select>
  659. <!--
  660. <select id="findCouponSendCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  661. select DATE_FORMAT(c.create_time,'%Y-%m-%d') xtime,count(id) xcount from wx_coupon_action_log c
  662. where c.create_time between #{startdate} and #{enddate}
  663. group by xtime
  664. </select>
  665. <select id="findCouponGetCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  666. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon c
  667. left join wx_coupon_order wco on c.id = wco.coupon_id
  668. where 1=1
  669. and wco.create_date between #{startdate} and #{enddate}
  670. and wco.coupon_price = 0
  671. group by xtime
  672. </select>
  673. -->
  674. <select id="findCouponOrderCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  675. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon c
  676. left join wx_coupon_order wco on c.id = wco.coupon_id
  677. where c.type not in(8,9,100)
  678. and wco.create_date between #{startdate} and #{enddate}
  679. group by xtime
  680. </select>
  681. <select id="findCouponPaymentCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  682. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon c,wx_coupon_order wco
  683. where c.type not in(8,9,100)
  684. and wco.coupon_id = c.id and wco.coupon_order_status = 1
  685. and wco.update_date between #{startdate} and #{enddate}
  686. group by xtime
  687. </select>
  688. <select id="priceCouponSaleCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  689. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon c,wx_coupon_order wco
  690. where c.type not in(8,9,100)
  691. and wco.coupon_id = c.id and wco.coupon_price > 0
  692. and wco.create_date between #{startdate} and #{enddate}
  693. group by xtime
  694. </select>
  695. <select id="priceCouponPaymentCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  696. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon c,wx_coupon_order wco
  697. where c.type not in(8,9,100)
  698. and wco.coupon_id = c.id and wco.coupon_order_status = 1 and wco.coupon_price > 0
  699. and wco.update_date between #{startdate} and #{enddate}
  700. group by xtime
  701. </select>
  702. <select id="findSumPriceSaleMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
  703. select sum(round(c.sale_price/100,2)) from wx_coupon c,wx_coupon_order wco
  704. where wco.coupon_id = c.id and wco.coupon_price > 0
  705. and wco.create_date between #{startdate} and #{enddate}
  706. </select>
  707. <select id="findSumPricePayMent" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
  708. select sum(round(c.sale_price/100,2)) from wx_coupon c,wx_coupon_order wco
  709. where wco.coupon_id = c.id and wco.coupon_price > 0 and wco.coupon_order_status = 1
  710. and wco.update_date between #{startdate} and #{enddate}
  711. </select>
  712. <select id="findSumSubsidyMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
  713. select sum(round(sc.subsidy/100,2)) from wx_coupon c
  714. left join wx_coupon_order wo on wo.coupon_id = c.id
  715. left join wx_merchant_subsidy sc on sc.coupon_order_id = wo.id
  716. where c.type not in(8,9,100) and wo.coupon_order_status = 1
  717. and c.create_date between #{startdate} and #{enddate}
  718. </select>
  719. <!--砍价-->
  720. <select id="pressSendHistory" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  721. select DATE_FORMAT(wop.create_date,'%Y-%m-%d') xtime,count(wop.id) xcount from wx_coupon wc
  722. left join wx_order wo on wo.product_id = wc.id
  723. left join wx_order_press wop on wop.order_id = wo.id
  724. where wc.type = 8 and wop.first = 1 and
  725. wop.create_date between #{startdate} and #{enddate}
  726. group by xtime
  727. </select>
  728. <select id="pressSuccHistory" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  729. select DATE_FORMAT(wo.create_date,'%Y-%m-%d') xtime,count(wo.id) xcount from wx_coupon wc
  730. left join wx_order wo on wo.product_id = wc.id
  731. where wc.type = 8 and wo.order_status = 7
  732. and wo.create_date between #{startdate} and #{enddate}
  733. group by xtime
  734. </select>
  735. <select id="pressPaymentHistory" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  736. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon wc
  737. left join wx_coupon_order wco on wco.coupon_id = wc.id
  738. where wc.type = 8 and wco.coupon_order_status = 1
  739. and wco.create_date between #{startdate} and #{enddate}
  740. group by xtime
  741. </select>
  742. <select id="pressSuccRate" parameterType="com.iformall.domain.po.WxCoupon" resultType="java.lang.String">
  743. select
  744. round(
  745. (select count(wo.id) from wx_coupon wc
  746. left join wx_order wo on wo.product_id = wc.id
  747. where wo.order_status = 7 and wc.type = 8
  748. and wo.create_date between #{startdate} and #{enddate})
  749. /
  750. (select count(wop.id) from wx_coupon wc
  751. left join wx_order wo on wo.product_id = wc.id
  752. left join wx_order_press wop on wop.order_id = wo.id
  753. where wop.first = 1 and wc.type = 8
  754. and wop.create_date between #{startdate} and #{enddate})
  755. * 100
  756. ,2)
  757. </select>
  758. <select id="sumJoin" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
  759. select count(wop.id) from wx_coupon wc
  760. left join wx_order wo on wo.product_id = wc.id
  761. left join wx_order_press wop on wop.order_id = wo.id
  762. where wc.type = 8
  763. and wop.create_date between #{startdate} and #{enddate}
  764. </select>
  765. </mapper>