OrderGoodsDao.xml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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="goodsSpecificationNameValue" column="goods_specification_name_value"/>
  16. <result property="isReal" column="is_real"/>
  17. <result property="goodsSpecificationIds" column="goods_specification_ids"/>
  18. <result property="listPicUrl" column="list_pic_url"/>
  19. <result property="sku" column="sku"/>
  20. </resultMap>
  21. <select id="queryObject" resultType="com.kmall.admin.entity.OrderGoodsEntity">
  22. select * from mall_order_goods where id = #{value}
  23. </select>
  24. <select id="queryList" resultType="com.kmall.admin.entity.OrderGoodsEntity">
  25. select * from mall_order_goods
  26. WHERE 1=1
  27. <if test="orderId != null">
  28. AND order_id = #{orderId}
  29. </if>
  30. <choose>
  31. <when test="sidx != null and sidx.trim() != ''">
  32. order by ${sidx} ${order}
  33. </when>
  34. <otherwise>
  35. order by id desc
  36. </otherwise>
  37. </choose>
  38. <if test="offset != null and limit != null">
  39. limit #{offset}, #{limit}
  40. </if>
  41. </select>
  42. <select id="queryTotal" resultType="int">
  43. select count(*) from mall_order_goods WHERE 1=1
  44. <if test="orderId != null">
  45. AND order_id = #{orderId}
  46. </if>
  47. </select>
  48. <insert id="save" parameterType="com.kmall.admin.entity.OrderGoodsEntity" useGeneratedKeys="true" keyProperty="id">
  49. insert into mall_order_goods
  50. (
  51. `order_id`,
  52. `goods_id`,
  53. `goods_name`,
  54. `goods_sn`,
  55. `product_id`,
  56. `number`,
  57. `market_price`,
  58. `retail_price`,
  59. `goods_specification_name_value`,
  60. `is_real`,
  61. `goods_specification_ids`,
  62. `list_pic_url`
  63. )
  64. values
  65. (
  66. #{orderId},
  67. #{goodsId},
  68. #{goodsName},
  69. #{goodsSn},
  70. #{productId},
  71. #{number},
  72. #{marketPrice},
  73. #{retailPrice},
  74. #{goodsSpecificationNameValue},
  75. #{isReal},
  76. #{goodsSpecificationIds},
  77. #{listPicUrl}
  78. )
  79. </insert>
  80. <insert id="saveOrderGoodsVo" parameterType="com.kmall.api.entity.OrderGoodsVo" useGeneratedKeys="true" keyProperty="id">
  81. insert into mall_order_goods
  82. (
  83. `order_id`,
  84. `goods_id`,
  85. `goods_name`,
  86. `goods_sn`,
  87. `product_id`,
  88. `number`,
  89. `market_price`,
  90. `retail_price`,
  91. `goods_specification_name_value`,
  92. `is_real`,
  93. `goods_specification_ids`,
  94. `list_pic_url`,
  95. is_dist_sell_scan,
  96. store_topic_id,
  97. <if test="goodsRate != null" >
  98. goods_rate,
  99. </if>
  100. <if test="settlePrice != null" >
  101. settle_price,
  102. </if>
  103. <if test="sku != null" >
  104. sku,
  105. </if>
  106. <if test="orderBizType != null" >
  107. order_biz_type,
  108. </if>
  109. <if test="createrSn != null" >
  110. creater_sn,
  111. </if>
  112. <if test="createTime != null" >
  113. create_time,
  114. </if>
  115. <if test="moderSn != null" >
  116. moder_sn,
  117. </if>
  118. <if test="modTime != null" >
  119. mod_time
  120. </if>
  121. )
  122. values
  123. (
  124. #{order_id},
  125. #{goods_id},
  126. #{goods_name},
  127. #{goods_sn},
  128. #{product_id},
  129. #{number},
  130. #{market_price},
  131. #{retail_price},
  132. #{goods_specification_name_value},
  133. #{is_real},
  134. #{goods_specification_ids},
  135. #{list_pic_url},
  136. 0,
  137. #{storeTopicId},
  138. <if test="goodsRate != null" >
  139. #{goodsRate},
  140. </if>
  141. <if test="settlePrice != null" >
  142. #{settlePrice},
  143. </if>
  144. <if test="sku != null" >
  145. #{sku,jdbcType=VARCHAR},
  146. </if>
  147. <if test="orderBizType != null" >
  148. #{orderBizType,jdbcType=VARCHAR},
  149. </if>
  150. <if test="createrSn != null" >
  151. #{createrSn,jdbcType=VARCHAR},
  152. </if>
  153. <if test="createTime != null" >
  154. #{createTime,jdbcType=TIMESTAMP},
  155. </if>
  156. <if test="moderSn != null" >
  157. #{moderSn,jdbcType=VARCHAR},
  158. </if>
  159. <if test="modTime != null" >
  160. #{modTime,jdbcType=TIMESTAMP}
  161. </if>
  162. )
  163. </insert>
  164. <update id="update" parameterType="com.kmall.admin.entity.OrderGoodsEntity">
  165. update mall_order_goods
  166. <set>
  167. <if test="orderId != null">`order_id` = #{orderId},</if>
  168. <if test="goodsId != null">`goods_id` = #{goodsId},</if>
  169. <if test="goodsName != null">`goods_name` = #{goodsName},</if>
  170. <if test="goodsSn != null">`goods_sn` = #{goodsSn},</if>
  171. <if test="productId != null">`product_id` = #{productId},</if>
  172. <if test="number != null">`number` = #{number},</if>
  173. <if test="marketPrice != null">`market_price` = #{marketPrice},</if>
  174. <if test="retailPrice != null">`retail_price` = #{retailPrice},</if>
  175. <if test="goodsSpecificationNameValue != null">`goods_specification_name_value` =
  176. #{goodsSpecificationNameValue},
  177. </if>
  178. <if test="isReal != null">`is_real` = #{isReal},</if>
  179. <if test="goodsSpecificationIds != null">`goods_specification_ids` = #{goodsSpecificationIds},</if>
  180. <if test="listPicUrl != null">`list_pic_url` = #{listPicUrl}</if>
  181. </set>
  182. where id = #{id}
  183. </update>
  184. <delete id="delete">
  185. delete from mall_order_goods where id = #{value}
  186. </delete>
  187. <delete id="deleteBatch">
  188. delete from mall_order_goods where id in
  189. <foreach item="id" collection="array" open="(" separator="," close=")">
  190. #{id}
  191. </foreach>
  192. </delete>
  193. <select id="queryListByOrderId" resultType="com.kmall.admin.entity.OrderGoodsEntity">
  194. SELECT
  195. g.goods_name,
  196. g.number,
  197. g.retail_price,
  198. r.order_id isPromGoods,
  199. r.prom_id promId
  200. FROM
  201. mall_order_goods g
  202. LEFT JOIN mk_store_prom_order_real r ON g.id = r.order_goods_id
  203. WHERE 1=1
  204. <if test="orderId != null">
  205. AND g.order_id = #{orderId}
  206. </if>
  207. <if test="offset != null and limit != null">
  208. limit #{offset}, #{limit}
  209. </if>
  210. </select>
  211. <select id="queryHistoryPrice" resultType="com.kmall.admin.entity.OrderGoodsEntity">
  212. SELECT
  213. g.order_id,
  214. g.sku,
  215. g.retail_price,
  216. g.create_time ,
  217. r.plu
  218. FROM
  219. mall_order_goods g
  220. LEFT JOIN mall_goods r ON g.sku = r.sku
  221. WHERE 1=1
  222. <if test="plu != null and plu.trim() != ''">
  223. AND r.plu = #{plu}
  224. </if>
  225. <if test="sku != null and sku.trim() != ''">
  226. AND g.sku = #{sku}
  227. </if>
  228. <if test="offset != null and limit != null">
  229. limit #{offset}, #{limit}
  230. </if>
  231. </select>
  232. <select id="queryHistoryPriceTotal" resultType="int">
  233. select count(*)
  234. FROM
  235. mall_order_goods g
  236. LEFT JOIN mall_goods r ON g.sku = r.sku
  237. WHERE 1=1
  238. <if test="plu != null and plu.trim() != ''">
  239. AND r.plu = #{plu}
  240. </if>
  241. <if test="sku != null and sku.trim() != ''">
  242. AND g.sku = #{sku}
  243. </if>
  244. </select>
  245. </mapper>