You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

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