Exemple #1
0
        public ActionResult Add(Goods_Order_ViewModel model)
        {
            AutoMapper.Mapper.CreateMap <Goods_Order_ViewModel, Goods_Order>();
            Goods_Order order = AutoMapper.Mapper.Map <Goods_Order>(model);

            order.State = "未发货";

            if (model.CategoryName == "虚拟商品")
            {
                order.State = "已发货";
            }

            order.CreateTime = DateTime.Now;
            Goods_Order_BLL bll = new Goods_Order_BLL();

            bll.Add(order);
            Goods_BLL gbll = new Goods_BLL();
            Goods     good = gbll.Get(a => a.GoodID == model.GoodID);

            Subscriber_BLL sbll = new Subscriber_BLL();
            Subscriber     sub  = sbll.Get(a => a.SubscribeID == model.SubscribeID);

            if (sub.Score >= 0 && sub.Score >= good.CostScore)
            {
                sub.Score = sub.Score - good.CostScore;
                if (sub.ScoreUsed != null)
                {
                    sub.ScoreUsed += good.CostScore;
                }
                else
                {
                    sub.ScoreUsed = good.CostScore;
                }
                sbll.Update(sub);

                good.Count = good.Count - 1;
                gbll.Update(good);
                //Subscriber sub = new Subscriber_BLL().Get(a => a.SubscribeID == model.SubscribeID);

                //string link = WeiXinHelper.AuthorizeUrl(sub.OfficialAccount.AppID, Url.Content("~/WeiXin/Order/MyList"),
                //    sub.AccountID.ToString());

                return(RedirectToAction("MyList", "Order", new { SubscribeID = model.SubscribeID }));
            }
            else
            {
                ModelState.AddModelError("", "抱歉,您的积分不够!");
                return(View(model));
            }
        }
        public ActionResult FaHuo(Guid id)
        {
            Goods_Order_BLL bll   = new Goods_Order_BLL();
            Goods_Order     order = bll.Get(a => a.OrderID == id);


            AutoMapper.Mapper.CreateMap <Goods_Order, Goods_Order_FaHuo_ViewModel>()
            .ForMember(dest => dest.UserName, opt => opt.MapFrom(src => src.Users.UserName))
            .ForMember(dest => dest.CategoryName, opt => opt.MapFrom(src => src.Goods.Goods_Category.CategoryName))
            .ForMember(dest => dest.GoodsName, opt => opt.MapFrom(src => src.Goods.GoodName))
            .ForMember(dest => dest.GoodsImage, opt => opt.MapFrom(src => src.Goods.Image))
            .ForMember(dest => dest.SendWayName, opt => opt.MapFrom(src => src.Goods.Goods_SendWay.SendWayName));
            Goods_Order_FaHuo_ViewModel model = AutoMapper.Mapper.Map <Goods_Order_FaHuo_ViewModel>(order);

            return(View(model));
        }
        public ActionResult FaHuo(Goods_Order_FaHuo_ViewModel model)
        {
            Goods_Order_BLL bll   = new Goods_Order_BLL();
            Goods_Order     order = bll.Get(a => a.OrderID == model.OrderID);

            if (model.CategoryName == "实物商品")
            {
                if (model.SendWayName == "快递到付" || model.SendWayName == "商家包邮")
                {
                    order.ExpressCompany = model.ExpressCompany;
                    order.ExpressNumber  = model.ExpressNumber;
                }
            }


            order.State = "已发货";
            bll.Update(order);


            return(RedirectToAction("List", new { accountid = order.AccountID }));
        }
Exemple #4
0
        //
        // GET: /WeiXin/Order/

        public ActionResult Add(Guid GoodID, Guid SubscribeID)
        {
            Goods_Order_BLL obll  = new Goods_Order_BLL();
            int             count = obll.GetCount(a => a.GoodID == GoodID && a.SubscribeID == SubscribeID);


            if (count > 0)
            {
                MessageHelper mh         = new MessageHelper();
                string        messagestr = mh.Alert("抱歉,您已经兑换过此商品,每人限兑换一个。", Url.Action("MyList", "Order", new { area = "WeiXin", SubscribeID = SubscribeID }));

                return(Content(messagestr));
            }

            Goods good = new Goods_BLL().Get(a => a.GoodID == GoodID);



            ViewBag.GoodName  = good.GoodName;
            ViewBag.CostScore = good.CostScore;



            Goods_Order order = new Goods_Order();

            order.OrderID     = Guid.NewGuid();
            order.GoodID      = GoodID;
            order.SubscribeID = SubscribeID;
            order.AccountID   = good.AccountID;
            order.UserID      = good.UserID;


            AutoMapper.Mapper.CreateMap <Goods_Order, Goods_Order_ViewModel>();
            Goods_Order_ViewModel model = AutoMapper.Mapper.Map <Goods_Order_ViewModel>(order);

            model.CategoryName = good.Goods_Category.CategoryName;
            model.SendWayName  = good.Goods_SendWay.SendWayName;

            return(View(model));
        }