Exemplo n.º 1
0
        //计算其它费用
        int CountOtherFee(ShopDbContext shopDb, ShopOrderOtherFee otherFee)
        {
            if (otherFee == null)
            {
                return(0);
            }
            int rtn = otherFee.BoxFee + otherFee.DeliveryFee;

            return(rtn);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 记录其它费用
 /// </summary>
 /// <param name="db"></param>
 /// <param name="takeWay"></param>
 public void RecordOtherFee(ShopDbContext db, TakeWay?takeWay, int orderItemNumb)
 {
     if (mShopOrder.IsTakeOut)
     {
         var takeOutInfo = db.Query <ShopTakeOutInfo>()
                           .Where(m => !m.IsDel)
                           .Where(m => m.ShopId == mShopOrder.ShopId)
                           .FirstOrDefault();
         if (takeOutInfo == null)
         {
             throw new Exception("该商铺未有外卖功能");
         }
         ShopOrderOtherFee otherFee = new ShopOrderOtherFee()
         {
             BoxFee = takeOutInfo.BoxFee
         };
         if (takeWay == TakeWay.送货上门)
         {
             otherFee.DeliveryFee = takeOutInfo.DeliveryFee;
         }
         mShopOrder.ShopOrderOtherFee = otherFee;
     }
     else if (mShopOrder.ShopOrderSelfHelp != null) //自助点餐
     {
         var selfHelpInfo = db.Query <ShopSelfHelpInfo>()
                            .Where(m => !m.IsDel && m.ShopId == mShopOrder.ShopId)
                            .FirstOrDefault();
         if (mShopOrder.ShopOrderSelfHelp.IsTakeOut && selfHelpInfo != null && selfHelpInfo.HasBoxFee)
         {
             ShopOrderOtherFee otherFee = new ShopOrderOtherFee()
             {
                 BoxFee = selfHelpInfo.BoxFee
             };
             mShopOrder.ShopOrderOtherFee = otherFee;
         }
     }
 }
Exemplo n.º 3
0
        public ActionResult GetShopOrderView(GetShopOrderViewArgsModel args)
        {
            var order = db.Set <ShopOrder>().Find(args.orderid);

            if (order == null)
            {
                throw new Exception("该订单不存在");
            }

            var Oauth = db.Query <ShopOrderReceiver>()
                        .Where(m => !m.IsDel)
                        .Where(m => m.ReceiverOpenId == args.openid)
                        .Where(m => m.ShopId == order.ShopId)
                        .FirstOrDefault();

            if (Oauth == null)
            {
                return(View("unauthorized"));
            }

            var items = db.Query <ShopOrderItem>()
                        .Where(m => !m.IsDel)
                        .Where(m => m.ShopOrderId == order.Id)
                        .ToList();

            if (items.Count == 0)
            {
                throw new Exception($"该订单出错,订单号为:{order.Id}");
            }

            var orderitems = items.Select(m =>
            {
                double p = Math.Round(m.SalePrice / 100d, 2);
                return(new ShopOrderItemInfo()
                {
                    Name = m.CommodityName,
                    Price = p,
                    Count = m.Count,
                    Amount = p * m.Count,
                    SkuSummary = m.SkuSummary
                });
            }).ToList();
            string   address    = null;
            string   takeway    = null;
            string   phone      = null;
            string   name       = null;
            DateTime pickupTime = new DateTime();

            if (order.IsTakeOut)
            {
                var takeout = db.Query <ShopOrderTakeout>()
                              .Where(m => !m.IsDel && m.ShopOrderId == order.Id)
                              .FirstOrDefault();
                if (takeout != null)
                {
                    address    = takeout.Address;
                    takeway    = takeout.TakeWay.ToString();
                    phone      = takeout.Phone;
                    name       = takeout.Name;
                    pickupTime = takeout.PickupTime;
                }
            }

            if (!order.Payment.HasValue)
            {
                order.Payment = 0;
            }
            //其它费用
            ShopOrderOtherFee otherFee = null;

            if (order.OtherFeeId.HasValue)
            {
                otherFee = db.GetSingle <ShopOrderOtherFee>(order.OtherFeeId.Value);
            }
            //满减折扣
            ShopOrderMoneyOffRule moneyOff = null;

            if (order.MoneyOffRuleId.HasValue)
            {
                moneyOff = db.GetSingle <ShopOrderMoneyOffRule>(order.MoneyOffRuleId.Value);
            }

            Member member = memberDb.GetSingleMember(order.MemberId);

            GetShopOrderViewResultModel rtn = new GetShopOrderViewResultModel()
            {
                MemberId              = order.MemberId,
                Id                    = order.Id,
                PayTime               = order.PayTime,
                Address               = address,
                ShopOrderItems        = orderitems,
                OrderAmount           = Math.Round(order.Amount / 100d, 2),
                ShopOrderOtherFee     = otherFee,
                ShopOrderMoneyOffRule = moneyOff,
                Remark                = order.Remark,
                TakeWay               = takeway,
                PayAmount             = Math.Round(order.Payment.Value / 100d, 2),
                Headimgurl            = member.Avatar,
                NickName              = member.NickName,
                Name                  = name,
                Phone                 = phone,
                OrderNumber           = order.OrderNumber,
                PickupTime            = pickupTime,
                PayWay                = order.PayWay ?? ""
            };

            if (order.ShopPartId.HasValue)
            {
                rtn.ShopPartName = db.Set <ShopPart>().Find(order.ShopPartId).Title;
            }
            else
            {
                rtn.ShopPartName = null;
            }
            if (order.ShopOrderSelfHelpId.HasValue)
            {
                rtn.ShopOrderSelfHelp = db.GetSingle <ShopOrderSelfHelp>(order.ShopOrderSelfHelpId.Value);
            }

            return(View(rtn));
        }
Exemplo n.º 4
0
        public APIResult <GetSingleModel> GetSingle([FromBody] IdArgsModel args)
        {
            var memberId = GetMemberId();
            var model    = db.Query <ShopOrder>()
                           .Where(m => !m.IsDel)
                           .Where(m => m.MemberId == memberId)
                           .Where(m => m.Id == args.Id)
                           .FirstOrDefault();

            if (model == null)
            {
                throw new Exception("指定纪录不存在");
            }

            var items = db.Query <ShopOrderItem>()
                        .Where(m => !m.IsDel)
                        .Where(m => m.ShopOrderId == model.Id)
                        .ToList();

            string title = null, orderStatus = null;

            if (model.ShopPartId.HasValue)
            {
                title = db.GetSingle <ShopPart>(model.ShopPartId.Value)?.Title;
            }
            string            takeway, address = null, name = null, phone = null, orderTitle = null, selfHelpNumber = null;
            ShopOrderTakeout  takeout = null;
            ShopOrderOtherFee otherFee = null;

            if (model.IsTakeOut)
            {
                orderTitle = "外卖单";
                takeout    = db.Query <ShopOrderTakeout>()
                             .Where(m => !m.IsDel && m.ShopOrderId == model.Id)
                             .FirstOrDefault();
                if (takeout == null)
                {
                    takeway = "外卖";
                }
                else
                {
                    takeway     = takeout.TakeWay.ToString();
                    address     = takeout.Address;
                    name        = takeout.Name;
                    phone       = takeout.Phone;
                    orderStatus = takeout.Status.ToString();
                }
            }
            else if (model.ShopOrderSelfHelpId.HasValue)
            {
                orderTitle = "自助点餐";
                var selfHelp = db.Set <ShopOrderSelfHelp>().Find(model.ShopOrderSelfHelpId.Value);
                if (selfHelp.IsTakeOut)
                {
                    takeway = "外带";
                }
                else
                {
                    takeway = "堂食";
                }
                orderStatus    = model.Status.ToString();
                selfHelpNumber = selfHelp.Number;
            }
            else
            {
                orderTitle  = "堂食点餐";
                orderStatus = model.Status.ToString();
                takeway     = "堂食点餐";
            }

            if (model.OtherFeeId.HasValue)
            {
                otherFee = db.Set <ShopOrderOtherFee>().Find(model.OtherFeeId.Value);
            }

            return(Success(new GetSingleModel
            {
                Takeway = takeway,
                Address = address,
                OrderStatus = orderStatus,
                Name = name,
                Phone = phone,
                OrderTitle = orderTitle,
                SelfHelpNumber = selfHelpNumber,
                Title = title,
                OtherFee = otherFee,
                ExpectTitle = takeout?.TakeWay == TakeWay.自提 ? "预计自提时间" : "期望配送时间",
                ExpectTime = takeout?.PickupTime.ToString("HH:mm"),
                Order = model,
                Items = items
            }));
        }