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.
 
 
 
 
 

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