Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

724 wiersze
33 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.WxOrderMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxOrder">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="order_number" jdbcType="BIGINT" property="orderNumber"/>
  7. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  8. <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
  9. <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
  10. <result column="product_id" jdbcType="BIGINT" property="productId"/>
  11. <result column="type" jdbcType="TINYINT" property="type"/>
  12. <result column="payment_type" jdbcType="INTEGER" property="paymentType"/>
  13. <result column="payment" jdbcType="INTEGER" property="payment"/>
  14. <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/>
  15. <result column="order_status" jdbcType="INTEGER" property="orderStatus"/>
  16. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  17. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  18. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  19. <result column="press_end_date" jdbcType="TIMESTAMP" property="pressEndDate"/>
  20. <result column="press_current_num" jdbcType="INTEGER" property="pressCurrentNum"/>
  21. <result column="press_current_value" jdbcType="INTEGER" property="pressCurrentValue"/>
  22. <result column="order_group_id" jdbcType="BIGINT" property="orderGroupId"/>
  23. </resultMap>
  24. <sql id="allColumns">
  25. `id`,`order_number`,`tenant_id`,`c_user_id`,`coupon_channel_id`,`product_id`,`type`,`payment_type`,`payment`,`payment_time`,`order_status`,`create_date`,`update_date`,`detail`,
  26. `press_end_date`,`press_current_num`,`press_current_value`,`order_group_id`
  27. </sql>
  28. <sql id="dynamicWhereConditions">
  29. where 1 = 1
  30. <if test=" null != id ">
  31. and `id` = #{id}
  32. </if>
  33. <if test=" null != orderNumber ">
  34. and `order_number` = #{orderNumber}
  35. </if>
  36. <if test=" null != tenantId ">
  37. and `tenant_id` = #{tenantId}
  38. </if>
  39. <if test=" null != cUserId ">
  40. and `c_user_id` = #{cUserId}
  41. </if>
  42. <if test=" null != couponChannelId ">
  43. and `coupon_channel_id` = #{couponChannelId}
  44. </if>
  45. <if test=" null != productId ">
  46. and `product_id` = #{productId}
  47. </if>
  48. <if test=" null != type ">
  49. and `type` = #{type}
  50. </if>
  51. <if test=" null != paymentType ">
  52. and `payment_type` = #{paymentType}
  53. </if>
  54. <if test=" null != payment ">
  55. and `payment` = #{payment}
  56. </if>
  57. <if test=" null != paymentTime ">
  58. and `payment_time` = #{paymentTime}
  59. </if>
  60. <if test=" null != orderStatus ">
  61. and `order_status` = #{orderStatus}
  62. </if>
  63. <if test=" null != createDate ">
  64. and `create_date` = #{createDate}
  65. </if>
  66. <if test=" null != updateDate ">
  67. and `update_date` = #{updateDate}
  68. </if>
  69. <if test=" null != detail ">
  70. and `detail` like concat('%', #{detail},'%')
  71. </if>
  72. <if test=" null != pressEndDate ">
  73. and `press_end_date` = #{pressEndDate}
  74. </if>
  75. <if test=" null != pressCurrentNum ">
  76. and `press_current_num` = #{pressCurrentNum}
  77. </if>
  78. <if test=" null != pressCurrentValue ">
  79. and `press_current_value` = #{pressCurrentValue}
  80. </if>
  81. <if test=" null != orderGroupId ">
  82. and `order_group_id` = #{orderGroupId}
  83. </if>
  84. <if test=" null != statusS ">
  85. and `order_status` in
  86. <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")">
  87. #{sItem}
  88. </foreach>
  89. </if>
  90. <if test=" null != ids ">
  91. and id in
  92. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  93. #{idItem}
  94. </foreach>
  95. </if>
  96. <if test=" null != sortColumns">order by ${sortColumns}</if>
  97. </sql>
  98. <select id="findList" parameterType="com.iformall.domain.po.WxOrder" resultMap="BaseResultMap">
  99. select
  100. <include refid="allColumns"/>
  101. from wx_order
  102. <include refid="dynamicWhereConditions"/>
  103. </select>
  104. <select id="countList" parameterType="com.iformall.domain.po.WxOrder" resultType="java.lang.Integer">
  105. select count(*) from wx_order
  106. <include refid="dynamicWhereConditions"/>
  107. </select>
  108. <select id="findListOfUnpaidOrderByDate" parameterType="map" resultMap="BaseResultMap">
  109. select
  110. <include refid="allColumns"/>
  111. from wx_order
  112. where order_status = '0' and press_end_date is null
  113. <if test="type != null">
  114. AND type = #{type,jdbcType=TINYINT}
  115. </if>
  116. <if test="startDate != null">
  117. AND unix_timestamp(`create_date`) &gt; unix_timestamp(#{startDate,jdbcType=TIMESTAMP})
  118. </if>
  119. <if test="endDate != null">
  120. AND unix_timestamp(`create_date`) &lt; unix_timestamp(#{endDate,jdbcType=TIMESTAMP})
  121. </if>
  122. </select>
  123. <select id="findListOfUnpaidPressOrderByDate" parameterType="map" resultMap="BaseResultMap">
  124. select
  125. <include refid="allColumns"/>
  126. from wx_order
  127. where press_end_date is not null and (order_status = 6 or order_status = 7)
  128. <if test="type != null">
  129. AND type = #{type,jdbcType=TINYINT}
  130. </if>
  131. <if test="startDate != null">
  132. AND unix_timestamp(`create_date`) &gt; unix_timestamp(#{startDate,jdbcType=TIMESTAMP})
  133. </if>
  134. <if test="endDate != null">
  135. AND unix_timestamp(`press_end_date`) &lt; unix_timestamp(#{endDate,jdbcType=TIMESTAMP})
  136. </if>
  137. </select>
  138. <select id="findListOfCompleteUnPaidPressOrderByDate" parameterType="map" resultMap="BaseResultMap">
  139. select
  140. <include refid="allColumns"/>
  141. from wx_order
  142. where press_end_date is not null and order_status = 7
  143. <if test="type != null">
  144. AND type = #{type,jdbcType=TINYINT}
  145. </if>
  146. <if test="startDate != null">
  147. AND unix_timestamp(`create_date`) &gt; unix_timestamp(#{startDate,jdbcType=TIMESTAMP})
  148. </if>
  149. <if test="endDate != null">
  150. AND unix_timestamp(`update_date`) &lt; unix_timestamp(#{endDate,jdbcType=TIMESTAMP})
  151. </if>
  152. </select>
  153. <sql id="allCUserOrderListColumns">
  154. o.id,o.order_number,o.tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment,o.payment_time,o.order_status,o.create_date,o.update_date,
  155. c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.valid_start_date,c.valid_end_date,
  156. cal.channel_type as send_channel_type
  157. </sql>
  158. <sql id="allCUserOrderDetailColumns">
  159. o.id,o.order_number,o.tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment,o.payment_time,o.order_status,o.create_date,o.update_date,
  160. c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.detail,c.remark,c.valid_start_date,c.valid_end_date,
  161. co.id as coupon_order_id,co.coupon_order_status,c.support_transfer
  162. </sql>
  163. <update id="updateStatusByPressCouponId" parameterType="com.iformall.domain.po.WxOrder">
  164. update wx_order set order_status=#{orderStatus}
  165. where product_id=#{productId}
  166. and press_end_date is not null and order_status in (6,7)
  167. <if test=" null != tenantId ">
  168. and `tenant_id` = #{tenantId}
  169. </if>
  170. </update>
  171. <update id="updateOrderGroupStatusByCouponId" parameterType="com.iformall.domain.po.WxOrder">
  172. update wx_order set order_status=#{orderStatus},update_date=#{updateDate}
  173. where product_id=#{productId} and order_status in(10,15)
  174. <if test=" null != tenantId ">
  175. and `tenant_id` = #{tenantId}
  176. </if>
  177. </update>
  178. <update id="updateOrderGroupStatusByCouponChannelId" parameterType="com.iformall.domain.po.WxOrder">
  179. update wx_order set order_status=#{orderStatus},update_date=#{updateDate}
  180. where coupon_channel_id=#{couponChannelId} and order_status in(10,15)
  181. <if test=" null != tenantId ">
  182. and `tenant_id` = #{tenantId}
  183. </if>
  184. </update>
  185. <resultMap id="CVoResultMap" type="com.iformall.domain.vo.WxOrderCouponVo">
  186. <id column="id" jdbcType="BIGINT" property="id"/>
  187. <result column="order_number" jdbcType="BIGINT" property="orderNumber"/>
  188. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  189. <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
  190. <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
  191. <result column="product_id" jdbcType="BIGINT" property="productId"/>
  192. <result column="payment_type" jdbcType="INTEGER" property="paymentType"/>
  193. <result column="payment" jdbcType="INTEGER" property="payment"/>
  194. <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/>
  195. <result column="order_status" jdbcType="INTEGER" property="orderStatus"/>
  196. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  197. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  198. <result column="type" jdbcType="INTEGER" property="type"/>
  199. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  200. <result column="title" jdbcType="VARCHAR" property="title"/>
  201. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  202. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  203. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  204. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  205. <result column="price" jdbcType="INTEGER" property="price"/>
  206. <result column="unit" jdbcType="INTEGER" property="unit"/>
  207. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  208. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  209. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  210. <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId"/>
  211. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus"/>
  212. <result column="send_channel_type" jdbcType="INTEGER" property="sendChannelType" />
  213. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  214. <collection column="{productId=product_id}" property="merchantVoList"
  215. ofType="com.iformall.domain.vo.WxMerchantVo"
  216. javaType="java.util.List"
  217. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" >
  218. </collection>
  219. </resultMap>
  220. <select id="findListOfCUser" parameterType="com.iformall.domain.po.WxOrder" resultMap="CVoResultMap">
  221. select
  222. <include refid="allCUserOrderListColumns"/>
  223. from wx_coupon c,wx_order o
  224. left join wx_coupon_order co on co.order_id = o.id
  225. left join wx_coupon_action_log cal on cal.coupon_order_id = co.id
  226. where o.product_id = c.id and o.order_status in (0,1,2,3,4,5)
  227. <if test="cUserId != null">
  228. and o.c_user_id = #{cUserId}
  229. </if>
  230. <if test="tenantId != null">
  231. and o.tenant_id = #{tenantId}
  232. </if>
  233. <if test="orderStatus != null">
  234. AND o.order_status = #{orderStatus}
  235. </if>
  236. <if test=" null != sortColumns">order by ${sortColumns}</if>
  237. </select>
  238. <select id="selectDetailOfCUser" parameterType="com.iformall.domain.po.WxOrder" resultMap="CVoResultMap">
  239. select
  240. <include refid="allCUserOrderDetailColumns"/>
  241. FROM wx_order o
  242. left join wx_coupon c ON o.product_id = c.id
  243. left join wx_coupon_order co on o.id = co.order_id
  244. where o.product_id = c.id
  245. <if test="cUserId != null">
  246. and o.c_user_id = #{cUserId}
  247. </if>
  248. <if test="tenantId != null">
  249. and o.tenant_id = #{tenantId}
  250. </if>
  251. <if test="id != null">
  252. and o.id = #{id}
  253. </if>
  254. </select>
  255. <select id="dayMicroPayAmountList" parameterType="map" resultType="map">
  256. select count(*) as count, IFNULL(sum(o.payment), 0) as total_price
  257. from wx_order o
  258. inner join wx_merchant_b_user bu on bu.id = product_id
  259. inner join wx_merchant m on m.id = bu.merchant_id
  260. where o.`type` = 1 and o.`order_status` = 1
  261. <if test=" null != tenantId ">
  262. and o.`tenant_id` = #{tenantId}
  263. </if>
  264. <if test=" null != merchantId ">
  265. and bu.`merchant_id` = #{merchantId}
  266. </if>
  267. <if test=" null != cUserId ">
  268. and o.`c_user_id` = #{cUserId}
  269. </if>
  270. <if test=" null != bUserId ">
  271. and bu.`id` = #{bUserId}
  272. </if>
  273. <if test=" null != couponChannelId ">
  274. and o.`coupon_channel_id` = #{couponChannelId}
  275. </if>
  276. <if test=" null != productId ">
  277. and o.`product_id` = #{productId}
  278. </if>
  279. <if test="startDate != null">
  280. AND o.create_date &gt; #{startDate,jdbcType=TIMESTAMP}
  281. </if>
  282. <if test="endDate != null">
  283. AND o.create_date &lt; #{endDate,jdbcType=TIMESTAMP}
  284. </if>
  285. </select>
  286. <resultMap id="PayVoResultMap" type="com.iformall.domain.vo.WxOrderPayVo">
  287. <id column="id" jdbcType="BIGINT" property="id"/>
  288. <result column="order_number" jdbcType="BIGINT" property="orderNumber"/>
  289. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  290. <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
  291. <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
  292. <result column="product_id" jdbcType="BIGINT" property="productId"/>
  293. <result column="type" jdbcType="TINYINT" property="type"/>
  294. <result column="payment_type" jdbcType="INTEGER" property="paymentType"/>
  295. <result column="payment" jdbcType="INTEGER" property="payment"/>
  296. <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/>
  297. <result column="order_status" jdbcType="INTEGER" property="orderStatus"/>
  298. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  299. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  300. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  301. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />
  302. <result column="name" jdbcType="VARCHAR" property="bUserName" />
  303. <result column="bphone" jdbcType="VARCHAR" property="bUserPhone" />
  304. <result column="phone" jdbcType="VARCHAR" property="cUserPhone" />
  305. <result column="nick_name" jdbcType="VARCHAR" property="nickName" />
  306. <result column="c_user_name" jdbcType="VARCHAR" property="cUserName" />
  307. </resultMap>
  308. <sql id="allPayOrderColumns">
  309. o.`id`,o.`order_number`,o.`tenant_id`,o.`c_user_id`,o.`coupon_channel_id`,o.`product_id`,o.`type`,
  310. o.`payment_type`,o.`payment`,o.`payment_time`,o.`order_status`,o.`create_date`,o.`update_date`,o.`detail`,
  311. m.name as merchant_name, bu.name, bu.phone as bphone,
  312. cu.phone, cu.nick_name, cubi.name c_user_name
  313. </sql>
  314. <select id="findListOfMicroPayOrderByDate" parameterType="map" resultMap="PayVoResultMap">
  315. select
  316. <include refid="allPayOrderColumns"/>
  317. from wx_order o
  318. inner join wx_merchant_b_user bu on bu.id = o.product_id
  319. inner join wx_merchant m on m.id = bu.merchant_id
  320. LEFT JOIN wx_c_user cu on cu.id = o.c_user_id
  321. LEFT JOIN wx_c_user_basic_info cubi on cubi.id = o.c_user_id
  322. where o.order_status = '1' and o.`type` = 1
  323. <if test=" null != tenantId ">
  324. and o.`tenant_id` = #{tenantId}
  325. </if>
  326. <if test=" null != merchantId ">
  327. and bu.`merchant_id` = #{merchantId}
  328. </if>
  329. <if test=" null != bUserId ">
  330. and bu.`id` = #{bUserId}
  331. </if>
  332. <if test="startDate != null">
  333. AND o.create_date &gt; #{startDate,jdbcType=TIMESTAMP}
  334. </if>
  335. <if test="endDate != null">
  336. AND o.create_date &lt; #{endDate,jdbcType=TIMESTAMP}
  337. </if>
  338. order by o.create_date desc
  339. </select>
  340. <select id="queryForSceneRepotyHistory" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
  341. select DATE_FORMAT(o.create_date,'%Y-%m-%d') xTime, count(o.id) triggerCount
  342. from wx_order o
  343. where o.`tenant_id` = #{tenantId} and o.`type` = #{type}
  344. <if test=" null != startTime and null != endTime">
  345. and o.`create_date` BETWEEN #{startTime} and #{endTime}
  346. </if>
  347. group by xTime
  348. </select>
  349. <select id="listOrderReportByDate" resultType="com.iformall.domain.vo.WxOrderReportVo" parameterType="hashmap">
  350. select DATE_FORMAT(o.create_date,'%Y-%m-%d') xTime,
  351. count(o.id) count,
  352. IFNULL (SUM(o.payment),0) amount
  353. from wx_order o
  354. where o.`tenant_id` = #{tenantId}
  355. <if test=" null != tenantId">
  356. and o.`tenant_id` = #{tenantId}
  357. </if>
  358. <if test=" null != type">
  359. and o.`type` = #{type}
  360. </if>
  361. <if test=" null != orderStatus">
  362. and o.`order_status` = #{orderStatus}
  363. </if>
  364. <if test=" null != startTime and null != endTime">
  365. and o.`create_date` BETWEEN #{startTime} and #{endTime}
  366. </if>
  367. group by xTime
  368. </select>
  369. <select id="listMicroPayOrderReportByDateAndMerchant" resultType="com.iformall.domain.vo.WxOrderReportVo" parameterType="hashmap">
  370. select DATE_FORMAT(o.create_date,'%Y-%m-%d') xTime, count(o.id) count, IFNULL (SUM(o.payment),0) amount
  371. from wx_order o
  372. inner join wx_merchant_b_user bu on bu.id = o.product_id
  373. inner join wx_merchant m on m.id = bu.merchant_id
  374. where m.`id` = #{merchantId} and o.`type` = 1
  375. <if test=" null != startTime and null != endTime">
  376. and o.`create_date` BETWEEN #{startTime} and #{endTime}
  377. </if>
  378. group by xTime
  379. </select>
  380. <resultMap id="WxMerchantMicroPayVo" type="com.iformall.domain.vo.WxMerchantMicroPayVo">
  381. <id column="id" jdbcType="BIGINT" property="id" />
  382. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  383. <result column="trade_amt" jdbcType="DECIMAL" property="tradeAmt" />
  384. <result column="report_date" jdbcType="VARCHAR" property="reportDate" />
  385. <result column="merchant_phone" jdbcType="VARCHAR" property="merchantPhone" />
  386. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />
  387. </resultMap>
  388. <sql id="WxMerchantMicroPayColumnsVo">
  389. wm.id as id,
  390. wm.tenant_id as tenant_id,
  391. wm.name as merchant_name,
  392. wm.link_phone as merchant_phone,
  393. mo.xTime as report_date,
  394. (case when mo.amount > 0 then mo.amount else 0 end) trade_amt
  395. </sql>
  396. <select id="findListOfMerchantMicroPayOrderByDate" parameterType="map" resultMap="WxMerchantMicroPayVo">
  397. select
  398. <include refid="WxMerchantMicroPayColumnsVo"/>
  399. from wx_merchant wm
  400. left join
  401. (select m.id as mid, IFNULL(sum(o.payment),0) amount,DATE_FORMAT(o.create_date,'%Y-%m-%d') xTime
  402. from wx_merchant m, wx_order o, wx_merchant_b_user bu
  403. where bu.id = o.product_id
  404. and m.status = 1
  405. and m.id = bu.merchant_id
  406. and o.order_status = '1'
  407. and o.type = 1
  408. <if test="startTime != null">
  409. AND o.create_date &gt; #{startTime}
  410. </if>
  411. <if test="endTime != null">
  412. AND o.create_date &lt; #{endTime}
  413. </if>
  414. group by m.id,xTime) mo on mo.mid = wm.id
  415. where wm.status = 1
  416. <if test=" null != merchantName ">
  417. and wm.name like concat('%', #{merchantName},'%')
  418. </if>
  419. order by wm.create_date desc
  420. </select>
  421. <resultMap id="orderMap" type="com.iformall.domain.po.WxOrder">
  422. <id column="id" jdbcType="BIGINT" property="id"/>
  423. <result column="order_number" jdbcType="BIGINT" property="orderNumber"/>
  424. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  425. <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
  426. <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
  427. <result column="product_id" jdbcType="BIGINT" property="productId"/>
  428. <result column="type" jdbcType="TINYINT" property="type"/>
  429. <result column="payment_type" jdbcType="INTEGER" property="paymentType"/>
  430. <result column="payment" jdbcType="INTEGER" property="payment"/>
  431. <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/>
  432. <result column="order_status" jdbcType="INTEGER" property="orderStatus"/>
  433. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  434. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  435. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  436. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/>
  437. <result column="c_user_name" jdbcType="VARCHAR" property="cUserName"/>
  438. <result column="phone" jdbcType="VARCHAR" property="phone"/>
  439. </resultMap>
  440. <select id="findListOrder" resultMap="orderMap" parameterType="com.iformall.domain.vo.WxOrderQueryVo">
  441. select o.* from (
  442. select o.id,o.order_number,o.tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.type,o.payment_type,o.payment,o.payment_time,
  443. o.order_status,o.create_date,o.update_date,o.detail,'[多商户交易]' merchant_name,cubi.`name` c_user_name,cubi.phone
  444. from
  445. (
  446. select o.* from wx_order o where o.type=0 and o.order_status in (1,4) and o.id in(
  447. select o.id from wx_order o left join wx_coupon_merchant cm
  448. on o.product_id=cm.product_id group by o.id having count(o.id)>1)) o
  449. left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id
  450. union all
  451. select o.id,o.order_number,o.tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.type,o.payment_type,o.payment,o.payment_time,
  452. o.order_status,o.create_date,o.update_date,o.detail,m.`name` merchant_name,cubi.`name` c_user_name,cubi.phone
  453. from(
  454. select o.*,cm.merchant_id from (
  455. select o.* from wx_order o where o.type=0 and o.order_status in (1,4) and o.id not in(
  456. select o.id from wx_order o left join wx_coupon_merchant cm
  457. on o.product_id=cm.product_id group by o.id having count(o.id)>1)
  458. ) o
  459. left join wx_coupon_merchant cm on o.product_id=cm.product_id
  460. union all
  461. select o.*,mbu.merchant_id from wx_order o
  462. left join wx_merchant_b_user mbu on o.product_id=mbu.id
  463. where o.type in (1,2) and o.order_status in (1,4) ) o
  464. left join wx_merchant m on o.merchant_id=m.id
  465. left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id
  466. ) o
  467. <where>
  468. <if test="tenantId!=null">
  469. and o.tenant_id =#{tenantId}
  470. </if>
  471. <if test="merchantName!=null and merchantName!=''">
  472. and o.`merchant_name` like concat('%',#{merchantName},'%')
  473. </if>
  474. <if test="startdate!=null and enddate!=null">
  475. and o.create_date between #{startdate} and #{enddate}
  476. </if>
  477. </where>
  478. order by o.id desc
  479. </select>
  480. <select id="queryOrderForMerchantCount" resultType="Long" parameterType="hashmap">
  481. select count(*) merchantCount from (
  482. select distinct merchant_id from (
  483. select o.*, m.`name` merchantName from (
  484. select o.*,cm.merchant_id from wx_order o
  485. left join wx_coupon_merchant cm on o.product_id=cm.product_id
  486. where o.type = 0 and o.order_status in (1,4)) o
  487. left join wx_merchant m on o.merchant_id=m.id
  488. union all
  489. select o.*,m.`name` merchantName from (
  490. select o.*,mbu.merchant_id from wx_order o
  491. left join wx_merchant_b_user mbu on o.product_id=mbu.id
  492. where o.type in (1,2) and o.order_status in (1,4)) o
  493. left join wx_merchant m on o.merchant_id=m.id
  494. ) o
  495. <where>
  496. <if test="tenantId!=null">
  497. and o.tenant_id =#{tenantId}
  498. </if>
  499. <if test="startdate!=null and enddate!=null">
  500. and o.create_date between #{startdate} and #{enddate}
  501. </if>
  502. </where>
  503. ) o
  504. </select>
  505. <select id="queryOrderForSum" resultType="Long" parameterType="hashmap">
  506. select ifnull(sum(o.payment),0) payment from (
  507. select o.* from wx_order o
  508. where o.type in (0,1,2) and o.order_status = #{order_status}
  509. ) o
  510. <where>
  511. <if test="tenantId!=null">
  512. and o.tenant_id =#{tenantId}
  513. </if>
  514. <if test="startdate!=null and enddate!=null">
  515. and o.create_date between #{startdate} and #{enddate}
  516. </if>
  517. </where>
  518. </select>
  519. <resultMap id="PressVoResultMap" type="com.iformall.domain.vo.WxOrderCouponPressVo">
  520. <id column="id" jdbcType="BIGINT" property="id"/>
  521. <result column="order_number" jdbcType="BIGINT" property="orderNumber"/>
  522. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  523. <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
  524. <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
  525. <result column="product_id" jdbcType="BIGINT" property="productId"/>
  526. <result column="type" jdbcType="INTEGER" property="type"/>
  527. <result column="payment_type" jdbcType="INTEGER" property="paymentType"/>
  528. <result column="payment" jdbcType="INTEGER" property="payment"/>
  529. <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/>
  530. <result column="order_status" jdbcType="INTEGER" property="orderStatus"/>
  531. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  532. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  533. <result column="press_end_date" jdbcType="TIMESTAMP" property="pressEndDate"/>
  534. <result column="press_current_num" jdbcType="INTEGER" property="pressCurrentNum"/>
  535. <result column="press_current_value" jdbcType="INTEGER" property="pressCurrentValue"/>
  536. <result column="coupon_type" jdbcType="INTEGER" property="couponType"/>
  537. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  538. <result column="title" jdbcType="VARCHAR" property="title"/>
  539. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  540. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  541. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  542. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  543. <result column="price" jdbcType="INTEGER" property="price"/>
  544. <result column="unit" jdbcType="INTEGER" property="unit"/>
  545. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  546. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  547. <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId"/>
  548. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus"/>
  549. </resultMap>
  550. <resultMap id="PressVoDetailResultMap" type="com.iformall.domain.vo.WxOrderCouponPressVo">
  551. <id column="id" jdbcType="BIGINT" property="id"/>
  552. <result column="order_number" jdbcType="BIGINT" property="orderNumber"/>
  553. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  554. <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
  555. <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
  556. <result column="product_id" jdbcType="BIGINT" property="productId"/>
  557. <result column="type" jdbcType="INTEGER" property="type"/>
  558. <result column="payment_type" jdbcType="INTEGER" property="paymentType"/>
  559. <result column="payment" jdbcType="INTEGER" property="payment"/>
  560. <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/>
  561. <result column="order_status" jdbcType="INTEGER" property="orderStatus"/>
  562. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  563. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  564. <result column="press_end_date" jdbcType="TIMESTAMP" property="pressEndDate"/>
  565. <result column="press_current_num" jdbcType="INTEGER" property="pressCurrentNum"/>
  566. <result column="press_current_value" jdbcType="INTEGER" property="pressCurrentValue"/>
  567. <result column="coupon_type" jdbcType="INTEGER" property="couponType"/>
  568. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  569. <result column="title" jdbcType="VARCHAR" property="title"/>
  570. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  571. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  572. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  573. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  574. <result column="price" jdbcType="INTEGER" property="price"/>
  575. <result column="unit" jdbcType="INTEGER" property="unit"/>
  576. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  577. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  578. <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId"/>
  579. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus"/>
  580. <collection column="{orderId=order_number}" property="orderPressList"
  581. ofType="com.iformall.domain.vo.WxOrderPressVo"
  582. javaType="java.util.List"
  583. select="com.iformall.mapper.WxOrderPressMapper.findPressList" >
  584. </collection>
  585. </resultMap>
  586. <sql id="allOrderPressListColumns">
  587. o.id,o.order_number,o.tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment,o.payment_time,o.order_status,
  588. o.create_date,o.update_date,o.press_end_date,o.press_current_num,o.press_current_value,
  589. c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.press_limit_num
  590. </sql>
  591. <sql id="allOrderPressDetailColumns">
  592. o.id,o.order_number,o.tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment,o.payment_time,o.order_status,
  593. o.create_date,o.update_date,o.press_end_date,o.press_current_num,o.press_current_value,
  594. c.type as coupon_type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.detail,c.remark,c.press_limit_num,
  595. co.id as coupon_order_id,co.coupon_order_status
  596. </sql>
  597. <select id="findListOfPress" parameterType="com.iformall.domain.po.WxOrder" resultMap="PressVoResultMap">
  598. select
  599. <include refid="allOrderPressListColumns"/>
  600. from wx_coupon c,wx_order o
  601. left join wx_coupon_order co on co.order_id = o.id
  602. where o.product_id = c.id and c.type = 8 and o.order_status in (6,7,8,9)
  603. <if test="cUserId != null">
  604. and o.c_user_id = #{cUserId}
  605. </if>
  606. <if test="tenantId != null">
  607. and o.tenant_id = #{tenantId}
  608. </if>
  609. <if test="orderStatus != null">
  610. AND o.order_status = #{orderStatus}
  611. </if>
  612. <if test=" null != sortColumns">order by ${sortColumns}</if>
  613. </select>
  614. <select id="selectDetailOfPress" parameterType="com.iformall.domain.po.WxOrder" resultMap="PressVoDetailResultMap">
  615. select
  616. <include refid="allOrderPressDetailColumns"/>
  617. FROM wx_order o
  618. left join wx_coupon c ON o.product_id = c.id
  619. left join wx_coupon_order co on o.id = co.order_id
  620. where o.product_id = c.id
  621. <if test="cUserId != null">
  622. and o.c_user_id = #{cUserId}
  623. </if>
  624. <if test="tenantId != null">
  625. and o.tenant_id = #{tenantId}
  626. </if>
  627. <if test="id != null">
  628. and o.id = #{id}
  629. </if>
  630. </select>
  631. <update id="updateStatusByOrderGroupId" parameterType="com.iformall.domain.po.WxOrder">
  632. update wx_order set order_status=#{orderStatus} where tenant_id=#{tenantId} and order_group_id=#{orderGroupId} and order_status=10
  633. </update>
  634. </mapper>