Пример #1
0
        /// <summary>
        /// 查询订单明细
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public List <IOrderDetail> QueryOrderDetail(string orderId)
        {
            List <IOrderDetail> orderDetail = new List <IOrderDetail>();
            DBExtend            helper      = dbHelper;

            orderDetail = helper.QueryList <IOrderDetail>(b => b.OrderId == orderId);
            return(orderDetail);
        }
Пример #2
0
        /// <summary>
        /// 获取用户收货地址
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static List <T> QueryUserAddress <T>(string userId) where T : IAddress, new()
        {
            DBExtend        helper = dbHelper;
            LamadaQuery <T> query  = new LamadaQuery <T>();

            query = query.Select().Where(b => b.UserId == userId).OrderBy(b => b.DefaultAddress, true);
            string key;

            return(helper.QueryList <T>(query, 0, out key));
        }
Пример #3
0
        /// <summary>
        /// 返回当前类型
        /// 会按GROUP和分页判断
        /// </summary>
        /// <returns></returns>
        public List <T> ToList()
        {
            var db = new DBExtend(__DbContext);

            //如果是筛选后的结果,属性可能匹配不上
            if (__PageSize > 0)
            {
                return(db.Page <T, T>(this));
            }
            return(db.QueryList(this));
        }
Пример #4
0
        void InItCache()
        {
            if (nameCache.Count == 0)
            {
                #region 初始缓存

                DBExtend            helper = dbHelper;
                List <PropertyName> list   = helper.QueryList <PropertyName>();
                foreach (PropertyName c in list)
                {
                    nameCache.Add(c.Id, c);
                }

                List <PropertyValue> list2 = helper.QueryList <PropertyValue>();
                foreach (PropertyValue c in list2)
                {
                    valueCache.Add(c.Id, c);
                }
                #endregion
            }
        }
Пример #5
0
        /// <summary>
        /// 运费计算
        /// 查询不到返回0
        /// </summary>
        /// <param name="orderDetail"></param>
        /// <param name="areaId"></param>
        /// <param name="supplier"></param>
        /// <param name="freight1">物流运费</param>
        /// <param name="freight2">快递运费</param>
        public static void CalculateFreight(List <CRL.Order.ProductOrder.IOrderDetail> orderDetail, string areaId, Person.IShopSupplier supplier, out double freight1, out double freight2)
        {
            //总重
            double totalHeavy = 0;
            //免运费金额
            decimal minFreePostAmount = 0;

            int supplierId = supplier.Id;

            minFreePostAmount = supplier.MinFreePostAmount;
            decimal freePostAmount = 0;

            //计算总额
            foreach (var item in orderDetail)
            {
                if (item.IncludedFreePost)
                {
                    freePostAmount += item.Price * item.Num;
                }
                totalHeavy += item.TotalWeight;
            }
            //小于免运费金额才计算运费
            if (freePostAmount > minFreePostAmount)
            {
                freight1 = 0;
                freight2 = 0;
                return;
            }
            //freight1 = 100;
            //freight2 = 100;
            //return;
            //实际运费=首重运费+((总重-首重)/续重)*续重运费
            freight1 = 0;
            freight2 = 0;
            DBExtend        helper  = dbHelper;
            List <IFreight> freight = null;

            while (true)
            {
                //helper.Clear();
                freight = helper.QueryList <IFreight>(b => b.SupplierId == supplierId && b.AreaId == areaId && b.Disable == false);
                if (freight.Count == 0)//找上一级
                {
                    areaId = Area.AreaAction.Get(areaId).ParentCode;
                    if (areaId == "1")
                    {
                        return;
                    }
                }
                else
                {
                    break;
                }
            }
            //同时返回物流和快递,没有则只返回一个
            IFreight f1             = freight[0];
            double   continuedMoney = 0;

            if (totalHeavy > 0)
            {
                continuedMoney = ((totalHeavy - f1.Heavy) / f1.ContinuedHeavy) * f1.ContinuedHeavyMoney;
                if (continuedMoney < 0)
                {
                    continuedMoney = 0;
                }
            }
            double a = f1.HeavyMoney + continuedMoney;

            if (f1.DeliverType == DeliverType.物流)
            {
                freight1 = a;
            }
            else
            {
                freight2 = a;
            }
            if (freight.Count > 1)
            {
                IFreight f2 = freight[1];
                double   continuedMoney2 = 0;
                if (totalHeavy > 0)
                {
                    continuedMoney2 = ((totalHeavy - f2.Heavy) / f2.ContinuedHeavy) * f2.ContinuedHeavyMoney;
                    if (continuedMoney2 < 0)
                    {
                        continuedMoney2 = 0;
                    }
                }
                double b = f2.HeavyMoney + continuedMoney2;
                if (f2.DeliverType == DeliverType.物流)
                {
                    freight1 = b;
                }
                else
                {
                    freight2 = b;
                }
            }
            return;
        }