Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

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