LiveOrderMapper.xml 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297
  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.pay_money,
  931. o.is_pay,
  932. o.pay_time,
  933. o.pay_type,
  934. o.pay_money,
  935. o.pay_delivery,
  936. o.create_time,
  937. o.update_time,
  938. o.status,
  939. o.refund_status,
  940. o.refund_img,
  941. o.refund_explain,
  942. o.refund_time,
  943. o.refund_reason,
  944. o.refund_money,
  945. o.delivery_code,
  946. o.delivery_name,
  947. o.delivery_sn,
  948. o.remark,
  949. o.is_del,
  950. o.cost_price,
  951. o.company_id,
  952. o.company_user_id,
  953. o.product_id,
  954. o.customer_id,
  955. o.coupon_price,
  956. o.cancel_reason,
  957. cu.nick_name AS companyUserNickName,
  958. cu.phonenumber AS companyUserPhone,
  959. cu.create_time AS companyUserCreateTime,
  960. u.user_code AS userCode,
  961. u.level AS userLevel,
  962. u.nick_name AS nickName,
  963. u.phone AS userBindPhone,
  964. u.order_count AS totalOrderCount,
  965. u.total_amount AS totalOrderAmount,
  966. u.status AS userStatus,
  967. u.update_time AS latestBindTime,
  968. p.product_name AS productName,
  969. p.cost AS costPrice,
  970. p.price AS price,
  971. p.cost AS cost,
  972. p.prescribe_spec AS productSpec,
  973. p.prescribe_factory AS supplierName,
  974. s.store_name AS storeName,
  975. s.store_id AS storeId,
  976. GROUP_CONCAT(DISTINCT spavs.bar_code SEPARATOR ',') AS bar_codes,
  977. spcs.cate_name,
  978. lop.bank_transaction_id AS bankTransactionId
  979. FROM
  980. live_order o
  981. LEFT JOIN fs_user u ON o.user_id = u.user_id
  982. LEFT JOIN company_user cu ON o.company_user_id = cu.user_id
  983. LEFT JOIN fs_store_product_scrm p ON o.product_id = p.product_id
  984. LEFT JOIN fs_store_scrm s ON p.store_id = s.store_id
  985. LEFT JOIN fs_store_product_attr_value_scrm spavs ON p.product_id = spavs.product_id
  986. LEFT JOIN fs_store_product_category_scrm spcs ON p.cate_id = spcs.cate_id
  987. LEFT JOIN (
  988. SELECT
  989. sp.*,
  990. ROW_NUMBER() OVER (PARTITION BY sp.business_code ORDER BY sp.create_time DESC) as rn
  991. FROM live_order_payment sp
  992. WHERE sp.business_code IS NOT NULL
  993. ) lop ON lop.business_code = o.order_code AND lop.rn = 1
  994. <where>
  995. o.is_del = 0 and p.product_id IS NOT NULL
  996. <if test="orderId != null">
  997. AND o.order_id = #{orderId}
  998. </if>
  999. <if test="liveId != null">
  1000. AND o.live_id = #{liveId}
  1001. </if>
  1002. <if test="storeId != null">
  1003. AND o.store_id = #{storeId}
  1004. </if>
  1005. <if test="orderCode != null and orderCode != ''">
  1006. AND o.order_code LIKE CONCAT('%', #{orderCode}, '%')
  1007. </if>
  1008. <if test="userId != null and userId != ''">
  1009. AND o.user_id = #{userId}
  1010. </if>
  1011. <if test="status != null">
  1012. AND o.status = #{status}
  1013. </if>
  1014. <if test="companyId != null">
  1015. AND o.company_id = #{companyId}
  1016. </if>
  1017. <if test="totalNum != null">
  1018. AND o.total_num = #{totalNum}
  1019. </if>
  1020. <if test="price != null">
  1021. AND p.price = #{price}
  1022. </if>
  1023. <if test="cost != null">
  1024. AND p.cost = #{cost}
  1025. </if>
  1026. <if test="companyUserId != null">
  1027. AND o.company_user_id = #{companyUserId}
  1028. </if>
  1029. <if test="productId != null">
  1030. AND o.product_id = #{productId}
  1031. </if>
  1032. <!-- 新增筛选条件 -->
  1033. <if test="productName != null and productName != ''">
  1034. AND p.product_name LIKE CONCAT('%', #{productName}, '%')
  1035. </if>
  1036. <if test="productSpec != null and productSpec != ''">
  1037. AND p.prescribe_spec LIKE CONCAT('%', #{productSpec}, '%')
  1038. </if>
  1039. <if test="storeId != null and storeId != ''">
  1040. AND p.store_id = #{storeId}
  1041. </if>
  1042. <if test="userAddress != null and userAddress != ''">
  1043. AND o.user_address LIKE CONCAT('%', #{userAddress}, '%')
  1044. </if>
  1045. <if test="userName != null and userName != ''">
  1046. AND o.user_name LIKE CONCAT('%', #{userName}, '%')
  1047. </if>
  1048. <if test="createTimeStart != null ">
  1049. AND o.create_time &gt;= #{createTimeStart}
  1050. </if>
  1051. <if test="createTimeEnd != null ">
  1052. AND o.create_time &lt;= #{createTimeEnd}
  1053. </if>
  1054. <if test="payStartTime != null ">
  1055. AND o.pay_time &gt;= #{payStartTime}
  1056. </if>
  1057. <if test="payEndTime != null ">
  1058. AND o.pay_time &lt;= #{payEndTime}
  1059. </if>
  1060. <if test="userPhone != null and userPhone != ''">
  1061. AND o.user_phone = #{userPhone}
  1062. </if>
  1063. </where>
  1064. GROUP BY o.order_id
  1065. ORDER BY o.create_time DESC
  1066. </select>
  1067. <select id="getUnsettledOrder" resultType="com.fs.live.domain.LiveOrder">
  1068. SELECT
  1069. sos.*,
  1070. sps.bank_transaction_id
  1071. FROM
  1072. live_order sos
  1073. INNER JOIN live_order_payment sps ON sos.id = sps.order_id
  1074. WHERE
  1075. sos.is_del = 0 and
  1076. sos.is_pay = 1
  1077. AND sps.business_type = 2
  1078. AND sos.`status` = 2
  1079. AND sps.`status`=1
  1080. AND DATEDIFF(
  1081. NOW(),
  1082. sos.delivery_send_time
  1083. ) >= 3
  1084. </select>
  1085. <select id="getDeliveryNote" resultType="com.fs.live.vo.LiveOrderDeliveryNoteExportVO">
  1086. SELECT
  1087. CONCAT('AC', o.order_id) AS orderNumber,
  1088. o.user_name AS recipient,
  1089. o.user_phone AS recipientPhone,
  1090. o.user_address AS recipientAddress,
  1091. GROUP_CONCAT(
  1092. DISTINCT IFNULL(
  1093. CASE WHEN LENGTH(sps.product_name) > 0
  1094. THEN CONCAT(sps.product_name, '*', sois.num)
  1095. END, ''
  1096. )
  1097. SEPARATOR '+'
  1098. ) AS nameAndNumber,
  1099. sps.keyword
  1100. FROM
  1101. live_order o
  1102. LEFT JOIN live_order_item sois
  1103. ON sois.order_id = o.order_id
  1104. LEFT JOIN fs_store_product_scrm sps
  1105. ON sps.product_id = sois.product_id
  1106. LEFT JOIN fs_user u
  1107. ON o.user_id = u.user_id
  1108. LEFT JOIN company c
  1109. ON c.company_id = o.company_id
  1110. LEFT JOIN company_user cu
  1111. ON cu.user_id = o.company_user_id
  1112. LEFT JOIN (
  1113. SELECT DISTINCT business_id as order_id
  1114. FROM live_order_payment
  1115. WHERE STATUS != 0
  1116. ) fp
  1117. ON o.order_id = fp.order_id
  1118. WHERE
  1119. o.is_del = 0 and
  1120. 1 = 1
  1121. <if test="maps.orderCode != null and maps.orderCode != ''">
  1122. AND o.order_code LIKE CONCAT('%', #{maps.orderCode}, '%')
  1123. </if>
  1124. <if test="maps.userId != null">
  1125. AND o.user_id = #{maps.userId}
  1126. </if>
  1127. <if test="maps.deliveryId != null and maps.deliveryId != ''">
  1128. AND o.delivery_id = #{maps.deliveryId}
  1129. </if>
  1130. <if test="maps.nickname != null and maps.nickname != ''">
  1131. AND u.nickname LIKE CONCAT('%', #{maps.nickname}, '%')
  1132. </if>
  1133. <if test="maps.realName != null and maps.realName != ''">
  1134. AND o.user_name LIKE CONCAT('%', #{maps.realName}, '%')
  1135. </if>
  1136. <if test="maps.phone != null and maps.phone != ''">
  1137. AND u.phone LIKE CONCAT('%', #{maps.phone}, '%')
  1138. </if>
  1139. <if test="maps.userPhone != null and maps.userPhone != ''">
  1140. AND o.user_phone LIKE CONCAT('%', #{maps.userPhone}, '%')
  1141. </if>
  1142. <if test="maps.status == null">
  1143. AND o.status = 1
  1144. </if>
  1145. <if test="maps.status != null">
  1146. AND o.status = #{maps.status}
  1147. </if>
  1148. <if test="maps.deliveryStatus != null">
  1149. AND o.delivery_status = #{maps.deliveryStatus}
  1150. </if>
  1151. <if test="maps.deliveryPayStatus != null">
  1152. AND o.delivery_pay_status = #{maps.deliveryPayStatus}
  1153. </if>
  1154. <if test="maps.companyId != null">
  1155. AND o.company_id = #{maps.companyId}
  1156. </if>
  1157. <if test="maps.isHealth != null and maps.isHealth != ''">
  1158. AND o.company_id IS NULL
  1159. </if>
  1160. <if test="maps.notHealth != null and maps.notHealth != ''">
  1161. AND o.company_id IS NOT NULL
  1162. </if>
  1163. <if test="maps.companyUserId != null">
  1164. AND o.company_user_id = #{maps.companyUserId}
  1165. </if>
  1166. <if test="maps.companyUserNickName != null and maps.companyUserNickName != ''">
  1167. AND cu.nick_name LIKE CONCAT('%', #{maps.companyUserNickName}, '%')
  1168. </if>
  1169. <if test="maps.orderType != null">
  1170. AND o.order_type = #{maps.orderType}
  1171. </if>
  1172. <if test="maps.payType != null">
  1173. AND o.pay_type = #{maps.payType}
  1174. </if>
  1175. <if test="maps.createTimeList != null">
  1176. AND o.create_time >= STR_TO_DATE(#{maps.createTimeList[0]}, '%Y%m%d')
  1177. AND o.create_time &lt; DATE_ADD(STR_TO_DATE(#{maps.createTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
  1178. </if>
  1179. <if test="maps.payTimeList != null">
  1180. AND o.pay_time >= STR_TO_DATE(#{maps.payTimeList[0]}, '%Y%m%d')
  1181. AND o.pay_time &lt; DATE_ADD(STR_TO_DATE(#{maps.payTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
  1182. </if>
  1183. <if test="maps.deliverySendTimeList != null">
  1184. AND o.delivery_send_time >= STR_TO_DATE(#{maps.deliverySendTimeList[0]}, '%Y%m%d')
  1185. AND o.delivery_send_time &lt; DATE_ADD(STR_TO_DATE(#{maps.deliverySendTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
  1186. </if>
  1187. <if test="maps.deliveryImportTimeList != null">
  1188. AND o.delivery_import_time >= STR_TO_DATE(#{maps.deliveryImportTimeList[0]}, '%Y%m%d')
  1189. AND o.delivery_import_time &lt; DATE_ADD(STR_TO_DATE(#{maps.deliveryImportTimeList[1]}, '%Y%m%d'), INTERVAL 1 DAY)
  1190. </if>
  1191. <if test="maps.deptId != null">
  1192. AND (o.dept_id = #{maps.deptId}
  1193. OR o.dept_id IN (SELECT t.dept_id FROM company_dept t WHERE FIND_IN_SET(#{maps.deptId}, t.ancestors)))
  1194. </if>
  1195. <if test="maps.isUpload != null and maps.isUpload == 0">
  1196. AND o.certificates IS NULL
  1197. </if>
  1198. <if test="maps.scheduleId != null">
  1199. AND o.schedule_id = #{maps.scheduleId}
  1200. </if>
  1201. <if test="maps.isUpload != null and maps.isUpload == 1">
  1202. AND o.certificates IS NOT NULL
  1203. </if>
  1204. ${maps.params.dataScope}
  1205. AND o.paid = 1
  1206. GROUP BY o.id
  1207. LIMIT 10000;
  1208. </select>
  1209. <select id="selectLiveOrderCodeOpenIdInOrderCode" resultType="com.fs.live.vo.LiveOrderCodeOpenIdVo">
  1210. SELECT
  1211. os.order_id as id,
  1212. fu.phone,
  1213. fu.ma_open_id openId,
  1214. ois.json_info,
  1215. lop.bank_transaction_id outTransId
  1216. FROM
  1217. live_order os
  1218. INNER JOIN fs_user fu ON os.user_id = fu.user_id
  1219. INNER JOIN live_order_item ois ON ois.order_id = os.order_id
  1220. INNER JOIN live_order_payment lop ON os.order_id = lop.business_id
  1221. WHERE os.is_del = 0 and os.order_code IN
  1222. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  1223. #{item}
  1224. </foreach>
  1225. AND lop.`status` = 1
  1226. </select>
  1227. <update id="batchUpdateInOrderCode">
  1228. UPDATE live_order
  1229. <set>
  1230. delivery_sn = CASE
  1231. <foreach collection="list" item="item">
  1232. WHEN order_code = #{item.orderNumber} THEN #{item.deliverySn}
  1233. </foreach>
  1234. ELSE delivery_sn
  1235. END,
  1236. delivery_name = CASE
  1237. <foreach collection="list" item="item">
  1238. WHEN order_code = #{item.orderNumber} THEN #{item.logisticsCompany}
  1239. </foreach>
  1240. ELSE delivery_name
  1241. END,
  1242. delivery_id = CASE
  1243. <foreach collection="list" item="item">
  1244. WHEN order_code = #{item.orderNumber} THEN #{item.deliveryId}
  1245. </foreach>
  1246. ELSE delivery_id
  1247. END,
  1248. status = CASE
  1249. WHEN status = 1 THEN 2
  1250. ELSE status
  1251. END,
  1252. delivery_send_time = NOW()
  1253. </set>
  1254. WHERE order_code IN
  1255. <foreach collection="list" item="item" open="(" separator="," close=")">
  1256. #{item.orderNumber}
  1257. </foreach>
  1258. </update>
  1259. </mapper>