LiveOrderMapper.xml 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424
  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="userName != null">user_name,</if>
  213. <if test="userPhone != null">user_phone,</if>
  214. <if test="userAddress != null">user_address,</if>
  215. <if test="cartId != null">cart_id,</if>
  216. <if test="totalNum != null and totalNum != ''">total_num,</if>
  217. <if test="totalPrice != null">total_price,</if>
  218. <if test="payPrice != null">pay_price,</if>
  219. <if test="payMoney != null">pay_money,</if>
  220. <if test="isPay != null">is_pay,</if>
  221. <if test="payTime != null">pay_time,</if>
  222. <if test="payType != null">pay_type,</if>
  223. <if test="createTime != null">create_time,</if>
  224. <if test="updateTime != null">update_time,</if>
  225. <if test="status != null">status,</if>
  226. <if test="refundStatus != null">refund_status,</if>
  227. <if test="refundImg != null">refund_img,</if>
  228. <if test="refundExplain != null">refund_explain,</if>
  229. <if test="refundTime != null">refund_time,</if>
  230. <if test="refundReason != null">refund_reason,</if>
  231. <if test="refundMoney != null">refund_money,</if>
  232. <if test="deliveryCode != null">delivery_code,</if>
  233. <if test="deliveryName != null">delivery_name,</if>
  234. <if test="deliverySn != null">delivery_sn,</if>
  235. <if test="remark != null">remark,</if>
  236. <if test="isDel != null">is_del,</if>
  237. <if test="costPrice != null">cost_price,</if>
  238. <if test="verifyCode != null">verify_code,</if>
  239. <if test="shippingType != null">shipping_type,</if>
  240. <if test="isChannel != null">is_channel,</if>
  241. <if test="finishTime != null">finish_time,</if>
  242. <if test="deliveryTime != null">delivery_time,</if>
  243. <if test="tuiMoney != null">tui_money,</if>
  244. <if test="tuiMoneyStatus != null">tui_money_status,</if>
  245. <if test="tuiUserId != null">tui_user_id,</if>
  246. <if test="itemJson != null">item_json,</if>
  247. <if test="discountMoney != null">discount_money,</if>
  248. <if test="userCouponId != null">user_coupon_id,</if>
  249. <if test="companyId != null">company_id,</if>
  250. <if test="companyUserId != null">company_user_id,</if>
  251. <if test="storeHouseCode != null">store_house_code,</if>
  252. <if test="extendOrderId != null">extend_order_id,</if>
  253. <if test="payDelivery != null">pay_delivery,</if>
  254. <if test="payRemain != null">pay_remain,</if>
  255. <if test="deliveryStatus != null">delivery_status,</if>
  256. <if test="deliveryPayStatus != null">delivery_pay_status,</if>
  257. <if test="deliveryPayTime != null">delivery_pay_time,</if>
  258. <if test="deliveryType != null">delivery_type,</if>
  259. <if test="deliveryPayMoney != null">delivery_pay_money,</if>
  260. <if test="deliveryImportTime != null">delivery_import_time,</if>
  261. <if test="deliverySendTime != null">delivery_send_time,</if>
  262. <if test="isAfterSales != null">is_after_sales,</if>
  263. <if test="deptId != null">dept_id,</if>
  264. <if test="channel != null">channel,</if>
  265. <if test="source != null">source,</if>
  266. <if test="billPrice != null">bill_price,</if>
  267. <if test="totalPostage != null">total_postage,</if>
  268. <if test="payPostage != null">pay_postage,</if>
  269. <if test="gainIntegral != null">gain_integral,</if>
  270. <if test="useIntegral != null">use_integral,</if>
  271. <if test="payIntegral != null">pay_integral,</if>
  272. <if test="backIntegral != null">back_integral,</if>
  273. <if test="isEditMoney != null">is_edit_money,</if>
  274. <if test="productId != null">product_id,</if>
  275. <if test="customerId != null">customer_id,</if>
  276. <if test="couponPrice != null">coupon_price,</if>
  277. </trim>
  278. <trim prefix="values (" suffix=")" suffixOverrides=",">
  279. <if test="liveId != null">#{liveId},</if>
  280. <if test="storeId != null">#{storeId},</if>
  281. <if test="orderCode != null and orderCode != ''">#{orderCode},</if>
  282. <if test="userId != null and userId != ''">#{userId},</if>
  283. <if test="realName != null">#{realName},</if>
  284. <if test="userName != null">#{userName},</if>
  285. <if test="userPhone != null">#{userPhone},</if>
  286. <if test="userAddress != null">#{userAddress},</if>
  287. <if test="cartId != null">#{cartId},</if>
  288. <if test="totalNum != null and totalNum != ''">#{totalNum},</if>
  289. <if test="totalPrice != null">#{totalPrice},</if>
  290. <if test="payPrice != null">#{payPrice},</if>
  291. <if test="payMoney != null">#{payMoney},</if>
  292. <if test="isPay != null">#{isPay},</if>
  293. <if test="payTime != null">#{payTime},</if>
  294. <if test="payType != null">#{payType},</if>
  295. <if test="createTime != null">#{createTime},</if>
  296. <if test="updateTime != null">#{updateTime},</if>
  297. <if test="status != null">#{status},</if>
  298. <if test="refundStatus != null">#{refundStatus},</if>
  299. <if test="refundImg != null">#{refundImg},</if>
  300. <if test="refundExplain != null">#{refundExplain},</if>
  301. <if test="refundTime != null">#{refundTime},</if>
  302. <if test="refundReason != null">#{refundReason},</if>
  303. <if test="refundMoney != null">#{refundMoney},</if>
  304. <if test="deliveryCode != null">#{deliveryCode},</if>
  305. <if test="deliveryName != null">#{deliveryName},</if>
  306. <if test="deliverySn != null">#{deliverySn},</if>
  307. <if test="remark != null">#{remark},</if>
  308. <if test="isDel != null">#{isDel},</if>
  309. <if test="costPrice != null">#{costPrice},</if>
  310. <if test="verifyCode != null">#{verifyCode},</if>
  311. <if test="shippingType != null">#{shippingType},</if>
  312. <if test="isChannel != null">#{isChannel},</if>
  313. <if test="finishTime != null">#{finishTime},</if>
  314. <if test="deliveryTime != null">#{deliveryTime},</if>
  315. <if test="tuiMoney != null">#{tuiMoney},</if>
  316. <if test="tuiMoneyStatus != null">#{tuiMoneyStatus},</if>
  317. <if test="tuiUserId != null">#{tuiUserId},</if>
  318. <if test="itemJson != null">#{itemJson},</if>
  319. <if test="discountMoney != null">#{discountMoney},</if>
  320. <if test="userCouponId != null">#{userCouponId},</if>
  321. <if test="companyId != null">#{companyId},</if>
  322. <if test="companyUserId != null">#{companyUserId},</if>
  323. <if test="storeHouseCode != null">#{storeHouseCode},</if>
  324. <if test="extendOrderId != null">#{extendOrderId},</if>
  325. <if test="payDelivery != null">#{payDelivery},</if>
  326. <if test="payRemain != null">#{payRemain},</if>
  327. <if test="deliveryStatus != null">#{deliveryStatus},</if>
  328. <if test="deliveryPayStatus != null">#{deliveryPayStatus},</if>
  329. <if test="deliveryPayTime != null">#{deliveryPayTime},</if>
  330. <if test="deliveryType != null">#{deliveryType},</if>
  331. <if test="deliveryPayMoney != null">#{deliveryPayMoney},</if>
  332. <if test="deliveryImportTime != null">#{deliveryImportTime},</if>
  333. <if test="deliverySendTime != null">#{deliverySendTime},</if>
  334. <if test="isAfterSales != null">#{isAfterSales},</if>
  335. <if test="deptId != null">#{deptId},</if>
  336. <if test="channel != null">#{channel},</if>
  337. <if test="source != null">#{source},</if>
  338. <if test="billPrice != null">#{billPrice},</if>
  339. <if test="totalPostage != null">#{totalPostage},</if>
  340. <if test="payPostage != null">#{payPostage},</if>
  341. <if test="gainIntegral != null">#{gainIntegral},</if>
  342. <if test="useIntegral != null">#{useIntegral},</if>
  343. <if test="payIntegral != null">#{payIntegral},</if>
  344. <if test="backIntegral != null">#{backIntegral},</if>
  345. <if test="isEditMoney != null">#{isEditMoney},</if>
  346. <if test="productId != null">#{productId},</if>
  347. <if test="customerId != null">#{customerId},</if>
  348. <if test="couponPrice != null">#{couponPrice},</if>
  349. </trim>
  350. </insert>
  351. <update id="updateLiveOrder" parameterType="LiveOrder">
  352. update live_order
  353. <trim prefix="SET" suffixOverrides=",">
  354. <if test="liveId != null">live_id = #{liveId},</if>
  355. <if test="storeId != null">store_id = #{storeId},</if>
  356. <if test="orderCode != null and orderCode != ''">order_code = #{orderCode},</if>
  357. <if test="userId != null and userId != ''">user_id = #{userId},</if>
  358. <if test="realName != null">real_name = #{realName},</if>
  359. <if test="userName != null">user_name = #{userName},</if>
  360. <if test="userPhone != null">user_phone = #{userPhone},</if>
  361. <if test="userAddress != null">user_address = #{userAddress},</if>
  362. <if test="cartId != null">cart_id = #{cartId},</if>
  363. <if test="totalNum != null and totalNum != ''">total_num = #{totalNum},</if>
  364. <if test="totalPrice != null">total_price = #{totalPrice},</if>
  365. <if test="payPrice != null">pay_price = #{payPrice},</if>
  366. <if test="payMoney != null">pay_money = #{payMoney},</if>
  367. <if test="isPay != null">is_pay = #{isPay},</if>
  368. <if test="payTime != null">pay_time = #{payTime},</if>
  369. <if test="payType != null">pay_type = #{payType},</if>
  370. <if test="createTime != null">create_time = #{createTime},</if>
  371. <if test="updateTime != null">update_time = #{updateTime},</if>
  372. <if test="status != null">status = #{status},</if>
  373. <if test="refundStatus != null">refund_status = #{refundStatus},</if>
  374. <if test="refundImg != null">refund_img = #{refundImg},</if>
  375. <if test="refundExplain != null">refund_explain = #{refundExplain},</if>
  376. <if test="refundTime != null">refund_time = #{refundTime},</if>
  377. <if test="refundReason != null">refund_reason = #{refundReason},</if>
  378. <if test="refundMoney != null">refund_money = #{refundMoney},</if>
  379. <if test="deliveryCode != null">delivery_code = #{deliveryCode},</if>
  380. <if test="deliveryName != null">delivery_name = #{deliveryName},</if>
  381. <if test="deliverySn != null">delivery_sn = #{deliverySn},</if>
  382. <if test="remark != null">remark = #{remark},</if>
  383. <if test="isDel != null">is_del = #{isDel},</if>
  384. <if test="costPrice != null">cost_price = #{costPrice},</if>
  385. <if test="verifyCode != null">verify_code = #{verifyCode},</if>
  386. <if test="shippingType != null">shipping_type = #{shippingType},</if>
  387. <if test="isChannel != null">is_channel = #{isChannel},</if>
  388. <if test="finishTime != null">finish_time = #{finishTime},</if>
  389. <if test="deliveryTime != null">delivery_time = #{deliveryTime},</if>
  390. <if test="tuiMoney != null">tui_money = #{tuiMoney},</if>
  391. <if test="tuiMoneyStatus != null">tui_money_status = #{tuiMoneyStatus},</if>
  392. <if test="tuiUserId != null">tui_user_id = #{tuiUserId},</if>
  393. <if test="itemJson != null">item_json = #{itemJson},</if>
  394. <if test="discountMoney != null">discount_money = #{discountMoney},</if>
  395. <if test="userCouponId != null">user_coupon_id = #{userCouponId},</if>
  396. <if test="companyId != null">company_id = #{companyId},</if>
  397. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  398. <if test="storeHouseCode != null">store_house_code = #{storeHouseCode},</if>
  399. <if test="extendOrderId != null">extend_order_id = #{extendOrderId},</if>
  400. <if test="payDelivery != null">pay_delivery = #{payDelivery},</if>
  401. <if test="payRemain != null">pay_remain = #{payRemain},</if>
  402. <if test="deliveryStatus != null">delivery_status = #{deliveryStatus},</if>
  403. <if test="deliveryPayStatus != null">delivery_pay_status = #{deliveryPayStatus},</if>
  404. <if test="deliveryPayTime != null">delivery_pay_time = #{deliveryPayTime},</if>
  405. <if test="deliveryType != null">delivery_type = #{deliveryType},</if>
  406. <if test="deliveryPayMoney != null">delivery_pay_money = #{deliveryPayMoney},</if>
  407. <if test="deliveryImportTime != null">delivery_import_time = #{deliveryImportTime},</if>
  408. <if test="deliverySendTime != null">delivery_send_time = #{deliverySendTime},</if>
  409. <if test="isAfterSales != null">is_after_sales = #{isAfterSales},</if>
  410. <if test="deptId != null">dept_id = #{deptId},</if>
  411. <if test="channel != null">channel = #{channel},</if>
  412. <if test="source != null">source = #{source},</if>
  413. <if test="billPrice != null">bill_price = #{billPrice},</if>
  414. <if test="totalPostage != null">total_postage = #{totalPostage},</if>
  415. <if test="payPostage != null">pay_postage = #{payPostage},</if>
  416. <if test="gainIntegral != null">gain_integral = #{gainIntegral},</if>
  417. <if test="useIntegral != null">use_integral = #{useIntegral},</if>
  418. <if test="payIntegral != null">pay_integral = #{payIntegral},</if>
  419. <if test="backIntegral != null">back_integral = #{backIntegral},</if>
  420. <if test="isEditMoney != null">is_edit_money = #{isEditMoney},</if>
  421. <if test="customerId != null">customer_id = #{customerId},</if>
  422. <if test="couponPrice != null">coupon_price = #{couponPrice},</if>
  423. </trim>
  424. where order_id = #{orderId}
  425. </update>
  426. <delete id="deleteLiveOrderByOrderId" parameterType="String">
  427. delete from live_order where order_id = #{orderId}
  428. </delete>
  429. <delete id="deleteLiveOrderByOrderIds" parameterType="String">
  430. delete from live_order where order_id in
  431. <foreach item="orderId" collection="array" open="(" separator="," close=")">
  432. #{orderId}
  433. </foreach>
  434. </delete>
  435. <select id="getLiveOrderTimeGranularity" parameterType="com.fs.live.vo.LiveOrderTimeVo" resultMap="LiveOrderResult">
  436. <include refid="selectLiveOrderVo"/>
  437. where 1=1
  438. <if test="timeOptions != 'all'">and a.create_time >= #{createTime}</if>
  439. <if test="liveId != null">and a.live_id = #{liveId}</if>
  440. order by a.create_time desc
  441. </select>
  442. <select id="selectFsOutDateOrder" resultType="com.fs.live.domain.LiveOrder">
  443. <![CDATA[
  444. SELECT *
  445. FROM live_order
  446. WHERE status = 1
  447. AND create_time < DATE_SUB(NOW(), INTERVAL 1800 MINUTE)
  448. ]]>
  449. </select>
  450. <update id="batchUpdateErpByOrderIds">
  451. UPDATE live_order
  452. SET erp_phone =
  453. <trim prefix="CASE order_id" suffix="END">
  454. <foreach collection="maps" item="map">
  455. WHEN #{map.orderId} THEN #{map.erpPhone}
  456. </foreach>
  457. </trim>
  458. WHERE order_id IN
  459. <foreach collection="maps" item="map" open="(" separator="," close=")">
  460. #{map.orderId}
  461. </foreach>
  462. </update>
  463. <select id="selectLiveOrderInId" resultType="com.fs.live.domain.LiveOrder">
  464. <include refid="selectLiveOrderVo"/>
  465. where order_id IN <foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
  466. #{item}
  467. </foreach>
  468. </select>
  469. <select id="selectLiveOrderListVO" resultType="com.fs.live.vo.LiveOrderVO">
  470. 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
  471. , csc.name miniProgramName, sp_latest.bank_transaction_id as bankTransactionId
  472. from live_order o
  473. left join fs_user u on o.user_id=u.user_id
  474. left join company c on c.company_id=o.company_id
  475. left join company_user cu on cu.user_id=o.company_user_id
  476. <if test="maps.erpAccount != null and maps.erpAccount != ''">
  477. LEFT JOIN live_order_df df on df.order_id=o.order_id
  478. </if>
  479. <if test = "maps.productName != null and maps.productName != '' ">
  480. left join live_order_item oi on o.order_id = oi.order_id
  481. left join fs_store_product_scrm fsp on fsp.product_id = oi.product_id
  482. </if>
  483. LEFT JOIN (
  484. SELECT
  485. sp.*,
  486. ROW_NUMBER() OVER (PARTITION BY sp.business_code ORDER BY sp.create_time DESC) as rn
  487. FROM live_order_payment sp
  488. WHERE sp.business_code IS NOT NULL
  489. ) sp_latest ON sp_latest.business_code = o.order_code AND sp_latest.rn = 1
  490. LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
  491. <where>
  492. <if test="maps.coursePlaySourceConfigId != null">
  493. and csc.id = #{maps.coursePlaySourceConfigId}
  494. </if>
  495. <if test="maps.orderCodes != null and maps.orderCodes.size > 0">
  496. and o.order_code in
  497. <foreach collection="maps.orderCodes" item="orderCode" open="(" close=")" separator=",">
  498. #{orderCode}
  499. </foreach>
  500. </if>
  501. <if test="maps.orderCode != null and maps.orderCode !=''">
  502. and o.order_code like CONCAT('%',#{maps.orderCode},'%')
  503. </if>
  504. <if test="maps.bankTransactionId != null and maps.bankTransactionId !=''">
  505. and sp_latest.bank_transaction_id like CONCAT('%',#{maps.bankTransactionId},'%')
  506. </if>
  507. <if test="maps.isPayRemain != null">
  508. and o.is_pay_remain =#{maps.isPayRemain}
  509. </if>
  510. <if test="maps.userId != null">
  511. and o.user_id =#{maps.userId}
  512. </if>
  513. <if test="maps.deliveryId != null and maps.deliveryId !=''">
  514. and o.delivery_id =#{maps.deliveryId}
  515. </if>
  516. <if test="maps.nickname != null and maps.nickname !=''">
  517. and u.nickname like CONCAT('%',#{maps.nickname},'%')
  518. </if>
  519. <if test="maps.realName != null and maps.realName !=''">
  520. and o.user_name like CONCAT('%',#{maps.realName},'%')
  521. </if>
  522. <if test="maps.userName != null and maps.userName !=''">
  523. and o.user_name like CONCAT('%',#{maps.userName},'%')
  524. </if>
  525. <if test="maps.phone != null and maps.phone !=''">
  526. and u.phone like CONCAT('%',#{maps.phone},'%')
  527. </if>
  528. <if test="maps.userPhone != null and maps.userPhone !=''">
  529. and o.user_phone like CONCAT('%',#{maps.userPhone},'%')
  530. </if>
  531. <if test="maps.status != null and maps.status != 6">
  532. and o.status = #{maps.status}
  533. </if>
  534. <if test="maps.status == 6">
  535. and o.`status`= 1
  536. and (o.extend_order_id is null or o.extend_order_id like '')
  537. </if>
  538. <if test="maps.isUpload != null and maps.isUpload == 0 ">
  539. and o.certificates is null
  540. </if>
  541. <if test="maps.isUpload != null and maps.isUpload == 1 ">
  542. and o.certificates is not null
  543. </if>
  544. <if test="maps.deliveryStatus != null ">
  545. and o.delivery_status =#{maps.deliveryStatus}
  546. </if>
  547. <if test="maps.deliveryPayStatus != null ">
  548. and o.delivery_pay_status =#{maps.deliveryPayStatus}
  549. </if>
  550. <if test="maps.companyId != null ">
  551. and o.company_id =#{maps.companyId}
  552. </if>
  553. <if test="maps.isHealth != null and maps.isHealth != '' ">
  554. and o.company_id is null
  555. </if>
  556. <if test="maps.notHealth != null ">
  557. and o.company_id is not null
  558. </if>
  559. <if test="maps.companyUserId != null ">
  560. and o.company_user_id =#{maps.companyUserId}
  561. </if>
  562. <if test="maps.companyUserNickName != null and maps.companyUserNickName != '' ">
  563. and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
  564. </if>
  565. <if test="maps.productName != null and maps.productName != '' ">
  566. and fsp.product_name like concat('%', #{maps.productName}, '%')
  567. </if>
  568. <if test="maps.orderType != null ">
  569. and o.order_type =#{maps.orderType}
  570. </if>
  571. <if test="maps.payType != null ">
  572. and o.pay_type =#{maps.payType}
  573. </if>
  574. <if test="maps.scheduleId != null ">
  575. and o.schedule_id =#{maps.scheduleId}
  576. </if>
  577. <if test="maps.createTimeList != null ">
  578. AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d')
  579. AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d')
  580. </if>
  581. <if test="maps.deliverySendTimeList != null ">
  582. AND date_format(o.delivery_send_time,'%y%m%d') &gt;= date_format(#{maps.deliverySendTimeList[0]},'%y%m%d')
  583. AND date_format(o.delivery_send_time,'%y%m%d') &lt;= date_format(#{maps.deliverySendTimeList[1]},'%y%m%d')
  584. </if>
  585. <if test="maps.paidStatus != null ">
  586. and o.paid =#{maps.paidStatus}
  587. </if>
  588. <if test="maps.payTimeList != null ">
  589. AND date_format(o.pay_time,'%y%m%d') &gt;= date_format(#{maps.payTimeList[0]},'%y%m%d')
  590. AND date_format(o.pay_time,'%y%m%d') &lt;= date_format(#{maps.payTimeList[1]},'%y%m%d')
  591. </if>
  592. <if test="maps.deliveryImportTimeList != null ">
  593. AND date_format(o.delivery_import_time,'%y%m%d') &gt;= date_format(#{maps.deliveryImportTimeList[0]},'%y%m%d')
  594. AND date_format(o.delivery_import_time,'%y%m%d') &lt;= date_format(#{maps.deliveryImportTimeList[1]},'%y%m%d')
  595. </if>
  596. <if test="maps.deptId != null ">
  597. 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) ))
  598. </if>
  599. <if test="maps.erpPhoneNumber != null and maps.erpPhoneNumber != ''">
  600. and o.erp_phone like concat(#{maps.erpPhoneNumber},'%')
  601. </if>
  602. <if test="maps.erpAccount != null and maps.erpAccount != '未分拣' and maps.erpAccount != ''">
  603. and df.login_account like #{maps.erpAccount}
  604. </if>
  605. <if test="maps.erpAccount == '未分拣'">
  606. and ( df.login_account is null or df.login_account like '')
  607. </if>
  608. </where>
  609. ${maps.params.dataScope}
  610. <if test="maps.productName != null and maps.productName != '' ">
  611. group by o.order_id
  612. </if>
  613. order by
  614. <if test="maps.sortField == 'companyUserName'">
  615. cu.nick_name
  616. </if>
  617. <if test="maps.sortField == 'packageName'">
  618. o.package_name
  619. </if>
  620. <if test="maps.sortField == 'payPrice'">
  621. o.pay_price
  622. </if>
  623. <if test="maps.sortField == 'payMoney'">
  624. o.pay_money
  625. </if>
  626. <if test="maps.sortOrder != null and maps.sortOrder != ''">
  627. ${maps.sortOrder}
  628. </if>
  629. <if test="maps.sortField == null or maps.sortField == ''">
  630. o.order_id desc
  631. </if>
  632. </select>
  633. <select id="selectLiveOrderStatistics" resultType="java.util.Map">
  634. select sum(o.pay_price) pay_price,sum(o.pay_money) pay_money,sum(o.pay_delivery) pay_remain
  635. FROM live_order o
  636. left join fs_user u on o.user_id=u.user_id
  637. left join company c on c.company_id=o.company_id
  638. left join company_user cu on cu.user_id=o.company_user_id
  639. <if test="maps.erpAccount != null or maps.erpAccount != ''">
  640. LEFT JOIN live_order_df df on df.order_id=o.order_id
  641. </if>
  642. <if test = "maps.productName != null and maps.productName != '' ">
  643. left join live_order_item oi on o.order_id = oi.order_id
  644. left join fs_store_product_scrm fsp on fsp.product_id = oi.product_id
  645. </if>
  646. <if test="maps.coursePlaySourceConfigId != null">
  647. LEFT JOIN (
  648. SELECT
  649. sp.*,
  650. ROW_NUMBER() OVER (PARTITION BY sp.business_code ORDER BY sp.create_time DESC) as rn
  651. FROM live_order_payment sp
  652. WHERE sp.business_code IS NOT NULL
  653. ) sp_latest ON sp_latest.business_code = o.order_code AND sp_latest.rn = 1
  654. LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
  655. </if>
  656. <where>
  657. <if test="maps.coursePlaySourceConfigId != null">
  658. and csc.id = #{maps.coursePlaySourceConfigId}
  659. </if>
  660. <if test="maps.orderCodes != null and maps.orderCodes.size > 0">
  661. and o.order_code in
  662. <foreach collection="maps.orderCodes" item="orderCode" open="(" close=")" separator=",">
  663. #{orderCode}
  664. </foreach>
  665. </if>
  666. <if test="maps.orderCode != null and maps.orderCode !=''">
  667. and o.order_code like CONCAT('%',#{maps.orderCode},'%')
  668. </if>
  669. <if test="maps.isPayRemain != null">
  670. and o.is_pay_remain =#{maps.isPayRemain}
  671. </if>
  672. <if test="maps.userId != null">
  673. and o.user_id =#{maps.userId}
  674. </if>
  675. <if test="maps.deliveryId != null and maps.deliveryId !=''">
  676. and o.delivery_id =#{maps.deliveryId}
  677. </if>
  678. <if test="maps.nickname != null and maps.nickname !=''">
  679. and u.nickname like CONCAT('%',#{maps.nickname},'%')
  680. </if>
  681. <if test="maps.realName != null and maps.realName !=''">
  682. and o.user_name like CONCAT('%',#{maps.realName},'%')
  683. </if>
  684. <if test="maps.userName != null and maps.userName !=''">
  685. and o.user_name like CONCAT('%',#{maps.userName},'%')
  686. </if>
  687. <if test="maps.phone != null and maps.phone !=''">
  688. and u.phone like CONCAT('%',#{maps.phone},'%')
  689. </if>
  690. <if test="maps.userPhone != null and maps.userPhone !=''">
  691. and o.user_phone like CONCAT('%',#{maps.userPhone},'%')
  692. </if>
  693. <if test="maps.status != null and maps.status != 6">
  694. and o.status = #{maps.status}
  695. </if>
  696. <if test="maps.status == 6">
  697. and o.`status`= 1
  698. and (o.extend_order_id is null or o.extend_order_id like '')
  699. </if>
  700. <if test="maps.isUpload != null and maps.isUpload == 0 ">
  701. and o.certificates is null
  702. </if>
  703. <if test="maps.isUpload != null and maps.isUpload == 1 ">
  704. and o.certificates is not null
  705. </if>
  706. <if test="maps.deliveryStatus != null ">
  707. and o.delivery_status =#{maps.deliveryStatus}
  708. </if>
  709. <if test="maps.deliveryPayStatus != null ">
  710. and o.delivery_pay_status =#{maps.deliveryPayStatus}
  711. </if>
  712. <if test="maps.companyId != null ">
  713. and o.company_id =#{maps.companyId}
  714. </if>
  715. <if test="maps.isHealth != null and maps.isHealth != '' ">
  716. and o.company_id is null
  717. </if>
  718. <if test="maps.notHealth != null ">
  719. and o.company_id is not null
  720. </if>
  721. <if test="maps.companyUserId != null ">
  722. and o.company_user_id =#{maps.companyUserId}
  723. </if>
  724. <if test="maps.companyUserNickName != null and maps.companyUserNickName != '' ">
  725. and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
  726. </if>
  727. <if test="maps.productName != null and maps.productName != '' ">
  728. and fsp.product_name like concat('%', #{maps.productName}, '%')
  729. </if>
  730. <if test="maps.orderType != null ">
  731. and o.order_type =#{maps.orderType}
  732. </if>
  733. <if test="maps.payType != null ">
  734. and o.pay_type =#{maps.payType}
  735. </if>
  736. <if test="maps.scheduleId != null ">
  737. and o.schedule_id =#{maps.scheduleId}
  738. </if>
  739. <if test="maps.createTimeList != null ">
  740. AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d')
  741. AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d')
  742. </if>
  743. <if test="maps.deliverySendTimeList != null ">
  744. AND date_format(o.delivery_send_time,'%y%m%d') &gt;= date_format(#{maps.deliverySendTimeList[0]},'%y%m%d')
  745. AND date_format(o.delivery_send_time,'%y%m%d') &lt;= date_format(#{maps.deliverySendTimeList[1]},'%y%m%d')
  746. </if>
  747. <if test="maps.paidStatus != null ">
  748. and o.paid =#{maps.paidStatus}
  749. </if>
  750. <if test="maps.payTimeList != null ">
  751. AND date_format(o.pay_time,'%y%m%d') &gt;= date_format(#{maps.payTimeList[0]},'%y%m%d')
  752. AND date_format(o.pay_time,'%y%m%d') &lt;= date_format(#{maps.payTimeList[1]},'%y%m%d')
  753. </if>
  754. <if test="maps.deliveryImportTimeList != null ">
  755. AND date_format(o.delivery_import_time,'%y%m%d') &gt;= date_format(#{maps.deliveryImportTimeList[0]},'%y%m%d')
  756. AND date_format(o.delivery_import_time,'%y%m%d') &lt;= date_format(#{maps.deliveryImportTimeList[1]},'%y%m%d')
  757. </if>
  758. <if test="maps.deptId != null ">
  759. 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) ))
  760. </if>
  761. <if test="maps.erpPhoneNumber != null and maps.erpPhoneNumber != ''">
  762. and o.erp_phone like concat(#{maps.erpPhoneNumber},'%')
  763. </if>
  764. <if test="maps.erpAccount != null and maps.erpAccount != '未分拣' and maps.erpAccount != ''">
  765. and df.login_account like #{maps.erpAccount}
  766. </if>
  767. <if test="maps.erpAccount == '未分拣'">
  768. and ( df.login_account is null or df.login_account like '')
  769. </if>
  770. </where>
  771. ${maps.params.dataScope}
  772. </select>
  773. <select id="selectLiveOrderProductStatistics" resultType="java.lang.String">
  774. SELECT GROUP_CONCAT(
  775. CONCAT(product_name, ':', product_num)
  776. ORDER BY product_name
  777. SEPARATOR ' '
  778. ) AS product_num_list
  779. FROM (
  780. SELECT sp.product_name,SUM(IF(soi.num IS NULL,0,soi.num)) product_num
  781. FROM fs_store_product_scrm sp
  782. INNER JOIN live_order_item soi ON soi.product_id = sp.product_id
  783. INNER JOIN live_order o ON soi.order_id = o.order_id
  784. LEFT JOIN fs_user us ON us.user_id=o.user_id
  785. LEFT JOIN company_user cu on cu.user_id=o.company_user_id
  786. LEFT JOIN live_order_df df on df.order_id=o.order_id
  787. <if test="maps.coursePlaySourceConfigId != null">
  788. LEFT JOIN (
  789. SELECT
  790. sp.*,
  791. ROW_NUMBER() OVER (PARTITION BY sp.business_code ORDER BY sp.create_time DESC) as rn
  792. FROM live_order_payment sp
  793. WHERE sp.business_code IS NOT NULL
  794. ) sp_latest ON sp_latest.business_code = o.order_code AND sp_latest.rn = 1
  795. LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
  796. </if>
  797. <where>
  798. <if test="maps.coursePlaySourceConfigId != null">
  799. and csc.id = #{maps.coursePlaySourceConfigId}
  800. </if>
  801. <if test="maps.orderCodes != null and maps.orderCodes.size > 0">
  802. and o.order_code in
  803. <foreach collection="maps.orderCodes" item="orderCode" open="(" close=")" separator=",">
  804. #{orderCode}
  805. </foreach>
  806. </if>
  807. <if test="maps.orderCode != null and maps.orderCode !=''">
  808. and o.order_code like CONCAT('%',#{maps.orderCode},'%')
  809. </if>
  810. <if test="maps.isPayRemain != null">
  811. and o.is_pay_remain =#{maps.isPayRemain}
  812. </if>
  813. <if test="maps.userId != null">
  814. and o.user_id =#{maps.userId}
  815. </if>
  816. <if test="maps.deliveryId != null and maps.deliveryId !=''">
  817. and o.delivery_id =#{maps.deliveryId}
  818. </if>
  819. <if test="maps.nickname != null and maps.nickname !=''">
  820. and u.nickname like CONCAT('%',#{maps.nickname},'%')
  821. </if>
  822. <if test="maps.realName != null and maps.realName !=''">
  823. and o.user_name like CONCAT('%',#{maps.realName},'%')
  824. </if>
  825. <if test="maps.userName != null and maps.userName !=''">
  826. and o.user_name like CONCAT('%',#{maps.userName},'%')
  827. </if>
  828. <if test="maps.phone != null and maps.phone !=''">
  829. and u.phone like CONCAT('%',#{maps.phone},'%')
  830. </if>
  831. <if test="maps.userPhone != null and maps.userPhone !=''">
  832. and o.user_phone like CONCAT('%',#{maps.userPhone},'%')
  833. </if>
  834. <if test="maps.status != null and maps.status != 6">
  835. and o.status = #{maps.status}
  836. </if>
  837. <if test="maps.status == 6">
  838. and o.`status`= 1
  839. and (o.extend_order_id is null or o.extend_order_id like '')
  840. </if>
  841. <if test="maps.isUpload != null and maps.isUpload == 0 ">
  842. and o.certificates is null
  843. </if>
  844. <if test="maps.isUpload != null and maps.isUpload == 1 ">
  845. and o.certificates is not null
  846. </if>
  847. <if test="maps.deliveryStatus != null ">
  848. and o.delivery_status =#{maps.deliveryStatus}
  849. </if>
  850. <if test="maps.deliveryPayStatus != null ">
  851. and o.delivery_pay_status =#{maps.deliveryPayStatus}
  852. </if>
  853. <if test="maps.companyId != null ">
  854. and o.company_id =#{maps.companyId}
  855. </if>
  856. <if test="maps.isHealth != null and maps.isHealth != '' ">
  857. and o.company_id is null
  858. </if>
  859. <if test="maps.notHealth != null ">
  860. and o.company_id is not null
  861. </if>
  862. <if test="maps.companyUserId != null ">
  863. and o.company_user_id =#{maps.companyUserId}
  864. </if>
  865. <if test="maps.companyUserNickName != null and maps.companyUserNickName != '' ">
  866. and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
  867. </if>
  868. <if test="maps.productName != null and maps.productName != '' ">
  869. and fsp.product_name like concat('%', #{maps.productName}, '%')
  870. </if>
  871. <if test="maps.orderType != null ">
  872. and o.order_type =#{maps.orderType}
  873. </if>
  874. <if test="maps.payType != null ">
  875. and o.pay_type =#{maps.payType}
  876. </if>
  877. <if test="maps.scheduleId != null ">
  878. and o.schedule_id =#{maps.scheduleId}
  879. </if>
  880. <if test="maps.createTimeList != null ">
  881. AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d')
  882. AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d')
  883. </if>
  884. <if test="maps.deliverySendTimeList != null ">
  885. AND date_format(o.delivery_send_time,'%y%m%d') &gt;= date_format(#{maps.deliverySendTimeList[0]},'%y%m%d')
  886. AND date_format(o.delivery_send_time,'%y%m%d') &lt;= date_format(#{maps.deliverySendTimeList[1]},'%y%m%d')
  887. </if>
  888. <if test="maps.paidStatus != null ">
  889. and o.paid =#{maps.paidStatus}
  890. </if>
  891. <if test="maps.payTimeList != null ">
  892. AND date_format(o.pay_time,'%y%m%d') &gt;= date_format(#{maps.payTimeList[0]},'%y%m%d')
  893. AND date_format(o.pay_time,'%y%m%d') &lt;= date_format(#{maps.payTimeList[1]},'%y%m%d')
  894. </if>
  895. <if test="maps.deliveryImportTimeList != null ">
  896. AND date_format(o.delivery_import_time,'%y%m%d') &gt;= date_format(#{maps.deliveryImportTimeList[0]},'%y%m%d')
  897. AND date_format(o.delivery_import_time,'%y%m%d') &lt;= date_format(#{maps.deliveryImportTimeList[1]},'%y%m%d')
  898. </if>
  899. <if test="maps.deptId != null ">
  900. 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) ))
  901. </if>
  902. <if test="maps.erpPhoneNumber != null and maps.erpPhoneNumber != ''">
  903. and o.erp_phone like concat(#{maps.erpPhoneNumber},'%')
  904. </if>
  905. <if test="maps.erpAccount != null and maps.erpAccount != '未分拣' and maps.erpAccount != ''">
  906. and df.login_account like #{maps.erpAccount}
  907. </if>
  908. <if test="maps.erpAccount == '未分拣'">
  909. and ( df.login_account is null or df.login_account like '')
  910. </if>
  911. </where>
  912. ${maps.params.dataScope} GROUP BY sp.product_id
  913. ) AS t
  914. </select>
  915. <!-- 查询订单列表Zm -->
  916. <select id="selectLiveOrderListZm" parameterType="LiveOrder" resultType="com.fs.live.vo.LiveOrderVoZm">
  917. SELECT
  918. o.order_id,
  919. o.live_id,
  920. o.store_id,
  921. o.order_code,
  922. o.user_id,
  923. o.user_name,
  924. o.user_phone,
  925. o.user_address,
  926. o.cart_id,
  927. o.total_num,
  928. o.total_price,
  929. o.pay_price,
  930. o.is_pay,
  931. o.pay_time,
  932. o.pay_type,
  933. o.pay_money,
  934. o.pay_delivery,
  935. o.create_time,
  936. o.update_time,
  937. o.status,
  938. o.refund_status,
  939. o.refund_img,
  940. o.refund_explain,
  941. o.refund_time,
  942. o.refund_reason,
  943. o.refund_money,
  944. o.delivery_code,
  945. o.delivery_name,
  946. o.delivery_sn,
  947. o.remark,
  948. o.is_del,
  949. o.cost_price,
  950. o.company_id,
  951. o.company_user_id,
  952. o.product_id,
  953. o.customer_id,
  954. o.coupon_price,
  955. o.cancel_reason,
  956. cu.nick_name AS companyUserNickName,
  957. cu.phonenumber AS companyUserPhone,
  958. cu.create_time AS companyUserCreateTime,
  959. u.user_code AS userCode,
  960. u.level AS userLevel,
  961. u.nick_name AS nickName,
  962. u.phone AS userBindPhone,
  963. u.order_count AS totalOrderCount,
  964. u.total_amount AS totalOrderAmount,
  965. u.status AS userStatus,
  966. u.update_time AS latestBindTime,
  967. p.product_name AS productName,
  968. p.cost AS costPrice,
  969. p.price AS price,
  970. p.cost AS cost,
  971. p.prescribe_spec AS productSpec,
  972. p.prescribe_factory AS supplierName,
  973. s.store_name AS storeName,
  974. s.store_id AS storeId,
  975. GROUP_CONCAT(DISTINCT spavs.bar_code SEPARATOR ',') AS bar_codes,
  976. spcs.cate_name,
  977. lop.bank_transaction_id AS bankTransactionId
  978. FROM
  979. live_order o
  980. LEFT JOIN fs_user u ON o.user_id = u.user_id
  981. LEFT JOIN company_user cu ON o.company_user_id = cu.user_id
  982. LEFT JOIN fs_store_product_scrm p ON o.product_id = p.product_id
  983. LEFT JOIN fs_store_scrm s ON p.store_id = s.store_id
  984. LEFT JOIN fs_store_product_attr_value_scrm spavs ON p.product_id = spavs.product_id
  985. LEFT JOIN fs_store_product_category_scrm spcs ON p.cate_id = spcs.cate_id
  986. LEFT JOIN (
  987. SELECT
  988. sp.*,
  989. ROW_NUMBER() OVER (PARTITION BY sp.business_code ORDER BY sp.create_time DESC) as rn
  990. FROM live_order_payment sp
  991. WHERE sp.business_code IS NOT NULL
  992. ) lop ON lop.business_code = o.order_code AND lop.rn = 1
  993. <where>
  994. o.is_del = 0 and p.product_id IS NOT NULL
  995. <if test="bankTransactionId != null and bankTransactionId !=''">
  996. and lop.bank_transaction_id like CONCAT('%',#{bankTransactionId},'%')
  997. </if>
  998. <if test="orderId != null">
  999. AND o.order_id = #{orderId}
  1000. </if>
  1001. <if test="liveId != null">
  1002. AND o.live_id = #{liveId}
  1003. </if>
  1004. <if test="storeId != null">
  1005. AND o.store_id = #{storeId}
  1006. </if>
  1007. <if test="orderCode != null and orderCode != ''">
  1008. AND o.order_code LIKE CONCAT('%', #{orderCode}, '%')
  1009. </if>
  1010. <if test="userId != null and userId != ''">
  1011. AND o.user_id = #{userId}
  1012. </if>
  1013. <if test="status != null">
  1014. AND o.status = #{status}
  1015. </if>
  1016. <if test="companyId != null">
  1017. AND o.company_id = #{companyId}
  1018. </if>
  1019. <if test="totalNum != null">
  1020. AND o.total_num = #{totalNum}
  1021. </if>
  1022. <if test="price != null">
  1023. AND p.price = #{price}
  1024. </if>
  1025. <if test="cost != null">
  1026. AND p.cost = #{cost}
  1027. </if>
  1028. <if test="companyUserId != null">
  1029. AND o.company_user_id = #{companyUserId}
  1030. </if>
  1031. <if test="productId != null">
  1032. AND o.product_id = #{productId}
  1033. </if>
  1034. <!-- 新增筛选条件 -->
  1035. <if test="productName != null and productName != ''">
  1036. AND p.product_name LIKE CONCAT('%', #{productName}, '%')
  1037. </if>
  1038. <if test="productSpec != null and productSpec != ''">
  1039. AND p.prescribe_spec LIKE CONCAT('%', #{productSpec}, '%')
  1040. </if>
  1041. <if test="storeId != null and storeId != ''">
  1042. AND p.store_id = #{storeId}
  1043. </if>
  1044. <if test="userAddress != null and userAddress != ''">
  1045. AND o.user_address LIKE CONCAT('%', #{userAddress}, '%')
  1046. </if>
  1047. <if test="userName != null and userName != ''">
  1048. AND o.user_name LIKE CONCAT('%', #{userName}, '%')
  1049. </if>
  1050. <if test="createTimeStart != null ">
  1051. AND o.create_time &gt;= #{createTimeStart}
  1052. </if>
  1053. <if test="createTimeEnd != null ">
  1054. AND o.create_time &lt;= #{createTimeEnd}
  1055. </if>
  1056. <if test="payStartTime != null ">
  1057. AND o.pay_time &gt;= #{payStartTime}
  1058. </if>
  1059. <if test="payEndTime != null ">
  1060. AND o.pay_time &lt;= #{payEndTime}
  1061. </if>
  1062. <if test="userPhone != null and userPhone != ''">
  1063. AND o.user_phone = #{userPhone}
  1064. </if>
  1065. </where>
  1066. GROUP BY o.order_id
  1067. ORDER BY o.create_time DESC
  1068. </select>
  1069. <select id="selectLiveOrderListZmNew" parameterType="LiveOrder" resultType="com.fs.hisStore.vo.FsStoreOrderItemExportZMVO">
  1070. select
  1071. t1.order_code as orderCode,
  1072. t1.status,
  1073. t1.user_id as userId,
  1074. if(JSON_VALID(t2.json_info),t2.json_info->>'$.productName','') as productName,
  1075. if(JSON_VALID(t2.json_info),t2.json_info->>'$.barCode','') as barCode,
  1076. if(JSON_VALID(t2.json_info),t2.json_info->>'$.sku','') as sku,
  1077. if(JSON_VALID(t2.json_info),t2.json_info->>'$.price','') as price,
  1078. t2.num,
  1079. fsps.cost,
  1080. fspcs.cate_name as cateName,
  1081. t1.user_name as realName,
  1082. t1.user_phone as userPhone,
  1083. t1.user_address as userAddress,
  1084. t1.create_time as createTime,
  1085. t1.pay_time as payTime,
  1086. t1.delivery_sn as deliveryId,
  1087. t1.delivery_name as deliveryName,
  1088. t1.delivery_code as deliverySn,
  1089. t3.company_name as companyName,
  1090. t4.nick_name as companyUserNickName,
  1091. lop.bank_transaction_id as bankTransactionId,
  1092. t1.pay_money,
  1093. t1.pay_delivery as payPostage
  1094. from
  1095. live_order t1
  1096. left join live_order_item t2 on t1.order_id = t2.order_id
  1097. left join fs_store_product_scrm fsps on fsps.product_id = t2.product_id
  1098. left join fs_store_product_category_scrm fspcs on fspcs.cate_id = fsps.cate_id
  1099. left join company t3 on t1.company_id = t3.company_id
  1100. left join company_user t4 on t4.user_id = t1.company_user_id
  1101. LEFT JOIN (
  1102. SELECT
  1103. t5.*,
  1104. ROW_NUMBER() OVER (PARTITION BY t5.business_code ORDER BY t5.status desc,t5.create_time DESC) as rn
  1105. FROM live_order_payment t5
  1106. WHERE t5.business_id IS NOT NULL
  1107. ) lop ON lop.business_id = t1.order_id AND lop.rn = 1
  1108. <where>
  1109. t1.is_del = 0 and fsps.product_id IS NOT NULL
  1110. <if test="orderId != null">
  1111. AND t1.order_id = #{orderId}
  1112. </if>
  1113. <if test="liveId != null">
  1114. AND t1.live_id = #{liveId}
  1115. </if>
  1116. <if test="storeId != null">
  1117. AND t1.store_id = #{storeId}
  1118. </if>
  1119. <if test="orderCode != null and orderCode != ''">
  1120. AND t1.order_code LIKE CONCAT('%', #{orderCode}, '%')
  1121. </if>
  1122. <if test="userId != null and userId != ''">
  1123. AND t1.user_id = #{userId}
  1124. </if>
  1125. <if test="status != null">
  1126. AND t1.status = #{status}
  1127. </if>
  1128. <if test="companyId != null">
  1129. AND t1.company_id = #{companyId}
  1130. </if>
  1131. <if test="totalNum != null">
  1132. AND t1.total_num = #{totalNum}
  1133. </if>
  1134. <if test="price != null">
  1135. AND fsps.price = #{price}
  1136. </if>
  1137. <if test="cost != null">
  1138. AND fsps.cost = #{cost}
  1139. </if>
  1140. <if test="companyUserId != null">
  1141. AND t1.company_user_id = #{companyUserId}
  1142. </if>
  1143. <if test="productId != null">
  1144. AND t1.product_id = #{productId}
  1145. </if>
  1146. <!-- 新增筛选条件 -->
  1147. <if test="productName != null and productName != ''">
  1148. AND fsps.product_name LIKE CONCAT('%', #{productName}, '%')
  1149. </if>
  1150. <if test="productSpec != null and productSpec != ''">
  1151. AND fsps.prescribe_spec LIKE CONCAT('%', #{productSpec}, '%')
  1152. </if>
  1153. <if test="storeId != null and storeId != ''">
  1154. AND fsps.store_id = #{storeId}
  1155. </if>
  1156. <if test="userAddress != null and userAddress != ''">
  1157. AND t1.user_address LIKE CONCAT('%', #{userAddress}, '%')
  1158. </if>
  1159. <if test="userName != null and userName != ''">
  1160. AND t1.user_name LIKE CONCAT('%', #{userName}, '%')
  1161. </if>
  1162. <if test="createTimeStart != null ">
  1163. AND t1.create_time &gt;= #{createTimeStart}
  1164. </if>
  1165. <if test="createTimeEnd != null ">
  1166. AND t1.create_time &lt;= #{createTimeEnd}
  1167. </if>
  1168. <if test="payStartTime != null ">
  1169. AND t1.pay_time &gt;= #{payStartTime}
  1170. </if>
  1171. <if test="payEndTime != null ">
  1172. AND t1.pay_time &lt;= #{payEndTime}
  1173. </if>
  1174. <if test="userPhone != null and userPhone != ''">
  1175. AND t1.user_phone = #{userPhone}
  1176. </if>
  1177. </where>
  1178. GROUP BY t1.order_id
  1179. </select>
  1180. <select id="getUnsettledOrder" resultType="com.fs.live.domain.LiveOrder">
  1181. SELECT
  1182. sos.*,
  1183. sps.bank_transaction_id
  1184. FROM
  1185. live_order sos
  1186. INNER JOIN live_order_payment sps ON sos.id = sps.order_id
  1187. WHERE
  1188. sos.is_del = 0 and
  1189. sos.is_pay = 1
  1190. AND sps.business_type = 2
  1191. AND sos.`status` = 2
  1192. AND sps.`status`=1
  1193. AND DATEDIFF(
  1194. NOW(),
  1195. sos.delivery_send_time
  1196. ) >= 3
  1197. </select>
  1198. <select id="getDeliveryNote" resultType="com.fs.live.vo.LiveOrderDeliveryNoteExportVO">
  1199. SELECT
  1200. CONCAT('AC', o.order_id) AS orderNumber,
  1201. o.user_name AS recipient,
  1202. o.user_phone AS recipientPhone,
  1203. o.user_address AS recipientAddress,
  1204. GROUP_CONCAT(
  1205. DISTINCT IFNULL(
  1206. CASE WHEN LENGTH(sps.product_name) > 0
  1207. THEN CONCAT(sps.product_name, '*', sois.num)
  1208. END, ''
  1209. )
  1210. SEPARATOR '+'
  1211. ) AS nameAndNumber,
  1212. sps.keyword
  1213. FROM
  1214. live_order o
  1215. LEFT JOIN live_order_item sois
  1216. ON sois.order_id = o.order_id
  1217. LEFT JOIN fs_store_product_scrm sps
  1218. ON sps.product_id = sois.product_id
  1219. LEFT JOIN fs_user u
  1220. ON o.user_id = u.user_id
  1221. LEFT JOIN company c
  1222. ON c.company_id = o.company_id
  1223. LEFT JOIN company_user cu
  1224. ON cu.user_id = o.company_user_id
  1225. LEFT JOIN (
  1226. SELECT DISTINCT business_id as order_id
  1227. FROM live_order_payment
  1228. WHERE STATUS != 0
  1229. ) fp
  1230. ON o.order_id = fp.order_id
  1231. WHERE
  1232. o.is_del = 0 and
  1233. 1 = 1
  1234. <if test="maps.orderCode != null and maps.orderCode != ''">
  1235. AND o.order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
  1236. </if>
  1237. <if test="maps.userId != null">
  1238. AND o.user_id = #{maps.userId}
  1239. </if>
  1240. <if test="maps.deliveryId != null and maps.deliveryId != ''">
  1241. AND o.delivery_id = #{maps.deliveryId}
  1242. </if>
  1243. <if test="maps.nickname != null and maps.nickname != ''">
  1244. AND u.nickname LIKE CONCAT('%', #{maps.nickname}, '%')
  1245. </if>
  1246. <if test="maps.realName != null and maps.realName != ''">
  1247. AND o.user_name LIKE CONCAT('%', #{maps.realName}, '%')
  1248. </if>
  1249. <if test="maps.phone != null and maps.phone != ''">
  1250. AND u.phone LIKE CONCAT('%', #{maps.phone}, '%')
  1251. </if>
  1252. <if test="maps.userPhone != null and maps.userPhone != ''">
  1253. AND o.user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
  1254. </if>
  1255. <if test="maps.status == null">
  1256. AND o.status = 1
  1257. </if>
  1258. <if test="maps.status != null">
  1259. AND o.status = #{maps.status}
  1260. </if>
  1261. <if test="maps.deliveryStatus != null">
  1262. AND o.delivery_status = #{maps.deliveryStatus}
  1263. </if>
  1264. <if test="maps.deliveryPayStatus != null">
  1265. AND o.delivery_pay_status = #{maps.deliveryPayStatus}
  1266. </if>
  1267. <if test="maps.companyId != null">
  1268. AND o.company_id = #{maps.companyId}
  1269. </if>
  1270. <if test="maps.isHealth != null and maps.isHealth != ''">
  1271. AND o.company_id IS NULL
  1272. </if>
  1273. <if test="maps.notHealth != null and maps.notHealth != ''">
  1274. AND o.company_id IS NOT NULL
  1275. </if>
  1276. <if test="maps.companyUserId != null">
  1277. AND o.company_user_id = #{maps.companyUserId}
  1278. </if>
  1279. <if test="maps.companyUserNickName != null and maps.companyUserNickName != ''">
  1280. AND cu.nick_name LIKE CONCAT('%', #{maps.companyUserNickName}, '%')
  1281. </if>
  1282. <if test="maps.orderType != null">
  1283. AND o.order_type = #{maps.orderType}
  1284. </if>
  1285. <if test="maps.payType != null">
  1286. AND o.pay_type = #{maps.payType}
  1287. </if>
  1288. <if test="maps.createTimeList != null">
  1289. AND o.create_time >= STR_TO_DATE(#{maps.createTimeList[0]}, '%Y%m%d')
  1290. AND o.create_time &lt; DATE_ADD(STR_TO_DATE(#{maps.createTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
  1291. </if>
  1292. <if test="maps.payTimeList != null">
  1293. AND o.pay_time >= STR_TO_DATE(#{maps.payTimeList[0]}, '%Y%m%d')
  1294. AND o.pay_time &lt; DATE_ADD(STR_TO_DATE(#{maps.payTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
  1295. </if>
  1296. <if test="maps.deliverySendTimeList != null">
  1297. AND o.delivery_send_time >= STR_TO_DATE(#{maps.deliverySendTimeList[0]}, '%Y%m%d')
  1298. AND o.delivery_send_time &lt; DATE_ADD(STR_TO_DATE(#{maps.deliverySendTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
  1299. </if>
  1300. <if test="maps.deliveryImportTimeList != null">
  1301. AND o.delivery_import_time >= STR_TO_DATE(#{maps.deliveryImportTimeList[0]}, '%Y%m%d')
  1302. AND o.delivery_import_time &lt; DATE_ADD(STR_TO_DATE(#{maps.deliveryImportTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
  1303. </if>
  1304. <if test="maps.deptId != null">
  1305. AND (o.dept_id = #{maps.deptId}
  1306. OR o.dept_id IN (SELECT t.dept_id FROM company_dept t WHERE FIND_IN_SET(#{maps.deptId}, t.ancestors)))
  1307. </if>
  1308. <if test="maps.isUpload != null and maps.isUpload == 0">
  1309. AND o.certificates IS NULL
  1310. </if>
  1311. <if test="maps.scheduleId != null">
  1312. AND o.schedule_id = #{maps.scheduleId}
  1313. </if>
  1314. <if test="maps.isUpload != null and maps.isUpload == 1">
  1315. AND o.certificates IS NOT NULL
  1316. </if>
  1317. ${maps.params.dataScope}
  1318. AND o.paid = 1
  1319. GROUP BY o.id
  1320. LIMIT 10000;
  1321. </select>
  1322. <select id="selectLiveOrderCodeOpenIdInOrderCode" resultType="com.fs.live.vo.LiveOrderCodeOpenIdVo">
  1323. SELECT
  1324. os.order_id as id,
  1325. fu.phone,
  1326. fu.ma_open_id openId,
  1327. ois.json_info,
  1328. lop.bank_transaction_id outTransId
  1329. FROM
  1330. live_order os
  1331. INNER JOIN fs_user fu ON os.user_id = fu.user_id
  1332. INNER JOIN live_order_item ois ON ois.order_id = os.order_id
  1333. INNER JOIN live_order_payment lop ON os.order_id = lop.business_id
  1334. WHERE os.is_del = 0 and os.order_code IN
  1335. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  1336. #{item}
  1337. </foreach>
  1338. AND lop.`status` = 1
  1339. </select>
  1340. <update id="batchUpdateInOrderCode">
  1341. UPDATE live_order
  1342. <set>
  1343. delivery_sn = CASE
  1344. <foreach collection="list" item="item">
  1345. WHEN order_code = #{item.orderNumber} THEN #{item.deliverySn}
  1346. </foreach>
  1347. ELSE delivery_sn
  1348. END,
  1349. delivery_name = CASE
  1350. <foreach collection="list" item="item">
  1351. WHEN order_code = #{item.orderNumber} THEN #{item.logisticsCompany}
  1352. </foreach>
  1353. ELSE delivery_name
  1354. END,
  1355. delivery_id = CASE
  1356. <foreach collection="list" item="item">
  1357. WHEN order_code = #{item.orderNumber} THEN #{item.deliveryId}
  1358. </foreach>
  1359. ELSE delivery_id
  1360. END,
  1361. status = CASE
  1362. WHEN status = 1 THEN 2
  1363. ELSE status
  1364. END,
  1365. delivery_send_time = NOW()
  1366. </set>
  1367. WHERE order_code IN
  1368. <foreach collection="list" item="item" open="(" separator="," close=")">
  1369. #{item.orderNumber}
  1370. </foreach>
  1371. </update>
  1372. <update id="batchUpdateTime">
  1373. UPDATE live_order
  1374. SET update_time = CASE
  1375. <foreach collection="list" item="item" separator="">
  1376. WHEN order_id = #{item.orderId} THEN #{item.updateTime}
  1377. </foreach>
  1378. END
  1379. WHERE order_id IN
  1380. <foreach collection="list" item="item" open="(" separator="," close=")">
  1381. #{item.orderId}
  1382. </foreach>
  1383. </update>
  1384. </mapper>