private void Dingtalk_userid_validate_Test(HttpContext context) { StreamReader stream = new StreamReader(context.Request.InputStream); string payload = stream.ReadToEnd(); JObject jo = JObject.Parse(payload); if (jo == null || jo["code"] == null || string.IsNullOrWhiteSpace(jo["code"].ToString())) { context.Response.Write("{\"status\": 0, \"msg\": \"ParameterIsNull\"}"); return; } OapiGettokenResponse response = dingtalk_helper.GetDingTalkAccessToken(); string userid = dingtalk_helper.GetDingTalkUserid(jo["code"].ToString(), response.AccessToken); //context.Response.Write("{\"status\":2, \"msg\": \"UseridIsNoOauth\"}"); //return; //string userid = "wangyu"; //string userid = jo["oauth_userid"].ToString(); //如果为Null,退出 if (string.IsNullOrEmpty(userid)) { //context.Response.Write("{\"status\": 1, \"msg\": \"UseridIsNull\"}"); return; } BLL.manager_oauth bll = new BLL.manager_oauth(); Model.manager_oauth oauthModel = bll.GetModel("dingtalk", userid.Trim()); //查询数据库 if (oauthModel == null) { context.Response.Write("{\"status\":2, \"msg\": \"UseridIsNoOauth\"}"); return; } else { Model.manager model = new BLL.manager().GetModel(oauthModel.manager_id); //写入登录日志 Model.sysconfig sysConfig = new BLL.sysconfig().loadConfig(); if (sysConfig.logstatus > 0) { new BLL.manager_log().Add(model.id, model.user_name, DTEnums.ActionEnum.Login.ToString(), "用户登录钉钉平台"); } context.Response.Write("{\"status\": 3, \"msg\": \"success\",\"model\":" + JObject.FromObject(model) + "}"); return; } }
private void removeOauthBind(HttpContext context) { string username = DTRequest.GetFormString("username"); BLL.manager_oauth oauthBll = new BLL.manager_oauth(); Model.manager_oauth oauthModel = oauthBll.GetModel(username); if (oauthModel == null || oauthModel.is_lock == 0) { context.Response.Write("{\"status\": 0, \"msg\": \"该账号还未绑定钉钉\"}"); return; } if (oauthModel.is_lock == 1) { if (oauthBll.Delete(oauthModel.id)) { context.Response.Write("{\"status\": 1, \"msg\": \"移除绑定成功\"}"); return; } } context.Response.Write("{\"status\": 0, \"msg\": \"移除绑定失败\"}"); return; }
private void Manager_oauth_remove(HttpContext context) { StreamReader stream = new StreamReader(context.Request.InputStream); string payload = stream.ReadToEnd(); JObject jo = JObject.Parse(payload); if (jo == null || jo["code"] == null || string.IsNullOrWhiteSpace(jo["code"].ToString())) { context.Response.Write("{\"status\": 0, \"msg\": \"CodeIsNull\"}"); return; } //获取钉钉授权数据 OapiGettokenResponse response = dingtalk_helper.GetDingTalkAccessToken(); string userid = dingtalk_helper.GetDingTalkUserid(jo["code"].ToString(), response.AccessToken); BLL.manager_oauth oauthBll = new BLL.manager_oauth(); Model.manager_oauth oauthModel = oauthBll.GetModel("dingtalk", userid); if (oauthModel != null) { if (!oauthBll.UpdateField("dingtalk", userid, "is_lock=0")) { context.Response.Write("{\"status\": 0, \"msg\": \"解除用户授权失败,请联系技术支持处理!\"}"); return; } else { context.Response.Write("{\"status\": 1, \"msg\": \"解除用户授权成功\"}"); return; } } else { context.Response.Write("{\"status\": 0, \"msg\": \"该钉钉账户未授权或员工用户已不存在\"}"); return; } }
/// <summary> /// 付款明细审批 /// </summary> /// <param name="id"></param> /// <param name="type"></param> /// <param name="status"></param> /// <param name="remark"></param> /// <param name="username"></param> /// <param name="realname"></param> /// <returns></returns> public string checkPayDetailStatus(int id, byte?type, byte?status, string remark, Model.manager adminModel) { Model.ReceiptPayDetail model = GetModel(id); if (model == null) { return("数据不存在"); } string content = ""; //3.如果是财务审批,要先验证部门审批是否已经审批通过,不通过不能审批;如果是总经理审批,要先验证财务审批是否已经审批通过,不通过不能审批 //4.反审批时:a.总经理要先验证是否已经确认汇总。b.财务要先验证总经理是否已经审批通过。c.部门要先验证财务是否已经审批通过 switch (type) { case 1: //部门审批 if (model.rpd_flag1 == status) { return("状态未变更"); } //判断有没有部门审批权限 if (model.rpd_area != adminModel.area || !new permission().checkHasPermission(adminModel, "0603")) { return("无权限审批"); } if (status == 2) { //由待审批、审批未通过→审批通过 } else { //由审批通过→待审批、审批未通过:验证财务审批是否通过,审批通过的不能再做部门反审批 if (model.rpd_flag2 == 2) { return("财务已经审批通过,不能做部门审批"); } } content = "记录id:" + id + ",部门审批状态:" + Common.BusinessDict.checkStatus()[model.rpd_flag1] + "→<font color='red'>" + Common.BusinessDict.checkStatus()[status] + "</font>"; model.rpd_flag1 = status; model.rpd_checkNum1 = adminModel.user_name; model.rpd_checkName1 = adminModel.real_name; model.rpd_checkRemark1 = remark; model.rpd_checkTime1 = DateTime.Now; break; case 2: //财务审批 if (model.rpd_flag2 == status) { return("状态未改变"); } if (new BLL.department().getGroupArea() != adminModel.area || !new permission().checkHasPermission(adminModel, "0402")) { return("无权限审批"); } if (status == 2) { //由待审批、审批未通过→审批通过:验证部门审批是否存在待审批或审批未通过的记录,存在则不能做财务审批 if (model.rpd_flag1 != 2) { return("部门审批是待审批或审批未通过的,不能做财务审批"); } } else { //由审批通过→待审批、审批未通过:验证总经理审批是否通过,审批通过的不能再做财务反审批 if (model.rpd_flag3 == 2) { return("总经理已经审批通过,不能做财务审批"); } } content = "记录id:" + id + ",财务审批状态:" + Common.BusinessDict.checkStatus()[model.rpd_flag2] + "→<font color='red'>" + Common.BusinessDict.checkStatus()[status] + "</font>"; model.rpd_flag2 = status; model.rpd_checkNum2 = adminModel.user_name; model.rpd_checkName2 = adminModel.real_name; model.rpd_checkRemark2 = remark; model.rpd_checkTime2 = DateTime.Now; break; case 3: //总经理审批 if (model.rpd_flag3 == status) { return("状态未改变"); } if (new BLL.department().getGroupArea() != adminModel.area || !new permission().checkHasPermission(adminModel, "0601")) { return("无权限审批"); } if (status == 2) { //由待审批、审批未通过→审批通过:验证财务审批是否存在待审批或审批未通过的记录,存在则不能做总经理审批 if (model.rpd_flag2 != 2) { return("财务审批是待审批或审批未通过的,不能做总经理审批"); } } else { //由审批通过→待审批、审批未通过:验证是否已经汇总,已经汇总的不能做总经理审批 if (model.rpd_rpid > 0) { return("已经汇总,不能做总经理审批"); } } content = "记录id:" + id + ",总经理审批状态:" + Common.BusinessDict.checkStatus()[model.rpd_flag3] + "→<font color='red'>" + Common.BusinessDict.checkStatus()[status] + "</font>"; model.rpd_flag3 = status; model.rpd_checkNum3 = adminModel.user_name; model.rpd_checkName3 = adminModel.real_name; model.rpd_checkRemark3 = remark; model.rpd_checkTime3 = DateTime.Now; break; } if (dal.Update(model)) { //写日志 Model.business_log log = new Model.business_log(); log.ol_title = "审批付款明细"; log.ol_oid = model.rpd_oid; log.ol_cid = model.rpd_cid.Value; log.ol_relateID = id; string _content = content; log.ol_content = _content; new business_log().Add(DTEnums.ActionEnum.Audit.ToString(), log, adminModel.user_name, adminModel.real_name); //信息通知 //审批未通过、审批通过时通知 if (status == 1 || status == 2) { string replaceUser1 = ""; string nodeName = string.Empty; DataTable dt = null; string replaceContent = new BLL.Customer().GetModel(model.rpd_cid.Value).c_name + "," + model.rpd_money + "," + model.rpd_content + "," + model.rpd_oid; string replaceUser = adminModel.user_name + "," + adminModel.real_name; if (status == 1) { nodeName = "非业务付款通知部门审批、财务审批、总经理未通过"; } else { if (type == 3)//总经理审批完成 { nodeName = "非业务付款通知总经理审批通过"; } else { nodeName = "非业务付款通知部门审批、财务审批通过"; if (type == 1) { dt = new manager().getUserByPermission("0402").Tables[0]; } else { dt = new manager().getUserByPermission("0601").Tables[0]; } if (dt != null) { foreach (DataRow dr in dt.Rows) { replaceUser1 += dr["user_name"] + "(" + dr["real_name"] + "),"; } } replaceUser1 = replaceUser1.TrimEnd(','); } } //钉钉通知申请人 Model.manager_oauth oauthModel = new BLL.manager_oauth().GetModel(model.rpd_personNum); if (oauthModel != null && oauthModel.is_lock == 1 && !string.IsNullOrEmpty(oauthModel.oauth_userid)) { new BLL.selfMessage().sentDingMessage(nodeName, oauthModel.oauth_userid, replaceContent, replaceUser); } //通知下付款通知人 new BLL.selfMessage().AddMessage(nodeName, model.rpd_personNum, model.rpd_personName, replaceContent, replaceUser, replaceUser1); //通知下一级审批人 if (!string.IsNullOrEmpty(replaceUser1)) { foreach (DataRow dr in dt.Rows) { new BLL.selfMessage().AddMessage(nodeName, dr["user_name"].ToString(), dr["real_name"].ToString(), replaceContent, replaceUser, replaceUser1); //钉钉推送通知 if (!string.IsNullOrEmpty(Utils.ObjectToStr(dr["oauth_userid"]))) { new BLL.selfMessage().sentDingMessage(nodeName, dr["oauth_userid"].ToString(), replaceContent, replaceUser, replaceUser1); } } } } return(""); } return("操作失败"); }
/// <summary> /// 发票审批 /// </summary> /// <param name="id"></param> /// <param name="type"></param> /// <param name="status"></param> /// <param name="remark"></param> /// <param name="username"></param> /// <param name="realname"></param> /// <returns></returns> public string checkInvoiceStatus(int id, byte?type, byte?status, string remark, Model.manager adminModel) { Model.invoices model = GetModel(id); if (model == null) { return("数据不存在"); } string content = ""; //3.如果是开票区域审批,要先验证申请区域审批是否已经审批通过,不通过不能审批;如果是财务审批,要先验证开票区域审批是否已经审批通过,不通过不能审批 //4.反审批时:a.财务要先验证是否已经开票。b.开票区域要先验证财务是否已经审批通过。c.申请区域要先验证开票区域是否已经审批通过 switch (type) { case 1: //申请区域审批 if (model.inv_flag1 == status) { return("状态未变更"); } //判断有没有部门审批权限 if (model.inv_farea != adminModel.area || !new permission().checkHasPermission(adminModel, "0603")) { return("无权限审批"); } if (status == 2) { //由待审批、审批未通过→审批通过 //当申请区域和开票区域相同时,申请区域审批通过时,同时把开票区域审批通过 if (model.inv_farea == model.inv_darea) { model.inv_flag2 = status; model.inv_checkNum2 = adminModel.user_name; model.inv_checkName2 = adminModel.real_name; model.inv_checkRemark2 = remark; model.inv_checkTime2 = DateTime.Now; } } else { //由审批通过→待审批、审批未通过:验证开票区域审批是否通过,审批通过的不能再做申请区域反审批 if (model.inv_flag2 == 2) { return("开票区域已经审批通过,不能做申请区域审批"); } } content = "记录id:" + id + ",申请区域审批状态:" + Common.BusinessDict.checkStatus()[model.inv_flag1] + "→<font color='red'>" + Common.BusinessDict.checkStatus()[status] + "</font>"; model.inv_flag1 = status; model.inv_checkNum1 = adminModel.user_name; model.inv_checkName1 = adminModel.real_name; model.inv_checkRemark1 = remark; model.inv_checkTime1 = DateTime.Now; break; case 2: //开票区域审批 if (model.inv_flag2 == status) { return("状态未变更"); } //判断有没有部门审批权限 if (model.inv_darea != adminModel.area || !new permission().checkHasPermission(adminModel, "0603")) { return("无权限审批"); } if (status == 2) { //由待审批、审批未通过→审批通过:验证申请区域审批是否存在待审批或审批未通过的记录,存在则不能做开票区域审批 if (model.inv_flag1 != 2) { return("申请区域审批是待审批或审批未通过的,不能做开票区域审批"); } } else { //由审批通过→待审批、审批未通过:验证财务审批是否通过,审批通过的不能再做开票区域反审批 if (model.inv_flag3 == 2) { return("财务已经审批通过的,不能做开票区域审批"); } //当申请区域和开票区域相同时,开票区域反审批时,同时把申请区域反审批 if (model.inv_farea == model.inv_darea) { model.inv_flag1 = status; model.inv_checkNum1 = adminModel.user_name; model.inv_checkName1 = adminModel.real_name; model.inv_checkRemark1 = remark; model.inv_checkTime1 = DateTime.Now; } } content = "记录id:" + id + ",开票区域审批状态:" + Common.BusinessDict.checkStatus()[model.inv_flag2] + "→<font color='red'>" + Common.BusinessDict.checkStatus()[status] + "</font>"; model.inv_flag2 = status; model.inv_checkNum2 = adminModel.user_name; model.inv_checkName2 = adminModel.real_name; model.inv_checkRemark2 = remark; model.inv_checkTime2 = DateTime.Now; break; case 3: //财务审批 if (model.inv_flag3 == status) { return("状态未改变"); } if (new BLL.department().getGroupArea() != adminModel.area || !new permission().checkHasPermission(adminModel, "0402")) { return("无权限审批"); } if (status == 2) { //由待审批、审批未通过→审批通过:验证开票区域审批是否存在待审批或审批未通过的记录,存在则不能做财务审批 if (model.inv_flag2 != 2) { return("开票区域审批是待审批或审批未通过的,不能做财务审批"); } } else { //由审批通过→待审批、审批未通过:验证是否已经开票,已经开票的不能做财务审批 if (model.inv_isConfirm.Value) { return("已经开票,不能做财务审批"); } } content = "记录id:" + id + ",开票区域审批状态:" + Common.BusinessDict.checkStatus()[model.inv_flag3] + "→<font color='red'>" + Common.BusinessDict.checkStatus()[status] + "</font>"; model.inv_flag3 = status; model.inv_checkNum3 = adminModel.user_name; model.inv_checkName3 = adminModel.real_name; model.inv_checkRemark3 = remark; model.inv_checkTime3 = DateTime.Now; break; } if (dal.Update(model)) { //写日志 Model.business_log log = new Model.business_log(); log.ol_title = "审批发票申请"; log.ol_oid = model.inv_oid; log.ol_cid = model.inv_cid.Value; log.ol_relateID = id; string _content = content; log.ol_content = _content; new business_log().Add(DTEnums.ActionEnum.Audit.ToString(), log, adminModel.user_name, adminModel.real_name); //信息通知下申请通知人、业务员 if (status == 1) { string replaceContent = new BLL.Customer().GetModel(model.inv_cid.Value).c_name + "," + model.inv_money; string replaceUser = adminModel.user_name + "," + adminModel.real_name; new BLL.selfMessage().AddMessage("开票申请审批未通过", model.inv_personNum, model.inv_personName, replaceContent, replaceUser); //通知业务员 DataSet ds = new BLL.Order().GetPersonList(0, "op_oid='" + model.inv_oid + "' and op_type=1", ""); if (ds != null && ds.Tables[0].Rows.Count > 0) { new BLL.selfMessage().AddMessage("开票申请审批未通过", ds.Tables[0].Rows[0]["op_number"].ToString(), ds.Tables[0].Rows[0]["op_name"].ToString(), replaceContent, replaceUser); } //钉钉通知申请人 Model.manager_oauth oauthModel = new BLL.manager_oauth().GetModel(model.inv_personNum); if (oauthModel != null && oauthModel.is_lock == 1 && !string.IsNullOrEmpty(oauthModel.oauth_userid)) { new BLL.selfMessage().sentDingMessage("发票申请审批未通过", oauthModel.oauth_userid, replaceContent, replaceUser); } } //信息通知下申请通知人、业务员,如果是申请区域审批和开票区域审批 要通知下一级审批人 if (status == 2) { string replaceContent = new BLL.Customer().GetModel(model.inv_cid.Value).c_name + "," + model.inv_money; string replaceUser = adminModel.user_name + "," + adminModel.real_name; new BLL.selfMessage().AddMessage("开票申请审批通过1", model.inv_personNum, model.inv_personName, replaceContent, replaceUser); //钉钉通知申请人 Model.manager_oauth oauthModel = new BLL.manager_oauth().GetModel(model.inv_personNum); if (oauthModel != null && oauthModel.is_lock == 1 && !string.IsNullOrEmpty(oauthModel.oauth_userid)) { new BLL.selfMessage().sentDingMessage("发票申请审批通过", oauthModel.oauth_userid, replaceContent, replaceUser); } //通知业务员 DataSet ds = new BLL.Order().GetPersonList(0, "op_oid='" + model.inv_oid + "' and op_type=1", ""); if (ds != null && ds.Tables[0].Rows.Count > 0) { new BLL.selfMessage().AddMessage("开票申请审批通过1", ds.Tables[0].Rows[0]["op_number"].ToString(), ds.Tables[0].Rows[0]["op_name"].ToString(), replaceContent, replaceUser); } if (type == 1)//申请区域审批,审批通过要通知开票区域审批人 { if (model.inv_farea == model.inv_darea) { DataTable userDt = new BLL.manager().getUserByPermission("0402", new BLL.department().getGroupArea()).Tables[0]; if (userDt != null) { foreach (DataRow dr in userDt.Rows) { new BLL.selfMessage().AddMessage("开票申请审批通过2", dr["user_name"].ToString(), dr["real_name"].ToString(), replaceContent, replaceUser); //钉钉推送通知 if (!string.IsNullOrEmpty(Utils.ObjectToStr(dr["oauth_userid"]))) { new BLL.selfMessage().sentDingMessage("开票申请审批通过2", dr["oauth_userid"].ToString(), replaceContent, replaceUser); } } } } else { DataTable userDt = new BLL.manager().getUserByPermission("0603", model.inv_darea).Tables[0]; if (userDt != null) { foreach (DataRow dr in userDt.Rows) { new BLL.selfMessage().AddMessage("开票申请审批通过2", dr["user_name"].ToString(), dr["real_name"].ToString(), replaceContent, replaceUser); //钉钉推送通知 if (!string.IsNullOrEmpty(Utils.ObjectToStr(dr["oauth_userid"]))) { new BLL.selfMessage().sentDingMessage("开票申请审批通过2", dr["oauth_userid"].ToString(), replaceContent, replaceUser); } } } } } if (type == 2)//开票区域审批,审批通过要通知财务审批人 { DataTable userDt = new BLL.manager().getUserByPermission("0402", new BLL.department().getGroupArea()).Tables[0]; if (userDt != null) { foreach (DataRow dr in userDt.Rows) { new BLL.selfMessage().AddMessage("开票申请审批通过2", dr["user_name"].ToString(), dr["real_name"].ToString(), replaceContent, replaceUser); //钉钉推送通知 if (!string.IsNullOrEmpty(Utils.ObjectToStr(dr["oauth_userid"]))) { new BLL.selfMessage().sentDingMessage("开票申请审批通过2", dr["oauth_userid"].ToString(), replaceContent, replaceUser); } } } } } return(""); } return("操作失败"); }
private void Manager_oauth_bind(HttpContext context) { StreamReader stream = new StreamReader(context.Request.InputStream); string payload = stream.ReadToEnd(); JObject jo = JObject.Parse(payload); if (jo == null || jo["code"] == null || string.IsNullOrWhiteSpace(jo["code"].ToString())) { context.Response.Write("{\"status\": 0, \"msg\": \"CodeIsNull\"}"); return; } //检查用户名密码 if (jo["username"] == null || string.IsNullOrWhiteSpace(jo["username"].ToString())) { context.Response.Write("{\"status\": 0, \"msg\": \"用户名不能为空\"}"); return; } if (jo["password"] == null || string.IsNullOrWhiteSpace(jo["password"].ToString())) { context.Response.Write("{\"status\": 0, \"msg\": \"密码不能为空\"}"); return; } string username = jo["username"].ToString().ToUpper(); string password = jo["password"].ToString(); BLL.manager bll = new BLL.manager(); Model.manager model = bll.GetModel(username, password, true); if (model == null) { context.Response.Write("{\"status\":0, \"msg\":\"该员工账号不存在或密码不正确\"}"); return; } BLL.manager_oauth oauthBll = new BLL.manager_oauth(); Model.manager_oauth oauthModel1 = oauthBll.GetModel(username); if (oauthModel1 != null && oauthModel1.is_lock == 1) { context.Response.Write("{\"status\": 0, \"msg\": \"该账号已经绑定过钉钉,不能重复绑定\"}"); return; } //获取钉钉授权数据 OapiGettokenResponse response = dingtalk_helper.GetDingTalkAccessToken(); string userid = dingtalk_helper.GetDingTalkUserid(jo["code"].ToString(), response.AccessToken); Model.manager_oauth oauthModel = oauthBll.GetModel("dingtalk", userid.Trim()); if (oauthModel != null) { if (oauthModel.manager_name != username) { context.Response.Write("{\"status\":0, \"msg\":\"已经绑定了工号" + oauthModel.manager_name + ",要重新绑定须先解除绑定!\"}"); return; } oauthModel.manager_id = model.id; oauthModel.manager_name = model.user_name; oauthModel.oauth_access_token = response.AccessToken; oauthModel.is_lock = 1; if (!oauthBll.Update(oauthModel)) { context.Response.Write("{\"status\":0, \"msg\":\"绑定用户授权失败,请联系技术支持处理!\"}"); return; } } else { //开始绑定 oauthModel = new Model.manager_oauth(); oauthModel.oauth_name = "dingtalk"; oauthModel.manager_id = model.id; oauthModel.manager_name = model.user_name; oauthModel.oauth_access_token = response.AccessToken; oauthModel.oauth_userid = userid; oauthModel.is_lock = 1; int newId = oauthBll.Add(oauthModel); if (newId < 1) { context.Response.Write("{\"status\":0, \"msg\":\"绑定用户授权失败,请联系技术支持处理!\"}"); return; } } //写入登录日志 Model.sysconfig sysConfig = new BLL.sysconfig().loadConfig(); if (sysConfig.logstatus > 0) { new BLL.manager_log().Add(model.id, model.user_name, DTEnums.ActionEnum.Login.ToString(), "用户授权绑定钉钉平台"); } //返回实体类 context.Response.Write("{\"status\": 1, \"msg\": \"success\",\"model\":" + JObject.FromObject(model) + "}"); return; }
/// <summary> /// 审批非业务支付申请状态 /// </summary> /// <param name="id">记录ID</param> /// <param name="type">1部门审批,2财务审批,3总经理审批</param> /// <param name="status">0待审批,1审批未通过,2审批通过</param> /// <param name="remark">备注</param> /// <param name="username">操作人工号</param> /// <param name="realname">操作人姓名</param> /// <returns></returns> public string checkStatus(int id, byte?type, byte?status, string checkMoney, string remark, Model.manager adminModel) { Model.unBusinessApply model = GetModel(id); if (model == null) { return("记录不存在"); } //如果是员工往来,要验证对应的订单是否已经锁单,锁单的不能再审批 if (model.uba_type == 0 && !string.IsNullOrEmpty(model.uba_oid)) { Model.Order order = new BLL.Order().GetModel(model.uba_oid); if (order != null && order.o_lockStatus == 1) { return("订单已锁单,不能再审批"); } } //批复金额 decimal _checkmoney = 0, _oldmoney = model.uba_money.Value; string addremark = string.Empty, ubmlRemark = string.Empty; Model.unBusinessMoneyLog mlog = null; int ubmlID = 0; if (model.uba_function == "业务活动执行备用金借款" && !string.IsNullOrEmpty(checkMoney) && status == 2) { if (!decimal.TryParse(checkMoney, out _checkmoney)) { return("请正确填写批复金额"); } else { if (_checkmoney <= 0 || _checkmoney >= model.uba_money) { return("批复金额需大于0且小于申请金额(" + model.uba_money + ")"); } else { mlog = new Model.unBusinessMoneyLog(); mlog.ubml_ubaid = model.uba_id; mlog.ubml_newMoney = _checkmoney; mlog.ubml_oldMoney = model.uba_money; mlog.ubml_date = DateTime.Now; mlog.ubml_username = adminModel.user_name; mlog.ubml_realname = adminModel.real_name; addremark = "批复借款金额由原" + model.uba_money + "元改为" + _checkmoney + "元;"; model.uba_money = _checkmoney; } } } string content = ""; //3.如果是财务审批,要先验证部门审批是否已经审批通过,不通过不能审批;如果是总经理审批,要先验证财务审批是否已经审批通过,不通过不能审批 //4.反审批时:a.总经理要先验证是否已经确认支付。b.财务要先验证总经理是否已经审批通过。c.部门要先验证财务是否已经审批通过 switch (type) { case 1: //部门审批 if (model.uba_flag1 == status) { return("状态未改变"); } //判断有没有部门审批权限 if (model.uba_area != adminModel.area || !new permission().checkHasPermission(adminModel, "0603")) { return("无权限审批"); } content = "记录id:" + id + ",部门审批状态:" + Common.BusinessDict.checkStatus()[model.uba_flag1] + "→<font color='red'>" + Common.BusinessDict.checkStatus()[status] + "</font>"; model.uba_flag1 = status; model.uba_checkNum1 = adminModel.user_name; model.uba_checkName1 = adminModel.real_name; model.uba_checkRemark1 = remark; model.uba_checkTime1 = DateTime.Now; if (status == 2) { //由待审批、审批未通过→审批通过 //存在批复金额 if (model.uba_function == "业务活动执行备用金借款" && mlog != null) { mlog.ubml_type = 1; mlog.ubml_remark = "部门审批" + addremark; model.uba_checkRemark1 += "部门审批" + addremark; } } else { //由审批通过→待审批、审批未通过:验证财务审批是否通过,审批通过的不能再做部门反审批 if (model.uba_flag2 == 2) { return("财务已经审批通过,不能做部门审批"); } if (model.uba_function == "业务活动执行备用金借款") { //检查部门审批是否存在批复记录,存在则退回原来的金额 ubmlID = getOldMoney(model, 1, out ubmlRemark); if (!string.IsNullOrEmpty(ubmlRemark)) { model.uba_checkRemark1 = model.uba_checkRemark1.Replace(ubmlRemark, ""); } } } break; case 2: //财务审批 if (model.uba_flag2 == status) { return("状态未改变"); } if (new BLL.department().getGroupArea() != adminModel.area || !new permission().checkHasPermission(adminModel, "0402")) { return("无权限审批"); } content = "记录id:" + id + ",财务审批状态:" + Common.BusinessDict.checkStatus()[model.uba_flag2] + "→<font color='red'>" + Common.BusinessDict.checkStatus()[status] + "</font>"; model.uba_flag2 = status; model.uba_checkNum2 = adminModel.user_name; model.uba_checkName2 = adminModel.real_name; model.uba_checkRemark2 = remark; model.uba_checkTime2 = DateTime.Now; if (status == 2) { //由待审批、审批未通过→审批通过:验证部门审批是否存在待审批或审批未通过的记录,存在则不能做财务审批 if (model.uba_flag1 != 2) { return("部门审批是待审批或审批未通过的,不能做财务审批"); } //存在批复金额 if (model.uba_function == "业务活动执行备用金借款" && mlog != null) { mlog.ubml_type = 2; mlog.ubml_remark = "财务审批" + addremark; model.uba_checkRemark2 += "财务审批" + addremark; } } else { //由审批通过→待审批、审批未通过:验证总经理审批是否通过,审批通过的不能再做财务反审批 if (model.uba_flag3 == 2) { return("总经理已经审批通过,不能做财务审批"); } if (model.uba_function == "业务活动执行备用金借款") { //检查部门审批是否存在批复记录,存在则退回原来的金额 ubmlID = getOldMoney(model, 2, out ubmlRemark); if (!string.IsNullOrEmpty(ubmlRemark)) { model.uba_checkRemark2 = model.uba_checkRemark2.Replace(ubmlRemark, ""); } } } break; case 3: //总经理审批 if (model.uba_flag3 == status) { return("状态未改变"); } if (new BLL.department().getGroupArea() != adminModel.area || !new permission().checkHasPermission(adminModel, "0601")) { return("无权限审批"); } content = "记录id:" + id + ",总经理审批状态:" + Common.BusinessDict.checkStatus()[model.uba_flag3] + "→<font color='red'>" + Common.BusinessDict.checkStatus()[status] + "</font>"; model.uba_flag3 = status; model.uba_checkNum3 = adminModel.user_name; model.uba_checkName3 = adminModel.real_name; model.uba_checkRemark3 = remark; model.uba_checkTime3 = DateTime.Now; if (status == 2) { //由待审批、审批未通过→审批通过:验证财务审批是否存在待审批或审批未通过的记录,存在则不能做总经理审批 if (model.uba_flag2 != 2) { return("财务审批是待审批或审批未通过的,不能做总经理审批"); } //存在批复金额 if (model.uba_function == "业务活动执行备用金借款" && mlog != null) { mlog.ubml_type = 3; mlog.ubml_remark = "总经理审批" + addremark; model.uba_checkRemark3 += "总经理审批" + addremark; } } else { //由审批通过→待审批、审批未通过:验证是否已经确认支付,已经确认支付的不能做总经理审批 if (model.uba_isConfirm.Value) { return("已经确认支付,不能做总经理审批"); } if (model.uba_function == "业务活动执行备用金借款") { //检查部门审批是否存在批复记录,存在则退回原来的金额 ubmlID = getOldMoney(model, 3, out ubmlRemark); if (!string.IsNullOrEmpty(ubmlRemark)) { model.uba_checkRemark3 = model.uba_checkRemark3.Replace(ubmlRemark, ""); } } } break; } if (dal.Update(model)) { //写日志 Model.business_log log = new Model.business_log(); log.ol_title = "审批非业务支付申请状态"; log.ol_content = content; new business_log().Add(DTEnums.ActionEnum.Audit.ToString(), log, adminModel.user_name, adminModel.real_name); //插入批复金额记录 if (mlog != null) { new unBusinessMoneyLog().Add(mlog); } //删除已经批复的记录 if (ubmlID > 0) { new unBusinessMoneyLog().Delete(ubmlID); } #region 审批未通过、审批通过时通知 if (status == 1 || status == 2) { string replaceUser1 = ""; string nodeName = string.Empty; DataTable dt = null; string replaceContent = model.uba_money + "," + model.uba_function; string replaceUser = adminModel.user_name + "," + adminModel.real_name; if (status == 1) { nodeName = "非业务付款通知部门审批、财务审批、总经理未通过"; } else { if (type == 3)//总经理审批完成 { nodeName = "非业务付款通知总经理审批通过"; } else { nodeName = "非业务付款通知部门审批、财务审批通过"; if (type == 1) { dt = new manager().getUserByPermission("0402").Tables[0]; } else { dt = new manager().getUserByPermission("0601").Tables[0]; } if (dt != null) { foreach (DataRow dr in dt.Rows) { replaceUser1 += dr["user_name"] + "(" + dr["real_name"] + "),"; } } replaceUser1 = replaceUser1.TrimEnd(','); } } //钉钉通知申请人 Model.manager_oauth oauthModel = new BLL.manager_oauth().GetModel(model.uba_PersonNum); if (oauthModel != null && oauthModel.is_lock == 1 && !string.IsNullOrEmpty(oauthModel.oauth_userid)) { new BLL.selfMessage().sentDingMessage(nodeName, oauthModel.oauth_userid, replaceContent, replaceUser); } //通知下付款通知人 new BLL.selfMessage().AddMessage(nodeName, model.uba_PersonNum, model.uba_personName, replaceContent, replaceUser, replaceUser1); //通知下一级审批人 if (!string.IsNullOrEmpty(replaceUser1)) { foreach (DataRow dr in dt.Rows) { new BLL.selfMessage().AddMessage(nodeName, dr["user_name"].ToString(), dr["real_name"].ToString(), replaceContent, replaceUser, replaceUser1); //钉钉推送通知 if (!string.IsNullOrEmpty(Utils.ObjectToStr(dr["oauth_userid"]))) { new BLL.selfMessage().sentDingMessage(nodeName, dr["oauth_userid"].ToString(), replaceContent, replaceUser, replaceUser1); } } } } #endregion return(""); } return("操作失败"); }
/// <summary> /// 审批付款 /// </summary> /// <param name="id"></param> /// <param name="status"></param> /// <param name="remark"></param> /// <param name="username"></param> /// <param name="realname"></param> /// <returns></returns> public string checkPay(int id, byte?type, byte?status, string remark, Model.manager manager) { Model.ReceiptPay model = GetModel(id); if (model == null) { return("数据不存在"); } if (!model.rp_isExpect.Value && model.rp_money >= 0) { return("非预付款不需要做审批"); } string content = ""; //3.如果是总经理审批,要先验证财务审批是否已经审批通过,不通过不能审批 //4.反审批时:a.总经理要先验证是否已经确认付款。b.财务要先验证总经理是否已经审批通过。 switch (type) { case 1: //财务审批 if (model.rp_flag == status) { return("状态未改变"); } if (new BLL.department().getGroupArea() != manager.area || !new permission().checkHasPermission(manager, "0402")) { return("无权限审批"); } if (status == 2) { } else { //由审批通过→待审批、审批未通过:验证总经理审批是否通过,审批通过的不能再做财务反审批 if (model.rp_flag1 == 2) { return("总经理已经审批通过,不能做财务审批"); } } content = "记录id:" + id + ",财务审批状态:" + Common.BusinessDict.checkStatus()[model.rp_flag] + "→<font color='red'>" + Common.BusinessDict.checkStatus()[status] + "</font>"; model.rp_flag = status; model.rp_checkNum = manager.user_name; model.rp_checkName = manager.real_name; model.rp_checkRemark = remark; model.rp_checkTime = DateTime.Now; break; case 2: //总经理审批 if (model.rp_flag1 == status) { return("状态未改变"); } if (new BLL.department().getGroupArea() != manager.area || !new permission().checkHasPermission(manager, "0601")) { return("无权限审批"); } if (status == 2) { //由待审批、审批未通过→审批通过:验证财务审批是否存在待审批或审批未通过的记录,存在则不能做总经理审批 if (model.rp_flag != 2) { return("财务审批是待审批或审批未通过的,不能做总经理审批"); } } else { //由审批通过→待审批、审批未通过:验证是否已经汇总,已经汇总的不能做总经理审批 if (model.rp_isConfirm.Value) { return("已经确认付款,不能做总经理审批"); } } content = "记录id:" + id + ",总经理审批状态:" + Common.BusinessDict.checkStatus()[model.rp_flag1] + "→<font color='red'>" + Common.BusinessDict.checkStatus()[status] + "</font>"; model.rp_flag1 = status; model.rp_checkNum1 = manager.user_name; model.rp_checkName1 = manager.real_name; model.rp_checkRemark1 = remark; model.rp_checkTime1 = DateTime.Now; break; } if (dal.Update(model)) { //写日志 Model.business_log log = new Model.business_log(); log.ol_title = "审批付款"; log.ol_cid = model.rp_cid.Value; log.ol_relateID = id; string _content = content; log.ol_content = _content; new business_log().Add(DTEnums.ActionEnum.Audit.ToString(), log, manager.user_name, manager.real_name); string payTypeName = "预付款"; if (model.rp_money < 0) { payTypeName = "退款"; } if (status == 1 || status == 2) { string nodeName = status == 2 ? "" + payTypeName + "审批通过" : "" + payTypeName + "审批未通过"; string replaceContent = new BLL.Customer().GetModel(model.rp_cid.Value).c_name + "," + model.rp_money + "," + model.rp_content; string replaceUser = manager.user_name + "," + manager.real_name; //钉钉通知申请人 Model.manager_oauth oauthModel = new BLL.manager_oauth().GetModel(model.rp_personNum); if (oauthModel != null && oauthModel.is_lock == 1 && !string.IsNullOrEmpty(oauthModel.oauth_userid)) { new BLL.selfMessage().sentDingMessage(nodeName, oauthModel.oauth_userid, replaceContent, replaceUser); } } if (type == 1 && status == 2) { //信息通知 DataTable dt = dt = new manager().getUserByPermission("0601").Tables[0]; string replaceContent = new BLL.Customer().GetModel(model.rp_cid.Value).c_name + "," + model.rp_money + "," + model.rp_content; string replaceUser = manager.user_name + "," + manager.real_name; if (dt != null) { foreach (DataRow dr in dt.Rows) { //钉钉推送通知 if (!string.IsNullOrEmpty(Utils.ObjectToStr(dr["oauth_userid"]))) { new BLL.selfMessage().sentDingMessage("" + payTypeName + "财务审批通过", dr["oauth_userid"].ToString(), replaceContent, replaceUser); } } } } return(""); } return("操作失败"); }