username@email.com
2025-03-14 4a16f96ceaac9b4cf684287cd2865fc3d2966475
CY_ECommercePlatform/CY.WebForm/Pages/business/InvoicingConfirm.aspx.cs
@@ -29,6 +29,10 @@
using CY.BLL;
using CY.WebForm.Pages.common;
using System.Transactions;
using CY.Infrastructure.Query;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System.IO;
namespace CY.WebForm.Pages.business
{
@@ -260,19 +264,123 @@
        private void Accept()
        {
            Response.Clear();
            PayAbout payAbout = new PayAbout();
            payAbout.LoadNewestPaymentAccount(true);
            double? commission = MyConvert.ConvertToDouble(CY.Config.WebInfo.Instance.FirmOrderAgencyFee);
            int? orderId = string.IsNullOrEmpty(Request["id"]) ? null : MyConvert.ConvertToInt32(Request["id"]);
            if (!orderId.HasValue || !commission.HasValue)
            var orderId = string.IsNullOrEmpty(Request["id"]) ? Guid.Empty : MyConvert.ConvertToGuid(Request["id"]);
            if ( orderId == Guid.Empty)
            {
                Response.Write("-2");
                return;
            }
           var a_Kaipiaoshenqing  = oA_KaipiaoshenqingBLL.GetModelByKeyid(orderId);
            if (a_Kaipiaoshenqing !=null  )
            {
                if(a_Kaipiaoshenqing.Kaipiaoshenqing == 3)
                {
                    Response.Write("已开票,无法撤回!");
                    return;
                }
                if(a_Kaipiaoshenqing.Shenqingleixing == "订单开票")
                {
                    Dictionary<int, object> searchParam = new Dictionary<int, object>();
                    SetParamValue(searchParam, 1, CurrentUser.MemberId);
                    SetParamValue(searchParam, 2, "");
                    SetParamValue(searchParam, 3, "");
                    SetParamValue(searchParam, 4, "");
                    SetParamValue(searchParam, 5, "");
                    SetParamValue(searchParam, 6, "");
                    SetParamValue(searchParam, 7, "");
                    SetParamValue(searchParam, 8, "");
                    SetParamValue(searchParam, 9, "");
                    SetParamValue(searchParam, 10, "");
                    SetParamValue(searchParam, 11, "");
                    SetParamValue(searchParam, 12, "");
                    SetParamValue(searchParam, 13, "");
                    SetParamValue(searchParam, 14, "");
                    SetParamValue(searchParam, 15, "");
                    SetParamValue(searchParam, 16, "");
                    SetParamValue(searchParam, 18, 0);
                    SetParamValue(searchParam, 19, CurrentUser.TrueMemberId);
                    SetParamValue(searchParam, 20, CurrentUser.StaffId);
                    SetParamValue(searchParam, 21, CurrentUser.TrueName);
                    SetParamValue(searchParam, 22, "");
                    SetParamValue(searchParam, 23, "");
                    SetParamValue(searchParam, 24, "");
                    SetParamValue(searchParam, 25, "");
                    SetParamValue(searchParam, 26, a_Kaipiaoshenqing.Keyid);
                    SetParamValue(searchParam, 29, "");
                    SearchParam = searchParam;
                    Infrastructure.Query.Pagination pagination = new Infrastructure.Query.Pagination()
                    {
                        PageSize = 1000,
                        PageIndex = 1
                    };
                    IEnumerable<EC_OrderBasic> result = _eC_OrderBasicBLL.SelectModelPage_Seller(pagination, SearchParam);
                    var PayedMoney =  result.Sum(x => x.TradingSingle.PayedMoney);
                    if (PayedMoney.HasValue &&  PayedMoney > 0)
                    {
                        Response.Write("已经有回款记录,无法撤回!");
                        return;
                    }
                }
                else
                {
                    if (a_Kaipiaoshenqing.Kehumoney.HasValue && a_Kaipiaoshenqing.Kehumoney.Value > 0)
                    {
                        Response.Write("已经有回款记录,无法撤回!");
                        return;
                    }
                }
                var sss = oA_KaipiaoshenqingBLL.DeleteModel(a_Kaipiaoshenqing);
                if (!sss)
                {
                    Response.Write("撤回失败!");
                    return;
                }
                if (a_Kaipiaoshenqing.Shenqingleixing == "订单开票")
                {
                    EC_OrderExtend model = new EC_OrderExtend();
                    model.KaipiaoshenqingId = a_Kaipiaoshenqing.Keyid;
                    model.KaipiaoshenqingTime = null;
                    model.Kaipiaoshenqing = 2;
                    model.KaipiaoshenqingCreater = Guid.Empty;
                    sss = _eC_OrderBLL.NewUpdateKaipiaoshenqings(model);
                    if (!sss)
                    {
                        Response.Write("撤回失败!");
                        return;
                    }
                }
            }
            else
            {
                Response.Write("撤回失败!");
                return;
            }
            Response.Write(_eC_OrderBasicBLL.AcceptOrder(orderId.Value, commission.Value) ? "1" : "0");
            Response.Write( "1");
        }
        /// <summary>
@@ -475,7 +583,7 @@
                //this.selKaipiaoshenqing.Value = "1";
                //this.selPayStates.Value = "1";
                //this.selHuikuanStates.Value = "1";
                this.selHuikuanStates.Value = "1";
                
@@ -486,8 +594,8 @@
                this.selBusinessManager.Items.Insert(0, new ListItem("全部", ""));
                //this.selBusinessManager.Items.Insert(1, new ListItem(CurrentUser.ShortName, CurrentUser.ShortName));
                this.txtSQBeginDate.Value = DateTime.Now.AddDays(-14).ToString("yyyy-MM-dd");
                this.txtSQEndDate.Value = DateTime.Now.ToString("yyyy-MM-dd");
                //this.txtSQBeginDate.Value = DateTime.Now.AddDays(-14).ToString("yyyy-MM-dd");
                //this.txtSQEndDate.Value = DateTime.Now.ToString("yyyy-MM-dd");
                //初次数据加载
                btn_Search_Click(btn_Search, new EventArgs());
@@ -586,9 +694,133 @@
            rptData.DataSource = result;
            rptData.DataBind();
            if (pagination.heji1.HasValue)
            {
                this.AllMoney.InnerText = pagination.heji1.Value.ToString("0.00");
            }
            else
            {
                this.AllMoney.InnerText = 0.ToString("0.00");
            }
            if (pagination.heji2.HasValue)
            {
                this.ZengMoney.InnerText = pagination.heji2.Value.ToString("0.00");
            }
            else
            {
                this.ZengMoney.InnerText = 0.ToString("0.00");
            }
            if (pagination.heji3.HasValue)
            {
                this.HuiMoney.InnerText = pagination.heji3.Value.ToString("0.00");
            }
            else
            {
                this.HuiMoney.InnerText = 0.ToString("0.00");
            }
            UCPager1.AspNetPager.RecordCount = pagination.RecordCount;
        }
        //查询事件
        protected void btn_Daochu_Click(object src, EventArgs e)
        {
            byte[] fileBytes = ExportToExcel();
            if (fileBytes != null)
            {
                Response.Clear();
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AppendHeader("Content-Disposition", "attachment; filename=开票管理导出.xlsx");
                Response.BinaryWrite(fileBytes);
                Response.End();
            }
            else
            {
                // 处理导出失败的情况
                Response.Write("导出失败,请稍后重试!");
            }
        }
        public byte[] ExportToExcel()
        {
            byte[] bt = null;
            try
            {
                Pagination pa = new Pagination();
                pa.PageSize = 1000;
                pa.PageIndex = 1;
                IEnumerable<OA_Kaipiaoshenqing> results = oA_KaipiaoshenqingBLL.SelectModelPage(pa, CurrentUser.MemberId, this.txtSQBeginDate.Value, this.txtSQEndDate.Value, this.selKaipiaoshenqing.Value, this.selKehuqianshou.Value, this.selBusinessManager.Value, this.txtCustormerName.Value, this.selPayStates.Value, this.selHuikuanStates.Value);
                // 创建工作簿
                IWorkbook workbook = new XSSFWorkbook();
                ISheet sheet = workbook.CreateSheet("导出数据");
                // 创建表头
                IRow headerRow = sheet.CreateRow(0);
                headerRow.CreateCell(0).SetCellValue("编号");
                headerRow.CreateCell(1).SetCellValue("申请开票时间");
                headerRow.CreateCell(2).SetCellValue("申请类型");
                headerRow.CreateCell(3).SetCellValue("业务经理");
                headerRow.CreateCell(4).SetCellValue("客户名称");
                headerRow.CreateCell(5).SetCellValue("发票号码");
                headerRow.CreateCell(6).SetCellValue("订单数量");
                headerRow.CreateCell(7).SetCellValue("金额");
                headerRow.CreateCell(8).SetCellValue("增减金额");
                headerRow.CreateCell(9).SetCellValue("回款金额");
                headerRow.CreateCell(10).SetCellValue("最近催款");
                headerRow.CreateCell(11).SetCellValue("开票状态");
                // 添加数据
                int rowIndex = 1;
                foreach (var oA_Kaipiaoshenqing in results)
                {
                    IRow row = sheet.CreateRow(rowIndex++);
                    row.CreateCell(0).SetCellValue((rowIndex - 1).ToString());
                    row.CreateCell(1).SetCellValue(oA_Kaipiaoshenqing.CreateTime.Value.ToString("yyyy-MM-dd"));
                    row.CreateCell(2).SetCellValue(oA_Kaipiaoshenqing.Shenqingleixing);
                    row.CreateCell(3).SetCellValue(oA_Kaipiaoshenqing.BusinessManager);
                    row.CreateCell(4).SetCellValue(oA_Kaipiaoshenqing.BuyerName);
                    row.CreateCell(5).SetCellValue(oA_Kaipiaoshenqing.Fapiaohao);
                    row.CreateCell(6).SetCellValue(oA_Kaipiaoshenqing.Dingdanshu.HasValue? oA_Kaipiaoshenqing.Dingdanshu.Value.ToString():"");
                    row.CreateCell(7).SetCellValue(oA_Kaipiaoshenqing.kpmoney.HasValue ? oA_Kaipiaoshenqing.kpmoney.Value.ToString() : "0");
                    row.CreateCell(8).SetCellValue(oA_Kaipiaoshenqing.Zengjianmoney.HasValue ? oA_Kaipiaoshenqing.Zengjianmoney.Value.ToString() : "0");
                    row.CreateCell(9).SetCellValue(oA_Kaipiaoshenqing.Huikuanmoney.HasValue ? oA_Kaipiaoshenqing.Huikuanmoney.Value.ToString() : "0");
                    row.CreateCell(10).SetCellValue(oA_Kaipiaoshenqing.ShoukuanTime.HasValue? oA_Kaipiaoshenqing.ShoukuanTime.Value.ToString("MM-dd HH:mm") : "");
                    row.CreateCell(11).SetCellValue(oA_Kaipiaoshenqing.KaipiaoshenqingName);
                }
                // 将工作簿写入内存流
                using (var ms = new MemoryStream())
                {
                    workbook.Write(ms);
                    bt = ms.ToArray();
                }
            }
            catch (Exception e)
            {
                bt = null;
                // 记录日志
            }
            return bt;
        }
        /// <summary>
        /// 查询参数
        /// </summary>