OrderDao.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.kmall.admin.dao.OrderDao">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.admin.entity.OrderEntity" id="orderMap">
  6. <result property="id" column="id"/>
  7. <result property="orderSn" column="order_sn"/>
  8. <result property="userId" column="user_id"/>
  9. <result property="orderStatus" column="order_status"/>
  10. <result property="shippingStatus" column="shipping_status"/>
  11. <result property="payStatus" column="pay_status"/>
  12. <result property="consignee" column="consignee"/>
  13. <result property="country" column="country"/>
  14. <result property="province" column="province"/>
  15. <result property="city" column="city"/>
  16. <result property="district" column="district"/>
  17. <result property="address" column="address"/>
  18. <result property="mobile" column="mobile"/>
  19. <result property="postscript" column="postscript"/>
  20. <result property="shippingId" column="shipping_id"/>
  21. <result property="shippingName" column="shipping_name"/>
  22. <result property="shippingCode" column="shipping_code"/>
  23. <result property="shippingNo" column="shipping_no"/>
  24. <result property="payId" column="pay_id"/>
  25. <result property="payName" column="pay_name"/>
  26. <result property="shippingFee" column="shipping_fee"/>
  27. <result property="actualPrice" column="actual_price"/>
  28. <result property="integral" column="integral"/>
  29. <result property="integralMoney" column="integral_money"/>
  30. <result property="orderPrice" column="order_price"/>
  31. <result property="goodsPrice" column="goods_price"/>
  32. <result property="addTime" column="add_time"/>
  33. <result property="confirmTime" column="confirm_time"/>
  34. <result property="payTime" column="pay_time"/>
  35. <result property="freightPrice" column="freight_price"/>
  36. <result property="couponId" column="coupon_id"/>
  37. <result property="parentId" column="parent_id"/>
  38. <result property="couponPrice" column="coupon_price"/>
  39. <result property="callbackStatus" column="callback_status"/>
  40. <result property="orderType" column="order_type"/>
  41. <result property="storeId" column="store_id"/>
  42. <result property="userName" column="username"/>
  43. <result property="orderType" column="order_type"/>
  44. <result property="activityId" column="activity_id"/>
  45. <result property="deliveryDate" column="delivery_date"/>
  46. <result property="deliveryRemark" column="delivery_remark"/>
  47. <result property="predictTime" column="predict_time"/>
  48. <result property="orderBizType" column="order_biz_type"/>
  49. <result property="isPaymentSend" column="is_payment_send"/>
  50. <result property="isEleOrderSend" column="is_ele_order_send"/>
  51. <result property="isCustomsSend" column="is_customs_send"/>
  52. <result column="buyer_pay_check" property="buyerPayCheck"/>
  53. </resultMap>
  54. <select id="queryObject" resultType="com.kmall.admin.entity.OrderEntity">
  55. select o.*,u.username as username
  56. from mall_order o
  57. left join mall_user u on o.user_id = u.id
  58. where o.id = #{value}
  59. </select>
  60. <select id="queryObjectByActivityId" resultType="com.kmall.admin.entity.OrderEntity">
  61. select o.*,u.username as username
  62. from mall_order o
  63. left join mall_user u on o.user_id = u.id
  64. where o.activity_id = #{activityId} and o.order_type = #{orderType}
  65. </select>
  66. <select id="getTotalActualPrice" resultType="java.lang.Double">
  67. select sum(a.actual_price) 'totalActualPrice' from mall_order a where merch_order_sn = #{merchOrderSn}
  68. </select>
  69. <select id="queryList" resultType="com.kmall.admin.entity.OrderEntity">
  70. SELECT
  71. o.*,
  72. u.username AS username,
  73. p.is_payment_send,
  74. p.is_ele_order_send,
  75. p.is_customs_send
  76. FROM
  77. mall_order o
  78. LEFT JOIN mall_user u ON o.user_id = u.id
  79. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  80. WHERE 1=1
  81. <if test="storeId != null">
  82. AND o.store_id = #{storeId}
  83. </if>
  84. <if test="orderSn != null and orderSn.trim() != ''">
  85. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  86. </if>
  87. <if test="shippingStatus != null">
  88. AND o.shipping_status = #{shippingStatus}
  89. </if>
  90. <if test="payStatus != null">
  91. AND o.pay_status = #{payStatus}
  92. </if>
  93. <if test="orderStatus != null and orderStatus.trim() != ''">
  94. AND o.order_status = #{orderStatus}
  95. </if>
  96. <if test="shippingId != null and shippingId != 0">
  97. AND o.shipping_id = #{shippingId}
  98. </if>
  99. <if test="orderType != null and orderType.trim() != ''">
  100. AND o.order_type = #{orderType}
  101. </if>
  102. <if test="ids != null and ids.trim() != ''">
  103. AND o.id in (${ids})
  104. </if>
  105. <choose>
  106. <when test="sidx != null and sidx.trim() != ''">
  107. order by ${sidx} ${order}
  108. </when>
  109. <otherwise>
  110. order by id desc
  111. </otherwise>
  112. </choose>
  113. <if test="offset != null and limit != null">
  114. limit #{offset}, #{limit}
  115. </if>
  116. </select>
  117. <select id="queryTotal" resultType="int">
  118. select count(*) from mall_order o WHERE 1=1
  119. <if test="storeId != null">
  120. AND o.store_id = #{storeId}
  121. </if>
  122. <if test="orderSn != null and orderSn.trim() != ''">
  123. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  124. </if>
  125. <if test="shippingStatus != null">
  126. AND o.shipping_status = #{shippingStatus}
  127. </if>
  128. <if test="payStatus != null">
  129. AND o.pay_status = #{payStatus}
  130. </if>
  131. <if test="orderStatus != null and orderStatus.trim() != ''">
  132. AND o.order_status = #{orderStatus}
  133. </if>
  134. <if test="shippingId != null and shippingId != 0">
  135. AND o.shipping_id = #{shippingId}
  136. </if>
  137. <if test="orderType != null and orderType.trim() != ''">
  138. AND o.order_type = #{orderType}
  139. </if>
  140. <if test="ids != null and ids.trim() != ''">
  141. AND o.id in (${ids})
  142. </if>
  143. </select>
  144. <insert id="save" parameterType="com.kmall.admin.entity.OrderEntity" useGeneratedKeys="true" keyProperty="id">
  145. insert into mall_order
  146. (
  147. `order_sn`,
  148. `user_id`,
  149. `order_status`,
  150. `shipping_status`,
  151. `pay_status`,
  152. `consignee`,
  153. `country`,
  154. `province`,
  155. `city`,
  156. `district`,
  157. `address`,
  158. `mobile`,
  159. `postscript`,
  160. `shipping_id`,
  161. `shipping_name`,
  162. `shipping_code`,
  163. `shipping_no`,
  164. `pay_id`,
  165. `pay_name`,
  166. `shipping_fee`,
  167. `actual_price`,
  168. `integral`,
  169. `integral_money`,
  170. `order_price`,
  171. `goods_price`,
  172. `add_time`,
  173. `confirm_time`,
  174. `pay_time`,
  175. `freight_price`,
  176. `coupon_id`,
  177. `parent_id`,
  178. `coupon_price`,
  179. `callback_status`,
  180. `order_type`,
  181. `store_id`,
  182. `order_biz_type`
  183. )
  184. values
  185. (
  186. #{orderSn},
  187. #{userId},
  188. #{orderStatus},
  189. #{shippingStatus},
  190. #{payStatus},
  191. #{consignee},
  192. #{country},
  193. #{province},
  194. #{city},
  195. #{district},
  196. #{address},
  197. #{mobile},
  198. #{postscript},
  199. #{shippingId},
  200. #{shippingName},
  201. #{shippingCode},
  202. #{shippingNo},
  203. #{payId},
  204. #{payName},
  205. #{shippingFee},
  206. #{actualPrice},
  207. #{integral},
  208. #{integralMoney},
  209. #{orderPrice},
  210. #{goodsPrice},
  211. #{addTime},
  212. #{confirmTime},
  213. #{payTime},
  214. #{freightPrice},
  215. #{couponId},
  216. #{parentId},
  217. #{couponPrice},
  218. #{callbackStatus},
  219. #{orderType},
  220. #{storeId},
  221. #{orderBizType}
  222. )
  223. </insert>
  224. <update id="update" parameterType="com.kmall.admin.entity.OrderEntity">
  225. update mall_order
  226. <set>
  227. <if test="orderSn != null">`order_sn` = #{orderSn},</if>
  228. <if test="userId != null">`user_id` = #{userId},</if>
  229. <if test="orderStatus != null">`order_status` = #{orderStatus},</if>
  230. <if test="shippingStatus != null">`shipping_status` = #{shippingStatus},</if>
  231. <if test="payStatus != null">`pay_status` = #{payStatus},</if>
  232. <if test="consignee != null">`consignee` = #{consignee},</if>
  233. <if test="country != null">`country` = #{country},</if>
  234. <if test="province != null">`province` = #{province},</if>
  235. <if test="city != null">`city` = #{city},</if>
  236. <if test="district != null">`district` = #{district},</if>
  237. <if test="address != null">`address` = #{address},</if>
  238. <if test="mobile != null">`mobile` = #{mobile},</if>
  239. <if test="postscript != null">`postscript` = #{postscript},</if>
  240. <if test="shippingId != null">`shipping_id` = #{shippingId},</if>
  241. <if test="shippingName != null">`shipping_name` = #{shippingName},</if>
  242. <if test="shippingCode != null">`shipping_code` = #{shippingCode},</if>
  243. <if test="shippingNo != null">`shipping_no` = #{shippingNo},</if>
  244. <if test="payId != null">`pay_id` = #{payId},</if>
  245. <if test="payName != null">`pay_name` = #{payName},</if>
  246. <if test="shippingFee != null">`shipping_fee` = #{shippingFee},</if>
  247. <if test="actualPrice != null">`actual_price` = #{actualPrice},</if>
  248. <if test="integral != null">`integral` = #{integral},</if>
  249. <if test="integralMoney != null">`integral_money` = #{integralMoney},</if>
  250. <if test="orderPrice != null">`order_price` = #{orderPrice},</if>
  251. <if test="goodsPrice != null">`goods_price` = #{goodsPrice},</if>
  252. <if test="addTime != null">`add_time` = #{addTime},</if>
  253. <if test="confirmTime != null">`confirm_time` = #{confirmTime},</if>
  254. <if test="payTime != null">`pay_time` = #{payTime},</if>
  255. <if test="freightPrice != null">`freight_price` = #{freightPrice},</if>
  256. <if test="couponId != null">`coupon_id` = #{couponId},</if>
  257. <if test="parentId != null">`parent_id` = #{parentId},</if>
  258. <if test="couponPrice != null">`coupon_price` = #{couponPrice},</if>
  259. <if test="callbackStatus != null">`callback_status` = #{callbackStatus},</if>
  260. <if test="orderType != null">`order_type` = #{orderType},</if>
  261. <if test="storeId != null">`store_id` = #{storeId},</if>
  262. <if test="orderBizType != null">`order_biz_type` = #{orderBizType},</if>
  263. </set>
  264. where id = #{id}
  265. </update>
  266. <delete id="delete">
  267. delete from mall_order where id = #{value}
  268. </delete>
  269. <delete id="deleteBatch">
  270. delete from mall_order where id in
  271. <foreach item="id" collection="array" open="(" separator="," close=")">
  272. #{id}
  273. </foreach>
  274. </delete>
  275. <update id="riderOrderUpdate" parameterType="com.kmall.admin.entity.OrderEntity">
  276. update mall_order
  277. <set>
  278. `order_status` = #{orderStatus},
  279. `shipping_status` = #{shippingStatus},
  280. `shipping_id` = #{shippingId},
  281. `shipping_name` = #{shippingName},
  282. `shipping_fee` = #{shippingFee},
  283. `shipping_no` = #{shippingNo},
  284. `shipping_mobile` = #{shippingMobile}
  285. </set>
  286. where id = #{id}
  287. </update>
  288. <select id="getYfkOrderUserSum" resultType="int">
  289. select count(1) from (select user_id,count(user_id) as counts from mall_order where pay_status = 2 group by user_id) u
  290. </select>
  291. <select id="getOderUserSum" resultType="int">
  292. select count(1) from (select user_id,count(user_id) as counts from mall_order group by user_id) u
  293. </select>
  294. <select id="getTodayUserOrder" resultType="int">
  295. select count(1) from mall_order where pay_status = 2 and pay_time > date_format(sysdate(), '%Y-%m-%d')
  296. </select>
  297. <select id="getTodayUserSales" resultType="int">
  298. select ifnull(sum(actual_price),0) from mall_order where pay_status = 2 and pay_time > date_format(sysdate(), '%Y-%m-%d')
  299. </select>
  300. <select id="getIncomeSum" resultType="int">
  301. select ifnull(sum(actual_price),0) from mall_order where pay_status = 2
  302. </select>
  303. <select id="getPayedOrderCount" resultType="int">
  304. select count(1) from mall_order where pay_status = 2
  305. </select>
  306. </mapper>