Beispiel #1
0
        /// <summary>
        /// Создание заказа
        /// </summary>
        /// <param name="JsonOrderRequest">Запрос посредством Json</param>
        /// <returns></returns>
        public CreateOrderResult CreateOrder(string JsonOrderRequest)
        {
            if (string.IsNullOrWhiteSpace(JsonOrderRequest))
            {
                throw new NullReferenceException("string JsonOrderRequest is NnullOeEmpty.");
            }
            var orderRequests = OrderRequest.FromJson(JsonOrderRequest);

            if (orderRequests.Length == 0)
            {
                throw new NullReferenceException("Массив объекта 'Заказ' пуст.");
            }

            // Url сервиса
            string url = $"{this._BaseUrl}/1.0/user/backlog";

            // Тело для запроса
            var JsonRequestBody = Request.OrderRequest.Serialize.ToJson(orderRequests);

            string requestResult =
                (Task.Run(async()
                          => await AsyncPUT(url, JsonRequestBody)))
                .Result;
            var result = CreateOrderResult.FromJson(requestResult);

            return(result);
        }
Beispiel #2
0
        public JsonResult CreateOrder([FromBody] OrderRequests model)
        {
            var result = new CreateOrderResult();

            result = ApiHelper <CreateOrderResult> .HttpPostAsync(
                $"{Helper.ApiUrl}api/order/save",
                model
                );

            return(Json(new { result }));
        }
 /// <summary>
 /// 创建订单
 /// </summary>
 public virtual CreateOrderResult CreateOrder(CreateOrderParameters parameters)
 {
     Parameters = parameters;
     Result     = new CreateOrderResult();
     CheckOrderParameters();
     CreateOrdersBySellers();
     RemoveCartProducts();
     SaveShippingAddress();
     CreateMergedTransaction();
     return(Result);
 }
Beispiel #4
0
        public static async Task <CreateOrderResult> CreateOrder(CreateOrderRequest createOrderRequest)
        {
            CreateOrderResult result = null;

            using (var orderClient = new CreateOrderClient())
            {
                var createOrderResult = await orderClient.CreateOrderAsync(createOrderRequest);

                createOrderResult.ThrowIfException(true);
                result = createOrderResult.Result;
            }
            return(result);
        }
        private async Task <XmlElement> CreateAppointment(CreateOrderResult result, DateTime startTime, DateTime endTime)
        {
            result.ExternallyManagedAppointment.Should().BeTrue();

            var drsConfirmBooking = Requests.DRSConfirmBooking;

            drsConfirmBooking = drsConfirmBooking.Replace("{{workOrderId}}", result.Id.ToString());
            drsConfirmBooking = drsConfirmBooking.Replace("{{planningWindowStart}}", startTime.ToString("s"));
            drsConfirmBooking = drsConfirmBooking.Replace("{{planningWindowEnd}}", endTime.ToString("s"));
            var(_, response)  = await SoapPost("/Service.asmx", drsConfirmBooking);

            return(response);
        }
 /// <summary>
 /// 创建订单
 /// </summary>
 public virtual CreateOrderResult CreateOrder(IDatabaseContext context, CreateOrderParameters parameters)
 {
     Parameters = parameters;
     Context    = context;
     Result     = new CreateOrderResult();
     CheckOrderParameters();
     CreateOrdersBySellers();
     RemoveCartProducts();
     SaveShippingAddress();
     ReduceProductsStock();
     CreateMergedTransaction();
     return(Result);
 }
Beispiel #7
0
        public CreateOrderResult CreateOrderAsync(CreateOrderParameter createOrderParameter)
        {
            string str;

            if (!this.ValidateParameter <CreateOrderParameter>(createOrderParameter, out str))
            {
                CreateOrderResult result1 = new CreateOrderResult();
                result1.ErrorMessage = str;
                return(result1);
            }
            UnifiedOrderRequest request = new UnifiedOrderRequest
            {
                AppId         = this.m_AppId,
                MerchantId    = createOrderParameter.MerchantId,
                DeviceInfo    = _DeviceInfo,
                NonceString   = WeChatSignHelper.CreateRandomString(),
                Body          = createOrderParameter.Body,
                Detail        = createOrderParameter.Detail,
                Attach        = createOrderParameter.Attach,
                OutTradeNo    = createOrderParameter.OutTradeNo,
                FeeType       = _OrderFeeType,
                TotalFee      = (int)(createOrderParameter.TotalFee * 100.0),
                SpbllCreateIP = createOrderParameter.IP,
                TimeStart     = DateTime.Now.ToString("yyyyMMddHHmmss"),
                TimeExpire    = DateTime.Now.AddHours((double)_OrderExpireHour).ToString("yyyyMMddHHmmss"),
                NotifyUrl     = createOrderParameter.NotifyUrl,
                TradeType     = createOrderParameter.TradeType,
                ProductId     = createOrderParameter.ProductId,
                OpenId        = createOrderParameter.OpenId
            };
            UnifiedOrderResponse response = this.InvokeApiAsync <UnifiedOrderRequest, UnifiedOrderResponse>(_UnifiedorderUrl, request);

            if (!response.IsSuccess)
            {
                CreateOrderResult result3 = new CreateOrderResult();
                result3.ErrorCode    = response.ErrCode;
                result3.ErrorMessage = response.ReturnMsg;
                return(result3);
            }
            CreateOrderResult result2 = new CreateOrderResult();

            result2.IsSuccess = true;
            result2.CodeUrl   = response.CodeUrl;
            result2.PrepayId  = response.PrepayId;
            return(result2);
        }
Beispiel #8
0
        public async override Task HandleAsync()
        {
            string domain = this.context.Request.Query["domain"];


            //验证
            CreateOrderResult result = new CreateOrderResult();

            System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"^(\*\.)?([a-zA-Z0-9-]{1,61}\.){0,}[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](\.[a-zA-Z]{2,})+$");
            if (!reg.IsMatch(domain))
            {
                result.Success = 0;
                result.Message = "域名格式不正确";
                await this.WriteResultAsync <CreateOrderResult>(200, result);

                return;
            }

            result.SessionKey = Guid.NewGuid().ToString();
            SSLGenerate generate = new SSLGenerate(acme, account, dnsHelper);

            bool ret = await generate.CreateOrder(domain);

            if (!ret)
            {
                result.Success = 0;
                result.Message = "创建订单失败,10秒后重试";
            }
            else
            {
                result.Success         = 1;
                result.Message         = "ok";
                result.ChallengeDomain = generate.ChallengeDomain;
                result.DnsTxtValue     = generate.ChallengRecordValue;

                MemoryCacheEntryOptions option = new MemoryCacheEntryOptions();
                option.SetPriority(CacheItemPriority.Normal);
                option.SetSlidingExpiration(TimeSpan.FromHours(24));
                this.cache.Set <SSLGenerate>(result.SessionKey, generate, option);
            }


            //序列化结果
            await this.WriteResultAsync <CreateOrderResult>(200, result);
        }
        public static async Task <CreateOrderResult> CreateOrder(string url)
        {
            CreateOrderResult objData = new CreateOrderResult();

            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(url);
                    var result = await client.GetAsync(url);

                    var place = result.Content.ReadAsStringAsync().Result;
                    objData = JsonConvert.DeserializeObject <CreateOrderResult>(await result.Content.ReadAsStringAsync());
                }
            }
            catch (Exception ex)
            {
            }
            return(objData);
        }
Beispiel #10
0
        public static CreateOrderResult CreateOrder(decimal price, string pid, string name, Guid vipUserId,
                                                    int num, string remark)
        {
            var vipUser     = BaoYangExternalService.GetCompanyUserInfo(vipUserId);
            var companyId   = vipUser.CompanyId == 0 ? (int?)null : vipUser.CompanyId;
            var companyName = string.Empty;

            if (companyId != null && vipUser.CompanyInfo != null)
            {
                if (vipUser.CompanyInfo.Id == companyId.Value)
                {
                    companyName = vipUser.CompanyInfo.Name;
                }
                else if (vipUser.CompanyInfo.ChildCompany != null)
                {
                    companyName = vipUser.CompanyInfo.ChildCompany.FirstOrDefault(c => c.Id == companyId.Value)?.Name;
                }
            }
            var createOrderRequest = new CreateOrderRequest
            {
                OrderChannel = "f大客户保养套餐",
                OrderType    = "44大客户保养2B保批",
                Status       = OrderEnum.OrderStatus.New,
                Customer     = new OrderCustomer
                {
                    UserId   = vipUser.UserId,
                    UserName = vipUser.UserName,
                    UserTel  = vipUser.UserMobile,
                },
                Delivery = new OrderDelivery
                {
                    DeliveryStatus = OrderEnum.DeliveryStatus.Signed,
                    DeliveryType   = OrderEnum.DeliveryType.NoDelivery,
                    InstallType    = OrderEnum.InstallType.ShopInstall,
                },
                Payment = new OrderPayment
                {
                    PayStatus   = OrderEnum.PayStatus.Waiting,
                    PayMothed   = OrderEnum.PayMethod.MonthPay,
                    PaymentType = "5Special",
                },
                Money = new OrderMoney
                {
                    SumMoney       = price * num,
                    SumMarkedMoney = price * num,
                },
                Items = new List <OrderItem>()
                {
                    new OrderItem()
                    {
                        Price    = price,
                        Pid      = pid,
                        Num      = num,
                        Name     = name,
                        Category = "BXGSDCBY"
                    }
                },
                SumNum = num,
                Remark = remark,
                BigCustomerCompanyId   = companyId,
                BigCustomerCompanyName = companyName,
            };
            CreateOrderResult result = null;

            try
            {
                result = BaoYangExternalService.CreateOrder(createOrderRequest);
            }
            catch (Exception ex)
            {
                Logger.Error($"创建订单失败, request:{{{JsonConvert.SerializeObject(createOrderRequest)}}}", ex);
            }
            return(result);
        }
Beispiel #11
0
        private async void Pay_Clicked(object sender, EventArgs e)
        {
            if (paymentType == "2")
            {
                string products = "";
                var    _note    = AddNotePage.notes;

                try
                {
                    products = "[";
                    var _products = App.Database.GetAllProduct();

                    List <CartProductDetail> cartProductDetails = new List <CartProductDetail>();
                    cartProductDetails.Clear();
                    foreach (var group in _products)
                    {
                        var resultID = cartProductDetails.Find(x => x.baseProductId == group.baseProductId);
                        if (resultID == null)
                        {
                            products += "{";
                            products += '"' + "id" + '"' + ":" + group.baseProductId + ",";
                            products += '"' + "addon" + '"' + ":" + "[";


                            cartProductDetails.Add(new CartProductDetail {
                                baseProductId = group.baseProductId
                            });
                            foreach (var food in _products)
                            {
                                if (group.baseProductId == food.baseProductId)
                                {
                                    int type = 1;
                                    if (food.typePrice == "M")
                                    {
                                        type = 1;
                                    }
                                    if (food.typePrice == "L")
                                    {
                                        type = 2;
                                    }
                                    if (food.typePrice == "S")
                                    {
                                        type = 3;
                                    }
                                    products += "{";
                                    products += '"' + "id" + '"' + ":" + food.productId + ",";
                                    products += '"' + "quantity" + '"' + ":" + food.productQty + ",";
                                    products += '"' + "note" + '"' + ":" + '"' + food.note + '"' + ",";
                                    products += '"' + "type" + '"' + ":" + type;
                                    products += "},";
                                }
                            }


                            products  = products.Substring(0, products.Length - 1);
                            products += "]";


                            products += "},";
                        }
                    }


                    products  = products.Substring(0, products.Length - 1);
                    products += "]";
                }
                catch (Exception)
                {
                }


                string note_Json = "";

                if (AddNotePage.notes.Count > 0)
                {
                    try
                    {
                        note_Json = "[";

                        foreach (var cn in _note)
                        {
                            //id
                            note_Json += "{";
                            note_Json += '"' + "shop_id" + '"' + ":" + cn.id + ",";
                            note_Json += '"' + "description" + '"' + ":" + '"' + cn.noteTxt + '"';
                            note_Json += "},";
                        }
                        note_Json  = note_Json.Substring(0, note_Json.Length - 1);
                        note_Json += "]";
                    }
                    catch (Exception)
                    {
                    }
                }



                var ans = await App.Current.MainPage.DisplayAlert("", AppResources.createOrder, AppResources.yes, AppResources.no);

                if (ans)
                {
                    try
                    {
                        if (!CommonLib.checkconnection())
                        {
                            await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection));

                            await Task.Delay(1000);

                            ShowMessage.CloseAllPopup();
                            return;
                        }

                        await App.Current.MainPage.Navigation.PushPopupAsync(new Loader());

                        LoggedInUser objUser = App.Database.GetLoggedInUser();



                        string postData = "user_id=" + objUser.userId + "&items=" + products + "&payment_method=" + paymentType + "&full_address=" + DeliveryAddressPopUp.Txt + "&lat=" + DeliveryAddressPopUp.Lat1 + "&lng=" + DeliveryAddressPopUp.Lng1 + "&notes=" + note_Json + "&self_pick=" + pickOrders;


                        HttpClient httpClient = new HttpClient();
                        string     boundary   = "---8d0f01e6b3b5dafaaadaad";
                        MultipartFormDataContent multipartContent = new MultipartFormDataContent(boundary);
                        try
                        {
                            foreach (var cn in _note)
                            {
                                if (cn.noteImg != null)
                                {
                                    var fileContent = new ByteArrayContent(cn.noteImg);
                                    fileContent.Headers.ContentType        = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
                                    fileContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data")
                                    {
                                        Name     = "note_image[]",
                                        FileName = cn.id + "_orderNote" + ".png",
                                    };
                                    multipartContent.Add(fileContent);
                                }
                                else
                                {
                                    string fileName    = "Icon";
                                    byte[] array       = Encoding.ASCII.GetBytes(fileName);
                                    var    fileContent = new ByteArrayContent(array);
                                    fileContent.Headers.ContentType        = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
                                    fileContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data")
                                    {
                                        Name     = "note_image[]",
                                        FileName = cn.id + "_emptyNote" + ".png",
                                    };
                                    multipartContent.Add(fileContent);
                                }
                            }
                        }
                        catch { }



                        HttpResponseMessage response = await httpClient.PostAsync(CommonLib.ws_MainUrl + "createOrder?" + postData, multipartContent);

                        if (response.IsSuccessStatusCode)
                        {
                            string content = await response.Content.ReadAsStringAsync();

                            if (content != null)
                            {
                                CreateOrderResult objData = new CreateOrderResult();
                                objData = Newtonsoft.Json.JsonConvert.DeserializeObject <CreateOrderResult>(content);

                                if (objData.status == 1)
                                {
                                    PaymentPopUp.checkoitId = objData.data.checkout_id;
                                    //notes clear
                                    // AddNotePage.notes.Clear();
                                    // App.Database.ClearProduc();
                                    // App.Database.ClearAddon();

                                    Loader.CloseAllPopup();


                                    PaymentPopUp Popup = new PaymentPopUp();
                                    await App.Current.MainPage.Navigation.PushPopupAsync(Popup);
                                }
                                else
                                {
                                    Loader.CloseAllPopup();

                                    if (App.Lng == "ar-AE")
                                    {
                                        await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(objData.msg_ar));
                                    }
                                    else
                                    {
                                        await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(objData.msg_en));
                                    }
                                    await Task.Delay(1000);

                                    ShowMessage.CloseAllPopup();
                                }
                            }
                        }
                        else
                        {
                            Loader.CloseAllPopup();


                            await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(response.ReasonPhrase.ToString()));

                            await Task.Delay(1000);

                            ShowMessage.CloseAllPopup();
                        }
                    }
                    catch (Exception ex)
                    {
                        Loader.CloseAllPopup();
                    }
                }
            }
            else
            {
                string products = "";
                var    _note    = AddNotePage.notes;

                try
                {
                    products = "[";
                    var _products = App.Database.GetAllProduct();

                    List <CartProductDetail> cartProductDetails = new List <CartProductDetail>();
                    cartProductDetails.Clear();
                    foreach (var group in _products)
                    {
                        var resultID = cartProductDetails.Find(x => x.baseProductId == group.baseProductId);
                        if (resultID == null)
                        {
                            products += "{";
                            products += '"' + "id" + '"' + ":" + group.baseProductId + ",";
                            //   products += '"' + "quantity" + '"' + ":" + group.productQty + ",";
                            products += '"' + "addon" + '"' + ":" + "[";
                            // var _addons = App.Database.GetAllProductAddon(Convert.ToString(group.ID));


                            cartProductDetails.Add(new CartProductDetail {
                                baseProductId = group.baseProductId
                            });
                            foreach (var food in _products)
                            {
                                if (group.baseProductId == food.baseProductId)
                                {
                                    int type = 1;
                                    if (food.typePrice == "M")
                                    {
                                        type = 1;
                                    }
                                    if (food.typePrice == "L")
                                    {
                                        type = 2;
                                    }
                                    if (food.typePrice == "S")
                                    {
                                        type = 3;
                                    }
                                    products += "{";
                                    products += '"' + "id" + '"' + ":" + food.productId + ",";
                                    products += '"' + "quantity" + '"' + ":" + food.productQty + ",";
                                    products += '"' + "note" + '"' + ":" + '"' + food.note + '"' + ",";
                                    products += '"' + "type" + '"' + ":" + type;
                                    products += "},";
                                }
                            }

                            //
                            //if (_addons.Count != 0)
                            products  = products.Substring(0, products.Length - 1);
                            products += "]";


                            products += "},";
                        }
                    }
                    //
                    products  = products.Substring(0, products.Length - 1);
                    products += "]";
                }
                catch (Exception)
                {
                }


                string note_Json = "";
                if (AddNotePage.notes.Count > 0)
                {
                    try
                    {
                        note_Json = "[";

                        foreach (var cn in _note)
                        {
                            note_Json += "{";
                            note_Json += '"' + "shop_id" + '"' + ":" + cn.id + ",";
                            note_Json += '"' + "description" + '"' + ":" + '"' + cn.noteTxt + '"';
                            note_Json += "},";
                        }
                        note_Json  = note_Json.Substring(0, note_Json.Length - 1);
                        note_Json += "]";
                    }
                    catch (Exception)
                    {
                    }
                }



                var ans = await App.Current.MainPage.DisplayAlert("", AppResources.createOrder, AppResources.yes, AppResources.no);

                if (ans)
                {
                    try
                    {
                        if (!CommonLib.checkconnection())
                        {
                            await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection));

                            await Task.Delay(1000);

                            ShowMessage.CloseAllPopup();
                            return;
                        }

                        await App.Current.MainPage.Navigation.PushPopupAsync(new Loader());

                        LoggedInUser objUser = App.Database.GetLoggedInUser();



                        string postData = "user_id=" + objUser.userId + "&items=" + products + "&payment_method=" + paymentType + "&full_address=" + DeliveryAddressPopUp.Txt + "&lat=" + DeliveryAddressPopUp.Lat1 + "&lng=" + DeliveryAddressPopUp.Lng1 + "&notes=" + note_Json + "&self_pick=" + pickOrders;

                        string aa = postData;


                        HttpClient httpClient = new HttpClient();
                        string     boundary   = "---8d0f01e6b3b5dafaaadaad";
                        MultipartFormDataContent multipartContent = new MultipartFormDataContent(boundary);
                        try
                        {
                            foreach (var cn in _note)
                            {
                                if (cn.noteImg != null)
                                {
                                    var fileContent = new ByteArrayContent(cn.noteImg);
                                    fileContent.Headers.ContentType        = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
                                    fileContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data")
                                    {
                                        Name     = "note_image[]",
                                        FileName = cn.id + "_orderNote" + ".png",
                                    };
                                    multipartContent.Add(fileContent);
                                }
                                else
                                {
                                    string fileName    = "Icon";
                                    byte[] array       = Encoding.ASCII.GetBytes(fileName);
                                    var    fileContent = new ByteArrayContent(array);
                                    fileContent.Headers.ContentType        = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream");
                                    fileContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data")
                                    {
                                        Name     = "note_image[]",
                                        FileName = cn.id + "_emptyNote" + ".png",
                                    };
                                    multipartContent.Add(fileContent);
                                }
                            }
                        }
                        catch { }

                        string aa1 = postData;

                        HttpResponseMessage response = await httpClient.PostAsync(CommonLib.ws_MainUrl + "createOrder?" + postData, multipartContent);

                        if (response.IsSuccessStatusCode)
                        {
                            string content = await response.Content.ReadAsStringAsync();

                            if (content != null)
                            {
                                CreateOrderResult objData = new CreateOrderResult();
                                objData = Newtonsoft.Json.JsonConvert.DeserializeObject <CreateOrderResult>(content);

                                if (objData.status == 1)
                                {
                                    //notes clear
                                    AddNotePage.notes.Clear();

                                    App.Database.ClearProduc();
                                    App.Database.ClearAddon();

                                    Loader.CloseAllPopup();

                                    if (App.Lng == "ar-AE")
                                    {
                                        await DisplayAlert("", objData.msg_ar, "OK");
                                    }
                                    else
                                    {
                                        await DisplayAlert("", objData.msg_en, "OK");
                                    }

                                    App.Current.MainPage = new NavigationPage(new MainPage());
                                }
                                else
                                {
                                    Loader.CloseAllPopup();

                                    if (App.Lng == "ar-AE")
                                    {
                                        await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(objData.msg_ar));
                                    }
                                    else
                                    {
                                        await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(objData.msg_en));
                                    }
                                    await Task.Delay(1000);

                                    ShowMessage.CloseAllPopup();
                                }
                            }
                        }
                        else
                        {
                            Loader.CloseAllPopup();


                            await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(response.ReasonPhrase.ToString()));

                            await Task.Delay(1000);

                            ShowMessage.CloseAllPopup();
                        }
                    }
                    catch (Exception ex)
                    {
                        Loader.CloseAllPopup();
                    }
                }
            }
        }
Beispiel #12
0
 public CreateOrderResponse(CreateOrderResult result)
 {
     Result = result;
 }