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

1169 строки
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 or order_status = 7) 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="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  379. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  380. <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"></result>
  381. <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
  382. <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>
  383. <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId"/>
  384. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus"/>
  385. <result column="send_channel_type" jdbcType="INTEGER" property="sendChannelType" />
  386. <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
  387. <result column="compose_order_type" jdbcType="INTEGER" property="composeOrderType" />
  388. <result column="compose_order_id" jdbcType="BIGINT" property="composeOrderId" />
  389. <result column="coupon_number" jdbcType="INTEGER" property="couponNumber"/>
  390. <result column="parent_order_id" jdbcType="BIGINT" property="parentOrderId" />
  391. <result column="shipping_type" jdbcType="INTEGER" property="shippingType"/>
  392. <result column="shipping_address" jdbcType="VARCHAR" property="shippingAddress"/>
  393. <result column="shipping_status" jdbcType="INTEGER" property="shippingStatus"/>
  394. <result column="delivery_info" jdbcType="VARCHAR" property="deliveryInfo"/>
  395. </resultMap>
  396. <select id="listGoodsCAsPage" parameterType="com.iformall.domain.po.WxOrder" resultMap="CVoListMap">
  397. select * from(
  398. select 0 level,o.compose_order_type,o.compose_order_id,o.payment,o.order_status,o.create_date,
  399. 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,
  400. 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,
  401. o.`coupon_number`,o.`freight_price`,o.`shipping_type`,o.`shipping_address`
  402. from wx_coupon c,wx_order o
  403. where o.product_id = c.id and o.order_status in (0,2)
  404. and o.compose_order_type = 0
  405. and o.compose_order_id = 0
  406. and o.parent_order_id = 0
  407. <if test="cUserId != null">
  408. and o.c_user_id = #{cUserId}
  409. </if>
  410. <if test=" null != tenantId and '' != tenantId">
  411. and o.`tenant_id` = #{tenantId}
  412. </if>
  413. <if test=" null != parentTenantId and '' != parentTenantId">
  414. and o.`parent_tenant_id` = #{parentTenantId}
  415. </if>
  416. <if test="orderStatus != null">
  417. AND o.order_status = #{orderStatus}
  418. </if>
  419. <if test=" null != payVendor ">
  420. and o.pay_vendor = #{payVendor}
  421. </if>
  422. union all
  423. select 0 level, o.compose_order_type,o.compose_order_id,o.payment,o.order_status,o.create_date,
  424. 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,
  425. 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,
  426. o.`coupon_number`,o.`freight_price`,o.`shipping_type`,o.`shipping_address`
  427. from wx_coupon c,wx_order o
  428. where o.product_id = c.id and o.order_status in (1,3,4,5)
  429. and o.compose_order_type in (0,1,2,3)
  430. and o.parent_order_id = 0
  431. <if test="cUserId != null">
  432. and o.c_user_id = #{cUserId}
  433. </if>
  434. <if test=" null != tenantId and '' != tenantId">
  435. and o.`tenant_id` = #{tenantId}
  436. </if>
  437. <if test=" null != parentTenantId and '' != parentTenantId">
  438. and o.`parent_tenant_id` = #{parentTenantId}
  439. </if>
  440. <if test="orderStatus != null">
  441. AND o.order_status = #{orderStatus}
  442. </if>
  443. <if test=" null != payVendor ">
  444. and o.pay_vendor = #{payVendor}
  445. </if>
  446. union all
  447. select 1 level,o.compose_order_type,o.compose_order_id,sum(o.payment) payment,o.order_status,min(create_date) create_date,
  448. null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,
  449. null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,
  450. null ,null ,null ,null
  451. from wx_order o
  452. where o.order_status in (0,2)
  453. and o.compose_order_type in (1,2,3)
  454. and o.compose_order_id &gt; 0
  455. and o.parent_order_id = 0
  456. <if test="cUserId != null">
  457. and o.c_user_id = #{cUserId}
  458. </if>
  459. <if test=" null != tenantId and '' != tenantId">
  460. and o.`tenant_id` = #{tenantId}
  461. </if>
  462. <if test=" null != parentTenantId and '' != parentTenantId">
  463. and o.`parent_tenant_id` = #{parentTenantId}
  464. </if>
  465. <if test="orderStatus != null">
  466. AND o.order_status = #{orderStatus}
  467. </if>
  468. <if test=" null != payVendor ">
  469. and o.pay_vendor = #{payVendor}
  470. </if>
  471. group by o.compose_order_type,o.compose_order_id
  472. ) a
  473. order by a.create_date desc
  474. </select>
  475. <select id="dayMicroPayAmountList" parameterType="map" resultType="map">
  476. select count(1) as count, IFNULL(sum(o.payment), 0) as total_price
  477. from wx_order o
  478. where o.`type` = 1 and o.`order_status` = 1
  479. <if test=" null != tenantId and '' != tenantId">
  480. and o.`tenant_id` = #{tenantId}
  481. </if>
  482. <if test=" null != parentTenantId and '' != parentTenantId">
  483. and o.`parent_tenant_id` = #{parentTenantId}
  484. </if>
  485. <if test=" null != payVendor ">
  486. and o.pay_vendor = #{payVendor}
  487. </if>
  488. <if test=" null != bUserIds ">
  489. and o.product_id in
  490. <foreach collection="bUserIds" index="index" item="bUserIdItem" open="(" separator="," close=")">
  491. #{bUserIdItem}
  492. </foreach>
  493. </if>
  494. <if test=" null != cUserId ">
  495. and o.`c_user_id` = #{cUserId}
  496. </if>
  497. <if test=" null != couponChannelId ">
  498. and o.`coupon_channel_id` = #{couponChannelId}
  499. </if>
  500. <if test=" null != productId ">
  501. and o.`product_id` = #{productId}
  502. </if>
  503. <if test="startDate != null">
  504. AND o.create_date &gt; #{startDate,jdbcType=TIMESTAMP}
  505. </if>
  506. <if test="endDate != null">
  507. AND o.create_date &lt; #{endDate,jdbcType=TIMESTAMP}
  508. </if>
  509. </select>
  510. <select id="findListOfMicroPayOrderByDate" parameterType="map" resultMap="BaseResultMap">
  511. select
  512. 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`,
  513. 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`
  514. from wx_order o
  515. where o.order_status = '1' and o.`type` = 1
  516. <if test=" null != tenantId and '' != tenantId">
  517. and o.`tenant_id` = #{tenantId}
  518. </if>
  519. <if test=" null != parentTenantId and '' != parentTenantId">
  520. and o.`parent_tenant_id` = #{parentTenantId}
  521. </if>
  522. <if test=" null != payVendor ">
  523. and o.pay_vendor = #{payVendor}
  524. </if>
  525. <if test=" null != payVersion ">
  526. and o.pay_version = #{payVersion}
  527. </if>
  528. <if test=" null != bUserIds ">
  529. and o.product_id in
  530. <foreach collection="bUserIds" index="index" item="bUserIdItem" open="(" separator="," close=")">
  531. #{bUserIdItem}
  532. </foreach>
  533. </if>
  534. <if test="startDate != null">
  535. AND o.create_date &gt; #{startDate,jdbcType=TIMESTAMP}
  536. </if>
  537. <if test="endDate != null">
  538. AND o.create_date &lt; #{endDate,jdbcType=TIMESTAMP}
  539. </if>
  540. order by o.create_date desc
  541. </select>
  542. <select id="findListOfExpMicroPayOrderByDate" parameterType="map" resultMap="BaseResultMap">
  543. select
  544. 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`,
  545. 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`
  546. from wx_order o
  547. where o.order_status = '0' and o.`type` = 1
  548. <if test=" null != tenantId and '' != tenantId">
  549. and o.`tenant_id` = #{tenantId}
  550. </if>
  551. <if test=" null != parentTenantId and '' != parentTenantId">
  552. and o.`parent_tenant_id` = #{parentTenantId}
  553. </if>
  554. <if test=" null != payVendor ">
  555. and o.pay_vendor = #{payVendor}
  556. </if>
  557. <if test=" null != payVersion ">
  558. and o.pay_version = #{payVersion}
  559. </if>
  560. <if test=" null != bUserIds ">
  561. and o.product_id in
  562. <foreach collection="bUserIds" index="index" item="bUserIdItem" open="(" separator="," close=")">
  563. #{bUserIdItem}
  564. </foreach>
  565. </if>
  566. <if test="startDate != null">
  567. AND o.create_date &gt; #{startDate,jdbcType=TIMESTAMP}
  568. </if>
  569. <if test="endDate != null">
  570. AND o.create_date &lt; #{endDate,jdbcType=TIMESTAMP}
  571. </if>
  572. order by o.create_date desc
  573. </select>
  574. <select id="queryForSceneRepotyHistory" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
  575. select DATE_FORMAT(o.create_date,'%Y-%m-%d') xTime, count(o.id) triggerCount
  576. from wx_order o
  577. where o.`type` = #{type}
  578. <if test=" null != payVendor ">
  579. and o.pay_vendor = #{payVendor}
  580. </if>
  581. <if test=" null != tenantId and '' != tenantId">
  582. and o.`tenant_id` = #{tenantId}
  583. </if>
  584. <if test=" null != parentTenantId and '' != parentTenantId">
  585. and o.`parent_tenant_id` = #{parentTenantId}
  586. </if>
  587. <if test=" null != startTime and null != endTime">
  588. and o.`create_date` BETWEEN #{startTime} and #{endTime}
  589. </if>
  590. group by xTime
  591. </select>
  592. <select id="listOrderReportByDate" resultType="com.iformall.domain.vo.WxOrderReportVo" parameterType="hashmap">
  593. select DATE_FORMAT(o.create_date,'%Y-%m-%d') xTime,
  594. count(o.id) count,
  595. IFNULL (SUM(o.payment),0) amount
  596. from wx_order o
  597. where o.`tenant_id` = #{tenantId}
  598. <if test=" null != parentTenantId and '' != parentTenantId">
  599. and o.`parent_tenant_id` = #{parentTenantId}
  600. </if>
  601. <if test=" null != type">
  602. and o.`type` = #{type}
  603. </if>
  604. <if test=" null != payVendor ">
  605. and o.pay_vendor = #{payVendor}
  606. </if>
  607. <if test=" null != orderStatus">
  608. and o.`order_status` = #{orderStatus}
  609. </if>
  610. <if test=" null != startTime and null != endTime">
  611. and o.`create_date` BETWEEN #{startTime} and #{endTime}
  612. </if>
  613. group by xTime
  614. </select>
  615. <select id="listMicroPayOrderReportByDateAndMerchant" resultType="com.iformall.domain.vo.WxOrderReportVo" parameterType="hashmap">
  616. select DATE_FORMAT(o.create_date,'%Y-%m-%d') xTime, count(o.id) count, IFNULL (SUM(o.payment),0) amount
  617. from wx_order o
  618. where o.tenant_id = #{tenantId} and o.`type` = 1 and o.`order_status` = 1
  619. <if test=" null != bUserIds ">
  620. and o.product_id in
  621. <foreach collection="bUserIds" index="index" item="bUserIdItem" open="(" separator="," close=")">
  622. #{bUserIdItem}
  623. </foreach>
  624. </if>
  625. <if test=" null != payVendor ">
  626. and o.pay_vendor = #{payVendor}
  627. </if>
  628. <if test=" null != startTime and null != endTime">
  629. and o.`create_date` BETWEEN #{startTime} and #{endTime}
  630. </if>
  631. group by xTime
  632. </select>
  633. <!-- <resultMap id="WxMerchantMicroPayVo" type="com.iformall.domain.vo.WxMerchantMicroPayVo">
  634. <id column="id" jdbcType="BIGINT" property="id" />
  635. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  636. <result column="trade_amt" jdbcType="DECIMAL" property="tradeAmt" />
  637. <result column="report_date" jdbcType="VARCHAR" property="reportDate" />
  638. <result column="merchant_phone" jdbcType="VARCHAR" property="merchantPhone" />
  639. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />
  640. </resultMap>
  641. <sql id="WxMerchantMicroPayColumnsVo">
  642. wm.id as id,
  643. wm.tenant_id as tenant_id,
  644. wm.parent_tenant_id as parent_tenant_id,
  645. wm.name as merchant_name,
  646. wm.link_phone as merchant_phone,
  647. mo.xTime as report_date,
  648. (case when mo.amount > 0 then mo.amount else 0 end) trade_amt
  649. </sql> -->
  650. <select id="findListOfMerchantMicroPayOrderByDate" parameterType="com.iformall.domain.dto.WxOrderReportDto" resultType="com.iformall.domain.vo.WxMerchantMicroPayVo">
  651. select bu.merchant_id as id, IFNULL(sum(o.payment),0) tradeAmt
  652. from wx_order o, wx_merchant_b_user bu
  653. where bu.id = o.product_id
  654. and o.order_status = 1
  655. and o.type = 1
  656. AND o.create_date &gt; #{startTime}
  657. AND o.create_date &lt; #{endTime}
  658. <if test=" null != merchantIds ">
  659. and bu.merchant_id in
  660. <foreach collection="merchantIds" index="index" item="merchantIdItem" open="(" separator="," close=")">
  661. #{merchantIdItem}
  662. </foreach>
  663. </if>
  664. group by id
  665. order by tradeAmt desc
  666. </select>
  667. <resultMap id="orderMap" type="com.iformall.domain.po.WxOrder">
  668. <id column="id" jdbcType="BIGINT" property="id"/>
  669. <result column="order_number" jdbcType="BIGINT" property="orderNumber"/>
  670. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  671. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  672. <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
  673. <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
  674. <result column="product_id" jdbcType="BIGINT" property="productId"/>
  675. <result column="type" jdbcType="TINYINT" property="type"/>
  676. <result column="pay_vendor" jdbcType="TINYINT" property="payVendor"/>
  677. <result column="payment_type" jdbcType="INTEGER" property="paymentType"/>
  678. <result column="payment" jdbcType="INTEGER" property="payment"/>
  679. <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/>
  680. <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
  681. <result column="order_status" jdbcType="INTEGER" property="orderStatus"/>
  682. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  683. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  684. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  685. <result column="ref_detail" jdbcType="VARCHAR" property="refDetail"/>
  686. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/>
  687. <result column="c_user_name" jdbcType="VARCHAR" property="cUserName"/>
  688. <result column="phone" jdbcType="VARCHAR" property="phone"/>
  689. <result column="title" jdbcType="VARCHAR" property="title"/>
  690. <result column="attribute" jdbcType="INTEGER" property="attribute"/>
  691. <result column="pay" jdbcType="INTEGER" property="pay"/>
  692. </resultMap>
  693. <select id="findListOrder" resultMap="orderMap" parameterType="com.iformall.domain.vo.WxOrderQueryVo">
  694. select o.*,case o.order_status when 0 then 0 when 2 then 0 else o.payment end pay from (
  695. select o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.product_id,o.payment,o.order_status,
  696. c.title,cubi.`name` c_user_name,cubi.phone,o.create_date,1 attribute from wx_order o
  697. left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id
  698. left join wx_coupon c on o.product_id=c.id
  699. where c.type=100
  700. <if test=" null != tenantId and '' != tenantId">
  701. and o.`tenant_id` = #{tenantId}
  702. </if>
  703. <if test=" null != parentTenantId and '' != parentTenantId">
  704. and o.`parent_tenant_id` = #{parentTenantId}
  705. </if>
  706. union all
  707. select o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.product_id,o.payment,o.order_status,
  708. c.title,cubi.`name` c_user_name,cubi.phone,o.create_date,2 attribute from wx_order o
  709. left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id
  710. left join wx_coupon c on o.product_id=c.id
  711. 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)
  712. <if test=" null != tenantId and '' != tenantId">
  713. and o.`tenant_id` = #{tenantId}
  714. </if>
  715. <if test=" null != parentTenantId and '' != parentTenantId">
  716. and o.`parent_tenant_id` = #{parentTenantId}
  717. </if>
  718. <!-- and ifnull(press_current_num,0)=0 and ifnull(order_group_id,0)=0 -->
  719. union all
  720. select o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.product_id,o.payment,o.order_status,
  721. c.title,cubi.`name` c_user_name,cubi.phone,o.create_date,6 attribute from wx_order o
  722. left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id
  723. left join wx_coupon c on o.product_id=c.id
  724. where c.type = 11 and o.order_status in(0,1,2,3,4,5,97)
  725. <if test=" null != tenantId and '' != tenantId">
  726. and o.`tenant_id` = #{tenantId}
  727. </if>
  728. <if test=" null != parentTenantId and '' != parentTenantId">
  729. and o.`parent_tenant_id` = #{parentTenantId}
  730. </if>
  731. union all
  732. select o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.product_id,o.payment,o.order_status,
  733. c.title,cubi.`name` c_user_name,cubi.phone,o.create_date,7 attribute from wx_order o
  734. left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id
  735. left join wx_coupon c on o.product_id=c.id
  736. where c.type = 12 and o.order_status in(0,1,2,3,4,5,97)
  737. <if test=" null != tenantId and '' != tenantId">
  738. and o.`tenant_id` = #{tenantId}
  739. </if>
  740. <if test=" null != parentTenantId and '' != parentTenantId">
  741. and o.`parent_tenant_id` = #{parentTenantId}
  742. </if>
  743. union all
  744. select o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.product_id,o.payment,
  745. case o.order_status when 6 then 0 when 7 then 0
  746. when 8 then 2 when 9 then 2 else o.order_status end order_status,
  747. c.title,cubi.`name` c_user_name,cubi.phone,o.create_date,3 attribute from wx_order o
  748. left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id
  749. left join wx_coupon c on o.product_id=c.id
  750. where c.type=8 and o.press_current_num>0
  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. union all
  758. select o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.product_id,o.payment,
  759. case o.order_status when 10 then 1 when 11 then 1
  760. when 12 then 4 when 13 then 4 when 14 then 4 when 15 then 0 when 16 then 2
  761. else o.order_status end order_status,
  762. c.title,cubi.`name` c_user_name,cubi.phone,o.create_date,4 attribute from wx_order o
  763. left join wx_c_user_basic_info cubi on o.c_user_id=cubi.id
  764. left join wx_coupon c on o.product_id=c.id
  765. where c.type=9 and o.order_group_id>0
  766. <if test=" null != tenantId and '' != tenantId">
  767. and o.`tenant_id` = #{tenantId}
  768. </if>
  769. <if test=" null != parentTenantId and '' != parentTenantId">
  770. and o.`parent_tenant_id` = #{parentTenantId}
  771. </if>
  772. ) o
  773. <where>
  774. <if test=" null != tenantId and '' != tenantId">
  775. and o.`tenant_id` = #{tenantId}
  776. </if>
  777. <if test=" null != parentTenantId and '' != parentTenantId">
  778. and o.`parent_tenant_id` = #{parentTenantId}
  779. </if>
  780. <if test="title!=null and title!=''">
  781. and o.`title` like concat('%',#{title},'%')
  782. </if>
  783. <if test="payment!=null and (payment== '' or payment == 0)">
  784. and o.`payment` = 0
  785. </if>
  786. <if test="payment!=null and payment > 0">
  787. and o.`payment` &gt; 0
  788. </if>
  789. <if test="startdate!=null and enddate!=null">
  790. and o.create_date between #{startdate} and #{enddate}
  791. </if>
  792. <if test="orderStatus!=null">
  793. and o.order_status = #{orderStatus}
  794. </if>
  795. <if test="attribute!=null">
  796. and o.attribute = #{attribute}
  797. </if>
  798. <if test="orderNumber!=null">
  799. and o.order_number like concat('%',#{orderNumber},'%')
  800. </if>
  801. </where>
  802. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  803. <if test=" null == sortColumns">order by o.create_date desc, o.id desc</if>
  804. </select>
  805. <select id="queryOrderForMerchantCount" resultType="Long" parameterType="hashmap">
  806. select count(*) merchantCount from (
  807. select distinct merchant_id from (
  808. select o.*, m.`name` merchantName from (
  809. select o.*,cm.merchant_id from wx_order o
  810. left join wx_coupon_merchant cm on o.product_id=cm.product_id
  811. where o.type = 0 and o.order_status in (1,4)) o
  812. left join wx_merchant m on o.merchant_id=m.id
  813. union all
  814. select o.*,m.`name` merchantName from (
  815. select o.*,mbu.merchant_id from wx_order o
  816. left join wx_merchant_b_user mbu on o.product_id=mbu.id
  817. where o.type in (1,2) and o.order_status in (1,4)) o
  818. left join wx_merchant m on o.merchant_id=m.id
  819. ) o
  820. <where>
  821. <if test=" null != tenantId and '' != tenantId">
  822. and o.`tenant_id` = #{tenantId}
  823. </if>
  824. <if test=" null != parentTenantId and '' != parentTenantId">
  825. and o.`parent_tenant_id` = #{parentTenantId}
  826. </if>
  827. <if test="startdate!=null and enddate!=null">
  828. and o.create_date between #{startdate} and #{enddate}
  829. </if>
  830. </where>
  831. ) o
  832. </select>
  833. <select id="queryOrderForSum" resultType="Long" parameterType="hashmap">
  834. select ifnull(sum(o.payment),0) payment from wx_order o
  835. where o.type in (0,1,2) and o.order_status = #{order_status}
  836. <if test=" null != tenantId and '' != tenantId">
  837. and o.`tenant_id` = #{tenantId}
  838. </if>
  839. <if test=" null != parentTenantId and '' != parentTenantId">
  840. and o.`parent_tenant_id` = #{parentTenantId}
  841. </if>
  842. <if test="startdate!=null and enddate!=null">
  843. and o.create_date between #{startdate} and #{enddate}
  844. </if>
  845. </select>
  846. <select id="queryOrderForCount" resultType="Long" parameterType="hashmap">
  847. select count(*) from (
  848. select o.* from wx_order o
  849. where o.type in (0,1,2) and o.order_status = #{order_status}
  850. ) o
  851. <where>
  852. <if test=" null != tenantId and '' != tenantId">
  853. and o.`tenant_id` = #{tenantId}
  854. </if>
  855. <if test=" null != parentTenantId and '' != parentTenantId">
  856. and o.`parent_tenant_id` = #{parentTenantId}
  857. </if>
  858. <if test="startdate!=null and enddate!=null">
  859. and o.create_date between #{startdate} and #{enddate}
  860. </if>
  861. </where>
  862. </select>
  863. <resultMap id="PressVoResultMap" type="com.iformall.domain.vo.WxOrderCouponPressVo">
  864. <id column="id" jdbcType="BIGINT" property="id"/>
  865. <result column="order_number" jdbcType="BIGINT" property="orderNumber"/>
  866. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  867. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  868. <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
  869. <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
  870. <result column="product_id" jdbcType="BIGINT" property="productId"/>
  871. <result column="type" jdbcType="INTEGER" property="type"/>
  872. <result column="payment_type" jdbcType="INTEGER" property="paymentType"/>
  873. <result column="payment" jdbcType="INTEGER" property="payment"/>
  874. <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/>
  875. <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
  876. <result column="order_status" jdbcType="INTEGER" property="orderStatus"/>
  877. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  878. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  879. <result column="press_end_date" jdbcType="TIMESTAMP" property="pressEndDate"/>
  880. <result column="press_current_num" jdbcType="INTEGER" property="pressCurrentNum"/>
  881. <result column="press_current_value" jdbcType="INTEGER" property="pressCurrentValue"/>
  882. <result column="coupon_type" jdbcType="INTEGER" property="couponType"/>
  883. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  884. <result column="title" jdbcType="VARCHAR" property="title"/>
  885. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  886. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  887. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  888. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  889. <result column="price" jdbcType="INTEGER" property="price"/>
  890. <result column="unit" jdbcType="INTEGER" property="unit"/>
  891. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  892. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  893. <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId"/>
  894. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus"/>
  895. <result column="compose_order_id" jdbcType="BIGINT" property="composeOrderId"/>
  896. <result column="compose_order_type" jdbcType="INTEGER" property="composeOrderType"/>
  897. <result column="shipping_type" jdbcType="INTEGER" property="shippingType"/>
  898. <result column="shipping_address" jdbcType="VARCHAR" property="shippingAddress"/>
  899. </resultMap>
  900. <resultMap id="PressVoDetailResultMap" type="com.iformall.domain.vo.WxOrderCouponPressVo">
  901. <id column="id" jdbcType="BIGINT" property="id"/>
  902. <result column="order_number" jdbcType="BIGINT" property="orderNumber"/>
  903. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  904. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  905. <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
  906. <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
  907. <result column="product_id" jdbcType="BIGINT" property="productId"/>
  908. <result column="type" jdbcType="INTEGER" property="type"/>
  909. <result column="payment_type" jdbcType="INTEGER" property="paymentType"/>
  910. <result column="payment" jdbcType="INTEGER" property="payment"/>
  911. <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/>
  912. <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
  913. <result column="order_status" jdbcType="INTEGER" property="orderStatus"/>
  914. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  915. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  916. <result column="press_end_date" jdbcType="TIMESTAMP" property="pressEndDate"/>
  917. <result column="press_current_num" jdbcType="INTEGER" property="pressCurrentNum"/>
  918. <result column="press_current_value" jdbcType="INTEGER" property="pressCurrentValue"/>
  919. <result column="coupon_type" jdbcType="INTEGER" property="couponType"/>
  920. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  921. <result column="title" jdbcType="VARCHAR" property="title"/>
  922. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  923. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  924. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  925. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  926. <result column="price" jdbcType="INTEGER" property="price"/>
  927. <result column="unit" jdbcType="INTEGER" property="unit"/>
  928. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  929. <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
  930. <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId"/>
  931. <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus"/>
  932. <result column="compose_order_id" jdbcType="BIGINT" property="composeOrderId"/>
  933. <result column="compose_order_type" jdbcType="INTEGER" property="composeOrderType"/>
  934. <!-- <collection column="{orderId=order_number,tenantId=tenant_id}" property="orderPressList"
  935. ofType="com.iformall.domain.vo.WxOrderPressVo"
  936. javaType="java.util.List"
  937. select="com.iformall.mapper.WxOrderPressMapper.findPressList" >
  938. </collection> -->
  939. </resultMap>
  940. <sql id="allOrderPressListColumns">
  941. 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,
  942. o.create_date,o.update_date,o.press_end_date,o.press_current_num,o.press_current_value,
  943. c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.press_limit_num,
  944. o.compose_order_id,o.compose_order_type,o.`shipping_type`,o.`shipping_address`
  945. </sql>
  946. <sql id="allOrderPressDetailColumns">
  947. 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,
  948. o.create_date,o.update_date,o.press_end_date,o.press_current_num,o.press_current_value,
  949. o.compose_order_id,o.compose_order_type,
  950. 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,
  951. co.id as coupon_order_id,co.coupon_order_status
  952. </sql>
  953. <select id="findListOfPress" parameterType="com.iformall.domain.po.WxOrder" resultMap="PressVoResultMap">
  954. select
  955. <include refid="allOrderPressListColumns"/>
  956. from wx_coupon c,wx_order o
  957. left join wx_coupon_order co on co.order_id = o.id
  958. where o.product_id = c.id and c.type = 8 and o.order_status in (6,7,8,9)
  959. <if test="cUserId != null">
  960. and o.c_user_id = #{cUserId}
  961. </if>
  962. <if test=" null != tenantId and '' != tenantId">
  963. and o.`tenant_id` = #{tenantId}
  964. </if>
  965. <if test=" null != parentTenantId and '' != parentTenantId">
  966. and o.`parent_tenant_id` = #{parentTenantId}
  967. </if>
  968. <if test="orderStatus != null">
  969. AND o.order_status = #{orderStatus}
  970. </if>
  971. <if test=" null != sortColumns">order by ${sortColumns}</if>
  972. </select>
  973. <select id="selectDetailOfPress" parameterType="com.iformall.domain.po.WxOrder" resultMap="PressVoDetailResultMap">
  974. select
  975. <include refid="allOrderPressDetailColumns"/>
  976. FROM wx_order o
  977. left join wx_coupon c ON o.product_id = c.id
  978. left join wx_coupon_order co on o.id = co.order_id
  979. where o.product_id = c.id
  980. <if test="cUserId != null">
  981. and o.c_user_id = #{cUserId}
  982. </if>
  983. <if test=" null != tenantId and '' != tenantId">
  984. and o.`tenant_id` = #{tenantId}
  985. </if>
  986. <if test=" null != parentTenantId and '' != parentTenantId">
  987. and o.`parent_tenant_id` = #{parentTenantId}
  988. </if>
  989. <if test="id != null">
  990. and o.id = #{id}
  991. </if>
  992. </select>
  993. <update id="updateStatusByOrderGroupId" parameterType="com.iformall.domain.po.WxOrder">
  994. update wx_order set order_status=#{orderStatus}
  995. where order_group_id=#{orderGroupId} and order_status=10
  996. <if test=" null != tenantId and '' != tenantId">
  997. and `tenant_id` = #{tenantId}
  998. </if>
  999. <if test=" null != parentTenantId and '' != parentTenantId">
  1000. and `parent_tenant_id` = #{parentTenantId}
  1001. </if>
  1002. </update>
  1003. <update id="updateOrderStatusForGroup" parameterType="java.util.HashMap">
  1004. 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
  1005. </update>
  1006. <update id="updateCUserId" parameterType="com.iformall.domain.po.WxOrder">
  1007. update wx_order set c_user_id= #{cUserId} where tenant_id = #{tenantId}
  1008. <if test=" null != id ">
  1009. and id = #{id}
  1010. </if>
  1011. <if test=" null != ids ">
  1012. and id in
  1013. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  1014. #{idItem}
  1015. </foreach>
  1016. </if>
  1017. </update>
  1018. <select id="getComposeOrderIds" parameterType="com.iformall.domain.po.WxOrder" resultType="Long">
  1019. select distinct compose_order_id from wx_order
  1020. where c_user_id = #{cUserId}
  1021. and parent_order_id = 0
  1022. and (`type` = 0 or `type` = 4)
  1023. and order_status in (0,1,2,3,4,5,97)
  1024. and `tenant_id` = #{tenantId}
  1025. <if test=" null != parentTenantId and '' != parentTenantId">
  1026. and `parent_tenant_id` = #{parentTenantId}
  1027. </if>
  1028. <if test="null != orderStatus">
  1029. AND order_status = #{orderStatus}
  1030. </if>
  1031. <if test=" null != statusS ">
  1032. and `order_status` in
  1033. <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")">
  1034. #{sItem}
  1035. </foreach>
  1036. </if>
  1037. <if test=" null != payVendor ">
  1038. and pay_vendor = #{payVendor}
  1039. </if>
  1040. </select>
  1041. </mapper>