using System;
using System.Data;
using System.Collections.Generic;

using BrnShop.Core;

namespace BrnShop.Data
{
    /// <summary>
    /// 订单数据访问类
    /// </summary>
    public class Orders
    {
        #region 私有方法

        /// <summary>
        /// 从IDataReader创建OrderProductInfo
        /// </summary>
        private static OrderProductInfo BuildOrderProductFromReader(IDataReader reader)
        {
            OrderProductInfo orderProductInfo = new OrderProductInfo();
            orderProductInfo.RecordId = TypeHelper.ObjectToInt(reader["recordid"]);
            orderProductInfo.Oid = TypeHelper.ObjectToInt(reader["oid"]);
            orderProductInfo.Uid = TypeHelper.ObjectToInt(reader["uid"]);
            orderProductInfo.Sid = reader["sid"].ToString();
            orderProductInfo.Pid = TypeHelper.ObjectToInt(reader["pid"]);
            orderProductInfo.PSN = reader["psn"].ToString();
            orderProductInfo.CateId = TypeHelper.ObjectToInt(reader["cateid"]);
            orderProductInfo.BrandId = TypeHelper.ObjectToInt(reader["brandid"]);
            orderProductInfo.Name = reader["name"].ToString();
            orderProductInfo.ShowImg = reader["showimg"].ToString();
            orderProductInfo.DiscountPrice = TypeHelper.ObjectToDecimal(reader["discountprice"]);
            orderProductInfo.ShopPrice = TypeHelper.ObjectToDecimal(reader["shopprice"]);
            orderProductInfo.CostPrice = TypeHelper.ObjectToDecimal(reader["costprice"]);
            orderProductInfo.MarketPrice = TypeHelper.ObjectToDecimal(reader["marketprice"]);
            orderProductInfo.Weight = TypeHelper.ObjectToInt(reader["weight"]);
            orderProductInfo.IsReview = TypeHelper.ObjectToInt(reader["isreview"]);
            orderProductInfo.RealCount = TypeHelper.ObjectToInt(reader["realcount"]);
            orderProductInfo.BuyCount = TypeHelper.ObjectToInt(reader["buycount"]);
            orderProductInfo.SendCount = TypeHelper.ObjectToInt(reader["sendcount"]);
            orderProductInfo.Type = TypeHelper.ObjectToInt(reader["type"]);
            orderProductInfo.PayCredits = TypeHelper.ObjectToInt(reader["paycredits"]);
            orderProductInfo.CouponTypeId = TypeHelper.ObjectToInt(reader["coupontypeid"]);
            orderProductInfo.ExtCode1 = TypeHelper.ObjectToInt(reader["extcode1"]);
            orderProductInfo.ExtCode2 = TypeHelper.ObjectToInt(reader["extcode2"]);
            orderProductInfo.ExtCode3 = TypeHelper.ObjectToInt(reader["extcode3"]);
            orderProductInfo.ExtCode4 = TypeHelper.ObjectToInt(reader["extcode4"]);
            orderProductInfo.ExtCode5 = TypeHelper.ObjectToInt(reader["extcode5"]);
            orderProductInfo.ExtCode6 = TypeHelper.ObjectToInt(reader["extcode6"]);
            orderProductInfo.ExtCode7 = TypeHelper.ObjectToInt(reader["extcode7"]);
            orderProductInfo.ExtCode8 = TypeHelper.ObjectToInt(reader["extcode8"]);
            orderProductInfo.ExtCode9 = TypeHelper.ObjectToInt(reader["extcode9"]);
            orderProductInfo.ExtCode10 = TypeHelper.ObjectToInt(reader["extcode10"]);
            orderProductInfo.ExtCode11 = TypeHelper.ObjectToInt(reader["extcode11"]);
            orderProductInfo.ExtCode12 = TypeHelper.ObjectToInt(reader["extcode12"]);
            orderProductInfo.ExtStr1 = reader["extstr1"].ToString();
            orderProductInfo.ExtStr2 = reader["extstr2"].ToString();
            orderProductInfo.ExtStr3 = reader["extstr3"].ToString();
            orderProductInfo.ExtStr4 = reader["extstr4"].ToString();
            orderProductInfo.IP = reader["ip"].ToString();
            orderProductInfo.AddTime = TypeHelper.ObjectToDateTime(reader["addtime"]);
            return orderProductInfo;
        }

        /// <summary>
        /// 从IDataReader创建OrderInfo
        /// </summary>
        private static OrderInfo BuildOrderFromReader(IDataReader reader)
        {
            OrderInfo orderInfo = new OrderInfo();

            orderInfo.Oid = TypeHelper.ObjectToInt(reader["oid"]);
            orderInfo.OSN = reader["osn"].ToString();
            orderInfo.Uid = TypeHelper.ObjectToInt(reader["uid"]);

            orderInfo.OrderState = TypeHelper.ObjectToInt(reader["orderstate"]);

            orderInfo.ProductAmount = TypeHelper.ObjectToDecimal(reader["productamount"]);
            orderInfo.FullCut = TypeHelper.ObjectToInt(reader["fullcut"]);
            orderInfo.OrderAmount = TypeHelper.ObjectToDecimal(reader["orderamount"]);
            orderInfo.SurplusMoney = TypeHelper.ObjectToDecimal(reader["surplusmoney"]);

            orderInfo.ParentId = TypeHelper.ObjectToInt(reader["parentid"]);
            orderInfo.AddTime = TypeHelper.ObjectToDateTime(reader["addtime"]);
            orderInfo.ShipSN = reader["shipsn"].ToString();
            orderInfo.ShipFriendName = reader["shipfriendname"].ToString();
            orderInfo.ShipSystemName = reader["shipsystemname"].ToString();
            orderInfo.PaySN = reader["paysn"].ToString();
            orderInfo.PayFriendName = reader["payfriendname"].ToString();
            orderInfo.PaySystemName = reader["paysystemname"].ToString();
            orderInfo.PayMode = TypeHelper.ObjectToInt(reader["paymode"]);

            orderInfo.RegionId = TypeHelper.ObjectToInt(reader["regionid"]);
            orderInfo.Consignee = reader["consignee"].ToString();
            orderInfo.Mobile = reader["mobile"].ToString();
            orderInfo.Phone = reader["phone"].ToString();
            orderInfo.Email = reader["email"].ToString();
            orderInfo.ZipCode = reader["zipcode"].ToString();
            orderInfo.Address = reader["address"].ToString();
            orderInfo.BestTime = TypeHelper.ObjectToDateTime(reader["besttime"]);

            orderInfo.ShipFee = TypeHelper.ObjectToDecimal(reader["shipfee"]);
            orderInfo.PayFee = TypeHelper.ObjectToDecimal(reader["payfee"]);
            orderInfo.Discount = TypeHelper.ObjectToDecimal(reader["discount"]);
            orderInfo.PaidMoney = TypeHelper.ObjectToDecimal(reader["paidmoney"]);
            orderInfo.WalletMoney = TypeHelper.ObjectToDecimal(reader["walletmoney"]);
            orderInfo.PayCreditCount = TypeHelper.ObjectToInt(reader["paycreditcount"]);
            orderInfo.PayCreditMoney = TypeHelper.ObjectToDecimal(reader["paycreditmoney"]);
            orderInfo.CouponMoney = TypeHelper.ObjectToInt(reader["couponmoney"]);
            orderInfo.Weight = TypeHelper.ObjectToInt(reader["weight"]);

            orderInfo.BuyerRemark = reader["buyerremark"].ToString();
            orderInfo.IP = reader["ip"].ToString();

            return orderInfo;
        }

        #endregion

        /// <summary>
        /// 获得订单商品
        /// </summary>
        /// <param name="recordId">记录id</param>
        /// <returns></returns>
        public static OrderProductInfo GetOrderProductByRecordId(int recordId)
        {
            OrderProductInfo orderProductInfo = null;
            IDataReader reader = BrnShop.Core.BSPData.RDBSInstance.GetOrderProductByRecordId(recordId);
            if (reader.Read())
            {
                orderProductInfo = BuildOrderProductFromReader(reader);
            }
            reader.Close();
            return orderProductInfo;
        }

        /// <summary>
        /// 获得购物车中商品数量
        /// </summary>
        /// <param name="uid">用户id</param>
        /// <returns></returns>
        public static int GetShopCartProductCount(int uid)
        {
            return BrnShop.Core.BSPData.RDBSInstance.GetShopCartProductCount(uid);
        }

        /// <summary>
        /// 获得购物车中商品数量
        /// </summary>
        /// <param name="sid">用户sid</param>
        /// <returns></returns>
        public static int GetShopCartProductCount(string sid)
        {
            return BrnShop.Core.BSPData.RDBSInstance.GetShopCartProductCount(sid);
        }

        /// <summary>
        /// 添加订单商品
        /// </summary>
        /// <param name="orderProductInfo">订单商品</param>
        public static int AddOrderProduct(OrderProductInfo orderProductInfo)
        {
            return BrnShop.Core.BSPData.RDBSInstance.AddOrderProduct(orderProductInfo);
        }

        /// <summary>
        /// 更新订单商品
        /// </summary>
        /// <param name="orderProductInfo">订单商品</param>
        public static void UpdateOrderProduct(OrderProductInfo orderProductInfo)
        {
            BrnShop.Core.BSPData.RDBSInstance.UpdateOrderProduct(orderProductInfo);
        }

        /// <summary>
        /// 获得购物车商品列表
        /// </summary>
        /// <param name="uid">用户id</param>
        /// <returns></returns>
        public static List<OrderProductInfo> GetShopCartProductList(int uid)
        {
            List<OrderProductInfo> orderProductList = new List<OrderProductInfo>();
            IDataReader reader = BrnShop.Core.BSPData.RDBSInstance.GetShopCartProductList(uid);
            while (reader.Read())
            {
                OrderProductInfo orderProductInfo = BuildOrderProductFromReader(reader);
                orderProductList.Add(orderProductInfo);
            }
            reader.Close();
            return orderProductList;
        }

        /// <summary>
        /// 获得购物车商品列表
        /// </summary>
        /// <param name="sid">用户sid</param>
        /// <returns></returns>
        public static List<OrderProductInfo> GetShopCartProductList(string sid)
        {
            List<OrderProductInfo> orderProductList = new List<OrderProductInfo>();
            IDataReader reader = BrnShop.Core.BSPData.RDBSInstance.GetShopCartProductList(sid);
            while (reader.Read())
            {
                OrderProductInfo orderProductInfo = BuildOrderProductFromReader(reader);
                orderProductList.Add(orderProductInfo);
            }
            reader.Close();
            return orderProductList;
        }

        /// <summary>
        /// 更新购物车的用户id
        /// </summary>
        /// <param name="uid">用户id</param>
        /// <param name="sid">用户sid</param>
        /// <returns></returns>
        public static void UpdateShopCartUidBySid(int uid, string sid)
        {
            BrnShop.Core.BSPData.RDBSInstance.UpdateShopCartUidBySid(uid, sid);
        }

        /// <summary>
        /// 删除订单商品
        /// </summary>
        /// <param name="recordIdList">记录id列表</param>
        public static void DeleteOrderProductByRecordId(string recordIdList)
        {
            BrnShop.Core.BSPData.RDBSInstance.DeleteOrderProductByRecordId(recordIdList);
        }

        /// <summary>
        /// 清空购物车
        /// </summary>
        /// <param name="uid">用户id</param>
        /// <returns></returns>
        public static int ClearShopCart(int uid)
        {
            return BrnShop.Core.BSPData.RDBSInstance.ClearShopCart(uid);
        }

        /// <summary>
        /// 清空购物车的商品
        /// </summary>
        /// <param name="sid">sid</param>
        /// <returns></returns>
        public static int ClearShopCart(string sid)
        {
            return BrnShop.Core.BSPData.RDBSInstance.ClearShopCart(sid);
        }

        /// <summary>
        /// 更新订单商品的数量
        /// </summary>
        /// <param name="recordId">记录id</param>
        /// <param name="realCount">真实数量</param>
        /// <param name="buyCount">购买数量</param>
        public static void UpdateOrderProductCount(int recordId, int realCount, int buyCount)
        {
            BrnShop.Core.BSPData.RDBSInstance.UpdateOrderProductCount(recordId, realCount, buyCount);
        }

        /// <summary>
        /// 更新订单商品的满减促销活动
        /// </summary>
        /// <param name="recordIdList">记录id列表</param>
        /// <param name="limitMoney">限制金额</param>
        /// <param name="cutMoney">优惠金额</param>
        public static void UpdateFullCutPromotionOfOrderProduct(string recordIdList, int limitMoney, int cutMoney)
        {
            BrnShop.Core.BSPData.RDBSInstance.UpdateFullCutPromotionOfOrderProduct(recordIdList, limitMoney, cutMoney);
        }

        /// <summary>
        /// 清空过期购物车
        /// </summary>
        /// <param name="expireTime">过期时间</param>
        public static void ClearExpiredShopCart(DateTime expireTime)
        {
            BrnShop.Core.BSPData.RDBSInstance.ClearExpiredShopCart(expireTime);
        }

        /// <summary>
        /// 创建订单
        /// </summary>
        /// <param name="orderInfo">订单信息</param>
        /// <returns>订单id</returns>
        public static int CreateOrder(OrderInfo orderInfo)
        {
            return BrnShop.Core.BSPData.RDBSInstance.CreateOrder(orderInfo);
        }

        /// <summary>
        /// 获得订单信息
        /// </summary>
        /// <param name="oid">订单id</param>
        /// <returns>订单信息</returns>
        public static OrderInfo GetOrderByOid(int oid)
        {
            OrderInfo orderInfo = null;
            IDataReader reader = BrnShop.Core.BSPData.RDBSInstance.GetOrderByOid(oid);
            if (reader.Read())
            {
                orderInfo = BuildOrderFromReader(reader);
            }
            reader.Close();
            return orderInfo;
        }

        /// <summary>
        /// 获得订单信息
        /// </summary>
        /// <param name="osn">订单编号</param>
        /// <returns>订单信息</returns>
        public static OrderInfo GetOrderByOSN(string osn)
        {
            OrderInfo orderInfo = null;
            IDataReader reader = BrnShop.Core.BSPData.RDBSInstance.GetOrderByOSN(osn);
            if (reader.Read())
            {
                orderInfo = BuildOrderFromReader(reader);
            }
            reader.Close();
            return orderInfo;
        }

        /// <summary>
        /// 获得订单状态
        /// </summary>
        /// <param name="oid">订单id</param>
        /// <returns></returns>
        public static int GetOrderStateByOid(int oid)
        {
            return BrnShop.Core.BSPData.RDBSInstance.GetOrderStateByOid(oid);
        }

        /// <summary>
        /// 根据下单时间获得订单数量
        /// </summary>
        /// <param name="orderState">订单状态</param>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <returns></returns>
        public static int GetOrderCountByOrderStateAndAddTime(int orderState, string startTime, string endTime)
        {
            return BrnShop.Core.BSPData.RDBSInstance.GetOrderCountByOrderStateAndAddTime(orderState, startTime, endTime);
        }

        /// <summary>
        /// 获得订单列表
        /// </summary>
        /// <param name="pageSize">每页数</param>
        /// <param name="pageNumber">当前页数</param>
        /// <param name="condition">条件</param>
        /// <param name="sort">排序</param>
        /// <returns></returns>
        public static DataTable GetOrderList(int pageSize, int pageNumber, string condition, string sort)
        {
            return BrnShop.Core.BSPData.RDBSInstance.GetOrderList(pageSize, pageNumber, condition, sort);
        }

        /// <summary>
        /// 获得列表搜索条件
        /// </summary>
        /// <param name="osn">订单编号</param>
        /// <param name="uid">用户id</param>
        /// <param name="consignee">收货人</param>
        /// <param name="orderState">订单状态</param>
        /// <returns></returns>
        public static string GetOrderListCondition(string osn, int uid, string consignee, int orderState)
        {
            return BrnShop.Core.BSPData.RDBSInstance.GetOrderListCondition(osn, uid, consignee, orderState);
        }

        /// <summary>
        /// 获得列表排序
        /// </summary>
        /// <param name="sortColumn">排序列</param>
        /// <param name="sortDirection">排序方向</param>
        /// <returns></returns>
        public static string GetOrderListSort(string sortColumn, string sortDirection)
        {
            return BrnShop.Core.BSPData.RDBSInstance.GetOrderListSort(sortColumn, sortDirection);
        }

        /// <summary>
        /// 获得订单数量
        /// </summary>
        /// <param name="condition">条件</param>
        /// <returns></returns>
        public static int GetOrderCount(string condition)
        {
            return BrnShop.Core.BSPData.RDBSInstance.GetOrderCount(condition);
        }

        /// <summary>
        /// 获得订单商品列表
        /// </summary>
        /// <param name="oid">订单id</param>
        /// <returns></returns>
        public static List<OrderProductInfo> GetOrderProductList(int oid)
        {
            List<OrderProductInfo> orderProductList = new List<OrderProductInfo>();
            IDataReader reader = BrnShop.Core.BSPData.RDBSInstance.GetOrderProductList(oid);
            while (reader.Read())
            {
                OrderProductInfo orderProductInfo = BuildOrderProductFromReader(reader);
                orderProductList.Add(orderProductInfo);
            }
            reader.Close();
            return orderProductList;
        }

        /// <summary>
        /// 获得订单商品列表
        /// </summary>
        /// <param name="oidList">订单id列表</param>
        /// <returns></returns>
        public static List<OrderProductInfo> GetOrderProductList(string oidList)
        {
            List<OrderProductInfo> orderProductList = new List<OrderProductInfo>();
            IDataReader reader = BrnShop.Core.BSPData.RDBSInstance.GetOrderProductList(oidList);
            while (reader.Read())
            {
                OrderProductInfo orderProductInfo = BuildOrderProductFromReader(reader);
                orderProductList.Add(orderProductInfo);
            }
            reader.Close();
            return orderProductList;
        }

        /// <summary>
        /// 更新订单的配送地址
        /// </summary>
        /// <param name="oid">订单id</param>
        /// <param name="regionId">区域id</param>
        /// <param name="consignee">收货人</param>
        /// <param name="mobile">手机号</param>
        /// <param name="phone">固话号</param>
        /// <param name="email">邮箱</param>
        /// <param name="zipCode">邮政编码</param>
        /// <param name="address">详细地址</param>
        /// <param name="bestTime">最佳送货时间</param>
        /// <param name="shipFee">配送费用</param>
        /// <param name="orderAmount">订单合计</param>
        /// <param name="surplusMoney">剩余金额</param>
        public static void UpdateOrderShipAddress(int oid, int regionId, string consignee, string mobile, string phone, string email, string zipCode, string address, DateTime bestTime, decimal shipFee, decimal orderAmount, decimal surplusMoney)
        {
            BrnShop.Core.BSPData.RDBSInstance.UpdateOrderShipAddress(oid, regionId, consignee, mobile, phone, email, zipCode, address, bestTime, shipFee, orderAmount, surplusMoney);
        }

        /// <summary>
        /// 更新订单的配送类型
        /// </summary>
        /// <param name="oid">订单id</param>
        /// <param name="shipSystemName">配送系统名</param>
        /// <param name="shipFriendName">配送友好名</param>
        /// <param name="shipFee">配送费用</param>
        /// <param name="orderAmount">订单合计</param>
        /// <param name="surplusMoney">剩余金额</param>
        public static void UpdateOrderShipType(int oid, string shipSystemName, string shipFriendName, decimal shipFee, decimal orderAmount, decimal surplusMoney)
        {
            BrnShop.Core.BSPData.RDBSInstance.UpdateOrderShipType(oid, shipSystemName, shipFriendName, shipFee, orderAmount, surplusMoney);
        }

        /// <summary>
        /// 更新订单的支付类型
        /// </summary>
        /// <param name="oid">订单id</param>
        /// <param name="paySystemName">支付系统名</param>
        /// <param name="payFriendName">支付友好名</param>
        /// <param name="payMode">支付方式</param>
        /// <param name="orderState">订单状态</param>
        /// <param name="payFee">手续费</param>
        /// <param name="orderAmount">订单合计</param>
        /// <param name="surplusMoney">剩余金额</param>
        public static void UpdateOrderPayType(int oid, string paySystemName, string payFriendName, int payMode, int orderState, decimal payFee, decimal orderAmount, decimal surplusMoney)
        {
            BrnShop.Core.BSPData.RDBSInstance.UpdateOrderPayType(oid, paySystemName, payFriendName, payMode, orderState, payFee, orderAmount, surplusMoney);
        }

        /// <summary>
        /// 更新订单折扣
        /// </summary>
        /// <param name="oid">订单id</param>
        /// <param name="discount">折扣</param>
        /// <param name="orderAmount">订单合计</param>
        /// <param name="surplusMoney">剩余金额</param>
        public static void UpdateOrderDiscount(int oid, decimal discount, decimal orderAmount, decimal surplusMoney)
        {
            BrnShop.Core.BSPData.RDBSInstance.UpdateOrderDiscount(oid, discount, orderAmount, surplusMoney);
        }

        /// <summary>
        /// 更新订单状态
        /// </summary>
        /// <param name="oid">订单id</param>
        /// <param name="orderState">订单状态</param>
        public static void UpdateOrderState(int oid, int orderState)
        {
            BrnShop.Core.BSPData.RDBSInstance.UpdateOrderState(oid, orderState);
        }

        /// <summary>
        /// 发货
        /// </summary>
        /// <param name="oid">订单id</param>
        /// <param name="orderState">订单状态</param>
        /// <param name="shipSN">配送单号</param>
        public static void SendOrderProduct(int oid, int orderState, string shipSN)
        {
            BrnShop.Core.BSPData.RDBSInstance.SendOrderProduct(oid, orderState, shipSN);
        }

        /// <summary>
        /// 付款
        /// </summary>
        /// <param name="oid">订单id</param>
        /// <param name="orderState">订单状态</param>
        /// <param name="paySN">支付单号</param>
        public static void PayOrder(int oid, int orderState, string paySN)
        {
            BrnShop.Core.BSPData.RDBSInstance.PayOrder(oid, orderState, paySN);
        }

        /// <summary>
        /// 清空过期的在线支付订单
        /// </summary>
        /// <param name="expireTime">过期时间</param>
        public static void ClearExpiredOnlinePayOrder(DateTime expireTime)
        {
            BrnShop.Core.BSPData.RDBSInstance.ClearExpiredOnlinePayOrder(expireTime);
        }

        /// <summary>
        /// 清空过期的线下支付订单
        /// </summary>
        /// <param name="expireTime">过期时间</param>
        public static void ClearExpiredOfflinePayOrder(DateTime expireTime)
        {
            BrnShop.Core.BSPData.RDBSInstance.ClearExpiredOfflinePayOrder(expireTime);
        }

        /// <summary>
        /// 获得用户订单列表
        /// </summary>
        /// <param name="uid">用户id</param>
        /// <param name="pageSize">每页数</param>
        /// <param name="pageNumber">当前页数</param>
        /// <param name="startAddTime">添加开始时间</param>
        /// <param name="endAddTime">添加结束时间</param>
        /// <param name="orderState">订单状态(0代表全部状态)</param>
        /// <returns></returns>
        public static DataTable GetUserOrderList(int uid, int pageSize, int pageNumber, string startAddTime, string endAddTime, int orderState)
        {
            return BrnShop.Core.BSPData.RDBSInstance.GetUserOrderList(uid, pageSize, pageNumber, startAddTime, endAddTime, orderState);
        }

        /// <summary>
        /// 获得用户订单列表
        /// </summary>
        /// <param name="uid">用户id</param>
        /// <param name="startAddTime">添加开始时间</param>
        /// <param name="endAddTime">添加结束时间</param>
        /// <param name="orderState">订单状态(0代表全部状态)</param>
        /// <returns></returns>
        public static int GetUserOrderCount(int uid, string startAddTime, string endAddTime, int orderState)
        {
            return BrnShop.Core.BSPData.RDBSInstance.GetUserOrderCount(uid, startAddTime, endAddTime, orderState);
        }

        /// <summary>
        /// 获得销售商品列表
        /// </summary>
        /// <param name="pageSize">每页数</param>
        /// <param name="pageNumber">当前页数</param>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <returns></returns>
        public static DataTable GetSaleProductList(int pageSize, int pageNumber, string startTime, string endTime)
        {
            return BrnShop.Core.BSPData.RDBSInstance.GetSaleProductList(pageSize, pageNumber, startTime, endTime);
        }

        /// <summary>
        /// 获得销售商品数量
        /// </summary>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <returns></returns>
        public static int GetSaleProductCount(string startTime, string endTime)
        {
            return BrnShop.Core.BSPData.RDBSInstance.GetSaleProductCount(startTime, endTime);
        }

        /// <summary>
        /// 获得销售趋势
        /// </summary>
        /// <param name="trendType">趋势类型(0代表订单数,1代表订单合计)</param>
        /// <param name="timeType">时间类型(0代表小时,1代表天,2代表月,3代表年)</param>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <returns></returns>
        public static DataTable GetSaleTrend(int trendType, int timeType, string startTime, string endTime)
        {
            return BrnShop.Core.BSPData.RDBSInstance.GetSaleTrend(trendType, timeType, startTime, endTime);
        }
    }
}