LiveOrderMapper.xml 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.live.mapper.LiveOrderMapper">
  6. <resultMap type="LiveOrder" id="LiveOrderResult">
  7. <result property="orderId" column="order_id" />
  8. <result property="liveId" column="live_id" />
  9. <result property="storeId" column="store_id" />
  10. <result property="orderCode" column="order_code" />
  11. <result property="userId" column="user_id" />
  12. <result property="userName" column="user_name" />
  13. <result property="userPhone" column="user_phone" />
  14. <result property="userAddress" column="user_address" />
  15. <result property="cartId" column="cart_id" />
  16. <result property="totalNum" column="total_num" />
  17. <result property="totalPrice" column="total_price" />
  18. <result property="payPrice" column="pay_price" />
  19. <result property="payMoney" column="pay_money" />
  20. <result property="isPay" column="is_pay" />
  21. <result property="payTime" column="pay_time" />
  22. <result property="payType" column="pay_type" />
  23. <result property="createTime" column="create_time" />
  24. <result property="updateTime" column="update_time" />
  25. <result property="status" column="status" />
  26. <result property="refundStatus" column="refund_status" />
  27. <result property="refundImg" column="refund_img" />
  28. <result property="refundExplain" column="refund_explain" />
  29. <result property="refundTime" column="refund_time" />
  30. <result property="refundReason" column="refund_reason" />
  31. <result property="refundMoney" column="refund_money" />
  32. <result property="deliveryCode" column="delivery_code" />
  33. <result property="deliveryName" column="delivery_name" />
  34. <result property="deliverySn" column="delivery_sn" />
  35. <result property="remark" column="remark" />
  36. <result property="isDel" column="is_del" />
  37. <result property="costPrice" column="cost_price" />
  38. <result property="verifyCode" column="verify_code" />
  39. <result property="shippingType" column="shipping_type" />
  40. <result property="isChannel" column="is_channel" />
  41. <result property="finishTime" column="finish_time" />
  42. <result property="deliveryTime" column="delivery_time" />
  43. <result property="tuiMoney" column="tui_money" />
  44. <result property="tuiMoneyStatus" column="tui_money_status" />
  45. <result property="tuiUserId" column="tui_user_id" />
  46. <result property="itemJson" column="item_json" />
  47. <result property="discountMoney" column="discount_money" />
  48. <result property="userCouponId" column="user_coupon_id" />
  49. <result property="companyId" column="company_id" />
  50. <result property="companyUserId" column="company_user_id" />
  51. <result property="storeHouseCode" column="store_house_code" />
  52. <result property="extendOrderId" column="extend_order_id" />
  53. <result property="payDelivery" column="pay_delivery" />
  54. <result property="payRemain" column="pay_remain" />
  55. <result property="deliveryStatus" column="delivery_status" />
  56. <result property="deliveryPayStatus" column="delivery_pay_status" />
  57. <result property="deliveryPayTime" column="delivery_pay_time" />
  58. <result property="deliveryType" column="delivery_type" />
  59. <result property="deliveryPayMoney" column="delivery_pay_money" />
  60. <result property="deliveryImportTime" column="delivery_import_time" />
  61. <result property="deliverySendTime" column="delivery_send_time" />
  62. <result property="isAfterSales" column="is_after_sales" />
  63. <result property="deptId" column="dept_id" />
  64. <result property="channel" column="channel" />
  65. <result property="source" column="source" />
  66. <result property="billPrice" column="bill_price" />
  67. <result property="totalPostage" column="total_postage" />
  68. <result property="payPostage" column="pay_postage" />
  69. <result property="gainIntegral" column="gain_integral" />
  70. <result property="useIntegral" column="use_integral" />
  71. <result property="payIntegral" column="pay_integral" />
  72. <result property="backIntegral" column="back_integral" />
  73. <result property="isEditMoney" column="is_edit_money" />
  74. <result property="orderName" column="order_name" />
  75. <result property="productIntroduce" column="product_introduce" />
  76. <result property="companyUserName" column="company_user_name" />
  77. <result property="companyName" column="company_name" />
  78. <result property="customerId" column="customer_id" />
  79. <result property="couponPrice" column="coupon_price" />
  80. </resultMap>
  81. <sql id="selectLiveOrderVo">
  82. SELECT
  83. a.order_id,a.live_id, a.product_id, a.order_name, a.store_id, a.order_code, a.user_id, a.user_name,
  84. a.user_phone, a.user_address, a.cart_id, a.total_num, a.total_price, a.pay_price, a.pay_money, a.is_pay,
  85. a.pay_time, a.pay_type, a.create_time, a.update_time, a.STATUS, a.refund_status, a.refund_img, a.refund_explain,
  86. a.refund_time, a.refund_reason, a.refund_money, a.delivery_code, a.delivery_name, a.delivery_sn,
  87. a.remark, a.is_del, a.cost_price, a.verify_code, a.shipping_type, a.is_channel, a.finish_time,
  88. a.delivery_time, a.tui_money, a.tui_money_status, a.tui_user_id, a.item_json, a.discount_money,
  89. a.user_coupon_id, a.company_id, a.company_user_id, a.store_house_code, a.extend_order_id, a.pay_delivery,
  90. a.pay_remain, a.delivery_status, a.delivery_pay_status, a.delivery_pay_time, a.delivery_type,
  91. a.delivery_pay_money, a.delivery_import_time, a.delivery_send_time, a.is_after_sales, a.dept_id,
  92. a.channel, a.source, a.bill_price, a.total_postage, a.pay_postage, a.gain_integral,a.coupon_price,
  93. a.use_integral, a.pay_integral, a.back_integral, a.is_edit_money, b.product_info as product_introduce,a.customer_id
  94. FROM
  95. live_order a LEFT JOIN fs_store_product_scrm b ON a.product_id = b.product_id
  96. </sql>
  97. <select id="selectLiveOrderList" parameterType="com.fs.live.domain.LiveOrder" resultMap="LiveOrderResult">
  98. SELECT
  99. c.company_name,cu.user_name as company_user_name,a.order_id,a.live_id, a.product_id, a.order_name, a.store_id, a.order_code, a.user_id, a.user_name,
  100. a.user_phone, a.user_address, a.cart_id, a.total_num, a.total_price, a.pay_price, a.pay_money, a.is_pay,
  101. a.pay_time, a.pay_type, a.create_time, a.update_time, a.STATUS, a.refund_status, a.refund_img, a.refund_explain,
  102. a.refund_time, a.refund_reason, a.refund_money, a.delivery_code, a.delivery_name, a.delivery_sn,
  103. a.remark, a.is_del, a.cost_price, a.verify_code, a.shipping_type, a.is_channel, a.finish_time,
  104. a.delivery_time, a.tui_money, a.tui_money_status, a.tui_user_id, a.item_json, a.discount_money,
  105. a.user_coupon_id, a.company_id, a.company_user_id, a.store_house_code, a.extend_order_id, a.pay_delivery,
  106. a.pay_remain, a.delivery_status, a.delivery_pay_status, a.delivery_pay_time, a.delivery_type,
  107. a.delivery_pay_money, a.delivery_import_time, a.delivery_send_time, a.is_after_sales, a.dept_id,
  108. a.channel, a.source, a.bill_price, a.total_postage, a.pay_postage, a.gain_integral,a.coupon_price,
  109. a.use_integral, a.pay_integral, a.back_integral, a.is_edit_money, b.product_info as product_introduce,a.customer_id
  110. FROM
  111. live_order a LEFT JOIN fs_store_product_scrm b ON a.product_id = b.product_id
  112. left join company_user cu on a.company_user_id = cu.user_id
  113. left join company c on a.company_id = c.company_id
  114. <where>
  115. <if test="finishTimeStart != null and finishTimeEnd != null">and finish_time between #{finishTimeStart} and #{finishTimeEnd}</if>
  116. <if test="payStartTime != null and payEndTime != null">and pay_time between #{payStartTime} and #{payEndTime}</if>
  117. <if test="liveId != null "> and live_id = #{liveId}</if>
  118. <if test="storeId != null "> and store_id = #{storeId}</if>
  119. <if test="orderCode != null and orderCode != ''"> and a.order_code = #{orderCode}</if>
  120. <if test="userId != null and userId != ''"> and a.user_id = #{userId}</if>
  121. <if test="realName != null and realName != ''"> and a.user_name like concat('%', #{realName}, '%')</if>
  122. <if test="userPhone != null and userPhone != ''"> and a.user_phone = #{userPhone}</if>
  123. <if test="userAddress != null and userAddress != ''"> and a.user_address = #{userAddress}</if>
  124. <if test="cartId != null and cartId != ''"> and cart_id = #{cartId}</if>
  125. <if test="totalNum != null and totalNum != ''"> and total_num = #{totalNum}</if>
  126. <if test="totalPrice != null "> and total_price = #{totalPrice}</if>
  127. <if test="payPrice != null "> and a.pay_price = #{payPrice}</if>
  128. <if test="payMoney != null "> and a.pay_money = #{payMoney}</if>
  129. <if test="isPay != null and isPay != ''"> and a.is_pay = #{isPay}</if>
  130. <if test="payTime != null "> and pay_time = #{payTime}</if>
  131. <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
  132. <if test="status != null "> and a.status = #{status}</if>
  133. <if test="refundStatus != null and refundStatus != ''"> and refund_status = #{refundStatus}</if>
  134. <if test="refundImg != null and refundImg != ''"> and refund_img = #{refundImg}</if>
  135. <if test="refundExplain != null and refundExplain != ''"> and refund_explain = #{refundExplain}</if>
  136. <if test="refundTime != null "> and refund_time = #{refundTime}</if>
  137. <if test="refundReason != null and refundReason != ''"> and refund_reason = #{refundReason}</if>
  138. <if test="refundMoney != null "> and refund_money = #{refundMoney}</if>
  139. <if test="deliveryCode != null and deliveryCode != ''"> and a.delivery_code = #{deliveryCode}</if>
  140. <if test="deliveryName != null and deliveryName != ''"> and a.delivery_name like concat('%', #{deliveryName}, '%')</if>
  141. <if test="deliverySn != null and deliverySn != ''"> and a.delivery_sn = #{deliverySn}</if>
  142. <if test="isDel != null and isDel != ''"> and is_del = #{isDel}</if>
  143. <if test="costPrice != null "> and cost_price = #{costPrice}</if>
  144. <if test="verifyCode != null and verifyCode != ''"> and verify_code = #{verifyCode}</if>
  145. <if test="shippingType != null "> and shipping_type = #{shippingType}</if>
  146. <if test="isChannel != null and isChannel != ''"> and is_channel = #{isChannel}</if>
  147. <if test="finishTime != null ">and a.finish_time >= #{finishTime} and a.finish_time &lt; date_add(#{finishTime}, interval 1 day)</if>
  148. <if test="deliveryTime != null and deliveryTime != ''"> and a.delivery_time = #{deliveryTime}</if>
  149. <if test="tuiMoney != null "> and tui_money = #{tuiMoney}</if>
  150. <if test="tuiMoneyStatus != null "> and tui_money_status = #{tuiMoneyStatus}</if>
  151. <if test="tuiUserId != null "> and tui_user_id = #{tuiUserId}</if>
  152. <if test="itemJson != null and itemJson != ''"> and item_json = #{itemJson}</if>
  153. <if test="discountMoney != null "> and discount_money = #{discountMoney}</if>
  154. <if test="userCouponId != null "> and user_coupon_id = #{userCouponId}</if>
  155. <if test="companyId != null "> and a.company_id = #{companyId}</if>
  156. <if test="companyUserId != null "> and a.company_user_id = #{companyUserId}</if>
  157. <if test="storeHouseCode != null and storeHouseCode != ''"> and store_house_code = #{storeHouseCode}</if>
  158. <if test="extendOrderId != null and extendOrderId != ''"> and extend_order_id = #{extendOrderId}</if>
  159. <if test="payDelivery != null "> and pay_delivery = #{payDelivery}</if>
  160. <if test="payRemain != null "> and pay_remain = #{payRemain}</if>
  161. <if test="deliveryStatus != null "> and delivery_status = #{deliveryStatus}</if>
  162. <if test="deliveryPayStatus != null "> and delivery_pay_status = #{deliveryPayStatus}</if>
  163. <if test="deliveryPayTime != null and deliveryPayTime != ''"> and delivery_pay_time = #{deliveryPayTime}</if>
  164. <if test="deliveryType != null and deliveryType != ''"> and delivery_type = #{deliveryType}</if>
  165. <if test="deliveryPayMoney != null "> and delivery_pay_money = #{deliveryPayMoney}</if>
  166. <if test="deliveryImportTime != null "> and delivery_import_time = #{deliveryImportTime}</if>
  167. <if test="deliverySendTime != null "> and delivery_send_time = #{deliverySendTime}</if>
  168. <if test="isAfterSales != null "> and is_after_sales = #{isAfterSales}</if>
  169. <if test="deptId != null "> and cu.dept_id = #{deptId}</if>
  170. <if test="channel != null and channel != ''"> and channel = #{channel}</if>
  171. <if test="source != null "> and source = #{source}</if>
  172. <if test="billPrice != null "> and bill_price = #{billPrice}</if>
  173. <if test="totalPostage != null "> and total_postage = #{totalPostage}</if>
  174. <if test="payPostage != null "> and pay_postage = #{payPostage}</if>
  175. <if test="gainIntegral != null "> and gain_integral = #{gainIntegral}</if>
  176. <if test="useIntegral != null "> and use_integral = #{useIntegral}</if>
  177. <if test="payIntegral != null "> and pay_integral = #{payIntegral}</if>
  178. <if test="backIntegral != null "> and back_integral = #{backIntegral}</if>
  179. <if test="isEditMoney != null "> and is_edit_money = #{isEditMoney}</if>
  180. <if test="orderName != null "> and order_name = #{orderName}</if>
  181. </where>
  182. order by a.create_time desc
  183. </select>
  184. <select id="selectLiveOrderByOrderId" parameterType="String" resultMap="LiveOrderResult">
  185. SELECT
  186. c.company_name,cu.user_name as company_user_name,a.order_id,a.live_id, a.product_id, a.order_name, a.store_id, a.order_code, a.user_id, a.user_name,
  187. a.user_phone, a.user_address, a.cart_id, a.total_num, a.total_price, a.pay_price, a.pay_money, a.is_pay,
  188. a.pay_time, a.pay_type, a.create_time, a.update_time, a.STATUS, a.refund_status, a.refund_img, a.refund_explain,
  189. a.refund_time, a.refund_reason, a.refund_money, a.delivery_code, a.delivery_name, a.delivery_sn,
  190. a.remark, a.is_del, a.cost_price, a.verify_code, a.shipping_type, a.is_channel, a.finish_time,
  191. a.delivery_time, a.tui_money, a.tui_money_status, a.tui_user_id, a.item_json, a.discount_money,
  192. a.user_coupon_id, a.company_id, a.company_user_id, a.store_house_code, a.extend_order_id, a.pay_delivery,
  193. a.pay_remain, a.delivery_status, a.delivery_pay_status, a.delivery_pay_time, a.delivery_type,
  194. a.delivery_pay_money, a.delivery_import_time, a.delivery_send_time, a.is_after_sales, a.dept_id,
  195. a.channel, a.source, a.bill_price, a.total_postage, a.pay_postage, a.gain_integral,a.coupon_price,
  196. a.use_integral, a.pay_integral, a.back_integral, a.is_edit_money, b.product_info as product_introduce,a.customer_id
  197. FROM
  198. live_order a LEFT JOIN fs_store_product_scrm b ON a.product_id = b.product_id
  199. left join company_user cu on a.company_user_id = cu.user_id
  200. left join company c on a.company_id = c.company_id
  201. where a.order_id = #{orderId}
  202. order by a.create_time desc
  203. </select>
  204. <insert id="insertLiveOrder" parameterType="LiveOrder" useGeneratedKeys="true" keyProperty="orderId">
  205. insert into live_order
  206. <trim prefix="(" suffix=")" suffixOverrides=",">
  207. <if test="liveId != null">live_id,</if>
  208. <if test="storeId != null">store_id,</if>
  209. <if test="orderCode != null and orderCode != ''">order_code,</if>
  210. <if test="userId != null and userId != ''">user_id,</if>
  211. <if test="realName != null">real_name,</if>
  212. <if test="userPhone != null">user_phone,</if>
  213. <if test="userAddress != null">user_address,</if>
  214. <if test="cartId != null">cart_id,</if>
  215. <if test="totalNum != null and totalNum != ''">total_num,</if>
  216. <if test="totalPrice != null">total_price,</if>
  217. <if test="payPrice != null">pay_price,</if>
  218. <if test="payMoney != null">pay_money,</if>
  219. <if test="isPay != null">is_pay,</if>
  220. <if test="payTime != null">pay_time,</if>
  221. <if test="payType != null">pay_type,</if>
  222. <if test="createTime != null">create_time,</if>
  223. <if test="updateTime != null">update_time,</if>
  224. <if test="status != null">status,</if>
  225. <if test="refundStatus != null">refund_status,</if>
  226. <if test="refundImg != null">refund_img,</if>
  227. <if test="refundExplain != null">refund_explain,</if>
  228. <if test="refundTime != null">refund_time,</if>
  229. <if test="refundReason != null">refund_reason,</if>
  230. <if test="refundMoney != null">refund_money,</if>
  231. <if test="deliveryCode != null">delivery_code,</if>
  232. <if test="deliveryName != null">delivery_name,</if>
  233. <if test="deliverySn != null">delivery_sn,</if>
  234. <if test="remark != null">remark,</if>
  235. <if test="isDel != null">is_del,</if>
  236. <if test="costPrice != null">cost_price,</if>
  237. <if test="verifyCode != null">verify_code,</if>
  238. <if test="shippingType != null">shipping_type,</if>
  239. <if test="isChannel != null">is_channel,</if>
  240. <if test="finishTime != null">finish_time,</if>
  241. <if test="deliveryTime != null">delivery_time,</if>
  242. <if test="tuiMoney != null">tui_money,</if>
  243. <if test="tuiMoneyStatus != null">tui_money_status,</if>
  244. <if test="tuiUserId != null">tui_user_id,</if>
  245. <if test="itemJson != null">item_json,</if>
  246. <if test="discountMoney != null">discount_money,</if>
  247. <if test="userCouponId != null">user_coupon_id,</if>
  248. <if test="companyId != null">company_id,</if>
  249. <if test="companyUserId != null">company_user_id,</if>
  250. <if test="storeHouseCode != null">store_house_code,</if>
  251. <if test="extendOrderId != null">extend_order_id,</if>
  252. <if test="payDelivery != null">pay_delivery,</if>
  253. <if test="payRemain != null">pay_remain,</if>
  254. <if test="deliveryStatus != null">delivery_status,</if>
  255. <if test="deliveryPayStatus != null">delivery_pay_status,</if>
  256. <if test="deliveryPayTime != null">delivery_pay_time,</if>
  257. <if test="deliveryType != null">delivery_type,</if>
  258. <if test="deliveryPayMoney != null">delivery_pay_money,</if>
  259. <if test="deliveryImportTime != null">delivery_import_time,</if>
  260. <if test="deliverySendTime != null">delivery_send_time,</if>
  261. <if test="isAfterSales != null">is_after_sales,</if>
  262. <if test="deptId != null">dept_id,</if>
  263. <if test="channel != null">channel,</if>
  264. <if test="source != null">source,</if>
  265. <if test="billPrice != null">bill_price,</if>
  266. <if test="totalPostage != null">total_postage,</if>
  267. <if test="payPostage != null">pay_postage,</if>
  268. <if test="gainIntegral != null">gain_integral,</if>
  269. <if test="useIntegral != null">use_integral,</if>
  270. <if test="payIntegral != null">pay_integral,</if>
  271. <if test="backIntegral != null">back_integral,</if>
  272. <if test="isEditMoney != null">is_edit_money,</if>
  273. <if test="productId != null">product_id,</if>
  274. <if test="customerId != null">customer_id,</if>
  275. <if test="couponPrice != null">coupon_price,</if>
  276. </trim>
  277. <trim prefix="values (" suffix=")" suffixOverrides=",">
  278. <if test="liveId != null">#{liveId},</if>
  279. <if test="storeId != null">#{storeId},</if>
  280. <if test="orderCode != null and orderCode != ''">#{orderCode},</if>
  281. <if test="userId != null and userId != ''">#{userId},</if>
  282. <if test="realName != null">#{realName},</if>
  283. <if test="userPhone != null">#{userPhone},</if>
  284. <if test="userAddress != null">#{userAddress},</if>
  285. <if test="cartId != null">#{cartId},</if>
  286. <if test="totalNum != null and totalNum != ''">#{totalNum},</if>
  287. <if test="totalPrice != null">#{totalPrice},</if>
  288. <if test="payPrice != null">#{payPrice},</if>
  289. <if test="payMoney != null">#{payMoney},</if>
  290. <if test="isPay != null">#{isPay},</if>
  291. <if test="payTime != null">#{payTime},</if>
  292. <if test="payType != null">#{payType},</if>
  293. <if test="createTime != null">#{createTime},</if>
  294. <if test="updateTime != null">#{updateTime},</if>
  295. <if test="status != null">#{status},</if>
  296. <if test="refundStatus != null">#{refundStatus},</if>
  297. <if test="refundImg != null">#{refundImg},</if>
  298. <if test="refundExplain != null">#{refundExplain},</if>
  299. <if test="refundTime != null">#{refundTime},</if>
  300. <if test="refundReason != null">#{refundReason},</if>
  301. <if test="refundMoney != null">#{refundMoney},</if>
  302. <if test="deliveryCode != null">#{deliveryCode},</if>
  303. <if test="deliveryName != null">#{deliveryName},</if>
  304. <if test="deliverySn != null">#{deliverySn},</if>
  305. <if test="remark != null">#{remark},</if>
  306. <if test="isDel != null">#{isDel},</if>
  307. <if test="costPrice != null">#{costPrice},</if>
  308. <if test="verifyCode != null">#{verifyCode},</if>
  309. <if test="shippingType != null">#{shippingType},</if>
  310. <if test="isChannel != null">#{isChannel},</if>
  311. <if test="finishTime != null">#{finishTime},</if>
  312. <if test="deliveryTime != null">#{deliveryTime},</if>
  313. <if test="tuiMoney != null">#{tuiMoney},</if>
  314. <if test="tuiMoneyStatus != null">#{tuiMoneyStatus},</if>
  315. <if test="tuiUserId != null">#{tuiUserId},</if>
  316. <if test="itemJson != null">#{itemJson},</if>
  317. <if test="discountMoney != null">#{discountMoney},</if>
  318. <if test="userCouponId != null">#{userCouponId},</if>
  319. <if test="companyId != null">#{companyId},</if>
  320. <if test="companyUserId != null">#{companyUserId},</if>
  321. <if test="storeHouseCode != null">#{storeHouseCode},</if>
  322. <if test="extendOrderId != null">#{extendOrderId},</if>
  323. <if test="payDelivery != null">#{payDelivery},</if>
  324. <if test="payRemain != null">#{payRemain},</if>
  325. <if test="deliveryStatus != null">#{deliveryStatus},</if>
  326. <if test="deliveryPayStatus != null">#{deliveryPayStatus},</if>
  327. <if test="deliveryPayTime != null">#{deliveryPayTime},</if>
  328. <if test="deliveryType != null">#{deliveryType},</if>
  329. <if test="deliveryPayMoney != null">#{deliveryPayMoney},</if>
  330. <if test="deliveryImportTime != null">#{deliveryImportTime},</if>
  331. <if test="deliverySendTime != null">#{deliverySendTime},</if>
  332. <if test="isAfterSales != null">#{isAfterSales},</if>
  333. <if test="deptId != null">#{deptId},</if>
  334. <if test="channel != null">#{channel},</if>
  335. <if test="source != null">#{source},</if>
  336. <if test="billPrice != null">#{billPrice},</if>
  337. <if test="totalPostage != null">#{totalPostage},</if>
  338. <if test="payPostage != null">#{payPostage},</if>
  339. <if test="gainIntegral != null">#{gainIntegral},</if>
  340. <if test="useIntegral != null">#{useIntegral},</if>
  341. <if test="payIntegral != null">#{payIntegral},</if>
  342. <if test="backIntegral != null">#{backIntegral},</if>
  343. <if test="isEditMoney != null">#{isEditMoney},</if>
  344. <if test="productId != null">#{productId},</if>
  345. <if test="customerId != null">#{customerId},</if>
  346. <if test="couponPrice != null">#{couponPrice},</if>
  347. </trim>
  348. </insert>
  349. <update id="updateLiveOrder" parameterType="LiveOrder">
  350. update live_order
  351. <trim prefix="SET" suffixOverrides=",">
  352. <if test="liveId != null">live_id = #{liveId},</if>
  353. <if test="storeId != null">store_id = #{storeId},</if>
  354. <if test="orderCode != null and orderCode != ''">order_code = #{orderCode},</if>
  355. <if test="userId != null and userId != ''">user_id = #{userId},</if>
  356. <if test="realName != null">real_name = #{realName},</if>
  357. <if test="userPhone != null">user_phone = #{userPhone},</if>
  358. <if test="userAddress != null">user_address = #{userAddress},</if>
  359. <if test="cartId != null">cart_id = #{cartId},</if>
  360. <if test="totalNum != null and totalNum != ''">total_num = #{totalNum},</if>
  361. <if test="totalPrice != null">total_price = #{totalPrice},</if>
  362. <if test="payPrice != null">pay_price = #{payPrice},</if>
  363. <if test="payMoney != null">pay_money = #{payMoney},</if>
  364. <if test="isPay != null">is_pay = #{isPay},</if>
  365. <if test="payTime != null">pay_time = #{payTime},</if>
  366. <if test="payType != null">pay_type = #{payType},</if>
  367. <if test="createTime != null">create_time = #{createTime},</if>
  368. <if test="updateTime != null">update_time = #{updateTime},</if>
  369. <if test="status != null">status = #{status},</if>
  370. <if test="refundStatus != null">refund_status = #{refundStatus},</if>
  371. <if test="refundImg != null">refund_img = #{refundImg},</if>
  372. <if test="refundExplain != null">refund_explain = #{refundExplain},</if>
  373. <if test="refundTime != null">refund_time = #{refundTime},</if>
  374. <if test="refundReason != null">refund_reason = #{refundReason},</if>
  375. <if test="refundMoney != null">refund_money = #{refundMoney},</if>
  376. <if test="deliveryCode != null">delivery_code = #{deliveryCode},</if>
  377. <if test="deliveryName != null">delivery_name = #{deliveryName},</if>
  378. <if test="deliverySn != null">delivery_sn = #{deliverySn},</if>
  379. <if test="remark != null">remark = #{remark},</if>
  380. <if test="isDel != null">is_del = #{isDel},</if>
  381. <if test="costPrice != null">cost_price = #{costPrice},</if>
  382. <if test="verifyCode != null">verify_code = #{verifyCode},</if>
  383. <if test="shippingType != null">shipping_type = #{shippingType},</if>
  384. <if test="isChannel != null">is_channel = #{isChannel},</if>
  385. <if test="finishTime != null">finish_time = #{finishTime},</if>
  386. <if test="deliveryTime != null">delivery_time = #{deliveryTime},</if>
  387. <if test="tuiMoney != null">tui_money = #{tuiMoney},</if>
  388. <if test="tuiMoneyStatus != null">tui_money_status = #{tuiMoneyStatus},</if>
  389. <if test="tuiUserId != null">tui_user_id = #{tuiUserId},</if>
  390. <if test="itemJson != null">item_json = #{itemJson},</if>
  391. <if test="discountMoney != null">discount_money = #{discountMoney},</if>
  392. <if test="userCouponId != null">user_coupon_id = #{userCouponId},</if>
  393. <if test="companyId != null">company_id = #{companyId},</if>
  394. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  395. <if test="storeHouseCode != null">store_house_code = #{storeHouseCode},</if>
  396. <if test="extendOrderId != null">extend_order_id = #{extendOrderId},</if>
  397. <if test="payDelivery != null">pay_delivery = #{payDelivery},</if>
  398. <if test="payRemain != null">pay_remain = #{payRemain},</if>
  399. <if test="deliveryStatus != null">delivery_status = #{deliveryStatus},</if>
  400. <if test="deliveryPayStatus != null">delivery_pay_status = #{deliveryPayStatus},</if>
  401. <if test="deliveryPayTime != null">delivery_pay_time = #{deliveryPayTime},</if>
  402. <if test="deliveryType != null">delivery_type = #{deliveryType},</if>
  403. <if test="deliveryPayMoney != null">delivery_pay_money = #{deliveryPayMoney},</if>
  404. <if test="deliveryImportTime != null">delivery_import_time = #{deliveryImportTime},</if>
  405. <if test="deliverySendTime != null">delivery_send_time = #{deliverySendTime},</if>
  406. <if test="isAfterSales != null">is_after_sales = #{isAfterSales},</if>
  407. <if test="deptId != null">dept_id = #{deptId},</if>
  408. <if test="channel != null">channel = #{channel},</if>
  409. <if test="source != null">source = #{source},</if>
  410. <if test="billPrice != null">bill_price = #{billPrice},</if>
  411. <if test="totalPostage != null">total_postage = #{totalPostage},</if>
  412. <if test="payPostage != null">pay_postage = #{payPostage},</if>
  413. <if test="gainIntegral != null">gain_integral = #{gainIntegral},</if>
  414. <if test="useIntegral != null">use_integral = #{useIntegral},</if>
  415. <if test="payIntegral != null">pay_integral = #{payIntegral},</if>
  416. <if test="backIntegral != null">back_integral = #{backIntegral},</if>
  417. <if test="isEditMoney != null">is_edit_money = #{isEditMoney},</if>
  418. <if test="customerId != null">customer_id = #{customerId},</if>
  419. <if test="couponPrice != null">coupon_price = #{couponPrice},</if>
  420. </trim>
  421. where order_id = #{orderId}
  422. </update>
  423. <delete id="deleteLiveOrderByOrderId" parameterType="String">
  424. delete from live_order where order_id = #{orderId}
  425. </delete>
  426. <delete id="deleteLiveOrderByOrderIds" parameterType="String">
  427. delete from live_order where order_id in
  428. <foreach item="orderId" collection="array" open="(" separator="," close=")">
  429. #{orderId}
  430. </foreach>
  431. </delete>
  432. <select id="getLiveOrderTimeGranularity" parameterType="com.fs.live.vo.LiveOrderTimeVo" resultMap="LiveOrderResult">
  433. <include refid="selectLiveOrderVo"/>
  434. where 1=1
  435. <if test="timeOptions != 'all'">and a.create_time >= #{createTime}</if>
  436. <if test="liveId != null">and a.live_id = #{liveId}</if>
  437. order by a.create_time desc
  438. </select>
  439. <select id="selectFsOutDateOrder" resultType="com.fs.live.domain.LiveOrder">
  440. <![CDATA[
  441. SELECT *
  442. FROM live_order
  443. WHERE status = 1
  444. AND create_time < DATE_SUB(NOW(), INTERVAL 1800 MINUTE)
  445. ]]>
  446. </select>
  447. <update id="batchUpdateErpByOrderIds">
  448. UPDATE live_order
  449. SET erp_phone =
  450. <trim prefix="CASE order_id" suffix="END">
  451. <foreach collection="maps" item="map">
  452. WHEN #{map.orderId} THEN #{map.erpPhone}
  453. </foreach>
  454. </trim>
  455. WHERE order_id IN
  456. <foreach collection="maps" item="map" open="(" separator="," close=")">
  457. #{map.orderId}
  458. </foreach>
  459. </update>
  460. <select id="selectLiveOrderInId" resultType="com.fs.live.domain.LiveOrder">
  461. <include refid="selectLiveOrderVo"/>
  462. where order_id IN <foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
  463. #{item}
  464. </foreach>
  465. </select>
  466. <select id="selectLiveOrderListVO" resultType="com.fs.live.vo.LiveOrderVO">
  467. select o.*,u.phone,u.register_code,u.register_date,u.source, c.company_name ,cu.nick_name as company_user_nick_name ,cu.phonenumber as company_usere_phonenumber
  468. , csc.name miniProgramName
  469. from live_order o
  470. left join fs_user u on o.user_id=u.user_id
  471. left join company c on c.company_id=o.company_id
  472. left join company_user cu on cu.user_id=o.company_user_id
  473. <if test="maps.erpAccount != null and maps.erpAccount != ''">
  474. LEFT JOIN live_order_df df on df.order_id=o.order_id
  475. </if>
  476. <if test = "maps.productName != null and maps.productName != '' ">
  477. left join live_order_item oi on o.order_id = oi.order_id
  478. left join fs_store_product_scrm fsp on fsp.product_id = oi.product_id
  479. </if>
  480. LEFT JOIN (
  481. SELECT
  482. sp.*,
  483. ROW_NUMBER() OVER (PARTITION BY sp.business_code ORDER BY sp.create_time DESC) as rn
  484. FROM live_order_payment sp
  485. WHERE sp.business_code IS NOT NULL
  486. ) sp_latest ON sp_latest.business_code = o.order_code AND sp_latest.rn = 1
  487. LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
  488. <where>
  489. <if test="maps.coursePlaySourceConfigId != null">
  490. and csc.id = #{maps.coursePlaySourceConfigId}
  491. </if>
  492. <if test="maps.orderCodes != null and maps.orderCodes.size > 0">
  493. and o.order_code in
  494. <foreach collection="maps.orderCodes" item="orderCode" open="(" close=")" separator=",">
  495. #{orderCode}
  496. </foreach>
  497. </if>
  498. <if test="maps.orderCode != null and maps.orderCode !=''">
  499. and o.order_code like CONCAT('%',#{maps.orderCode},'%')
  500. </if>
  501. <if test="maps.isPayRemain != null">
  502. and o.is_pay_remain =#{maps.isPayRemain}
  503. </if>
  504. <if test="maps.userId != null">
  505. and o.user_id =#{maps.userId}
  506. </if>
  507. <if test="maps.deliveryId != null and maps.deliveryId !=''">
  508. and o.delivery_id =#{maps.deliveryId}
  509. </if>
  510. <if test="maps.nickname != null and maps.nickname !=''">
  511. and u.nickname like CONCAT('%',#{maps.nickname},'%')
  512. </if>
  513. <if test="maps.realName != null and maps.realName !=''">
  514. and o.user_name like CONCAT('%',#{maps.realName},'%')
  515. </if>
  516. <if test="maps.phone != null and maps.phone !=''">
  517. and u.phone like CONCAT('%',#{maps.phone},'%')
  518. </if>
  519. <if test="maps.userPhone != null and maps.userPhone !=''">
  520. and o.user_phone like CONCAT('%',#{maps.userPhone},'%')
  521. </if>
  522. <if test="maps.status != null and maps.status != 6">
  523. and o.status = #{maps.status}
  524. </if>
  525. <if test="maps.status == 6">
  526. and o.`status`= 1
  527. and (o.extend_order_id is null or o.extend_order_id like '')
  528. </if>
  529. <if test="maps.isUpload != null and maps.isUpload == 0 ">
  530. and o.certificates is null
  531. </if>
  532. <if test="maps.isUpload != null and maps.isUpload == 1 ">
  533. and o.certificates is not null
  534. </if>
  535. <if test="maps.deliveryStatus != null ">
  536. and o.delivery_status =#{maps.deliveryStatus}
  537. </if>
  538. <if test="maps.deliveryPayStatus != null ">
  539. and o.delivery_pay_status =#{maps.deliveryPayStatus}
  540. </if>
  541. <if test="maps.companyId != null ">
  542. and o.company_id =#{maps.companyId}
  543. </if>
  544. <if test="maps.isHealth != null and maps.isHealth != '' ">
  545. and o.company_id is null
  546. </if>
  547. <if test="maps.notHealth != null ">
  548. and o.company_id is not null
  549. </if>
  550. <if test="maps.companyUserId != null ">
  551. and o.company_user_id =#{maps.companyUserId}
  552. </if>
  553. <if test="maps.companyUserNickName != null and maps.companyUserNickName != '' ">
  554. and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
  555. </if>
  556. <if test="maps.productName != null and maps.productName != '' ">
  557. and fsp.product_name like concat('%', #{maps.productName}, '%')
  558. </if>
  559. <if test="maps.orderType != null ">
  560. and o.order_type =#{maps.orderType}
  561. </if>
  562. <if test="maps.payType != null ">
  563. and o.pay_type =#{maps.payType}
  564. </if>
  565. <if test="maps.scheduleId != null ">
  566. and o.schedule_id =#{maps.scheduleId}
  567. </if>
  568. <if test="maps.createTimeList != null ">
  569. AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d')
  570. AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d')
  571. </if>
  572. <if test="maps.deliverySendTimeList != null ">
  573. AND date_format(o.delivery_send_time,'%y%m%d') &gt;= date_format(#{maps.deliverySendTimeList[0]},'%y%m%d')
  574. AND date_format(o.delivery_send_time,'%y%m%d') &lt;= date_format(#{maps.deliverySendTimeList[1]},'%y%m%d')
  575. </if>
  576. <if test="maps.paidStatus != null ">
  577. and o.paid =#{maps.paidStatus}
  578. </if>
  579. <if test="maps.payTimeList != null ">
  580. AND date_format(o.pay_time,'%y%m%d') &gt;= date_format(#{maps.payTimeList[0]},'%y%m%d')
  581. AND date_format(o.pay_time,'%y%m%d') &lt;= date_format(#{maps.payTimeList[1]},'%y%m%d')
  582. </if>
  583. <if test="maps.deliveryImportTimeList != null ">
  584. AND date_format(o.delivery_import_time,'%y%m%d') &gt;= date_format(#{maps.deliveryImportTimeList[0]},'%y%m%d')
  585. AND date_format(o.delivery_import_time,'%y%m%d') &lt;= date_format(#{maps.deliveryImportTimeList[1]},'%y%m%d')
  586. </if>
  587. <if test="maps.deptId != null ">
  588. AND (o.dept_id = #{maps.deptId} OR o.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) ))
  589. </if>
  590. <if test="maps.erpPhoneNumber != null and maps.erpPhoneNumber != ''">
  591. and o.erp_phone like concat(#{maps.erpPhoneNumber},'%')
  592. </if>
  593. <if test="maps.erpAccount != null and maps.erpAccount != '未分拣' and maps.erpAccount != ''">
  594. and df.login_account like #{maps.erpAccount}
  595. </if>
  596. <if test="maps.erpAccount == '未分拣'">
  597. and ( df.login_account is null or df.login_account like '')
  598. </if>
  599. </where>
  600. ${maps.params.dataScope}
  601. <if test="maps.productName != null and maps.productName != '' ">
  602. group by o.order_id
  603. </if>
  604. order by
  605. <if test="maps.sortField == 'companyUserName'">
  606. cu.nick_name
  607. </if>
  608. <if test="maps.sortField == 'packageName'">
  609. o.package_name
  610. </if>
  611. <if test="maps.sortField == 'payPrice'">
  612. o.pay_price
  613. </if>
  614. <if test="maps.sortField == 'payMoney'">
  615. o.pay_money
  616. </if>
  617. <if test="maps.sortOrder != null and maps.sortOrder != ''">
  618. ${maps.sortOrder}
  619. </if>
  620. <if test="maps.sortField == null or maps.sortField == ''">
  621. o.order_id desc
  622. </if>
  623. </select>
  624. <select id="selectLiveOrderStatistics" resultType="java.util.Map">
  625. select sum(o.pay_price) pay_price,sum(o.pay_money) pay_money,sum(o.pay_delivery) pay_remain
  626. FROM live_order o
  627. left join fs_user u on o.user_id=u.user_id
  628. left join company c on c.company_id=o.company_id
  629. left join company_user cu on cu.user_id=o.company_user_id
  630. <if test="maps.erpAccount != null or maps.erpAccount != ''">
  631. LEFT JOIN live_order_df df on df.order_id=o.order_id
  632. </if>
  633. <if test = "maps.productName != null and maps.productName != '' ">
  634. left join live_order_item oi on o.order_id = oi.order_id
  635. left join fs_store_product_scrm fsp on fsp.product_id = oi.product_id
  636. </if>
  637. <if test="maps.coursePlaySourceConfigId != null">
  638. LEFT JOIN (
  639. SELECT
  640. sp.*,
  641. ROW_NUMBER() OVER (PARTITION BY sp.business_code ORDER BY sp.create_time DESC) as rn
  642. FROM live_order_payment sp
  643. WHERE sp.business_code IS NOT NULL
  644. ) sp_latest ON sp_latest.business_code = o.order_code AND sp_latest.rn = 1
  645. LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
  646. </if>
  647. <where>
  648. <if test="maps.coursePlaySourceConfigId != null">
  649. and csc.id = #{maps.coursePlaySourceConfigId}
  650. </if>
  651. <if test="maps.orderCodes != null and maps.orderCodes.size > 0">
  652. and o.order_code in
  653. <foreach collection="maps.orderCodes" item="orderCode" open="(" close=")" separator=",">
  654. #{orderCode}
  655. </foreach>
  656. </if>
  657. <if test="maps.orderCode != null and maps.orderCode !=''">
  658. and o.order_code like CONCAT('%',#{maps.orderCode},'%')
  659. </if>
  660. <if test="maps.isPayRemain != null">
  661. and o.is_pay_remain =#{maps.isPayRemain}
  662. </if>
  663. <if test="maps.userId != null">
  664. and o.user_id =#{maps.userId}
  665. </if>
  666. <if test="maps.deliveryId != null and maps.deliveryId !=''">
  667. and o.delivery_id =#{maps.deliveryId}
  668. </if>
  669. <if test="maps.nickname != null and maps.nickname !=''">
  670. and u.nickname like CONCAT('%',#{maps.nickname},'%')
  671. </if>
  672. <if test="maps.realName != null and maps.realName !=''">
  673. and o.user_name like CONCAT('%',#{maps.realName},'%')
  674. </if>
  675. <if test="maps.phone != null and maps.phone !=''">
  676. and u.phone like CONCAT('%',#{maps.phone},'%')
  677. </if>
  678. <if test="maps.userPhone != null and maps.userPhone !=''">
  679. and o.user_phone like CONCAT('%',#{maps.userPhone},'%')
  680. </if>
  681. <if test="maps.status != null and maps.status != 6">
  682. and o.status = #{maps.status}
  683. </if>
  684. <if test="maps.status == 6">
  685. and o.`status`= 1
  686. and (o.extend_order_id is null or o.extend_order_id like '')
  687. </if>
  688. <if test="maps.isUpload != null and maps.isUpload == 0 ">
  689. and o.certificates is null
  690. </if>
  691. <if test="maps.isUpload != null and maps.isUpload == 1 ">
  692. and o.certificates is not null
  693. </if>
  694. <if test="maps.deliveryStatus != null ">
  695. and o.delivery_status =#{maps.deliveryStatus}
  696. </if>
  697. <if test="maps.deliveryPayStatus != null ">
  698. and o.delivery_pay_status =#{maps.deliveryPayStatus}
  699. </if>
  700. <if test="maps.companyId != null ">
  701. and o.company_id =#{maps.companyId}
  702. </if>
  703. <if test="maps.isHealth != null and maps.isHealth != '' ">
  704. and o.company_id is null
  705. </if>
  706. <if test="maps.notHealth != null ">
  707. and o.company_id is not null
  708. </if>
  709. <if test="maps.companyUserId != null ">
  710. and o.company_user_id =#{maps.companyUserId}
  711. </if>
  712. <if test="maps.companyUserNickName != null and maps.companyUserNickName != '' ">
  713. and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
  714. </if>
  715. <if test="maps.productName != null and maps.productName != '' ">
  716. and fsp.product_name like concat('%', #{maps.productName}, '%')
  717. </if>
  718. <if test="maps.orderType != null ">
  719. and o.order_type =#{maps.orderType}
  720. </if>
  721. <if test="maps.payType != null ">
  722. and o.pay_type =#{maps.payType}
  723. </if>
  724. <if test="maps.scheduleId != null ">
  725. and o.schedule_id =#{maps.scheduleId}
  726. </if>
  727. <if test="maps.createTimeList != null ">
  728. AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d')
  729. AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d')
  730. </if>
  731. <if test="maps.deliverySendTimeList != null ">
  732. AND date_format(o.delivery_send_time,'%y%m%d') &gt;= date_format(#{maps.deliverySendTimeList[0]},'%y%m%d')
  733. AND date_format(o.delivery_send_time,'%y%m%d') &lt;= date_format(#{maps.deliverySendTimeList[1]},'%y%m%d')
  734. </if>
  735. <if test="maps.paidStatus != null ">
  736. and o.paid =#{maps.paidStatus}
  737. </if>
  738. <if test="maps.payTimeList != null ">
  739. AND date_format(o.pay_time,'%y%m%d') &gt;= date_format(#{maps.payTimeList[0]},'%y%m%d')
  740. AND date_format(o.pay_time,'%y%m%d') &lt;= date_format(#{maps.payTimeList[1]},'%y%m%d')
  741. </if>
  742. <if test="maps.deliveryImportTimeList != null ">
  743. AND date_format(o.delivery_import_time,'%y%m%d') &gt;= date_format(#{maps.deliveryImportTimeList[0]},'%y%m%d')
  744. AND date_format(o.delivery_import_time,'%y%m%d') &lt;= date_format(#{maps.deliveryImportTimeList[1]},'%y%m%d')
  745. </if>
  746. <if test="maps.deptId != null ">
  747. AND (o.dept_id = #{maps.deptId} OR o.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) ))
  748. </if>
  749. <if test="maps.erpPhoneNumber != null and maps.erpPhoneNumber != ''">
  750. and o.erp_phone like concat(#{maps.erpPhoneNumber},'%')
  751. </if>
  752. <if test="maps.erpAccount != null and maps.erpAccount != '未分拣' and maps.erpAccount != ''">
  753. and df.login_account like #{maps.erpAccount}
  754. </if>
  755. <if test="maps.erpAccount == '未分拣'">
  756. and ( df.login_account is null or df.login_account like '')
  757. </if>
  758. </where>
  759. ${maps.params.dataScope}
  760. </select>
  761. <select id="selectLiveOrderProductStatistics" resultType="java.lang.String">
  762. SELECT GROUP_CONCAT(
  763. CONCAT(product_name, ':', product_num)
  764. ORDER BY product_name
  765. SEPARATOR ' '
  766. ) AS product_num_list
  767. FROM (
  768. SELECT sp.product_name,SUM(IF(soi.num IS NULL,0,soi.num)) product_num
  769. FROM fs_store_product_scrm sp
  770. INNER JOIN live_order_item soi ON soi.product_id = sp.product_id
  771. INNER JOIN live_order o ON soi.order_id = o.order_id
  772. LEFT JOIN fs_user us ON us.user_id=o.user_id
  773. LEFT JOIN company_user cu on cu.user_id=o.company_user_id
  774. LEFT JOIN live_order_df df on df.order_id=o.order_id
  775. <if test="maps.coursePlaySourceConfigId != null">
  776. LEFT JOIN (
  777. SELECT
  778. sp.*,
  779. ROW_NUMBER() OVER (PARTITION BY sp.business_code ORDER BY sp.create_time DESC) as rn
  780. FROM live_order_payment sp
  781. WHERE sp.business_code IS NOT NULL
  782. ) sp_latest ON sp_latest.business_code = o.order_code AND sp_latest.rn = 1
  783. LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
  784. </if>
  785. <where>
  786. <if test="maps.coursePlaySourceConfigId != null">
  787. and csc.id = #{maps.coursePlaySourceConfigId}
  788. </if>
  789. <if test="maps.orderCodes != null and maps.orderCodes.size > 0">
  790. and o.order_code in
  791. <foreach collection="maps.orderCodes" item="orderCode" open="(" close=")" separator=",">
  792. #{orderCode}
  793. </foreach>
  794. </if>
  795. <if test="maps.orderCode != null and maps.orderCode !=''">
  796. and o.order_code like CONCAT('%',#{maps.orderCode},'%')
  797. </if>
  798. <if test="maps.isPayRemain != null">
  799. and o.is_pay_remain =#{maps.isPayRemain}
  800. </if>
  801. <if test="maps.userId != null">
  802. and o.user_id =#{maps.userId}
  803. </if>
  804. <if test="maps.deliveryId != null and maps.deliveryId !=''">
  805. and o.delivery_id =#{maps.deliveryId}
  806. </if>
  807. <if test="maps.nickname != null and maps.nickname !=''">
  808. and u.nickname like CONCAT('%',#{maps.nickname},'%')
  809. </if>
  810. <if test="maps.realName != null and maps.realName !=''">
  811. and o.user_name like CONCAT('%',#{maps.realName},'%')
  812. </if>
  813. <if test="maps.phone != null and maps.phone !=''">
  814. and u.phone like CONCAT('%',#{maps.phone},'%')
  815. </if>
  816. <if test="maps.userPhone != null and maps.userPhone !=''">
  817. and o.user_phone like CONCAT('%',#{maps.userPhone},'%')
  818. </if>
  819. <if test="maps.status != null and maps.status != 6">
  820. and o.status = #{maps.status}
  821. </if>
  822. <if test="maps.status == 6">
  823. and o.`status`= 1
  824. and (o.extend_order_id is null or o.extend_order_id like '')
  825. </if>
  826. <if test="maps.isUpload != null and maps.isUpload == 0 ">
  827. and o.certificates is null
  828. </if>
  829. <if test="maps.isUpload != null and maps.isUpload == 1 ">
  830. and o.certificates is not null
  831. </if>
  832. <if test="maps.deliveryStatus != null ">
  833. and o.delivery_status =#{maps.deliveryStatus}
  834. </if>
  835. <if test="maps.deliveryPayStatus != null ">
  836. and o.delivery_pay_status =#{maps.deliveryPayStatus}
  837. </if>
  838. <if test="maps.companyId != null ">
  839. and o.company_id =#{maps.companyId}
  840. </if>
  841. <if test="maps.isHealth != null and maps.isHealth != '' ">
  842. and o.company_id is null
  843. </if>
  844. <if test="maps.notHealth != null ">
  845. and o.company_id is not null
  846. </if>
  847. <if test="maps.companyUserId != null ">
  848. and o.company_user_id =#{maps.companyUserId}
  849. </if>
  850. <if test="maps.companyUserNickName != null and maps.companyUserNickName != '' ">
  851. and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
  852. </if>
  853. <if test="maps.productName != null and maps.productName != '' ">
  854. and fsp.product_name like concat('%', #{maps.productName}, '%')
  855. </if>
  856. <if test="maps.orderType != null ">
  857. and o.order_type =#{maps.orderType}
  858. </if>
  859. <if test="maps.payType != null ">
  860. and o.pay_type =#{maps.payType}
  861. </if>
  862. <if test="maps.scheduleId != null ">
  863. and o.schedule_id =#{maps.scheduleId}
  864. </if>
  865. <if test="maps.createTimeList != null ">
  866. AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d')
  867. AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d')
  868. </if>
  869. <if test="maps.deliverySendTimeList != null ">
  870. AND date_format(o.delivery_send_time,'%y%m%d') &gt;= date_format(#{maps.deliverySendTimeList[0]},'%y%m%d')
  871. AND date_format(o.delivery_send_time,'%y%m%d') &lt;= date_format(#{maps.deliverySendTimeList[1]},'%y%m%d')
  872. </if>
  873. <if test="maps.paidStatus != null ">
  874. and o.paid =#{maps.paidStatus}
  875. </if>
  876. <if test="maps.payTimeList != null ">
  877. AND date_format(o.pay_time,'%y%m%d') &gt;= date_format(#{maps.payTimeList[0]},'%y%m%d')
  878. AND date_format(o.pay_time,'%y%m%d') &lt;= date_format(#{maps.payTimeList[1]},'%y%m%d')
  879. </if>
  880. <if test="maps.deliveryImportTimeList != null ">
  881. AND date_format(o.delivery_import_time,'%y%m%d') &gt;= date_format(#{maps.deliveryImportTimeList[0]},'%y%m%d')
  882. AND date_format(o.delivery_import_time,'%y%m%d') &lt;= date_format(#{maps.deliveryImportTimeList[1]},'%y%m%d')
  883. </if>
  884. <if test="maps.deptId != null ">
  885. AND (o.dept_id = #{maps.deptId} OR o.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) ))
  886. </if>
  887. <if test="maps.erpPhoneNumber != null and maps.erpPhoneNumber != ''">
  888. and o.erp_phone like concat(#{maps.erpPhoneNumber},'%')
  889. </if>
  890. <if test="maps.erpAccount != null and maps.erpAccount != '未分拣' and maps.erpAccount != ''">
  891. and df.login_account like #{maps.erpAccount}
  892. </if>
  893. <if test="maps.erpAccount == '未分拣'">
  894. and ( df.login_account is null or df.login_account like '')
  895. </if>
  896. </where>
  897. ${maps.params.dataScope} GROUP BY sp.product_id
  898. ) AS t
  899. </select>
  900. <!-- 查询订单列表Zm -->
  901. <select id="selectLiveOrderListZm" parameterType="LiveOrder" resultType="com.fs.live.vo.LiveOrderVoZm">
  902. SELECT
  903. o.order_id,
  904. o.live_id,
  905. o.store_id,
  906. o.order_code,
  907. o.user_id,
  908. o.user_name,
  909. o.user_phone,
  910. o.user_address,
  911. o.cart_id,
  912. o.total_num,
  913. o.total_price,
  914. o.pay_price,
  915. o.pay_money,
  916. o.is_pay,
  917. o.pay_time,
  918. o.pay_type,
  919. o.create_time,
  920. o.update_time,
  921. o.status,
  922. o.refund_status,
  923. o.refund_img,
  924. o.refund_explain,
  925. o.refund_time,
  926. o.refund_reason,
  927. o.refund_money,
  928. o.delivery_code,
  929. o.delivery_name,
  930. o.delivery_sn,
  931. o.remark,
  932. o.is_del,
  933. o.cost_price,
  934. o.company_id,
  935. o.company_user_id,
  936. o.product_id,
  937. o.customer_id,
  938. o.coupon_price,
  939. o.cancel_reason,
  940. <!-- 销售信息 -->
  941. cu.nick_name AS companyUserNickName,
  942. cu.phonenumber AS companyUserPhone,
  943. cu.create_time AS companyUserCreateTime,
  944. <!-- 客户信息 -->
  945. u.user_code AS userCode,
  946. u.level AS userLevel,
  947. u.nick_name AS nickName,
  948. u.phone AS userBindPhone,
  949. u.order_count AS totalOrderCount,
  950. u.total_amount AS totalOrderAmount,
  951. u.status AS userStatus,
  952. u.update_time AS latestBindTime,
  953. <!-- 商品信息 -->
  954. p.product_name AS productName,
  955. p.cost AS costPrice,
  956. p.price AS price,
  957. p.cost AS cost,
  958. p.prescribe_spec AS productSpec,
  959. p.prescribe_factory AS supplierName,
  960. <!-- 门店信息 -->
  961. s.store_name AS storeName,
  962. s.store_id AS storeId
  963. FROM
  964. live_order o
  965. LEFT JOIN fs_user u ON o.user_id = u.user_id
  966. LEFT JOIN company_user cu ON o.company_user_id = cu.user_id
  967. LEFT JOIN fs_store_product_scrm p ON o.product_id = p.product_id
  968. LEFT JOIN fs_store_scrm s ON p.store_id = s.store_id
  969. <where>
  970. o.is_del = 0
  971. <if test="orderId != null">
  972. AND o.order_id = #{orderId}
  973. </if>
  974. <if test="liveId != null">
  975. AND o.live_id = #{liveId}
  976. </if>
  977. <if test="storeId != null">
  978. AND o.store_id = #{storeId}
  979. </if>
  980. <if test="orderCode != null and orderCode != ''">
  981. AND o.order_code LIKE CONCAT('%', #{orderCode}, '%')
  982. </if>
  983. <if test="userId != null and userId != ''">
  984. AND o.user_id = #{userId}
  985. </if>
  986. <if test="status != null">
  987. AND o.status = #{status}
  988. </if>
  989. <if test="companyId != null">
  990. AND o.company_id = #{companyId}
  991. </if>
  992. <if test="totalNum != null">
  993. AND o.total_num = #{totalNum}
  994. </if>
  995. <if test="price != null">
  996. AND p.price = #{price}
  997. </if>
  998. <if test="cost != null">
  999. AND p.cost = #{cost}
  1000. </if>
  1001. <if test="companyUserId != null">
  1002. AND o.company_user_id = #{companyUserId}
  1003. </if>
  1004. <if test="productId != null">
  1005. AND o.product_id = #{productId}
  1006. </if>
  1007. <!-- 新增筛选条件 -->
  1008. <if test="productName != null and productName != ''">
  1009. AND p.product_name LIKE CONCAT('%', #{productName}, '%')
  1010. </if>
  1011. <if test="productSpec != null and productSpec != ''">
  1012. AND p.prescribe_spec LIKE CONCAT('%', #{productSpec}, '%')
  1013. </if>
  1014. <if test="storeId != null and storeId != ''">
  1015. AND p.store_id #{storeId}
  1016. </if>
  1017. <if test="userAddress != null and userAddress != ''">
  1018. AND o.user_address LIKE CONCAT('%', #{userAddress}, '%')
  1019. </if>
  1020. <if test="createTimeStart != null and createTimeStart != ''">
  1021. AND o.create_time &gt;= #{createTimeStart}
  1022. </if>
  1023. <if test="createTimeEnd != null and createTimeEnd != ''">
  1024. AND o.create_time &lt;= #{createTimeEnd}
  1025. </if>
  1026. <if test="payStartTime != null and payStartTime != ''">
  1027. AND o.pay_time &gt;= #{payStartTime}
  1028. </if>
  1029. <if test="payEndTime != null and payEndTime != ''">
  1030. AND o.pay_time &lt;= #{payEndTime}
  1031. </if>
  1032. </where>
  1033. ORDER BY o.create_time DESC
  1034. </select>
  1035. </mapper>