123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.kmall.admin.dao.CartDao">
- <!-- 可根据自己的需求,是否要使用 -->
- <resultMap type="com.kmall.admin.entity.CartEntity" id="cartMap">
- <result property="id" column="id"/>
- <result property="userName" column="user_name"/>
- <result property="userId" column="user_id"/>
- <result property="goodsId" column="goods_id"/>
- <result property="goodsSn" column="goods_sn"/>
- <result property="productId" column="product_id"/>
- <result property="goodsName" column="goods_name"/>
- <result property="marketPrice" column="market_price"/>
- <result property="retailPrice" column="retail_price"/>
- <result property="number" column="number"/>
- <result property="goodsSpecificationNameValue" column="goods_specification_name_value"/>
- <result property="goodsSpecificationIds" column="goods_specification_ids"/>
- <result property="checked" column="checked"/>
- <result property="listPicUrl" column="list_pic_url"/>
- <result column="sku" property="sku" jdbcType="VARCHAR" />
- <result column="goods_biz_type" property="goodsBizType" jdbcType="CHAR" />
- <result column="creater_sn" property="createrSn" jdbcType="VARCHAR" />
- <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
- <result column="moder_sn" property="moderSn" jdbcType="VARCHAR" />
- <result column="mod_time" property="modTime" jdbcType="TIMESTAMP" />
- <result column="tstm" property="tstm" jdbcType="TIMESTAMP" />
- <result property="stockNum" column="productStockNum"/>
- <result property="storeName" column="store_name"/>
- </resultMap>
- <select id="queryObject" resultType="com.kmall.admin.entity.CartEntity">
- select * from mall_cart where id = #{value}
- </select>
- <select id="queryList" resultMap="cartMap">
- select distinct a.* ,b.nickname as user_name
- from mall_cart a
- left join mall_user b on a.user_id = b.id
- LEFT JOIN mall_merch_user d ON a.user_id = d.user_id and a.store_id = d.store_id
- left join mall_store s on d.store_id = s.id
- where 1=1
- <if test="storeId != null">
- and d.store_id = #{storeId}
- </if>
- <if test="merchSn != null and merchSn.trim() != ''">
- and d.merch_sn = #{merchSn}
- </if>
- <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
- AND s.third_party_merch_code = #{thirdPartyMerchCode}
- </if>
- <if test="goodsId != null">
- and a.goods_id = #{goodsId}
- </if>
- <if test="userId != null">
- AND a.user_id = #{userId}
- </if>
- <if test="goodsBizType != null">
- AND a.goods_biz_type = #{goodsBizType}
- </if>
- <choose>
- <when test="sidx != null and sidx.trim() != ''">
- order by ${sidx} ${order}
- </when>
- <otherwise>
- order by id desc
- </otherwise>
- </choose>
- <if test="offset != null and limit != null">
- limit #{offset}, #{limit}
- </if>
- </select>
- <select id="queryTotal" resultType="int">
- select count(distinct a.id)
- from mall_cart a
- LEFT JOIN mall_merch_user d ON a.user_id=d.user_id
- left join mall_store s on d.store_id = s.id
- where 1=1
- <if test="storeId != null">
- and d.store_id = #{storeId}
- </if>
- <if test="merchSn != null and merchSn.trim() != ''">
- and d.merch_sn = #{merchSn}
- </if>
- <if test="goodsId != null">
- and a.goods_id = #{goodsId}
- </if>
- <if test="userId != null">
- AND d.user_id = #{userId}
- </if>
- <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
- AND s.third_party_merch_code = #{thirdPartyMerchCode}
- </if>
- </select>
- <insert id="save" parameterType="com.kmall.admin.entity.CartEntity" useGeneratedKeys="true" keyProperty="id">
- insert into mall_cart
- (
- `user_id`,
- `goods_id`,
- `goods_sn`,
- `product_id`,
- `goods_name`,
- `market_price`,
- `retail_price`,
- `number`,
- `goods_specification_name_value`,
- `goods_specification_ids`,
- `checked`,
- `list_pic_url`,
- `stock_num`,
- `store_id`,
- `sku`,
- `goods_biz_type`,
- `creater_sn`,
- `create_time`,
- `moder_sn`,
- `mod_time`
- )
- values
- (
- #{userId},
- #{goodsId},
- #{goodsSn},
- #{productId},
- #{goodsName},
- #{marketPrice},
- #{retailPrice},
- #{number},
- #{goodsSpecificationNameValue},
- #{goodsSpecificationIds},
- #{checked},
- #{listPicUrl},
- #{stockNum},
- #{storeId},
- #{sku},
- #{goodsBizType},
- #{createrSn},
- #{createTime},
- #{moderSn},
- #{modTime}
- )
- </insert>
- <update id="update" parameterType="com.kmall.admin.entity.CartEntity">
- update mall_cart
- <set>
- <if test="userId != null">`user_id` = #{userId},</if>
- <if test="goodsId != null">`goods_id` = #{goodsId},</if>
- <if test="goodsSn != null">`goods_sn` = #{goodsSn},</if>
- <if test="productId != null">`product_id` = #{productId},</if>
- <if test="goodsName != null">`goods_name` = #{goodsName},</if>
- <if test="marketPrice != null">`market_price` = #{marketPrice},</if>
- <if test="retailPrice != null">`retail_price` = #{retailPrice},</if>
- <if test="number != null">`number` = #{number},</if>
- <if test="goodsSpecificationNameValue != null">`goods_specification_name_value` =
- #{goodsSpecificationNameValue},
- </if>
- <if test="goodsSpecificationIds != null">`goods_specification_ids` = #{goodsSpecificationIds},</if>
- <if test="checked != null">`checked` = #{checked},</if>
- <if test="listPicUrl != null">`list_pic_url` = #{listPicUrl},</if>
- <if test="stockNum != null">`stock_num` = #{stockNum},</if>
- <if test="storeId != null">`store_id` = #{storeId},</if>
- <if test="goodsBizType != null">`goods_biz_type` = #{goodsBizType},</if>
- <if test="createrSn != null" >
- creater_sn = #{createrSn,jdbcType=VARCHAR},
- </if>
- <if test="createTime != null" >
- create_time = #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="moderSn != null" >
- moder_sn = #{moderSn,jdbcType=VARCHAR},
- </if>
- <if test="modTime != null" >
- mod_time = #{modTime,jdbcType=TIMESTAMP}
- </if>
- </set>
- where id = #{id}
- </update>
- <delete id="delete">
- delete from mall_cart where id = #{value}
- </delete>
- <delete id="deleteBatch">
- delete from mall_cart where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- </mapper>
|