Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

681 righe
27 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="dynamicWhereConditionsForCoupon">
  164. <if test=" null != id ">
  165. and `id` = #{id}
  166. </if>
  167. <if test=" null != tenantId ">
  168. and `tenant_id` = #{tenantId}
  169. </if>
  170. <if test=" null == type ">
  171. and `type` &lt; 7
  172. </if>
  173. <if test=" null != type ">
  174. and `type` = #{type}
  175. </if>
  176. <if test=" null != coverImg ">
  177. and `cover_img` like concat('%', #{coverImg},'%')
  178. </if>
  179. <if test=" null != title and ''!=title">
  180. and `title` like concat('%', #{title},'%')
  181. </if>
  182. <if test=" null != subTitle ">
  183. and `sub_title` like concat('%', #{subTitle},'%')
  184. </if>
  185. <if test=" null != salePrice ">
  186. and `sale_price` = #{salePrice}
  187. </if>
  188. <if test=" null != usePrice ">
  189. and `use_price` = #{usePrice}
  190. </if>
  191. <if test=" null != useLimitQuantity ">
  192. and `use_limit_quantity` = #{useLimitQuantity}
  193. </if>
  194. <if test=" null != sendType ">
  195. and `send_type` = #{sendType}
  196. </if>
  197. <if test=" null != validType ">
  198. and `valid_type` = #{validType}
  199. </if>
  200. <if test=" null != validStartDate ">
  201. and `valid_start_date` = #{validStartDate}
  202. </if>
  203. <if test=" null != validEndDate ">
  204. and `valid_end_date` = #{validEndDate}
  205. </if>
  206. <if test=" null != validDays ">
  207. and `valid_days` = #{validDays}
  208. </if>
  209. <if test=" null != detail ">
  210. and `detail` like concat('%', #{detail},'%')
  211. </if>
  212. <if test=" null != price ">
  213. and `price` = #{price}
  214. </if>
  215. <if test=" null != unit ">
  216. and `unit` = #{unit}
  217. </if>
  218. <if test=" null != remainInventory ">
  219. and `remain_inventory` = #{remainInventory}
  220. </if>
  221. <if test=" null != inventory ">
  222. and `inventory` = #{inventory}
  223. </if>
  224. <if test=" null != remark ">
  225. and `remark` like concat('%', #{remark},'%')
  226. </if>
  227. <if test=" null != status">
  228. and `status` = #{status}
  229. </if>
  230. <if test=" null != startdate and null!=enddate">
  231. and `create_date` between #{startdate} and #{enddate}
  232. </if>
  233. <if test=" null != updateDate ">
  234. and `update_date` = #{updateDate}
  235. </if>
  236. <if test=" null != business ">
  237. and `business` = #{business}
  238. </if>
  239. <if test=" null != supportTransfer ">
  240. and `support_transfer` = #{supportTransfer}
  241. </if>
  242. <if test=" null != subsidyType ">
  243. and `subsidy_type` = #{subsidyType}
  244. </if>
  245. <if test=" null != subsidyNum ">
  246. and `subsidy_num` = #{subsidyNum}
  247. </if>
  248. <if test=" null != pressLimitNum ">
  249. and `press_limit_num` = #{pressLimitNum}
  250. </if>
  251. <if test=" null != pressLimitHours ">
  252. and `press_limit_hours` = #{pressLimitHours}
  253. </if>
  254. <if test=" null != autoRefund ">
  255. and `auto_refund` = #{autoRefund}
  256. </if>
  257. <if test=" null != ids ">
  258. and id in
  259. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  260. #{idItem}
  261. </foreach>
  262. </if>
  263. <if test=" null != sortColumns">order by ${sortColumns}</if>
  264. </sql>
  265. <select id="findCouponList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  266. select
  267. <include refid="allColumns"/>
  268. from wx_coupon
  269. <include refid="dynamicWhereConditionsForCoupon"/>
  270. </select>
  271. <resultMap id="WxCouponCVoMap" type="com.iformall.domain.vo.WxCouponCVo">
  272. <id column="id" jdbcType="BIGINT" property="id"/>
  273. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  274. <result column="type" jdbcType="INTEGER" property="type"/>
  275. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  276. <result column="title" jdbcType="VARCHAR" property="title"/>
  277. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  278. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  279. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  280. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  281. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  282. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  283. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  284. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  285. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  286. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  287. <result column="price" jdbcType="INTEGER" property="price"/>
  288. <result column="unit" jdbcType="INTEGER" property="unit"/>
  289. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  290. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  291. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  292. <result column="status" jdbcType="INTEGER" property="status"/>
  293. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  294. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  295. <result column="business" jdbcType="INTEGER" property="business"/>
  296. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  297. <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
  298. <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
  299. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  300. <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
  301. <result column="xtime" property="xtime"/>
  302. <result column="xcount" property="xcount"/>
  303. <result column="sale_count" property="saleCount"/>
  304. <result column="transfer_count" property="transferCount"/>
  305. <result column="sale_amount" property="saleAmount"/>
  306. <result column="sum_payment" property="sumPayment"/>
  307. <result column="backpay_count" property="backpayCount"/>
  308. <collection column="{productId=id}" property="merchantVoList"
  309. ofType="com.iformall.domain.vo.WxMerchantVo"
  310. javaType="java.util.List"
  311. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantBaseList" >
  312. </collection>
  313. </resultMap>
  314. <select id="findVoDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMap">
  315. select
  316. <include refid="allColumns"/>
  317. from wx_coupon
  318. where id = #{id}
  319. </select>
  320. <update id="reduceInventory">
  321. update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory>= #{number}
  322. </update>
  323. <update id="offExpiriedCouponByValidDate">
  324. update wx_coupon SET status = 1, update_date = now()
  325. where status = 0 and valid_type = 1 and valid_end_date &lt; now()
  326. </update>
  327. <update id="offExpiriedCouponByMerchantStatus">
  328. update wx_coupon c
  329. SET c.status = 1, c.update_date = now()
  330. where c.status = 0 and
  331. (select count(*) from wx_coupon_merchant cm, wx_merchant m
  332. where m.id = cm.merchant_id
  333. and c.id = cm.product_id
  334. and cm.status = 0
  335. and m.status = 1) = 0
  336. </update>
  337. <select id="findSaleMoneyByDate" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  338. select DATE_FORMAT(ci.create_date,'%Y-%m-%d') xtime,sum(round(ci.sale_amount/100,2)) xcount from wx_card_info ci
  339. left join wx_coupon c on c.id = ci.coupon_id
  340. where c.type = 100
  341. and ci.create_date between #{startdate} and #{enddate}
  342. group by xtime
  343. </select>
  344. <select id="findPaymentByDate" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  345. select DATE_FORMAT(wcs.create_date,'%Y-%m-%d') xtime,sum(round(wcs.real_payment/100,2)) xcount from wx_card_info ci
  346. left join wx_coupon c on c.id = ci.coupon_id
  347. left join wx_card_spend wcs on wcs.card_id = ci.id
  348. where c.type = 100
  349. and wcs.create_date between #{startdate} and #{enddate}
  350. group by xtime
  351. </select>
  352. <select id="findSaleCardCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
  353. select count(co.id)
  354. from wx_card_info ci
  355. left join wx_coupon c on c.id = ci.coupon_id
  356. left join wx_coupon_order co on co.id = ci.id
  357. where c.type = 100
  358. and c.create_date between #{startdate} and #{enddate}
  359. </select>
  360. <select id="findTranCardCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
  361. select count(distinct wcs.coupon_order_id) from wx_card_info ci
  362. left join wx_coupon c on c.id = ci.coupon_id
  363. left join wx_card_transfer_info wcs on wcs.coupon_order_id = ci.id
  364. where c.type = 100 and c.create_date between #{startdate} and #{enddate}
  365. </select>
  366. <select id="findSubsidyMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
  367. select sum(round(sc.subsidy/100,2)) from wx_card_info ci
  368. left join wx_coupon c on c.id = ci.coupon_id
  369. left join wx_merchant_subsidy sc on sc.coupon_order_id = ci.id
  370. where c.type = 100 and c.create_date between #{startdate} and #{enddate}
  371. </select>
  372. <select id="findCountData" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  373. select c.*,
  374. (select count(wco.id) from wx_coupon wc
  375. left join wx_coupon_order wco on wc.id = wco.coupon_id
  376. where wc.id = c.id) as sale_count,
  377. (select count(distinct wcs.coupon_order_id) from wx_card_info ci
  378. left join wx_coupon wc on wc.id = ci.coupon_id
  379. left join wx_card_transfer_info wcs on wcs.coupon_order_id = ci.id
  380. where wc.id = c.id) as transfer_count,
  381. (select sum(ci.sale_amount) from wx_card_info ci
  382. left join wx_coupon wc on wc.id = ci.coupon_id
  383. where wc.id = c.id) as sale_amount,
  384. (select sum(wcs.real_payment) from wx_card_info ci
  385. left join wx_coupon wc on wc.id = ci.coupon_id
  386. left join wx_card_spend wcs on wcs.card_id = ci.id
  387. where wc.id = c.id) as sum_payment,
  388. (select sum(sc.subsidy) from wx_card_info ci
  389. left join wx_coupon wc on wc.id = ci.coupon_id
  390. left join wx_merchant_subsidy sc on sc.coupon_order_id = ci.id
  391. where wc.id = c.id) as sum_subsidy
  392. from wx_coupon c where c.type = 100
  393. <if test="title != null">
  394. and c.title = concat('%', #{title},'%')
  395. </if>
  396. <if test="id != null">
  397. and c.id = #{id}
  398. </if>
  399. order by c.status asc,c.create_date desc
  400. </select>
  401. <select id="findCouponData" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  402. select c.*,
  403. (select count(wco.id) from wx_coupon_order wco where wco.coupon_id = c.id) as sale_count,
  404. (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,
  405. (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,
  406. (select sum(sc.subsidy) from wx_coupon wc
  407. left join wx_coupon_order wo on wo.coupon_id = wc.id
  408. left join wx_merchant_subsidy sc on sc.coupon_order_id = wo.id
  409. where wc.id = c.id) as sum_subsidy
  410. from wx_coupon c where c.type not in(8,9,100)
  411. <if test=" 1 == type ">
  412. and c.sale_price > 0
  413. </if>
  414. <if test=" 2 == type ">
  415. and c.sale_price = 0
  416. </if>
  417. <if test="title != null">
  418. and c.title = concat('%', #{title},'%')
  419. </if>
  420. <if test="id != null">
  421. and c.id = #{id}
  422. </if>
  423. order by c.status asc,c.create_date desc
  424. </select>
  425. <select id="findPressData" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  426. select c.*
  427. ,(select count(wop.id) from wx_coupon wc
  428. left join wx_order wo on wo.product_id = wc.id
  429. left join wx_order_press wop on wop.order_id = wo.id
  430. where wop.first = 1 and wc.id = c.id) as press_count,
  431. (select count(wo.id) from wx_coupon wc
  432. left join wx_order wo on wo.product_id = wc.id
  433. where wo.order_status = 1 and wc.id = c.id) as press_succ_count,
  434. (select count(wop.id) from wx_coupon wc
  435. left join wx_order wo on wo.product_id = wc.id
  436. left join wx_order_press wop on wop.order_id = wo.id
  437. where wc.id = c.id) as join_count,
  438. round(
  439. (select count(wco.id) xcount from wx_coupon wc
  440. left join wx_coupon_order wco on wco.coupon_id = wc.id
  441. where wc.type = 8 and wco.coupon_order_status = 1
  442. and wc.id = c.id)
  443. /
  444. (select count(wop.id) from wx_coupon wc
  445. left join wx_order wo on wo.product_id = wc.id
  446. left join wx_order_press wop on wop.order_id = wo.id
  447. where wop.first = 1 and wc.id = c.id)
  448. *100,2) as payment_rate
  449. from wx_coupon c where c.type = 8
  450. <if test="id != null">
  451. and c.id = #{id}
  452. </if>
  453. <if test="title != null">
  454. and c.title = concat('%', #{title},'%')
  455. </if>
  456. order by c.status asc,c.create_date desc
  457. </select>
  458. <!--
  459. <select id="findCouponSendCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  460. select DATE_FORMAT(c.create_time,'%Y-%m-%d') xtime,count(id) xcount from wx_coupon_action_log c
  461. where c.create_time between #{startdate} and #{enddate}
  462. group by xtime
  463. </select>
  464. <select id="findCouponGetCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  465. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon c
  466. left join wx_coupon_order wco on c.id = wco.coupon_id
  467. where 1=1
  468. and wco.create_date between #{startdate} and #{enddate}
  469. and wco.coupon_price = 0
  470. group by xtime
  471. </select>
  472. -->
  473. <select id="findCouponOrderCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  474. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon c
  475. left join wx_coupon_order wco on c.id = wco.coupon_id
  476. where c.type not in(8,9,100)
  477. and wco.create_date between #{startdate} and #{enddate}
  478. group by xtime
  479. </select>
  480. <select id="findCouponPaymentCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  481. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon c,wx_coupon_order wco
  482. where c.type not in(8,9,100)
  483. and wco.coupon_id = c.id and wco.coupon_order_status = 1
  484. and wco.update_date between #{startdate} and #{enddate}
  485. group by xtime
  486. </select>
  487. <select id="priceCouponSaleCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  488. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon c,wx_coupon_order wco
  489. where c.type not in(8,9,100)
  490. and wco.coupon_id = c.id and wco.coupon_price > 0
  491. and wco.create_date between #{startdate} and #{enddate}
  492. group by xtime
  493. </select>
  494. <select id="priceCouponPaymentCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  495. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon c,wx_coupon_order wco
  496. where c.type not in(8,9,100)
  497. and wco.coupon_id = c.id and wco.coupon_order_status = 1 and wco.coupon_price > 0
  498. and wco.update_date between #{startdate} and #{enddate}
  499. group by xtime
  500. </select>
  501. <select id="findSumPriceSaleMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
  502. select sum(round(c.sale_price/100,2)) from wx_coupon c,wx_coupon_order wco
  503. where wco.coupon_id = c.id and wco.coupon_price > 0
  504. and wco.create_date between #{startdate} and #{enddate}
  505. </select>
  506. <select id="findSumPricePayMent" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
  507. select sum(round(c.sale_price/100,2)) from wx_coupon c,wx_coupon_order wco
  508. where wco.coupon_id = c.id and wco.coupon_price > 0 and wco.coupon_order_status = 1
  509. and wco.update_date between #{startdate} and #{enddate}
  510. </select>
  511. <select id="findSumSubsidyMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
  512. select sum(round(sc.subsidy/100,2)) from wx_coupon c
  513. left join wx_coupon_order wo on wo.coupon_id = c.id
  514. left join wx_merchant_subsidy sc on sc.coupon_order_id = wo.id
  515. where c.type not in(8,9,100) and wo.coupon_order_status = 1
  516. and c.create_date between #{startdate} and #{enddate}
  517. </select>
  518. <!--砍价-->
  519. <select id="pressSendHistory" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  520. select DATE_FORMAT(wop.create_date,'%Y-%m-%d') xtime,count(wop.id) xcount from wx_coupon wc
  521. left join wx_order wo on wo.product_id = wc.id
  522. left join wx_order_press wop on wop.order_id = wo.id
  523. where wc.type = 8 and wop.first = 1 and
  524. wop.create_date between #{startdate} and #{enddate}
  525. group by xtime
  526. </select>
  527. <select id="pressSuccHistory" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  528. select DATE_FORMAT(wo.create_date,'%Y-%m-%d') xtime,count(wo.id) xcount from wx_coupon wc
  529. left join wx_order wo on wo.product_id = wc.id
  530. where wc.type = 8 and wo.order_status = 1
  531. and wo.create_date between #{startdate} and #{enddate}
  532. group by xtime
  533. </select>
  534. <select id="pressPaymentHistory" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
  535. select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon wc
  536. left join wx_coupon_order wco on wco.coupon_id = wc.id
  537. where wc.type = 8 and wco.coupon_order_status = 1
  538. and wco.create_date between #{startdate} and #{enddate}
  539. group by xtime
  540. </select>
  541. <select id="pressSuccRate" parameterType="com.iformall.domain.po.WxCoupon" resultType="java.lang.String">
  542. select
  543. round(
  544. (select count(wo.id) from wx_coupon wc
  545. left join wx_order wo on wo.product_id = wc.id
  546. where wo.order_status = 1 and wc.type = 8
  547. and wo.create_date between #{startdate} and #{enddate})
  548. /
  549. (select count(wop.id) from wx_coupon wc
  550. left join wx_order wo on wo.product_id = wc.id
  551. left join wx_order_press wop on wop.order_id = wo.id
  552. where wop.first = 1 and wc.type = 8
  553. and wop.create_date between #{startdate} and #{enddate})
  554. * 100
  555. ,2)
  556. </select>
  557. <select id="sumJoin" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
  558. select count(wop.id) from wx_coupon wc
  559. left join wx_order wo on wo.product_id = wc.id
  560. left join wx_order_press wop on wop.order_id = wo.id
  561. where wc.type = 8
  562. and wop.create_date between #{startdate} and #{enddate}
  563. </select>
  564. </mapper>