Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

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