OrderGoodsDao.xml 12 KB

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