1
lan
2024-05-30 8affd199e02bd37f0dcb16447d1fbcaa34bfa2f8
WebAPI/Controllers/XSGL/Xs_CusRatingChangeBillController.cs
@@ -37,23 +37,23 @@
            {
                List<object> columnNameList = new List<object>();
                //查看权限
                //if (!DBUtility.ClsPub.Security_Log("Gy_ProjectStage_Query", 1, false, user))
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "无查看权限!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                if (!DBUtility.ClsPub.Security_Log("Xs_CusRatingChangeBill_Query", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Xs_CusRatingChangeBillList_Query order by 单据号 ", "h_v_Xs_CusRatingChangeBillList_Query");
                    ds = oCN.RunProcReturn("select * from h_v_Xs_CusRatingChangeBillList_Query order by 单据号 desc", "h_v_Xs_CusRatingChangeBillList_Query");
                }
                else
                {
                    string sql1 = "select * from h_v_Xs_CusRatingChangeBillList_Query where 1 = 1 ";
                    string sql = sql1 + sWhere + " order by 单据号 ";
                    string sql = sql1 + sWhere + " order by 单据号 desc";
                    ds = oCN.RunProcReturn(sql, "h_v_Xs_CusRatingChangeBillList_Query");
                }
@@ -217,7 +217,15 @@
                }
                //进行 会计期间 结账 的判断和控制
                int sYear = 0;
                int sPeriod = 0;
                DateTime HDate = DateTime.Now;
                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
                {
                    objJsonResult.Message = s;
                    return objJsonResult;
                }
                //保存
                //保存完毕后处理
@@ -349,6 +357,15 @@
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
                //进行 会计期间 结账 的判断和控制
                int sYear = 0;
                int sPeriod = 0;
                DateTime HDate = DateTime.Now;
                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
                {
                    objJsonResult.Message = s;
                    return objJsonResult;
                }
                oCN.BeginTran();
@@ -359,7 +376,7 @@
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.Message = "您已删除单据号为" + BillOld.omodel.HBillNo + "的信用额度申请单!";
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -468,34 +485,25 @@
                //进行需要进行的审核/反审核操作
                if (IsAudit == 0) //审核提交
                {
                    //反写客户信用额度
                    oCN.BeginTran();
                    string sql = "select * from Gy_Customer_Credit where HCusID = " + oBill.omodel.HCusID;
                    ds = oCN.RunProcReturn(sql, "Gy_Customer_Credit");
                    if (ds.Tables[0].Rows.Count == 0)
                    //进行 会计期间 结账 的判断和控制
                    string s = "";
                    int sYear = 0;
                    int sPeriod = 0;
                    DateTime HDate = DateTime.Now;
                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
                    {
                        sql = "insert into Gy_Customer_Credit" +
                            "(HCusID,HCreditRating_Now,HUpdateTime,HUpdateMan)" +
                            " values(" +
                            "" + oBill.omodel.HCusID +
                            "," + oBill.omodel.HNewRating +
                            ",'" + DateTime.Now.ToString("yyyy-MM-dd") + "'" +
                            ",'" + CurUserName + "'" +
                            ")";
                        oCN.RunProc(sql);
                        objJsonResult.Message = s;
                        return objJsonResult;
                    }
                    else
                    {
                        sql = "update Gy_Customer_Credit set " +
                            "HCreditRating_Now = " + oBill.omodel.HNewRating +
                            ",HUpdateTime = '" + DateTime.Now.ToString("yyyy-MM-dd") + "'" +
                            ",HUpdateMan = '" + CurUserName + "'" +
                            " where HCusID = " + oBill.omodel.HCusID;
                        oCN.RunProc(sql);
                    }
                    //审核提交
                    if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        //反写客户信用额度
                        oCN.BeginTran();
                        string sql = "exec h_p_Xs_CusRatingChangeBill_ReWriteCustomerCredit " + oBill.omodel.HCusID + "," + oBill.omodel.HNewRating + ",'" + CurUserName + "'";
                        oCN.RunProc(sql);
                        oCN.Commit();
                        objJsonResult.code = "1";
@@ -515,6 +523,17 @@
                }
                if (IsAudit == 1) //反审核提交
                {
                    //进行 会计期间 结账 的判断和控制
                    string s = "";
                    int sYear = 0;
                    int sPeriod = 0;
                    DateTime HDate = DateTime.Now;
                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
                    {
                        objJsonResult.Message = s;
                        return objJsonResult;
                    }
                    //反审核提交AbandonCheck
                    if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
@@ -827,5 +846,54 @@
            }
        }
        #endregion
        #region 根据客户内码获取客户余额与客户信用额度
        /// <summary>
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Xs_CusRatingChangeBill/getCustomerBalance")]
        [HttpGet]
        public object getCustomerBalance(Int64 HCusID, string CurUserName)
        {
            try
            {
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Gy_Customer_Balance", 1, false, CurUserName))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无客户余额查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                string sql = "exec h_p_Gy_Customer_CrediControl " + HCusID;
                ds = oCN.RunProcReturn(sql, "h_p_Gy_Customer_CrediControl");
                if(ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "Exception!未获取到对应客户的信息!!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}