예제 #1
0
        public ActionResult ConfirmOrder()
        {
            var        loginUser  = (UserInfo)ViewBag.User;
            var        list       = _order.GetShoppingCar(loginUser);
            var        mj         = _active.CheckManjiujian(loginUser, ViewBag.ManagerId);
            Manjiusong ms         = _active.CheckManSong(loginUser, ViewBag.ManagerId);
            var        couponList = _active.FindCanUseCoupon(loginUser.UserId);
            var        dpses      = _active.CheckDPS(list, loginUser.TypeId, loginUser.AreaNum);

            dpses.ForEach(x =>
            {
                var model = _manager.GetGoodInfoById(x.SendGoodsId);
                if (model != null)
                {
                    x.SendGoodsNum = model.pic1;
                }
            });
            if (ms != null)
            {
                var msGoods = _manager.GetGoodInfoById(ms.SendGoodId);
                if (msGoods != null)
                {
                    ms.Tittle = msGoods.pic1;
                }
            }
            ViewBag.Mj   = mj;
            ViewBag.Ms   = ms;
            ViewBag.List = list;

            ViewBag.CouponList = couponList;
            ViewBag.DPSES      = dpses;

            return(View());
        }
예제 #2
0
        public ActionResult SaveEditManSong(Manjiusong m, List <int> userType, string areaNums)
        {
            var  areaList  = areaNums.Split(',').ToList();
            var  loginUser = (UserInfo)ViewBag.User;
            Guid managerId = (Guid)ViewBag.ManagerId;

            m.CreateTime   = DateTime.Now;
            m.CreateUserId = managerId;
            string userTypes = "";

            userType.ForEach(x =>
            {
                userTypes += x;
                userTypes += ",";
            });
            m.UserTypes = userTypes;
            _active.SaveManjiusong(m, areaList);
            Response.Redirect("GetManSongList");
            return(View());
        }
예제 #3
0
        /// <summary>
        /// 保存满就送
        /// </summary>
        /// <param name="model"></param>
        /// <param name="areNum"></param>
        /// <returns></returns>
        public ResponseModel SaveManjiusong(Manjiusong model, List <string> areNum)
        {
            List <ManToArea> list = new List <ManToArea>();
            var areaHis           = _context.ManToAreas.Where(x => x.ActiveId == model.Id);

            areNum.ForEach(x =>
            {
                var area = _context.Areas.FirstOrDefault(c => c.Num == x);
                if (area != null)
                {
                    var newArea        = new ManToArea();
                    newArea.ActiveId   = model.Id;
                    newArea.ActiveName = model.Tittle;
                    newArea.AreaNum    = area.Num;
                    newArea.AreaName   = area.Name;
                    list.Add(newArea);
                }
            });
            var modelHis = _context.Manjiusongs.FirstOrDefault(x => x.Id == model.Id);

            modelHis.Tittle        = model.Tittle;
            modelHis.StartTime     = model.StartTime;
            modelHis.EndTime       = model.EndTime;
            modelHis.LimitMoney    = model.LimitMoney;
            modelHis.SendGoodCount = model.SendGoodCount;
            modelHis.SendGoodId    = model.SendGoodId;
            modelHis.SendGoodName  = model.SendGoodName;
            modelHis.SendGoodNum   = model.SendGoodNum;
            modelHis.UserTypes     = model.UserTypes;
            modelHis.BrandId       = model.BrandId;
            modelHis.BrandName     = model.BrandName;
            modelHis.SupplierId    = model.SupplierId;
            modelHis.SupplierName  = model.SupplierName;
            modelHis.TypeId        = model.TypeId;
            _context.ManToAreas.RemoveRange(areaHis);
            _context.ManToAreas.AddRange(list);
            _response.Stutas = _context.SaveChanges() > 0;
            return(_response);
        }
예제 #4
0
        /// <summary>
        /// 创建满就减活动
        /// </summary>
        /// <param name="model"></param>
        /// <param name="areNum"></param>
        /// <returns></returns>
        public ResponseModel CreateManjiusong(Manjiusong model, List <string> areNum)
        {
            List <ManToArea> list = new List <ManToArea>();

            areNum.ForEach(x =>
            {
                var area = _context.Areas.FirstOrDefault(c => c.Num == x);
                if (area != null)
                {
                    var newArea        = new ManToArea();
                    newArea.ActiveId   = model.Id;
                    newArea.ActiveName = model.Tittle;
                    newArea.AreaNum    = area.Num;
                    newArea.AreaName   = area.Name;
                    list.Add(newArea);
                }
            });
            _context.ManToAreas.AddRange(list);
            _context.Manjiusongs.Add(model);
            _response.Stutas = _context.SaveChanges() > 0;
            return(_response);
        }
예제 #5
0
        public string CreateOrder(string remark = "", string couponId = "")
        {
            var loginUser  = (UserInfo)ViewBag.User;
            var list       = _order.GetShoppingCar(loginUser);
            var totalPrice = list.Sum(x => x.Count * x.Price);

            if (list != null && list.Count > 0 && totalPrice > 380)
            {
                var order   = new OrderInfo();
                var saleMan = _user.GetUserByUserId(loginUser.SaleManGuid);
                order.Id               = Guid.NewGuid();
                order.CreateTime       = DateTime.Now;
                order.CreateUserId     = loginUser.UserId;
                order.CreateUserName   = loginUser.UserName;
                order.CreateUserType   = loginUser.TypeName;
                order.CreateUserNum    = loginUser.UserNum;
                order.StoreName        = loginUser.SotreName;
                order.CreateUserTel    = loginUser.Tel;
                order.CreateUserTypeId = loginUser.TypeId;
                order.RootUserId       = loginUser.CreateUserId;
                order.RootUserName     = loginUser.CreateUser;
                order.SaleManGuid      = loginUser.SaleManGuid;
                order.SaleManName      = loginUser.SaleManName;
                order.ReceiveAddr      = loginUser.Addr;
                order.Province         = loginUser.Province;
                order.ProvinceNum      = loginUser.ProvinceNum;
                order.City             = loginUser.City;
                order.CityNum          = loginUser.CityNum;
                order.Area             = loginUser.Area;
                order.AreaNum          = loginUser.AreaNum;
                order.Stutas           = (int)Common.Entities.OrderStatus.等待商家发货;
                order.SaleManTel       = saleMan == null ? "" : saleMan.Tel;
                order.PayType          = "货到付款";
                order.Remark           = remark;

                Guid Cid = new Guid();

                if (Guid.TryParse(couponId, out Cid))
                {
                    Coupon c = _active.GetCouponById(Cid);
                    if (c != null)
                    {
                        order.LessMoney += c.LessMoney;
                        _active.SetCouponUse(Cid, order.Id);
                    }
                }

                Manjiujian     mj = _active.CheckManjiujian(loginUser, ViewBag.ManagerId);
                Manjiusong     ms = _active.CheckManSong(loginUser, ViewBag.ManagerId);
                CouponActivity ca = _active.CheckCouponActivity(loginUser, ViewBag.ManagerId);
                if (mj != null)
                {
                    order.Manjian = mj.LessMoeny;
                }
                if ((ms != null && ca == null) || (ms != null && ca != null && ms.LimitMoney > ca.SendMoney))
                {
                    var       model = _manager.GetGoodsWithPrice(ms.SendGoodId, loginUser.TypeId);
                    OrderItem item  = new OrderItem();
                    item.IsGift        = true;
                    item.Count         = ms.SendGoodCount;
                    item.CreateUserId  = loginUser.UserId;
                    item.Id            = Guid.NewGuid();
                    item.LessPrice     = 0;
                    item.Price         = 0;
                    item.RealPrice     = 0;
                    item.ProductId     = model.Id;
                    item.ProductTittle = model.GoodsTittle;
                    item.TotalPrice    = 0;
                    item.ProductType   = model.FirstTypeName;
                    item.ProductTypeId = model.FirstTypeId;
                    item.ProductId     = model.Id;
                    item.BarCode       = model.BarCode;
                    item.Spec          = model.Spec;
                    item.Unit          = model.Unit;
                    item.SupplierId    = model.SupplierId;
                    item.SupplierName  = model.SupplierName;
                    item.BrandId       = model.BrandId;
                    item.Brand         = model.BrandName;
                    item.Pic           = model.pic1;
                    var res = _order.AddOrderItem(item);
                }
                if ((ms == null && ca != null) || (ms != null && ca != null && ms.LimitMoney <= ca.SendMoney))
                {
                    Coupon coupon = new Coupon();
                    coupon.BrandId        = ca.BrandId;
                    coupon.BrandName      = ca.BrandName;
                    coupon.CouponType     = ca.CouponType;
                    coupon.CreateTime     = DateTime.Now;
                    coupon.CreateUserId   = ca.CreateUserId;
                    coupon.CreateUserName = ca.CreateUserName;
                    coupon.EffectTime     = ca.EffectTime;
                    coupon.EndTime        = DateTime.Now.AddDays(coupon.EffectTime);
                    coupon.Id             = Guid.NewGuid();
                    coupon.IsUsed         = false;
                    coupon.LessMoney      = ca.LessMoney;
                    coupon.Limit          = ca.Limit;
                    coupon.Remark         = ca.Remark;
                    coupon.StartTime      = ca.StartTime;
                    coupon.StoreId        = loginUser.UserId;
                    coupon.StoreNum       = loginUser.UserNum;
                    coupon.SupplierId     = ca.SupplierId;
                    coupon.SupplierName   = ca.SupplierName;
                    coupon.ActivityID     = ca.Id;
                    List <UserInfo> userList = new List <UserInfo>();
                    userList.Add(loginUser);
                    _active.CreateCoupon(coupon, userList);
                }
                var dpses = _active.CheckDPS(list, loginUser.TypeId, loginUser.AreaNum);
                foreach (var dps in dpses)
                {
                    var       model = _manager.GetGoodsWithPrice(dps.SendGoodsId, loginUser.TypeId);
                    OrderItem item  = new OrderItem();
                    item.IsGift        = true;
                    item.Count         = dps.SendCount;
                    item.CreateUserId  = loginUser.UserId;
                    item.Id            = Guid.NewGuid();
                    item.LessPrice     = 0;
                    item.Price         = 0;
                    item.RealPrice     = 0;
                    item.ProductId     = model.Id;
                    item.ProductTittle = model.GoodsTittle;
                    item.TotalPrice    = 0;
                    item.ProductType   = model.FirstTypeName;
                    item.ProductTypeId = model.FirstTypeId;
                    item.ProductId     = model.Id;
                    item.BarCode       = model.BarCode;
                    item.Spec          = model.Spec;
                    item.Unit          = model.Unit;
                    item.SupplierId    = model.SupplierId;
                    item.SupplierName  = model.SupplierName;
                    item.BrandId       = model.BrandId;
                    item.Brand         = model.BrandName;
                    item.Pic           = model.pic1;
                    var res = _order.AddOrderItem(item);
                }
                _response.Stutas = _order.SaveOrder(order, loginUser);
                //保存订单成功后 保存销售订单到erp 系统中
                if (_response.Stutas)
                {
                    try
                    {
                        var res = _order.InsertErp(order.Id);
                    }
                    catch (Exception ex)
                    {
                        LogsHelper.WriteErrorLog(ex, "导入Erp");
                    }
                }
            }
            else
            {
                _response.Msg = "总金额不足380无法下单!请继续添加商品!";
            }
            return(Utils.SerializeObject(_response));
        }
예제 #6
0
        /// <summary>
        /// 创建订单
        /// </summary>
        /// <param name="method"></param>
        /// <param name="remark"></param>
        /// <param name="couponId"></param>
        /// <returns></returns>
        public string CreateOrder(string remark = "", string couponId = "")
        {
            var loginUser = GetUserInfo();

            if (loginUser != null)
            {
                var list       = _order.GetShoppingCar(loginUser);
                var totalPrice = list.Sum(x => x.Count * x.Price);
                if (list != null && list.Count > 0 && totalPrice > 380)

                {
                    Guid managerId = GetManagerId(loginUser);

                    var order   = new OrderInfo();
                    var saleMan = _user.GetUserByUserId(loginUser.SaleManGuid);
                    order.Id               = Guid.NewGuid();
                    order.CreateTime       = DateTime.Now;
                    order.CreateUserId     = loginUser.UserId;
                    order.CreateUserName   = loginUser.UserName;
                    order.CreateUserType   = loginUser.TypeName;
                    order.CreateUserNum    = loginUser.UserNum;
                    order.StoreName        = loginUser.SotreName;
                    order.CreateUserTel    = loginUser.Tel;
                    order.CreateUserTypeId = loginUser.TypeId;
                    order.RootUserId       = loginUser.CreateUserId;
                    order.RootUserName     = loginUser.CreateUser;
                    order.SaleManGuid      = loginUser.SaleManGuid;
                    order.SaleManName      = loginUser.SaleManName;
                    order.ReceiveAddr      = loginUser.Addr;
                    order.Province         = loginUser.Province;
                    order.ProvinceNum      = loginUser.ProvinceNum;
                    order.City             = loginUser.City;
                    order.CityNum          = loginUser.CityNum;
                    order.Area             = loginUser.Area;
                    order.AreaNum          = loginUser.AreaNum;
                    order.Stutas           = (int)Common.Entities.OrderStatus.等待商家发货;
                    order.SaleManTel       = saleMan == null ? "" : saleMan.Tel;
                    order.PayType          = "货到付款";
                    order.Remark           = remark;

                    Guid Cid = new Guid();

                    if (Guid.TryParse(couponId, out Cid))
                    {
                        Coupon c = _active.GetCouponById(Cid);
                        if (c != null)
                        {
                            order.LessMoney += c.LessMoney;
                            _active.SetCouponUse(Cid, order.Id);
                        }
                    }

                    Manjiujian mj = _active.CheckManjiujian(loginUser, managerId);
                    Manjiusong ms = _active.CheckManSong(loginUser, managerId);
                    if (mj != null)
                    {
                        order.Manjian = mj.LessMoeny;
                    }
                    if (ms != null)
                    {
                        var       model = _goodsmanager.GetGoodsWithPrice(ms.SendGoodId, loginUser.TypeId);
                        OrderItem item  = new OrderItem();
                        item.Count         = ms.SendGoodCount;
                        item.CreateUserId  = loginUser.UserId;
                        item.Id            = Guid.NewGuid();
                        item.LessPrice     = 0;
                        item.Price         = model.RetailtPrice;
                        item.RealPrice     = 0;
                        item.ProductId     = model.Id;
                        item.ProductTittle = model.GoodsTittle;
                        item.TotalPrice    = 0;
                        item.ProductType   = model.FirstTypeName;
                        item.ProductTypeId = model.FirstTypeId;
                        item.ProductId     = model.Id;
                        item.BarCode       = model.BarCode;
                        item.Spec          = model.Spec;
                        item.Unit          = model.Unit;
                        item.SupplierId    = model.SupplierId;
                        item.SupplierName  = model.SupplierName;
                        item.BrandId       = model.BrandId;
                        item.Brand         = model.BrandName;
                        var res = _order.AddOrderItem(item);
                    }
                    var dpses = _active.CheckDPS(list, loginUser.TypeId, loginUser.AreaNum);
                    foreach (var dps in dpses)
                    {
                        var       model = _goodsmanager.GetGoodsWithPrice(dps.SendGoodsId, loginUser.TypeId);
                        OrderItem item  = new OrderItem();
                        item.IsGift        = true;
                        item.Count         = dps.SendCount;
                        item.CreateUserId  = loginUser.UserId;
                        item.Id            = Guid.NewGuid();
                        item.LessPrice     = 0;
                        item.Price         = model.RetailtPrice;
                        item.RealPrice     = 0;
                        item.ProductId     = model.Id;
                        item.ProductTittle = model.GoodsTittle;
                        item.TotalPrice    = 0;
                        item.ProductType   = model.FirstTypeName;
                        item.ProductTypeId = model.FirstTypeId;
                        item.ProductId     = model.Id;
                        item.BarCode       = model.BarCode;
                        item.Spec          = model.Spec;
                        item.Unit          = model.Unit;
                        item.SupplierId    = model.SupplierId;
                        item.SupplierName  = model.SupplierName;
                        item.BrandId       = model.BrandId;
                        item.Brand         = model.BrandName;
                        var res = _order.AddOrderItem(item);
                    }
                    var ress = _order.SaveOrder(order, loginUser);
                    if (ress)
                    {
                        var orderDetail = _order.InsertErp(order.Id);
                    }
                    _response.Stutas = ress;
                }
                else
                {
                    _response.Stutas = false;
                    _response.Msg    = "订单总金额不足380元无法下单!请继续添加商品!";
                }
            }
            else
            {
                _response.Stutas = false;
                _response.Msg    = "请先登录";
            }
            string result = Utils.SerializeObject(_response);

            return(result);
        }