From 6aed7494358291a457030993bec7db1dda4542bb Mon Sep 17 00:00:00 2001 From: liangkun Date: Wed, 4 Jan 2023 18:03:49 +0800 Subject: [PATCH] =?UTF-8?q?excel=E5=AF=BC=E5=85=A5=E7=94=A8=E5=8F=8B?= =?UTF-8?q?=E5=9B=9E=E5=86=99=E5=8E=BB=E6=8E=89=E4=BA=8B=E7=89=A9=EF=BC=8C?= =?UTF-8?q?=E5=9B=A0=E4=B8=BA=E6=9C=8D=E5=8A=A1=E5=99=A8=E4=B8=8A=E8=80=81?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StuInfoFresh/StuInfoFreshService.cs | 58 +++++++++++++------ 1 file changed, 41 insertions(+), 17 deletions(-) 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 ab8b27539..8987b58f2 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 @@ -2295,7 +2295,7 @@ where bb.StuNo not in (select b.StuNo from StuInfoBasic b where b.StuNo=bb.StuNo } //数据筛查完毕,执行导入 //order主表记录查询 - var orderlist = BaseRepository("CollegeMIS").FindList("select * from StuEnrollFeeOrder where YearNo='" +(templateId=="1"? "20"+stufreshlist.FirstOrDefault(m=>m.StuNo== dr[1].ToString()).Grade: dr[0].ToString()) + "' and StuNo='" + dr[1].ToString() + "' and Status=999"); + var orderlist = BaseRepository("CollegeMIS").FindList("select * from StuEnrollFeeOrder where YearNo='" + (templateId == "1" ? "20" + stufreshlist.FirstOrDefault(m => m.StuNo == dr[1].ToString()).Grade : dr[0].ToString()) + "' and StuNo='" + dr[1].ToString() + "' and Status=999"); //查无订单新建 if (orderlist.Count() == 0) { @@ -2303,7 +2303,7 @@ where bb.StuNo not in (select b.StuNo from StuInfoBasic b where b.StuNo=bb.StuNo db.BeginTrans(); StuEnrollFeeOrderEntity orderEntity = new StuEnrollFeeOrderEntity(); orderEntity.Create(); - orderEntity.YearNo = templateId == "1" ? Convert.ToInt32("20" + stufreshlist.FirstOrDefault(m => m.StuNo == dr[1].ToString()).Grade): dr[0].ToInt(); + orderEntity.YearNo = templateId == "1" ? Convert.ToInt32("20" + stufreshlist.FirstOrDefault(m => m.StuNo == dr[1].ToString()).Grade) : dr[0].ToInt(); orderEntity.StuNo = dr[1].ToString(); Random ran = new Random(); orderEntity.orderid = DateTime.Now.ToString("yyyyMMddhhmmss") + ran.Next(0, 100000); @@ -2389,8 +2389,7 @@ where bb.StuNo not in (select b.StuNo from StuInfoBasic b where b.StuNo=bb.StuNo foreach (var detail in insertedorderlist) { - var dbyongyou = BaseRepository("YongyouDb"); - dbyongyou.BeginTrans(); + //此处订单列表内金额不是实时数据,需要再次查询 var newdetail = BaseRepository("CollegeMIS").FindEntity(m => m.orderid == detail.orderid); //newdetail.Status = 1; @@ -2408,7 +2407,7 @@ where bb.StuNo not in (select b.StuNo from StuInfoBasic b where b.StuNo=bb.StuNo 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 + "'"); + DataTable stuinfo = BaseRepository("YongyouDb").FindTable("select * from SCS_XSXX where XH='" + detailstuno + "'"); if (stuinfo.Rows.Count == 0) { //用友库无学生数据 @@ -2417,20 +2416,45 @@ where bb.StuNo not in (select b.StuNo from StuInfoBasic b where b.StuNo=bb.StuNo 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++) + //判断用友订单是否存在记录 + DataTable scs_orderlist = BaseRepository("YongyouDb").FindTable("select * from SCS_ORDER where KJND='" + newdetail.YearNo + "' and OR_ID='" + newdetail.orderid + "-" + newdetail.YearNo + "' and OR_NO='" + newdetail.orderid + "'"); + if (scs_orderlist.Rows.Count == 0) { - 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); + //用友库无订单记录 + 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','','支付成功')"; + BaseRepository("YongyouDb").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 + "')"; + BaseRepository("YongyouDb").ExecuteBySql(sqldetail); + } + } + else + { + int xhnew = 0; + //获取序号 + DataTable scs_ordel = BaseRepository("YongyouDb").FindTable("select * from SCS_ORDEL where OR_ID='" + newdetail.orderid + "-" + newdetail.YearNo + "' order by xh desc"); + if (scs_ordel.Rows.Count > 0) + { + xhnew = Convert.ToInt32(scs_ordel.Rows[0]["XH"]); + } + //用友明细 + 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 + "','" + (xhnew + i + 1) + "','" + newdetail.YearNo + "','" + orderdetaillist[i].ChargeItemID + "','" + orderdetaillist[i].ChargeItemName + "','" + orderdetaillist[i].SJAmount + "','" + newdetail.YearNo + "')"; + BaseRepository("YongyouDb").ExecuteBySql(sqldetail); + //更新主表 + BaseRepository("YongyouDb").ExecuteBySql("update SCS_ORDER set AMOUNT=AMOUNT+" + orderdetaillist[i].SJAmount + " where KJND='" + newdetail.YearNo + "' and OR_ID='" + newdetail.orderid + "-" + newdetail.YearNo + "' and OR_NO='" + newdetail.orderid + "'"); + } } - dbyongyou.Commit(); } //触发开具发票任务 //通过调用digitalschoolapi的接口实现任务触发