<?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.fuxi.ws.data.dao.WGcartMapper">
	<resultMap id="BaseResultMap" type="com.fuxi.ws.data.entity.WGcart">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Fri Mar 20 
			12:01:43 CST 2015. -->
		<id column="GcartID" property="gcartid" jdbcType="BIGINT" />
		<result column="Fitting" property="fitting" jdbcType="BIGINT" />
		<result column="EmployeeID" property="employeeid" jdbcType="VARCHAR" />
		<result column="Vipid" property="vipid" jdbcType="VARCHAR" />
		<result column="GoodsID" property="goodsid" jdbcType="VARCHAR" />
		<result column="ColorID" property="colorid" jdbcType="VARCHAR" />
		<result column="SizeID" property="sizeid" jdbcType="VARCHAR" />
		<result column="Quantity" property="quantity" jdbcType="INTEGER" />
		<result column="Price" property="price" jdbcType="DECIMAL" />
		<result column="Dec" property="dec" jdbcType="NVARCHAR" />
	</resultMap>
	<sql id="Example_Where_Clause">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Fri Mar 20 
			12:01:43 CST 2015. -->
		<where>
			<foreach collection="oredCriteria" item="criteria" separator="or">
				<if test="criteria.valid">
					<trim prefix="(" suffix=")" prefixOverrides="and">
						<foreach collection="criteria.criteria" item="criterion">
							<choose>
								<when test="criterion.noValue">
									and ${criterion.condition}
								</when>
								<when test="criterion.singleValue">
									and ${criterion.condition} #{criterion.value}
								</when>
								<when test="criterion.betweenValue">
									and ${criterion.condition} #{criterion.value}
									and
									#{criterion.secondValue}
								</when>
								<when test="criterion.listValue">
									and ${criterion.condition}
									<foreach collection="criterion.value" item="listItem"
										open="(" close=")" separator=",">
										#{listItem}
									</foreach>
								</when>
							</choose>
						</foreach>
					</trim>
				</if>
			</foreach>
		</where>
	</sql>
	<sql id="Base_Column_List">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Fri Mar 20 
			12:01:43 CST 2015. -->
		GcartID, Fitting, EmployeeID, Vipid, GoodsID, ColorID, SizeID,
		Quantity, Price, Dec
	</sql>
	<select id="selectByExample" resultMap="BaseResultMap"
		parameterType="com.fuxi.ws.data.entity.WGcartExample">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Fri Mar 20 
			12:01:43 CST 2015. -->
		select
		<if test="distinct">
			distinct
		</if>
		'false' as QUERYID,
		<include refid="Base_Column_List" />
		from W_Gcart
		<if test="_parameter != null">
			<include refid="Example_Where_Clause" />
		</if>
		<if test="orderByClause != null">
			order by ${orderByClause}
		</if>
	</select>
	<select id="selectByPrimaryKey" resultMap="BaseResultMap"
		parameterType="java.lang.Long">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Fri Mar 20 
			12:01:43 CST 2015. -->
		select
		<include refid="Base_Column_List" />
		from W_Gcart
		where GcartID = #{gcartid,jdbcType=BIGINT}
	</select>
	<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Fri Mar 20 
			12:01:43 CST 2015. -->
		delete from W_Gcart
		where GcartID = #{gcartid,jdbcType=BIGINT}
	</delete>
	<insert id="insert" parameterType="com.fuxi.ws.data.entity.WGcart">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Fri Mar 20 
			12:01:43 CST 2015. -->
		insert into W_Gcart (GcartID, Fitting, EmployeeID,
		Vipid, GoodsID,
		ColorID,
		SizeID, Quantity, Price,
		Dec)
		values
		(#{gcartid,jdbcType=BIGINT}, #{fitting,jdbcType=BIGINT},
		#{employeeid,jdbcType=VARCHAR},
		#{vipid,jdbcType=VARCHAR},
		#{goodsid,jdbcType=VARCHAR}, #{colorid,jdbcType=VARCHAR},
		#{sizeid,jdbcType=VARCHAR}, #{quantity,jdbcType=INTEGER},
		#{price,jdbcType=DECIMAL},
		#{dec,jdbcType=NVARCHAR})
	</insert>
	<insert id="insertSelective" parameterType="com.fuxi.ws.data.entity.WGcart">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Fri Mar 20 
			12:01:43 CST 2015. -->
		insert into W_Gcart
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="gcartid != null">
				GcartID,
			</if>
			<if test="fitting != null">
				Fitting,
			</if>
			<if test="employeeid != null">
				EmployeeID,
			</if>
			<if test="vipid != null">
				Vipid,
			</if>
			<if test="goodsid != null">
				GoodsID,
			</if>
			<if test="colorid != null">
				ColorID,
			</if>
			<if test="sizeid != null">
				SizeID,
			</if>
			<if test="quantity != null">
				Quantity,
			</if>
			<if test="price != null">
				Price,
			</if>
			<if test="dec != null">
				Dec,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="gcartid != null">
				#{gcartid,jdbcType=BIGINT},
			</if>
			<if test="fitting != null">
				#{fitting,jdbcType=BIGINT},
			</if>
			<if test="employeeid != null">
				#{employeeid,jdbcType=VARCHAR},
			</if>
			<if test="vipid != null">
				#{vipid,jdbcType=VARCHAR},
			</if>
			<if test="goodsid != null">
				#{goodsid,jdbcType=VARCHAR},
			</if>
			<if test="colorid != null">
				#{colorid,jdbcType=VARCHAR},
			</if>
			<if test="sizeid != null">
				#{sizeid,jdbcType=VARCHAR},
			</if>
			<if test="quantity != null">
				#{quantity,jdbcType=INTEGER},
			</if>
			<if test="price != null">
				#{price,jdbcType=DECIMAL},
			</if>
			<if test="dec != null">
				#{dec,jdbcType=NVARCHAR},
			</if>
		</trim>
	</insert>
	<select id="countByExample" parameterType="com.fuxi.ws.data.entity.WGcartExample"
		resultType="java.lang.Integer">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Fri Mar 20 
			12:01:43 CST 2015. -->
		select count(*) from W_Gcart
		<if test="_parameter != null">
			<include refid="Example_Where_Clause" />
		</if>
	</select>
	<update id="updateByPrimaryKeySelective" parameterType="com.fuxi.ws.data.entity.WGcart">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Fri Mar 20 
			12:01:43 CST 2015. -->
		update W_Gcart
		<set>
			<if test="fitting != null">
				Fitting = #{fitting,jdbcType=BIGINT},
			</if>
			<if test="employeeid != null">
				EmployeeID = #{employeeid,jdbcType=VARCHAR},
			</if>
			<if test="vipid != null">
				Vipid = #{vipid,jdbcType=VARCHAR},
			</if>
			<if test="goodsid != null">
				GoodsID = #{goodsid,jdbcType=VARCHAR},
			</if>
			<if test="colorid != null">
				ColorID = #{colorid,jdbcType=VARCHAR},
			</if>
			<if test="sizeid != null">
				SizeID = #{sizeid,jdbcType=VARCHAR},
			</if>
			<if test="quantity != null">
				Quantity = #{quantity,jdbcType=INTEGER},
			</if>
			<if test="price != null">
				Price = #{price,jdbcType=DECIMAL},
			</if>
			<if test="dec != null">
				Dec = #{dec,jdbcType=NVARCHAR},
			</if>
		</set>
		where GcartID = #{gcartid,jdbcType=BIGINT}
	</update>
	<update id="updateByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WGcart">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Fri Mar 20 
			12:01:43 CST 2015. -->
		update W_Gcart
		set Fitting = #{fitting,jdbcType=BIGINT},
		EmployeeID =
		#{employeeid,jdbcType=VARCHAR},
		Vipid = #{vipid,jdbcType=VARCHAR},
		GoodsID = #{goodsid,jdbcType=VARCHAR},
		ColorID =
		#{colorid,jdbcType=VARCHAR},
		SizeID = #{sizeid,jdbcType=VARCHAR},
		Quantity = #{quantity,jdbcType=INTEGER},
		Price =
		#{price,jdbcType=DECIMAL},
		Dec = #{dec,jdbcType=NVARCHAR}
		where GcartID
		= #{gcartid,jdbcType=BIGINT}
	</update>

	<select id="getGCart" resultType="java.util.LinkedHashMap">
		select
		a.GcartID,a.Fitting,a.EmployeeID,a.Vipid,a.GoodsID,a.ColorID,a.SizeID,a.Quantity,a.BuyKind,b.Price,a.Dec,
		b.GoodName,b.ImgPath,b.AtList,b.Postage,b.PayByPoint,c.Color,d.Size,b.ViewColor,b.ViewSize,e.Price
		Price2,f.PromotPrice,e.PreMoney,b.BookingFlag,e.Quantity InvQty
		from W_Gcart a with(nolock) 
		join
		W_Goods b with(nolock) on
		a.GoodsID=b.GoodsID
		join Color c with(nolock)
		on
		a.ColorID=c.ColorID
		join
		Size d with(nolock) on
		a.SizeID=d.SizeID
		join W_Store e with(nolock) on
		a.GoodsID=e.GoodsID and
		a.ColorID=e.ColorID and a.SizeID=e.SizeID
		left
		join W_PromotionsStore f with(nolock)
		on a.GoodsID=f.GoodsID and
		a.ColorID=f.ColorID
		and a.SizeID=f.SizeID
		where
		a.EmployeeID=#{employeeid}
	</select>

	<!-- 删除全部商品 -->
	<delete id="allDelete">
		delete from W_Gcart
		where EmployeeID = #{employeeid}
	</delete>

	<update id="updateCartVip">
		update W_Gcart set Vipid=#{vipid},Fitting='' where
		EmployeeID=#{employeeid}
	</update>
	
	<select id="cashiergoodslist" resultType="java.util.LinkedHashMap">
		select a.GoodsID,b.Code,b.GoodName,b.ImgPath,a.SizeID,d.Size,a.ColorID,a.Price as TransferPrice,e.Color,a.Quantity,c.Price,b.Price as GoodsPrice,b.ViewColor,b.ViewSize,c.Quantity as InvQty,b.PriceDec 
		from W_Gcart as a 
		inner join W_Goods as b on a.GoodsID=b.GoodsID 
		inner join W_Store as c on a.GoodsID=c.GoodsID and a.ColorID=c.ColorID and a.SizeID=c.SizeID 
		left join Size as d on a.SizeID=d.SizeID 
		left join Color as e on a.ColorID=e.ColorID 
		where a.Fitting is null and c.Quantity>0 and a.EmployeeID=#{employeeid,jdbcType=VARCHAR}
	</select>
</mapper>