Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

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