1
0

CartDao.xml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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.CartDao">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.admin.entity.CartEntity" id="cartMap">
  6. <result property="id" column="id"/>
  7. <result property="userName" column="user_name"/>
  8. <result property="userId" column="user_id"/>
  9. <result property="goodsId" column="goods_id"/>
  10. <result property="goodsSn" column="goods_sn"/>
  11. <result property="productId" column="product_id"/>
  12. <result property="goodsName" column="goods_name"/>
  13. <result property="marketPrice" column="market_price"/>
  14. <result property="retailPrice" column="retail_price"/>
  15. <result property="number" column="number"/>
  16. <result property="goodsSpecificationNameValue" column="goods_specification_name_value"/>
  17. <result property="goodsSpecificationIds" column="goods_specification_ids"/>
  18. <result property="checked" column="checked"/>
  19. <result property="listPicUrl" column="list_pic_url"/>
  20. <result column="sku" property="sku" jdbcType="VARCHAR" />
  21. <result column="goods_biz_type" property="goodsBizType" jdbcType="CHAR" />
  22. <result column="creater_sn" property="createrSn" jdbcType="VARCHAR" />
  23. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  24. <result column="moder_sn" property="moderSn" jdbcType="VARCHAR" />
  25. <result column="mod_time" property="modTime" jdbcType="TIMESTAMP" />
  26. <result column="tstm" property="tstm" jdbcType="TIMESTAMP" />
  27. <result property="stockNum" column="productStockNum"/>
  28. <result property="storeName" column="store_name"/>
  29. </resultMap>
  30. <select id="queryObject" resultType="com.kmall.admin.entity.CartEntity">
  31. select * from mall_cart where id = #{value}
  32. </select>
  33. <select id="queryList" resultMap="cartMap">
  34. select distinct a.* ,b.nickname as user_name
  35. from mall_cart a
  36. left join mall_user b on a.user_id = b.id
  37. LEFT JOIN mall_merch_user d ON a.user_id=d.user_id
  38. where 1=1
  39. <if test="storeId != null">
  40. and d.store_id = #{storeId}
  41. </if>
  42. <if test="merchSn != null and merchSn.trim() != ''">
  43. and d.merch_sn = #{merchSn}
  44. </if>
  45. <if test="goodsId != null">
  46. and a.goods_id = #{goodsId}
  47. </if>
  48. <if test="userId != null">
  49. AND a.user_id = #{userId}
  50. </if>
  51. <if test="goodsBizType != null">
  52. AND a.goods_biz_type = #{goodsBizType}
  53. </if>
  54. <choose>
  55. <when test="sidx != null and sidx.trim() != ''">
  56. order by ${sidx} ${order}
  57. </when>
  58. <otherwise>
  59. order by id desc
  60. </otherwise>
  61. </choose>
  62. <if test="offset != null and limit != null">
  63. limit #{offset}, #{limit}
  64. </if>
  65. </select>
  66. <select id="queryTotal" resultType="int">
  67. select count(distinct a.id)
  68. from mall_cart a
  69. LEFT JOIN mall_merch_user d ON a.user_id=d.user_id
  70. where 1=1
  71. <if test="storeId != null">
  72. and d.store_id = #{storeId}
  73. </if>
  74. <if test="merchSn != null and merchSn.trim() != ''">
  75. and d.merch_sn = #{merchSn}
  76. </if>
  77. <if test="goodsId != null">
  78. and a.goods_id = #{goodsId}
  79. </if>
  80. <if test="userId != null">
  81. AND mall_cart.user_id = #{userId}
  82. </if>
  83. </select>
  84. <insert id="save" parameterType="com.kmall.admin.entity.CartEntity" useGeneratedKeys="true" keyProperty="id">
  85. insert into mall_cart
  86. (
  87. `user_id`,
  88. `goods_id`,
  89. `goods_sn`,
  90. `product_id`,
  91. `goods_name`,
  92. `market_price`,
  93. `retail_price`,
  94. `number`,
  95. `goods_specification_name_value`,
  96. `goods_specification_ids`,
  97. `checked`,
  98. `list_pic_url`,
  99. `stock_num`,
  100. `store_id`,
  101. `sku`,
  102. `goods_biz_type`,
  103. `creater_sn`,
  104. `create_time`,
  105. `moder_sn`,
  106. `mod_time`
  107. )
  108. values
  109. (
  110. #{userId},
  111. #{goodsId},
  112. #{goodsSn},
  113. #{productId},
  114. #{goodsName},
  115. #{marketPrice},
  116. #{retailPrice},
  117. #{number},
  118. #{goodsSpecificationNameValue},
  119. #{goodsSpecificationIds},
  120. #{checked},
  121. #{listPicUrl},
  122. #{stockNum},
  123. #{storeId},
  124. #{sku},
  125. #{goodsBizType},
  126. #{createrSn},
  127. #{createTime},
  128. #{moderSn},
  129. #{modTime}
  130. )
  131. </insert>
  132. <update id="update" parameterType="com.kmall.admin.entity.CartEntity">
  133. update mall_cart
  134. <set>
  135. <if test="userId != null">`user_id` = #{userId},</if>
  136. <if test="goodsId != null">`goods_id` = #{goodsId},</if>
  137. <if test="goodsSn != null">`goods_sn` = #{goodsSn},</if>
  138. <if test="productId != null">`product_id` = #{productId},</if>
  139. <if test="goodsName != null">`goods_name` = #{goodsName},</if>
  140. <if test="marketPrice != null">`market_price` = #{marketPrice},</if>
  141. <if test="retailPrice != null">`retail_price` = #{retailPrice},</if>
  142. <if test="number != null">`number` = #{number},</if>
  143. <if test="goodsSpecificationNameValue != null">`goods_specification_name_value` =
  144. #{goodsSpecificationNameValue},
  145. </if>
  146. <if test="goodsSpecificationIds != null">`goods_specification_ids` = #{goodsSpecificationIds},</if>
  147. <if test="checked != null">`checked` = #{checked},</if>
  148. <if test="listPicUrl != null">`list_pic_url` = #{listPicUrl},</if>
  149. <if test="stockNum != null">`stock_num` = #{stockNum},</if>
  150. <if test="storeId != null">`store_id` = #{storeId},</if>
  151. <if test="goodsBizType != null">`goods_biz_type` = #{goodsBizType},</if>
  152. <if test="createrSn != null" >
  153. creater_sn = #{createrSn,jdbcType=VARCHAR},
  154. </if>
  155. <if test="createTime != null" >
  156. create_time = #{createTime,jdbcType=TIMESTAMP},
  157. </if>
  158. <if test="moderSn != null" >
  159. moder_sn = #{moderSn,jdbcType=VARCHAR},
  160. </if>
  161. <if test="modTime != null" >
  162. mod_time = #{modTime,jdbcType=TIMESTAMP}
  163. </if>
  164. </set>
  165. where id = #{id}
  166. </update>
  167. <delete id="delete">
  168. delete from mall_cart where id = #{value}
  169. </delete>
  170. <delete id="deleteBatch">
  171. delete from mall_cart where id in
  172. <foreach item="id" collection="array" open="(" separator="," close=")">
  173. #{id}
  174. </foreach>
  175. </delete>
  176. </mapper>