diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Learun.Application.WebApi.csproj b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Learun.Application.WebApi.csproj index b15e9bd60..9d30b0df7 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Learun.Application.WebApi.csproj +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Learun.Application.WebApi.csproj @@ -156,6 +156,9 @@ + + ..\packages\ThoughtWorks.QRCode.1.1.0\lib\ThoughtWorks.QRCode.dll + ..\packages\WebGrease.1.5.2\lib\WebGrease.dll @@ -192,6 +195,8 @@ + + diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/StuFreshPayFeeApi.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/StuFreshPayFeeApi.cs new file mode 100644 index 000000000..4610f9a20 --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/StuFreshPayFeeApi.cs @@ -0,0 +1,216 @@ +using System; +using Learun.Application.Organization; +using Learun.Application.TwoDevelopment.EducationalAdministration; +using Learun.Application.TwoDevelopment.EvaluationTeach; +using Learun.Util; +using Nancy; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Web; +using System.Web.Mvc; +using Learun.Application.Base.SystemModule; +using Learun.Application.TwoDevelopment.Ask; +using Learun.Application.TwoDevelopment.ReceiveSendFeeManagement; +using Newtonsoft.Json; +using ThoughtWorks.QRCode.Codec; + +namespace Learun.Application.WebApi.Modules +{ + /// + /// 版 本 Learun-ADMS V7.0.0 数字化智慧校园 + /// Copyright (c) 2013-2018 北京泉江科技有限公司 + /// 创建人:数字化智慧校园-框架开发组 + /// 日 期:2018.01.04 + /// 描 述:部门管理 + /// + public class StuFreshPayFeeApi : BaseApi + { + public StuFreshPayFeeApi() + : base("/learun/freshpayfee") + { + Get["/getpayfeelist"] = GetPayfeeList;// 获取缴费列表 + Get["/getpayfeeinfo"] = GetPayfeeInfo;//获取缴费明细 + Post["/generateqrcode"] = PayFeeQRCode; + } + + private StuInfoFreshIBLL stuInfoFreshIBLL = new StuInfoFreshBLL(); + private FinaChargesStandardIBLL finaChargesStandardIBLL = new FinaChargesStandardBLL(); + + /// + /// 获取问卷 + /// + /// + /// + public Response GetPayfeeList(dynamic _) + { + ReqPageParam parameter = this.GetReqData(); + var data = stuInfoFreshIBLL.GetPageList(parameter.pagination, parameter.queryJson); + var jsonData = new + { + rows = data, + total = parameter.pagination.total, + page = parameter.pagination.page, + records = parameter.pagination.records + }; + return Success(jsonData); + } + + public Response GetPayfeeInfo(dynamic _) + { + string keyValue = Request.Query["keyValue"]; + int jiaoFeiYear = DateTime.Now.Year; + var StuInfoFreshData = stuInfoFreshIBLL.GetStuInfoFreshEntity(keyValue); + var stuInfoFreshFamily = stuInfoFreshIBLL.GetStuInfoFreshFamilyList(keyValue); + //当前年度缴费记录 + var FeeOrderList = stuInfoFreshIBLL.GetFeeOrderList(StuInfoFreshData.StuNo, jiaoFeiYear); + var FinaChargesStandardList = new List(); + FinaChargesStandardList = finaChargesStandardIBLL.GetFinaChargesStandardListByYongYou(StuInfoFreshData.StuNo, jiaoFeiYear).ToList(); + var PayFeeTotal = FinaChargesStandardList.Select(x => x.Standard).Sum(); + var jsonData = new + { + StuInfoFreshData = StuInfoFreshData, + FinaChargesStandardList = FinaChargesStandardList, + StuInfoFreshFamilyList = stuInfoFreshFamily, + PayFeeTotal = PayFeeTotal, + YJAmount = FeeOrderList.Sum(x => x.SJAmount) + }; + return Success(jsonData); + } + + + public class PayfeeRequest + { + public string strEntity { get; set; } + public string detailList { get; set; } + } + + /// + /// 生成缴费二维码 + /// + /// + public Response PayFeeQRCode(dynamic _) + { + string keyValue = Request.Query["keyValue"]; + PayfeeRequest parameter = this.GetReqData(); + StuInfoFreshEntity entity = parameter.strEntity.ToObject(); + List list = parameter.detailList.ToObject>(); + var model = stuInfoFreshIBLL.GetStuInfoFreshEntity(keyValue); + var imgUrl = ""; + Random ran = new Random(); + string merchantid = "105000082201406";//商户号 + string posid = "043724806";//商户柜台代码 + string branchid = "510000000";//分行代码 + string orderid = DateTime.Now.ToString("yyyyMMddhhmmss") + ran.Next(0, 100000); + string payment = entity.PayMoney.ToString(); + string curcode = "01"; + string txcode = "530550"; + string remark1 = model.StuNo; + string remark2 = "20" + model.Grade; + string returntype = "3"; + string timeout = DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"); + string pub32tr2 = "40d987faa793a0a27e7a86ef020111"; + string bankURL = "https://ibsbjstar.ccb.com.cn/CCBIS/ccbMain?CCB_IBSVersion=V6"; + string tmp = "MERCHANTID=" + merchantid + "&POSID=" + posid + "&BRANCHID=" + branchid + "&ORDERID=" + orderid; + tmp += "&PAYMENT=" + payment + "&CURCODE=" + curcode + "&TXCODE=" + txcode + "&REMARK1=" + remark1; + tmp += "&REMARK2=" + remark2 + "&RETURNTYPE=" + returntype + "&TIMEOUT=" + timeout; + MD5 md5 = MD5.Create(); + string tmp1 = tmp; + tmp += "&PUB=" + pub32tr2; + byte[] buffer = Encoding.Default.GetBytes(tmp); + byte[] md5Buffer = md5.ComputeHash(buffer); + string strMd5 = ""; + //hdnOrderId.Value = orderid; + foreach (byte item in md5Buffer) + { + strMd5 += item.ToString("x2"); + } + string url = bankURL + "&" + tmp1 + "&MAC=" + strMd5; + string reJson = HttpMethods.Post(url); + LogEntity logEntity = new LogEntity(); + logEntity.F_CategoryId = 121; + logEntity.F_ExecuteResultJson = reJson; + logEntity.WriteLog(); + //HttpConnect conn = new HttpConnect(); + //string reJson = conn.Post(url, ""); + JsonBean MemberInfoList = JsonConvert.DeserializeObject(reJson); + if (MemberInfoList.SUCCESS.Equals("true")) + { + string imgCode = HttpMethods.Post(MemberInfoList.PAYURL); + logEntity.F_CategoryId = 121; + logEntity.F_ExecuteResultJson = imgCode; + logEntity.WriteLog(); + MemberInfoList = JsonConvert.DeserializeObject(imgCode); + if (MemberInfoList.SUCCESS.Equals("true")) + { + imgUrl = CreateQRImg(MemberInfoList.QRURL, orderid); + } + } + + if (!string.IsNullOrEmpty(imgUrl)) + { + // model.PayFeeDetail = entity.PayFeeDetail; + // model.PayMoney = entity.PayMoney; + model.LoanMoney = entity.LoanMoney; + model.orderid = orderid; + stuInfoFreshIBLL.SaveFeeData(keyValue, model, list); + } + + return Success(imgUrl); + } + + public class JsonBean + { + /// + /// + /// + public string SUCCESS { get; set; } + public string PAYURL { get; set; } + public string QRURL { get; set; } + } + /// + /// 生成并保存二维码图片的方法 + /// + /// 输入的内容 + public string CreateQRImg(string str, string orderId) + { + string QRCodeFile = Config.GetValue("QRCodeFile"); + Random ran = new Random(); + Bitmap bt; + str = HttpUtility.UrlDecode(str); + string enCodeString = str; + //生成设置编码实例 + QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); + //设置二维码的规模,默认4 + qrCodeEncoder.QRCodeScale = 3; + //设置二维码的版本,默认7 + qrCodeEncoder.QRCodeVersion = 7; + //设置错误校验级别,默认中等 + qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M; + //生成二维码图片 + bt = qrCodeEncoder.Encode(enCodeString, Encoding.UTF8); + //二维码图片的名称 + string filename = orderId; + if (!DirFileHelper.IsExistFile(QRCodeFile + "/Content/images/QRCode/")) + { + Directory.CreateDirectory(QRCodeFile + "/Content/images/QRCode/"); + } + var path = QRCodeFile + "/Content/images/QRCode/" + filename + ".jpg"; + //保存二维码图片在photos路径下 + try + { + bt.Save(path); + } + catch (Exception ex) + { + return ""; + } + + //图片控件要显示的二维码图片路径 + return QRCodeFile + "/Content/images/QRCode/" + filename + ".jpg"; + } + } +} \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/StuPayFeeApi.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/StuPayFeeApi.cs new file mode 100644 index 000000000..76afef7bb --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/StuPayFeeApi.cs @@ -0,0 +1,212 @@ +using System; +using Learun.Application.Organization; +using Learun.Application.TwoDevelopment.EducationalAdministration; +using Learun.Application.TwoDevelopment.EvaluationTeach; +using Learun.Util; +using Nancy; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Web; +using System.Web.Mvc; +using Learun.Application.Base.SystemModule; +using Learun.Application.TwoDevelopment.Ask; +using Learun.Application.TwoDevelopment.ReceiveSendFeeManagement; +using Newtonsoft.Json; +using ThoughtWorks.QRCode.Codec; + +namespace Learun.Application.WebApi.Modules +{ + /// + /// 版 本 Learun-ADMS V7.0.0 数字化智慧校园 + /// Copyright (c) 2013-2018 北京泉江科技有限公司 + /// 创建人:数字化智慧校园-框架开发组 + /// 日 期:2018.01.04 + /// 描 述:部门管理 + /// + public class StuPayFeeApi : BaseApi + { + public StuPayFeeApi() + : base("/learun/payfee") + { + Get["/getpayfeelist"] = GetPayfeeList;// 获取缴费列表 + Get["/getpayfeeinfo"] = GetPayfeeInfo;//获取缴费明细 + Post["/generateqrcode"] = PayFeeQRCode; + } + + private StuInfoBasic_PayFeeIBLL stuInfoBasic_PayFeeIBLL = new StuInfoBasic_PayFeeBLL(); + private StuInfoBasicIBLL stuInfoBasicIbll = new StuInfoBasicBLL(); + private StuInfoFreshIBLL stuInfoFreshIBLL = new StuInfoFreshBLL(); + private FinaChargesStandardIBLL finaChargesStandardIBLL = new FinaChargesStandardBLL(); + + /// + /// 获取问卷 + /// + /// + /// + public Response GetPayfeeList(dynamic _) + { + ReqPageParam parameter = this.GetReqData(); + var data = stuInfoBasic_PayFeeIBLL.GetPageList(parameter.pagination, parameter.queryJson); + var jsonData = new + { + rows = data, + total = parameter.pagination.total, + page = parameter.pagination.page, + records = parameter.pagination.records + }; + return Success(jsonData); + } + + public Response GetPayfeeInfo(dynamic _) + { + string keyValue = Request.Query["keyValue"]; + var stuInfoBasic_PayFeeEntity = stuInfoBasic_PayFeeIBLL.GetStuInfoBasic_PayFeeEntity(keyValue); + var StuInfoFreshData = stuInfoBasicIbll.GetStuInfoBasicEntityByStuNo(stuInfoBasic_PayFeeEntity.StuNo); + //当前年度缴费记录 + var FinaChargesStandardList = new List(); + FinaChargesStandardList = finaChargesStandardIBLL.GetFinaChargesStandardListByYongYou(StuInfoFreshData.StuNo, stuInfoBasic_PayFeeEntity.PayYear.Value).ToList(); + var PayFeeTotal = FinaChargesStandardList.Select(x => x.SJAmount).Sum(); + var jsonData = new + { + StuInfoFreshData = StuInfoFreshData, + FinaChargesStandardList = FinaChargesStandardList, + PayFeeTotal = PayFeeTotal, + YJAmount = FinaChargesStandardList.Sum(x => x.PayedMoney) + }; + return Success(jsonData); + } + + + public class PayfeeRequest + { + public string strEntity { get; set; } + public string detailList { get; set; } + } + + /// + /// 生成缴费二维码 + /// + /// + public Response PayFeeQRCode(dynamic _) + { + string keyValue = Request.Query["keyValue"]; + PayfeeRequest parameter = this.GetReqData(); + StuInfoFreshEntity entity = parameter.strEntity.ToObject(); + List list = parameter.detailList.ToObject>(); + var model = stuInfoBasic_PayFeeIBLL.GetStuInfoBasic_PayFeeEntity(keyValue); + var imgUrl = ""; + Random ran = new Random(); + string merchantid = "105000082201406";//商户号 + string posid = "043724806";//商户柜台代码 + string branchid = "510000000";//分行代码 + string orderid = DateTime.Now.ToString("yyyyMMddhhmmss") + ran.Next(0, 100000); + string payment = entity.PayMoney.ToString(); + string curcode = "01"; + string txcode = "530550"; + string remark1 = model.StuNo; + string remark2 = model.PayYear.ToString(); + string returntype = "3"; + string timeout = DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"); + string pub32tr2 = "40d987faa793a0a27e7a86ef020111"; + string bankURL = "https://ibsbjstar.ccb.com.cn/CCBIS/ccbMain?CCB_IBSVersion=V6"; + string tmp = "MERCHANTID=" + merchantid + "&POSID=" + posid + "&BRANCHID=" + branchid + "&ORDERID=" + orderid; + tmp += "&PAYMENT=" + payment + "&CURCODE=" + curcode + "&TXCODE=" + txcode + "&REMARK1=" + remark1; + tmp += "&REMARK2=" + remark2 + "&RETURNTYPE=" + returntype + "&TIMEOUT=" + timeout; + MD5 md5 = MD5.Create(); + string tmp1 = tmp; + tmp += "&PUB=" + pub32tr2; + byte[] buffer = Encoding.Default.GetBytes(tmp); + byte[] md5Buffer = md5.ComputeHash(buffer); + string strMd5 = ""; + //hdnOrderId.Value = orderid; + foreach (byte item in md5Buffer) + { + strMd5 += item.ToString("x2"); + } + string url = bankURL + "&" + tmp1 + "&MAC=" + strMd5; + string reJson = HttpMethods.Post(url); + LogEntity logEntity = new LogEntity(); + logEntity.F_CategoryId = 121; + logEntity.F_ExecuteResultJson = reJson; + logEntity.WriteLog(); + //HttpConnect conn = new HttpConnect(); + //string reJson = conn.Post(url, ""); + JsonBean MemberInfoList = JsonConvert.DeserializeObject(reJson); + if (MemberInfoList.SUCCESS.Equals("true")) + { + string imgCode = HttpMethods.Post(MemberInfoList.PAYURL); + logEntity.F_CategoryId = 121; + logEntity.F_ExecuteResultJson = imgCode; + logEntity.WriteLog(); + MemberInfoList = JsonConvert.DeserializeObject(imgCode); + if (MemberInfoList.SUCCESS.Equals("true")) + { + imgUrl = CreateQRImg(MemberInfoList.QRURL, orderid); + } + } + + if (!string.IsNullOrEmpty(imgUrl)) + { + model.orderid = orderid; + stuInfoFreshIBLL.SaveFeeData(keyValue, model, list); + } + + return Success(imgUrl); + } + + public class JsonBean + { + /// + /// + /// + public string SUCCESS { get; set; } + public string PAYURL { get; set; } + public string QRURL { get; set; } + } + /// + /// 生成并保存二维码图片的方法 + /// + /// 输入的内容 + public string CreateQRImg(string str, string orderId) + { + string QRCodeFile = Config.GetValue("QRCodeFile"); + Random ran = new Random(); + Bitmap bt; + str = HttpUtility.UrlDecode(str); + string enCodeString = str; + //生成设置编码实例 + QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); + //设置二维码的规模,默认4 + qrCodeEncoder.QRCodeScale = 3; + //设置二维码的版本,默认7 + qrCodeEncoder.QRCodeVersion = 7; + //设置错误校验级别,默认中等 + qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M; + //生成二维码图片 + bt = qrCodeEncoder.Encode(enCodeString, Encoding.UTF8); + //二维码图片的名称 + string filename = orderId; + if (!DirFileHelper.IsExistFile(QRCodeFile+"/Content/images/QRCode/")) + { + Directory.CreateDirectory(QRCodeFile + "/Content/images/QRCode/"); + } + var path = QRCodeFile + "/Content/images/QRCode/" + filename + ".jpg"; + //保存二维码图片在photos路径下 + try + { + bt.Save(path); + } + catch (Exception ex) + { + return ""; + } + + //图片控件要显示的二维码图片路径 + return QRCodeFile + "/Content/images/QRCode/" + filename + ".jpg"; + } + } +} \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/WeixinApi.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/WeixinApi.cs index ee3d82139..50306a2bc 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/WeixinApi.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/WeixinApi.cs @@ -36,6 +36,8 @@ namespace Learun.Application.WebApi.Modules Get["/weixinconfig"] = GetWeixinConfig; Post["/getweixinaccess_token"] = GetWeixinAccess_token; Post["/login"] = Login; + //新生首次登陆 + Post["/loginbyidcard"] = LoginByIdCard; Get["/getweixinwebaccess_token"] = GetWeixinWebaccess_token; //获取ACIp Get["/GetACIp"] = GetACIp; @@ -241,6 +243,77 @@ namespace Learun.Application.WebApi.Modules #endregion } + private Response LoginByIdCard(dynamic _) + { + LoginModel loginModel = this.GetReqData(); + + #region 内部账户验证 + UserEntity userEntity = userIbll.CheckLoginByIdCard(loginModel.username, loginModel.password); + + #region 写入日志 + LogEntity logEntity = new LogEntity(); + logEntity.F_CategoryId = 1; + logEntity.F_OperateTypeId = ((int)OperationType.Login).ToString(); + logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Login); + logEntity.F_OperateAccount = loginModel.username + "(" + userEntity.F_RealName + ")"; + logEntity.F_OperateUserId = !string.IsNullOrEmpty(userEntity.F_UserId) ? userEntity.F_UserId : loginModel.username; + logEntity.F_Module = Config.GetValue("SoftName"); + logEntity.F_Description = "移动端"; + #endregion + + if (!userEntity.LoginOk)//登录失败 + { + //写入日志 + logEntity.F_ExecuteResult = 0; + logEntity.F_ExecuteResultJson = "登录失败:" + userEntity.LoginMsg; + logEntity.WriteLog(); + return Fail(userEntity.LoginMsg); + } + else + { + ReqParameter req = this.Bind(); + string token = OperatorHelper.Instance.AddLoginUser(userEntity.F_Account, "Learun_ADMS_6.1_App", req.loginMark, false);//写入缓存信息 + //写入日志 + logEntity.F_ExecuteResult = 1; + logEntity.F_ExecuteResultJson = "登录成功"; + logEntity.WriteLog(); + OperatorResult res = OperatorHelper.Instance.IsOnLine(token, req.loginMark); + res.userInfo.password = null; + res.userInfo.secretkey = null; + var studententity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(userEntity.F_Account); + if (studententity != null) + { + res.userInfo.grade = studententity.Grade; + var majorinfo = majorIbll.GetCdMajorEntityByMajorNo(studententity.MajorNo); + if (majorinfo != null) + { + res.userInfo.majorno = majorinfo.ID ?? ""; + } + + } + //是否强密码验证 + bool pwd = false; + if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["verifypwd"]) && ConfigurationManager.AppSettings["verifypwd"] == "true" && loginModel.up == false) + { + pwd = true; + } + else + { + //保存用户设备号 + userIbll.UpdateWeixinOpenId(userEntity.F_UserId, loginModel.openid); + } + var jsonData = new + { + baseinfo = res.userInfo, + post = postIBLL.GetListByPostIds(res.userInfo.postIds), + role = roleIBLL.GetListByRoleIds(res.userInfo.roleIds), + pwd = pwd + }; + return Success(jsonData); + } + #endregion + } + public Response GetWeixinWebaccess_token(dynamic _) { var entity = weChatConfigIbll.GetEnableEntity(); diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/XmlConfig/system.config b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/XmlConfig/system.config index 0fac6f538..39f36d613 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/XmlConfig/system.config +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/XmlConfig/system.config @@ -66,6 +66,7 @@ + diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/packages.config b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/packages.config index b9d939563..05bbc23ba 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/packages.config +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/packages.config @@ -30,6 +30,7 @@ + \ No newline at end of file