后台服务
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

WxOrderMapper.xml 53 KiB

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