CartDao.xml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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="userId != null">
  46. AND a.user_id = #{userId}
  47. </if>
  48. <if test="goodsBizType != null">
  49. AND a.goods_biz_type = #{goodsBizType}
  50. </if>
  51. <choose>
  52. <when test="sidx != null and sidx.trim() != ''">
  53. order by ${sidx} ${order}
  54. </when>
  55. <otherwise>
  56. order by id desc
  57. </otherwise>
  58. </choose>
  59. <if test="offset != null and limit != null">
  60. limit #{offset}, #{limit}
  61. </if>
  62. </select>
  63. <select id="queryTotal" resultType="int">
  64. select count(distinct a.id)
  65. from mall_cart a
  66. LEFT JOIN mall_merch_user d ON a.user_id=d.user_id
  67. where 1=1
  68. <if test="storeId != null">
  69. and d.store_id = #{storeId}
  70. </if>
  71. <if test="merchSn != null and merchSn.trim() != ''">
  72. and d.merch_sn = #{merchSn}
  73. </if>
  74. <if test="userId != null">
  75. AND mall_cart.user_id = #{userId}
  76. </if>
  77. </select>
  78. <insert id="save" parameterType="com.kmall.admin.entity.CartEntity" useGeneratedKeys="true" keyProperty="id">
  79. insert into mall_cart
  80. (
  81. `user_id`,
  82. `goods_id`,
  83. `goods_sn`,
  84. `product_id`,
  85. `goods_name`,
  86. `market_price`,
  87. `retail_price`,
  88. `number`,
  89. `goods_specification_name_value`,
  90. `goods_specification_ids`,
  91. `checked`,
  92. `list_pic_url`,
  93. `stock_num`,
  94. `store_id`,
  95. `sku`,
  96. `goods_biz_type`,
  97. `creater_sn`,
  98. `create_time`,
  99. `moder_sn`,
  100. `mod_time`
  101. )
  102. values
  103. (
  104. #{userId},
  105. #{goodsId},
  106. #{goodsSn},
  107. #{productId},
  108. #{goodsName},
  109. #{marketPrice},
  110. #{retailPrice},
  111. #{number},
  112. #{goodsSpecificationNameValue},
  113. #{goodsSpecificationIds},
  114. #{checked},
  115. #{listPicUrl},
  116. #{stockNum},
  117. #{storeId},
  118. #{sku},
  119. #{goodsBizType},
  120. #{createrSn},
  121. #{createTime},
  122. #{moderSn},
  123. #{modTime}
  124. )
  125. </insert>
  126. <update id="update" parameterType="com.kmall.admin.entity.CartEntity">
  127. update mall_cart
  128. <set>
  129. <if test="userId != null">`user_id` = #{userId},</if>
  130. <if test="goodsId != null">`goods_id` = #{goodsId},</if>
  131. <if test="goodsSn != null">`goods_sn` = #{goodsSn},</if>
  132. <if test="productId != null">`product_id` = #{productId},</if>
  133. <if test="goodsName != null">`goods_name` = #{goodsName},</if>
  134. <if test="marketPrice != null">`market_price` = #{marketPrice},</if>
  135. <if test="retailPrice != null">`retail_price` = #{retailPrice},</if>
  136. <if test="number != null">`number` = #{number},</if>
  137. <if test="goodsSpecificationNameValue != null">`goods_specification_name_value` =
  138. #{goodsSpecificationNameValue},
  139. </if>
  140. <if test="goodsSpecificationIds != null">`goods_specification_ids` = #{goodsSpecificationIds},</if>
  141. <if test="checked != null">`checked` = #{checked},</if>
  142. <if test="listPicUrl != null">`list_pic_url` = #{listPicUrl},</if>
  143. <if test="stockNum != null">`stock_num` = #{stockNum},</if>
  144. <if test="storeId != null">`store_id` = #{storeId},</if>
  145. <if test="goodsBizType != null">`goods_biz_type` = #{goodsBizType},</if>
  146. <if test="createrSn != null" >
  147. creater_sn = #{createrSn,jdbcType=VARCHAR},
  148. </if>
  149. <if test="createTime != null" >
  150. create_time = #{createTime,jdbcType=TIMESTAMP},
  151. </if>
  152. <if test="moderSn != null" >
  153. moder_sn = #{moderSn,jdbcType=VARCHAR},
  154. </if>
  155. <if test="modTime != null" >
  156. mod_time = #{modTime,jdbcType=TIMESTAMP}
  157. </if>
  158. </set>
  159. where id = #{id}
  160. </update>
  161. <delete id="delete">
  162. delete from mall_cart where id = #{value}
  163. </delete>
  164. <delete id="deleteBatch">
  165. delete from mall_cart where id in
  166. <foreach item="id" collection="array" open="(" separator="," close=")">
  167. #{id}
  168. </foreach>
  169. </delete>
  170. </mapper>