From c20a6a52a1debb73cab647875193244471c52663 Mon Sep 17 00:00:00 2001 From: liangkun Date: Wed, 14 Dec 2022 18:18:59 +0800 Subject: [PATCH] =?UTF-8?q?excel=E5=AF=BC=E5=85=A5=E7=BC=B4=E8=B4=B9?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StuInfoBasic_PayFee/PayFeeIndex.cshtml | 1 + .../Views/StuInfoBasic_PayFee/PayFeeIndex.js | 11 ++ .../XmlConfig/system.config | 3 +- .../Learun.Application.Website/Web.config | 12 ++ .../StuEnrollFeeOrderEntity.cs | 6 +- .../StuInfoFresh/StuInfoFreshService.cs | 169 ++++++++++++++++-- .../Learun.Application.TwoDevelopment.csproj | 3 + .../packages.config | 2 + 8 files changed, 192 insertions(+), 15 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic_PayFee/PayFeeIndex.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic_PayFee/PayFeeIndex.cshtml index 3fd8665c4..7a2c9d7c3 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic_PayFee/PayFeeIndex.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic_PayFee/PayFeeIndex.cshtml @@ -54,6 +54,7 @@  初始化缴费数据  二维码缴费  查看发票 +  导入缴费明细 diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic_PayFee/PayFeeIndex.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic_PayFee/PayFeeIndex.js index ca2dc16d3..6ac6872e1 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic_PayFee/PayFeeIndex.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic_PayFee/PayFeeIndex.js @@ -57,6 +57,17 @@ var bootstrap = function ($, learun) { }); } }); + //导入缴费明细 + $('#lr_import').on('click', function () { + learun.layerForm({ + id: 'form_import', + title: '导入缴费明细', + url: top.$.rootUrl + '/EducationalAdministration/StuInfoFresh/ExcelImportPay?id=2', + width: 600, + height: 400, + btn: null + }); + }); //查看发票 $('#lr_viewinvoice').on('click', function () { var keyValue = $('#gridtable').jfGridValue('Id'); diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config b/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config index 38e965f34..ac8026e8f 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/XmlConfig/system.config @@ -170,11 +170,12 @@ - + + \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Website/Web.config b/Learun.Framework.Ultimate V7/Learun.Application.Website/Web.config index 65a84299c..77bf6316c 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Website/Web.config +++ b/Learun.Framework.Ultimate V7/Learun.Application.Website/Web.config @@ -69,6 +69,18 @@ + + + + + + + + + + + + diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuEnrollFeeOrder/StuEnrollFeeOrderEntity.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuEnrollFeeOrder/StuEnrollFeeOrderEntity.cs index 14f3be839..bd0769952 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuEnrollFeeOrder/StuEnrollFeeOrderEntity.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuEnrollFeeOrder/StuEnrollFeeOrderEntity.cs @@ -55,7 +55,11 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration /// [Column("PAYTIME")] public DateTime? PayTime { get; set; } - + /// + /// 付款方式 + /// + [Column("PAYMODE")] + public string PayMode { get; set; } /// /// 电子票据代码 /// diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoFresh/StuInfoFreshService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoFresh/StuInfoFreshService.cs index 081186ab1..2585de6ac 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoFresh/StuInfoFreshService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoFresh/StuInfoFreshService.cs @@ -11,6 +11,7 @@ using System.Data; using System.IO; using System.Linq; using System.Text; +using System.Threading.Tasks; using Learun.Cache.Base; using Learun.Cache.Factory; @@ -2208,22 +2209,22 @@ where bb.StuNo not in (select b.StuNo from StuInfoBasic b where b.StuNo=bb.StuNo //获取学生数据 if (templateId == "1")//新生 { - stufreshlist = BaseRepository("CollegeMIS").FindList("select StuNo,StuName from StuInfoFresh"); + stufreshlist = BaseRepository("CollegeMIS").FindList("select StuNo,StuName,PayFeeStatus from StuInfoFresh"); } else//老生 { stuinfobasiclist = BaseRepository("CollegeMIS").FindList("select StuNo,StuName from StuInfoBasic"); //老生缴费初始化记录 - stuinfobasicpayfeelist = BaseRepository("CollegeMIS").FindList("select StuNo,PayYear from StuInfoBasic_PayFee"); + stuinfobasicpayfeelist = BaseRepository("CollegeMIS").FindList("select StuNo,PayYear,PayStatus from StuInfoBasic_PayFee"); } - + List insertedorderlist = new List(); // 循环遍历导入 foreach (DataRow dr in dt.Rows) { try { //检测是否有空值 - if (dr[0] == null || dr[1] == null || dr[2] == null || dr[3] == null || dr[4] == null || dr[5] == null) + if (dr[0].ToString() == "" || dr[1].ToString() == "" || dr[2].ToString() == "" || dr[3].ToString() == "" || dr[4].ToString() == "" || dr[5].ToString() == "") { throw (new Exception("行内数据有空值,不能为空!")); } @@ -2244,7 +2245,7 @@ where bb.StuNo not in (select b.StuNo from StuInfoBasic b where b.StuNo=bb.StuNo } //筛选不在标准代码表内的数据 //第五列是金额 - if (typecodelist.Count(m => m.ProjectCode == dr[5].ToString()) == 0) + if (typecodelist.Count(m => m.ProjectCode == dr[4].ToString()) == 0) { throw (new Exception("【缴费项目编码】不存在,请核对!")); } @@ -2256,6 +2257,11 @@ where bb.StuNo not in (select b.StuNo from StuInfoBasic b where b.StuNo=bb.StuNo { throw (new Exception("【学号】不存在,请核对新生数据!")); } + //已缴费的跳过 + if (stufreshlist.Count(m => m.StuNo == dr[1].ToString() & m.PayFeeStatus == "1") > 0) + { + throw (new Exception("当前学生已缴费,请核对新生数据!")); + } } else//老生 { @@ -2270,15 +2276,102 @@ where bb.StuNo not in (select b.StuNo from StuInfoBasic b where b.StuNo=bb.StuNo { throw (new Exception("【学生年度缴费数据】不存在,请核对是否初始化缴费数据!")); } + //已缴费的跳过 + if (stuinfobasicpayfeelist.Count(m => m.StuNo == dr[1].ToString() && m.PayYear == dr[0].ToInt() && m.PayStatus == 1) == 0) + { + throw (new Exception("当前学生已缴费,请核对缴费数据!")); + } + } + //用友库查询是否存在缴费项目 + + if (BaseRepository("YongyouDb").FindTable("select * from SCS_XSXX where XH='" + dr[1].ToString() + "'").Rows.Count==0) + { + throw (new Exception("【用友系统】不存在学生信息数据,请核对用友系统数据!")); } //数据筛查完毕,执行导入 - StuEnrollFeeOrderEntity orderEntity=new StuEnrollFeeOrderEntity(); - orderEntity.Create(); - orderEntity.YearNo = dr[0].ToInt(); - orderEntity.StuNo = dr[1].ToString(); - Random ran = new Random(); - orderEntity.orderid = DateTime.Now.ToString("yyyyMMddhhmmss") + ran.Next(0, 100000); - + //order主表记录查询 + var orderlist = BaseRepository("CollegeMIS").FindList("select * from StuEnrollFeeOrder where YearNo='" + dr[0].ToString() + "' and StuNo='" + dr[1].ToString() + "' and Status=999"); + //查无订单新建 + if (orderlist.Count() == 0) + { + var db = BaseRepository("CollegeMIS"); + db.BeginTrans(); + StuEnrollFeeOrderEntity orderEntity = new StuEnrollFeeOrderEntity(); + orderEntity.Create(); + orderEntity.YearNo = dr[0].ToInt(); + orderEntity.StuNo = dr[1].ToString(); + Random ran = new Random(); + orderEntity.orderid = DateTime.Now.ToString("yyyyMMddhhmmss") + ran.Next(0, 100000); + orderEntity.YJAmount = dr[5].ToDecimal(); + orderEntity.SJAmount = dr[5].ToDecimal(); + orderEntity.PlaceOrderTime = DateTime.Now; + orderEntity.PayMode = "ExcelOffLine"; + orderEntity.Status = 999; + orderEntity.billStatus = false; + orderEntity.PayTime = DateTime.Now; + db.Insert(orderEntity); + //写入数据记录 + insertedorderlist.Add(orderEntity); + //写入订单详情表 + StuEnrollFeeOrderDetailEntity orderDetailEntity = new StuEnrollFeeOrderDetailEntity(); + orderDetailEntity.Create(); + orderDetailEntity.OrderId = orderEntity.Id; + orderDetailEntity.ChargeItemName = dr[3].ToString(); + orderDetailEntity.ChargeItemID = dr[4].ToString(); + orderDetailEntity.YJAmount = dr[5].ToDecimal(); + orderDetailEntity.SJAmount = dr[5].ToDecimal(); + db.Insert(orderDetailEntity); + db.Commit(); + snum++; + } + //否则直接写入订单详情表,并更新主订单表 + else + { + var db = BaseRepository("CollegeMIS"); + db.BeginTrans(); + StuEnrollFeeOrderEntity orderEntity = orderlist.FirstOrDefault(); + var orderdetails = db.FindList("select * from StuEnrollFeeOrderDetail where OrderId='" + orderEntity.Id + "' and ChargeItemID='" + dr[4].ToString() + "'"); + //判断是否存在缴费明细 + if (orderdetails.Count() == 0) + { + //写入订单详情表 + StuEnrollFeeOrderDetailEntity orderDetailEntity = new StuEnrollFeeOrderDetailEntity(); + orderDetailEntity.Create(); + orderDetailEntity.OrderId = orderEntity.Id; + orderDetailEntity.ChargeItemName = dr[3].ToString(); + orderDetailEntity.ChargeItemID = dr[4].ToString(); + orderDetailEntity.YJAmount = dr[5].ToDecimal(); + orderDetailEntity.SJAmount = dr[5].ToDecimal(); + db.Insert(orderDetailEntity); + //更新主订单表 + orderEntity.YJAmount += orderDetailEntity.YJAmount; + orderEntity.SJAmount += orderDetailEntity.SJAmount; + db.Update(orderEntity); + db.Commit(); + snum++; + } + //已存在当前缴费项目 + //跳过还是覆盖? + else + { //跳过 + throw (new Exception("当前学生的缴费项目数据已存在数据,未能导入!")); + //覆盖 + //StuEnrollFeeOrderDetailEntity orderDetailEntity = orderdetails.FirstOrDefault(); + //orderDetailEntity.OrderId = orderEntity.Id; + //orderDetailEntity.ChargeItemName = dr[3].ToString(); + //orderDetailEntity.ChargeItemID = dr[4].ToString(); + //orderDetailEntity.YJAmount = dr[5].ToDecimal(); + //orderDetailEntity.SJAmount = dr[5].ToDecimal(); + //db.Update(orderDetailEntity); + ////更新主订单表 + //orderEntity.YJAmount =db.FindList("select * from StuEnrollFeeOrderDetail where OrderId='"+orderEntity.Id+"'").Sum(m=>m.YJAmount); + //orderEntity.SJAmount = db.FindList("select * from StuEnrollFeeOrderDetail where OrderId='" + orderEntity.Id + "'").Sum(m => m.SJAmount); + //db.Update(orderEntity); + //db.Commit(); + } + if (insertedorderlist.Count(m => m.orderid == orderEntity.orderid) == 0) + insertedorderlist.Add(orderEntity); + } } catch (Exception ex) { @@ -2287,11 +2380,61 @@ where bb.StuNo not in (select b.StuNo from StuInfoBasic b where b.StuNo=bb.StuNo failDt.Rows.Add(dr.ItemArray); } } + //用友回写 + + foreach (var detail in insertedorderlist) + { + var dbyongyou = BaseRepository("YongyouDb"); + dbyongyou.BeginTrans(); + //此处订单列表内金额不是实时数据,需要再次查询 + var newdetail = BaseRepository("CollegeMIS").FindEntity(m => m.orderid == detail.orderid); + //newdetail.Status = 1; + //newdetail.YJAmount = 0; + //newdetail.SJAmount = 0; + //BaseRepository("CollegeMIS").Update(newdetail); + //缴费状态更新 + //新老生判断 + if (BaseRepository("CollegeMIS").FindList("select stuno from StuInfoFresh where StuNo='" + newdetail.StuNo + "' and grade='" + newdetail.YearNo.ToString().Substring(2) + "'").Count() > 0) + { + BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoFresh set PayFeeStatus='1' where StuNo='" + newdetail.StuNo + "'"); + } + else + { + BaseRepository("CollegeMIS").ExecuteBySql("update StuInfoBasic_PayFee set PayStatus='1' where StuNo='" + newdetail.StuNo + "' and PayYear='" + newdetail.YearNo + "'"); + } + string detailstuno = newdetail.StuNo; + DataTable stuinfo = dbyongyou.FindTable("select * from SCS_XSXX where XH='" + detailstuno + "'"); + if (stuinfo.Rows.Count==0) + { + //用友库无学生数据 + continue; + } + string XSID = stuinfo.Rows[0]["XSID"].ToString(); + string XM = stuinfo.Rows[0]["XM"].ToString(); + string SFZ = stuinfo.Rows[0]["SFZ"].ToString(); + string strSql = "insert into SCS_ORDER(GSDM,KJND,OR_ID,OR_NO,XSID,ZDRDM,ZDRMC,ZDRQ,ZDSJ,ZFZT,CHANNELTYPE,AMOUNT,PAYTYPE,IDCARD,realamount,moneytype,BZ,pstring) " + + " values('001','" + newdetail.YearNo + "','" + newdetail.orderid + "-" + newdetail.YearNo + "','" + newdetail.orderid + "','" + XSID + "','" + newdetail.StuNo + "','" + XM + "','" + DateTime.Now.ToString("yyyyMMdd") + "','" + DateTime.Now.ToString("hhmmss") + "','20','4','" + newdetail.SJAmount + "','ExcelOffLine','" + SFZ + "','" + newdetail.SJAmount + "','1','','支付成功')"; + dbyongyou.ExecuteBySql(strSql); + //日志 + BaseRepository().ExecuteBySql("insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),122,'yongyou','用友回写SCS_ORDER完成',getdate())"); + //用友明细 + List orderdetaillist = BaseRepository("CollegeMIS").FindList("select * from StuEnrollFeeOrderDetail where OrderId='" + newdetail.Id + "'").ToList(); + for (int i = 0; i < orderdetaillist.Count; i++) + { + string sqldetail = "insert into SCS_ORDEL(GSDM,KJND,OR_ID,XH,SFND,SFXMDM,SFXMMC,JE,SFQJNM) " + + "values('001','" + newdetail.YearNo + "','" + newdetail.orderid + "-" + newdetail.YearNo + "','" + (i + 1) + "','" + newdetail.YearNo + "','" + orderdetaillist[i].ChargeItemID + "','" + orderdetaillist[i].ChargeItemName + "','" + orderdetaillist[i].SJAmount + "','" + newdetail.YearNo + "')"; + dbyongyou.ExecuteBySql(sqldetail); + } + dbyongyou.Commit(); + } + //触发开具发票任务 + //通过调用digitalschoolapi的接口实现任务触发 + string excelInvoice = Config.GetValue("ExcelInvoice"); + Task.Run(()=> HttpMethods.Post(excelInvoice)); // 写入缓存如果有未导入的数据 if (failDt.Rows.Count > 0) { string errordt = failDt.ToJson(); - cache.Write(cacheKey + fileId, errordt, CacheId.excel); } } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Learun.Application.TwoDevelopment.csproj b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Learun.Application.TwoDevelopment.csproj index 16ff04be9..9039a341b 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Learun.Application.TwoDevelopment.csproj +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Learun.Application.TwoDevelopment.csproj @@ -54,6 +54,9 @@ ..\..\..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll + + ..\..\..\packages\Owin.1.0\lib\net40\Owin.dll + diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/packages.config b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/packages.config index 911962960..b62d424eb 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/packages.config +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/packages.config @@ -1,8 +1,10 @@  + + \ No newline at end of file