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

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