LiveOrderMapper.xml 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269
  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
  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.isPayRemain != null">
  505. and o.is_pay_remain =#{maps.isPayRemain}
  506. </if>
  507. <if test="maps.userId != null">
  508. and o.user_id =#{maps.userId}
  509. </if>
  510. <if test="maps.deliveryId != null and maps.deliveryId !=''">
  511. and o.delivery_id =#{maps.deliveryId}
  512. </if>
  513. <if test="maps.nickname != null and maps.nickname !=''">
  514. and u.nickname like CONCAT('%',#{maps.nickname},'%')
  515. </if>
  516. <if test="maps.realName != null and maps.realName !=''">
  517. and o.user_name like CONCAT('%',#{maps.realName},'%')
  518. </if>
  519. <if test="maps.userName != null and maps.userName !=''">
  520. and o.user_name like CONCAT('%',#{maps.userName},'%')
  521. </if>
  522. <if test="maps.phone != null and maps.phone !=''">
  523. and u.phone like CONCAT('%',#{maps.phone},'%')
  524. </if>
  525. <if test="maps.userPhone != null and maps.userPhone !=''">
  526. and o.user_phone like CONCAT('%',#{maps.userPhone},'%')
  527. </if>
  528. <if test="maps.status != null and maps.status != 6">
  529. and o.status = #{maps.status}
  530. </if>
  531. <if test="maps.status == 6">
  532. and o.`status`= 1
  533. and (o.extend_order_id is null or o.extend_order_id like '')
  534. </if>
  535. <if test="maps.isUpload != null and maps.isUpload == 0 ">
  536. and o.certificates is null
  537. </if>
  538. <if test="maps.isUpload != null and maps.isUpload == 1 ">
  539. and o.certificates is not null
  540. </if>
  541. <if test="maps.deliveryStatus != null ">
  542. and o.delivery_status =#{maps.deliveryStatus}
  543. </if>
  544. <if test="maps.deliveryPayStatus != null ">
  545. and o.delivery_pay_status =#{maps.deliveryPayStatus}
  546. </if>
  547. <if test="maps.companyId != null ">
  548. and o.company_id =#{maps.companyId}
  549. </if>
  550. <if test="maps.isHealth != null and maps.isHealth != '' ">
  551. and o.company_id is null
  552. </if>
  553. <if test="maps.notHealth != null ">
  554. and o.company_id is not null
  555. </if>
  556. <if test="maps.companyUserId != null ">
  557. and o.company_user_id =#{maps.companyUserId}
  558. </if>
  559. <if test="maps.companyUserNickName != null and maps.companyUserNickName != '' ">
  560. and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
  561. </if>
  562. <if test="maps.productName != null and maps.productName != '' ">
  563. and fsp.product_name like concat('%', #{maps.productName}, '%')
  564. </if>
  565. <if test="maps.orderType != null ">
  566. and o.order_type =#{maps.orderType}
  567. </if>
  568. <if test="maps.payType != null ">
  569. and o.pay_type =#{maps.payType}
  570. </if>
  571. <if test="maps.scheduleId != null ">
  572. and o.schedule_id =#{maps.scheduleId}
  573. </if>
  574. <if test="maps.createTimeList != null ">
  575. AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d')
  576. AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d')
  577. </if>
  578. <if test="maps.deliverySendTimeList != null ">
  579. AND date_format(o.delivery_send_time,'%y%m%d') &gt;= date_format(#{maps.deliverySendTimeList[0]},'%y%m%d')
  580. AND date_format(o.delivery_send_time,'%y%m%d') &lt;= date_format(#{maps.deliverySendTimeList[1]},'%y%m%d')
  581. </if>
  582. <if test="maps.paidStatus != null ">
  583. and o.paid =#{maps.paidStatus}
  584. </if>
  585. <if test="maps.payTimeList != null ">
  586. AND date_format(o.pay_time,'%y%m%d') &gt;= date_format(#{maps.payTimeList[0]},'%y%m%d')
  587. AND date_format(o.pay_time,'%y%m%d') &lt;= date_format(#{maps.payTimeList[1]},'%y%m%d')
  588. </if>
  589. <if test="maps.deliveryImportTimeList != null ">
  590. AND date_format(o.delivery_import_time,'%y%m%d') &gt;= date_format(#{maps.deliveryImportTimeList[0]},'%y%m%d')
  591. AND date_format(o.delivery_import_time,'%y%m%d') &lt;= date_format(#{maps.deliveryImportTimeList[1]},'%y%m%d')
  592. </if>
  593. <if test="maps.deptId != null ">
  594. 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) ))
  595. </if>
  596. <if test="maps.erpPhoneNumber != null and maps.erpPhoneNumber != ''">
  597. and o.erp_phone like concat(#{maps.erpPhoneNumber},'%')
  598. </if>
  599. <if test="maps.erpAccount != null and maps.erpAccount != '未分拣' and maps.erpAccount != ''">
  600. and df.login_account like #{maps.erpAccount}
  601. </if>
  602. <if test="maps.erpAccount == '未分拣'">
  603. and ( df.login_account is null or df.login_account like '')
  604. </if>
  605. </where>
  606. ${maps.params.dataScope}
  607. <if test="maps.productName != null and maps.productName != '' ">
  608. group by o.order_id
  609. </if>
  610. order by
  611. <if test="maps.sortField == 'companyUserName'">
  612. cu.nick_name
  613. </if>
  614. <if test="maps.sortField == 'packageName'">
  615. o.package_name
  616. </if>
  617. <if test="maps.sortField == 'payPrice'">
  618. o.pay_price
  619. </if>
  620. <if test="maps.sortField == 'payMoney'">
  621. o.pay_money
  622. </if>
  623. <if test="maps.sortOrder != null and maps.sortOrder != ''">
  624. ${maps.sortOrder}
  625. </if>
  626. <if test="maps.sortField == null or maps.sortField == ''">
  627. o.order_id desc
  628. </if>
  629. </select>
  630. <select id="selectLiveOrderStatistics" resultType="java.util.Map">
  631. select sum(o.pay_price) pay_price,sum(o.pay_money) pay_money,sum(o.pay_delivery) pay_remain
  632. FROM live_order o
  633. left join fs_user u on o.user_id=u.user_id
  634. left join company c on c.company_id=o.company_id
  635. left join company_user cu on cu.user_id=o.company_user_id
  636. <if test="maps.erpAccount != null or maps.erpAccount != ''">
  637. LEFT JOIN live_order_df df on df.order_id=o.order_id
  638. </if>
  639. <if test = "maps.productName != null and maps.productName != '' ">
  640. left join live_order_item oi on o.order_id = oi.order_id
  641. left join fs_store_product_scrm fsp on fsp.product_id = oi.product_id
  642. </if>
  643. <if test="maps.coursePlaySourceConfigId != null">
  644. LEFT JOIN (
  645. SELECT
  646. sp.*,
  647. ROW_NUMBER() OVER (PARTITION BY sp.business_code ORDER BY sp.create_time DESC) as rn
  648. FROM live_order_payment sp
  649. WHERE sp.business_code IS NOT NULL
  650. ) sp_latest ON sp_latest.business_code = o.order_code AND sp_latest.rn = 1
  651. LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
  652. </if>
  653. <where>
  654. <if test="maps.coursePlaySourceConfigId != null">
  655. and csc.id = #{maps.coursePlaySourceConfigId}
  656. </if>
  657. <if test="maps.orderCodes != null and maps.orderCodes.size > 0">
  658. and o.order_code in
  659. <foreach collection="maps.orderCodes" item="orderCode" open="(" close=")" separator=",">
  660. #{orderCode}
  661. </foreach>
  662. </if>
  663. <if test="maps.orderCode != null and maps.orderCode !=''">
  664. and o.order_code like CONCAT('%',#{maps.orderCode},'%')
  665. </if>
  666. <if test="maps.isPayRemain != null">
  667. and o.is_pay_remain =#{maps.isPayRemain}
  668. </if>
  669. <if test="maps.userId != null">
  670. and o.user_id =#{maps.userId}
  671. </if>
  672. <if test="maps.deliveryId != null and maps.deliveryId !=''">
  673. and o.delivery_id =#{maps.deliveryId}
  674. </if>
  675. <if test="maps.nickname != null and maps.nickname !=''">
  676. and u.nickname like CONCAT('%',#{maps.nickname},'%')
  677. </if>
  678. <if test="maps.realName != null and maps.realName !=''">
  679. and o.user_name like CONCAT('%',#{maps.realName},'%')
  680. </if>
  681. <if test="maps.userName != null and maps.userName !=''">
  682. and o.user_name like CONCAT('%',#{maps.userName},'%')
  683. </if>
  684. <if test="maps.phone != null and maps.phone !=''">
  685. and u.phone like CONCAT('%',#{maps.phone},'%')
  686. </if>
  687. <if test="maps.userPhone != null and maps.userPhone !=''">
  688. and o.user_phone like CONCAT('%',#{maps.userPhone},'%')
  689. </if>
  690. <if test="maps.status != null and maps.status != 6">
  691. and o.status = #{maps.status}
  692. </if>
  693. <if test="maps.status == 6">
  694. and o.`status`= 1
  695. and (o.extend_order_id is null or o.extend_order_id like '')
  696. </if>
  697. <if test="maps.isUpload != null and maps.isUpload == 0 ">
  698. and o.certificates is null
  699. </if>
  700. <if test="maps.isUpload != null and maps.isUpload == 1 ">
  701. and o.certificates is not null
  702. </if>
  703. <if test="maps.deliveryStatus != null ">
  704. and o.delivery_status =#{maps.deliveryStatus}
  705. </if>
  706. <if test="maps.deliveryPayStatus != null ">
  707. and o.delivery_pay_status =#{maps.deliveryPayStatus}
  708. </if>
  709. <if test="maps.companyId != null ">
  710. and o.company_id =#{maps.companyId}
  711. </if>
  712. <if test="maps.isHealth != null and maps.isHealth != '' ">
  713. and o.company_id is null
  714. </if>
  715. <if test="maps.notHealth != null ">
  716. and o.company_id is not null
  717. </if>
  718. <if test="maps.companyUserId != null ">
  719. and o.company_user_id =#{maps.companyUserId}
  720. </if>
  721. <if test="maps.companyUserNickName != null and maps.companyUserNickName != '' ">
  722. and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
  723. </if>
  724. <if test="maps.productName != null and maps.productName != '' ">
  725. and fsp.product_name like concat('%', #{maps.productName}, '%')
  726. </if>
  727. <if test="maps.orderType != null ">
  728. and o.order_type =#{maps.orderType}
  729. </if>
  730. <if test="maps.payType != null ">
  731. and o.pay_type =#{maps.payType}
  732. </if>
  733. <if test="maps.scheduleId != null ">
  734. and o.schedule_id =#{maps.scheduleId}
  735. </if>
  736. <if test="maps.createTimeList != null ">
  737. AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d')
  738. AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d')
  739. </if>
  740. <if test="maps.deliverySendTimeList != null ">
  741. AND date_format(o.delivery_send_time,'%y%m%d') &gt;= date_format(#{maps.deliverySendTimeList[0]},'%y%m%d')
  742. AND date_format(o.delivery_send_time,'%y%m%d') &lt;= date_format(#{maps.deliverySendTimeList[1]},'%y%m%d')
  743. </if>
  744. <if test="maps.paidStatus != null ">
  745. and o.paid =#{maps.paidStatus}
  746. </if>
  747. <if test="maps.payTimeList != null ">
  748. AND date_format(o.pay_time,'%y%m%d') &gt;= date_format(#{maps.payTimeList[0]},'%y%m%d')
  749. AND date_format(o.pay_time,'%y%m%d') &lt;= date_format(#{maps.payTimeList[1]},'%y%m%d')
  750. </if>
  751. <if test="maps.deliveryImportTimeList != null ">
  752. AND date_format(o.delivery_import_time,'%y%m%d') &gt;= date_format(#{maps.deliveryImportTimeList[0]},'%y%m%d')
  753. AND date_format(o.delivery_import_time,'%y%m%d') &lt;= date_format(#{maps.deliveryImportTimeList[1]},'%y%m%d')
  754. </if>
  755. <if test="maps.deptId != null ">
  756. 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) ))
  757. </if>
  758. <if test="maps.erpPhoneNumber != null and maps.erpPhoneNumber != ''">
  759. and o.erp_phone like concat(#{maps.erpPhoneNumber},'%')
  760. </if>
  761. <if test="maps.erpAccount != null and maps.erpAccount != '未分拣' and maps.erpAccount != ''">
  762. and df.login_account like #{maps.erpAccount}
  763. </if>
  764. <if test="maps.erpAccount == '未分拣'">
  765. and ( df.login_account is null or df.login_account like '')
  766. </if>
  767. </where>
  768. ${maps.params.dataScope}
  769. </select>
  770. <select id="selectLiveOrderProductStatistics" resultType="java.lang.String">
  771. SELECT GROUP_CONCAT(
  772. CONCAT(product_name, ':', product_num)
  773. ORDER BY product_name
  774. SEPARATOR ' '
  775. ) AS product_num_list
  776. FROM (
  777. SELECT sp.product_name,SUM(IF(soi.num IS NULL,0,soi.num)) product_num
  778. FROM fs_store_product_scrm sp
  779. INNER JOIN live_order_item soi ON soi.product_id = sp.product_id
  780. INNER JOIN live_order o ON soi.order_id = o.order_id
  781. LEFT JOIN fs_user us ON us.user_id=o.user_id
  782. LEFT JOIN company_user cu on cu.user_id=o.company_user_id
  783. LEFT JOIN live_order_df df on df.order_id=o.order_id
  784. <if test="maps.coursePlaySourceConfigId != null">
  785. LEFT JOIN (
  786. SELECT
  787. sp.*,
  788. ROW_NUMBER() OVER (PARTITION BY sp.business_code ORDER BY sp.create_time DESC) as rn
  789. FROM live_order_payment sp
  790. WHERE sp.business_code IS NOT NULL
  791. ) sp_latest ON sp_latest.business_code = o.order_code AND sp_latest.rn = 1
  792. LEFT JOIN fs_course_play_source_config csc ON csc.appid = sp_latest.app_id
  793. </if>
  794. <where>
  795. <if test="maps.coursePlaySourceConfigId != null">
  796. and csc.id = #{maps.coursePlaySourceConfigId}
  797. </if>
  798. <if test="maps.orderCodes != null and maps.orderCodes.size > 0">
  799. and o.order_code in
  800. <foreach collection="maps.orderCodes" item="orderCode" open="(" close=")" separator=",">
  801. #{orderCode}
  802. </foreach>
  803. </if>
  804. <if test="maps.orderCode != null and maps.orderCode !=''">
  805. and o.order_code like CONCAT('%',#{maps.orderCode},'%')
  806. </if>
  807. <if test="maps.isPayRemain != null">
  808. and o.is_pay_remain =#{maps.isPayRemain}
  809. </if>
  810. <if test="maps.userId != null">
  811. and o.user_id =#{maps.userId}
  812. </if>
  813. <if test="maps.deliveryId != null and maps.deliveryId !=''">
  814. and o.delivery_id =#{maps.deliveryId}
  815. </if>
  816. <if test="maps.nickname != null and maps.nickname !=''">
  817. and u.nickname like CONCAT('%',#{maps.nickname},'%')
  818. </if>
  819. <if test="maps.realName != null and maps.realName !=''">
  820. and o.user_name like CONCAT('%',#{maps.realName},'%')
  821. </if>
  822. <if test="maps.userName != null and maps.userName !=''">
  823. and o.user_name like CONCAT('%',#{maps.userName},'%')
  824. </if>
  825. <if test="maps.phone != null and maps.phone !=''">
  826. and u.phone like CONCAT('%',#{maps.phone},'%')
  827. </if>
  828. <if test="maps.userPhone != null and maps.userPhone !=''">
  829. and o.user_phone like CONCAT('%',#{maps.userPhone},'%')
  830. </if>
  831. <if test="maps.status != null and maps.status != 6">
  832. and o.status = #{maps.status}
  833. </if>
  834. <if test="maps.status == 6">
  835. and o.`status`= 1
  836. and (o.extend_order_id is null or o.extend_order_id like '')
  837. </if>
  838. <if test="maps.isUpload != null and maps.isUpload == 0 ">
  839. and o.certificates is null
  840. </if>
  841. <if test="maps.isUpload != null and maps.isUpload == 1 ">
  842. and o.certificates is not null
  843. </if>
  844. <if test="maps.deliveryStatus != null ">
  845. and o.delivery_status =#{maps.deliveryStatus}
  846. </if>
  847. <if test="maps.deliveryPayStatus != null ">
  848. and o.delivery_pay_status =#{maps.deliveryPayStatus}
  849. </if>
  850. <if test="maps.companyId != null ">
  851. and o.company_id =#{maps.companyId}
  852. </if>
  853. <if test="maps.isHealth != null and maps.isHealth != '' ">
  854. and o.company_id is null
  855. </if>
  856. <if test="maps.notHealth != null ">
  857. and o.company_id is not null
  858. </if>
  859. <if test="maps.companyUserId != null ">
  860. and o.company_user_id =#{maps.companyUserId}
  861. </if>
  862. <if test="maps.companyUserNickName != null and maps.companyUserNickName != '' ">
  863. and cu.nick_name like concat('%', #{maps.companyUserNickName}, '%')
  864. </if>
  865. <if test="maps.productName != null and maps.productName != '' ">
  866. and fsp.product_name like concat('%', #{maps.productName}, '%')
  867. </if>
  868. <if test="maps.orderType != null ">
  869. and o.order_type =#{maps.orderType}
  870. </if>
  871. <if test="maps.payType != null ">
  872. and o.pay_type =#{maps.payType}
  873. </if>
  874. <if test="maps.scheduleId != null ">
  875. and o.schedule_id =#{maps.scheduleId}
  876. </if>
  877. <if test="maps.createTimeList != null ">
  878. AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d')
  879. AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d')
  880. </if>
  881. <if test="maps.deliverySendTimeList != null ">
  882. AND date_format(o.delivery_send_time,'%y%m%d') &gt;= date_format(#{maps.deliverySendTimeList[0]},'%y%m%d')
  883. AND date_format(o.delivery_send_time,'%y%m%d') &lt;= date_format(#{maps.deliverySendTimeList[1]},'%y%m%d')
  884. </if>
  885. <if test="maps.paidStatus != null ">
  886. and o.paid =#{maps.paidStatus}
  887. </if>
  888. <if test="maps.payTimeList != null ">
  889. AND date_format(o.pay_time,'%y%m%d') &gt;= date_format(#{maps.payTimeList[0]},'%y%m%d')
  890. AND date_format(o.pay_time,'%y%m%d') &lt;= date_format(#{maps.payTimeList[1]},'%y%m%d')
  891. </if>
  892. <if test="maps.deliveryImportTimeList != null ">
  893. AND date_format(o.delivery_import_time,'%y%m%d') &gt;= date_format(#{maps.deliveryImportTimeList[0]},'%y%m%d')
  894. AND date_format(o.delivery_import_time,'%y%m%d') &lt;= date_format(#{maps.deliveryImportTimeList[1]},'%y%m%d')
  895. </if>
  896. <if test="maps.deptId != null ">
  897. 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) ))
  898. </if>
  899. <if test="maps.erpPhoneNumber != null and maps.erpPhoneNumber != ''">
  900. and o.erp_phone like concat(#{maps.erpPhoneNumber},'%')
  901. </if>
  902. <if test="maps.erpAccount != null and maps.erpAccount != '未分拣' and maps.erpAccount != ''">
  903. and df.login_account like #{maps.erpAccount}
  904. </if>
  905. <if test="maps.erpAccount == '未分拣'">
  906. and ( df.login_account is null or df.login_account like '')
  907. </if>
  908. </where>
  909. ${maps.params.dataScope} GROUP BY sp.product_id
  910. ) AS t
  911. </select>
  912. <!-- 查询订单列表Zm -->
  913. <select id="selectLiveOrderListZm" parameterType="LiveOrder" resultType="com.fs.live.vo.LiveOrderVoZm">
  914. SELECT
  915. o.order_id,
  916. o.live_id,
  917. o.store_id,
  918. o.order_code,
  919. o.user_id,
  920. o.user_name,
  921. o.user_phone,
  922. o.user_address,
  923. o.cart_id,
  924. o.total_num,
  925. o.total_price,
  926. o.pay_price,
  927. o.pay_money,
  928. o.is_pay,
  929. o.pay_time,
  930. o.pay_type,
  931. o.create_time,
  932. o.update_time,
  933. o.status,
  934. o.refund_status,
  935. o.refund_img,
  936. o.refund_explain,
  937. o.refund_time,
  938. o.refund_reason,
  939. o.refund_money,
  940. o.delivery_code,
  941. o.delivery_name,
  942. o.delivery_sn,
  943. o.remark,
  944. o.is_del,
  945. o.cost_price,
  946. o.company_id,
  947. o.company_user_id,
  948. o.product_id,
  949. o.customer_id,
  950. o.coupon_price,
  951. o.cancel_reason,
  952. <!-- 销售信息 -->
  953. cu.nick_name AS companyUserNickName,
  954. cu.phonenumber AS companyUserPhone,
  955. cu.create_time AS companyUserCreateTime,
  956. <!-- 客户信息 -->
  957. u.user_code AS userCode,
  958. u.level AS userLevel,
  959. u.nick_name AS nickName,
  960. u.phone AS userBindPhone,
  961. u.order_count AS totalOrderCount,
  962. u.total_amount AS totalOrderAmount,
  963. u.status AS userStatus,
  964. u.update_time AS latestBindTime,
  965. <!-- 商品信息 -->
  966. p.product_name AS productName,
  967. p.cost AS costPrice,
  968. p.price AS price,
  969. p.cost AS cost,
  970. p.prescribe_spec AS productSpec,
  971. p.prescribe_factory AS supplierName,
  972. <!-- 门店信息 -->
  973. s.store_name AS storeName,
  974. s.store_id AS storeId
  975. FROM
  976. live_order o
  977. LEFT JOIN fs_user u ON o.user_id = u.user_id
  978. LEFT JOIN company_user cu ON o.company_user_id = cu.user_id
  979. LEFT JOIN fs_store_product_scrm p ON o.product_id = p.product_id
  980. LEFT JOIN fs_store_scrm s ON p.store_id = s.store_id
  981. <where>
  982. o.is_del = 0
  983. <if test="orderId != null">
  984. AND o.order_id = #{orderId}
  985. </if>
  986. <if test="liveId != null">
  987. AND o.live_id = #{liveId}
  988. </if>
  989. <if test="storeId != null">
  990. AND o.store_id = #{storeId}
  991. </if>
  992. <if test="orderCode != null and orderCode != ''">
  993. AND o.order_code LIKE CONCAT('%', #{orderCode}, '%')
  994. </if>
  995. <if test="userId != null and userId != ''">
  996. AND o.user_id = #{userId}
  997. </if>
  998. <if test="status != null">
  999. AND o.status = #{status}
  1000. </if>
  1001. <if test="companyId != null">
  1002. AND o.company_id = #{companyId}
  1003. </if>
  1004. <if test="totalNum != null">
  1005. AND o.total_num = #{totalNum}
  1006. </if>
  1007. <if test="price != null">
  1008. AND p.price = #{price}
  1009. </if>
  1010. <if test="cost != null">
  1011. AND p.cost = #{cost}
  1012. </if>
  1013. <if test="companyUserId != null">
  1014. AND o.company_user_id = #{companyUserId}
  1015. </if>
  1016. <if test="productId != null">
  1017. AND o.product_id = #{productId}
  1018. </if>
  1019. <!-- 新增筛选条件 -->
  1020. <if test="productName != null and productName != ''">
  1021. AND p.product_name LIKE CONCAT('%', #{productName}, '%')
  1022. </if>
  1023. <if test="productSpec != null and productSpec != ''">
  1024. AND p.prescribe_spec LIKE CONCAT('%', #{productSpec}, '%')
  1025. </if>
  1026. <if test="storeId != null and storeId != ''">
  1027. AND p.store_id #{storeId}
  1028. </if>
  1029. <if test="userAddress != null and userAddress != ''">
  1030. AND o.user_address LIKE CONCAT('%', #{userAddress}, '%')
  1031. </if>
  1032. <if test="createTimeStart != null and createTimeStart != ''">
  1033. AND o.create_time &gt;= #{createTimeStart}
  1034. </if>
  1035. <if test="createTimeEnd != null and createTimeEnd != ''">
  1036. AND o.create_time &lt;= #{createTimeEnd}
  1037. </if>
  1038. <if test="payStartTime != null and payStartTime != ''">
  1039. AND o.pay_time &gt;= #{payStartTime}
  1040. </if>
  1041. <if test="payEndTime != null and payEndTime != ''">
  1042. AND o.pay_time &lt;= #{payEndTime}
  1043. </if>
  1044. </where>
  1045. ORDER BY o.create_time DESC
  1046. </select>
  1047. <select id="getUnsettledOrder" resultType="com.fs.live.domain.LiveOrder">
  1048. SELECT
  1049. sos.*,
  1050. sps.bank_transaction_id
  1051. FROM
  1052. live_order sos
  1053. INNER JOIN live_order_payment sps ON sos.id = sps.order_id
  1054. WHERE
  1055. sos.is_del = 0 and
  1056. sos.is_pay = 1
  1057. AND sps.business_type = 2
  1058. AND sos.`status` = 2
  1059. AND sps.`status`=1
  1060. AND DATEDIFF(
  1061. NOW(),
  1062. sos.delivery_send_time
  1063. ) >= 3
  1064. </select>
  1065. <select id="getDeliveryNote" resultType="com.fs.live.vo.LiveOrderDeliveryNoteExportVO">
  1066. SELECT
  1067. CONCAT('AC', o.id) AS orderNumber,
  1068. o.user_name AS recipient,
  1069. o.user_phone AS recipientPhone,
  1070. o.user_address AS recipientAddress,
  1071. GROUP_CONCAT(
  1072. DISTINCT IFNULL(
  1073. CASE WHEN LENGTH(sps.product_name) > 0
  1074. THEN CONCAT(sps.product_name, '*', sois.num)
  1075. END, ''
  1076. )
  1077. SEPARATOR '+'
  1078. ) AS nameAndNumber,
  1079. sps.keyword
  1080. FROM
  1081. live_order o
  1082. LEFT JOIN live_order_item sois
  1083. ON sois.order_id = o.order_id
  1084. LEFT JOIN fs_store_product_scrm sps
  1085. ON sps.product_id = sois.product_id
  1086. LEFT JOIN fs_user u
  1087. ON o.user_id = u.user_id
  1088. LEFT JOIN company c
  1089. ON c.company_id = o.company_id
  1090. LEFT JOIN company_user cu
  1091. ON cu.user_id = o.company_user_id
  1092. LEFT JOIN (
  1093. SELECT DISTINCT order_id
  1094. FROM live_order_payment
  1095. WHERE is_pay_remain != 0 AND STATUS != 0
  1096. ) fp
  1097. ON o.id = fp.order_id
  1098. WHERE
  1099. o.is_del = 0 and
  1100. 1 = 1
  1101. <if test="maps.orderCode != null and maps.orderCode != ''">
  1102. AND o.order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
  1103. </if>
  1104. <if test="maps.userId != null">
  1105. AND o.user_id = #{maps.userId}
  1106. </if>
  1107. <if test="maps.deliveryId != null and maps.deliveryId != ''">
  1108. AND o.delivery_id = #{maps.deliveryId}
  1109. </if>
  1110. <if test="maps.nickname != null and maps.nickname != ''">
  1111. AND u.nickname LIKE CONCAT('%', #{maps.nickname}, '%')
  1112. </if>
  1113. <if test="maps.realName != null and maps.realName != ''">
  1114. AND o.user_name LIKE CONCAT('%', #{maps.realName}, '%')
  1115. </if>
  1116. <if test="maps.phone != null and maps.phone != ''">
  1117. AND u.phone LIKE CONCAT('%', #{maps.phone}, '%')
  1118. </if>
  1119. <if test="maps.userPhone != null and maps.userPhone != ''">
  1120. AND o.user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
  1121. </if>
  1122. <if test="maps.status == null">
  1123. AND o.status = 1
  1124. </if>
  1125. <if test="maps.status != null">
  1126. AND o.status = #{maps.status}
  1127. </if>
  1128. <if test="maps.deliveryStatus != null">
  1129. AND o.delivery_status = #{maps.deliveryStatus}
  1130. </if>
  1131. <if test="maps.deliveryPayStatus != null">
  1132. AND o.delivery_pay_status = #{maps.deliveryPayStatus}
  1133. </if>
  1134. <if test="maps.companyId != null">
  1135. AND o.company_id = #{maps.companyId}
  1136. </if>
  1137. <if test="maps.isHealth != null and maps.isHealth != ''">
  1138. AND o.company_id IS NULL
  1139. </if>
  1140. <if test="maps.notHealth != null and maps.notHealth != ''">
  1141. AND o.company_id IS NOT NULL
  1142. </if>
  1143. <if test="maps.companyUserId != null">
  1144. AND o.company_user_id = #{maps.companyUserId}
  1145. </if>
  1146. <if test="maps.companyUserNickName != null and maps.companyUserNickName != ''">
  1147. AND cu.nick_name LIKE CONCAT('%', #{maps.companyUserNickName}, '%')
  1148. </if>
  1149. <if test="maps.orderType != null">
  1150. AND o.order_type = #{maps.orderType}
  1151. </if>
  1152. <if test="maps.payType != null">
  1153. AND o.pay_type = #{maps.payType}
  1154. </if>
  1155. <if test="maps.createTimeList != null">
  1156. AND o.create_time >= STR_TO_DATE(#{maps.createTimeList[0]}, '%Y%m%d')
  1157. AND o.create_time &lt; DATE_ADD(STR_TO_DATE(#{maps.createTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
  1158. </if>
  1159. <if test="maps.payTimeList != null">
  1160. AND o.pay_time >= STR_TO_DATE(#{maps.payTimeList[0]}, '%Y%m%d')
  1161. AND o.pay_time &lt; DATE_ADD(STR_TO_DATE(#{maps.payTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
  1162. </if>
  1163. <if test="maps.deliverySendTimeList != null">
  1164. AND o.delivery_send_time >= STR_TO_DATE(#{maps.deliverySendTimeList[0]}, '%Y%m%d')
  1165. AND o.delivery_send_time &lt; DATE_ADD(STR_TO_DATE(#{maps.deliverySendTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
  1166. </if>
  1167. <if test="maps.deliveryImportTimeList != null">
  1168. AND o.delivery_import_time >= STR_TO_DATE(#{maps.deliveryImportTimeList[0]}, '%Y%m%d')
  1169. AND o.delivery_import_time &lt; DATE_ADD(STR_TO_DATE(#{maps.deliveryImportTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
  1170. </if>
  1171. <if test="maps.deptId != null">
  1172. AND (o.dept_id = #{maps.deptId}
  1173. OR o.dept_id IN (SELECT t.dept_id FROM company_dept t WHERE FIND_IN_SET(#{maps.deptId}, t.ancestors)))
  1174. </if>
  1175. <if test="maps.isUpload != null and maps.isUpload == 0">
  1176. AND o.certificates IS NULL
  1177. </if>
  1178. <if test="maps.scheduleId != null">
  1179. AND o.schedule_id = #{maps.scheduleId}
  1180. </if>
  1181. <if test="maps.isUpload != null and maps.isUpload == 1">
  1182. AND o.certificates IS NOT NULL
  1183. </if>
  1184. ${maps.params.dataScope}
  1185. AND o.paid = 1
  1186. GROUP BY o.id
  1187. LIMIT 10000;
  1188. </select>
  1189. <select id="selectLiveOrderCodeOpenIdInOrderCode" resultType="com.fs.live.vo.LiveOrderCodeOpenIdVo">
  1190. SELECT
  1191. os.order_id as id,
  1192. fu.phone,
  1193. fu.ma_open_id openId,
  1194. ois.json_info,
  1195. lop.bank_transaction_id outTransId
  1196. FROM
  1197. live_order os
  1198. INNER JOIN fs_user fu ON os.user_id = fu.user_id
  1199. INNER JOIN live_order_item ois ON ois.order_id = os.order_id
  1200. INNER JOIN live_order_payment lop ON os.order_id = lop.business_id
  1201. WHERE os.is_del = 0 and os.order_code IN
  1202. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  1203. #{item}
  1204. </foreach>
  1205. AND lop.`status` = 1
  1206. </select>
  1207. <update id="batchUpdateInOrderCode">
  1208. UPDATE live_order
  1209. <set>
  1210. delivery_sn = CASE
  1211. <foreach collection="list" item="item">
  1212. WHEN order_code = #{item.orderNumber} THEN #{item.deliverySn}
  1213. </foreach>
  1214. ELSE delivery_sn
  1215. END,
  1216. delivery_name = CASE
  1217. <foreach collection="list" item="item">
  1218. WHEN order_code = #{item.orderNumber} THEN #{item.logisticsCompany}
  1219. </foreach>
  1220. ELSE delivery_name
  1221. END,
  1222. delivery_id = CASE
  1223. <foreach collection="list" item="item">
  1224. WHEN order_code = #{item.orderNumber} THEN #{item.deliveryId}
  1225. </foreach>
  1226. ELSE delivery_id
  1227. END,
  1228. status = CASE
  1229. WHEN status = 1 THEN 2
  1230. ELSE status
  1231. END,
  1232. delivery_send_time = NOW()
  1233. </set>
  1234. WHERE order_code IN
  1235. <foreach collection="list" item="item" open="(" separator="," close=")">
  1236. #{item.orderNumber}
  1237. </foreach>
  1238. </update>
  1239. </mapper>