ShuanghongS 2 meses atrás
pai
commit
9dd186432c
2 arquivos alterados com 35 adições e 28 exclusões
  1. 31 23
      service/destination_delivery.class.php
  2. 4 5
      utils/common.class.php

+ 31 - 23
service/destination_delivery.class.php

@@ -999,34 +999,42 @@ class destination_delivery {
 
             //前端按钮 后台权限拦截
             common::checkedActionLegal($serial_no,$operate);
-            $sql = "";
-            //审核通过时,才取下放当时应用修改的地址
-            if ($status == "Approve") {
-                $delivery_booking = common::excuteObjectSql("select *,array_to_json(address_country) as address_country,
-                    array_to_json(h_serial_no) as h_serial_no_json,
-                    TO_CHAR( delivery_date, 'HH24:MI') AS _delivery_time,
-                    delivery_date::date AS _delivery_date
-                    from public.kln_destination_delivery where serial_no = '$serial_no'");
 
-                $onine_address = common::excuteListSql("select * from public.contacts_address_online where delivery_serial_no = '$serial_no'");
+            global $db;
+            $db->StartTrans();
+            try {
+                $sql = "";
+                //审核通过时,才取下放当时应用修改的地址
+                if ($status == "Approve") {
+                    $delivery_booking = common::excuteObjectSql("select *,array_to_json(address_country) as address_country,
+                        array_to_json(h_serial_no) as h_serial_no_json,
+                        TO_CHAR( delivery_date, 'HH24:MI') AS _delivery_time,
+                        delivery_date::date AS _delivery_date
+                        from public.kln_destination_delivery where serial_no = '$serial_no'");
 
-                $sql .= "delete from public.contacts_address_online where delivery_serial_no = '$serial_no';";
-                $sql .=common::returnDAddressRecord($delivery_booking["address_country"],$onine_address);
+                    $onine_address = common::excuteListSql("select * from public.contacts_address_online where delivery_serial_no = '$serial_no'");
+                    $sql .= "delete from public.contacts_address_online where delivery_serial_no = '$serial_no';";
+                    $sql .=common::returnDAddressRecord($delivery_booking["address_country"],$onine_address);
 
-                //Booking自動同步到Ksmart WO 的逻辑   保存在do_header和do_details表里
-                $sql .=common::saveWorkOrder($delivery_booking);
-            }
-            if ($status == "Reject" || $status == "Cancel") {
-                //这种情况,清除当前用户对这一票的修改和添加的信息
-                $sql .= "delete from public.contacts_address_online where delivery_serial_no = '$serial_no';";
-            }
+                    //Booking自動同步到Ksmart WO 的逻辑   保存在do_header和do_details表里
+                    common::saveWorkOrder($delivery_booking);
+                }
+                if ($status == "Reject" || $status == "Cancel") {
+                    //这种情况,清除当前用户对这一票的修改和添加的信息
+                    $sql .= "delete from public.contacts_address_online where delivery_serial_no = '$serial_no';";
+                }
 
-            $sql .= "update public.kln_destination_delivery set status = '$status', modify_by = '"._getLoginName()."',update_time = now() where serial_no = '$serial_no';";
-            $sql .="INSERT INTO public.kln_destination_delivery_operation_log(
-                            serial_no, action,notes, create_by, created_time, created_zone)
-                    VALUES ('$serial_no', '$status','$notes', '$action_user', now(), ''); ";
+                $sql .= "update public.kln_destination_delivery set status = '$status', modify_by = '"._getLoginName()."',update_time = now() where serial_no = '$serial_no';";
+                $sql .= "INSERT INTO public.kln_destination_delivery_operation_log(
+                                serial_no, action,notes, create_by, created_time, created_zone)
+                        VALUES ('$serial_no', '$status','$notes', '$action_user', now(), ''); ";
+
+                $db->Execute($sql) or ((!$db->ErrorMsg()) or error_log(common::dbLog($db, $sql), 0));
+                $rs = $db->CompleteTrans();
+            } catch (Exception $e) {
+                $db->RollbackTrans();
+            } 
 
-            $rs = common::excuteUpdateSql($sql);  
             if ($rs === FALSE){
                 $data = array("msg" => "Update Error");
                 common::echo_json_encode(200,$data);

+ 4 - 5
utils/common.class.php

@@ -4020,15 +4020,14 @@ class common {
      * Booking自動同步到Ksmart WO 的逻辑   保存在do_header和do_details表里
      */
     public static function saveWorkOrder($delivery_booking){
+        global $db;
         $h_serial_no_json  = $delivery_booking['h_serial_no_json'];
         $h_serial_no_arr  =json_decode($h_serial_no_json,true);
 
         $ctnr  = $delivery_booking['ctnr'];
-        
         //从UI 设计的case来讲,一个hbol就生成成一个wo ID 
         foreach($h_serial_no_arr as $serial_no){
             $sql = "";
-
             $oceanInfo = common::excuteObjectSql("select * from public.kln_ocean oo where oo.serial_no ='".$serial_no."'" );
             //空運我們先不管,不做同步,就只做創建到審批,後面的讓他們自己錄入系統處理吧
             if ($oceanInfo['transport_mode'] == "air"){
@@ -4067,7 +4066,7 @@ class common {
                 $total_volume += $_ctnr_info['cbm'];
             }      
 
-            $doHeaderId = common::excuteOneSql("select nextval('do_header_id_seq')");
+            $doHeaderId = $db->GetOne("select nextval('do_header_id_seq')");
             $sql .="INSERT INTO public.do_header(
                 id,air_ocean, station_code, biztype,delivery_type,mode_type,
                 serial_no, lot_no, awbbl_no, job_no, do_date,
@@ -4101,8 +4100,8 @@ class common {
                     '".$ctnr['marks']."','".$ctnr['description']."','KLN_Online',now(),
                     '".$ctnr['ctnr']."','".$ctnr['size']."','".$ctnr['seal_no']."','".$ctnr['is_lcl']."',
                     $l4_length,$l4_width,$l4_height);";
-            }    
-            common::excuteUpdateSql($sql);
+            }
+            $db->Execute($sql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $sql), 0)); 
         }
     }