OrderGoodsDao.xml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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.OrderGoodsDao">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.admin.entity.OrderGoodsEntity" id="orderGoodsMap">
  6. <result property="id" column="id"/>
  7. <result property="orderId" column="order_id"/>
  8. <result property="goodsId" column="goods_id"/>
  9. <result property="goodsName" column="goods_name"/>
  10. <result property="goodsSn" column="goods_sn"/>
  11. <result property="productId" column="product_id"/>
  12. <result property="number" column="number"/>
  13. <result property="marketPrice" column="market_price"/>
  14. <result property="retailPrice" column="retail_price"/>
  15. <result property="taxPrice" column="tax_price"/>
  16. <result property="goodsSpecificationNameValue" column="goods_specification_name_value"/>
  17. <result property="isReal" column="is_real"/>
  18. <result property="goodsSpecificationIds" column="goods_specification_ids"/>
  19. <result property="listPicUrl" column="list_pic_url"/>
  20. <result property="sku" column="sku"/>
  21. </resultMap>
  22. <select id="queryObject" resultType="com.kmall.admin.entity.OrderGoodsEntity">
  23. select * from mall_order_goods where id = #{value}
  24. </select>
  25. <select id="queryList" resultType="com.kmall.admin.entity.OrderGoodsEntity">
  26. select * from mall_order_goods
  27. WHERE 1=1
  28. <if test="orderId != null">
  29. AND order_id = #{orderId}
  30. </if>
  31. <choose>
  32. <when test="sidx != null and sidx.trim() != ''">
  33. order by ${sidx} ${order}
  34. </when>
  35. <otherwise>
  36. order by id desc
  37. </otherwise>
  38. </choose>
  39. <if test="offset != null and limit != null">
  40. limit #{offset}, #{limit}
  41. </if>
  42. </select>
  43. <select id="queryTotal" resultType="int">
  44. select count(*) from mall_order_goods WHERE 1=1
  45. <if test="orderId != null">
  46. AND order_id = #{orderId}
  47. </if>
  48. </select>
  49. <insert id="save" parameterType="com.kmall.admin.entity.OrderGoodsEntity" useGeneratedKeys="true" keyProperty="id">
  50. insert into mall_order_goods
  51. (
  52. `order_id`,
  53. `goods_id`,
  54. `goods_name`,
  55. `goods_sn`,
  56. `product_id`,
  57. `number`,
  58. `market_price`,
  59. `retail_price`,
  60. `goods_specification_name_value`,
  61. `is_real`,
  62. `goods_specification_ids`,
  63. `list_pic_url`
  64. )
  65. values
  66. (
  67. #{orderId},
  68. #{goodsId},
  69. #{goodsName},
  70. #{goodsSn},
  71. #{productId},
  72. #{number},
  73. #{marketPrice},
  74. #{retailPrice},
  75. #{goodsSpecificationNameValue},
  76. #{isReal},
  77. #{goodsSpecificationIds},
  78. #{listPicUrl}
  79. )
  80. </insert>
  81. <insert id="saveOrderGoodsVo" parameterType="com.kmall.api.entity.OrderGoodsVo" useGeneratedKeys="true" keyProperty="id">
  82. insert into mall_order_goods
  83. (
  84. `order_id`,
  85. `goods_id`,
  86. `goods_name`,
  87. `goods_sn`,
  88. `product_id`,
  89. `number`,
  90. `market_price`,
  91. `retail_price`,
  92. `discounted_price`,
  93. `actual_payment_amount`,
  94. `goods_specification_name_value`,
  95. `is_real`,
  96. `goods_specification_ids`,
  97. `list_pic_url`,
  98. is_dist_sell_scan,
  99. tax_price,
  100. store_topic_id,
  101. <if test="goodsRate != null" >
  102. goods_rate,
  103. </if>
  104. <if test="settlePrice != null" >
  105. settle_price,
  106. </if>
  107. <if test="sku != null" >
  108. sku,
  109. </if>
  110. <if test="orderBizType != null" >
  111. order_biz_type,
  112. </if>
  113. <if test="activity != null">
  114. activity,
  115. </if>
  116. <if test="createrSn != null" >
  117. creater_sn,
  118. </if>
  119. <if test="createTime != null" >
  120. create_time,
  121. </if>
  122. <if test="moderSn != null" >
  123. moder_sn,
  124. </if>
  125. <if test="modTime != null" >
  126. mod_time
  127. </if>
  128. )
  129. values
  130. (
  131. #{order_id},
  132. #{goods_id},
  133. #{goods_name},
  134. #{goods_sn},
  135. #{product_id},
  136. #{number},
  137. #{market_price},
  138. #{retail_price},
  139. #{discountedPrice},
  140. #{actualPaymentAmount},
  141. #{goods_specification_name_value},
  142. #{is_real},
  143. #{goods_specification_ids},
  144. #{list_pic_url},
  145. 0,
  146. #{taxPrice},
  147. #{storeTopicId},
  148. <if test="goodsRate != null" >
  149. #{goodsRate},
  150. </if>
  151. <if test="settlePrice != null" >
  152. #{settlePrice},
  153. </if>
  154. <if test="sku != null" >
  155. #{sku,jdbcType=VARCHAR},
  156. </if>
  157. <if test="orderBizType != null" >
  158. #{orderBizType,jdbcType=VARCHAR},
  159. </if>
  160. <if test="activity != null">
  161. #{activity},
  162. </if>
  163. <if test="createrSn != null" >
  164. #{createrSn,jdbcType=VARCHAR},
  165. </if>
  166. <if test="createTime != null" >
  167. #{createTime,jdbcType=TIMESTAMP},
  168. </if>
  169. <if test="moderSn != null" >
  170. #{moderSn,jdbcType=VARCHAR},
  171. </if>
  172. <if test="modTime != null" >
  173. #{modTime,jdbcType=TIMESTAMP}
  174. </if>
  175. )
  176. </insert>
  177. <update id="update" parameterType="com.kmall.admin.entity.OrderGoodsEntity">
  178. update mall_order_goods
  179. <set>
  180. <if test="orderId != null">`order_id` = #{orderId},</if>
  181. <if test="goodsId != null">`goods_id` = #{goodsId},</if>
  182. <if test="goodsName != null">`goods_name` = #{goodsName},</if>
  183. <if test="goodsSn != null">`goods_sn` = #{goodsSn},</if>
  184. <if test="productId != null">`product_id` = #{productId},</if>
  185. <if test="number != null">`number` = #{number},</if>
  186. <if test="marketPrice != null">`market_price` = #{marketPrice},</if>
  187. <if test="retailPrice != null">`retail_price` = #{retailPrice},</if>
  188. <if test="goodsSpecificationNameValue != null">`goods_specification_name_value` =
  189. #{goodsSpecificationNameValue},
  190. </if>
  191. <if test="isReal != null">`is_real` = #{isReal},</if>
  192. <if test="goodsSpecificationIds != null">`goods_specification_ids` = #{goodsSpecificationIds},</if>
  193. <if test="listPicUrl != null">`list_pic_url` = #{listPicUrl}</if>
  194. </set>
  195. where id = #{id}
  196. </update>
  197. <delete id="delete">
  198. delete from mall_order_goods where id = #{value}
  199. </delete>
  200. <delete id="deleteBatch">
  201. delete from mall_order_goods where id in
  202. <foreach item="id" collection="array" open="(" separator="," close=")">
  203. #{id}
  204. </foreach>
  205. </delete>
  206. <select id="queryListByOrderId" resultType="com.kmall.admin.entity.OrderGoodsEntity">
  207. SELECT
  208. g.goods_name,
  209. g.number,
  210. g.sku,
  211. g.retail_price,
  212. r.order_id isPromGoods,
  213. r.prom_id promId,
  214. g.activity
  215. FROM
  216. mall_order_goods g
  217. LEFT JOIN mk_store_prom_order_real r ON g.id = r.order_goods_id
  218. WHERE 1=1
  219. <if test="orderId != null">
  220. AND g.order_id = #{orderId}
  221. </if>
  222. <if test="offset != null and limit != null">
  223. limit #{offset}, #{limit}
  224. </if>
  225. </select>
  226. <select id="queryHistoryPrice" resultType="com.kmall.admin.entity.OrderGoodsEntity">
  227. SELECT
  228. g.order_id,
  229. g.sku,
  230. g.retail_price,
  231. g.create_time ,
  232. r.plu
  233. FROM
  234. mall_order_goods g
  235. LEFT JOIN mall_goods r ON g.sku = r.sku
  236. WHERE 1=1
  237. <if test="plu != null and plu.trim() != ''">
  238. AND r.plu = #{plu}
  239. </if>
  240. <if test="sku != null and sku.trim() != ''">
  241. AND g.sku = #{sku}
  242. </if>
  243. <if test="offset != null and limit != null">
  244. limit #{offset}, #{limit}
  245. </if>
  246. </select>
  247. <select id="queryHistoryPriceTotal" resultType="int">
  248. select count(*)
  249. FROM
  250. mall_order_goods g
  251. LEFT JOIN mall_goods r ON g.sku = r.sku
  252. WHERE 1=1
  253. <if test="plu != null and plu.trim() != ''">
  254. AND r.plu = #{plu}
  255. </if>
  256. <if test="sku != null and sku.trim() != ''">
  257. AND g.sku = #{sku}
  258. </if>
  259. </select>
  260. <select id="queryYesterdayTax" resultType="com.kmall.admin.dto.OrderGoodsDto">
  261. SELECT
  262. o.order_sn as orderSn,
  263. sum( tax_price ) as tax
  264. FROM
  265. mall_order_goods g,
  266. mall_order o
  267. WHERE
  268. g.order_id = o.id
  269. AND o.order_status = 300
  270. AND DATE_FORMAT( g.create_time, '%Y-%m-%d' ) = #{date}
  271. GROUP BY
  272. order_id
  273. </select>
  274. <select id="queryListByOrderIds" resultType="com.kmall.api.entity.OrderGoodsRestoreVo">
  275. select
  276. mog.sku as sku,
  277. mog.number as number,
  278. mo.id as orderId,
  279. mo.store_id as storeId,
  280. mo.order_sn as orderSn,
  281. mo.merch_sn as merchSn,
  282. mo.address as shopName
  283. from mall_order_goods mog
  284. left join mall_order mo on mog.order_id=mo.id
  285. where
  286. 1=1
  287. <if test="list != null">
  288. and mo.id in
  289. <foreach collection="list" item="item" open="(" separator="," close=")">
  290. #{item}
  291. </foreach>
  292. </if>
  293. </select>
  294. </mapper>