1
0

CartDao.xml 7.3 KB

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