LiveOrderMapper.xml 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419
  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="orderId != null">
  996. AND o.order_id = #{orderId}
  997. </if>
  998. <if test="liveId != null">
  999. AND o.live_id = #{liveId}
  1000. </if>
  1001. <if test="storeId != null">
  1002. AND o.store_id = #{storeId}
  1003. </if>
  1004. <if test="orderCode != null and orderCode != ''">
  1005. AND o.order_code LIKE CONCAT('%', #{orderCode}, '%')
  1006. </if>
  1007. <if test="userId != null and userId != ''">
  1008. AND o.user_id = #{userId}
  1009. </if>
  1010. <if test="status != null">
  1011. AND o.status = #{status}
  1012. </if>
  1013. <if test="companyId != null">
  1014. AND o.company_id = #{companyId}
  1015. </if>
  1016. <if test="totalNum != null">
  1017. AND o.total_num = #{totalNum}
  1018. </if>
  1019. <if test="price != null">
  1020. AND p.price = #{price}
  1021. </if>
  1022. <if test="cost != null">
  1023. AND p.cost = #{cost}
  1024. </if>
  1025. <if test="companyUserId != null">
  1026. AND o.company_user_id = #{companyUserId}
  1027. </if>
  1028. <if test="productId != null">
  1029. AND o.product_id = #{productId}
  1030. </if>
  1031. <!-- 新增筛选条件 -->
  1032. <if test="productName != null and productName != ''">
  1033. AND p.product_name LIKE CONCAT('%', #{productName}, '%')
  1034. </if>
  1035. <if test="productSpec != null and productSpec != ''">
  1036. AND p.prescribe_spec LIKE CONCAT('%', #{productSpec}, '%')
  1037. </if>
  1038. <if test="storeId != null and storeId != ''">
  1039. AND p.store_id = #{storeId}
  1040. </if>
  1041. <if test="userAddress != null and userAddress != ''">
  1042. AND o.user_address LIKE CONCAT('%', #{userAddress}, '%')
  1043. </if>
  1044. <if test="userName != null and userName != ''">
  1045. AND o.user_name LIKE CONCAT('%', #{userName}, '%')
  1046. </if>
  1047. <if test="createTimeStart != null ">
  1048. AND o.create_time &gt;= #{createTimeStart}
  1049. </if>
  1050. <if test="createTimeEnd != null ">
  1051. AND o.create_time &lt;= #{createTimeEnd}
  1052. </if>
  1053. <if test="payStartTime != null ">
  1054. AND o.pay_time &gt;= #{payStartTime}
  1055. </if>
  1056. <if test="payEndTime != null ">
  1057. AND o.pay_time &lt;= #{payEndTime}
  1058. </if>
  1059. <if test="userPhone != null and userPhone != ''">
  1060. AND o.user_phone = #{userPhone}
  1061. </if>
  1062. </where>
  1063. GROUP BY o.order_id
  1064. ORDER BY o.create_time DESC
  1065. </select>
  1066. <select id="selectLiveOrderListZmNew" parameterType="LiveOrder" resultType="com.fs.hisStore.vo.FsStoreOrderItemExportZMVO">
  1067. select
  1068. t1.order_code as orderCode,
  1069. t1.status,
  1070. t1.user_id as userId,
  1071. if(JSON_VALID(t2.json_info),t2.json_info->>'$.productName','') as productName,
  1072. if(JSON_VALID(t2.json_info),t2.json_info->>'$.barCode','') as barCode,
  1073. if(JSON_VALID(t2.json_info),t2.json_info->>'$.sku','') as sku,
  1074. if(JSON_VALID(t2.json_info),t2.json_info->>'$.price','') as price,
  1075. t2.num,
  1076. fsps.cost,
  1077. fspcs.cate_name as cateName,
  1078. t1.user_name as realName,
  1079. t1.user_phone as userPhone,
  1080. t1.user_address as userAddress,
  1081. t1.create_time as createTime,
  1082. t1.pay_time as payTime,
  1083. t1.delivery_sn as deliveryId,
  1084. t1.delivery_name as deliveryName,
  1085. t1.delivery_code as deliverySn,
  1086. t3.company_name as companyName,
  1087. t4.nick_name as companyUserNickName,
  1088. lop.bank_transaction_id as bankTransactionId
  1089. from
  1090. live_order t1
  1091. left join live_order_item t2 on t1.order_id = t2.order_id
  1092. left join fs_store_product_scrm fsps on fsps.product_id = t2.product_id
  1093. left join fs_store_product_category_scrm fspcs on fspcs.cate_id = fsps.cate_id
  1094. left join company t3 on t1.company_id = t3.company_id
  1095. left join company_user t4 on t4.user_id = t1.company_user_id
  1096. LEFT JOIN (
  1097. SELECT
  1098. t5.*,
  1099. ROW_NUMBER() OVER (PARTITION BY t5.business_code ORDER BY t5.status desc,t5.create_time DESC) as rn
  1100. FROM live_order_payment t5
  1101. WHERE t5.business_id IS NOT NULL
  1102. ) lop ON lop.business_id = t1.order_id AND lop.rn = 1
  1103. <where>
  1104. t1.is_del = 0 and fsps.product_id IS NOT NULL
  1105. <if test="orderId != null">
  1106. AND t1.order_id = #{orderId}
  1107. </if>
  1108. <if test="liveId != null">
  1109. AND t1.live_id = #{liveId}
  1110. </if>
  1111. <if test="storeId != null">
  1112. AND t1.store_id = #{storeId}
  1113. </if>
  1114. <if test="orderCode != null and orderCode != ''">
  1115. AND t1.order_code LIKE CONCAT('%', #{orderCode}, '%')
  1116. </if>
  1117. <if test="userId != null and userId != ''">
  1118. AND t1.user_id = #{userId}
  1119. </if>
  1120. <if test="status != null">
  1121. AND t1.status = #{status}
  1122. </if>
  1123. <if test="companyId != null">
  1124. AND t1.company_id = #{companyId}
  1125. </if>
  1126. <if test="totalNum != null">
  1127. AND t1.total_num = #{totalNum}
  1128. </if>
  1129. <if test="price != null">
  1130. AND fsps.price = #{price}
  1131. </if>
  1132. <if test="cost != null">
  1133. AND fsps.cost = #{cost}
  1134. </if>
  1135. <if test="companyUserId != null">
  1136. AND t1.company_user_id = #{companyUserId}
  1137. </if>
  1138. <if test="productId != null">
  1139. AND t1.product_id = #{productId}
  1140. </if>
  1141. <!-- 新增筛选条件 -->
  1142. <if test="productName != null and productName != ''">
  1143. AND fsps.product_name LIKE CONCAT('%', #{productName}, '%')
  1144. </if>
  1145. <if test="productSpec != null and productSpec != ''">
  1146. AND fsps.prescribe_spec LIKE CONCAT('%', #{productSpec}, '%')
  1147. </if>
  1148. <if test="storeId != null and storeId != ''">
  1149. AND fsps.store_id = #{storeId}
  1150. </if>
  1151. <if test="userAddress != null and userAddress != ''">
  1152. AND t1.user_address LIKE CONCAT('%', #{userAddress}, '%')
  1153. </if>
  1154. <if test="userName != null and userName != ''">
  1155. AND t1.user_name LIKE CONCAT('%', #{userName}, '%')
  1156. </if>
  1157. <if test="createTimeStart != null ">
  1158. AND t1.create_time &gt;= #{createTimeStart}
  1159. </if>
  1160. <if test="createTimeEnd != null ">
  1161. AND t1.create_time &lt;= #{createTimeEnd}
  1162. </if>
  1163. <if test="payStartTime != null ">
  1164. AND t1.pay_time &gt;= #{payStartTime}
  1165. </if>
  1166. <if test="payEndTime != null ">
  1167. AND t1.pay_time &lt;= #{payEndTime}
  1168. </if>
  1169. <if test="userPhone != null and userPhone != ''">
  1170. AND t1.user_phone = #{userPhone}
  1171. </if>
  1172. </where>
  1173. GROUP BY t1.order_id
  1174. </select>
  1175. <select id="getUnsettledOrder" resultType="com.fs.live.domain.LiveOrder">
  1176. SELECT
  1177. sos.*,
  1178. sps.bank_transaction_id
  1179. FROM
  1180. live_order sos
  1181. INNER JOIN live_order_payment sps ON sos.id = sps.order_id
  1182. WHERE
  1183. sos.is_del = 0 and
  1184. sos.is_pay = 1
  1185. AND sps.business_type = 2
  1186. AND sos.`status` = 2
  1187. AND sps.`status`=1
  1188. AND DATEDIFF(
  1189. NOW(),
  1190. sos.delivery_send_time
  1191. ) >= 3
  1192. </select>
  1193. <select id="getDeliveryNote" resultType="com.fs.live.vo.LiveOrderDeliveryNoteExportVO">
  1194. SELECT
  1195. CONCAT('AC', o.order_id) AS orderNumber,
  1196. o.user_name AS recipient,
  1197. o.user_phone AS recipientPhone,
  1198. o.user_address AS recipientAddress,
  1199. GROUP_CONCAT(
  1200. DISTINCT IFNULL(
  1201. CASE WHEN LENGTH(sps.product_name) > 0
  1202. THEN CONCAT(sps.product_name, '*', sois.num)
  1203. END, ''
  1204. )
  1205. SEPARATOR '+'
  1206. ) AS nameAndNumber,
  1207. sps.keyword
  1208. FROM
  1209. live_order o
  1210. LEFT JOIN live_order_item sois
  1211. ON sois.order_id = o.order_id
  1212. LEFT JOIN fs_store_product_scrm sps
  1213. ON sps.product_id = sois.product_id
  1214. LEFT JOIN fs_user u
  1215. ON o.user_id = u.user_id
  1216. LEFT JOIN company c
  1217. ON c.company_id = o.company_id
  1218. LEFT JOIN company_user cu
  1219. ON cu.user_id = o.company_user_id
  1220. LEFT JOIN (
  1221. SELECT DISTINCT business_id as order_id
  1222. FROM live_order_payment
  1223. WHERE STATUS != 0
  1224. ) fp
  1225. ON o.order_id = fp.order_id
  1226. WHERE
  1227. o.is_del = 0 and
  1228. 1 = 1
  1229. <if test="maps.orderCode != null and maps.orderCode != ''">
  1230. AND o.order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
  1231. </if>
  1232. <if test="maps.userId != null">
  1233. AND o.user_id = #{maps.userId}
  1234. </if>
  1235. <if test="maps.deliveryId != null and maps.deliveryId != ''">
  1236. AND o.delivery_id = #{maps.deliveryId}
  1237. </if>
  1238. <if test="maps.nickname != null and maps.nickname != ''">
  1239. AND u.nickname LIKE CONCAT('%', #{maps.nickname}, '%')
  1240. </if>
  1241. <if test="maps.realName != null and maps.realName != ''">
  1242. AND o.user_name LIKE CONCAT('%', #{maps.realName}, '%')
  1243. </if>
  1244. <if test="maps.phone != null and maps.phone != ''">
  1245. AND u.phone LIKE CONCAT('%', #{maps.phone}, '%')
  1246. </if>
  1247. <if test="maps.userPhone != null and maps.userPhone != ''">
  1248. AND o.user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
  1249. </if>
  1250. <if test="maps.status == null">
  1251. AND o.status = 1
  1252. </if>
  1253. <if test="maps.status != null">
  1254. AND o.status = #{maps.status}
  1255. </if>
  1256. <if test="maps.deliveryStatus != null">
  1257. AND o.delivery_status = #{maps.deliveryStatus}
  1258. </if>
  1259. <if test="maps.deliveryPayStatus != null">
  1260. AND o.delivery_pay_status = #{maps.deliveryPayStatus}
  1261. </if>
  1262. <if test="maps.companyId != null">
  1263. AND o.company_id = #{maps.companyId}
  1264. </if>
  1265. <if test="maps.isHealth != null and maps.isHealth != ''">
  1266. AND o.company_id IS NULL
  1267. </if>
  1268. <if test="maps.notHealth != null and maps.notHealth != ''">
  1269. AND o.company_id IS NOT NULL
  1270. </if>
  1271. <if test="maps.companyUserId != null">
  1272. AND o.company_user_id = #{maps.companyUserId}
  1273. </if>
  1274. <if test="maps.companyUserNickName != null and maps.companyUserNickName != ''">
  1275. AND cu.nick_name LIKE CONCAT('%', #{maps.companyUserNickName}, '%')
  1276. </if>
  1277. <if test="maps.orderType != null">
  1278. AND o.order_type = #{maps.orderType}
  1279. </if>
  1280. <if test="maps.payType != null">
  1281. AND o.pay_type = #{maps.payType}
  1282. </if>
  1283. <if test="maps.createTimeList != null">
  1284. AND o.create_time >= STR_TO_DATE(#{maps.createTimeList[0]}, '%Y%m%d')
  1285. AND o.create_time &lt; DATE_ADD(STR_TO_DATE(#{maps.createTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
  1286. </if>
  1287. <if test="maps.payTimeList != null">
  1288. AND o.pay_time >= STR_TO_DATE(#{maps.payTimeList[0]}, '%Y%m%d')
  1289. AND o.pay_time &lt; DATE_ADD(STR_TO_DATE(#{maps.payTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
  1290. </if>
  1291. <if test="maps.deliverySendTimeList != null">
  1292. AND o.delivery_send_time >= STR_TO_DATE(#{maps.deliverySendTimeList[0]}, '%Y%m%d')
  1293. AND o.delivery_send_time &lt; DATE_ADD(STR_TO_DATE(#{maps.deliverySendTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
  1294. </if>
  1295. <if test="maps.deliveryImportTimeList != null">
  1296. AND o.delivery_import_time >= STR_TO_DATE(#{maps.deliveryImportTimeList[0]}, '%Y%m%d')
  1297. AND o.delivery_import_time &lt; DATE_ADD(STR_TO_DATE(#{maps.deliveryImportTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
  1298. </if>
  1299. <if test="maps.deptId != null">
  1300. AND (o.dept_id = #{maps.deptId}
  1301. OR o.dept_id IN (SELECT t.dept_id FROM company_dept t WHERE FIND_IN_SET(#{maps.deptId}, t.ancestors)))
  1302. </if>
  1303. <if test="maps.isUpload != null and maps.isUpload == 0">
  1304. AND o.certificates IS NULL
  1305. </if>
  1306. <if test="maps.scheduleId != null">
  1307. AND o.schedule_id = #{maps.scheduleId}
  1308. </if>
  1309. <if test="maps.isUpload != null and maps.isUpload == 1">
  1310. AND o.certificates IS NOT NULL
  1311. </if>
  1312. ${maps.params.dataScope}
  1313. AND o.paid = 1
  1314. GROUP BY o.id
  1315. LIMIT 10000;
  1316. </select>
  1317. <select id="selectLiveOrderCodeOpenIdInOrderCode" resultType="com.fs.live.vo.LiveOrderCodeOpenIdVo">
  1318. SELECT
  1319. os.order_id as id,
  1320. fu.phone,
  1321. fu.ma_open_id openId,
  1322. ois.json_info,
  1323. lop.bank_transaction_id outTransId
  1324. FROM
  1325. live_order os
  1326. INNER JOIN fs_user fu ON os.user_id = fu.user_id
  1327. INNER JOIN live_order_item ois ON ois.order_id = os.order_id
  1328. INNER JOIN live_order_payment lop ON os.order_id = lop.business_id
  1329. WHERE os.is_del = 0 and os.order_code IN
  1330. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  1331. #{item}
  1332. </foreach>
  1333. AND lop.`status` = 1
  1334. </select>
  1335. <update id="batchUpdateInOrderCode">
  1336. UPDATE live_order
  1337. <set>
  1338. delivery_sn = CASE
  1339. <foreach collection="list" item="item">
  1340. WHEN order_code = #{item.orderNumber} THEN #{item.deliverySn}
  1341. </foreach>
  1342. ELSE delivery_sn
  1343. END,
  1344. delivery_name = CASE
  1345. <foreach collection="list" item="item">
  1346. WHEN order_code = #{item.orderNumber} THEN #{item.logisticsCompany}
  1347. </foreach>
  1348. ELSE delivery_name
  1349. END,
  1350. delivery_id = CASE
  1351. <foreach collection="list" item="item">
  1352. WHEN order_code = #{item.orderNumber} THEN #{item.deliveryId}
  1353. </foreach>
  1354. ELSE delivery_id
  1355. END,
  1356. status = CASE
  1357. WHEN status = 1 THEN 2
  1358. ELSE status
  1359. END,
  1360. delivery_send_time = NOW()
  1361. </set>
  1362. WHERE order_code IN
  1363. <foreach collection="list" item="item" open="(" separator="," close=")">
  1364. #{item.orderNumber}
  1365. </foreach>
  1366. </update>
  1367. <update id="batchUpdateTime">
  1368. UPDATE live_order
  1369. SET update_time = CASE
  1370. <foreach collection="list" item="item" separator="">
  1371. WHEN order_id = #{item.orderId} THEN #{item.updateTime}
  1372. </foreach>
  1373. END
  1374. WHERE order_id IN
  1375. <foreach collection="list" item="item" open="(" separator="," close=")">
  1376. #{item.orderId}
  1377. </foreach>
  1378. </update>
  1379. </mapper>