選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 

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