OrderGoodsDao.xml 12 KB

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