Ejemplo n.º 1
0
        public async Task <bool> OfflinePayCompleted(WaiterPaidDetails paidDetails)
        {
            Dine dine = await ctx.Dines.FirstOrDefaultAsync(p => p.Id == paidDetails.DineId);

            List <DinePaidDetail> exisedPaidDetails = await ctx.DinePaidDetails.Where(p => p.Dine.Id == paidDetails.DineId).ToListAsync();

            decimal price = 0;

            foreach (var p in exisedPaidDetails)
            {
                price += p.Price;
            }
            foreach (var p in paidDetails.PaidDetails)
            {
                price += p.Price;
                ctx.DinePaidDetails.Add(new DinePaidDetail {
                    DineId    = paidDetails.DineId,
                    PayKindId = p.PayKindId,
                    Price     = p.Price,
                    RecordId  = p.RecordId
                });
            }
            if (Math.Abs(dine.Price - price) > 0.01m)
            {
                return(false);
            }
            dine.IsPaid = true;

            await changeCustomerPoints(dine);

            await ctx.SaveChangesAsync();

            return(true);
        }
Ejemplo n.º 2
0
        public async Task <JsonResult> WaiterPayCompleted(WaiterPaidDetails paidDetails)
        {
            bool succeeded = await OrderManager.OfflinePayCompleted(paidDetails);

            if (!succeeded)
            {
                return(Json(new JsonError("支付金额与应付金额不匹配")));
            }

            NewDineInformTcpClient.SendNewDineInfrom(CurrHotel.Id, paidDetails.DineId, true);
            return(Json(new JsonSuccess {
                Data = paidDetails.DineId
            }));
        }
Ejemplo n.º 3
0
        public async Task <JsonResult> WaiterPayWithPaidDetails(Cart cart, WaiterCartAddition cartAddition, WaiterPaidDetails paidDetails)
        {
            FunctionResult result = await waiterPay(cart, cartAddition, "WaiterWithPaidDetails");

            if (!result.Succeeded)
            {
                return(Json(new JsonError(result.Message)));
            }

            Dine dine = ((Dine)result.Data);

            await newDineInform(dine, "WaiterWithPaidDetail");
            await requestPrintDine(dine.Id);

            paidDetails.DineId = dine.Id;

            bool succeeded = await OrderManager.OfflinePayCompleted(paidDetails);

            if (!succeeded)
            {
                return(Json(new JsonError("支付金额与应付金额不匹配")));
            }

            NewDineInformTcpClient.SendNewDineInfrom(CurrHotel.Id, paidDetails.DineId, true);
            return(Json(new JsonSuccess {
                Data = paidDetails.DineId
            }));
        }