Example #1
0
        public async Task Ship(OrderShipDto dto)
        {
            var shipInfo = await _orderShipRepository.FirstOrDefaultAsync(t => t.OrderId == dto.OrderId);

            Order orderInfo = await _orderRepository.FirstOrDefaultAsync(t => t.Id == dto.OrderId);

            if (shipInfo == null && orderInfo != null && orderInfo.Status == OrderStatus.IsReading)
            {
                OrderShip orderShip = dto.MapTo <OrderShip>();
                await _orderShipRepository.InsertAsync(orderShip);


                orderInfo.Status = OrderStatus.HasShip;

                await _orderRepository.UpdateAsync(orderInfo);


                UnitOfWorkManager.Current.Completed += (sender, args) =>
                {
                    new Thread(() => EventBus.Default.Trigger(new OrderShipEventData()
                    {
                        OrderId = dto.OrderId
                    })).Start();
                };
            }
        }
Example #2
0
        public ActionResult OrderDetail(int ID)
        {
            if (Session["Member"] == null)
            {
                return(View());
            }
            if (ID == null)
            {
                return(null);
            }
            OrderShip order = _orderService.GetByID(ID);
            IEnumerable <OrderDetail> orderDetails = _orderDetailService.GetByOrderID(ID);

            if (orderDetails == null)
            {
                return(null);
            }
            ViewBag.OrderID = ID;
            if (order.isApproved.Value)
            {
                ViewBag.Approved = "Approved";
            }
            if (order.isDelivere.Value)
            {
                ViewBag.Delivere = "Delivere";
            }
            if (order.isReceived.Value)
            {
                ViewBag.Received = "Received";
            }
            ViewBag.Total = order.total;
            return(View(orderDetails));
        }
Example #3
0
        /// <summary>
        /// 获取面单信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public OrderShip GetShipOrder(long id)
        {
            OrderShip orderShip = null;

            orderShip = context.OrderShip.SingleOrDefault(x => x.Id == id);

            return(orderShip);
        }
Example #4
0
        public ActionResult OrderApproval(int ID)
        {
            OrderShip order = _orderService.Approved(ID);
            //Get email customer
            string Email = _customerService.GetEmailByID(order.customerID.Value);

            SentMail("Đơn hàng của bạn đã được duyệt", Email, "*****@*****.**", "id0ntkn0w", "Vào đơn hàng của bạn để xem thông tin chi tiết");
            return(RedirectToAction("ApprovedAndNotDelivery"));
        }
Example #5
0
        public ActionResult Delivered(int ID)
        {
            OrderShip order = _orderService.Delivered(ID);
            //Get email customer
            string Email   = _customerService.GetEmailByID(order.customerID.Value);
            string urlBase = Request.Url.GetLeftPart(UriPartial.Authority) + Url.Content("~");

            SentMail("Đơn hàng của bạn đã được giao cho đối tác vận chuyển", Email, "*****@*****.**", "id0ntkn0w", "Vào đơn hàng của bạn để xem thông tin chi tiết. Sau khi nhận được đơn hàng, bạn vui lòng click vào link sau để xác nhận đã nhận được đơn hàng từ đơn vị vận chuyển: " + urlBase + "/OrderManage/Received/" + ID + "");
            return(RedirectToAction("DeliveredList"));
        }
Example #6
0
        public JsonResult Cancel(int ID)
        {
            OrderShip order = _orderService.GetByID(ID);

            order.isCancel = true;
            _orderService.Update(order);
            return(Json(new
            {
                status = true
            }, JsonRequestBehavior.AllowGet));
        }
Example #7
0
 public ActionResult NewPdfPrint(string orderShipId)
 {
     if (!string.IsNullOrEmpty(orderShipId))
     {
         long      id        = long.Parse(orderShipId);
         OrderShip orderShip = ServiceHelper.Create <IShipmentService>().GetShipOrder(id);
         string    base64PDF = string.Empty;
         if (orderShip != null)
         {
             Response.ContentType = "application/pdf";
             Response.AddHeader("content-length", orderShip.LabelImage.Length.ToString());
             Response.BinaryWrite(orderShip.LabelImage);
         }
     }
     return(View(""));
 }
        public ActionResult AddOrder(Customer customer, int NumberDiscountPass = 0, string CodePass = "")
        {
            //Check null session cart
            if (Session["Cart"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            Customer customercheck = new Customer();
            bool     status        = false;
            //Is Customer
            Customer customerNew = new Customer();

            if (Session["Member"] == null)
            {
                //Insert customer into DB
                customerNew          = customer;
                customerNew.isMember = false;
                _customerService.AddCustomer(customerNew);
            }
            else
            {
                //Is member
                Member member = Session["Member"] as Member;
                customercheck = _customerService.GetAll().FirstOrDefault(x => x.fullName.Contains(member.fullName));
                if (customercheck != null)
                {
                    status = true;
                }
                else
                {
                    customerNew.fullName    = member.fullName;
                    customerNew.addresss    = member.addresss;
                    customerNew.email       = member.email;
                    customerNew.phoneNumber = member.phoneNumber;
                    customerNew.isMember    = true;
                    _customerService.AddCustomer(customerNew);
                }
            }
            //Add order
            OrderShip order = new OrderShip();

            if (status)
            {
                order.customerID = customercheck.id;
            }
            else
            {
                order.customerID = customerNew.id;
            }
            order.dateOrder  = DateTime.Now;
            order.dateShip   = DateTime.Now.AddDays(3);
            order.isPaid     = false;
            order.isDelete   = false;
            order.isDelivere = false;
            order.isApproved = false;
            order.isReceived = false;
            order.isCancel   = false;
            order.offer      = NumberDiscountPass;
            _orderService.AddOrder(order);
            //Add order detail
            List <Cart> listCart = GetCart();
            decimal     sumtotal = 0;

            foreach (Cart item in listCart)
            {
                OrderDetail orderDetail = new OrderDetail();
                orderDetail.orderID   = order.id;
                orderDetail.productID = item.productID;
                orderDetail.quantity  = item.quantity;
                orderDetail.price     = item.price;
                _orderDetailService.AddOrderDetail(orderDetail);
                sumtotal += orderDetail.quantity.Value * orderDetail.price.Value;
                if (Session["Member"] != null)
                {
                    //Remove Cart
                    _cartService.RemoveCart(item.productID.Value, item.memberID.Value);
                }
            }
            if (NumberDiscountPass != 0)
            {
                _orderService.UpdateTotal(order.id, sumtotal - (sumtotal / 100 * NumberDiscountPass));
            }
            else
            {
                _orderService.UpdateTotal(order.id, sumtotal);
            }
            if (CodePass != "")
            {
                //Set discountcode used
                _discountCodeDetailService.Used(CodePass);
            }
            Session["Code"] = null;
            Session["num"]  = null;
            Session["Cart"] = null;
            if (status)
            {
                SentMail("Đặt hàng thành công", customercheck.email, "*****@*****.**", "id0ntkn0w", "<p style=\"font-size:20px\">Cảm ơn bạn đã đặt hàng<br/>Mã đơn hàng của bạn là: " + order.id + "</p>");
            }
            else
            {
                SentMail("Đặt hàng thành công", customerNew.email, "*****@*****.**", "id0ntkn0w", "<p style=\"font-size:20px\">Cảm ơn bạn đã đặt hàng<br/>Mã đơn hàng của bạn là: " + order.id + "</p>");
            }
            return(RedirectToAction("Message"));
        }
Example #9
0
        /// <summary>
        /// 生成运单
        /// </summary>
        public ShipReply CreateShip(CreateShipQuery shipQuery)
        {
            ShipReply        reply       = new ShipReply();
            FedExShipService shipService = new FedExShipService(shipQuery.Url, shipQuery.Key, shipQuery.Password, shipQuery.AccountNumber, shipQuery.MeterNumber);
            List <Package>   packages    = new List <Package>();
            Package          pkg;

            foreach (ShipPackage item in shipQuery.ShipPkgs)
            {
                //pkg = GetPackage(item);
                //pkg.Currency = shipQuery.CoinType;
                //pkg.Description = item.Description;
                //pkg.PackageCount = item.Num;
                //pkg.PackageType = "自备包装";
                //packages.Add(pkg);

                if (item.Num > 0)
                {
                    for (int i = 0; i < item.Num; i++)
                    {
                        pkg              = GetPackage(item);
                        pkg.Currency     = shipQuery.CoinType;
                        pkg.Description  = item.Description;
                        pkg.PackageCount = 1;
                        pkg.PackageType  = "自备包装";
                        packages.Add(pkg);
                    }
                }
            }
            try
            {
                ShipmentEx shipEx = new ShipmentEx(shipQuery.Origin, shipQuery.Dest, packages);
                shipEx.Currency = shipQuery.CoinType;

                CreateShipRep    shipRep   = shipService.CreateShip(shipEx);
                List <ShipReply> replyList = shipRep.ReplyList;
                reply.ErrorMessage = shipRep.Message;
                if (replyList != null)
                {
                    foreach (ShipReply item in replyList)
                    {
                        OrderShip orderShip = new OrderShip()
                        {
                            OrderId = shipQuery.OrderId, OrderItemId = shipQuery.OrderItemId, TrackFormId = item.TrackFormId, TrackNumber = item.TrackNumber
                        };
                        //  orderShip.LabelImage = item.LabelImage;
                        string result = System.Text.Encoding.UTF8.GetString(item.LabelImage);
                        orderShip.LabelImage = item.LabelImage;
                        orderShip.Master     = item.Master;
                        context.OrderShip.Add(orderShip);
                    }
                    context.SaveChanges();
                    List <ShipReply> tmpShip = replyList.Where(x => x.Master == true).ToList();
                    if (tmpShip.Count > 0)
                    {
                        reply = tmpShip[0];
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
            }
            catch (Exception ex)
            {
            }

            return(reply);
        }