25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 

1051 satır
50 KiB

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