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.
 
 
 
 
 

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