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

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