Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

432 lignes
16 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.simple.mapper.WxCouponOrderMapper">
  4. <resultMap id="BaseResultMap" type="com.simple.domain.po.WxCouponOrder">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
  7. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  8. <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
  9. <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
  10. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  11. <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
  12. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
  13. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  14. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  15. <result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />
  16. </resultMap>
  17. <sql id="allColumns">
  18. `id`,`tenant_id`,`coupon_id`,`c_user_id`,`b_user_id`,`order_id`,`expired_time`,`coupon_order_status`,`create_date`,`update_date`,`coupon_price`
  19. </sql>
  20. <sql id="dynamicWhereConditions">
  21. where 1 = 1
  22. <if test=" null != id ">
  23. and `id` = #{id}
  24. </if>
  25. <if test=" null != tenantId ">
  26. and `tenant_id` = #{tenantId}
  27. </if>
  28. <if test=" null != couponId ">
  29. and `coupon_id` = #{couponId}
  30. </if>
  31. <if test=" null != cUserId ">
  32. and `c_user_id` = #{cUserId}
  33. </if>
  34. <if test=" null != bUserId ">
  35. and `b_user_id` = #{bUserId}
  36. </if>
  37. <if test=" null != orderId ">
  38. and `order_id` = #{orderId}
  39. </if>
  40. <if test=" null != expiredTime ">
  41. and `expired_time` = #{expiredTime}
  42. </if>
  43. <if test=" null != couponOrderStatus ">
  44. and `coupon_order_status` = #{couponOrderStatus}
  45. </if>
  46. <if test=" null != createDate ">
  47. and `create_date` = #{createDate}
  48. </if>
  49. <if test=" null != updateDate ">
  50. and `update_date` = #{updateDate}
  51. </if>
  52. <if test=" null != couponPrice ">
  53. and `coupon_price` = #{couponPrice}
  54. </if>
  55. <if test=" null != ids ">
  56. and id in
  57. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  58. #{idItem}
  59. </foreach>
  60. </if>
  61. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  62. </sql>
  63. <select id="findList" parameterType="com.simple.domain.po.WxCouponOrder" resultMap="BaseResultMap">
  64. select <include refid="allColumns" /> from wx_coupon_order
  65. <include refid="dynamicWhereConditions" />
  66. </select>
  67. <select id="countList" parameterType="com.simple.domain.po.WxCouponOrder" resultType="java.lang.Integer">
  68. select count(*) from wx_coupon_order
  69. <include refid="dynamicWhereConditions" />
  70. </select>
  71. <resultMap id="BVoResultMap" type="com.simple.domain.vo.WxCouponOrderBVo">
  72. <id column="id" jdbcType="BIGINT" property="id" />
  73. <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
  74. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  75. <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
  76. <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
  77. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  78. <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
  79. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
  80. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  81. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  82. <result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />
  83. <result column="type" jdbcType="INTEGER" property="type" />
  84. <result column="title" jdbcType="VARCHAR" property="title" />
  85. <result column="sale_price" jdbcType="INTEGER" property="salePrice" />
  86. <result column="use_price" jdbcType="INTEGER" property="usePrice" />
  87. <result column="price" jdbcType="INTEGER" property="price" />
  88. <result column="name" jdbcType="VARCHAR" property="bUserName" />
  89. <result column="phone" jdbcType="VARCHAR" property="cUserPhone" />
  90. </resultMap>
  91. <sql id="allBUserVerifiedCouponOrderColumns">
  92. co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
  93. c.type,c.title,c.sale_price,c.use_price,c.price,
  94. bu.name,cu.phone
  95. </sql>
  96. <sql id="allBUserOrderedCouponOrderColumns">
  97. co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
  98. c.type,c.title,c.sale_price,c.use_price,c.price,
  99. cu.phone
  100. </sql>
  101. <sql id="allCouponOrderColumns">
  102. co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price
  103. </sql>
  104. <select id="findListOfOrderedByDateForBUser" parameterType="map" resultMap="BVoResultMap">
  105. select <include refid="allBUserOrderedCouponOrderColumns" />
  106. from wx_coupon_order co,wx_order o,wx_coupon c,wx_c_user cu
  107. where o.id = co.order_id
  108. and o.merchant_id = #{merchantID}
  109. and co.coupon_id = c.id
  110. and cu.id = co.c_user_id
  111. <if test="startDate != null">
  112. AND co.create_date &gt; #{startDate,jdbcType=TIMESTAMP}
  113. </if>
  114. <if test="startDate != null">
  115. AND co.create_date &lt; #{endDate,jdbcType=TIMESTAMP}
  116. </if>
  117. AND (co.coupon_order_status = '0' or co.coupon_order_status = '1')
  118. order by co.create_date desc
  119. </select>
  120. <select id="findListOfVerifiedByDateForBUser" parameterType="map" resultMap="BVoResultMap">
  121. select <include refid="allBUserVerifiedCouponOrderColumns" />
  122. from wx_coupon_order co,wx_order o,wx_coupon c,wx_c_user cu,wx_merchant_b_user bu
  123. where o.id = co.order_id
  124. and o.merchant_id = #{merchantID}
  125. and co.coupon_id = c.id
  126. and cu.id = co.c_user_id
  127. and bu.id = co.b_user_id
  128. <if test="startDate != null">
  129. AND co.update_date &gt; #{startDate,jdbcType=TIMESTAMP}
  130. </if>
  131. <if test="startDate != null">
  132. AND co.update_date &lt; #{endDate,jdbcType=TIMESTAMP}
  133. </if>
  134. AND co.coupon_order_status = '1'
  135. order by co.update_date desc
  136. </select>
  137. <select id="findListOfAdmin" parameterType="com.simple.domain.po.WxCouponOrder" resultMap="BVoResultMap">
  138. select <include refid="allBUserOrderedCouponOrderColumns" />
  139. from wx_coupon_order co,wx_order o,wx_coupon c,wx_c_user cu
  140. where o.id = co.order_id
  141. and co.coupon_id = c.id
  142. and cu.id = co.c_user_id
  143. <if test=" null != id ">
  144. and co.id = #{id}
  145. </if>
  146. <if test=" null != tenantId ">
  147. and co.tenant_id = #{tenantId}
  148. </if>
  149. <if test=" null != couponId ">
  150. and co.coupon_id = #{couponId}
  151. </if>
  152. <if test=" null != cUserId ">
  153. and co.c_user_id = #{cUserId}
  154. </if>
  155. <if test=" null != bUserId ">
  156. and co.b_user_id = #{bUserId}
  157. </if>
  158. <if test=" null != orderId ">
  159. and co.order_id = #{orderId}
  160. </if>
  161. <if test=" null != expiredTime ">
  162. and co.expired_time = #{expiredTime}
  163. </if>
  164. <if test=" null != couponOrderStatus ">
  165. and co.coupon_order_status = #{couponOrderStatus}
  166. </if>
  167. <if test=" null != createDate ">
  168. and co.create_date = #{createDate}
  169. </if>
  170. <if test=" null != updateDate ">
  171. and co.update_date = #{updateDate}
  172. </if>
  173. <if test=" null != couponPrice ">
  174. and co.coupon_price = #{couponPrice}
  175. </if>
  176. <if test=" null != ids ">
  177. and id in
  178. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  179. #{idItem}
  180. </foreach>
  181. </if>
  182. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  183. </select>
  184. <select id="findListOfOrderedByDate" parameterType="map" resultMap="BaseResultMap">
  185. select <include refid="allCouponOrderColumns" />
  186. from wx_coupon_order co,wx_order o
  187. where o.id = co.order_id
  188. and o.merchant_id = #{merchantID}
  189. <if test="startDate != null">
  190. AND co.create_date &gt; #{startDate,jdbcType=TIMESTAMP}
  191. </if>
  192. <if test="startDate != null">
  193. AND co.create_date &lt; #{endDate,jdbcType=TIMESTAMP}
  194. </if>
  195. AND (co.coupon_order_status = '0' or co.coupon_order_status = '1')
  196. </select>
  197. <select id="findListOfVerifiedByDate" parameterType="map" resultMap="BaseResultMap">
  198. select <include refid="allCouponOrderColumns" />
  199. from wx_coupon_order co,wx_order o
  200. where o.id = co.order_id
  201. and o.merchant_id = #{merchantID}
  202. <if test="startDate != null">
  203. AND co.update_date &gt; #{startDate,jdbcType=TIMESTAMP}
  204. </if>
  205. <if test="startDate != null">
  206. AND co.update_date &lt; #{endDate,jdbcType=TIMESTAMP}
  207. </if>
  208. AND co.coupon_order_status = '1'
  209. </select>
  210. <sql id="allCUserCouponOrderListColumns">
  211. c.id,c.expired_time,c.coupon_order_status,c.create_date,c.update_date,c.coupon_price,
  212. co.cover_img,co.title,co.sub_title,co.sale_price,co.use_price,co.price,
  213. m.name
  214. </sql>
  215. <sql id="allCUserCouponOrderDetailColumns">
  216. c.id,c.tenant_id,c.coupon_id,c.c_user_id,c.b_user_id,c.order_id,c.expired_time,c.coupon_order_status,c.create_date,c.update_date,c.coupon_price,
  217. co.merchant_id,co.type,co.cover_img,co.title,co.sub_title,co.sale_price,co.use_price,co.price,co.detail,co.remark,
  218. m.img_url,m.name,m.link_phone,m.status,
  219. s.addr,s.shop_number,s.baidu_poi,
  220. mb.building_name,mf.floor_name
  221. </sql>
  222. <resultMap id="CVoResultMap" type="com.simple.domain.vo.WxCouponOrderCVo">
  223. <id column="id" jdbcType="BIGINT" property="id" />
  224. <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
  225. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  226. <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
  227. <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
  228. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  229. <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
  230. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
  231. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  232. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  233. <result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />
  234. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  235. <result column="type" jdbcType="INTEGER" property="type" />
  236. <result column="cover_img" jdbcType="VARCHAR" property="coverImg" />
  237. <result column="title" jdbcType="VARCHAR" property="title" />
  238. <result column="sub_title" jdbcType="VARCHAR" property="subTitle" />
  239. <result column="sale_price" jdbcType="INTEGER" property="salePrice" />
  240. <result column="use_price" jdbcType="INTEGER" property="usePrice" />
  241. <result column="detail" jdbcType="VARCHAR" property="detail" />
  242. <result column="price" jdbcType="INTEGER" property="price" />
  243. <result column="remark" jdbcType="VARCHAR" property="remark" />
  244. <result column="img_url" jdbcType="VARCHAR" property="merchantImgUrl" />
  245. <result column="name" jdbcType="VARCHAR" property="merchantName" />
  246. <result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone" />
  247. <result column="status" jdbcType="VARCHAR" property="merchantStatus" />
  248. <result column="addr" jdbcType="VARCHAR" property="addr"/>
  249. <result column="shop_number" jdbcType="VARCHAR" property="shopNumber"/>
  250. <result column="building_name" jdbcType="VARCHAR" property="buildingName" />
  251. <result column="floor_name" jdbcType="VARCHAR" property="floorName" />
  252. <result column="baidu_poi" jdbcType="VARCHAR" property="baiduPoi"/>
  253. </resultMap>
  254. <select id="findListOfCUser" parameterType="com.simple.domain.po.WxCouponOrder" resultMap="CVoResultMap">
  255. select <include refid="allCUserCouponOrderListColumns" />
  256. from wx_coupon_order c,wx_coupon co,wx_merchant m
  257. where 1=1
  258. and c.coupon_id = co.id
  259. and co.merchant_id = m.id
  260. <if test="cUserId != null">
  261. and c.c_user_id = #{cUserId}
  262. </if>
  263. <if test="tenantId != null">
  264. and c.tenant_id = #{tenantId}
  265. </if>
  266. <if test="couponOrderStatus != null">
  267. AND c.coupon_order_status = #{couponOrderStatus}
  268. </if>
  269. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  270. </select>
  271. <select id="selectDetailOfUser" parameterType="map" resultMap="CVoResultMap">
  272. select <include refid="allCUserCouponOrderDetailColumns" />
  273. from wx_coupon_order c,wx_coupon co,wx_merchant m
  274. left join wx_merchant_shop ms on ms.merchant_id = m.id
  275. left join wx_shop s on ms.shop_id = s.id
  276. left join wx_mall_building mb on s.building = mb.id
  277. left join wx_mall_floor mf on s.floor = mf.id
  278. where c.coupon_id = co.id
  279. and co.merchant_id = m.id
  280. <if test="cUserId != null">
  281. and c.c_user_id = #{cUserId}
  282. </if>
  283. <if test="merchantId != null">
  284. and co.merchant_id = #{merchantId}
  285. </if>
  286. <if test="tenantId != null">
  287. and c.tenant_id = #{tenantId}
  288. </if>
  289. <if test="couponOrderId != null">
  290. and c.id = #{couponOrderId}
  291. </if>
  292. </select>
  293. <select id="findCountByDateLimit" resultType="java.lang.Integer">
  294. select COUNT(*) FROM wx_coupon_order where tenant_id = #{tenantId} and create_date &gt;= #{startTime} and create_date &lt;= #{endTime}
  295. </select>
  296. <select id="couponDataMap" resultType="com.simple.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap">
  297. SELECT DATE_FORMAT(create_date,'%m/%d') as createTime
  298. ,COUNT(DISTINCT c_user_id) as couponUserCount,count(*) as couponCount
  299. ,(select Count(*) from wx_coupon_order c where coupon_order_status=1 AND DATE_FORMAT(create_date,'%m/%d')=createTime and tenant_id=#{tenantId} AND c.update_date &gt;= #{startTime} and c.update_date &lt;= #{endTime}) as verifyCount
  300. ,(select Count(DISTINCT c_user_id) from wx_coupon_order d where coupon_order_status=1 AND DATE_FORMAT(create_date,'%m/%d')=createTime and tenant_id=#{tenantId} AND d.update_date &gt;= #{startTime} and d.update_date &lt;= #{endTime}) as verifyUserCount
  301. from wx_coupon_order where tenant_id=#{tenantId} AND create_date &gt;= #{startTime} and create_date &lt;= #{endTime} GROUP BY createTime
  302. </select>
  303. <select id="couponDataList" resultType="com.simple.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap">
  304. SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as createTime
  305. ,COUNT(DISTINCT c_user_id) as couponUserCount,count(*) as couponCount
  306. ,(select Count(*) from wx_coupon_order c where coupon_order_status=1 AND DATE_FORMAT(create_date,'%Y-%m-%d')=createTime and tenant_id=#{tenantId} AND c.update_date &gt;= #{startTime} and c.update_date &lt;= #{endTime}) as verifyCount
  307. ,(select Count(DISTINCT c_user_id) from wx_coupon_order d where coupon_order_status=1 AND DATE_FORMAT(create_date,'%Y-%m-%d')=createTime and tenant_id=#{tenantId} AND d.update_date &gt;= #{startTime} and d.update_date &lt;= #{endTime}) as verifyUserCount
  308. from wx_coupon_order where tenant_id=#{tenantId} AND create_date &gt;= #{startTime} and create_date &lt;= #{endTime} GROUP BY createTime
  309. </select>
  310. <select id="touchUsersReportList" resultType="com.simple.domain.vo.TouchUsersReportVo" parameterType="hashmap">
  311. SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime
  312. ,COUNT(DISTINCT c_user_id) as userCount,count(*) as couponCount
  313. ,(select Count(*) from wx_coupon_order c where coupon_order_status=1 AND DATE_FORMAT(create_date,'%Y-%m-%d')=xTime and tenant_id=#{tenantId}
  314. <if test="startTime != null">
  315. AND c.update_date &gt;= #{startTime}
  316. </if>
  317. <if test="endTime != null">
  318. and c.update_date &lt;= #{endTime}
  319. </if>
  320. ) as verifyCount
  321. ,(select Count(DISTINCT c_user_id) from wx_coupon_order d where coupon_order_status=1 AND DATE_FORMAT(create_date,'%Y-%m-%d')=xTime and tenant_id=#{tenantId} AND d.update_date &gt;= #{startTime} and d.update_date &lt;= #{endTime}) as verifyUserCount
  322. from wx_coupon_order where tenant_id=#{tenantId}
  323. <if test="startTime != null">
  324. AND create_date &gt;= #{startTime}
  325. </if>
  326. <if test="endTime != null">
  327. and create_date &lt;= #{endTime}
  328. </if>
  329. GROUP BY xTime
  330. </select>
  331. <select id="queryPriceTotalGroup" resultType="com.simple.domain.vo.CUserDateAmountVo" >
  332. SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime,SUM(coupon_price) as price from wx_coupon_order
  333. where tenant_id=#{tenantId} AND create_date &gt;= #{startTime} and create_date &lt;= #{endTime} GROUP BY xTime
  334. </select>
  335. <select id="queryPriceTotal" resultType="java.lang.Integer" >
  336. SELECT SUM(coupon_price) from wx_coupon_order
  337. where tenant_id=#{tenantId} AND create_date &gt;= #{startTime} and create_date &lt;= #{endTime}
  338. </select>
  339. </mapper>