From a8d0182b40faeabad3233d83c7b553c6eb2a34c1 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期三, 15 十月 2025 07:50:51 +0800
Subject: [PATCH] fix: update ServiceOrdTraOfferPrice

---
 Report_DispatchDetailed_Data.php |  119 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 100 insertions(+), 19 deletions(-)

diff --git a/Report_DispatchDetailed_Data.php b/Report_DispatchDetailed_Data.php
index d0e35f7..45e0867 100644
--- a/Report_DispatchDetailed_Data.php
+++ b/Report_DispatchDetailed_Data.php
@@ -266,7 +266,7 @@
 	 ,ServiceOrdTraDistance,DispatchOrdCarID,DispatchOrd_NS_Time,DispatchOrdActualDate,DispatchOrd_OAName,DispatchOrd_OAEntourage,FromHQ_is,FromHQ2_is,ServiceOrdPtName,ServiceOrdPtServices,ServiceOrdTraVia,ServiceOrdTraEnd
 	 ,HopsProvince=hospA.HopsProvince,HopsCity=hospA.HopsCity,HopsArea=hospA.HopsArea,HospName=hospA.HospName
 	 ,HopsProvinceIn=hospB.HopsProvince,HopsCityIn=hospB.HopsCity,HopsAreaIn=hospB.HopsArea,HospNameIn=hospB.HospName,ServiceOrdTaskRemarks
-	 ,ServiceOrd_work_ID,ServiceOrd_work_IDs,ServiceOrd_work_is,CommissionScenarioID
+	 ,ServiceOrd_work_ID,ServiceOrd_work_IDs,ServiceOrd_work_is,CommissionScenarioID,ServiceOrdStairClimberPrice
 	 ,row_number() over (order by ServiceOrd_CC_Time desc) n  $sqlWhere";
 	//闄勫姞缁撴灉SQL
 	//$Additional_sql = ",ServiceOrderStateTXT=(select vtext from dictionary where vtitle='ServiceOrderState' and vID=ServiceOrdState),ServiceOrd_SaleName=(select OA_Name from OA_User where OA_User_ID=ServiceOrd_Sale_ID),ServiceOrd_CCName=(select OA_Name from OA_User where OA_User_ID=ServiceOrd_CC_ID),DispatchOrd_NSName=(select OA_Name from OA_User where OA_User_ID=DispatchOrd_NS_ID),ServiceOrdSource=(select vtext from dictionary where vtitle='OrdSource' and vID=ServiceOrdSource) ,HospNameA=(select HospName from HospData where HospID=ServiceOrdPtOutHospID),HospNameB=(select HospName from HospData where HospID=ServiceOrdPtInHospID),PaidType=(SELECT  STUFF(( select ',' + vtext from PaidMoney,dictionary where vtitle='PaidMoneyType' and vType>=1 and vID=PaidMoneyType and PaidMoney<>0 and ServiceOrdIDDt=ServiceOrdID GROUP BY vtext FOR XML PATH('')), 1, 1, '') AS PaidType),HospDepartmentName=isnull((select top 1 vtext from dictionary where vtitle='HospitalDepartment' and ServiceOrdPtServicesID=vID),''),HospDepartmentInName=isnull((select top 1 vtext from dictionary where vtitle='HospitalDepartment' and ServiceOrdPtInServicesID=vID),''),isRespirator=AMV_is,EntourageName='--',MessageCountInt=FromHQ_is,Stime2='--'";
@@ -304,7 +304,7 @@
 	 ,ServiceOrdTraDistance,DispatchOrdCarID,DispatchOrd_NS_Time,DispatchOrdActualDate,DispatchOrd_OAName,DispatchOrd_OAEntourage,FromHQ_is,FromHQ2_is,ServiceOrdPtName,ServiceOrdPtServices,ServiceOrdTraVia,ServiceOrdTraEnd
 	 ,HopsProvince=hospA.HopsProvince,HopsCity=hospA.HopsCity,HopsArea=hospA.HopsArea,HospName=hospA.HospName
 	 ,HopsProvinceIn=hospB.HopsProvince,HopsCityIn=hospB.HopsCity,HopsAreaIn=hospB.HopsArea,HospNameIn=hospB.HospName,ServiceOrdTaskRemarks
-	 ,ServiceOrd_work_ID,ServiceOrd_work_IDs,ServiceOrd_work_is,CommissionScenarioID
+	 ,ServiceOrd_work_ID,ServiceOrd_work_IDs,ServiceOrd_work_is,CommissionScenarioID,ServiceOrdStairClimberPrice
 	 ,row_number() over (order by DispatchOrd_NS_Time desc) n  $sqlWhere";
 	//闄勫姞缁撴灉SQL
 	$Additional_sql = ",DispatchOrdStateTXT=(select vtext from dictionary where vtitle='DispatchOrdState' and vID=DispatchOrdState)
@@ -324,6 +324,42 @@
 	";
 	//$sql=",isRespirator=(select count(id) from ServiceOrd_Condition where ConditionID=4 and ServiceOrdCoID=ServiceOrdID)"
 }
+/**
+ * 鏍规嵁 DispatchOrdID 鏌ユ壘寮�鍗曚汉鍙婅窡鍗曚汉鍒楄〃
+ * 
+ * @param int $ServiceOrdID 璋冨害鍗� ID
+ * @param object $conn 鏁版嵁搴撹繛鎺ュ璞�
+ * @return array 鍖呭惈寮�鍗曚汉鍙婅窡鍗曚汉淇℃伅鐨勬暟缁�
+ */
+function getDispatchOrderStaff($ServiceOrdID, $conn) {
+    $staffList = [];
+
+    // 鏌ヨ寮�鍗曚汉淇℃伅
+    $sqlDispatcher = "select PersonName,CommissionRatio from ServiceOrderCommissionDetails where ServiceOrderID='$ServiceOrdID' and PersonType='Opener'";
+                      
+    $dataDispatcher = sqlsrv_query($conn, $sqlDispatcher);
+    if ($dataDispatcher && sqlsrv_has_rows($dataDispatcher)) {
+        $rsDispatcher = sqlsrv_fetch_array($dataDispatcher);
+        $staffList['Opener'] = $rsDispatcher['PersonName'];
+        $staffList['OpenerCommissionRatio'] = $rsDispatcher['CommissionRatio'];
+    }
+
+    // 鏌ヨ璺熷崟浜哄垪琛�
+    $sqlEntourage = "select PersonName,CommissionRatio from ServiceOrderCommissionDetails where ServiceOrderID='$ServiceOrdID' and PersonType='Follower'";
+    $dataEntourage = sqlsrv_query($conn, $sqlEntourage);
+    if ($dataEntourage) {
+        $entourageList = [];
+		$i=1;
+        while ($rsEntourage = sqlsrv_fetch_array($dataEntourage)) {
+            $entourageList[$i]["Follower"] = $rsEntourage['PersonName'];
+            $entourageList[$i]["FollowerRatio"] = $rsEntourage['CommissionRatio'];
+			$i++;
+        }
+        $staffList['entourage'] = $entourageList;
+    }
+
+    return $staffList;
+}
 //echo $total_sql;exit;
 if ($is_CSV!=1){
 	//璁$畻鎬婚〉鏁�
@@ -341,12 +377,16 @@
 	$sqlPage="" ;
 }
 $sql = "select * $Additional_sql from ($Result_sql) sqlData ".$sqlPage." order by sqlData.n" ;
-//echo $sql;exit;
+//  echo $sql;exit;
+
+// 鍒濆鍖栧彉閲忥紝纭繚鍦ㄦ墍鏈夋儏鍐典笅閮借瀹氫箟
+$FormArrayX = 0;
+$FormArray = array();
+
 $data = sqlsrv_query($conn,$sql);
 if($data == true){
-	$FormArray=array();
 	//琛ㄥご
-	$FormArray[0]=array("搴忓彿","鏈嶅姟鍗曞彿","璋冨害鍗曞彿","绾у埆","鍒嗗尯","棰勭害绫诲瀷","璋冨害鍗曠姸鎬�","鏃ユ湡","鏃堕棿","鐝","鑱旂郴浜�","鑱旂郴鐢佃瘽","鎮h�呭鍚�","閿�鍞�","浠嬬粛浜�","瀹㈡湇","璋冨害","鏉ユ簮","鏄惁浼佸井鎴愪氦","涓昏浼佸井瀹㈡湇","鍏朵粬浼佸井瀹㈡湇","鎯呮櫙缂栧彿","浼佸井缁╂晥","鎬婚儴涓嬪彂","鏀彺鎬婚儴","鎵垮寘缁�","鍖哄煙","绫诲瀷","鍑哄彂鐪佷唤","鍑哄彂甯�","鍑哄彂鍖�","杞嚭鍖婚櫌","杞嚭绉戝","杞嚭搴婁綅","杞叆鐪佷唤","杞叆甯�","杞叆鍖�","杞叆鍖婚櫌","杞叆绉戝","鎬绘垚浜や环","绯荤粺鎶ヤ环鍙傝��","绛夊緟璐�","鎷呮灦璐�","灞呭ICU璐�","璺濈(鍏噷)","鏀粯鏂瑰紡","浣跨敤鍛煎惛鏈�","杞︾墝","鍑鸿溅鎴愬憳","鍑鸿溅宀椾綅","鍖绘姢鍑鸿溅鏃堕棿(鍒嗛挓)");
+	$FormArray[0]=array("搴忓彿","鏈嶅姟鍗曞彿","璋冨害鍗曞彿","绾у埆","鍒嗗尯","棰勭害绫诲瀷","璋冨害鍗曠姸鎬�","鏃ユ湡","鏃堕棿","鐝","鑱旂郴浜�","鑱旂郴鐢佃瘽","鎮h�呭鍚�","閿�鍞�","浠嬬粛浜�","瀹㈡湇","璋冨害","鏉ユ簮","鏄惁浼佸井鎴愪氦","涓昏浼佸井瀹㈡湇","鍏朵粬浼佸井瀹㈡湇","鎯呮櫙缂栧彿","浼佸井缁╂晥","鎬婚儴涓嬪彂","鏀彺鎬婚儴","鎵垮寘缁�","鍖哄煙","绫诲瀷","鍑哄彂鐪佷唤","鍑哄彂甯�","鍑哄彂鍖�","杞嚭鍖婚櫌","杞嚭绉戝","杞嚭搴婁綅","杞叆鐪佷唤","杞叆甯�","杞叆鍖�","杞叆鍖婚櫌","杞叆绉戝","鎬绘垚浜や环","鐖ゼ鏈鸿垂","绯荤粺鎶ヤ环鍙傝��","绛夊緟璐�","鎷呮灦璐�","灞呭ICU璐�","璺濈(鍏噷)","鏀粯鏂瑰紡","浣跨敤鍛煎惛鏈�","杞︾墝","鍑鸿溅鎴愬憳","鍑鸿溅宀椾綅","鍖绘姢鍑鸿溅鏃堕棿(鍒嗛挓)","寮�鍗曚汉","寮�鍗曚汉鎻愭垚姣斾緥","璺熷崟浜�","璺熷崟浜烘彁鎴愭瘮渚�","璺熷崟浜�","璺熷崟浜烘彁鎴愭瘮渚�","璺熷崟浜�","璺熷崟浜烘彁鎴愭瘮渚�","璺熷崟浜�","璺熷崟浜烘彁鎴愭瘮渚�");
 	if ($is_CSV==1){array_push($FormArray[0],"浠诲姟澶囨敞");}
 	$FormArrayX=count($FormArray[0]);
 	if (sqlsrv_rows_affected($data)==0) {
@@ -366,11 +406,11 @@
 				$isRespirator="鏄�";
 			}
 			//璇诲彇鏁版嵁--End
-			
+			$ServiceOrdID=$rs['ServiceOrdID'];
 			//鍐欏叆鏁扮粍
 			$FormArray[$i][0]=$i+(($page-1)*$page_size);
 			If ($OrdType=="2") {
-				$FormArray[$i][1]="<a href='ServiceOrder.gds?ServiceOrdID=".$rs['ServiceOrdID']."&OrdDateType=4&OrdClassList=&h_menu1_1=1' target='_blank'>".$rs['ServiceOrdNo']."</a>";
+				$FormArray[$i][1]="<a href='ServiceOrder.gds?ServiceOrdID=".$ServiceOrdID."&OrdDateType=4&OrdClassList=&h_menu1_1=1' target='_blank'>".$rs['ServiceOrdNo']."</a>";
 				if (!empty($rs['DispatchOrdNo'])) {
 					$FormArray[$i][2]="<a href='DispatchOrder.gds?DispatchOrdID=".$rs['DispatchOrdID']."&OrdDateType=4&OrdClassList=&h_menu1_1=1' target='_blank'>".$rs['DispatchOrdNo']."</a>";
 				}else{
@@ -475,19 +515,60 @@
 			$FormArray[$i][37]=$HospNameIn;
 			$FormArray[$i][38]=$rs['HospDepartmentInName'];
 			$FormArray[$i][39]=round($rs['OrdTraPrice'],2);
+			$ServiceOrdStairClimberPrice=$rs['ServiceOrdStairClimberPrice'];
+			$FormArray[$i][40]=floatval(number_format($ServiceOrdStairClimberPrice,2,".",""));
 			if (!empty($rs['OrderPrice_Auto'])) {$OrderPrice_Auto=round($rs['OrderPrice_Auto'],2);}else{$OrderPrice_Auto='--';}
-			$FormArray[$i][40]=$OrderPrice_Auto;
-			$FormArray[$i][41]=round($rs['AddMoney1'],2);
-			$FormArray[$i][42]=round($rs['AddMoney2'],2);
-			$FormArray[$i][43]=round($rs['AddMoney3'],2);
-			$FormArray[$i][44]=str_replace("鍏噷","",$rs['ServiceOrdTraDistance']);
-			$FormArray[$i][45]=$rs['PaidType'];
-			$FormArray[$i][46]=$isRespirator;
-			$FormArray[$i][47]=CarDataA($rs['DispatchOrdCarID'],'','CarLicense');
-			$FormArray[$i][48]=$rs['EntourageName'];
-			$FormArray[$i][49]=$rs['EntouragePost'];
-			$FormArray[$i][50]=$rs['Stime2'];
-			if ($is_CSV==1){$FormArray[$i][51]=$rs['ServiceOrdTaskRemarks'];}
+			$FormArray[$i][41]=$OrderPrice_Auto;
+			$FormArray[$i][42]=round($rs['AddMoney1'],2);
+			$FormArray[$i][43]=round($rs['AddMoney2'],2);
+			$FormArray[$i][44]=round($rs['AddMoney3'],2);
+			$FormArray[$i][45]=str_replace("鍏噷","",$rs['ServiceOrdTraDistance']);
+			$FormArray[$i][46]=$rs['PaidType'];
+			$FormArray[$i][47]=$isRespirator;
+			$FormArray[$i][48]=CarDataA($rs['DispatchOrdCarID'],'','CarLicense');
+			$FormArray[$i][49]=$rs['EntourageName'];
+			$FormArray[$i][50]=$rs['EntouragePost'];
+			$FormArray[$i][51]=$rs['Stime2'];
+			$rs2=getDispatchOrderStaff($ServiceOrdID, $conn);
+			//濡傛灉 $rs2 涓虹┖锛岃缃粯璁ゅ��
+			if (empty($rs2)) {
+				$FormArray[$i][52]='--';
+				$FormArray[$i][53]='';
+			}else{
+				$FormArray[$i][52]=isset($rs2['Opener'])?$rs2['Opener']:'--';
+				$FormArray[$i][53]=isset($rs2['OpenerCommissionRatio'])?$rs2['OpenerCommissionRatio']:'';
+			}
+			if (!empty($rs2['entourage'])) {
+				//$rs2['entourage']鐨勯暱搴�
+			
+				$FormArray[$i][54]='--';
+				$FormArray[$i][55]='';
+				$FormArray[$i][56]='--';
+				$FormArray[$i][57]='';
+				$FormArray[$i][58]='--';
+				$FormArray[$i][59]='';
+				$FormArray[$i][60]='--';
+				$FormArray[$i][61]='';
+				$j=0;
+				
+				foreach ($rs2['entourage'] as $key => $value) {
+					$FormArray[$i][54+$j*2]=$value['Follower'];
+					$FormArray[$i][55+$j*2]=$value['FollowerRatio'];
+					$j++;
+				}	
+
+				
+			}else{
+				$FormArray[$i][54]='--';
+				$FormArray[$i][55]='';
+				$FormArray[$i][56]='--';
+				$FormArray[$i][57]='';
+				$FormArray[$i][58]='--';
+				$FormArray[$i][59]='';
+				$FormArray[$i][60]='--';
+				$FormArray[$i][61]='';
+			}
+			if ($is_CSV==1){$FormArray[$i][62]=$rs['ServiceOrdTaskRemarks'];}
 
 			$i++;
 			//鍐欏叆鏁扮粍--End

--
Gitblit v1.9.1