<?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.WProfitsharMapper">
	<resultMap id="BaseResultMap" type="com.fuxi.ws.data.entity.WProfitshar">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Mon Jun 13 
			13:47:22 CST 2016. -->
		<id column="EShopOrderID" jdbcType="INTEGER" property="eshoporderid" />
		<id column="GoodsID" jdbcType="VARCHAR" property="goodsid" />
		<result column="SaleQty" jdbcType="INTEGER" property="saleqty" />
		<result column="ReturnQty" jdbcType="INTEGER" property="returnqty" />
		<result column="TotalSale" jdbcType="DECIMAL" property="totalsale" />
		<result column="TotalReturn" jdbcType="DECIMAL" property="totalreturn" />
		<result column="POSSalesID" jdbcType="VARCHAR" property="possalesid" />
		<result column="VIPID" jdbcType="VARCHAR" property="vipid" />
		<result column="wxId" jdbcType="NVARCHAR" property="wxid" />
		<result column="ReturnRate" jdbcType="DECIMAL" property="returnrate" />
		<result column="ReturnAmt" jdbcType="DECIMAL" property="returnamt" />
		<result column="RecommenderVIP" jdbcType="VARCHAR" property="recommendervip" />
		<result column="Rec_ReturnRate" jdbcType="DECIMAL" property="recReturnrate" />
		<result column="Rec_ReturnAmt" jdbcType="DECIMAL" property="recReturnamt" />
		<result column="OwnerDeptID" jdbcType="VARCHAR" property="ownerdeptid" />
		<result column="OwnerRate" jdbcType="DECIMAL" property="ownerrate" />
		<result column="OwnerAmt" jdbcType="DECIMAL" property="owneramt" />
		<result column="BusinessDept" jdbcType="VARCHAR" property="businessdept" />
		<result column="BusinessDeptRate" jdbcType="DECIMAL" property="businessdeptrate" />
		<result column="BusinessDeptAmt" jdbcType="DECIMAL" property="businessdeptamt" />
		<result column="Employee" jdbcType="VARCHAR" property="employee" />
		<result column="EmployeeRate" jdbcType="DECIMAL" property="employeerate" />
		<result column="EmployeeAmt" jdbcType="DECIMAL" property="employeeamt" />
		<result column="Distributer" jdbcType="VARCHAR" property="distributer" />
		<result column="DistributerRate" jdbcType="DECIMAL" property="distributerrate" />
		<result column="DistributerAmt" jdbcType="DECIMAL" property="distributeramt" />
		<result column="ParentDistributer" jdbcType="VARCHAR" property="parentdistributer" />
		<result column="ParentDistributerRate" jdbcType="DECIMAL"
			property="parentdistributerrate" />
		<result column="ParentDistributerAmt" jdbcType="DECIMAL"
			property="parentdistributeramt" />
		<result column="GuideID" jdbcType="VARCHAR" property="guideid" />
		<result column="GuideRate" jdbcType="DECIMAL" property="guiderate" />
		<result column="GuideAmt" jdbcType="DECIMAL" property="guideamt" />
		<result column="DistribShopID" jdbcType="VARCHAR" property="distribshopid" />
		<result column="DistribShopRate" jdbcType="DECIMAL" property="distribshoprate" />
		<result column="DistribShopAmt" jdbcType="DECIMAL" property="distribshopamt" />
		<result column="Created" jdbcType="TIMESTAMP" property="created" />
		<result column="Status" jdbcType="TINYINT" property="status" />
		<result column="AllotSales" jdbcType="DECIMAL" property="allotsales" />
	</resultMap>
	<sql id="Example_Where_Clause">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Mon Jun 13 
			13:47:22 CST 2016. -->
		<where>
			<foreach collection="oredCriteria" item="criteria" separator="or">
				<if test="criteria.valid">
					<trim prefix="(" prefixOverrides="and" suffix=")">
						<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 close=")" collection="criterion.value" item="listItem"
										open="(" 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 Mon Jun 13 
			13:47:22 CST 2016. -->
		EShopOrderID, GoodsID, SaleQty, ReturnQty, TotalSale, TotalReturn,
		POSSalesID, VIPID,
		wxId, ReturnRate, ReturnAmt, RecommenderVIP, Rec_ReturnRate, Rec_ReturnAmt,
		OwnerDeptID,
		OwnerRate, OwnerAmt, BusinessDept, BusinessDeptRate, BusinessDeptAmt, Employee,
		EmployeeRate,
		EmployeeAmt, Distributer, DistributerRate, DistributerAmt, ParentDistributer,
		ParentDistributerRate,
		ParentDistributerAmt, GuideID, GuideRate, GuideAmt, DistribShopID, DistribShopRate,
		DistribShopAmt, Created, Status, AllotSales
	</sql>
	<select id="selectByExample" parameterType="com.fuxi.ws.data.entity.WProfitsharExample"
		resultMap="BaseResultMap">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Mon Jun 13 
			13:47:22 CST 2016. -->
		select
		<if test="distinct">
			distinct
		</if>
		'false' as QUERYID,
		<include refid="Base_Column_List" />
		from W_Profitshar
		<if test="_parameter != null">
			<include refid="Example_Where_Clause" />
		</if>
		<if test="orderByClause != null">
			order by ${orderByClause}
		</if>
	</select>
	<select id="selectByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WProfitsharKey"
		resultMap="BaseResultMap">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Mon Jun 13 
			13:47:22 CST 2016. -->
		select
		<include refid="Base_Column_List" />
		from W_Profitshar
		where EShopOrderID = #{eshoporderid,jdbcType=INTEGER}
		and GoodsID = #{goodsid,jdbcType=VARCHAR}
	</select>
	<delete id="deleteByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WProfitsharKey">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Mon Jun 13 
			13:47:22 CST 2016. -->
		delete from W_Profitshar
		where EShopOrderID = #{eshoporderid,jdbcType=INTEGER}
		and GoodsID = #{goodsid,jdbcType=VARCHAR}
	</delete>
	<insert id="insert" parameterType="com.fuxi.ws.data.entity.WProfitshar">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Mon Jun 13 
			13:47:22 CST 2016. -->
		insert into W_Profitshar (EShopOrderID, GoodsID, SaleQty,
		ReturnQty, TotalSale, TotalReturn,
		POSSalesID, VIPID, wxId,
		ReturnRate, ReturnAmt, RecommenderVIP,
		Rec_ReturnRate, Rec_ReturnAmt, OwnerDeptID,
		OwnerRate, OwnerAmt, BusinessDept,
		BusinessDeptRate, BusinessDeptAmt, Employee,
		EmployeeRate, EmployeeAmt, Distributer,
		DistributerRate, DistributerAmt, ParentDistributer,
		ParentDistributerRate, ParentDistributerAmt,
		GuideID, GuideRate, GuideAmt,
		DistribShopID, DistribShopRate, DistribShopAmt,
		Created, Status, AllotSales
		)
		values (#{eshoporderid,jdbcType=INTEGER}, #{goodsid,jdbcType=VARCHAR},
		#{saleqty,jdbcType=INTEGER},
		#{returnqty,jdbcType=INTEGER}, #{totalsale,jdbcType=DECIMAL}, #{totalreturn,jdbcType=DECIMAL},
		#{possalesid,jdbcType=VARCHAR}, #{vipid,jdbcType=VARCHAR},
		#{wxid,jdbcType=NVARCHAR},
		#{returnrate,jdbcType=DECIMAL}, #{returnamt,jdbcType=DECIMAL}, #{recommendervip,jdbcType=VARCHAR},
		#{recReturnrate,jdbcType=DECIMAL}, #{recReturnamt,jdbcType=DECIMAL},
		#{ownerdeptid,jdbcType=VARCHAR},
		#{ownerrate,jdbcType=DECIMAL}, #{owneramt,jdbcType=DECIMAL}, #{businessdept,jdbcType=VARCHAR},
		#{businessdeptrate,jdbcType=DECIMAL},
		#{businessdeptamt,jdbcType=DECIMAL}, #{employee,jdbcType=VARCHAR},
		#{employeerate,jdbcType=DECIMAL}, #{employeeamt,jdbcType=DECIMAL},
		#{distributer,jdbcType=VARCHAR},
		#{distributerrate,jdbcType=DECIMAL}, #{distributeramt,jdbcType=DECIMAL},
		#{parentdistributer,jdbcType=VARCHAR},
		#{parentdistributerrate,jdbcType=DECIMAL},
		#{parentdistributeramt,jdbcType=DECIMAL},
		#{guideid,jdbcType=VARCHAR}, #{guiderate,jdbcType=DECIMAL}, #{guideamt,jdbcType=DECIMAL},
		#{distribshopid,jdbcType=VARCHAR},
		#{distribshoprate,jdbcType=DECIMAL},
		#{distribshopamt,jdbcType=DECIMAL},
		#{created,jdbcType=TIMESTAMP}, #{status,jdbcType=TINYINT}, #{allotsales,jdbcType=DECIMAL}
		)
	</insert>
	<insert id="insertSelective" parameterType="com.fuxi.ws.data.entity.WProfitshar">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Mon Jun 13 
			13:47:22 CST 2016. -->
		insert into W_Profitshar
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="eshoporderid != null">
				EShopOrderID,
			</if>
			<if test="goodsid != null">
				GoodsID,
			</if>
			<if test="saleqty != null">
				SaleQty,
			</if>
			<if test="returnqty != null">
				ReturnQty,
			</if>
			<if test="totalsale != null">
				TotalSale,
			</if>
			<if test="totalreturn != null">
				TotalReturn,
			</if>
			<if test="possalesid != null">
				POSSalesID,
			</if>
			<if test="vipid != null">
				VIPID,
			</if>
			<if test="wxid != null">
				wxId,
			</if>
			<if test="returnrate != null">
				ReturnRate,
			</if>
			<if test="returnamt != null">
				ReturnAmt,
			</if>
			<if test="recommendervip != null">
				RecommenderVIP,
			</if>
			<if test="recReturnrate != null">
				Rec_ReturnRate,
			</if>
			<if test="recReturnamt != null">
				Rec_ReturnAmt,
			</if>
			<if test="ownerdeptid != null">
				OwnerDeptID,
			</if>
			<if test="ownerrate != null">
				OwnerRate,
			</if>
			<if test="owneramt != null">
				OwnerAmt,
			</if>
			<if test="businessdept != null">
				BusinessDept,
			</if>
			<if test="businessdeptrate != null">
				BusinessDeptRate,
			</if>
			<if test="businessdeptamt != null">
				BusinessDeptAmt,
			</if>
			<if test="employee != null">
				Employee,
			</if>
			<if test="employeerate != null">
				EmployeeRate,
			</if>
			<if test="employeeamt != null">
				EmployeeAmt,
			</if>
			<if test="distributer != null">
				Distributer,
			</if>
			<if test="distributerrate != null">
				DistributerRate,
			</if>
			<if test="distributeramt != null">
				DistributerAmt,
			</if>
			<if test="parentdistributer != null">
				ParentDistributer,
			</if>
			<if test="parentdistributerrate != null">
				ParentDistributerRate,
			</if>
			<if test="parentdistributeramt != null">
				ParentDistributerAmt,
			</if>
			<if test="guideid != null">
				GuideID,
			</if>
			<if test="guiderate != null">
				GuideRate,
			</if>
			<if test="guideamt != null">
				GuideAmt,
			</if>
			<if test="distribshopid != null">
				DistribShopID,
			</if>
			<if test="distribshoprate != null">
				DistribShopRate,
			</if>
			<if test="distribshopamt != null">
				DistribShopAmt,
			</if>
			<if test="created != null">
				Created,
			</if>
			<if test="status != null">
				Status,
			</if>
			<if test="allotsales != null">
				AllotSales,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="eshoporderid != null">
				#{eshoporderid,jdbcType=INTEGER},
			</if>
			<if test="goodsid != null">
				#{goodsid,jdbcType=VARCHAR},
			</if>
			<if test="saleqty != null">
				#{saleqty,jdbcType=INTEGER},
			</if>
			<if test="returnqty != null">
				#{returnqty,jdbcType=INTEGER},
			</if>
			<if test="totalsale != null">
				#{totalsale,jdbcType=DECIMAL},
			</if>
			<if test="totalreturn != null">
				#{totalreturn,jdbcType=DECIMAL},
			</if>
			<if test="possalesid != null">
				#{possalesid,jdbcType=VARCHAR},
			</if>
			<if test="vipid != null">
				#{vipid,jdbcType=VARCHAR},
			</if>
			<if test="wxid != null">
				#{wxid,jdbcType=NVARCHAR},
			</if>
			<if test="returnrate != null">
				#{returnrate,jdbcType=DECIMAL},
			</if>
			<if test="returnamt != null">
				#{returnamt,jdbcType=DECIMAL},
			</if>
			<if test="recommendervip != null">
				#{recommendervip,jdbcType=VARCHAR},
			</if>
			<if test="recReturnrate != null">
				#{recReturnrate,jdbcType=DECIMAL},
			</if>
			<if test="recReturnamt != null">
				#{recReturnamt,jdbcType=DECIMAL},
			</if>
			<if test="ownerdeptid != null">
				#{ownerdeptid,jdbcType=VARCHAR},
			</if>
			<if test="ownerrate != null">
				#{ownerrate,jdbcType=DECIMAL},
			</if>
			<if test="owneramt != null">
				#{owneramt,jdbcType=DECIMAL},
			</if>
			<if test="businessdept != null">
				#{businessdept,jdbcType=VARCHAR},
			</if>
			<if test="businessdeptrate != null">
				#{businessdeptrate,jdbcType=DECIMAL},
			</if>
			<if test="businessdeptamt != null">
				#{businessdeptamt,jdbcType=DECIMAL},
			</if>
			<if test="employee != null">
				#{employee,jdbcType=VARCHAR},
			</if>
			<if test="employeerate != null">
				#{employeerate,jdbcType=DECIMAL},
			</if>
			<if test="employeeamt != null">
				#{employeeamt,jdbcType=DECIMAL},
			</if>
			<if test="distributer != null">
				#{distributer,jdbcType=VARCHAR},
			</if>
			<if test="distributerrate != null">
				#{distributerrate,jdbcType=DECIMAL},
			</if>
			<if test="distributeramt != null">
				#{distributeramt,jdbcType=DECIMAL},
			</if>
			<if test="parentdistributer != null">
				#{parentdistributer,jdbcType=VARCHAR},
			</if>
			<if test="parentdistributerrate != null">
				#{parentdistributerrate,jdbcType=DECIMAL},
			</if>
			<if test="parentdistributeramt != null">
				#{parentdistributeramt,jdbcType=DECIMAL},
			</if>
			<if test="guideid != null">
				#{guideid,jdbcType=VARCHAR},
			</if>
			<if test="guiderate != null">
				#{guiderate,jdbcType=DECIMAL},
			</if>
			<if test="guideamt != null">
				#{guideamt,jdbcType=DECIMAL},
			</if>
			<if test="distribshopid != null">
				#{distribshopid,jdbcType=VARCHAR},
			</if>
			<if test="distribshoprate != null">
				#{distribshoprate,jdbcType=DECIMAL},
			</if>
			<if test="distribshopamt != null">
				#{distribshopamt,jdbcType=DECIMAL},
			</if>
			<if test="created != null">
				#{created,jdbcType=TIMESTAMP},
			</if>
			<if test="status != null">
				#{status,jdbcType=TINYINT},
			</if>
			<if test="allotsales != null">
				#{allotsales,jdbcType=DECIMAL},
			</if>
		</trim>
	</insert>
	<select id="countByExample" parameterType="com.fuxi.ws.data.entity.WProfitsharExample"
		resultType="java.lang.Integer">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Mon Jun 13 
			13:47:22 CST 2016. -->
		select count(*) from W_Profitshar
		<if test="_parameter != null">
			<include refid="Example_Where_Clause" />
		</if>
	</select>
	<update id="updateByPrimaryKeySelective" parameterType="com.fuxi.ws.data.entity.WProfitshar">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Mon Jun 13 
			13:47:22 CST 2016. -->
		update W_Profitshar
		<set>
			<if test="saleqty != null">
				SaleQty = #{saleqty,jdbcType=INTEGER},
			</if>
			<if test="returnqty != null">
				ReturnQty = #{returnqty,jdbcType=INTEGER},
			</if>
			<if test="totalsale != null">
				TotalSale = #{totalsale,jdbcType=DECIMAL},
			</if>
			<if test="totalreturn != null">
				TotalReturn = #{totalreturn,jdbcType=DECIMAL},
			</if>
			<if test="possalesid != null">
				POSSalesID = #{possalesid,jdbcType=VARCHAR},
			</if>
			<if test="vipid != null">
				VIPID = #{vipid,jdbcType=VARCHAR},
			</if>
			<if test="wxid != null">
				wxId = #{wxid,jdbcType=NVARCHAR},
			</if>
			<if test="returnrate != null">
				ReturnRate = #{returnrate,jdbcType=DECIMAL},
			</if>
			<if test="returnamt != null">
				ReturnAmt = #{returnamt,jdbcType=DECIMAL},
			</if>
			<if test="recommendervip != null">
				RecommenderVIP = #{recommendervip,jdbcType=VARCHAR},
			</if>
			<if test="recReturnrate != null">
				Rec_ReturnRate = #{recReturnrate,jdbcType=DECIMAL},
			</if>
			<if test="recReturnamt != null">
				Rec_ReturnAmt = #{recReturnamt,jdbcType=DECIMAL},
			</if>
			<if test="ownerdeptid != null">
				OwnerDeptID = #{ownerdeptid,jdbcType=VARCHAR},
			</if>
			<if test="ownerrate != null">
				OwnerRate = #{ownerrate,jdbcType=DECIMAL},
			</if>
			<if test="owneramt != null">
				OwnerAmt = #{owneramt,jdbcType=DECIMAL},
			</if>
			<if test="businessdept != null">
				BusinessDept = #{businessdept,jdbcType=VARCHAR},
			</if>
			<if test="businessdeptrate != null">
				BusinessDeptRate = #{businessdeptrate,jdbcType=DECIMAL},
			</if>
			<if test="businessdeptamt != null">
				BusinessDeptAmt = #{businessdeptamt,jdbcType=DECIMAL},
			</if>
			<if test="employee != null">
				Employee = #{employee,jdbcType=VARCHAR},
			</if>
			<if test="employeerate != null">
				EmployeeRate = #{employeerate,jdbcType=DECIMAL},
			</if>
			<if test="employeeamt != null">
				EmployeeAmt = #{employeeamt,jdbcType=DECIMAL},
			</if>
			<if test="distributer != null">
				Distributer = #{distributer,jdbcType=VARCHAR},
			</if>
			<if test="distributerrate != null">
				DistributerRate = #{distributerrate,jdbcType=DECIMAL},
			</if>
			<if test="distributeramt != null">
				DistributerAmt = #{distributeramt,jdbcType=DECIMAL},
			</if>
			<if test="parentdistributer != null">
				ParentDistributer = #{parentdistributer,jdbcType=VARCHAR},
			</if>
			<if test="parentdistributerrate != null">
				ParentDistributerRate = #{parentdistributerrate,jdbcType=DECIMAL},
			</if>
			<if test="parentdistributeramt != null">
				ParentDistributerAmt = #{parentdistributeramt,jdbcType=DECIMAL},
			</if>
			<if test="guideid != null">
				GuideID = #{guideid,jdbcType=VARCHAR},
			</if>
			<if test="guiderate != null">
				GuideRate = #{guiderate,jdbcType=DECIMAL},
			</if>
			<if test="guideamt != null">
				GuideAmt = #{guideamt,jdbcType=DECIMAL},
			</if>
			<if test="distribshopid != null">
				DistribShopID = #{distribshopid,jdbcType=VARCHAR},
			</if>
			<if test="distribshoprate != null">
				DistribShopRate = #{distribshoprate,jdbcType=DECIMAL},
			</if>
			<if test="distribshopamt != null">
				DistribShopAmt = #{distribshopamt,jdbcType=DECIMAL},
			</if>
			<if test="created != null">
				Created = #{created,jdbcType=TIMESTAMP},
			</if>
			<if test="status != null">
				Status = #{status,jdbcType=TINYINT},
			</if>
			<if test="allotsales != null">
				AllotSales = #{allotsales,jdbcType=DECIMAL},
			</if>
		</set>
		where EShopOrderID = #{eshoporderid,jdbcType=INTEGER}
		and GoodsID = #{goodsid,jdbcType=VARCHAR}
	</update>
	<update id="updateByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WProfitshar">
		<!-- WARNING - @mbggenerated This element is automatically generated by 
			MyBatis Generator, do not modify. This element was generated on Mon Jun 13 
			13:47:22 CST 2016. -->
		update W_Profitshar
		set SaleQty = #{saleqty,jdbcType=INTEGER},
		ReturnQty = #{returnqty,jdbcType=INTEGER},
		TotalSale = #{totalsale,jdbcType=DECIMAL},
		TotalReturn = #{totalreturn,jdbcType=DECIMAL},
		POSSalesID = #{possalesid,jdbcType=VARCHAR},
		VIPID = #{vipid,jdbcType=VARCHAR},
		wxId = #{wxid,jdbcType=NVARCHAR},
		ReturnRate = #{returnrate,jdbcType=DECIMAL},
		ReturnAmt = #{returnamt,jdbcType=DECIMAL},
		RecommenderVIP = #{recommendervip,jdbcType=VARCHAR},
		Rec_ReturnRate = #{recReturnrate,jdbcType=DECIMAL},
		Rec_ReturnAmt = #{recReturnamt,jdbcType=DECIMAL},
		OwnerDeptID = #{ownerdeptid,jdbcType=VARCHAR},
		OwnerRate = #{ownerrate,jdbcType=DECIMAL},
		OwnerAmt = #{owneramt,jdbcType=DECIMAL},
		BusinessDept = #{businessdept,jdbcType=VARCHAR},
		BusinessDeptRate = #{businessdeptrate,jdbcType=DECIMAL},
		BusinessDeptAmt = #{businessdeptamt,jdbcType=DECIMAL},
		Employee = #{employee,jdbcType=VARCHAR},
		EmployeeRate = #{employeerate,jdbcType=DECIMAL},
		EmployeeAmt = #{employeeamt,jdbcType=DECIMAL},
		Distributer = #{distributer,jdbcType=VARCHAR},
		DistributerRate = #{distributerrate,jdbcType=DECIMAL},
		DistributerAmt = #{distributeramt,jdbcType=DECIMAL},
		ParentDistributer = #{parentdistributer,jdbcType=VARCHAR},
		ParentDistributerRate = #{parentdistributerrate,jdbcType=DECIMAL},
		ParentDistributerAmt = #{parentdistributeramt,jdbcType=DECIMAL},
		GuideID = #{guideid,jdbcType=VARCHAR},
		GuideRate = #{guiderate,jdbcType=DECIMAL},
		GuideAmt = #{guideamt,jdbcType=DECIMAL},
		DistribShopID = #{distribshopid,jdbcType=VARCHAR},
		DistribShopRate = #{distribshoprate,jdbcType=DECIMAL},
		DistribShopAmt = #{distribshopamt,jdbcType=DECIMAL},
		Created = #{created,jdbcType=TIMESTAMP},
		Status = #{status,jdbcType=TINYINT},
		AllotSales = #{allotsales,jdbcType=DECIMAL}
		where EShopOrderID = #{eshoporderid,jdbcType=INTEGER}
		and GoodsID = #{goodsid,jdbcType=VARCHAR}
	</update>

	<!-- 我的钱包:总收入 -->
	<select id="totalIncome" resultType="java.lang.String">
		select SUM(case when
		Distributer=#{vipid} then
		DistributerAmt else 0 end)
		+SUM(case when
		ParentDistributer=#{vipid}
		then ParentDistributerAmt else
		0 end)
		totalIncome from W_Profitshar where
		Distributer=#{vipid} or
		ParentDistributer=#{vipid}
	</select>

	<!-- 分销商待提现 -->
	<select id="stayWithdraw" resultType="java.lang.String">
	<![CDATA[
		select SUM(case when a.Distributer=#{vipid} then a.DistributerAmt else 0 end)
		+SUM(case when a.ParentDistributer=#{vipid} then a.ParentDistributerAmt else
		0 end) from W_Profitshar a
		join EShopOrder b on a.EShopOrderID=b.EShopOrderID
		where (b.order_flag in ('4','5','8') or (b.order_flag='7' and b.RecieveTime > #{receiveTime})) and (Distributer=#{vipid} or
		ParentDistributer=#{vipid})
	]]>
	</select>

	<!-- 分销商可提现 -->
	<select id="usableWithdraw" resultType="java.lang.String">
	<![CDATA[
		select SUM(case when a.Distributer=#{vipid} then a.DistributerAmt else 0 end)
		+SUM(case when a.ParentDistributer=#{vipid} then a.ParentDistributerAmt else
		0 end) from W_Profitshar a
		join EShopOrder b on a.EShopOrderID=b.EShopOrderID
		where (b.order_flag='7' and b.RecieveTime <= #{receiveTime}) and (Distributer=#{vipid} or
		ParentDistributer=#{vipid})
	]]>
	</select>


	<!-- 分销商分成明细 -->
	<select id="selectProfitshar" parameterType="java.util.HashMap"
		resultType="java.util.LinkedHashMap">
		SELECT a.EShopOrderID,a.GoodsID,b.ImgPath, b.Code, b.GoodName, e.No,
		case when a.Distributer=c.VIPID then '自售' when a.ParentDistributer =
		v.VIPID then '下级' else '' end distributeSource,
		isnull(a.SaleQty,0)-isnull(a.ReturnQty,0) as Quantity,
		(select top 1
		j.UnitPrice from
		EShopOrderDetail j where e.EShopOrderID =
		j.EShopOrderID and
		j.GoodsID=a.GoodsID)
		UnitPrice,isnull(a.TotalSale,0)-ISNULL(a.TotalReturn,0) TotalSale,
		case when a.Distributer=c.VIPID then a.DistributerRate else
		a.ParentDistributerRate end as DistributerRate,
		case when
		a.Distributer=c.VIPID then a.DistributerAmt else
		a.ParentDistributerAmt end as DistributerAmt,
		isnull(convert(varchar(10),a.Created,121),'') + '<![CDATA[<br/>]]>'
		+ isnull(convert(varchar(8),a.Created,108),'') as Created,
		case
		e.order_flag when 7 then '已完成' else '进行中' end as
		orderflag,e.order_flag as Status
		FROM W_Profitshar AS a INNER JOIN
		EShopOrder AS e ON a.EShopOrderID = e.EShopOrderID
		INNER JOIN
		W_Goods AS
		b ON a.GoodsID = b.GoodsID left JOIN
		VIP AS c ON a.Distributer =
		c.VIPID
		<if test="vipid != '' and vipid != null ">
			and c.VIPID=#{vipid,jdbcType=VARCHAR}
		</if>
		<if test="nickname != '' and nickname != null ">
			and c.VIP=#{nickname,jdbcType=VARCHAR}
		</if>
		<if test="mobile != '' and mobile != null ">
			and c.MobilePhone=#{mobile,jdbcType=VARCHAR}
		</if>
		<if test="departmentid != '' and departmentid != null ">
			and c.DepartmentID=#{departmentid,jdbcType=VARCHAR}
		</if>
		left JOIN
		VIP AS v ON a.ParentDistributer = v.VIPID
		<if test="vipid != '' and vipid != null ">
			and v.VIPID=#{vipid,jdbcType=VARCHAR}
		</if>
		<if test="nickname != '' and nickname != null ">
			and v.VIP=#{nickname,jdbcType=VARCHAR}
		</if>
		<if test="mobile != '' and mobile != null ">
			and v.MobilePhone=#{mobile,jdbcType=VARCHAR}
		</if>
		<if test="departmentid != '' and departmentid != null ">
			and v.DepartmentID=#{departmentid,jdbcType=VARCHAR}
		</if>
		where (a.Distributer <![CDATA[<>]]>
		'' or a.ParentDistributer <![CDATA[<>]]>
		'') and a.TotalSale-a.TotalReturn <![CDATA[<>]]>
		0
		<if test="status == '0'.toString() ">
			and (e.order_flag <![CDATA[<>]]>
			7)
		</if>
		<if test="status == '1'.toString() ">
			and (e.order_flag = 7)
		</if>
		<if test="fromsource == ''.toString() ">
			<if test="nickname != '' and nickname != null ">
				and (c.VIP=#{nickname,jdbcType=VARCHAR} or
				v.VIP=#{nickname,jdbcType=VARCHAR})
			</if>
			<if test="mobile != '' and mobile != null ">
				and (c.MobilePhone=#{mobile,jdbcType=VARCHAR} or
				v.MobilePhone=#{mobile,jdbcType=VARCHAR})
			</if>
			<if test="vipid != '' and vipid != null ">
				and (a.Distributer=#{vipid,jdbcType=VARCHAR} or
				a.ParentDistributer=#{vipid,jdbcType=VARCHAR})
			</if>
		</if>
		<if test="fromsource == '1'.toString() ">
			<if test="nickname != '' and nickname != null ">
				and (c.VIP=#{nickname,jdbcType=VARCHAR})
			</if>
			<if test="mobile != '' and mobile != null ">
				and (c.MobilePhone=#{mobile,jdbcType=VARCHAR})
			</if>
			<if test="vipid != '' and vipid != null ">
				and (a.Distributer=#{vipid,jdbcType=VARCHAR})
			</if>
		</if>
		<if test="fromsource == '2'.toString() ">
			<if test="nickname != '' and nickname != null ">
				and (v.VIP=#{nickname,jdbcType=VARCHAR})
			</if>
			<if test="mobile != '' and mobile != null ">
				and (v.MobilePhone=#{mobile,jdbcType=VARCHAR})
			</if>
			<if test="vipid != '' and vipid != null ">
				and (a.ParentDistributer=#{vipid,jdbcType=VARCHAR})
			</if>
		</if>
		order by a.EShopOrderID desc
	</select>

	<!-- 我的钱包:收入列表 -->
	<select id="myWalletIncome" resultType="java.util.LinkedHashMap">
		<![CDATA[select * from (
		select CONVERT(varchar(10),a.Created,121)date1,CONVERT(varchar(8),a.Created,108)date2,a.Created,a.EShopOrderID,
		b.ImgPath, b.GoodName,
		case e.order_flag when 7 then '已完成' else '进行中' end as orderflag,
		case when a.Distributer=#{ vipid } then a.DistributerAmt else
		a.ParentDistributerAmt end as DistributerAmt,
		v.VIP
		FROM W_Profitshar AS a
		INNER JOIN EShopOrder AS e ON a.EShopOrderID = e.EShopOrderID
		INNER JOIN W_Goods AS b ON a.GoodsID = b.GoodsID
		JOIN VIP AS v ON e.Vipid = v.VIPID
		where (a.Distributer <> '' or a.ParentDistributer <> '') and
		(a.Distributer=#{ vipid } or a.ParentDistributer=#{ vipid })
		) t
		where t.DistributerAmt>0
		order by t.Created desc
		]]>
	</select>

	<select id="selectProfitsharTotal" parameterType="java.util.HashMap"
		resultType="java.util.HashMap">
		SELECT sum(isnull(a.TotalSale,0)-ISNULL(a.TotalReturn,0)) TotalSale,
		sum(case when a.Distributer=c.VIPID then a.DistributerAmt else
		a.ParentDistributerAmt end) as DistributerAmt
		FROM W_Profitshar AS a
		INNER JOIN
		EShopOrder AS e ON a.EShopOrderID = e.EShopOrderID
		<if test="departmentid != '' and departmentid != null ">
			inner join VIP p on p.vipid=a.vipid
			and
			p.DepartmentID=#{departmentid,jdbcType=VARCHAR}
		</if>
		INNER JOIN
		W_Goods AS d ON a.GoodsID = d.GoodsID left JOIN
		VIP AS c ON
		a.Distributer = c.VIPID
		<if test="vipid != '' and vipid != null ">
			and c.VIPID=#{vipid,jdbcType=VARCHAR}
		</if>
		<if test="nickname != '' and nickname != null ">
			and c.VIP=#{nickname,jdbcType=VARCHAR}
		</if>
		<if test="mobile != '' and mobile != null ">
			and c.MobilePhone=#{mobile,jdbcType=VARCHAR}
		</if>
		left JOIN
		VIP AS v ON a.ParentDistributer = v.VIPID
		<if test="vipid != '' and vipid != null ">
			and v.VIPID=#{vipid,jdbcType=VARCHAR}
		</if>
		<if test="nickname != '' and nickname != null ">
			and v.VIP=#{nickname,jdbcType=VARCHAR}
		</if>
		<if test="mobile != '' and mobile != null ">
			and v.MobilePhone=#{mobile,jdbcType=VARCHAR}
		</if>
		where (a.Distributer <![CDATA[<>]]>
		'' or a.ParentDistributer <![CDATA[<>]]>
		'')
		<if test="status == '0'.toString() ">
			and (e.order_flag <![CDATA[<>]]>
			7)
		</if>
		<if test="status == '1'.toString() ">
			and (e.order_flag = 7)
		</if>
		<if test="fromsource == ''.toString() ">
			<if test="nickname != '' and nickname != null ">
				and (c.VIP=#{nickname,jdbcType=VARCHAR} or
				v.VIP=#{nickname,jdbcType=VARCHAR})
			</if>
			<if test="mobile != '' and mobile != null ">
				and (c.MobilePhone=#{mobile,jdbcType=VARCHAR} or
				v.MobilePhone=#{mobile,jdbcType=VARCHAR})
			</if>
			<if test="vipid != '' and vipid != null ">
				and (a.Distributer=#{vipid,jdbcType=VARCHAR} or
				a.ParentDistributer=#{vipid,jdbcType=VARCHAR})
			</if>
		</if>
		<if test="fromsource == '1'.toString() ">
			<if test="nickname != '' and nickname != null ">
				and (c.VIP=#{nickname,jdbcType=VARCHAR})
			</if>
			<if test="mobile != '' and mobile != null ">
				and (c.MobilePhone=#{mobile,jdbcType=VARCHAR})
			</if>
			<if test="vipid != '' and vipid != null ">
				and (a.Distributer=#{vipid,jdbcType=VARCHAR})
			</if>
		</if>
		<if test="fromsource == '2'.toString() ">
			<if test="nickname != '' and nickname != null ">
				and (v.VIP=#{nickname,jdbcType=VARCHAR})
			</if>
			<if test="mobile != '' and mobile != null ">
				and (v.MobilePhone=#{mobile,jdbcType=VARCHAR})
			</if>
			<if test="vipid != '' and vipid != null ">
				and (a.ParentDistributer=#{vipid,jdbcType=VARCHAR})
			</if>
		</if>
	</select>

	<!-- 会员分成明细 -->
	<select id="vipProfitshar" parameterType="java.util.HashMap"
		resultType="java.util.LinkedHashMap">
		SELECT a.EShopOrderID,a.GoodsID,b.ImgPath, b.Code, b.GoodName, e.No,
		isnull(a.SaleQty,0)-isnull(a.ReturnQty,0) as Quantity,
		(select top 1
		j.UnitPrice from
		EShopOrderDetail j where e.EShopOrderID =
		j.EShopOrderID and
		j.GoodsID=a.GoodsID)
		UnitPrice,isnull(a.TotalSale,0)-ISNULL(a.TotalReturn,0) TotalSale,
		a.Rec_ReturnRate as DistributerRate,a.Rec_ReturnAmt as DistributerAmt,
		isnull(convert(varchar(10),a.Created,121),'') + '<![CDATA[<br/>]]>'
		+ isnull(convert(varchar(8),a.Created,108),'') as Created,
		case
		e.order_flag when 7 then '已完成' else '进行中' end as
		orderflag,e.order_flag as Status
		FROM W_Profitshar AS a INNER JOIN
		EShopOrder AS e ON a.EShopOrderID = e.EShopOrderID
		INNER JOIN
		W_Goods AS
		b ON a.GoodsID = b.GoodsID inner JOIN
		VIP AS c ON a.RecommenderVIP =
		c.VIPID
		where
		a.TotalSale-a.TotalReturn <![CDATA[<>]]>
		0
		<if test="status == '0'.toString() ">
			and (e.order_flag <![CDATA[<>]]>
			7)
		</if>
		<if test="status == '1'.toString() ">
			and (e.order_flag = 7)
		</if>
		<if test="nickname != '' and nickname != null ">
			and (c.VIP=#{nickname,jdbcType=VARCHAR})
		</if>
		<if test="mobile != '' and mobile != null ">
			and (c.MobilePhone=#{mobile,jdbcType=VARCHAR})
		</if>
		<if test="vipid != '' and vipid != null ">
			and (a.RecommenderVIP=#{vipid,jdbcType=VARCHAR})
		</if>
		<if test="departmentid != '' and departmentid != null ">
			and c.DepartmentID=#{departmentid,jdbcType=VARCHAR}
		</if>
		order by a.EShopOrderID desc
	</select>

	<select id="vipProfitsharTotal" parameterType="java.util.HashMap"
		resultType="java.util.HashMap">
		SELECT sum(isnull(a.TotalSale,0)-ISNULL(a.TotalReturn,0)) TotalSale,
		sum(a.Rec_ReturnAmt) as DistributerAmt
		FROM W_Profitshar AS a
		INNER JOIN
		EShopOrder AS e ON a.EShopOrderID = e.EShopOrderID
		<if test="departmentid != '' and departmentid != null ">
			inner join VIP p on p.vipid=a.vipid
			and
			p.DepartmentID=#{departmentid,jdbcType=VARCHAR}
		</if>
		INNER JOIN
		W_Goods AS d ON a.GoodsID = d.GoodsID inner JOIN
		VIP AS c ON
		a.RecommenderVIP = c.VIPID
		where 1=1
		<if test="status == '0'.toString() ">
			and (e.order_flag <![CDATA[<>]]>
			7)
		</if>
		<if test="status == '1'.toString() ">
			and (e.order_flag = 7)
		</if>
		<if test="nickname != '' and nickname != null ">
			and (c.VIP=#{nickname,jdbcType=VARCHAR})
		</if>
		<if test="mobile != '' and mobile != null ">
			and (c.MobilePhone=#{mobile,jdbcType=VARCHAR})
		</if>
		<if test="vipid != '' and vipid != null ">
			and (a.RecommenderVIP=#{vipid,jdbcType=VARCHAR})
		</if>
	</select>


	<!-- 订单分成统计 -->
	<!-- 会员所属门店分成统计 -->
	<select id="OwnerDeptSum" resultType="java.util.LinkedHashMap">
		select d.DepartmentID as ID,d.Code,d.Department as
		Name,SUM(p.OwnerAmt) as Amt,
		SUM(ISNULL(p.TotalSale,0)-ISNULL(p.TotalReturn,0)) as
		SaleAmt,SUM(ISNULL(p.AllotSales,0)) as AllotSales
		from
		W_Profitshar as p
		inner join Department as d on
		p.OwnerDeptID=d.DepartmentID
		inner join
		EShopOrder as e on
		p.EShopOrderID=e.EShopOrderID
		<if test="conditions != null and conditions != ''">
			where
			${conditions}
		</if>
		group by d.DepartmentID,d.Code,d.Department
		order by d.Code
	</select>
	<!-- 业务部门分成统计 -->
	<select id="BusinessDeptSum" resultType="java.util.LinkedHashMap">
		select d.DepartmentID as ID,d.Code,d.Department as
		Name,SUM(p.BusinessDeptAmt) as Amt,
		SUM(ISNULL(p.TotalSale,0)-ISNULL(p.TotalReturn,0)) as
		SaleAmt,SUM(ISNULL(p.AllotSales,0)) as AllotSales
		from
		W_Profitshar as p
		inner join Department as d on
		p.BusinessDept=d.DepartmentID
		inner join
		EShopOrder as e on
		p.EShopOrderID=e.EShopOrderID
		<if test="conditions != null and conditions != ''">
			where
			${conditions}
		</if>
		group by d.DepartmentID,d.Code,d.Department
		order by d.Code
	</select>
	<!-- 订单导购员分成统计 -->
	<select id="EmployeeSum" resultType="java.util.LinkedHashMap">
		select p.Employee as ID,em.Code,em.Name+(case when v.MobilePhone is
		not null then '<![CDATA[<br/>]]>'
		+ v.MobilePhone else '' end)
		as Name,SUM(p.EmployeeAmt) as Amt,
		SUM(ISNULL(p.TotalSale,0)-ISNULL(p.TotalReturn,0)) as
		SaleAmt,SUM(ISNULL(p.AllotSales,0)) as AllotSales
		from
		W_Profitshar as p
		inner join Employee as em on p.Employee=em.EmployeeID
		inner join EShopOrder as e on p.EShopOrderID=e.EShopOrderID
		left join
		VIP as v on em.VIPID=v.VIPID
		<if test="conditions != null and conditions != ''">
			where
			${conditions}
		</if>
		group by p.Employee,em.Code,em.Name,v.MobilePhone
		order by em.Code
	</select>
	<!-- 发货仓库分成统计 -->
	<select id="SendDeptSum" resultType="java.util.LinkedHashMap">
		select d.DepartmentID as ID,d.Code,d.Department as Name,SUM(p.Profit)
		as Amt,
		SUM(ISNULL(p.TotalSale,0)) as
		SaleAmt,SUM(ISNULL(ps.AllotSales,0)) as AllotSales
		from W_ProfitSendDtl as p
		inner join Department as d on
		p.DepartmentID=d.DepartmentID
		inner join
		EShopOrder as e on
		p.EShopOrderID=e.EShopOrderID
		inner join W_Profitshar as ps on p.EShopOrderID=ps.EShopOrderID and
		p.GoodsID=ps.GoodsID
		<if test="conditions != null and conditions != ''">
			where
			${conditions}
		</if>
		group by d.DepartmentID,d.Code,d.Department
		order by d.Code
	</select>
	<!-- 推荐导购员分成统计 -->
	<select id="GuideSum" resultType="java.util.LinkedHashMap">
		select p.GuideID as ID,em.Code,em.Name+(case when v.MobilePhone is not
		null then '<![CDATA[<br/>]]>'
		+ v.MobilePhone else '' end)
		as Name,SUM(p.GuideAmt) as Amt,
		SUM(ISNULL(p.TotalSale,0)-ISNULL(p.TotalReturn,0)) as
		SaleAmt,SUM(ISNULL(p.AllotSales,0)) as AllotSales
		from
		W_Profitshar as p
		inner join Employee as em on p.GuideID=em.EmployeeID
		inner join EShopOrder as e on p.EShopOrderID=e.EShopOrderID
		left join
		VIP as v on em.VIPID=v.VIPID
		<if test="conditions != null and conditions != ''">
			where
			${conditions}
		</if>
		group by p.GuideID,em.Code,em.Name,v.MobilePhone
		order by em.Code
	</select>
	<!-- 分销商分成统计 -->
	<select id="DistributerSum" resultType="java.util.LinkedHashMap">
		select p.Distributer as ID,v.Code,v.VIP+(case when v.MobilePhone is
		not null then '<![CDATA[<br/>]]>'
		+ v.MobilePhone else '' end)
		as Name,SUM(p.DistributerAmt) as Amt,
		SUM(ISNULL(p.TotalSale,0)-ISNULL(p.TotalReturn,0)) as
		SaleAmt,SUM(ISNULL(p.AllotSales,0)) as AllotSales
		from
		W_Profitshar as p
		inner join VIP as v on p.Distributer=v.VIPID
		inner
		join EShopOrder as e on p.EShopOrderID=e.EShopOrderID
		inner join
		W_Distributer as wd on wd.VIP=p.Distributer and wd.Status=1
		<if test="conditions != null and conditions != ''">
			where
			${conditions}
		</if>
		group by p.Distributer,v.Code,v.VIP,v.MobilePhone
		order by v.Code
	</select>
	<!-- 上级分销商分成统计 -->
	<select id="ParentDistributerSum" resultType="java.util.LinkedHashMap">
		select p.ParentDistributer as ID,v.Code,v.VIP+(case when v.MobilePhone
		is not null then '<![CDATA[<br/>]]>'
		+ v.MobilePhone else '' end)
		as Name,SUM(p.ParentDistributerAmt) as
		Amt,
		SUM(ISNULL(p.TotalSale,0)-ISNULL(p.TotalReturn,0)) as
		SaleAmt,SUM(ISNULL(p.AllotSales,0)) as AllotSales
		from
		W_Profitshar as p
		inner join VIP as v on p.ParentDistributer=v.VIPID
		inner join EShopOrder as e on p.EShopOrderID=e.EShopOrderID
		inner join
		W_Distributer as wd on wd.VIP=p.Distributer and wd.Status=1
		<if test="conditions != null and conditions != ''">
			where
			${conditions}
		</if>
		group by p.ParentDistributer,v.Code,v.VIP,v.MobilePhone
		order by v.Code
	</select>
	<!-- 会员推荐人分成统计 -->
	<select id="RecommenderVIPSum" resultType="java.util.LinkedHashMap">
		select p.RecommenderVIP as ID,v.Code,v.VIP+(case when v.MobilePhone is
		not null then '<![CDATA[<br/>]]>'
		+ v.MobilePhone else '' end)
		as Name,SUM(p.Rec_ReturnAmt) as Amt,
		SUM(ISNULL(p.TotalSale,0)-ISNULL(p.TotalReturn,0)) as
		SaleAmt,SUM(ISNULL(p.AllotSales,0)) as AllotSales
		from
		W_Profitshar as p
		inner join VIP as v on p.RecommenderVIP=v.VIPID
		inner
		join EShopOrder as e on p.EShopOrderID=e.EShopOrderID
		<if test="conditions != null and conditions != ''">
			where
			${conditions}
		</if>
		group by p.RecommenderVIP,v.Code,v.VIP,v.MobilePhone
		order by v.Code
	</select>
	<!-- 分销商所属门店分成统计 -->
	<select id="DistribShopSum" resultType="java.util.LinkedHashMap">
		select d.DepartmentID as ID,d.Code,d.Department as
		Name,SUM(p.DistribShopAmt) as Amt,
		SUM(ISNULL(p.TotalSale,0)-ISNULL(p.TotalReturn,0)) as
		SaleAmt,SUM(ISNULL(p.AllotSales,0)) as AllotSales
		from
		W_Profitshar as p
		inner join Department as d on
		p.DistribShopID=d.DepartmentID
		inner join
		EShopOrder as e on
		p.EShopOrderID=e.EShopOrderID
		<if test="conditions != null and conditions != ''">
			where
			${conditions}
		</if>
		group by d.DepartmentID,d.Code,d.Department
		order by d.Code
	</select>
	<update id="updateByEshopOrderID">

	</update>

	<!-- (VIP)我的钱包:总收入 -->
	<select id="viptotalIncome" resultType="java.lang.String">
		select SUM(Rec_ReturnAmt)
		as totalIncome
		from W_Profitshar
		where RecommenderVIP=#{vipid}
	</select>

	<!-- (VIP)我的钱包:待提现 -->
	<select id="vipstayWithdraw" resultType="java.lang.String">
	<![CDATA[
		select SUM(a.Rec_ReturnAmt) as stayWithdraw
		from W_Profitshar as a
		inner join EShopOrder as b on a.EShopOrderID=b.EShopOrderID
		where (b.order_flag in ('4','5','8') or (b.order_flag='7' and b.RecieveTime > #{receiveTime})) 
		and a.RecommenderVIP=#{vipid}
	]]>
	</select>

	<!-- (VIP)我的钱包:可提现 -->
	<select id="vipusableWithdraw" resultType="java.lang.String">
	<![CDATA[
		select SUM(a.Rec_ReturnAmt) as usableWithdraw
		from W_Profitshar as a
		inner join EShopOrder as b on a.EShopOrderID=b.EShopOrderID
		where (b.order_flag='7' and b.RecieveTime <= #{receiveTime}) 
		and a.RecommenderVIP=#{vipid}
	]]>
	</select>

	<!-- (VIP)我的钱包——收入 -->
	<select id="vipincome" parameterType="java.util.HashMap"
		resultType="java.util.LinkedHashMap">
		SELECT a.EShopOrderID,a.GoodsID,b.ImgPath, b.Code, b.GoodName, e.No,
		isnull(a.SaleQty,0)-isnull(a.ReturnQty,0) as Quantity,(select top 1
		j.UnitPrice
		from EShopOrderDetail j
		where e.EShopOrderID =
		j.EShopOrderID and j.GoodsID=a.GoodsID) UnitPrice,
		isnull(a.TotalSale,0)-ISNULL(a.TotalReturn,0) TotalSale,
		a.Rec_ReturnRate,a.Rec_ReturnAmt,
		isnull(convert(varchar(10),a.Created,121),'') + '<![CDATA[<br/>]]>'
		+ isnull(convert(varchar(8),a.Created,108),'') as Created,
		case
		e.order_flag when 7 then '已完成' else '进行中' end as
		orderflag,e.order_flag as Status
		FROM W_Profitshar AS a
		INNER JOIN
		EShopOrder AS e ON a.EShopOrderID = e.EShopOrderID
		INNER JOIN W_Goods
		AS b ON a.GoodsID = b.GoodsID
		where a.RecommenderVIP =
		#{vipid,jdbcType=VARCHAR}
		and
		a.TotalSale-a.TotalReturn <![CDATA[<>]]>
		0
		order by a.EShopOrderID desc
	</select>
</mapper>