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

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