コード例 #1
0
ファイル: mPrepaid.aspx.cs プロジェクト: ycyreddevil/yelioa
    protected void Page_Load(object sender, EventArgs e)
    {
        WxNetSalesHelper wx  = new WxNetSalesHelper("http://yelioa.top/mSalesReport.aspx");
        string           res = wx.CheckAndGetUserInfo(HttpContext.Current);

        if (res != "success")
        {
            Response.Clear();
            Response.Write("<script language='javascript'>alert('" + res + "')</script>");
            Response.End();
            return;
        }

        string action = Request.Form["act"];

        if (!string.IsNullOrEmpty(action))
        {
            Response.Clear();
            if (action == "getPrepaidData")
            {
                Response.Write(getPrepaidData());
            }
            else if (action == "updatePrepaidData")
            {
                Response.Write(updatePrepaidData());
            }

            Response.End();
        }
    }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        WxNetSalesHelper wx  = new WxNetSalesHelper("http://yelioa.top/mNetSalesApproval.aspx");
        string           res = wx.CheckAndGetUserInfo(HttpContext.Current);

        if (res != "success")
        {
            Response.Clear();
            Response.Write("<script language='javascript'>alert('" + res + "')</script>");
            Response.End();
            return;
        }

        String action = Request.Params["act"];

        if (!string.IsNullOrEmpty(action))
        {
            Response.Clear();
            if (action == "getDatalist")
            {
                Response.Write(getDataList());
            }
            else if (action == "getProcessInfo")
            {
                Response.Write(getProcessInfo());
            }
            else if (action == "getProcessStage")
            {
                Response.Write(getProcessStage());
            }
            else if (action == "getDetails")
            {
                Response.Write(getDetails());
            }
            else if (action == "getApprovalRecord")
            {
                Response.Write(getApprovalRecord());
            }
            else if (action == "beginApproval")
            {
                Response.Write(beginApproval());
            }
            else if (action == "getSubDataList")
            {
                Response.Write(getSubDataList());
            }
            else if (action == "returnDocument")
            {
                Response.Write(returnDocument());
            }
            Response.End();
        }
    }
コード例 #3
0
    public static string SubmitDocument(string table, string docCode, UserInfo user, string url1, string url2,
                                        string appSecret, string thisAppName, string agentId)
    {
        string  res = "";
        DataSet ds  = ApprovalFlowSrv.GetDocumentInfo(table, docCode, ref res);

        if (ds == null)//出错,返回错误信息
        {
            return("获取单据信息出错,错误信息:" + res);
        }

        if (ds.Tables[0].Rows.Count > 0 && ds.Tables[2].Rows.Count > 0)
        {
            return("该单据已提交,请勿重复提交");
        }
        //保存审批记录信息
        Dictionary <string, string> dict = new Dictionary <string, string>();
        SqlExceRes sqlRes = new SqlExceRes(ApprovalFlowSrv.SubmitDocumentSaveRecord(user, ds, ref dict));

        res = sqlRes.GetResultString("提交成功!", "该单据已提交,请勿重复提交!");
        if (res != "提交成功!")
        {
            return("提交单据出错,错误信息:" + res);
        }
        //保存所有审批人信息
        JArray listApproverInfo = null;//所有审批人信息

        ApprovalFlowSrv.SaveAllApproverInfo(user, ds, dict, ref listApproverInfo);

        //更新单据状态,state="审批中",level=1
        res = ApprovalFlowSrv.UpdateDocStatus(table, docCode, "审批中", 1);

        DataSet userDs = ApprovalFlowSrv.GetUserInfoByUserId(
            ApprovalFlowSrv.GetApproverIddByLevel(1, listApproverInfo));

        string approverIds = "";

        foreach (DataTable dt in userDs.Tables)
        {
            approverIds += dt.Rows[0]["wechatUserId"].ToString() + "|";
        }
        approverIds = approverIds.Substring(0, approverIds.Length - 1);

        WxNetSalesHelper wxNetSalesHelper = new WxNetSalesHelper(appSecret, thisAppName, agentId);

        //// 给待审批人发送消息
        //wxNetSalesHelper.GetJsonAndSendWxMsg(approverIds, "请及时审批 提交人为:" + user.userName
        //    + "的单据,谢谢!", url2, agentId);
        //// 给提交人发送消息
        wxNetSalesHelper.GetJsonAndSendWxMsg(user.wechatUserId, "您的审批单据已提交 请耐心等待审批人审批", url1, agentId);

        return(res);
    }
コード例 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        WxNetSalesHelper wx  = new WxNetSalesHelper("http://yelioa.top/mNetSalesApproval.aspx");
        string           res = wx.CheckAndGetUserInfo(HttpContext.Current);

        if (res != "success")
        {
            Response.Clear();
            Response.Write("<script language='javascript'>alert('" + res + "')</script>");
            Response.End();
            return;
        }
        string action = Request.Form["act"];

        if (!string.IsNullOrEmpty(action))
        {
            Response.Clear();
            if ("getData".Equals(action))
            {
                Response.Write(getData());
            }
            else if ("saveData".Equals(action))
            {
                Response.Write(saveData());
            }
            else if ("getExcel".Equals(action))
            {
                Response.Write(getExcel());
            }
            else if ("importExcel".Equals(action))
            {
                Response.Write(importExcel());
            }
            else if ("getSector".Equals(action))
            {
                Response.Write(getSector());
            }
            Response.End();
        }
    }
コード例 #5
0
    private string submit()
    {
        List <string>  codeList    = JsonHelper.DeserializeJsonToList <string>(Request.Params["code"]);
        List <JObject> receiptList = JsonHelper.DeserializeJsonToList <JObject>(Request.Params["receipt"]);
        string         batchNo     = Request.Form["batchNo"].ToString();
        string         receiptDesc = Request.Form["receiptDesc"].ToString();

        JObject result = new JObject(); // 返回结果jobject

        string codeString = "";

        foreach (string code in codeList)
        {
            codeString += code + ",";
        }

        double totalReceiptAmount = 0.0;

        Boolean isReSubmit = false;

        // 生成批次号
        if (string.IsNullOrEmpty(batchNo))
        {
            batchNo = Guid.NewGuid().ToString("N");
        }
        else
        {
            isReSubmit = true;
        }

        foreach (JObject temp in receiptList)
        {
            temp["code"]        = codeString;
            temp["status"]      = "已提交";
            temp["createTime"]  = DateTime.Now;
            temp["batchNo"]     = batchNo;
            temp["receiptDesc"] = receiptDesc;
            temp["submitterId"] = userInfo.userId.ToString();

            DataTable dt = new DataTable();

            // 发票公司税号校验
            if (!string.IsNullOrEmpty(temp["sellerRegisterNum"].ToString()))
            {
                string sellerRegisterNum = temp["sellerRegisterNum"].ToString();

                string checkRegisterNumSql = string.Format("select 1 from company_register_num t1 left join yl_reimburse t2 on t1.companyName = t2.fee_company " +
                                                           "where t1.registerNum = '{0}' and t2.code = '{1}'", sellerRegisterNum, codeString.Split(',')[0]);

                DataTable checkRegisterNumTable = SqlHelper.Find(checkRegisterNumSql).Tables[0];

                if (checkRegisterNumTable.Rows.Count == 0)
                {
                    result.Add("code", 400);
                    result.Add("msg", string.Format("发票税号:{0},与所选公司不匹配!", sellerRegisterNum));

                    return(result.ToString());
                }
            }

            // 发票查重
            if (temp["receiptCode"].ToString() != "" && temp["receiptCode"].ToString() != "")
            {
                string checkDuplicateSql = string.Format("select 1 from yl_reimburse_detail where receiptCode = '{0}' and receiptNum = '{1}' and status != '拒绝' and status != '草稿'", temp["receiptCode"], temp["receiptNum"]);

                DataTable checkDuplicateDt = SqlHelper.Find(checkDuplicateSql).Tables[0];

                if (checkDuplicateDt.Rows.Count > 0)
                {
                    result.Add("code", 400);
                    result.Add("msg", string.Format("发票代码:{0},发票号码:{1},此发票重复使用!", temp["receiptCode"], temp["receiptNum"]));

                    return(result.ToString());
                }
            }

            // 发票验真伪
            if (temp["feeType"] != null && (temp["feeType"].ToString() == "出租车票" || temp["feeType"].ToString() == "通用机打发票" ||
                                            temp["feeType"].ToString() == "定额发票" || temp["feeType"].ToString() == "汽车票") && temp["receiptNum"].ToString() != temp["receiptCode"].ToString())
            {
                string province = temp["receiptPlace"].ToString();

                if (!province.Contains("北京") && !province.Contains("上海") && !province.Contains("天津") && !province.Contains("重庆"))
                {
                    province = province.Substring(0, province.IndexOf("省"));
                }

                string validateMsg = "";

                if (province == "江西")
                {
                    //validateMsg = ReceiptValidate.JxHandWriting(temp["receiptNum"].ToString(), temp["receiptCode"].ToString());

                    //JObject tempJObject = JObject.Parse(validateMsg);

                    //if (tempJObject.Property("LX") == null || tempJObject.Property("LX").ToString() == "")
                    //{
                    //    result.Add("code", 400);
                    //    result.Add("msg", string.Format("发票代码:{0},发票号码:{1},此发票与税务机关信息不符,请确定发票代码和发票号码后重新提交!", temp["receiptCode"], temp["receiptNum"]));

                    //    return result.ToString();
                    //}
                }
                else if (province == "湖南")
                {
                    validateMsg = ReceiptValidate.HnQuotaInvoice(temp["receiptCode"].ToString(), temp["receiptNum"].ToString());

                    JObject tempJObject = JObject.Parse(validateMsg);

                    if (tempJObject["status"].ToString() == "0")
                    {
                        result.Add("code", 400);
                        result.Add("msg", string.Format("发票代码:{0},发票号码:{1},此发票与税务机关信息不符,请确定发票代码和发票号码后重新提交!", temp["receiptCode"], temp["receiptNum"]));

                        return(result.ToString());
                    }
                }
            }

            // 费用标准控制
            UserInfo user = (UserInfo)Session["user"];

            if (user.userName != "李茂龙")
            {
                string temp_sql = string.Format("select post from users where userId = '{0}';", user.userId);

                string relativePerson = temp["relativePerson"].ToString();
                temp_sql += string.Format("select post from users where userName = '******';", relativePerson);
                temp_sql += string.Format("select department from v_user_department_post where userId = '{0}'", user.userId);

                DataSet ds = SqlHelper.Find(temp_sql);

                dt = ds.Tables[0];

                if (dt != null && dt.Rows.Count > 0)
                {
                    string startTm       = temp["activityDate"].ToString();
                    string endTm         = string.IsNullOrEmpty(temp["activityEndDate"].ToString()) ? temp["activityDate"].ToString() : temp["activityEndDate"].ToString();
                    string post          = dt.Rows[0][0].ToString();
                    double receiptAmount = double.Parse(temp["receiptAmount"].ToString());

                    DateTime d1 = Convert.ToDateTime(endTm);
                    DateTime d2 = Convert.ToDateTime(startTm);

                    DateTime d3 = Convert.ToDateTime(string.Format("{0}-{1}-{2}", d1.Year, d1.Month, d1.Day));
                    DateTime d4 = Convert.ToDateTime(string.Format("{0}-{1}-{2}", d2.Year, d2.Month, d2.Day));

                    double interval_time = (d3 - d4).Days + 1;
                    //double interval_time = Convert.ToDateTime(endTm).Subtract(Convert.ToDateTime(startTm)).Days + 1;    ///// 差旅费算头算尾

                    int endHour   = Convert.ToDateTime(endTm).Hour;
                    int startHour = Convert.ToDateTime(startTm).Hour;

                    if (endHour <= 12)
                    {
                        interval_time -= 0.5;
                    }
                    if (startHour >= 12 && startHour <= 18)
                    {
                        interval_time -= 0.5;
                    }
                    else if (startHour > 18)
                    {
                        interval_time -= 1;
                    }

                    // 此处实报实销和出差补贴是反的 方便页面显示
                    if (temp["receiptType"].ToString() == "实报实销")
                    {
                        dt = ds.Tables[2];

                        string userDepartmentName = dt.Rows[0][0].ToString();

                        if (userDepartmentName.Contains("营销中心"))
                        {
                            if (!post.Contains("经理") && !post.Contains("总监") && !post.Contains("副总经理") && !post.Contains("总经理"))
                            {
                                if (receiptAmount > 80 * interval_time)
                                {
                                    result.Add("code", 400);
                                    result.Add("msg", "出差补贴不能超过一天80");

                                    return(result.ToString());
                                }
                            }
                            else
                            {
                                if (receiptAmount > 150 * interval_time)
                                {
                                    result.Add("code", 400);
                                    result.Add("msg", "出差补贴不能超过一天150");

                                    return(result.ToString());
                                }
                            }
                        }
                        else
                        {
                            if (receiptAmount > 80 * interval_time)
                            {
                                result.Add("code", 400);
                                result.Add("msg", "出差补贴不能超过一天80");

                                return(result.ToString());
                            }
                        }
                    }
                    else if (temp["receiptType"].ToString() == "住宿费")
                    {
                        // 比较提交人的岗位和同行人的岗位 按大的计算
                        dt = ds.Tables[1];

                        if (dt != null && dt.Rows.Count > 0)
                        {
                            string relativePost = dt.Rows[0][0].ToString();

                            if (relativePost == "总经理")
                            {
                                post = "总经理";
                            }
                            else if (relativePost == "副总经理")
                            {
                                if (post != "总经理")
                                {
                                    post = relativePost;
                                }
                            }
                            else if (relativePost.Contains("总监"))
                            {
                                if (post != "总经理" && post != "副总经理")
                                {
                                    post = relativePost;
                                }
                            }
                            else if (relativePost.Contains("经理"))
                            {
                                if (post != "总经理" && post != "副总经理" && !post.Contains("总监"))
                                {
                                    post = relativePost;
                                }
                            }
                            else if (relativePost.Contains("主管"))
                            {
                                if (post != "总经理" && post != "副总经理" && !post.Contains("总监") && !post.Contains("经理"))
                                {
                                    post = relativePost;
                                }
                            }
                            else
                            {
                                post = relativePost;
                            }
                        }

                        // 住宿费算头不算尾
                        //interval_time = Convert.ToDateTime(endTm).Subtract(Convert.ToDateTime(startTm)).Days;

                        d1 = Convert.ToDateTime(endTm);
                        d2 = Convert.ToDateTime(startTm);

                        d3 = Convert.ToDateTime(string.Format("{0}-{1}-{2}", d1.Year, d1.Month, d1.Day));
                        d4 = Convert.ToDateTime(string.Format("{0}-{1}-{2}", d2.Year, d2.Month, d2.Day));

                        interval_time = (d3 - d4).Days;

                        if (post.Contains("总经理"))
                        {
                        }
                        else if (post.Contains("副总经理"))
                        {
                            if (checkCityLevel(temp["receiptPlace"].ToString()) == "1" || checkCityLevel(temp["receiptPlace"].ToString()) == "2")
                            {
                                if (receiptAmount > 360 * interval_time)
                                {
                                    result.Add("code", 400);
                                    result.Add("msg", "住宿费不能超过一晚360");

                                    return(result.ToString());
                                }
                            }
                            else if (checkCityLevel(temp["receiptPlace"].ToString()) == "3" || checkCityLevel(temp["receiptPlace"].ToString()) == "4")
                            {
                                if (receiptAmount > 280 * interval_time)
                                {
                                    result.Add("code", 400);
                                    result.Add("msg", "住宿费不能超过一晚280");

                                    return(result.ToString());
                                }
                            }
                        }
                        else if (post.Contains("总监"))
                        {
                            if (checkCityLevel(temp["receiptPlace"].ToString()) == "1" || checkCityLevel(temp["receiptPlace"].ToString()) == "2")
                            {
                                if (receiptAmount > 280 * interval_time)
                                {
                                    result.Add("code", 400);
                                    result.Add("msg", "住宿费不能超过一晚280");

                                    return(result.ToString());
                                }
                            }
                            else if (checkCityLevel(temp["receiptPlace"].ToString()) == "3" || checkCityLevel(temp["receiptPlace"].ToString()) == "4")
                            {
                                if (receiptAmount > 220 * interval_time)
                                {
                                    result.Add("code", 400);
                                    result.Add("msg", "住宿费不能超过一晚220");

                                    return(result.ToString());
                                }
                            }
                        }
                        else if (post.Contains("经理"))
                        {
                            if (checkCityLevel(temp["receiptPlace"].ToString()) == "1")
                            {
                                if (receiptAmount > 220 * interval_time)
                                {
                                    result.Add("code", 400);
                                    result.Add("msg", "住宿费不能超过一晚220");

                                    return(result.ToString());
                                }
                            }
                            else if (checkCityLevel(temp["receiptPlace"].ToString()) == "2")
                            {
                                if (receiptAmount > 180 * interval_time)
                                {
                                    result.Add("code", 400);
                                    result.Add("msg", "住宿费不能超过一晚180");

                                    return(result.ToString());
                                }
                            }
                            else if (checkCityLevel(temp["receiptPlace"].ToString()) == "3")
                            {
                                if (receiptAmount > 150 * interval_time)
                                {
                                    result.Add("code", 400);
                                    result.Add("msg", "住宿费不能超过一晚150");

                                    return(result.ToString());
                                }
                            }
                            else if (checkCityLevel(temp["receiptPlace"].ToString()) == "4")
                            {
                                if (receiptAmount > 120 * interval_time)
                                {
                                    result.Add("code", 400);
                                    result.Add("msg", "住宿费不能超过一晚120");

                                    return(result.ToString());
                                }
                            }
                        }
                        else if (post.Contains("主管"))
                        {
                            if (checkCityLevel(temp["receiptPlace"].ToString()) == "1")
                            {
                                if (receiptAmount > 200 * interval_time)
                                {
                                    result.Add("code", 400);
                                    result.Add("msg", "住宿费不能超过一晚200");

                                    return(result.ToString());
                                }
                            }
                            else if (checkCityLevel(temp["receiptPlace"].ToString()) == "2")
                            {
                                if (receiptAmount > 160 * interval_time)
                                {
                                    result.Add("code", 400);
                                    result.Add("msg", "住宿费不能超过一晚160");

                                    return(result.ToString());
                                }
                            }
                            else if (checkCityLevel(temp["receiptPlace"].ToString()) == "3")
                            {
                                if (receiptAmount > 130 * interval_time)
                                {
                                    result.Add("code", 400);
                                    result.Add("msg", "住宿费不能超过一晚130");

                                    return(result.ToString());
                                }
                            }
                            else if (checkCityLevel(temp["receiptPlace"].ToString()) == "4")
                            {
                                if (receiptAmount > 110 * interval_time)
                                {
                                    result.Add("code", 400);
                                    result.Add("msg", "住宿费不能超过一晚110");

                                    return(result.ToString());
                                }
                            }
                        }
                        else
                        {
                            if (checkCityLevel(temp["receiptPlace"].ToString()) == "1")
                            {
                                if (receiptAmount > 180 * interval_time)
                                {
                                    result.Add("code", 400);
                                    result.Add("msg", "住宿费不能超过一晚180");

                                    return(result.ToString());
                                }
                            }
                            else if (checkCityLevel(temp["receiptPlace"].ToString()) == "2")
                            {
                                if (receiptAmount > 150 * interval_time)
                                {
                                    result.Add("code", 400);
                                    result.Add("msg", "住宿费不能超过一晚150");

                                    return(result.ToString());
                                }
                            }
                            else if (checkCityLevel(temp["receiptPlace"].ToString()) == "3")
                            {
                                if (receiptAmount > 120 * interval_time)
                                {
                                    result.Add("code", 400);
                                    result.Add("msg", "住宿费不能超过一晚120");

                                    return(result.ToString());
                                }
                            }
                            else if (checkCityLevel(temp["receiptPlace"].ToString()) == "4")
                            {
                                if (receiptAmount > 100 * interval_time)
                                {
                                    result.Add("code", 400);
                                    result.Add("msg", "住宿费不能超过一晚100");

                                    return(result.ToString());
                                }
                            }
                        }
                    }
                }
            }

            // 计算税率
            if (temp["receiptPerson"].ToString() != "" && temp["receiptPerson"].ToString() != "无")
            {
                dt = SqlHelper.Find(string.Format("select 1 from users where userName = '******'", temp["receiptPerson"].ToString())).Tables[0];

                if (dt.Rows.Count > 0 && (temp["receiptType"].ToString().Equals("出差车船费") || temp["receiptType"].ToString().Equals("培训费")))
                {
                    if (temp["feeType"].ToString().Equals("火车票"))
                    {
                        temp["receiptTax"] = Math.Round(double.Parse(temp["receiptAmount"].ToString()) / 1.09 * 0.09, 3);
                    }
                    else if (temp["feeType"].ToString().Equals("飞机票"))
                    {
                        temp["receiptTax"] = Math.Round((double.Parse(temp["receiptAmount"].ToString()) - 50) / 1.09 * 0.09, 3);
                    }
                    else if (temp["feeType"].ToString().Equals("汽车票"))
                    {
                        temp["receiptTax"] = Math.Round(double.Parse(temp["receiptAmount"].ToString()) / 1.03 * 0.03, 3);
                    }
                }
                if (dt.Rows.Count == 0)
                {
                    if (temp["receiptType"].ToString().Equals("出差车船费") || temp["receiptType"].ToString().Equals("住宿费") || temp["receiptType"].ToString().Equals("出差补贴"))
                    {
                        result.Add("code", 400);
                        result.Add("msg", "外部人员不能报销差旅费");

                        return(result.ToString());
                    }
                }
            }

            totalReceiptAmount += double.Parse(temp["receiptAmount"].ToString());
        }

        string sql = "";

        if (isReSubmit)
        {
            // 如果是被拒绝后重新提交 则删除之前记录再新增
            sql += string.Format("delete from yl_reimburse_detail where batchNo = '{0}';", batchNo);
        }

        sql += SqlHelper.GetInsertString(receiptList, "yl_reimburse_detail");

        string msg = SqlHelper.Exce(sql);

        if (msg.Contains("操作成功"))
        {
            result.Add("code", 200);
            result.Add("msg", batchNo);

            // 更新单据可用额度
            foreach (string code in codeList)
            {
                double remain_fee_amount = double.Parse(SqlHelper.Find(string.Format("select remain_fee_amount from yl_reimburse where code = '{0}'", code)).Tables[0].Rows[0][0].ToString());
                string tempSql           = "";
                if (remain_fee_amount >= totalReceiptAmount)
                {
                    tempSql  = string.Format("update yl_reimburse set remain_fee_amount = {0} where code = '{1}';", (remain_fee_amount - totalReceiptAmount), code);
                    tempSql += string.Format("delete from yl_reimburse_detail_relevance where batchNo = '{0}' and reimburseCode = '{1}';", batchNo, code);
                    tempSql += string.Format("insert into yl_reimburse_detail_relevance (batchNo,reimburseCode,amount) values ('{0}','{1}',{2});", batchNo, code, totalReceiptAmount);
                    SqlHelper.Exce(tempSql);
                    break;
                }
                else
                {
                    tempSql             = string.Format("update yl_reimburse set remain_fee_amount = {0} where code = '{1}';", 0, code);
                    tempSql            += string.Format("delete from yl_reimburse_detail_relevance where batchNo = '{0}' and reimburseCode = '{1}';", batchNo, code);
                    tempSql            += string.Format("insert into yl_reimburse_detail_relevance (batchNo,reimburseCode,amount) values ('{0}','{1}',{2});", batchNo, code, remain_fee_amount);
                    totalReceiptAmount -= remain_fee_amount;
                    SqlHelper.Exce(tempSql);
                }
            }

            UserInfo user = (UserInfo)Session["user"];
            // 发送审批消息给财务进行审批
            WxNetSalesHelper wxNetSalesHelper = new WxNetSalesHelper("v5afj_CYpboe-JWNOrCU0Cy-xP5krFq6cWYM9KZfe4o", "发票上报", "1000020");
            //// 给待审批人发送消息
            wxNetSalesHelper.GetJsonAndSendWxMsg("18100661|19080720", "请及时审批 提交人为:" + user.userName
                                                 + "的发票,谢谢!", "http://yelioa.top//mApprovalReimburseDetail.aspx", "1000020");

            //// 给提交人发送消息
            wxNetSalesHelper.GetJsonAndSendWxMsg(user.wechatUserId, "您的发票信息已提交 请耐心等待财务审批", "http://yelioa.top//mMySubmittedReimburseDetail.aspx", "1000020");
        }
        else
        {
            result.Add("code", 500);
            result.Add("msg", msg);
        }

        return(result.ToString());
    }
コード例 #6
0
    public static string ApproveDocument(string table, string docCode, UserInfo user
                                         , string ApprovalResult, string ApprovalOpinions, string url1, string url2, string url3,
                                         string appSecret, string thisAppName, string agentId)
    {
        string  res = "";
        DataSet ds  = ApprovalFlowSrv.GetDocumentInfo(table, docCode, ref res);

        if (ds == null)//出错,返回错误信息
        {
            return("获取单据信息出错,错误信息:" + res);
        }

        WxNetSalesHelper wxNetSalesHelper = new WxNetSalesHelper(appSecret, thisAppName, agentId);
        DataTable        DtAppApprover    = ds.Tables[0];
        DataTable        DtAppProcess     = ds.Tables[1];
        DataTable        DtAppRecord      = ds.Tables[2];
        DataTable        DtDocument       = ds.Tables[3];
        DataTable        DtInformer       = ds.Tables[5];

        int     SubmitorUserId   = Convert.ToInt32(DtAppRecord.Rows[0]["SubmitterId"]);
        DataSet dsUserInfo       = ApprovalFlowSrv.GetUserInfoByUserId(new int[] { SubmitorUserId });
        string  SubmitorWechatId = dsUserInfo.Tables[0].Rows[0]["wechatUserId"].ToString();
        string  SubmitorName     = dsUserInfo.Tables[0].Rows[0]["userName"].ToString();

        int level    = Convert.ToInt32(DtDocument.Rows[0]["Level"]);
        int maxLevel = Convert.ToInt32(DtAppProcess.Rows[DtAppProcess.Rows.Count - 1]["Level"]);

        string informer = "";

        foreach (DataRow row in ds.Tables[5].Rows)
        {
            informer += row["wechatUserId"].ToString() + "|";
        }
        Boolean       flag     = false;
        List <string> tempList = new List <string>();

        for (int i = 0; i < DtAppApprover.Rows.Count; i++)
        {
            tempList.Add(DtAppApprover.Rows[i]["ApproverId"].ToString());
            if (i == level)
            {
                if (!flag)
                {
                    string     saveRecordMsg = ApprovalFlowSrv.ApproveDocumentSaveRecord(DtAppApprover.Rows[i]["ApproverId"].ToString(), ds, ApprovalResult, ApprovalOpinions, level);
                    SqlExceRes sqlRes        = new SqlExceRes(saveRecordMsg);
                    res = sqlRes.GetResultString("审批结果提交成功!", "该单据已提交,请勿重复提交!");
                    if (res != "审批结果提交成功!")
                    {
                        return("提交审批结果出错,错误信息:" + res);
                    }
                }
                else
                {
                    string     saveRecordMsg = ApprovalFlowSrv.ApproveDocumentSaveRecord(DtAppApprover.Rows[i]["ApproverId"].ToString(), ds, ApprovalResult, "自动审批", level);
                    SqlExceRes sqlRes        = new SqlExceRes(saveRecordMsg);
                    res = sqlRes.GetResultString("审批结果提交成功!", "该单据已提交,请勿重复提交!");
                    if (res != "审批结果提交成功!")
                    {
                        return("提交审批结果出错,错误信息:" + res);
                    }
                }


                if (!ApprovalResult.Contains("不同意"))//审批同意
                {
                    level++;
                    if (level > maxLevel)//审批到最后一级,审批流程结束
                    {
                        if (informer != "")
                        {
                            informer = informer.Substring(0, informer.Length - 1);
                            wxNetSalesHelper.GetJsonAndSendWxMsg(informer, "有一条与您相关的单据审批流程结束,请知悉", url1, agentId);
                        }

                        res = "审批流程结束";
                        //清除审批人相关信息
                        ApprovalFlowSrv.ClearCurrentApproverInfo(table, docCode);

                        // 更新表单状态
                        ApprovalFlowSrv.UpdateDocStatus(table, docCode, "已审批", level);

                        // 发送审批的消息给提交者
                        wxNetSalesHelper.GetJsonAndSendWxMsg(SubmitorWechatId, "您的审批单据审批流程结束,请知悉", url1, agentId);

                        // 审批流程结束后,需要把纯销数据更新到flow_statistic表中
                        //NetSalesInfoSrv.updateNetSalesAndStockAfterApproval(docCode);
                    }
                    else
                    {
                        string tempUserId = tempUserId = DtAppApprover.Rows[level]["ApproverId"].ToString();

                        res = "审批同意!";

                        // 更新表单状态
                        ApprovalFlowSrv.UpdateDocStatus(table, docCode, "审批中", level);


                        // 发送审批的消息给提交者
                        wxNetSalesHelper.GetJsonAndSendWxMsg(SubmitorWechatId, "您审批单据已被"
                                                             + user.userName + "审批,结果为同意,请知悉"
                                                             , url1, agentId);
                        if (!tempList.Contains(tempUserId))
                        {
                            // 向审批人发送审批通知
                            DataSet userDs = ApprovalFlowSrv.GetUserInfoByUserId(
                                ApprovalFlowSrv.GetApproverIddByLevel(level, DtAppApprover));

                            string approverIds = "";
                            foreach (DataTable dt in userDs.Tables)
                            {
                                approverIds += dt.Rows[0]["wechatUserId"].ToString() + "|";
                            }
                            approverIds = approverIds.Substring(0, approverIds.Length - 1);

                            wxNetSalesHelper.GetJsonAndSendWxMsg(approverIds, "已收到提交人为: " + SubmitorName
                                                                 + "的单据,请及时审批,谢谢"
                                                                 , url2, agentId);
                            break;
                        }
                        else
                        {
                            flag = true;
                        }
                    }
                }
                else//审批不同意
                {
                    if (informer != "")//发送消息给抄送人
                    {
                        informer = informer.Substring(0, informer.Length - 1);
                        wxNetSalesHelper.GetJsonAndSendWxMsg(informer, "有一条与您相关的单据被审批拒绝,请知悉", url1, agentId);
                    }
                    //清除审批人相关信息
                    ApprovalFlowSrv.ClearCurrentApproverInfo(table, docCode);
                    // 更新表单状态
                    if ("yl_reimburse".Equals(table) || "wages".Equals(table) || "outer_wages".Equals(table) || "tax".Equals(table))
                    {
                        ApprovalFlowSrv.UpdateDocStatus(table, docCode, "已拒绝", 0);
                    }
                    else
                    {
                        ApprovalFlowSrv.UpdateDocStatus(table, docCode, "未提交", 0);
                    }

                    res = "审批拒绝!";



                    string approver = "";

                    foreach (DataRow row in DtAppProcess.Rows)
                    {
                        if (Convert.ToInt32(row["Level"]) < level && Convert.ToInt32(row["Level"]) > 0)
                        {
                            approver += row["wechatUserId"].ToString() + "|";
                        }
                    }
                    if (approver != "")//发送消息给抄送人
                    {
                        approver = approver.Substring(0, approver.Length - 1);
                        wxNetSalesHelper.GetJsonAndSendWxMsg(approver, "有一条您审批通过的单据被审批拒绝,请知悉", url1, agentId);
                    }

                    // 发送审批被拒绝的消息
                    if ("".Equals(ApprovalOpinions))
                    {
                        wxNetSalesHelper.GetJsonAndSendWxMsg(SubmitorWechatId, "您的审批单据已被"
                                                             + user.userName + "审批,结果为拒绝,请重新提交该单据"
                                                             , url3, agentId);
                    }
                    else
                    {
                        wxNetSalesHelper.GetJsonAndSendWxMsg(SubmitorWechatId, "您的审批单据已被"
                                                             + user.userName + "审批,结果为拒绝,意见为:" + ApprovalOpinions + ",请重新提交该单据"
                                                             , url3, agentId);
                    }

                    break;
                }
                if (table == "deliver_apply_report")//销售订单重复的审批人不需要自动审批
                {
                    break;
                }
            }
        }
        //保存审批记录

        return(res);
    }
コード例 #7
0
    private string submit()
    {
        var result = new JObject
        {
            { "code", 200 },
            { "msg", "ok" }
        };

        DataTable      dt       = JsonHelper.Json2Dtb(Request.Form["tableData"]);
        List <JObject> approver = JsonHelper.DeserializeJsonToList <JObject>(Request.Form["approver"]);

        string year    = Request.Form["year"];
        string month   = Request.Form["month"];
        string company = Request.Form["company"];
        string type    = Request.Form["type"];

        string tableName = "";

        if (type == "1")
        {
            tableName = "wages";
        }
        else if (type == "2")
        {
            tableName = "outer_wages";
        }
        else if (type == "3")
        {
            tableName = "tax";
        }
        else if (type == "4")
        {
            tableName = "interest";
        }
        else if (type == "5")
        {
            tableName = "depreciation";
        }
        else if (type == "6")
        {
            tableName = "amortize";
        }

        // 先删除 后新增
        DataTable tempDt = SqlHelper.Find(string.Format("select docCode from {0} where year = '{1}' and month = '{2}' and company = '{3}' limit 1", tableName, year, month, company)).Tables[0];

        string originDocCode = "";

        if (tempDt.Rows.Count > 0)
        {
            originDocCode = tempDt.Rows[0][0].ToString();
        }

        string sql = string.Format("delete from {3} where year = '{0}' and month = '{1}' and company = '{2}';", year, month, company, tableName);

        sql += string.Format("delete from approval_approver where documentTableName = '{0}' and docCode = '{1}';", tableName, originDocCode);
        sql += string.Format("delete from approval_record where documentTableName = '{0}' and docCode = '{1}';", tableName, originDocCode);
        sql += SqlHelper.GetInsertString(dt, tableName);

        string msg = SqlHelper.Exce(sql);

        if (!msg.Contains("操作成功"))
        {
            result["code"] = 500;
            result["msg"]  = "导入数据失败:数据库操作错误!";

            return(result.ToString());
        }

        // 新增审批人表
        List <JObject> list    = new List <JObject>();
        string         docCode = dt.Rows[0]["DocCode"].ToString();

        int index = 0;

        foreach (JObject tempJ in approver)
        {
            JObject approverJ = new JObject
            {
                { "DocumentTableName", tableName },
                { "DocCode", docCode },
                { "ApproverId", tempJ["userId"] },
                { "Level", index++ }
            };
            list.Add(approverJ);
        }

        sql = SqlHelper.GetInsertString(list, "approval_approver");
        msg = SqlHelper.Exce(sql);

        if (!msg.Contains("操作成功"))
        {
            result["code"] = 500;
            result["msg"]  = "导入数据失败:数据库操作错误!";

            return(result.ToString());
        }

        // 新增审批记录表
        UserInfo userInfo = (UserInfo)Session["user"];

        JObject recordJ = new JObject
        {
            { "DocumentTableName", tableName },
            { "DocCode", docCode },
            { "Time", DateTime.Now },
            { "Level", 0 },
            { "ApproverId", userInfo.userId.ToString() },
            { "SubmitterId", userInfo.userId.ToString() },
            { "ApprovalResult", "单据提交" }
        };

        sql = SqlHelper.GetInsertString(recordJ, "approval_record");
        msg = SqlHelper.Exce(sql);

        if (!msg.Contains("操作成功"))
        {
            result["code"] = 500;
            result["msg"]  = "导入数据失败:数据库操作错误!";

            return(result.ToString());
        }

        WxNetSalesHelper wxNetSalesHelper = new WxNetSalesHelper("vbmKxak1-a5Ty1cEBJzUFa1OR9f0V4Yh5j0sJq2-e9o", "发票上报", "1000023");

        string chineseName = "";

        if (type == "1")
        {
            chineseName = "人员工资";
        }
        if (type == "2")
        {
            chineseName = "非全日制人员工资";
        }
        else if (type == "3")
        {
            chineseName = "税金";
        }
        else if (type == "4")
        {
            chineseName = "利息";
        }
        else if (type == "5")
        {
            chineseName = "折旧";
        }
        else if (type == "6")
        {
            chineseName = "摊销";
        }

        // 给提交人发消息通知
        wxNetSalesHelper.GetJsonAndSendWxMsg(userInfo.wechatUserId, string.Format("您的{0}年{1}月{2}{3}已提交,请耐心等待审批!", year, month, company, chineseName), "http://yelioa.top//mCompanyFee.aspx", "1000023");

        // 给审批人发消息通知
        wxNetSalesHelper.GetJsonAndSendWxMsg(approver[1]["wechatUserId"].ToString(), "请及时审批 提交人为:" + userInfo.userName
                                             + string.Format("提交的{0}年{1}月{2}{3},谢谢!", year, month, company, chineseName), "http://yelioa.top//mCompanyFee.aspx", "1000023");

        return(result.ToString());
    }
コード例 #8
0
    private string disagree()
    {
        string code    = Request.Form["code"];
        string batchNo = Request.Form["batchNo"];
        string opinion = Request.Form["opinion"];

        UserInfo user = (UserInfo)Session["user"];

        JObject result = new JObject(); // 返回结果jobject

        // 判断单据是否已经被审批
        string sql = string.Format("select 1 from yl_reimburse_detail where batchNo = '{0}' and status != '已提交'", batchNo);

        if (SqlHelper.Find(sql).Tables[0].Rows.Count > 0)
        {
            result.Add("code", 400);
            result.Add("msg", "该单据已被审批,请勿重复审批!");

            return(result.ToString());
        }

        sql = string.Format("update yl_reimburse_detail set status = '拒绝', opinion = '{0}', approvalTime = now() " +
                            "where batchNo = '{1}';", opinion, batchNo);

        string msg = SqlHelper.Exce(sql);

        if (msg.Contains("操作成功"))
        {
            result.Add("code", 200);
            result.Add("msg", "操作成功");

            // 还原消费记录的可用额度
            string[] codeArray = code.Split(',');

            sql = string.Format("select 1 from yl_reimburse t1 left join yl_reimburse_detail_relevance t2 on t1.code = t2.reimburseCode " +
                                "where t2.batchNo = '{0}'", batchNo);

            DataTable dt = SqlHelper.Find(sql).Tables[0];

            string _sql = "";

            double totalReceiptAmount = double.Parse(SqlHelper.Find(string.Format("select sum(receiptAmount) from yl_reimburse_detail " +
                                                                                  "where batchNo = '{0}'", batchNo)).Tables[0].Rows[0][0].ToString());

            foreach (string tempCode in codeArray)
            {
                if (string.IsNullOrEmpty(tempCode))
                {
                    continue;
                }

                if (dt.Rows.Count > 0)
                {
                    _sql += string.Format("update yl_reimburse t1 left join yl_reimburse_detail_relevance t2 on t1.code = t2.reimburseCode set t1.remain_fee_amount = " +
                                          "t1.remain_fee_amount + t2.amount where t2.batchNo = '{0}' and t2.reimburseCode = '{1}';", batchNo, tempCode);
                }
                else
                {
                    DataTable tempDt = SqlHelper.Find(string.Format("select fee_amount, remain_fee_amount from yl_reimburse where code = '{0}'", tempCode)).Tables[0];

                    double fee_amount        = double.Parse(tempDt.Rows[0][0].ToString());
                    double remain_fee_amount = double.Parse(tempDt.Rows[0][1].ToString());

                    if ((fee_amount - remain_fee_amount) >= totalReceiptAmount)
                    {
                        _sql += string.Format("update yl_reimburse set remain_fee_amount = remain_fee_amount + {0} where code = '{1}'", totalReceiptAmount, tempCode);
                        break;
                    }
                    else
                    {
                        _sql += string.Format("update yl_reimburse set remain_fee_amount = fee_amount where code = '{0}'", tempCode);
                        totalReceiptAmount -= fee_amount - remain_fee_amount;
                    }
                }
            }

            SqlHelper.Exce(_sql);

            WxNetSalesHelper wxNetSalesHelper = new WxNetSalesHelper("v5afj_CYpboe-JWNOrCU0Cy-xP5krFq6cWYM9KZfe4o", "发票上报", "1000020");

            dt = SqlHelper.Find(string.Format("select t2.wechatUserId from yl_reimburse t1 left join users t2 on t1.name = t2.userName " +
                                              "where '{0}' like concat('%', t1.code, '%') limit 1", code)).Tables[0];
            //// 给提交人发送消息
            wxNetSalesHelper.GetJsonAndSendWxMsg(dt.Rows[0][0].ToString(), "您的发票信息已被审批拒绝,审批人为: " + user.userName + ",拒绝理由为:" + opinion + ",请尽快重新提交。", "http://yelioa.top//mMySubmittedReimburseDetail.aspx", "1000020");
        }
        else
        {
            result.Add("code", 500);
            result.Add("msg", "操作失败");
        }

        return(result.ToString());
    }
コード例 #9
0
    private string agree()
    {
        string         batchNo     = Request.Form["batchNo"];
        string         code        = Request.Form["code"];
        UserInfo       user        = (UserInfo)Session["user"];
        List <JObject> receiptList = JsonHelper.DeserializeJsonToList <JObject>(Request.Form["receiptList"]);

        JObject result = new JObject(); // 返回结果jobject

        // 判断单据是否已经被审批
        string sql = string.Format("select * from yl_reimburse_detail where batchNo = '{0}' and status != '已提交'", batchNo);

        DataTable dt = SqlHelper.Find(sql).Tables[0];

        if (dt.Rows.Count > 0)
        {
            result.Add("code", 400);
            result.Add("msg", "该单据已被审批,请勿重复审批!");

            return(result.ToString());
        }

        // 删除并新增修改后的单据列表
        sql  = string.Format("delete from yl_reimburse_detail where batchNo = '{0}';", batchNo);
        sql += SqlHelper.GetInsertString(receiptList, "yl_reimburse_detail");
        SqlHelper.Exce(sql);

        sql = string.Format("update yl_reimburse_detail set status = '同意', opinion = '同意', approvalTime = now() where batchNo = '{0}'", batchNo);

        string msg = SqlHelper.Exce(sql);

        if (msg.Contains("操作成功"))
        {
            result.Add("code", 200);
            result.Add("msg", "操作成功");

            WxNetSalesHelper wxNetSalesHelper = new WxNetSalesHelper("v5afj_CYpboe-JWNOrCU0Cy-xP5krFq6cWYM9KZfe4o", "发票上报", "1000020");

            dt = SqlHelper.Find(string.Format("select t2.wechatUserId, t1.code, t1.remain_fee_amount from yl_reimburse t1 left join users t2 on t1.name = t2.userName " +
                                              "where '{0}' like concat('%', t1.code, '%')", code)).Tables[0];
            //// 给提交人发送消息
            wxNetSalesHelper.GetJsonAndSendWxMsg(dt.Rows[0][0].ToString(), "您的发票信息财务已审批通过。审批人为:" + user.userName, "http://yelioa.top//mMySubmittedReimburseDetail.aspx", "1000020");

            sql = string.Empty;

            foreach (DataRow dr in dt.Rows)
            {
                string tempCode          = dt.Rows[0][1].ToString();
                string remain_fee_amount = dt.Rows[0][2].ToString();

                // 如果remian_fee_amount为0 单据改成财务已审批
                if (remain_fee_amount == "0")
                {
                    sql += string.Format("update yl_reimburse set account_approval_time = now(), account_result = '同意', account_approver = '{1}' where code = '{0}';", tempCode, user.userName);
                }

                // 修改关联备用金金额
                double amount = double.Parse(SqlHelper.Find(string.Format("select amount from yl_reimburse_detail_relevance where batchNo = '{0}' and reimburseCode = '{1}'", batchNo, tempCode)).
                                             Tables[0].Rows[0][0].ToString());

                dt = SqlHelper.Find(string.Format("select * from yl_reimburse_loan where reimburseCode = '{0}'", tempCode)).Tables[0];

                foreach (DataRow tempDr in dt.Rows)
                {
                    double aaa         = double.Parse(tempDr["amount"].ToString());
                    string loanId      = tempDr["id"].ToString();
                    string loanDocCode = tempDr["docCode"].ToString();

                    if (aaa <= amount)
                    {
                        amount -= aaa;
                    }
                    else
                    {
                        sql   += string.Format("update yl_reimburse_loan set amount = {0} where id = {1};", amount, loanId);
                        sql   += string.Format("update wf_form_借款单 set remainAmount = remainAmount + {0} where docCode = '{1}'", aaa - amount, loanDocCode);
                        amount = 0;
                    }
                }
            }
            SqlHelper.Exce(sql);
        }
        else
        {
            result.Add("code", 500);
            result.Add("msg", "操作失败");
        }

        return(result.ToString());
    }