1
0

CartDao.xml 7.0 KB

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