OrderGoodsDao.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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. <insert id="saveBatchOrderDetail">
  178. insert into mall_order_goods
  179. (
  180. `order_id`,
  181. `goods_id`,
  182. `goods_name`,
  183. `goods_sn`,
  184. `product_id`,
  185. `number`,
  186. `market_price`,
  187. `retail_price`,
  188. `discounted_price`,
  189. `actual_payment_amount`,
  190. `goods_specification_name_value`,
  191. `is_real`,
  192. `goods_specification_ids`,
  193. `list_pic_url`,
  194. `is_dist_sell_scan`,
  195. `tax_price`,
  196. `store_topic_id`,
  197. `goods_rate`,
  198. `settle_price`,
  199. `sku`,
  200. `order_biz_type`,
  201. `activity`,
  202. `creater_sn`,
  203. `create_time`,
  204. `moder_sn`,
  205. `mod_time`
  206. )
  207. values
  208. <foreach collection="list" item="item" open="(" separator="," close=")">
  209. #{item.order_id},
  210. #{item.goods_id},
  211. #{item.goods_name},
  212. #{item.goods_sn},
  213. #{item.product_id},
  214. #{item.number},
  215. #{item.market_price},
  216. #{item.retail_price},
  217. #{item.discountedPrice},
  218. #{item.actualPaymentAmount},
  219. #{item.goods_specification_name_value},
  220. #{item.is_real},
  221. #{item.goods_specification_ids},
  222. #{item.list_pic_url},
  223. 0,
  224. #{item.taxPrice},
  225. #{item.storeTopicId},
  226. <if test="item.goodsRate != null" >
  227. #{item.goodsRate},
  228. </if>
  229. <if test="item.settlePrice != null" >
  230. #{item.settlePrice},
  231. </if>
  232. <if test="item.sku != null" >
  233. #{item.sku,jdbcType=VARCHAR},
  234. </if>
  235. <if test="item.orderBizType != null" >
  236. #{item.orderBizType,jdbcType=VARCHAR},
  237. </if>
  238. <if test="item.activity != null">
  239. #{item.activity},
  240. </if>
  241. <if test="item.createrSn != null" >
  242. #{item.createrSn,jdbcType=VARCHAR},
  243. </if>
  244. <if test="item.createTime != null" >
  245. #{item.createTime,jdbcType=TIMESTAMP},
  246. </if>
  247. <if test="item.moderSn != null" >
  248. #{item.moderSn,jdbcType=VARCHAR},
  249. </if>
  250. <if test="item.modTime != null" >
  251. #{item.modTime,jdbcType=TIMESTAMP}
  252. </if>
  253. </foreach>
  254. </insert>
  255. <update id="update" parameterType="com.kmall.admin.entity.OrderGoodsEntity">
  256. update mall_order_goods
  257. <set>
  258. <if test="orderId != null">`order_id` = #{orderId},</if>
  259. <if test="goodsId != null">`goods_id` = #{goodsId},</if>
  260. <if test="goodsName != null">`goods_name` = #{goodsName},</if>
  261. <if test="goodsSn != null">`goods_sn` = #{goodsSn},</if>
  262. <if test="productId != null">`product_id` = #{productId},</if>
  263. <if test="number != null">`number` = #{number},</if>
  264. <if test="marketPrice != null">`market_price` = #{marketPrice},</if>
  265. <if test="retailPrice != null">`retail_price` = #{retailPrice},</if>
  266. <if test="goodsSpecificationNameValue != null">`goods_specification_name_value` =
  267. #{goodsSpecificationNameValue},
  268. </if>
  269. <if test="isReal != null">`is_real` = #{isReal},</if>
  270. <if test="goodsSpecificationIds != null">`goods_specification_ids` = #{goodsSpecificationIds},</if>
  271. <if test="listPicUrl != null">`list_pic_url` = #{listPicUrl}</if>
  272. </set>
  273. where id = #{id}
  274. </update>
  275. <delete id="delete">
  276. delete from mall_order_goods where id = #{value}
  277. </delete>
  278. <delete id="deleteBatch">
  279. delete from mall_order_goods where id in
  280. <foreach item="id" collection="array" open="(" separator="," close=")">
  281. #{id}
  282. </foreach>
  283. </delete>
  284. <select id="queryListByOrderId" resultType="com.kmall.admin.entity.OrderGoodsEntity">
  285. SELECT
  286. g.goods_name,
  287. g.number,
  288. g.sku,
  289. g.retail_price,
  290. r.order_id isPromGoods,
  291. r.prom_id promId,
  292. g.activity
  293. FROM
  294. mall_order_goods g
  295. LEFT JOIN mk_store_prom_order_real r ON g.id = r.order_goods_id
  296. WHERE 1=1
  297. <if test="orderId != null">
  298. AND g.order_id = #{orderId}
  299. </if>
  300. <if test="offset != null and limit != null">
  301. limit #{offset}, #{limit}
  302. </if>
  303. </select>
  304. <select id="queryHistoryPrice" resultType="com.kmall.admin.entity.OrderGoodsEntity">
  305. SELECT
  306. g.order_id,
  307. g.sku,
  308. g.retail_price,
  309. g.create_time ,
  310. r.plu
  311. FROM
  312. mall_order_goods g
  313. LEFT JOIN mall_goods r ON g.sku = r.sku
  314. WHERE 1=1
  315. <if test="plu != null and plu.trim() != ''">
  316. AND r.plu = #{plu}
  317. </if>
  318. <if test="sku != null and sku.trim() != ''">
  319. AND g.sku = #{sku}
  320. </if>
  321. <if test="offset != null and limit != null">
  322. limit #{offset}, #{limit}
  323. </if>
  324. </select>
  325. <select id="queryHistoryPriceTotal" resultType="int">
  326. select count(*)
  327. FROM
  328. mall_order_goods g
  329. LEFT JOIN mall_goods r ON g.sku = r.sku
  330. WHERE 1=1
  331. <if test="plu != null and plu.trim() != ''">
  332. AND r.plu = #{plu}
  333. </if>
  334. <if test="sku != null and sku.trim() != ''">
  335. AND g.sku = #{sku}
  336. </if>
  337. </select>
  338. <select id="queryYesterdayTax" resultType="com.kmall.admin.dto.OrderGoodsDto">
  339. SELECT
  340. o.order_sn as orderSn,
  341. sum( tax_price ) as tax
  342. FROM
  343. mall_order_goods g,
  344. mall_order o
  345. WHERE
  346. g.order_id = o.id
  347. AND o.order_status = 300
  348. AND DATE_FORMAT( g.create_time, '%Y-%m-%d' ) = #{date}
  349. GROUP BY
  350. order_id
  351. </select>
  352. <select id="queryListByOrderIds" resultType="com.kmall.api.entity.OrderGoodsRestoreVo">
  353. select
  354. mog.sku as sku,
  355. mog.number as number,
  356. mo.id as orderId,
  357. mo.store_id as storeId,
  358. mo.order_sn as orderSn,
  359. mo.merch_sn as merchSn,
  360. mo.address as shopName
  361. from mall_order_goods mog
  362. left join mall_order mo on mog.order_id=mo.id
  363. where
  364. 1=1
  365. <if test="list != null">
  366. and mo.id in
  367. <foreach collection="list" item="item" open="(" separator="," close=")">
  368. #{item}
  369. </foreach>
  370. </if>
  371. </select>
  372. <select id="queryListHkMall" resultType="com.kmall.admin.entity.OrderGoodsEntity">
  373. select id,goods_id,number from mall_order_goods WHERE order_id = #{orderId}
  374. </select>
  375. </mapper>