Ejemplo n.º 1
0
        /// <summary>
        /// 根据请购买申请单重新初始化购物车
        /// </summary>
        /// <param name="ApplyID"></param>
        /// <returns></returns>
        public static ORD_OrderCartBLL InitByOrderApply(int OrderID)
        {
            ORD_OrderBLL Order = new ORD_OrderBLL(OrderID);

            if (Order.Model == null)
            {
                return(null);
            }

            ORD_PublishBLL publish = new ORD_PublishBLL(Order.Model.PublishID);

            if (publish.Model == null)
            {
                return(null);
            }

            ORD_OrderCartBLL cart = new ORD_OrderCartBLL(Order.Model.AccountMonth, Order.Model.PublishID, Order.Model.Client, Order.Model.Supplier,
                                                         Order.Model.Classify, Order.Model.PayMode, Order.Model.ReqWarehouse, Order.Model.ReqArrivalDate);

            int          quotaid = ORD_QuotaBLL.GetQuotaByClientAndMonth(cart.Client, cart.AccountMonth);
            ORD_QuotaBLL quota   = new ORD_QuotaBLL(quotaid);

            foreach (ORD_OrderDetail item in Order.Items)
            {
                ORD_PublishDetail _m = publish.Items.FirstOrDefault(m => m.Product == item.Product);
                if (_m == null)
                {
                    continue;
                }

                ORD_OrderCartItem cartitem = new ORD_OrderCartItem();
                cartitem.ID                = _m.ID;
                cartitem.Product           = _m.Product;
                cartitem.MinQuantity       = _m.MinQuantity;
                cartitem.MaxQuantity       = _m.MaxQuantity;
                cartitem.Price             = item.Price;
                cartitem.AvailableQuantity = _m.AvailableQuantity;
                cartitem.SubmitQuantity    = ORD_OrderBLL.GetSubmitQuantity(Order.Model.AccountMonth, Order.Model.Client, _m.Product, Order.Model.Classify == 1 ? 1 : 0);
                cartitem.BookQuantity      = item.BookQuantity;
                cartitem.Points            = item.Points;

                #region 获取配额数量
                if (quota.Model != null)
                {
                    ORD_QuotaDetail d = quota.Items.FirstOrDefault(p => p.Product == _m.Product);
                    if (d != null)
                    {
                        cartitem.QuotaQuantity = d.StdQuota + d.AdjQuota;
                    }
                }
                #endregion

                cart.Items.Add(cartitem);
            }

            return(cart);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 请购商提交订单
        /// </summary>
        /// <param name="User"></param>
        /// <returns>0:成功 -10:积分余额不足 </returns>
        public int Submit(Guid User)
        {
            ORD_Order neworder = new ORD_OrderBLL(_m.ID).Model;

            if (neworder == null || neworder.State != 1)
            {
                return(-1);
            }

            if (_m.PayMode == 8)
            {
                #region 扣减客户积分

                /*
                 * //判断积分是否足够
                 * MCSFramework.SQLDAL.RM.RM_AccountDAL accountdal = new MCSFramework.SQLDAL.RM.RM_AccountDAL();
                 * decimal totalbalance = 0;
                 * ORD_PublishBLL publish = new ORD_PublishBLL(_m.PublishID);
                 * foreach (ORD_PublishWithAccountType item in publish.GetAccountType())
                 * {
                 *  totalbalance += accountdal.GetBalance(_m.Client, item.AccountType);
                 * }
                 * decimal totalpoints = Items.Sum(p => p.BookQuantity * p.Points);
                 * if (totalpoints > totalbalance) return -10;
                 *
                 * //依次扣减积分
                 * decimal points = totalpoints;
                 * foreach (ORD_PublishWithAccountType item in publish.GetAccountType())
                 * {
                 *  decimal b = accountdal.GetBalance(_m.Client, item.AccountType);
                 *  if (b < 0) continue;    //某账户小于0分时,不处理
                 *
                 *  if (b >= points)
                 *  {
                 *      accountdal.ModifyPoints(_m.Client, item.AccountType, 0 - points, 0, 11, "提交积分兑换订单,订单号:" + _m.SheetCode);
                 *      AddSpentPoints(item.AccountType, 1, 0 - points);
                 *      break;
                 *  }
                 *  else
                 *  {
                 *      accountdal.ModifyPoints(_m.Client, item.AccountType, 0 - b, 0, 11, "提交积分兑换订单,订单号:" + _m.SheetCode);
                 *      AddSpentPoints(item.AccountType, 1, 0 - b);
                 *      points -= b;
                 *  }
                 * }
                 */
                #endregion
            }

            return(_dal.SetState(_m.ID, 2, User));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 供货商确认订单
        /// </summary>
        /// <param name="User"></param>
        /// <returns></returns>
        public int Confirm(Guid User)
        {
            //获取订单的最新状态
            ORD_Order neworder = new ORD_OrderBLL(_m.ID).Model;

            if (neworder == null || neworder.State != 2)
            {
                return(-1);
            }

            if (_m.PayMode == 8)
            {
                /*
                 * MCSFramework.SQLDAL.RM.RM_AccountDAL accountdal = new MCSFramework.SQLDAL.RM.RM_AccountDAL();
                 *
                 #region 向供货商增加积分
                 * foreach (ORD_OrderSpentPoints item in GetSpentPointsList())
                 * {
                 *  decimal p = 0 - item.Points;    //原订单提交时扣减的积分(取正值)
                 *  accountdal.ModifyPoints(_m.Supplier, item.AccountType, p, 0, 12, "确认积分兑换订单,订单号:" + _m.SheetCode);
                 * }
                 #endregion
                 *
                 #region 退还调整的积分余额
                 * decimal adjustpoints = Items.Sum(p => (p.BookQuantity - p.ConfirmQuantity) * p.Points);
                 * if (adjustpoints > 0)
                 * {
                 *  foreach (ORD_OrderSpentPoints item in GetSpentPointsList())
                 *  {
                 *      decimal p = 0 - item.Points;    //原订单提交时扣减的积分(取正值)
                 *      if (p > adjustpoints)
                 *      {
                 *          accountdal.ModifyPoints(_m.Client, item.AccountType, adjustpoints, 0, 11, "确认积分兑换订单,退还确认后的差额,订单号:" + _m.SheetCode);
                 *          AddSpentPoints(item.AccountType, 2, adjustpoints);
                 *          break;
                 *      }
                 *      else
                 *      {
                 *          accountdal.ModifyPoints(_m.Client, item.AccountType, p, 0, 11, "确认积分兑换订单,退还确认后的差额,订单号:" + _m.SheetCode);
                 *          AddSpentPoints(item.AccountType, 2, p);
                 *          adjustpoints -= p;
                 *      }
                 *  }
                 *
                 #endregion
                 * */
            }
            return(_dal.SetState(_m.ID, 3, User));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 修改请购买数量
        /// </summary>
        /// <param name="product"></param>
        /// <param name="quantity"></param>
        /// <returns>0:成功 -1:购物车中不包括此产品 -2:已超可请购数量 -3:小于最小单次请购数量 -4:大于最大单次请购数量 -5:超订货配额</returns>
        public int ModifyQuantity(int product, int quantity)
        {
            ORD_OrderCartItem cartitem = Items.FirstOrDefault(m => m.Product == product);

            if (cartitem == null)
            {
                return(-1);
            }

            cartitem.AvailableQuantity = cartitem.AvailableQuantity;
            cartitem.SubmitQuantity    = ORD_OrderBLL.GetSubmitQuantity(_accountmonth, _client, product, _classify == 1 ? 1 : 0);

            if (cartitem.MinQuantity > 0 && cartitem.MinQuantity > quantity || quantity < 0)
            {
                return(-3);
            }
            if (cartitem.MaxQuantity > 0 && cartitem.MaxQuantity < quantity)
            {
                return(-4);
            }

            #region 判断是否超过发布目录设定的可订货数量
            if (cartitem.AvailableQuantity > 0)
            {
                int totalquantity = ORD_PublishBLL.GetSubmitQuantity(_publish, product);
                if (cartitem.BookQuantity > cartitem.AvailableQuantity - totalquantity)
                {
                    return(-2);
                }
            }
            #endregion

            if (_classify == 1 && quantity > cartitem.QuotaQuantity - cartitem.SubmitQuantity)
            {
                return(-5);
            }

            cartitem.BookQuantity    = quantity;
            cartitem.ConfirmQuantity = quantity;
            return(0);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 取消订单
        /// </summary>
        /// <param name="User"></param>
        /// <returns></returns>
        public int Cancel(Guid User)
        {
            ORD_Order neworder = new ORD_OrderBLL(_m.ID).Model;

            if (neworder == null || neworder.State != 2)
            {
                return(-1);
            }

            if (_m.PayMode == 8)
            {
                //    #region 依次返还原扣除的积分
                //    MCSFramework.SQLDAL.RM.RM_AccountDAL accountdal = new MCSFramework.SQLDAL.RM.RM_AccountDAL();
                //    foreach (ORD_OrderSpentPoints item in GetSpentPointsList())
                //    {
                //        accountdal.ModifyPoints(_m.Client, item.AccountType, 0 - item.Points, 0, 11, "取消积分兑换订单,订单号:" + _m.SheetCode);
                //        AddSpentPoints(item.AccountType, 2, 0 - item.Points);
                //    }
                //    #endregion
            }
            return(_dal.SetState(_m.ID, 8, User));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 向购物车中新增产品
        /// </summary>
        /// <param name="product"></param>
        /// <returns>0:成功 -1:发布目录中不包括此产品 -2:已超可请购数量 -3:该产品已在购物车中 -4:超订货配额</returns>
        public int AddProduct(int product, int bookquantity)
        {
            if (Items.FirstOrDefault(p => p.Product == product) != null)
            {
                return(-3);
            }

            ORD_PublishDetail _m = new ORD_PublishBLL(_publish).Items.FirstOrDefault(m => m.Product == product);

            if (_m != null)
            {
                ORD_OrderCartItem cartitem = new ORD_OrderCartItem();
                cartitem.Product           = _m.Product;
                cartitem.MinQuantity       = _m.MinQuantity;
                cartitem.MaxQuantity       = _m.MaxQuantity;
                cartitem.Price             = _m.Price;
                cartitem.Points            = _m.Points;
                cartitem.AvailableQuantity = _m.AvailableQuantity;
                cartitem.SubmitQuantity    = ORD_OrderBLL.GetSubmitQuantity(_accountmonth, _client, product, _classify == 1 ? 1 : 0);

                if (bookquantity == 0)
                {
                    cartitem.BookQuantity = cartitem.MinQuantity > 0 ? cartitem.MinQuantity : new PDT_ProductBLL(product).Model.ConvertFactor;
                }
                else
                {
                    cartitem.BookQuantity = bookquantity;
                }
                cartitem.ConfirmQuantity = cartitem.BookQuantity;

                #region 判断是否超过发布目录设定的可订货数量
                if (cartitem.AvailableQuantity > 0)
                {
                    int totalquantity = ORD_PublishBLL.GetSubmitQuantity(_publish, product);
                    if (cartitem.BookQuantity > cartitem.AvailableQuantity - totalquantity)
                    {
                        return(-2);
                    }
                }
                #endregion

                #region 获取配额,判断是否超过配额
                if (_classify == 1)
                {
                    //常规订单,按配额订货
                    cartitem.QuotaQuantity = 0;
                    int          quotaid = ORD_QuotaBLL.GetQuotaByClientAndMonth(_client, _accountmonth);
                    ORD_QuotaBLL quota   = new ORD_QuotaBLL(quotaid);
                    if (quota != null)
                    {
                        ORD_QuotaDetail d = quota.Items.FirstOrDefault(p => p.Product == product);
                        if (d != null)
                        {
                            cartitem.QuotaQuantity = d.StdQuota + d.AdjQuota;
                        }
                    }

                    if (cartitem.BookQuantity > cartitem.QuotaQuantity - cartitem.SubmitQuantity)
                    {
                        return(-4);
                    }
                }
                #endregion

                _items.Add(cartitem);

                return(0);
            }
            return(-1);
        }