OrderDao.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. </resultMap>
  50. <select id="queryObject" resultType="com.kmall.admin.entity.OrderEntity">
  51. select o.*,u.username as username
  52. from mall_order o
  53. left join mall_user u on o.user_id = u.id
  54. where o.id = #{value}
  55. </select>
  56. <select id="queryObjectByActivityId" resultType="com.kmall.admin.entity.OrderEntity">
  57. select o.*,u.username as username
  58. from mall_order o
  59. left join mall_user u on o.user_id = u.id
  60. where o.activity_id = #{activityId} and o.order_type = #{orderType}
  61. </select>
  62. <select id="getTotalActualPrice" resultType="java.lang.Double">
  63. select sum(a.actual_price) 'totalActualPrice' from mall_order a where merch_order_sn = #{merchOrderSn}
  64. </select>
  65. <select id="queryList" resultType="com.kmall.admin.entity.OrderEntity">
  66. select o.*,u.username as username
  67. from mall_order o
  68. left join mall_user u on o.user_id = u.id
  69. WHERE 1=1
  70. <if test="orderSn != null and orderSn.trim() != ''">
  71. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  72. </if>
  73. <if test="shippingStatus != null">
  74. AND o.shipping_status = #{shippingStatus}
  75. </if>
  76. <if test="payStatus != null">
  77. AND o.pay_status = #{payStatus}
  78. </if>
  79. <if test="orderStatus != null and orderStatus.trim() != ''">
  80. AND o.order_status = #{orderStatus}
  81. </if>
  82. <if test="shippingId != null and shippingId != 0">
  83. AND o.shipping_id = #{shippingId}
  84. </if>
  85. <if test="orderType != null and orderType.trim() != ''">
  86. AND o.order_type = #{orderType}
  87. </if>
  88. <if test="ids != null and ids.trim() != ''">
  89. AND o.id in (${ids})
  90. </if>
  91. <choose>
  92. <when test="sidx != null and sidx.trim() != ''">
  93. order by ${sidx} ${order}
  94. </when>
  95. <otherwise>
  96. order by id desc
  97. </otherwise>
  98. </choose>
  99. <if test="offset != null and limit != null">
  100. limit #{offset}, #{limit}
  101. </if>
  102. </select>
  103. <select id="queryTotal" resultType="int">
  104. select count(*) from mall_order o WHERE 1=1
  105. <if test="orderSn != null and orderSn.trim() != ''">
  106. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  107. </if>
  108. <if test="shippingStatus != null">
  109. AND o.shipping_status = #{shippingStatus}
  110. </if>
  111. <if test="payStatus != null">
  112. AND o.pay_status = #{payStatus}
  113. </if>
  114. <if test="orderStatus != null and orderStatus.trim() != ''">
  115. AND o.order_status = #{orderStatus}
  116. </if>
  117. <if test="shippingId != null and shippingId != 0">
  118. AND o.shipping_id = #{shippingId}
  119. </if>
  120. <if test="orderType != null and orderType.trim() != ''">
  121. AND o.order_type = #{orderType}
  122. </if>
  123. </select>
  124. <insert id="save" parameterType="com.kmall.admin.entity.OrderEntity" useGeneratedKeys="true" keyProperty="id">
  125. insert into mall_order
  126. (
  127. `order_sn`,
  128. `user_id`,
  129. `order_status`,
  130. `shipping_status`,
  131. `pay_status`,
  132. `consignee`,
  133. `country`,
  134. `province`,
  135. `city`,
  136. `district`,
  137. `address`,
  138. `mobile`,
  139. `postscript`,
  140. `shipping_id`,
  141. `shipping_name`,
  142. `shipping_code`,
  143. `shipping_no`,
  144. `pay_id`,
  145. `pay_name`,
  146. `shipping_fee`,
  147. `actual_price`,
  148. `integral`,
  149. `integral_money`,
  150. `order_price`,
  151. `goods_price`,
  152. `add_time`,
  153. `confirm_time`,
  154. `pay_time`,
  155. `freight_price`,
  156. `coupon_id`,
  157. `parent_id`,
  158. `coupon_price`,
  159. `callback_status`,
  160. `order_type`,
  161. `store_id`,
  162. `order_biz_type`
  163. )
  164. values
  165. (
  166. #{orderSn},
  167. #{userId},
  168. #{orderStatus},
  169. #{shippingStatus},
  170. #{payStatus},
  171. #{consignee},
  172. #{country},
  173. #{province},
  174. #{city},
  175. #{district},
  176. #{address},
  177. #{mobile},
  178. #{postscript},
  179. #{shippingId},
  180. #{shippingName},
  181. #{shippingCode},
  182. #{shippingNo},
  183. #{payId},
  184. #{payName},
  185. #{shippingFee},
  186. #{actualPrice},
  187. #{integral},
  188. #{integralMoney},
  189. #{orderPrice},
  190. #{goodsPrice},
  191. #{addTime},
  192. #{confirmTime},
  193. #{payTime},
  194. #{freightPrice},
  195. #{couponId},
  196. #{parentId},
  197. #{couponPrice},
  198. #{callbackStatus},
  199. #{orderType},
  200. #{storeId},
  201. #{orderBizType}
  202. )
  203. </insert>
  204. <update id="update" parameterType="com.kmall.admin.entity.OrderEntity">
  205. update mall_order
  206. <set>
  207. <if test="orderSn != null">`order_sn` = #{orderSn},</if>
  208. <if test="userId != null">`user_id` = #{userId},</if>
  209. <if test="orderStatus != null">`order_status` = #{orderStatus},</if>
  210. <if test="shippingStatus != null">`shipping_status` = #{shippingStatus},</if>
  211. <if test="payStatus != null">`pay_status` = #{payStatus},</if>
  212. <if test="consignee != null">`consignee` = #{consignee},</if>
  213. <if test="country != null">`country` = #{country},</if>
  214. <if test="province != null">`province` = #{province},</if>
  215. <if test="city != null">`city` = #{city},</if>
  216. <if test="district != null">`district` = #{district},</if>
  217. <if test="address != null">`address` = #{address},</if>
  218. <if test="mobile != null">`mobile` = #{mobile},</if>
  219. <if test="postscript != null">`postscript` = #{postscript},</if>
  220. <if test="shippingId != null">`shipping_id` = #{shippingId},</if>
  221. <if test="shippingName != null">`shipping_name` = #{shippingName},</if>
  222. <if test="shippingCode != null">`shipping_code` = #{shippingCode},</if>
  223. <if test="shippingNo != null">`shipping_no` = #{shippingNo},</if>
  224. <if test="payId != null">`pay_id` = #{payId},</if>
  225. <if test="payName != null">`pay_name` = #{payName},</if>
  226. <if test="shippingFee != null">`shipping_fee` = #{shippingFee},</if>
  227. <if test="actualPrice != null">`actual_price` = #{actualPrice},</if>
  228. <if test="integral != null">`integral` = #{integral},</if>
  229. <if test="integralMoney != null">`integral_money` = #{integralMoney},</if>
  230. <if test="orderPrice != null">`order_price` = #{orderPrice},</if>
  231. <if test="goodsPrice != null">`goods_price` = #{goodsPrice},</if>
  232. <if test="addTime != null">`add_time` = #{addTime},</if>
  233. <if test="confirmTime != null">`confirm_time` = #{confirmTime},</if>
  234. <if test="payTime != null">`pay_time` = #{payTime},</if>
  235. <if test="freightPrice != null">`freight_price` = #{freightPrice},</if>
  236. <if test="couponId != null">`coupon_id` = #{couponId},</if>
  237. <if test="parentId != null">`parent_id` = #{parentId},</if>
  238. <if test="couponPrice != null">`coupon_price` = #{couponPrice},</if>
  239. <if test="callbackStatus != null">`callback_status` = #{callbackStatus},</if>
  240. <if test="orderType != null">`order_type` = #{orderType},</if>
  241. <if test="storeId != null">`store_id` = #{storeId},</if>
  242. <if test="orderBizType != null">`order_biz_type` = #{orderBizType},</if>
  243. </set>
  244. where id = #{id}
  245. </update>
  246. <delete id="delete">
  247. delete from mall_order where id = #{value}
  248. </delete>
  249. <delete id="deleteBatch">
  250. delete from mall_order where id in
  251. <foreach item="id" collection="array" open="(" separator="," close=")">
  252. #{id}
  253. </foreach>
  254. </delete>
  255. <update id="riderOrderUpdate" parameterType="com.kmall.admin.entity.OrderEntity">
  256. update mall_order
  257. <set>
  258. `order_status` = #{orderStatus},
  259. `shipping_status` = #{shippingStatus},
  260. `shipping_id` = #{shippingId},
  261. `shipping_name` = #{shippingName},
  262. `shipping_fee` = #{shippingFee},
  263. `shipping_no` = #{shippingNo},
  264. `shipping_mobile` = #{shippingMobile}
  265. </set>
  266. where id = #{id}
  267. </update>
  268. <select id="getYfkOrderUserSum" resultType="int">
  269. select count(1) from (select user_id,count(user_id) as counts from mall_order where pay_status = 2 group by user_id) u
  270. </select>
  271. <select id="getOderUserSum" resultType="int">
  272. select count(1) from (select user_id,count(user_id) as counts from mall_order group by user_id) u
  273. </select>
  274. <select id="getTodayUserOrder" resultType="int">
  275. select count(1) from mall_order where pay_status = 2 and pay_time > date_format(sysdate(), '%Y-%m-%d')
  276. </select>
  277. <select id="getTodayUserSales" resultType="int">
  278. select ifnull(sum(actual_price),0) from mall_order where pay_status = 2 and pay_time > date_format(sysdate(), '%Y-%m-%d')
  279. </select>
  280. <select id="getIncomeSum" resultType="int">
  281. select ifnull(sum(actual_price),0) from mall_order where pay_status = 2
  282. </select>
  283. <select id="getPayedOrderCount" resultType="int">
  284. select count(1) from mall_order where pay_status = 2
  285. </select>
  286. </mapper>