Beispiel #1
0
        public ActionResult GetOrders()
        {
            var orders      = _orderService.GetOrders();
            var orderModels = OrderMapping.SerializeOrdersToViewModels(orders);

            return(Ok(orderModels));
        }
Beispiel #2
0
        public async Task UpdateOrderDetailsAsync(UserOrder userOrder, CancellationToken cancellationToken = default)
        {
            if (userOrder == null)
            {
                throw new ArgumentNullException(nameof(userOrder));
            }

            await orderDetailsRepository.UpdateAsync(OrderMapping.CreateDtoOrderDetail(userOrder.OrderDetail), cancellationToken);

            await orderRecordRepository.AddAsync(OrderMapping.CreateDtoRecord(userOrder), cancellationToken);
        }
Beispiel #3
0
        public ActionResult GenerateNewOrder([FromBody] InvoiceViewModel invoice)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            _logger.LogInformation("Generating invoice");
            var order = OrderMapping.SerializeInvoiceToOrder(invoice);

            order.Customer = _customerService.GetCustomer(invoice.CustomerId);
            _orderService.GenerateOpenOrder(order);
            return(Ok());
        }
Beispiel #4
0
        private static CartResultModel BuilderOrderResultModel(ShoppingCart shoppingCart, string errorMessage = null, string proSysNos = null, string packSysNos = null)
        {
            if (proSysNos != null || packSysNos != null)
            {
                foreach (var itemGroup in shoppingCart.ShoppingItemGroupList)
                {
                    itemGroup.PackageChecked = false;
                    foreach (ShoppingItem ProductItem in itemGroup.ShoppingItemList)
                    {
                        ProductItem.ProductChecked = false;
                    }
                }
                //checkbox单个商品购买
                if (!string.IsNullOrEmpty(proSysNos))
                {
                    string[] array = proSysNos.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var item in array)
                    {
                        int sysNo = 0;
                        if (int.TryParse(item, out sysNo))
                        {
                            foreach (var itemGroup in shoppingCart.ShoppingItemGroupList)
                            {
                                if (itemGroup.PackageType.Equals(0))
                                {
                                    if (!itemGroup.PackageChecked)
                                    {
                                        foreach (ShoppingItem ProductItem in itemGroup.ShoppingItemList)
                                        {
                                            if (ProductItem.ProductSysNo == sysNo && !ProductItem.ProductChecked)
                                            {
                                                itemGroup.PackageChecked   = true;
                                                ProductItem.ProductChecked = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                //checkbox套餐商品购买
                if (!string.IsNullOrEmpty(packSysNos))
                {
                    string[] array = packSysNos.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var item in array)
                    {
                        int sysNo = 0;
                        if (int.TryParse(item, out sysNo))
                        {
                            foreach (var itemGroup in shoppingCart.ShoppingItemGroupList)
                            {
                                if (itemGroup.PackageType.Equals(1))
                                {
                                    if (!itemGroup.PackageChecked)
                                    {
                                        if (itemGroup.PackageNo == sysNo)
                                        {
                                            itemGroup.PackageChecked = true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            ////ShoppingCart pipelineShoppingCart = shoppingCart;
            //if (shoppingCart.ShoppingItemGroupList.Count == 1)
            //{
            //    foreach (var itemGroup in shoppingCart.ShoppingItemGroupList)
            //    {
            //        foreach (ShoppingItem ProductItem in itemGroup.ShoppingItemList)
            //        {
            //            itemGroup.PackageChecked = true;
            //            ProductItem.ProductChecked = true;
            //        }
            //    }
            //}
            //if (shoppingCart.ShoppingItemGroupList.Count > 1)
            //{
            //    if (shoppingCart.ShoppingItemGroupList.FindAll(m => m.PackageChecked).Count == 0)
            //    {
            //        if (shoppingCart.ShoppingItemGroupList[0].PackageType.Equals(1))
            //        {
            //            shoppingCart.ShoppingItemGroupList[0].PackageChecked = true;
            //        }
            //        if (shoppingCart.ShoppingItemGroupList[0].PackageType.Equals(0))
            //        {
            //            foreach (ShoppingItem ProductItem in shoppingCart.ShoppingItemGroupList[0].ShoppingItemList)
            //            {
            //                shoppingCart.ShoppingItemGroupList[0].PackageChecked = true;
            //                ProductItem.ProductChecked = true;
            //            }
            //        }
            //    }
            //}
            LoginUser userInfo = UserMgr.ReadUserInfo();

            shoppingCart.CustomerSysNo = userInfo == null ? 0 : userInfo.UserSysNo;
            OrderPipelineProcessResult shoppingResult = ShoppingFacade.BuildShoppingCart(shoppingCart);
            ShoppingCart pipelineShoppingCart         = (shoppingResult.ReturnData != null &&
                                                         shoppingResult.ReturnData["ShoppingCart"] != null)
                ? shoppingResult.ReturnData["ShoppingCart"] as ShoppingCart
                : new ShoppingCart();

            shoppingCart.OrderSelectGiftSysNo = pipelineShoppingCart.OrderSelectGiftSysNo;
            shoppingCart.OrderDeleteGiftSysNo = pipelineShoppingCart.OrderDeleteGiftSysNo;

            CartResultModel model = new CartResultModel();

            model.HasSucceed    = shoppingResult.HasSucceed;
            model.ErrorMessages = shoppingResult.ErrorMessages;
            if (!string.IsNullOrEmpty(errorMessage))
            {
                model.ErrorMessages.Add(errorMessage);
            }

            OrderInfo orderInfo = shoppingResult.ReturnData;

            if (orderInfo != null)
            {
                OrderInfoModel orderInfoModel = OrderMapping.MappingOrderInfo(orderInfo, "Cart");
                if (!string.IsNullOrEmpty(orderInfo.WarmTips))
                {
                    model.ErrorMessages.Add(orderInfo.WarmTips);
                }

                model.ReturnData = orderInfoModel;
            }

            ShoppingStorageManager.SaveShoppingCart(shoppingCart);

            return(model);
        }