コード例 #1
0
        public ActionResult ViewInvoice(long id, int?returnType)
        {
            var SettledPodResponse = new SettledService().GetSettledPodsByInvoiceID(new GetSettledPodsByInvoiceIDRequest()
            {
                InvoiceID = id
            });

            if (!SettledPodResponse.IsSuccess)
            {
                return(Error("获取结算单失败"));
            }

            InvoiceViewModel vm = new InvoiceViewModel();

            vm.IsViewModel = true;
            vm.SettledPods = SettledPodResponse.Result;
            var InvoiceResponse = new InvoiceService().GetInvoiceByID(new GetInvoiceByIDRequest()
            {
                ID = id
            });

            if (!InvoiceResponse.IsSuccess)
            {
                return(Error("获取发票失败"));
            }
            vm.ReturnType = returnType ?? 1;
            vm.Invoice    = InvoiceResponse.Result;

            return(View("Invoice", vm));
        }
コード例 #2
0
        public ActionResult AuditSettledPod(string SettledPodIDs, DateTime AuditDate, string AuditRemark, int AuditType, bool?isManualSettled)
        {
            var settledPodIDs = SettledPodIDs.Split(',').Select(id => id.ObjectToInt64());

            if (settledPodIDs == null || !settledPodIDs.Any())
            {
                throw new Exception("数据出错");
            }


            bool           result  = false;
            SettledService service = new SettledService();

            if (AuditType == 4)
            {
                if (isManualSettled == null || !isManualSettled.Value)
                {
                    result = service.DeleteAllExtenFeeData(new DeleteAllExtenFeeDataRequest()
                    {
                        SettledPodIDCollection = settledPodIDs
                    }).IsSuccess;
                }
                else
                {
                    result = service.DeleteManualSettledFee(new DeleteManualSettledFeeRequest()
                    {
                        SettledPodIDCollection = settledPodIDs
                    }).IsSuccess;
                }
            }
            else
            {
                result = service.AuditSettledPod(new AuditSettledPodRequest()
                {
                    SettledPodIDs    = settledPodIDs,
                    Auditor          = base.UserInfo.Name,
                    AuditTime        = AuditDate,
                    AuditRemark      = AuditRemark,
                    AuditType        = AuditType,
                    AuditTypeMessage = AuditType == 1 ? "同意" : (AuditType == 2 ? "不同意" : "终审同意")
                }).IsSuccess;
            }

            if (result)
            {
                return(Json(new { IsSuccess = true }));
            }

            throw new Exception("费用审核失败");
        }
コード例 #3
0
        public ActionResult EditSettledPod(long id)
        {
            var response = new SettledService().GetSettledPodByID(new GetSettledPodByIDRequest()
            {
                ID = id
            });

            if (response.IsSuccess)
            {
                return(View(response.Result));
            }

            return(Error("程序出错"));
        }
コード例 #4
0
        public JsonResult DeleteSettledPod(long id, int settledType)
        {
            var response = new SettledService().DeleteSettledPod(new DeleteSettledPodRequest()
            {
                ID = id, SettledType = settledType
            });

            if (response.IsSuccess)
            {
                return(Json(new { Message = "删除运单结算成功", IsSuccess = true }));
            }
            else
            {
                return(Json(new { Message = "删除运单结算失败!", IsSuccess = false }));
            }
        }
コード例 #5
0
        public string ImportForBatchEditSettledPod(int type, long customer)
        {
            if (Request.Files.Count > 0)
            {
                HttpPostedFileBase hpf = Request.Files[0] as HttpPostedFileBase;
                if (hpf.ContentLength > 0)
                {
                    DataSet ds = this.GetDataFromExcel(hpf);

                    if (ds != null && ds.Tables[0] != null)
                    {
                        IEnumerable <SettledPod> settledPods = ds.Tables[0].Rows.Select((i, dr) => new SettledPod()
                        {
                            SystemNumber        = dr["系统编号"].ToString(),
                            CustomerOrderNumber = dr["客户运单号"].ToString(),
                            SettledType         = type,
                            ShipAmt             = dr["运费"].ToString() == "" ? 0 : dr["运费"].ObjectToDecimal(),
                            PointAmt            = dr["点费"].ToString() == "" ? 0 : dr["点费"].ObjectToDecimal(),
                            BAFAmt            = dr["燃油附加费"].ToString() == "" ? 0 : dr["燃油附加费"].ObjectToDecimal(),
                            OtherAmt          = dr["其他费用"].ToString() == "" ? 0 : dr["其他费用"].ObjectToDecimal(),
                            Remark            = dr["备注"].ToString(),
                            RelatedCustomerID = customer
                        });

                        var response = new SettledService().BatchUpdateSettledPodAmt(new BatchUpdateSettledPodAmtRequest()
                        {
                            SettledPods = settledPods, Updator = base.UserInfo.Name, SettleType = type
                        });

                        if (response.IsSuccess)
                        {
                            StringBuilder sb = new StringBuilder();
                            this.GenerateReturnMessage(response.Result, sb, type);
                            return(new { result = sb.ToString(), IsSuccess = true, Count = response.Result.Count() }.ToJsonString());
                        }

                        return(new { result = "<h3>费用调整失败</h3><br/>" + response.Exception.Message, IsSuccess = false }.ToJsonString());
                    }

                    return(new { result = "<h3>费用调整失败</h3><br/>excel内容有误!", IsSuccess = false }.ToJsonString());
                }

                return(new { result = "文件内容为空", IsSuccess = false }.ToJsonString());
            }

            return(new { result = "请选择文件", IsSuccess = false }.ToJsonString());
        }
コード例 #6
0
        public string EditSettledPod(long id, decimal?shipAmt, decimal?bafAmt, decimal?pointAmt, decimal?otherAmt, string remark, int?settledType)
        {
            SettledPod settledPod = new SettledPod()
            {
                ID       = id,
                ShipAmt  = shipAmt,
                BAFAmt   = bafAmt,
                PointAmt = pointAmt,
                OtherAmt = otherAmt,
                TotalAmt = (shipAmt ?? 0) + (bafAmt ?? 0) + (pointAmt ?? 0) + (otherAmt ?? 0),
                Remark   = remark
            };
            var response = new SettledService().EditSettledPod(new EditSettledPodRequest()
            {
                SettledPod = settledPod, SettledType = settledType ?? 0, Updator = base.UserInfo.Name
            });

            if (response.IsSuccess)
            {
                return("运单结算修改成功");
            }

            return("运单结算修改失败");
        }
コード例 #7
0
        public ActionResult SettledCompare(SettledCompareViewModel vm)
        {
            vm.Customers = ApplicationConfigHelper.GetProjectUserCustomers(base.UserInfo.ProjectID, base.UserInfo.ID)
                           .Select(c => new SelectListItem()
            {
                Value = c.CustomerID.ToString(), Text = c.CustomerName
            });
            vm.DisplyMessage = vm.SettledType == 0 ? "导入应收结算比对(客户运单号|运费|点费|燃油附加费|其他费用)" : "导入应付结算比对(客户运单号|运费|点费|燃油附加费|其他费用)";

            if (Request.Files.Count > 0)
            {
                HttpPostedFileBase hpf = Request.Files[0] as HttpPostedFileBase;
                if (hpf.ContentLength > 0)
                {
                    string uploadFolderPath = Runbow.TWS.Common.Constants.UPLOAD_FOLDER_PATH;
                    string targetPath       = Path.Combine(Runbow.TWS.Common.Constants.UPLOAD_FOLDER_PATH, base.UserInfo.ProjectID.ToString(), Runbow.TWS.Common.Constants.TEMPFOLDER);
                    if (!Directory.Exists(targetPath))
                    {
                        Directory.CreateDirectory(targetPath);
                    }

                    string fileName = base.UserInfo.ID.ToString() + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + Path.GetFileName(hpf.FileName);
                    string fullPath = Path.Combine(targetPath, fileName);
                    hpf.SaveAs(fullPath);
                    hpf.InputStream.Close();

                    Runbow.TWS.Common.ExcelHelper excelHelper = new Runbow.TWS.Common.ExcelHelper(fullPath);
                    DataSet ds = excelHelper.GetAllDataFromAllSheets();
                    excelHelper.Dispose();
                    MyFile.Delete(fullPath);

                    if (ds == null || ds.Tables == null || ds.Tables[0].Rows.Count == 0)
                    {
                        vm.ErrorMessage = "Excel文件内容有误";
                    }
                    else
                    {
                        IList <SettledPodCompare> settledPodCompares = new List <SettledPodCompare>();
                        StringBuilder             errorMessage       = new StringBuilder();
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            string  customerOrderNumber = string.Empty;
                            decimal excelShipAmt        = 0;
                            decimal excelBafAmt         = 0;
                            decimal excelPointAmt       = 0;
                            decimal excelOtherAmt       = 0;

                            if (ds.Tables[0].Columns.Contains("客户运单号"))
                            {
                                customerOrderNumber = ds.Tables[0].Rows[i]["客户运单号"].ToString();
                                if (string.IsNullOrEmpty(customerOrderNumber))
                                {
                                    errorMessage.Append("Excel中第").Append(i + 1).Append("行客户运单号列为空,请重新编辑Excel");
                                }
                            }
                            else
                            {
                                errorMessage.Append("Excel中无客户运单号列,请重新编辑").Append("<br />");
                            }

                            if (ds.Tables[0].Columns.Contains("运费"))
                            {
                                decimal tempShipAmt;
                                if (decimal.TryParse(ds.Tables[0].Rows[i]["运费"].ToString().Trim(), out tempShipAmt))
                                {
                                    excelShipAmt = tempShipAmt;
                                }
                            }

                            if (ds.Tables[0].Columns.Contains("点费"))
                            {
                                decimal tempPointAmt;
                                if (decimal.TryParse(ds.Tables[0].Rows[i]["点费"].ToString().Trim(), out tempPointAmt))
                                {
                                    excelPointAmt = tempPointAmt;
                                }
                            }

                            if (ds.Tables[0].Columns.Contains("燃油附加费"))
                            {
                                decimal tempBafAmt;
                                if (decimal.TryParse(ds.Tables[0].Rows[i]["燃油附加费"].ToString().Trim(), out tempBafAmt))
                                {
                                    excelBafAmt = tempBafAmt;
                                }
                            }

                            if (ds.Tables[0].Columns.Contains("其他费用"))
                            {
                                decimal tempOtherAmt;
                                if (decimal.TryParse(ds.Tables[0].Rows[i]["其他费用"].ToString().Trim(), out tempOtherAmt))
                                {
                                    excelOtherAmt = tempOtherAmt;
                                }
                            }

                            settledPodCompares.Add(new SettledPodCompare()
                            {
                                CustomerOrderNumber = customerOrderNumber,
                                CompareShipAmt      = excelShipAmt,
                                CompareBAFAmt       = excelBafAmt,
                                ComparePointAmt     = excelPointAmt,
                                CompareOtherAmt     = excelOtherAmt,
                                CompareTotalAmt     = excelShipAmt + excelBafAmt + excelPointAmt + excelOtherAmt,
                                SettledType         = vm.SettledType,
                                ProjectID           = base.UserInfo.ProjectID,
                                CustomerOrShipperID = vm.SettledType == 0 ? vm.CustomerID : vm.ShipperID,
                                RelatedCustomerID   = vm.CustomerID
                            });
                        }

                        if (errorMessage.Length > 0)
                        {
                            vm.ErrorMessage = errorMessage.ToString();
                            return(View(vm));
                        }

                        var Response = new SettledService().GetSettledPodByCondition(new GetSettledPodByConditionRequest()
                        {
                            CustomerOrderNumberCollection = settledPodCompares.Select(s => s.CustomerOrderNumber),
                            SettledType = vm.SettledType,
                            CustomerID  = vm.CustomerID,
                            ShipperID   = vm.ShipperID
                        });

                        if (Response.IsSuccess)
                        {
                            settledPodCompares.Each((i, s) => {
                                var tempSettledPod   = Response.Result.FirstOrDefault(r => r.CustomerOrderNumber == s.CustomerOrderNumber);
                                s.ActualDeliveryDate = DateTime.MinValue;
                                if (tempSettledPod != null)
                                {
                                    s.SystemNumber          = tempSettledPod.SystemNumber;
                                    s.CustomerOrShipperName = tempSettledPod.CustomerOrShipperName;
                                    s.PodID              = tempSettledPod.PodID;
                                    s.ID                 = tempSettledPod.ID;
                                    s.SettledNumber      = tempSettledPod.SettledNumber;
                                    s.StartCityID        = tempSettledPod.StartCityID;
                                    s.StartCityName      = tempSettledPod.StartCityName;
                                    s.EndCityID          = tempSettledPod.EndCityID;
                                    s.EndCityName        = tempSettledPod.EndCityName;
                                    s.ShipperTypeID      = tempSettledPod.ShipperTypeID;
                                    s.ShipperTypeName    = tempSettledPod.ShipperTypeName;
                                    s.PODTypeID          = tempSettledPod.PODTypeID;
                                    s.PODTypeName        = tempSettledPod.PODTypeName;
                                    s.TtlOrTplID         = tempSettledPod.TtlOrTplID;
                                    s.TtlOrTplName       = tempSettledPod.TtlOrTplName;
                                    s.ActualDeliveryDate = tempSettledPod.ActualDeliveryDate ?? DateTime.MinValue;
                                    s.BoxNumber          = tempSettledPod.BoxNumber;
                                    s.Weight             = tempSettledPod.Weight;
                                    s.GoodsNumber        = tempSettledPod.GoodsNumber;
                                    s.Volume             = tempSettledPod.Volume;
                                    s.Remark             = tempSettledPod.Remark;
                                    s.ShipAmt            = tempSettledPod.ShipAmt;
                                    s.BAFAmt             = tempSettledPod.BAFAmt;
                                    s.PointAmt           = tempSettledPod.PointAmt;
                                    s.OtherAmt           = tempSettledPod.OtherAmt;
                                    s.TotalAmt           = tempSettledPod.TotalAmt;
                                    s.Str1               = tempSettledPod.Str1;
                                    s.Str2               = tempSettledPod.Str2;
                                    s.Str3               = tempSettledPod.Str3;
                                    s.Str4               = tempSettledPod.Str4;
                                    s.Str5               = tempSettledPod.Str5;
                                    s.DateTime1          = tempSettledPod.DateTime1;
                                    s.DateTime2          = tempSettledPod.DateTime2;
                                    s.Creator            = tempSettledPod.Creator;
                                    s.CreateTime         = tempSettledPod.CreateTime;
                                    s.InvoiceID          = tempSettledPod.InvoiceID;
                                    s.IsAudit            = tempSettledPod.IsAudit;
                                }
                            });

                            vm.SettledPodCompareCollection = settledPodCompares;
                        }
                        else
                        {
                            vm.ErrorMessage = "获取系统结算信息失败!";
                        }
                    }
                }
                else
                {
                    vm.ErrorMessage = "Excel文件内容为空";
                }
            }
            else
            {
                vm.ErrorMessage = "请选择excel文件";
            }

            return(View(vm));
        }
コード例 #8
0
        public ActionResult SettledPodManage(SettledPodManageViewModel vm)
        {
            if (vm.SearchCondition.UserType == 2)
            {
                vm.SearchCondition.CustomerIDs = ApplicationConfigHelper.GetProjectUserCustomers(base.UserInfo.ProjectID, base.UserInfo.ID).Select(c => c.CustomerID);
            }

            if (vm.IsInvoiced == 1)
            {
                vm.SearchCondition.InvoiceID = 1;
            }

            vm.ShowActionButton   = vm.ShowActionButton && vm.IsInvoiced == 0;
            vm.ShowSelectCheckBox = vm.ShowSelectCheckBox && vm.IsInvoiced == 0;

            this.GenQuerySettledPodViewModel(vm);

            var response = new SettledService().GetSettledPodsByCondition(new GetSettledPodsByConditionRequest()
            {
                SearchCondition = vm.SearchCondition
            });

            if (response.IsSuccess && vm.IsExport)
            {
                DataTable dt = this.InitExportTable(response.Result);
                //ExcelHelper excelHelper = new ExcelHelper();
                //string targetPath = Path.Combine(Runbow.TWS.Common.Constants.UPLOAD_FOLDER_PATH, base.UserInfo.ProjectID.ToString(), "Temp");
                //string fileFullPath = Path.Combine(targetPath, "ExportSettledPods_" + base.UserInfo.Name + ".xlsx");
                //excelHelper.CreateExcelByDataTable(fileFullPath, dt);
                //excelHelper.Dispose();
                //string mimeType = "application/msexcel";
                //FileStream fs = MyFile.Open(fileFullPath, FileMode.Open);
                //return File(fs, mimeType, "ExportSettledPods.xlsx");
                return(ExportDataTableToExcel(dt, "ExportSettledPods.xls"));
            }

            if (response.IsSuccess)
            {
                vm.SettledPods = response.Result;
                if (vm.IsForAudit && vm.SettledPods != null && vm.SettledPods.Any())
                {
                    var auditResponse = new SettledService().GetSettledHistoryBySettledPodIDs(new GetSettledHistoryBySettledPodIDsRequest()
                    {
                        SettledPodIDs = response.Result.Select(i => i.ID)
                    });
                    if (auditResponse.IsSuccess)
                    {
                        vm.SettledPodAuditHistoryCollection = auditResponse.Result;
                    }
                    else
                    {
                        vm.Message = "查询有误!";
                    }
                }
            }
            else
            {
                vm.Message = "查询有误";
            }


            return(View(vm));
        }
コード例 #9
0
        public ActionResult Invoice(int Type, long CustomerOrShipperID, string IDs)
        {
            if (string.IsNullOrEmpty(IDs))
            {
                return(Error());
            }

            var SettledPodResponse = new SettledService().GetSettledPodByIDs(new GetSettledPodByIDsRequest()
            {
                IDs = IDs.Split(',').Select(id => id.ObjectToInt64())
            });

            if (!SettledPodResponse.IsSuccess)
            {
                return(Error("获取结算单失败!"));
            }

            if (SettledPodResponse.Result.Select(s => s.RelatedCustomerID).Distinct().Count() > 1)
            {
                return(Error("多家客户的运单不能同时开在一张发票中"));
            }

            InvoiceViewModel vm = new InvoiceViewModel();

            vm.IsViewModel       = false;
            vm.SettledPods       = SettledPodResponse.Result;
            vm.Invoice           = new Invoice();
            vm.Invoice.Target    = Type;
            vm.Invoice.ProjectID = base.UserInfo.ProjectID;
            var sum = SettledPodResponse.Result.Sum(s => s.TotalAmt);

            vm.Invoice.Sum = sum ?? 0;

            if (Type == 0)
            {
                var customer = ApplicationConfigHelper.GetApplicationCustomers().First(c => c.ID == CustomerOrShipperID);
                vm.Invoice.CustomerOrShipperID   = customer.ID;
                vm.Invoice.CustomerOrShipperName = customer.Name;
                vm.Invoice.TaxID             = customer.TaxID;
                vm.Invoice.Address           = customer.Address1;
                vm.Invoice.Tel               = customer.Phone1;
                vm.Invoice.Bank              = customer.Bank;
                vm.Invoice.BankAccount       = customer.Account;
                vm.Invoice.RelatedCustomerID = CustomerOrShipperID;
            }
            else
            {
                var shipper = ApplicationConfigHelper.GetApplicationShippers().First(s => s.ID == CustomerOrShipperID);
                vm.Invoice.CustomerOrShipperID   = shipper.ID;
                vm.Invoice.CustomerOrShipperName = shipper.Name;
                vm.Invoice.TaxID             = shipper.TaxID;
                vm.Invoice.Address           = shipper.Address1;
                vm.Invoice.Tel               = shipper.Phone1;
                vm.Invoice.Bank              = shipper.Bank;
                vm.Invoice.BankAccount       = shipper.Account;
                vm.Invoice.RelatedCustomerID = SettledPodResponse.Result.First().RelatedCustomerID;
            }

            vm.Invoice.SystemNumber = (Type == 0 ? "FPS" : "FPF") + DateTime.Now.ToString("yyyyMMddHHssmm");
            vm.InvoiceTypes         = ApplicationConfigHelper.GetApplicationConfigs(WebConstants.INVOICETYPE)
                                      .Select(c => new SelectListItem()
            {
                Value = c.ID.ToString(), Text = c.Name
            });

            return(View(vm));
        }