OrderGoodsDao.xml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. `discounted_price`,
  92. `actual_payment_amount`,
  93. `goods_specification_name_value`,
  94. `is_real`,
  95. `goods_specification_ids`,
  96. `list_pic_url`,
  97. is_dist_sell_scan,
  98. store_topic_id,
  99. <if test="goodsRate != null" >
  100. goods_rate,
  101. </if>
  102. <if test="settlePrice != null" >
  103. settle_price,
  104. </if>
  105. <if test="sku != null" >
  106. sku,
  107. </if>
  108. <if test="orderBizType != null" >
  109. order_biz_type,
  110. </if>
  111. <if test="activity != null">
  112. activity,
  113. </if>
  114. <if test="createrSn != null" >
  115. creater_sn,
  116. </if>
  117. <if test="createTime != null" >
  118. create_time,
  119. </if>
  120. <if test="moderSn != null" >
  121. moder_sn,
  122. </if>
  123. <if test="modTime != null" >
  124. mod_time
  125. </if>
  126. )
  127. values
  128. (
  129. #{order_id},
  130. #{goods_id},
  131. #{goods_name},
  132. #{goods_sn},
  133. #{product_id},
  134. #{number},
  135. #{market_price},
  136. #{retail_price},
  137. #{discountedPrice},
  138. #{actualPaymentAmount},
  139. #{goods_specification_name_value},
  140. #{is_real},
  141. #{goods_specification_ids},
  142. #{list_pic_url},
  143. 0,
  144. #{storeTopicId},
  145. <if test="goodsRate != null" >
  146. #{goodsRate},
  147. </if>
  148. <if test="settlePrice != null" >
  149. #{settlePrice},
  150. </if>
  151. <if test="sku != null" >
  152. #{sku,jdbcType=VARCHAR},
  153. </if>
  154. <if test="orderBizType != null" >
  155. #{orderBizType,jdbcType=VARCHAR},
  156. </if>
  157. <if test="activity != null">
  158. #{activity},
  159. </if>
  160. <if test="createrSn != null" >
  161. #{createrSn,jdbcType=VARCHAR},
  162. </if>
  163. <if test="createTime != null" >
  164. #{createTime,jdbcType=TIMESTAMP},
  165. </if>
  166. <if test="moderSn != null" >
  167. #{moderSn,jdbcType=VARCHAR},
  168. </if>
  169. <if test="modTime != null" >
  170. #{modTime,jdbcType=TIMESTAMP}
  171. </if>
  172. )
  173. </insert>
  174. <update id="update" parameterType="com.kmall.admin.entity.OrderGoodsEntity">
  175. update mall_order_goods
  176. <set>
  177. <if test="orderId != null">`order_id` = #{orderId},</if>
  178. <if test="goodsId != null">`goods_id` = #{goodsId},</if>
  179. <if test="goodsName != null">`goods_name` = #{goodsName},</if>
  180. <if test="goodsSn != null">`goods_sn` = #{goodsSn},</if>
  181. <if test="productId != null">`product_id` = #{productId},</if>
  182. <if test="number != null">`number` = #{number},</if>
  183. <if test="marketPrice != null">`market_price` = #{marketPrice},</if>
  184. <if test="retailPrice != null">`retail_price` = #{retailPrice},</if>
  185. <if test="goodsSpecificationNameValue != null">`goods_specification_name_value` =
  186. #{goodsSpecificationNameValue},
  187. </if>
  188. <if test="isReal != null">`is_real` = #{isReal},</if>
  189. <if test="goodsSpecificationIds != null">`goods_specification_ids` = #{goodsSpecificationIds},</if>
  190. <if test="listPicUrl != null">`list_pic_url` = #{listPicUrl}</if>
  191. </set>
  192. where id = #{id}
  193. </update>
  194. <delete id="delete">
  195. delete from mall_order_goods where id = #{value}
  196. </delete>
  197. <delete id="deleteBatch">
  198. delete from mall_order_goods where id in
  199. <foreach item="id" collection="array" open="(" separator="," close=")">
  200. #{id}
  201. </foreach>
  202. </delete>
  203. <select id="queryListByOrderId" resultType="com.kmall.admin.entity.OrderGoodsEntity">
  204. SELECT
  205. g.goods_name,
  206. g.number,
  207. g.retail_price,
  208. r.order_id isPromGoods,
  209. r.prom_id promId,
  210. g.activity
  211. FROM
  212. mall_order_goods g
  213. LEFT JOIN mk_store_prom_order_real r ON g.id = r.order_goods_id
  214. WHERE 1=1
  215. <if test="orderId != null">
  216. AND g.order_id = #{orderId}
  217. </if>
  218. <if test="offset != null and limit != null">
  219. limit #{offset}, #{limit}
  220. </if>
  221. </select>
  222. <select id="queryHistoryPrice" resultType="com.kmall.admin.entity.OrderGoodsEntity">
  223. SELECT
  224. g.order_id,
  225. g.sku,
  226. g.retail_price,
  227. g.create_time ,
  228. r.plu
  229. FROM
  230. mall_order_goods g
  231. LEFT JOIN mall_goods r ON g.sku = r.sku
  232. WHERE 1=1
  233. <if test="plu != null and plu.trim() != ''">
  234. AND r.plu = #{plu}
  235. </if>
  236. <if test="sku != null and sku.trim() != ''">
  237. AND g.sku = #{sku}
  238. </if>
  239. <if test="offset != null and limit != null">
  240. limit #{offset}, #{limit}
  241. </if>
  242. </select>
  243. <select id="queryHistoryPriceTotal" resultType="int">
  244. select count(*)
  245. FROM
  246. mall_order_goods g
  247. LEFT JOIN mall_goods r ON g.sku = r.sku
  248. WHERE 1=1
  249. <if test="plu != null and plu.trim() != ''">
  250. AND r.plu = #{plu}
  251. </if>
  252. <if test="sku != null and sku.trim() != ''">
  253. AND g.sku = #{sku}
  254. </if>
  255. </select>
  256. </mapper>