From 278c9cfdb2aef8ac079e04b94719c6125b747d4b Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期四, 18 一月 2024 09:11:41 +0800
Subject: [PATCH] 特批申请单:审核时对于单据状态为0的单据无法审核,提示单据不为“创建”状态

---
 WebAPI/Controllers/XSGL/Xs_SeOrderChangeBillController.cs |  110 ++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 93 insertions(+), 17 deletions(-)

diff --git a/WebAPI/Controllers/XSGL/Xs_SeOrderChangeBillController.cs b/WebAPI/Controllers/XSGL/Xs_SeOrderChangeBillController.cs
index 27c74e0..1d424a4 100644
--- a/WebAPI/Controllers/XSGL/Xs_SeOrderChangeBillController.cs
+++ b/WebAPI/Controllers/XSGL/Xs_SeOrderChangeBillController.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_SeOrderChangeBill_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_SeOrderChangeBillList_Query order by 鍗曟嵁鍙� ", "h_v_Xs_SeOrderChangeBillList_Query");
+                    ds = oCN.RunProcReturn("select * from h_v_Xs_SeOrderChangeBillList_Query order by 鍗曟嵁鍙� desc", "h_v_Xs_SeOrderChangeBillList_Query");
                 }
                 else
                 {
                     string sql1 = "select * from h_v_Xs_SeOrderChangeBillList_Query where 1 = 1 ";
-                    string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� ";
+                    string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc";
                     ds = oCN.RunProcReturn(sql, "h_v_Xs_SeOrderChangeBillList_Query");
                 }
 
@@ -311,6 +311,8 @@
         {
             try
             {
+                string s = "";
+
                 //鏌ョ湅鏉冮檺
                 if (!DBUtility.ClsPub.Security_Log("Xs_SeOrderChangeBill_Drop", 1, false, user))
                 {
@@ -327,6 +329,24 @@
                     objJsonResult.count = 0;
                     objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�";
                     objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (BillOld.ShowBill(long.Parse(HInterID), ref s) == false)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "姝ゅ崟鎹湁璇紒";
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                //鍒ゆ柇鏄惁鍙紪杈�
+                if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽鍒犻櫎锛�";
+                    objJsonResult.data = 1;
                     return objJsonResult;
                 }
 
@@ -453,15 +473,28 @@
                     DateTime today = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));                   //褰撴棩鏃ユ湡
                     foreach (Model.ClsXs_SeOrderChangeBillSub oSub in oBill.DetailColl)
                     {
-                        //鍒ゆ柇鏂版暟閲忔槸鍚﹀皬浜庡崟鎹叧鑱旀暟閲�
-                        if(oSub.HQty_New < oSub.HRelationQty)                                             
+                        string sqlCheck = "select * from Xs_SeOrderBillSub where HInterID = " + oSub.HSourceInterID + " and HEntryID = " + oSub.HSourceEntryID;
+                        ds = oCN.RunProcReturn(sqlCheck, "Xs_SeOrderBillSub");
+                        if (ds.Tables[0].Rows.Count == 0)
                         {
-                            errorMessage += "绗�" + oSub.HEntryID + "琛岀墿鏂欐柊鏁伴噺灏忎簬鍗曟嵁琚叧鑱旀暟閲�!";
-                        } 
-                        //鍒ゆ柇鏂颁氦璐ф棩鏈熸槸鍚︽棭浜庡綋鏃�
-                        if ( oSub.HDate_New.CompareTo(today) < 0 ) 
+                            errorMessage += "绗�" + oSub.HEntryID + "琛岀墿鏂欏湪婧愬崟-閿�鍞鍗曚腑涓嶅瓨鍦�!";
+                        }
+                        else
                         {
-                            errorMessage +=  "绗�" + oSub.HEntryID + "琛屾柊浜よ揣鏃ユ湡鏃╀簬褰撴棩!";
+                            double HRelationQty = 0;
+                            //鑾峰彇閿�鍞鍗曞彉鏇村崟涓搴旂墿鏂欏湪婧愬崟-閿�鍞鍗曚腑鐨勫叧鑱旀暟閲�
+                            HRelationQty = double.Parse(ds.Tables[0].Rows[0]["HRelationQty"].ToString());
+
+                            //鍒ゆ柇鐗╂枡鏂版暟閲忔槸鍚﹀皬浜庢簮鍗曞崟鎹腑瀵瑰簲鐗╂枡鐨勫叧鑱旀暟閲�
+                            if (oSub.HQty_New < HRelationQty)
+                            {
+                                errorMessage += "绗�" + oSub.HEntryID + "琛岀墿鏂欐柊鏁伴噺灏忎簬婧愬崟-閿�鍞鍗曡鍏宠仈鏁伴噺!";
+                            }
+                            //鍒ゆ柇鏂颁氦璐ф棩鏈熸槸鍚︽棭浜庡綋鏃�
+                            if (oSub.HDate_New.CompareTo(today) < 0)
+                            {
+                                errorMessage += "绗�" + oSub.HEntryID + "琛屾柊浜よ揣鏃ユ湡鏃╀簬褰撴棩!";
+                            }
                         }
                     }
                     if(errorMessage != "")
@@ -473,10 +506,49 @@
                         return objJsonResult;
                     }
 
+                    //妫�楠屾簮鍗曟槸鍚﹀瓨鍦�
+                    string sql = "select * from Xs_SeOrderBillMain as a " +
+                        "inner join Xs_SeOrderBillSub as b on a.HInterID = b.HInterID " +
+                        "where a.HInterID = " + oBill.omodel.HMainSourceInterID;
+                    ds = oCN.RunProcReturn(sql, "Xs_SeOrderBill");
+                    if (ds == null || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟涓嶅瓨鍦�!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }else if(ds.Tables[0].Rows[0]["HBillStatus"].ToString() != "2")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟鏈浜庡鏍哥姸鎬�!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    oCN.BeginTran();
+                    //鍙嶅啓閿�鍞鍗曟暟鎹�
+                    sql = "exec h_p_IF_SeOrderBill_ReWriteBySeOrderChangeBill " + oBill.omodel.HInterID;
+                    oCN.RunProcReturn(sql, "h_p_IF_SeOrderBill_ReWriteBySeOrderChangeBill");
+                    //淇$敤鎺у埗
+                    sql = "exec h_p_Kf_CheckSeOrderChangeBill_CrediControl " + oBill.omodel.HMainSourceInterID;
+                    ds = oCN.RunProcReturn(sql, "h_p_Kf_CheckSeOrderBill_CrediControl");
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1")
+                    {
+                        oCN.RollBack();
+
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString();
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
 
                     //瀹℃牳鎻愪氦
                     if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
+                        oCN.Commit();
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
                         objJsonResult.Message = "瀹℃牳鎴愬姛";
@@ -485,6 +557,8 @@
                     }
                     else
                     {
+                        oCN.RollBack();
+
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
                         objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
@@ -516,6 +590,8 @@
             }
             catch (Exception e)
             {
+                oCN.RollBack();
+
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString();

--
Gitblit v1.9.1