Beispiel #1
0
 public void BookPositionsInternal(Guid deskId, DateTime selectedDate, List <string> positions)
 {
     using (var uow = GetUnitOfWork())
     {
         var order = new ZY_Order()
         {
             OrderId    = Guid.NewGuid(),
             Amount     = 0,
             IsInternal = true,
             OrderDate  = selectedDate,
             Status     = 1
         };
         var bookedPositions = new List <ZY_Booked_Position>();
         positions.ForEach(p =>
         {
             var bookedPosition = new ZY_Booked_Position
             {
                 Id         = Guid.NewGuid(),
                 IsInternal = true,
                 OrderDate  = selectedDate,
                 Position   = p,
                 DeskId     = deskId,
                 Status     = "1"
             };
             bookedPositions.Add(bookedPosition);
         });
         uow.Repository <ZY_Order>().Insert(order);
         uow.Repository <ZY_Booked_Position>().InsertRange(bookedPositions);
         uow.Save();
     }
 }
Beispiel #2
0
        public PlaceResult PlaceOrder(OrderInfo orderInfo)
        {
            var result = new PlaceResult()
            {
                Success = true, OrderId = Guid.NewGuid()
            };

            if (orderInfo.Positions == null || orderInfo.Positions.Count == 0)
            {
                result.Success = false;
                result.Message = "请选择位置";
                return(result);
            }
            var o = new JSSDKPayOrder();

            o.out_trade_no     = result.OrderId.ToString();
            o.body             = "";           //腾讯充值中心-QQ会员充值
            o.attach           = "";           //深圳分店
            o.spbill_create_ip = orderInfo.IP; //APP和网页支付提交用户端ip,Native支付填调用微信支付API的机器IP。
            result.prepay_id   = "test";
            //result.prepay_id = WxApiHelper.Instance.GetPaymentId(o);//todo test
            result.appId     = WxConfig.Appid;
            result.timeStamp = Utility.GetTimeSpan();
            result.nonceStr  = Utility.GenerateNonceStr();
            result.signType  = "MD5";
            string payRaw = "appId=" + result.appId
                            + "&nonceStr=" + result.nonceStr
                            + "&package=" + result.package
                            + "&signType=" + result.signType
                            + "&timeStamp=" + result.timeStamp;

            result.paySign = Utility.Signature(payRaw, result.signType);
            try
            {
                using (var uow = GetUnitOfWork())
                {
                    var desk =
                        uow.Repository <ZY_Shop_Desk>()
                        .Query()
                        .Filter(x => x.DeskId == orderInfo.DeskId)
                        .Get()
                        .FirstOrDefault();
                    if (desk == null)
                    {
                        result.Success = false;
                        result.Message = "没有找到桌子";
                        return(result);
                    }
                    var order = new ZY_Order()
                    {
                        OrderId        = result.OrderId,
                        Amount         = orderInfo.Positions.Count * desk.UnitPrice,
                        CustomerOpenId = orderInfo.CustomerOpenId,
                        OrderDate      = orderInfo.pickDate.Date,
                        Prepay_id      = result.prepay_id,
                        PickTime       = orderInfo.pickTime,
                        Status         = 0
                    };
                    var positions = new List <ZY_Booked_Position>();
                    orderInfo.Positions.ForEach(x =>
                    {
                        var p = new ZY_Booked_Position()
                        {
                            Id             = Guid.NewGuid(),
                            CustomerOpenId = orderInfo.CustomerOpenId,
                            OrderDate      = orderInfo.pickDate.Date,
                            DeskId         = orderInfo.DeskId,
                            Position       = x,
                            Status         = "1",
                            OrderId        = order.OrderId
                        };
                        positions.Add(p);
                    });
                    uow.Repository <ZY_Order>().Insert(order);
                    uow.Repository <ZY_Booked_Position>().InsertRange(positions);
                    uow.Save();
                    result.Success = true;
                    result.Message = string.Format("下单成功"); //todo message 优化
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = "失败啦";
            }
            return(result);
        }