示例#1
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));
        }
示例#2
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));
        }
示例#3
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));
        }