Beispiel #1
0
        public async Task <JsonResult> CancelAudit(string id)
        {
            var manager       = new ShipmentManager(User);
            var shipmentOrder = await manager.GetShipmentOrderAsync(id);

            if (shipmentOrder == null)
            {
                return(Json(false, "出货单不存在"));
            }

            if (shipmentOrder.AuditStatus != ShipmentOrderAduitStatus.Pass)
            {
                return(Json(false, "出货单不是已审核状态"));
            }

            shipmentOrder.AuditStatus = ShipmentOrderAduitStatus.New;
            shipmentOrder.AuditorName = User.Name;
            shipmentOrder.AuditDate   = DateTime.Now;
            var result = await manager.AuditShipmentOrder(shipmentOrder);

            if (result.Succeeded)
            {
                var orderIds = shipmentOrder.ShipmentOrderInfos.Select(r => r.Id);
                await new OrderManager(User).UpdateOrderStatusAsync(OrderStatus.Shipmenting, orderIds);
                await new OrderOperationLogManager(User).AddLogAsync(OrderStatus.Shipmenting, orderIds);

                await new ReconciliationManager(User).DeleteReconciliationAsync(shipmentOrder.Id);
            }
            return(Json(result));
        }
Beispiel #2
0
        public async Task <JsonResult> CreatedRecord([NamedModelBinder(typeof(CommaSeparatedModelBinder), "orderIds")] string[] orderIds)
        {
            var manager = new ShipmentManager(User);

            foreach (var id in orderIds)
            {
                var shipmentOrder = await manager.GetShipmentOrderAsync(id);

                if (shipmentOrder.AuditStatus == ShipmentOrderAduitStatus.Pass)
                {
                    return(Json(false, $"{id}出货单已经通过审核,不能再次审核"));
                }

                shipmentOrder.AuditStatus = ShipmentOrderAduitStatus.Pass;
                shipmentOrder.AuditorName = User.Name;
                shipmentOrder.AuditDate   = DateTime.Now;
                var result = await manager.AuditShipmentOrder(shipmentOrder);

                if (result.Succeeded)
                {
                    var orderInfoId = shipmentOrder.ShipmentOrderInfos.Select(r => r.Id);
                    await new OrderManager(User).UpdateOrderStatusAsync(OrderStatus.Shipment, orderInfoId);
                }
            }
            return(Json(true));
        }
Beispiel #3
0
        public async Task <JsonResult> Edit(ShipmentOrderViewModel shipmentOrderViewModel)
        {
            var shipmentOrder = new ShipmentOrder();

            var shipmentManager = new ShipmentManager(User);

            shipmentOrder = await shipmentManager.GetShipmentOrderAsync(shipmentOrderViewModel.Id);

            shipmentOrder = Mapper.Map <ShipmentOrderViewModel, ShipmentOrder>(shipmentOrderViewModel);
            shipmentOrder.ShipmentOrderInfos.Each(r => r.ShipmentOrderId = shipmentOrder.Id);

            var result = await shipmentManager.UpdateAsync(shipmentOrder);

            return(Json(result.Succeeded, "", result.Data));
        }
Beispiel #4
0
        public async Task <ActionResult> Detail(string id)
        {
            var manager       = new ShipmentManager(User);
            var shipmentOrder = await manager.GetShipmentOrderAsync(id);


            var discountRateManager = new DiscountRateManager();
            var discountRate        = await discountRateManager.GetCustomerDiscountRateAsync(shipmentOrder.CustomerId);

            var shipmentOrderViewModel = Mapper.Map <ShipmentOrder, ShipmentOrderViewModel>(shipmentOrder);

            shipmentOrderViewModel.SideStoneRate   = (double)discountRate.SideStone / 100;
            shipmentOrderViewModel.StoneSetterRate = (double)discountRate.StoneSetter / 100;

            shipmentOrderViewModel.ShipmentOrderInfos.Each(f => f.Hhz = Math.Round(f.GoldWeight * (1 + f.LossRate / 100), 2));

            shipmentOrderViewModel.TotalArrearage =
                await new ReconciliationManager(User).GetTotalSurplusArrearageAsync(shipmentOrder.CustomerId);
            return(View(shipmentOrderViewModel));
        }
Beispiel #5
0
        public async Task <ActionResult> Edit(string id)
        {
            var manager       = new ShipmentManager(User);
            var shipmentOrder = await manager.GetShipmentOrderAsync(id);

            var shipmentOrderViewModel = Mapper.Map <ShipmentOrder, ShipmentOrderViewModel>(shipmentOrder);

            var discountRateManager = new DiscountRateManager();
            var discountRate        = await discountRateManager.GetCustomerDiscountRateAsync(shipmentOrder.CustomerId);

            shipmentOrderViewModel.SideStoneRate = (double)discountRate.SideStone / 100;
            shipmentOrderViewModel.ShipmentOrderInfos.Each(f =>
            {
                f.Hhz        = Math.Round(f.GoldWeight * (1 + f.LossRate / 100), 2);
                f.GoldAmount = f.GoldPrice * f.Hhz;
                f.TotalSetStoneWorkingCost = f.OrderSetStoneInfos.Sum(r => r.SetStoneWorkingCost) * ((double)discountRate.StoneSetter / 100);
                f.SideStoneNumber          = f.OrderSetStoneInfos.Sum(r => r.Number);
                f.SideStoneTotalAmount     = f.OrderSetStoneInfos.Sum(r => r.TotalAmount) * ((double)discountRate.SideStone / 100);
                f.SideStoneWeight          = f.OrderSetStoneInfos.Sum(r => r.Weight);
            }
                                                           );
            return(View("create", shipmentOrderViewModel));
        }
Beispiel #6
0
        public async Task <JsonResult> Audit(string id)
        {
            var manager       = new ShipmentManager(User);
            var shipmentOrder = await manager.GetShipmentOrderAsync(id);

            if (shipmentOrder.AuditStatus == ShipmentOrderAduitStatus.Pass)
            {
                return(Json(false, "出货单已经通过审核,不能再次审核"));
            }

            shipmentOrder.AuditStatus = ShipmentOrderAduitStatus.Pass;
            shipmentOrder.AuditorName = User.Name;
            shipmentOrder.AuditDate   = DateTime.Now;
            var result = await manager.AuditShipmentOrder(shipmentOrder);

            if (result.Succeeded)
            {
                var orderIds = shipmentOrder.ShipmentOrderInfos.Select(r => r.Id);
                await new OrderManager(User).UpdateOrderStatusAsync(OrderStatus.Shipment, orderIds);
                await new OrderOperationLogManager(User).AddLogAsync(OrderStatus.Shipment, orderIds);
                var reconciliation = new Reconciliation
                {
                    Amount       = shipmentOrder.TotalAmount,
                    CompanyId    = User.CompanyId,
                    Created      = DateTime.Now,
                    CreatorId    = User.Id,
                    CustomerId   = shipmentOrder.CustomerId,
                    CustomerName = shipmentOrder.CustomerName,
                    Type         = ReconciliationType.Arrearage,
                    Remark       = $"{id}出货"
                };
                await new ReconciliationManager(User).CreateAsync(reconciliation);
                await SendShipmentOrderMsg(shipmentOrder);
            }
            return(Json(result));
        }