コード例 #1
0
ファイル: CheckOutController.cs プロジェクト: OpuZm/NHRTest
 public JsonResult Checkout(WholeOrPartialCheckoutDto req)
 {
     try
     {
         var currentUser = OperatorProvider.Provider.GetCurrent();
         var user        = _userService.GetUserInfo(new VerifyUserDTO()
         {
             UserId = currentUser.UserId
         });
         var discount = user.MinDiscountValue;
         req.OrderTableStatus       = OrderTableStatus.未结;
         req.CompanyId              = currentUser.CompanyId.ToInt();
         req.OperateUser            = currentUser.UserId;
         req.CurrentMarketId        = currentUser.LoginMarketId;
         req.AuthPermissionDiscount = discount;
         req.OperateUserCode        = currentUser.UserCode;
         if (_checkOutService.CheckoutVaild(req.ListOrderPayRecordDTO, currentUser.DepartmentId.ToInt()))
         {
             CheckOutResultDTO resultDto = _checkOutService.WholeOrPartialCheckout(req);
             return(Json(new { Result = true, Info = "操作成功", Data = resultDto }));
         }
         else
         {
             return(Json(new { Result = false, Info = "可挂账限额不足" }));
         }
     }
     catch (Exception e)
     {
         return(Json(new { Result = false, Info = "结账操作失败 - " + e.Message }));
     }
 }
コード例 #2
0
ファイル: WeiXinController.cs プロジェクト: OpuZm/NHRTest
        public async System.Threading.Tasks.Task <JsonResult> CheckOutOrder(WholeOrPartialCheckoutDto req, OperatorModel member)
        {
            var res = new Response()
            {
                Data = false, Successed = false
            };

            if (ModelState.IsValid)
            {
                try
                {
                    var orderInfo = _orderRepository.GetOrderDTO(req.OrderId);
                    var user      = new VerifyUserDTO()
                    {
                        UserId = member.UserId
                    };
                    //var discount = user.MinDiscountValue;
                    req.OrderTableStatus       = OrderTableStatus.未结;
                    req.CompanyId              = orderInfo.R_Restaurant_Id;
                    req.OperateUser            = member.UserId;
                    req.CurrentMarketId        = orderInfo.R_Market_Id;
                    req.AuthPermissionDiscount = 0;
                    req.OperateUserCode        = member.UserCode;
                    CheckOutResultDTO resultDto = _checkOutService.WholeOrPartialCheckout(req, CyddCzjlUserType.会员);
                    if (resultDto != null)
                    {
                        res.Successed = true;
                        res.Data      = true;
                        var hub = GlobalHost.ConnectionManager.GetHubContext <MyHub>();
                        await hub.Clients.All.callResServiceRefersh(true);
                    }
                    else
                    {
                        res.Message = "结账失败,请联系管理员";
                    }
                }
                catch (Exception e)
                {
                    res.Message = e.Message;
                }
            }
            else
            {
                res.Message = string.Join(",", ModelState.SelectMany(ms => ms.Value.Errors).Select(e => e.ErrorMessage));
            }
            return(Json(res));
        }