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

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