Пример #1
0
        private void acceptNewOrder()
        {
            try
            {
                PharmacyDto pharmacyId = aptekiListView.SelectedItems[0].Tag as PharmacyDto;
                var pharmacy = getPharmacyById(pharmacyId.ID);

                var productIdQuantityDictionary = new Dictionary<int, int>();

                foreach (DataGridViewRow row in zamowienieDataGridView.Rows)
                {
                    ProductDto product = row.Tag as ProductDto;
                    productIdQuantityDictionary.Add(product.ProductId, Int32.Parse(row.Cells["Obsluga_IloscHeader"].Value.ToString()));
                }

                var orderRequest = new OrderRequest()
                {
                    ProductIdQuantityDictionary = productIdQuantityDictionary
                };

                var response = client.PlaceOrder(orderRequest);
                Console.WriteLine(response.Message);

                zamowienieDataGridView.Rows.Clear();
            }
            catch (Exception)
            { }
        }
        public async Task<IHttpActionResult> CreateFor(string userId, OrderRequest order)
        {
            if (String.IsNullOrEmpty(userId)) return BadRequest("invalid user id");
            if (order == null || order.Equals(OrderRequest.Empty)) return BadRequest("invalid order request");

            var orderId = userId.GetHashCode().ToString("x") + "-" + Guid.NewGuid();
            return Ok(await _repository.Save(new Order(orderId, userId)));
        }
Пример #3
0
        public Order GetOrder(int orderId)
        {
            OrderRequest request = new OrderRequest();
            request.RequestId = NewRequestId;
            request.AccessToken = AccessToken;
            request.ClientTag = ClientTag;

            request.LoadOptions = new string[] { "Order", "Customer", "OrderDetails" };
            request.Criteria = new OrderCriteria { OrderId = orderId };

            OrderResponse response = ActionServiceClient.GetOrders(request);

            if (request.RequestId != response.CorrelationId)
                throw new ApplicationException("GetOrder: RequestId and CorrelationId do not match.");

            return response.Order;
        }
 public CupcakeNewOrderRecievedEvent(OrderRequest order)
 {
     this.Order = order;
 }
        public async Task <IActionResult> CreateEmpayOrderAsync()
        {
            try
            {
                await SetBasketModelAsync();

                // GET Empay configuration from appsettings.json
                var empaySettings = new EmpaySettings();
                _config.Bind("Empay", empaySettings);

                var orderRequest = new OrderRequest();
                var purchaseUnit = new OrderRequestPurchaseUnit
                {
                    CustomId    = BasketModel.Id.ToString(),
                    Description = "eShop purchase",
                    InvoiceId   = BasketModel.Id.ToString(),
                    Amount      = new AmountWithBreakdown
                    {
                        CurrencyCode = "AED",
                        Value        = BasketModel.Total().ToString(),
                        Breakdown    = new AmountBreakdown
                        {
                            ItemTotal = new Money
                            {
                                CurrencyCode = "AED",
                                Value        = BasketModel.Total().ToString(),
                            }
                        },
                    },
                    Payee = new OrderRequestPurchaseUnitPayee {
                        BillerId = empaySettings.BillerId
                    },
                };

                foreach (var item in BasketModel.Items)
                {
                    purchaseUnit.Items.Add(new OrderRequestPurchaseUnitItem
                    {
                        Name       = item.ProductName,
                        UnitAmount = new Money
                        {
                            CurrencyCode = "AED",
                            Value        = item.UnitPrice.ToString()
                        },
                        Quantity = item.Quantity
                    });
                }

                orderRequest.PurchaseUnits.Add(purchaseUnit);

                var orderService = new Emcredit.Empay.OrdersService();

                var result = await orderService.CreateOrderAsync(new CreateOrderInput
                {
                    Request       = orderRequest,
                    EmpaySettings = empaySettings
                }).ConfigureAwait(false);

                return(Ok(result));
            }
            catch (Exception ex)
            {
                // TODO: Handle create order error
                throw;
            }
        }
Пример #6
0
 /// <summary>
 /// Gets only the orders from the response object
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public async Task <IEnumerable <Order> > GetAllAsync(OrderRequest request = null)
 {
     return((await GetResponseAsync(request).ConfigureAwait(false))?.Orders);
 }
Пример #7
0
 /// <summary>
 /// Helper method to create an error response due to a bad order id
 /// </summary>
 public static OrderResponse UnableToFindOrder(OrderRequest request)
 {
     return(Error(request, OrderResponseErrorCode.UnableToFindOrder,
                  string.Format("Unable to locate order with id {0}.", request.OrderId)));
 }
Пример #8
0
        public void PlaceOrder_ShouldFailIfUserNotLogged()
        {
            var productIdQuantityDictionary = new Dictionary<int, int>();
            productIdQuantityDictionary.Add(1, 0);
            productIdQuantityDictionary.Add(2, 0);
            var request = new OrderRequest()
            {
                ProductIdQuantityDictionary = productIdQuantityDictionary
            };

            var response = _aptekaNetServiceClient.PlaceOrder(request);

            Assert.IsFalse(response.Success);
        }
Пример #9
0
 /// <summary>
 /// Helper method to create an error response due to a zero order quantity
 /// </summary>
 public static OrderResponse ZeroQuantity(OrderRequest request)
 {
     const string format = "Unable to {0} order to have zero quantity.";
     return Error(request, OrderResponseErrorCode.OrderQuantityZero, string.Format(format, request.OrderRequestType.ToString().ToLower()));
 }
Пример #10
0
        public void PlaceOrder_ShouldFailIfTooBigQuantityDefined()
        {
            var loginRequest = new LoginRequest()
            {
                Login = "******",
                Password = "******"
            };
            var loginResponse = _aptekaNetServiceClient.Login(loginRequest);
            Assert.IsTrue(loginResponse.Success);

            var productIdQuantityDictionary = new Dictionary<int, int>();
            productIdQuantityDictionary.Add(1, int.MaxValue);
            var request = new OrderRequest()
            {
                ProductIdQuantityDictionary = productIdQuantityDictionary
            };

            var response = _aptekaNetServiceClient.PlaceOrder(request);

            Assert.IsFalse(response.Success);
        }
Пример #11
0
            public async Task <AllowContractorToChatByClientVm> Handle(AllowContractorToChatByClientCommand request, CancellationToken cancellationToken)
            {
                User currentUser = await _context.User
                                   .Where(x => x.UserGuid == Guid.Parse(_currentUser.NameIdentifier) && !x.IsDelete)
                                   .SingleOrDefaultAsync(cancellationToken);

                if (currentUser == null)
                {
                    return(new AllowContractorToChatByClientVm()
                    {
                        Message = "کاربر مورد نظر یافت نشد",
                        State = (int)AllowOrderRequestState.UserNotFound
                    });
                }

                Client client = await _context.Client
                                .SingleOrDefaultAsync(x => x.UserId == currentUser.UserId, cancellationToken);

                if (client == null)
                {
                    return new AllowContractorToChatByClientVm
                           {
                               Message = "سرویس گیرنده مورد نظر یافت نشد",
                               State   = (int)AllowOrderRequestState.ClientNotFound
                           }
                }
                ;

                OrderRequest orderRequest = await _context.OrderRequest
                                            .Include(x => x.Order)
                                            .SingleOrDefaultAsync(x => x.OrderRequestGuid == request.OrderRequestGuid && !x.IsDelete, cancellationToken);

                if (orderRequest == null)
                {
                    return new AllowContractorToChatByClientVm
                           {
                               Message = "درخواست سفارش مورد نظر یافت نشد",
                               State   = (int)AllowOrderRequestState.OrderRequestNotFound
                           }
                }
                ;

                switch (orderRequest.Order.StateCodeId)
                {
                case 10:
                    return(new AllowContractorToChatByClientVm
                    {
                        Message = "سفارش مورد نظر قبول شده است",
                        State = (int)AllowOrderRequestState.OrderRequestAcceptedBefore
                    });

                case 11:
                    return(new AllowContractorToChatByClientVm
                    {
                        Message = "سفارش مورد نظر به اتمام رسیده است",
                        State = (int)AllowOrderRequestState.OrderDoneBefore
                    });

                case 12:
                    return(new AllowContractorToChatByClientVm
                    {
                        Message = "سفارش مورد نظر لغو شده است",
                        State = (int)AllowOrderRequestState.OrderCancelledBefore
                    });
                }

                if (orderRequest.IsAllow)
                {
                    return new AllowContractorToChatByClientVm
                           {
                               Message = "سفارش مورد نظر قبلا تایید شده است",
                               State   = (int)AllowOrderRequestState.OrderRequestAllowedBefore
                           }
                }
                ;

                orderRequest.IsAllow      = true;
                orderRequest.ModifiedDate = DateTime.Now;

                await _context.SaveChangesAsync(cancellationToken);

                return(new AllowContractorToChatByClientVm
                {
                    Message = "عملیات موفق آمیز",
                    State = (int)AllowOrderRequestState.Success
                });
            }
        }
    }
}
Пример #12
0
 /// <summary>
 /// 获取订单信息,用作显示
 /// </summary>
 public OrderResponse GetOrderShow(OrderRequest request)
 {
     return(ApiRequestHelper.Post <OrderRequest, OrderResponse>(request));
 }
Пример #13
0
 public void AddOrderRequest(OrderRequest order)
 {
     _context.OrderRequests.InsertOne(order);
 }
Пример #14
0
 private void AddOrderRequest(OrderRequest orderRequest)
 {
     _orderRequestRepository.AddOrderRequest(orderRequest);
 }
Пример #15
0
 /// <summary>
 /// Constructor to initialize order request
 /// </summary>
 /// <param name="orderRequest">Input OrderRequest object</param>
 public ShoppingCalculation(OrderRequest orderRequest)
 {
     OrderRequest = orderRequest;
 }
        public async Task <IEnumerable <OrderResponse> > GetOrderByAsync(OrderRequest orderRequest, string userId)
        {
            var order = await _orderRepository.GetAsync(p => p.UserId == userId);

            return(_mapper.Map <IEnumerable <OrderResponse> >(order));
        }
        private Order CreateOrder(OrderRequest orderRequest, string userId)
        {
            var order = new Order(Guid.NewGuid().ToString(), userId);

            return(order);
        }
        //public int CountTotalOrdersOneDay(DateTime dateTime)
        //{
        //    IOrderService orderService = DependencyUtils.Resolve<IOrderService>();
        //    int count =  orderService.CountTotalOrderInOneDay(dateTime);
        //    return count;
        //}

        public BaseResponse <List <OrderHistoryAPIViewModel> > GetOrderHistoryByRequest(OrderRequest <string> request)
        {
            var ser = this.Service <IOrderService>();

            var list = ser.GetOrderHistoryByRequest(request);

            if (list.Count <= 0)
            {
                throw ApiException.Get(true, ConstantManager.MES_ORDER_HISTORY_NOTFOUND, ResultEnum.OrderHistoryNotFound, HttpStatusCode.OK);
            }
            return(BaseResponse <List <OrderHistoryAPIViewModel> > .Get(true, ConstantManager.MES_SUCCESS, list, ResultEnum.Success));
        }
Пример #19
0
        public async Task <ActionResult> Order([FromBody] OrderRequest model)
        {
            await _notesService.UpdateOrderAsync(model.TargetId, model.ReplaceId, model.Up);

            return(Ok());
        }
Пример #20
0
 /// <summary>
 /// Helper method to create a successful response from a request
 /// </summary>
 public static OrderResponse Success(OrderRequest request)
 {
     return new OrderResponse(request.OrderId, OrderResponseErrorCode.None, null);
 }
Пример #21
0
 public static decimal ComputeFee(OrderRequest order)
 {
     return(0);
 }
        static void Main()
        {
            // Create a new TransferGuard Service Client.
            var client = new TransferServiceClient();

            // Add the client certificate (where the subject is equal to SiteId) from the current user's personal certificate store.  The client certificate must be manually imported into the certificate store.
            if (client.ClientCredentials != null)
                client.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName, SiteId);

            // Get the current version of the TransferGuard Service
            var version = client.GetVersion();
            Console.WriteLine("Using TransferGuard Service Version: {0}\n", version);

            // Create an order.
            Console.WriteLine("Preparing to place order...\n");
            var orderRequest = new OrderRequest
                                   {
                                       HL7Message = @"<ORM_O01><MSH><MSH.1>|</MSH.1><MSH.2>^~\&amp;</MSH.2><MSH.3><HD.1>SENDING_APPLICATION</HD.1></MSH.3><MSH.4><HD.1>SENDING_FACILITY</HD.1></MSH.4><MSH.5><HD.1>PAML</HD.1></MSH.5><MSH.6><HD.1>PAML</HD.1></MSH.6><MSH.7><TS.1>20121204105753.865-0800</TS.1></MSH.7><MSH.9><MSG.1>ORM</MSG.1><MSG.2>O01</MSG.2><MSG.3>ORM_O01</MSG.3></MSH.9><MSH.10>1</MSH.10><MSH.11><PT.1>T</PT.1></MSH.11><MSH.12><VID.1>2.5.1</VID.1></MSH.12></MSH></ORM_O01>",
                                       SiteID = SiteId
                                   };

            // Place an order.
            var orderResponse = client.PlaceOrder(orderRequest);

            // Get the order message ID for tracking purposes.
            Console.WriteLine("Order successfully placed. You can use Message ID {0} to track the message.\n", orderResponse.MessageID);

            // Check if there are any results waiting.
            Console.WriteLine("Checking for pending results...\n");
            var resultRequest = new ResultRequest
                                    {
                                        SiteID = SiteId
                                    };

            var resultCount = client.GetPendingResultCount(resultRequest);
            Console.WriteLine("There are {0} result(s) waiting to be retieved.\n", resultCount);

            // If there are pending results, retrieve them
            if (resultCount > 0)
            {
                // Retrieve results.
                Console.WriteLine("Retrieving results...\n");
                var results = client.GetResults(resultRequest);

                var xmlResults = new XmlDocument();
                var ns = new XmlNamespaceManager(xmlResults.NameTable);
                ns.AddNamespace("v2xml", "urn:hl7-org:v2xml");

                int index = 0;
                foreach (Result result in results.Results)
                {
                    xmlResults.LoadXml(result.HL7Message);
                    XmlNode node = xmlResults.SelectSingleNode("//v2xml:ORU_R01/v2xml:MSH/v2xml:MSH.8", ns);
                    Console.WriteLine("Result Message {0}   ID: {1}", index, node.InnerXml);
                    index++;
                }
            }

            Console.WriteLine("\nPress enter to continue...");
            Console.ReadLine();
        }
        public ActionResult OrderRequestDestroy([DataSourceRequest] DataSourceRequest request, OrderRequest OrderRequest)
        {
            BL.OrderRequests blOrderRequests = new BL.OrderRequests();
            OrderRequest     model           = blOrderRequests.SoftDelete(OrderRequest);

            return(Json(new[] { model }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet));
        }
Пример #24
0
 /// <summary>
 /// Helper method to create an error response due to an invalid order status
 /// </summary>
 public static OrderResponse InvalidStatus(OrderRequest request, Order order)
 {
     return(Error(request, OrderResponseErrorCode.InvalidOrderStatus,
                  string.Format("Unable to update order with id {0} because it already has {1} status", request.OrderId, order.Status)));
 }
Пример #25
0
        public void Orders_CreateEinvoiceOrder()
        {
            // Arrange
            var url     = ConfigurationManager.AppSettings["MultiSafepayAPI"];
            var apiKey  = ConfigurationManager.AppSettings["MultiSafepayAPIKey"];
            var client  = new MultiSafepayClient(apiKey, url);
            var orderId = Guid.NewGuid().ToString();

            var orderRequest = OrderRequest.CreateDirectEinvoiceOrder(orderId, "product description", 12100, "EUR",
                                                                      new PaymentOptions("http://example.com/notify", "http://example.com/success", "http://example.com/failed"),
                                                                      GatewayInfo.PayAfterDelivery(new DateTime(1986, 08, 31), "NL39 RABO 0300 0652 64", "+31 (0)20 8500 500", "*****@*****.**", "referrer", "useragent"),
                                                                      new ShoppingCart
            {
                Items = new[]
                {
                    new ShoppingCartItem("Test Product", 100.0, 1, "EUR")
                }
            },
                                                                      new CheckoutOptions()
            {
                TaxTables = new TaxTables()
                {
                    DefaultTaxTable = new TaxTable()
                    {
                        Name  = "Default",
                        Rules = new[] { new TaxRateRule()
                                        {
                                            Rate = 0.21
                                        } },
                        ShippingTaxed = false
                    }
                }
            },
                                                                      new Customer()
            {
                FirstName   = "Testperson-nl",
                LastName    = "Approved",
                HouseNumber = "1/XI",
                Address1    = "Neherkade",
                City        = "Gravenhage",
                Country     = "NL",
                PostCode    = "2521VA",
            },
                                                                      new DeliveryAddress()
            {
                FirstName   = "Testperson-nl",
                LastName    = "Approved",
                HouseNumber = "1/XI",
                Address1    = "Neherkade",
                City        = "Gravenhage",
                Country     = "NL",
                PostCode    = "2521VA",
            }
                                                                      );

            // Act
            var result = client.CreateOrder(orderRequest);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(orderRequest.OrderId, result.OrderId);
            Assert.IsTrue(result.PaymentUrl.StartsWith("http://example.com/success?transactionid=")); // redirect to success URL
        }
Пример #26
0
 /// <summary>
 /// Helper method to create an error response due to algorithm still in warmup mode
 /// </summary>
 public static OrderResponse WarmingUp(OrderRequest request)
 {
     return(Error(request, OrderResponseErrorCode.AlgorithmWarmingUp, "Algorithm in warmup."));
 }
Пример #27
0
        public void Order_CreateRedirectPayAfterDelivery_SetsRequiredProperties()
        {
            // Act
            var order = OrderRequest.CreateRedirectPayAfterDeliveryOrder("orderid", "description", 1000, "EUR",
                                                                         new PaymentOptions("notificationUrl", "successRedirectUrl", "cancelRedirectUrl"),
                                                                         GatewayInfo.PayAfterDelivery(new DateTime(1986, 08, 31), "NL39 RABO 0300 0652 64", "+31 (0)20 8500 500", "*****@*****.**", "referrer", "useragent"),
                                                                         new ShoppingCart
            {
                Items = new[]
                {
                    new ShoppingCartItem("Test Product", 10, 2, "EUR"),
                }
            },
                                                                         new CheckoutOptions()
            {
                TaxTables = new TaxTables()
                {
                    DefaultTaxTable = new TaxTable()
                    {
                        Name  = "Default",
                        Rules = new[] { new TaxRateRule()
                                        {
                                            Rate = 0.21
                                        } },
                        ShippingTaxed = false
                    }
                }
            },
                                                                         new Customer
            {
                FirstName   = "John",
                LastName    = "Doe",
                HouseNumber = "39",
                Address1    = "Kraanspoor",
                City        = "Amsterdam",
                Country     = "NL",
                PostCode    = "1033SC"
            });

            // Assert
            Assert.IsNotNull(order.Type);
            Assert.IsNotNull(order.GatewayId);
            Assert.IsNotNull(order.OrderId);
            Assert.IsNotNull(order.CurrencyCode);
            Assert.IsNotNull(order.AmountInCents);
            Assert.IsNotNull(order.Description);
            Assert.IsNotNull(order.GatewayInfo);
            Assert.IsNotNull(order.GatewayInfo.Birthday);
            Assert.IsNotNull(order.GatewayInfo.BankAccount);
            Assert.IsNotNull(order.GatewayInfo.Phone);
            Assert.IsNotNull(order.GatewayInfo.Email);
            Assert.IsNotNull(order.GatewayInfo.Referrer);
            Assert.IsNotNull(order.GatewayInfo.UserAgent);
            Assert.IsNotNull(order.PaymentOptions);
            Assert.IsNotNull(order.PaymentOptions.NotificationUrl);
            Assert.IsNotNull(order.PaymentOptions.SuccessRedirectUrl);
            Assert.IsNotNull(order.PaymentOptions.CancelRedirectUrl);
            Assert.IsNotNull(order.ShoppingCart);
            Assert.IsNotNull(order.ShoppingCart.Items);
            Assert.IsNotNull(order.ShoppingCart.Items[0]);
            Assert.IsNotNull(order.ShoppingCart.Items[0].Name);
            Assert.IsNotNull(order.ShoppingCart.Items[0].UnitPrice);
            Assert.IsNotNull(order.ShoppingCart.Items[0].Quantity);
            Assert.IsNotNull(order.Customer);
            Assert.IsNotNull(order.Customer.FirstName);
            Assert.IsNotNull(order.Customer.LastName);
            Assert.IsNotNull(order.Customer.Address1);
            Assert.IsNotNull(order.Customer.HouseNumber);
            Assert.IsNotNull(order.Customer.City);
            Assert.IsNotNull(order.Customer.Country);


            Assert.AreEqual(OrderType.Redirect, order.Type);
            Assert.AreEqual("PAYAFTER", order.GatewayId);
            Assert.AreEqual("orderid", order.OrderId);
            Assert.AreEqual("EUR", order.CurrencyCode);
            Assert.AreEqual(1000, order.AmountInCents);
            Assert.AreEqual("description", order.Description);
            Assert.AreEqual(new DateTime(1986, 8, 31), order.GatewayInfo.Birthday);
            Assert.AreEqual("NL39 RABO 0300 0652 64", order.GatewayInfo.BankAccount);
            Assert.AreEqual("+31 (0)20 8500 500", order.GatewayInfo.Phone);
            Assert.AreEqual("*****@*****.**", order.GatewayInfo.Email);
            Assert.AreEqual("referrer", order.GatewayInfo.Referrer);
            Assert.AreEqual("useragent", order.GatewayInfo.UserAgent);
            Assert.AreEqual("notificationUrl", order.PaymentOptions.NotificationUrl);
            Assert.AreEqual("successRedirectUrl", order.PaymentOptions.SuccessRedirectUrl);
            Assert.AreEqual("cancelRedirectUrl", order.PaymentOptions.CancelRedirectUrl);
            Assert.AreEqual("Test Product", order.ShoppingCart.Items[0].Name);
            Assert.AreEqual(10, order.ShoppingCart.Items[0].UnitPrice);
            Assert.AreEqual(2, order.ShoppingCart.Items[0].Quantity);
            Assert.AreEqual("John", order.Customer.FirstName);
            Assert.AreEqual("Doe", order.Customer.LastName);
            Assert.AreEqual("Kraanspoor", order.Customer.Address1);
            Assert.AreEqual("39", order.Customer.HouseNumber);
            Assert.AreEqual("Amsterdam", order.Customer.City);
            Assert.AreEqual("NL", order.Customer.Country);
        }
 public OrderEntity(OrderRequest order)
 {
     ParkingLotName = order.ParkingLotName;
     PlateNumber    = order.PlateNumber;
     CreationTime   = DateTime.Now;
 }
Пример #29
0
 /// <summary>
 /// Helper method to create an error response due to algorithm still in warmup mode
 /// </summary>
 public static OrderResponse WarmingUp(OrderRequest request)
 {
     return Error(request, OrderResponseErrorCode.AlgorithmWarmingUp, "Algorithm in warmup.");
 }
Пример #30
0
        public void DownloadOrders()
        {
            count = 0;
            string token  = yzService.QueryToken();
            int    pageNo = 1;

            if (token != null)
            {
                bool flag = true;
                while (flag)
                {
                    OrderRequest or = new OrderRequest()
                    {
                        start_created = DateTime.Now.AddMonths(-1),
                        end_created   = DateTime.Now,
                        page_no       = pageNo,
                        page_size     = 100,
                        status        = "WAIT_SELLER_SEND_GOODS"
                    };
                    OrderResponse orders = yzService.GetOrder(or, token);
                    if (orders != null)
                    {
                        if (orders.response.total_results == 0)
                        {
                            break;
                        }

                        if (orders.response.total_results > 0 && orders.response.total_results <= 100)
                        {
                            if (orders.response.total_results == 100)
                            {
                                pageNo++;
                            }
                            else
                            {
                                //100条内 循环完退出
                                flag = false;
                            }
                            foreach (var order in orders.response.full_order_info_list)
                            {
                                if (orderService.QueryOrderIsExit(order.full_order_info.order_info.tid))
                                {
                                    continue;
                                }

                                if (order.full_order_info.order_info.status_str == "待发货")
                                {
                                    string orderIds = yzService.AddOrder(order);
                                    if (!string.IsNullOrEmpty(orderIds))
                                    {
                                        List <string> listorderId = orderIds.Split(',').ToList();
                                        List <string> listOrderId = new List <string>();
                                        foreach (var orderId in listorderId)
                                        {
                                            if (!string.IsNullOrEmpty(orderId))
                                            {
                                                //快递中间表没数据
                                                if (!expService.IsExit(orderId))
                                                {
                                                    listOrderId.Add(orderId);
                                                }
                                            }
                                        }
                                        if (listOrderId.Count == 0)
                                        {
                                            continue;
                                        }
                                        //更新订单来源为有赞
                                        orderService.UpdateOrderSourceTypeID(listOrderId, "030");
                                        if (listOrderId.Count == 1)
                                        {
                                            expService.InsertExpressage(listOrderId[0], " ");
                                            count++;
                                        }
                                        else
                                        {
                                            Dictionary <string, string> dicOrder = new Dictionary <string, string>();
                                            foreach (var orderId in listOrderId)
                                            {
                                                List <OrderList> orderList = new List <OrderList>();
                                                var listItems = orderService.QueryDTOrder(orderId);
                                                foreach (var itemId in listItems)
                                                {
                                                    var ol = order.full_order_info.orders.Where(o => (o.outer_sku_id.Substring(o.outer_sku_id.LastIndexOf("|") + 1, o.outer_sku_id.Length - o.outer_sku_id.LastIndexOf("|") - 1)) == itemId).SingleOrDefault();
                                                    orderList.Add(new OrderList {
                                                        itemid = itemId, oid = ol.oid
                                                    });
                                                }

                                                dicOrder.Add(orderId, CommonHelper.ToJson(orderList));
                                            }
                                            expService.InsertExpressageAll(dicOrder);
                                            count++;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (count > 0)
            {
                log.Debug("============================有赞订单同步至ERP:" + count + "条数据同步成功==================================");
            }
        }
Пример #31
0
 /// <remarks/>
 public void CreateOrderAsync(OrderRequest request, string userName, string password) {
     this.CreateOrderAsync(request, userName, password, null);
 }
Пример #32
0
 public async Task <IActionResult> CreateOrder([FromBody] OrderRequest request)
 {
     return(Ok());
 }
Пример #33
0
 /// <summary>
 /// Helper method to create an error response from a request
 /// </summary>
 public static OrderResponse Error(OrderRequest request, OrderResponseErrorCode errorCode, string errorMessage)
 {
     return new OrderResponse(request.OrderId, errorCode, errorMessage);
 }
Пример #34
0
        public void Order_CreateFastCheckout_SetsRequiredProperties()
        {
            // Act
            var order = OrderRequest.CreateFastCheckoutOrder("orderid", "description", 1000, "EUR",
                                                             new PaymentOptions("notificationUrl", "successRedirectUrl", "cancelRedirectUrl"),
                                                             new ShoppingCart
            {
                Items = new[]
                {
                    new ShoppingCartItem("Test Product", 10, 2, "EUR"),
                }
            },
                                                             new CheckoutOptions()
            {
                ShippingMethods = new ShippingMethods()
                {
                    FlatRateShippingMethods = new []
                    {
                        new ShippingMethod("flatrate", 10, "EUR"),
                    },
                    Pickup = new ShippingMethod("pickup", 10, "EUR")
                },
            });

            // Assert
            Assert.IsNotNull(order.Type);
            Assert.IsNull(order.GatewayId);
            Assert.IsNotNull(order.OrderId);
            Assert.IsNotNull(order.CurrencyCode);
            Assert.IsNotNull(order.AmountInCents);
            Assert.IsNotNull(order.Description);
            Assert.IsNull(order.GatewayInfo);
            Assert.IsNotNull(order.PaymentOptions);
            Assert.IsNotNull(order.PaymentOptions.NotificationUrl);
            Assert.IsNotNull(order.PaymentOptions.SuccessRedirectUrl);
            Assert.IsNotNull(order.PaymentOptions.CancelRedirectUrl);
            Assert.IsNotNull(order.ShoppingCart);
            Assert.IsNotNull(order.ShoppingCart.Items);
            Assert.IsNotNull(order.ShoppingCart.Items[0]);
            Assert.IsNotNull(order.ShoppingCart.Items[0].Name);
            Assert.IsNotNull(order.ShoppingCart.Items[0].UnitPrice);
            Assert.IsNotNull(order.ShoppingCart.Items[0].Quantity);
            Assert.IsNotNull(order.CheckoutOptions);
            Assert.IsNotNull(order.CheckoutOptions.ShippingMethods);
            Assert.IsNotNull(order.CheckoutOptions.ShippingMethods.FlatRateShippingMethods);
            Assert.IsNotNull(order.CheckoutOptions.ShippingMethods.Pickup);


            Assert.AreEqual(OrderType.FastCheckout, order.Type);
            Assert.AreEqual("orderid", order.OrderId);
            Assert.AreEqual("EUR", order.CurrencyCode);
            Assert.AreEqual(1000, order.AmountInCents);
            Assert.AreEqual("description", order.Description);
            Assert.AreEqual("notificationUrl", order.PaymentOptions.NotificationUrl);
            Assert.AreEqual("successRedirectUrl", order.PaymentOptions.SuccessRedirectUrl);
            Assert.AreEqual("cancelRedirectUrl", order.PaymentOptions.CancelRedirectUrl);
            Assert.AreEqual("Test Product", order.ShoppingCart.Items[0].Name);
            Assert.AreEqual(10, order.ShoppingCart.Items[0].UnitPrice);
            Assert.AreEqual(2, order.ShoppingCart.Items[0].Quantity);
            Assert.AreEqual("flatrate", order.CheckoutOptions.ShippingMethods.FlatRateShippingMethods[0].Name);
            Assert.AreEqual(10, order.CheckoutOptions.ShippingMethods.FlatRateShippingMethods[0].Price);
            Assert.AreEqual("EUR", order.CheckoutOptions.ShippingMethods.FlatRateShippingMethods[0].CurrencyCode);
            Assert.AreEqual("pickup", order.CheckoutOptions.ShippingMethods.Pickup.Name);
            Assert.AreEqual(10, order.CheckoutOptions.ShippingMethods.Pickup.Price);
            Assert.AreEqual("EUR", order.CheckoutOptions.ShippingMethods.Pickup.CurrencyCode);
        }
Пример #35
0
        /// <summary>
        /// Create a simple redirect order
        /// </summary>
        /// <param name="orderRequest">OrderRequest object populated with the order details</param>
        /// <returns>The payment link to redirect the customer too</returns>
        public PaymentLink CreateOrder(OrderRequest orderRequest)
        {
            var response = DoRequest <PaymentLink>(_urlProvider.OrdersUrl(), orderRequest);

            return(response.Data);
        }
Пример #36
0
 public OrderRequest CreateOrder(OrderRequest request, string userName, string password) {
     object[] results = this.Invoke("CreateOrder", new object[] {
                 request,
                 userName,
                 password});
     return ((OrderRequest)(results[0]));
 }
Пример #37
0
 public OrderTicket Process(OrderRequest request)
 {
     throw new NotImplementedException();
 }
Пример #38
0
 /// <remarks/>
 public void CreateOrderAsync(OrderRequest request, string userName, string password, object userState) {
     if ((this.CreateOrderOperationCompleted == null)) {
         this.CreateOrderOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreateOrderOperationCompleted);
     }
     this.InvokeAsync("CreateOrder", new object[] {
                 request,
                 userName,
                 password}, this.CreateOrderOperationCompleted, userState);
 }
Пример #39
0
        /// <summary>
        /// Helper method to create an error response due to a zero order quantity
        /// </summary>
        public static OrderResponse ZeroQuantity(OrderRequest request)
        {
            const string format = "Unable to {0} order to have zero quantity.";

            return(Error(request, OrderResponseErrorCode.OrderQuantityZero, string.Format(format, request.OrderRequestType.ToString().ToLower())));
        }
Пример #40
0
 /// <summary>
 /// Helper method to create an error response due to an invalid order status
 /// </summary>
 public static OrderResponse InvalidStatus(OrderRequest request, Order order)
 {
     return Error(request, OrderResponseErrorCode.InvalidOrderStatus,
         string.Format("Unable to update order with id {0} because it already has {1} status", request.OrderId, order.Status));
 }
        public void Orders_CreateRedirectWithTemplate()
        {
            // Arrange
            var url     = ConfigurationManager.AppSettings["MultiSafepayAPI"];
            var apiKey  = ConfigurationManager.AppSettings["MultiSafepayAPIKey"];
            var client  = new MultiSafepayClient(apiKey, url);
            var orderId = Guid.NewGuid().ToString();

            //Template Id provided in MSP merchants panel
            var templateId = "template-id";

            var orderRequest = OrderRequest.CreateRedirectWithTemplate(orderId, "product description", 1000, "EUR",
                                                                       new PaymentOptions("http://example.com/notify", "http://example.com/success", "http://example.com/failed"),
                                                                       templateId,
                                                                       new Template()
            {
                Version = "1.0",    //Required
                Header  = new TemplateHeader()
                {
                    Background = "#dedede",
                    Text       = "#333333",
                    Logo       = new TemplateHeaderObject()
                    {
                        Image = "https://via.placeholder.com/150x150"
                    }
                },
                Body = new TemplateBody()
                {
                    Text       = "#333333",
                    Background = "#cccccc",
                    Link       = new TemplateButtonObject()
                    {
                        Text = "#00acf1"
                    }
                },
                Container = new TemplateContainer()
                {
                    Text       = "#626161",
                    Label      = "#a4a3a3",
                    Background = "#ffffff"
                },
                Cart = new TemplateCart()
                {
                    Text       = "#333333",
                    Label      = "#8b8b8b",
                    Background = "#ffffff",
                    Border     = "#d7d7d7"
                },
                PaymentForm = new TemplatePaymentForm()
                {
                    Background = "#ffffff",
                    Border     = "#d7d7d7",
                    Inputs     = new TemplateInputObject()
                    {
                        Border = "#d7d7d7",
                        Label  = "#38839e"
                    }
                },
                Buttons = new TemplateButtons()
                {
                    PaymentMethod = new TemplateButtonObject()
                    {
                        Background = "#ffffff",
                        Text       = "#38839e",
                        Border     = "#d7d7d7",
                        Hover      = new TemplateButtonObjectState()
                        {
                            Background = "#cccccc"
                        }
                    },
                    Primary = new TemplateButtonObject()
                    {
                        Background = "#cc0000",
                        Text       = "#ffffff"
                    },
                    Secondary = new TemplateButtonObject()
                    {
                        Background = "#38839e",
                        Text       = "#ffffff"
                    }
                }
            });

            // Act
            var result = client.CreateOrder(orderRequest);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(orderRequest.OrderId, result.OrderId);
            Assert.IsFalse(String.IsNullOrEmpty(result.PaymentUrl));
        }
Пример #42
0
 /// <summary>
 /// Helper method to create an error response due to a bad order id
 /// </summary>
 public static OrderResponse UnableToFindOrder(OrderRequest request)
 {
     return Error(request, OrderResponseErrorCode.UnableToFindOrder,
         string.Format("Unable to locate order with id {0}.", request.OrderId));
 }
Пример #43
0
 public PlaceNewOrderCommand(OrderRequest order)
 {
     this.Order = order;
 }
Пример #44
0
        private static void PlaceOrder()
        {
            try
            {
                Console.WriteLine("Lista aptek:");
                Console.WriteLine();
                var request = new QueryRequestOfPharmacyQueryVmy3cGwc()
                    {
                        Query = new PharmacyQuery()
                    };
                var pharmacies = client.GetMatchingPharmacies(request).Data;

                foreach (var p in pharmacies)
                {
                    Console.WriteLine("ID: " + p.ID);
                    Console.WriteLine("Nazwa: " + p.Name);
                    Console.WriteLine("Adres: " + p.Address);
                    Console.WriteLine("Telefon: " + p.Phone);
                    Console.WriteLine("Opis: " + p.Description);
                }
                Console.WriteLine();

                Console.Write("Podaj id apteki: ");
                int pharmacyId = int.Parse(Console.ReadLine());
                var pharmacy = GetPharmacyById(pharmacyId);
                if (pharmacy == null)
                {
                    Console.WriteLine("Nie ma takiej apteki");
                    return;
                }
                Console.WriteLine("Produkty w tej aptece: ");
                var productIdQuantityDictionary = new Dictionary<int, int>();
                var productsInPharmacy = GetProducstByPharmacyId(pharmacyId);

                Console.WriteLine();
                foreach (var product in productsInPharmacy)
                {
                    var medicine = GetMedicineById(product.MedicineId);
                    Console.WriteLine("Id produktu: {0}", product.ProductId);
                    Console.WriteLine("Id apteki: {0}", product.PharmacyId);
                    Console.WriteLine("Nazwa: {0}", medicine.CommercialName);
                    Console.WriteLine("Ilość w magazynie: {0}", product.OnStock);
                    Console.WriteLine("Cena: {0}", product.Price);
                    Console.WriteLine();
                }

                Console.WriteLine("Wybierz produkty:");
                for (int i = 0; i < productsInPharmacy.Count(); i++)
                {
                    Console.Write("Podaj id produktu (0 - zakoncz zamowienie):");
                    int id = int.Parse(Console.ReadLine());
                    if (id == 0)
                        break;

                    Console.Write("Podaj ilość: ");
                    int q = int.Parse(Console.ReadLine());
                    productIdQuantityDictionary.Add(id, q);

                }
                var orderRequest = new OrderRequest()
                    {
                        ProductIdQuantityDictionary = productIdQuantityDictionary
                    };
                var response = client.PlaceOrder(orderRequest);
                Console.WriteLine(response.Message);
            }
            catch (Exception)
            {
                Console.WriteLine("Error");
                throw;
            }
        }
Пример #45
0
 /// <summary>
 /// Helper method to create a successful response from a request
 /// </summary>
 public static OrderResponse Success(OrderRequest request)
 {
     return(new OrderResponse(request.OrderId, OrderResponseErrorCode.None, null));
 }
Пример #46
0
        /// <summary>
        /// Gets a list of orders for a given customer.
        /// </summary>
        /// <param name="customerId">Unique customer identifier.</param>
        /// <returns>List of orders.</returns>
        public IList<OrderModel> GetOrders(int customerId)
        {
            OrderRequest request = new OrderRequest();
            request.RequestId = NewRequestId;
            request.AccessToken = AccessToken;
            request.ClientTag = ClientTag;

            request.LoadOptions = new string[] { "Orders", "OrderDetails", "Product" };
            request.Criteria = new OrderCriteria { CustomerId = customerId, SortExpression = "OrderId ASC" };

            OrderResponse response = null;
            SafeProxy.DoAction<ActionServiceClient>(Service, client =>
                { response = client.GetOrders(request); });

            if (request.RequestId != response.CorrelationId)
                throw new ApplicationException("GetOrders: RequestId and CorrelationId do not match.");

            if (response.Acknowledge != AcknowledgeType.Success)
                throw new ApplicationException(response.Message);

            return Mapper.FromDataTransferObjects(response.Orders);
        }
Пример #47
0
 /// <summary>
 /// Helper method to create an error response from a request
 /// </summary>
 public static OrderResponse Error(OrderRequest request, OrderResponseErrorCode errorCode, string errorMessage)
 {
     return(new OrderResponse(request.OrderId, errorCode, errorMessage));
 }