From 2d98e07db706e1a882fff03685411b103d747a34 Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期一, 11 十二月 2023 16:22:56 +0800
Subject: [PATCH] 销售订单:下查增加工序流转卡

---
 WebAPI/Controllers/XSGL/YS_ReceiveBillController.cs |  140 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 137 insertions(+), 3 deletions(-)

diff --git a/WebAPI/Controllers/XSGL/YS_ReceiveBillController.cs b/WebAPI/Controllers/XSGL/YS_ReceiveBillController.cs
index 942e365..c9c1657 100644
--- a/WebAPI/Controllers/XSGL/YS_ReceiveBillController.cs
+++ b/WebAPI/Controllers/XSGL/YS_ReceiveBillController.cs
@@ -49,12 +49,12 @@
 
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select * from h_v_YS_ReceiveBillList_Query order by 鍗曟嵁鍙� ", "h_v_YS_ReceiveBillList_Query");
+                    ds = oCN.RunProcReturn("select * from h_v_YS_ReceiveBillList_Query order by 鍗曟嵁鍙� desc", "h_v_YS_ReceiveBillList_Query");
                 }
                 else
                 {
                     string sql1 = "select * from h_v_YS_ReceiveBillList_Query where 1 = 1 ";
-                    string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� ";
+                    string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc";
                     ds = oCN.RunProcReturn(sql, "h_v_YS_ReceiveBillList_Query");
                 }
 
@@ -312,6 +312,8 @@
         {
             try
             {
+                string s = "";
+
                 //鏌ョ湅鏉冮檺
                 if (!DBUtility.ClsPub.Security_Log("YS_ReceiveBill_Drop", 1, false, user))
                 {
@@ -328,6 +330,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;
                 }
 
@@ -449,17 +469,60 @@
                 //杩涜闇�瑕佽繘琛岀殑瀹℃牳/鍙嶅鏍告搷浣�
                 if (IsAudit == 0) //瀹℃牳鎻愪氦
                 {
+                    oCN.BeginTran();
+
+                    //璁板綍杩斿洖淇℃伅
+                    string msg = "";
+
+                    if(oBill.omodel.HMainSourceInterID != 0)
+                    {
+                        //妫�楠屾簮鍗曟槸鍚﹀瓨鍦ㄥ強鍗曟嵁鐘舵��
+                        string sql = "select * from Xs_ExceptiveCheckRequestBillMain where HInterID = " + oBill.omodel.HMainSourceInterID;
+                        ds = oCN.RunProcReturn(sql, "Xs_ExceptiveCheckRequestBill");
+                        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;
+                        }
+                        
+                        if( oBill.omodel.HRelSumMoney*oBill.omodel.HExRate < double.Parse( ds.Tables[0].Rows[0]["HLeftMoney"].ToString() ))
+                        {
+                            msg = "鏀舵鍗曟姌鎵e悗閲戦灏忎簬婧愬崟-鐗规壒鐢宠鍗曠殑娆犵己閲戦锛屾棤娉曞叧闂簮鍗�-鐗规壒鐢宠鍗�!";
+                        }
+                        else
+                        {
+                            //鍙嶅啓婧愬崟-鐗规壒鐢宠鍗曞崟鎹姸鎬�
+                            sql = "update Xs_ExceptiveCheckRequestBillMain set HBillStatus = 3 where HInterID = " + oBill.omodel.HMainSourceInterID;
+                            oCN.RunProc(sql);
+                        }
+                    }
+                    
                     //瀹℃牳鎻愪氦
                     if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
+                        oCN.Commit();
+
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
-                        objJsonResult.Message = "瀹℃牳鎴愬姛";
+                        objJsonResult.Message = "瀹℃牳鎴愬姛锛�" + msg;
                         objJsonResult.data = null;
                         return objJsonResult;
                     }
                     else
                     {
+                        oCN.RollBack();
+
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
                         objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
@@ -469,6 +532,17 @@
                 }
                 if (IsAudit == 1) //鍙嶅鏍告彁浜�
                 {
+                    string sql = "exec h_p_YS_ReceiveBill_AbandonCheckCrediControl " + oBill.omodel.HInterID;
+                    ds = oCN.RunProcReturn(sql, "h_p_YS_ReceiveBill_AbandonCheckCrediControl");
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString();
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
                     //鍙嶅鏍告彁浜bandonCheck
                     if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
@@ -491,6 +565,8 @@
             }
             catch (Exception e)
             {
+                oCN.RollBack();
+
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString();
@@ -781,5 +857,63 @@
             }
         }
         #endregion
+
+        #region 鏀舵鍗� 鏍规嵁瀹㈡埛鑾峰彇甯佸埆銆佹眹鐜囥�佺粨绠楁柟寮忋�侀摱琛屻�侀摱琛岃处鎴枫�佸鎴蜂俊鐢ㄩ搴�
+        [Route("YS_ReceiveBill/getCustomerByCusID")]
+        [HttpGet]
+        public object getCustomerByCusID(long HCusID)
+        {
+            try
+            {
+                string sql = @"select 
+                            c.HItemID HCusID
+                            ,c.HNumber HCusNumber
+                            ,c.HName HCusName
+                            ,c.HSSID
+                            ,s.HName HSSName
+                            ,c.HCurID
+                            ,cur.HName HCurName
+                            ,cur.HExchangeRate HExRate
+                            ,c.HTaxRate
+                            ,ISNULL(b.HItemID,0) HBankID
+							,b.HName HBankName
+                            ,c.HBankAccount
+                            ,ISNULL(cre.HCreditRating_Now,0) HCreditRating_Now
+                            from Gy_Customer as c 
+                            left join Gy_SettleStyle as s on c.HSSID = s.HItemID
+                            left join Gy_Currency as cur on c.HCurID = cur.HItemID
+							left join Gy_Bank as b on c.HBank = b.HName
+                            left join Gy_Customer_Credit as cre on c.HItemID = cre.HCusID
+                            where c.HItemID = " + HCusID;
+                ds = oCN.RunProcReturn(sql, "Gy_Customer");
+
+
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏈煡璇㈠埌璇ュ鎴蜂俊鎭紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    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
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1