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.
 
 
 
 
 

397 rindas
14 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="allBUserVerifiedCouponOrderColumns" />
  139. from wx_coupon_order co,wx_order o,wx_coupon c,wx_c_user cu,wx_merchant_b_user bu
  140. where o.id = co.order_id
  141. and co.coupon_id = c.id
  142. and cu.id = co.c_user_id
  143. and bu.id = co.b_user_id
  144. <if test=" null != id ">
  145. and co.id = #{id}
  146. </if>
  147. <if test=" null != tenantId ">
  148. and co.tenant_id = #{tenantId}
  149. </if>
  150. <if test=" null != couponId ">
  151. and co.coupon_id = #{couponId}
  152. </if>
  153. <if test=" null != cUserId ">
  154. and co.c_user_id = #{cUserId}
  155. </if>
  156. <if test=" null != bUserId ">
  157. and co.b_user_id = #{bUserId}
  158. </if>
  159. <if test=" null != orderId ">
  160. and co.order_id = #{orderId}
  161. </if>
  162. <if test=" null != expiredTime ">
  163. and co.expired_time = #{expiredTime}
  164. </if>
  165. <if test=" null != couponOrderStatus ">
  166. and co.coupon_order_status = #{couponOrderStatus}
  167. </if>
  168. <if test=" null != createDate ">
  169. and co.create_date = #{createDate}
  170. </if>
  171. <if test=" null != updateDate ">
  172. and co.update_date = #{updateDate}
  173. </if>
  174. <if test=" null != couponPrice ">
  175. and co.coupon_price = #{couponPrice}
  176. </if>
  177. <if test=" null != ids ">
  178. and id in
  179. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  180. #{idItem}
  181. </foreach>
  182. </if>
  183. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  184. </select>
  185. <select id="findListOfOrderedByDate" parameterType="map" resultMap="BaseResultMap">
  186. select <include refid="allCouponOrderColumns" />
  187. from wx_coupon_order co,wx_order o
  188. where o.id = co.order_id
  189. and o.merchant_id = #{merchantID}
  190. <if test="startDate != null">
  191. AND co.create_date &gt; #{startDate,jdbcType=TIMESTAMP}
  192. </if>
  193. <if test="startDate != null">
  194. AND co.create_date &lt; #{endDate,jdbcType=TIMESTAMP}
  195. </if>
  196. AND (co.coupon_order_status = '0' or co.coupon_order_status = '1')
  197. </select>
  198. <select id="findListOfVerifiedByDate" parameterType="map" resultMap="BaseResultMap">
  199. select <include refid="allCouponOrderColumns" />
  200. from wx_coupon_order co,wx_order o
  201. where o.id = co.order_id
  202. and o.merchant_id = #{merchantID}
  203. <if test="startDate != null">
  204. AND co.update_date &gt; #{startDate,jdbcType=TIMESTAMP}
  205. </if>
  206. <if test="startDate != null">
  207. AND co.update_date &lt; #{endDate,jdbcType=TIMESTAMP}
  208. </if>
  209. AND co.coupon_order_status = '1'
  210. </select>
  211. <sql id="allCUserCouponOrderListColumns">
  212. c.id,c.expired_time,c.coupon_order_status,c.create_date,c.update_date,c.coupon_price,
  213. co.cover_img,co.title,co.sub_title,co.sale_price,co.use_price,co.price,
  214. m.name
  215. </sql>
  216. <sql id="allCUserCouponOrderDetailColumns">
  217. 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,
  218. 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,
  219. m.img_url,m.name,m.link_phone,m.status,
  220. s.addr,s.shop_number,s.baidu_poi,
  221. mb.building_name,mf.floor_name
  222. </sql>
  223. <resultMap id="CVoResultMap" type="com.simple.domain.vo.WxCouponOrderCVo">
  224. <id column="id" jdbcType="BIGINT" property="id" />
  225. <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
  226. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  227. <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
  228. <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
  229. <result column="order_id" jdbcType="BIGINT" property="orderId" />
  230. <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
  231. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
  232. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  233. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  234. <result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />
  235. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  236. <result column="type" jdbcType="INTEGER" property="type" />
  237. <result column="cover_img" jdbcType="VARCHAR" property="coverImg" />
  238. <result column="title" jdbcType="VARCHAR" property="title" />
  239. <result column="sub_title" jdbcType="VARCHAR" property="subTitle" />
  240. <result column="sale_price" jdbcType="INTEGER" property="salePrice" />
  241. <result column="use_price" jdbcType="INTEGER" property="usePrice" />
  242. <result column="detail" jdbcType="VARCHAR" property="detail" />
  243. <result column="price" jdbcType="INTEGER" property="price" />
  244. <result column="remark" jdbcType="VARCHAR" property="remark" />
  245. <result column="img_url" jdbcType="VARCHAR" property="merchantImgUrl" />
  246. <result column="name" jdbcType="VARCHAR" property="merchantName" />
  247. <result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone" />
  248. <result column="status" jdbcType="VARCHAR" property="merchantStatus" />
  249. <result column="addr" jdbcType="VARCHAR" property="addr"/>
  250. <result column="shop_number" jdbcType="VARCHAR" property="shopNumber"/>
  251. <result column="building_name" jdbcType="VARCHAR" property="buildingName" />
  252. <result column="floor_name" jdbcType="VARCHAR" property="floorName" />
  253. <result column="baidu_poi" jdbcType="VARCHAR" property="baiduPoi"/>
  254. </resultMap>
  255. <select id="findListOfCUser" parameterType="com.simple.domain.po.WxCouponOrder" resultMap="CVoResultMap">
  256. select <include refid="allCUserCouponOrderListColumns" />
  257. from wx_coupon_order c,wx_coupon co,wx_merchant m
  258. where 1=1
  259. and c.coupon_id = co.id
  260. and co.merchant_id = m.id
  261. <if test="cUserId != null">
  262. and c.c_user_id = #{cUserId}
  263. </if>
  264. <if test="tenantId != null">
  265. and c.tenant_id = #{tenantId}
  266. </if>
  267. <if test="couponOrderStatus != null">
  268. AND c.coupon_order_status = #{couponOrderStatus}
  269. </if>
  270. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  271. </select>
  272. <select id="selectDetailOfUser" parameterType="map" resultMap="CVoResultMap">
  273. select <include refid="allCUserCouponOrderDetailColumns" />
  274. from wx_coupon_order c,wx_coupon co,wx_merchant m
  275. left join wx_merchant_shop ms on ms.merchant_id = m.id
  276. left join wx_shop s on ms.shop_id = s.id
  277. left join wx_mall_building mb on s.building = mb.id
  278. left join wx_mall_floor mf on s.floor = mf.id
  279. where c.coupon_id = co.id
  280. and co.merchant_id = m.id
  281. <if test="cUserId != null">
  282. and c.c_user_id = #{cUserId}
  283. </if>
  284. <if test="merchantId != null">
  285. and co.merchant_id = #{merchantId}
  286. </if>
  287. <if test="tenantId != null">
  288. and c.tenant_id = #{tenantId}
  289. </if>
  290. <if test="couponOrderId != null">
  291. and c.id = #{couponOrderId}
  292. </if>
  293. </select>
  294. <select id="findCountByDateLimit" resultType="java.lang.Integer">
  295. select COUNT(*) FROM wx_coupon_order where tenant_id = #{tenantId} and create_date &gt;= #{startTime} and create_date &lt;= #{endTime}
  296. </select>
  297. <select id="sceneMarkingMap" resultType="hashmap" parameterType="hashmap">
  298. select count(c.id) carcount,c.create_date from (
  299. select id,DATE_FORMAT(create_date,'%Y-%m-%d') create_date
  300. from wx_car_cmd_log where tenant_id = #{tenantId} and cmd_type=#{cmdType}
  301. and create_date BETWEEN #{startdate} and #{enddate}
  302. ) c
  303. group by c.create_date
  304. </select>
  305. <select id="couponDataMap" resultType="com.simple.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap">
  306. SELECT DATE_FORMAT(create_date,'%m/%d') as createTime
  307. ,COUNT(DISTINCT c_user_id) as couponUserCount,count(*) as couponCount
  308. ,(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
  309. ,(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
  310. from wx_coupon_order where tenant_id=#{tenantId} AND create_date &gt;= #{startTime} and create_date &lt;= #{endTime} GROUP BY createTime
  311. </select>
  312. </mapper>