/// <summary> /// /// </summary> /// <param name="area"></param> /// <returns></returns> public string getNewUserName(string area) { if (string.IsNullOrEmpty(area)) { return(""); } string username = string.Empty;// dal.getLastUserName(area); DataSet ds = new manager().GetList(0, "area='" + area + "' and user_name like '" + area + "%'", "user_name"); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { int n = 0, num = 0; string nextNum = string.Empty; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { n = Utils.ObjToInt(Utils.ObjectToStr(ds.Tables[0].Rows[i]["user_name"]).Substring(2)); //下一个工号 nextNum = getUsernameByNum(n + 1, area); if (ds.Tables[0].Select("user_name='" + nextNum + "'").Length > 0) { continue; } else { num = n + 1; break; } //if (n != i + 1) //{ // num = i + 1; //} //else //{ // //最后一个也没匹配,则在最后一个上加1生成新的工号 // if (i == ds.Tables[0].Rows.Count-1 && string.IsNullOrEmpty(username)) // { // n = Utils.ObjToInt(Utils.ObjectToStr(ds.Tables[0].Rows[i]["user_name"]).Substring(2)); // num = n + 1; // } //} } username = getUsernameByNum(num, area); } if (string.IsNullOrEmpty(username)) { return(area + "001"); } return(username); }
/// <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">记录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("操作失败"); }