diff --git a/webht/third_party/trippestOrderSync/controllers/order_finance.php b/webht/third_party/trippestOrderSync/controllers/order_finance.php index e5d07047..c33e796f 100644 --- a/webht/third_party/trippestOrderSync/controllers/order_finance.php +++ b/webht/third_party/trippestOrderSync/controllers/order_finance.php @@ -71,6 +71,7 @@ class Order_finance extends CI_Controller { $report_order['adultnumber'] = 0; $report_order['childnumber'] = 0; $report_order['babynumber'] = 0; + $report_order['orderstats'] = 1; $report_order['ordernumber'] = $order_info->ordernumber; $report_order['TuanName'] = mb_substr($order_info->TuanName, 0, 50); $report_order['operater'] = $order_info->operater; @@ -78,7 +79,7 @@ class Order_finance extends CI_Controller { $report_order['ChinaName'] = $order_info->ChinaName; $report_order['country'] = $order_info->country; $report_order['reservedate'] = $order_info->reservedate; - $report_order['guesttype'] = $order_info->guesttype; + $report_order['guesttype'] = ($order_info->guesttype===null) ? 1 : $order_info->guesttype; $report_order['RO_GRI_SN'] = $report_order['RO_CGI_SN'] = $order_info->GRI_SN; // $report_order['basemoney'] = $order_info->basemoney; // 总成本 // $report_order['OrderPrice'] = $order_info->OrderPrice; // 总报价 @@ -96,7 +97,7 @@ class Order_finance extends CI_Controller { $ret = new stdClass(); /** 图兰朵产品: 取拼团实际成本 */ - $ret->combine_cost = array(); + $ret->combine_cost = $ret->report_tour = array(); $combineNo_arr = $this->OrderFinance_model->get_order_combineNo($coli_sn); // $ret->x = $combineNo_arr; $group_type_arr = array_unique(array_map(function($ele){return $ele->GCI_groupType;}, $combineNo_arr)); @@ -190,7 +191,9 @@ class Order_finance extends CI_Controller { } /** 开始写入数据库 */ /** 图兰朵供应商 */ - $this->OrderFinance_model->insert_report_tour_tulanduo($ret->report_tour); + if ( ! empty($ret->report_tour)) { + $this->OrderFinance_model->insert_report_tour_tulanduo($ret->report_tour); + } /** 非图兰朵供应商的包价线路产品 */ $other_tour = $this->OrderFinance_model->get_order_detail($coli_sn, 'D', false); if ( ! empty($other_tour)) { diff --git a/webht/third_party/trippestOrderSync/models/orderFinance_model.php b/webht/third_party/trippestOrderSync/models/orderFinance_model.php index bbd89829..4f17b59d 100644 --- a/webht/third_party/trippestOrderSync/models/orderFinance_model.php +++ b/webht/third_party/trippestOrderSync/models/orderFinance_model.php @@ -130,7 +130,14 @@ class OrderFinance_model extends CI_Model { $query = $this->HT->query($sql); $ret->person_num = $query->num_rows(); $guest_type_cnt = array_count_values(array_map(function($ele) { return $ele->BPE_GuestType; }, $query->result())); - $ret->adult_num = $guest_type_cnt['1']; + if ($ret->person_num === 0) { + $sql2 = "SELECT COLD_PersonNum,COLD_ChildNum,isnull(COLD_BabyNum,0) COLD_BabyNum from BIZ_ConfirmLineDetail where COLD_COLI_SN=$coli_sn "; + $num_q = $this->HT->query($sql2)->row(); + $ret->person_num = $num_q->COLD_PersonNum + $num_q->COLD_ChildNum + $num_q->COLD_BabyNum; + $ret->adult_num = $num_q->COLD_PersonNum; + } else { + $ret->adult_num = $guest_type_cnt['1']; + } $ret->child_num = $ret->person_num-$ret->adult_num; return $ret; } @@ -194,7 +201,7 @@ class OrderFinance_model extends CI_Model { } public function report_order_exists($coli_id=null, $gri_sn=null) { - $sql = "SELECT top 1 ordernumber from report_order where ordernumber=? and ro_gri_sn=?"; + $sql = "SELECT top 1 ordernumber from report_order where ordernumber=? and ro_gri_sn=? and orderstats=1"; $num_rows = $this->HT->query($sql, array($coli_id, $gri_sn))->num_rows(); return $num_rows>0; } @@ -378,7 +385,8 @@ class OrderFinance_model extends CI_Model { /** 单团财务表 */ public function insert_report_order($report_order_arr=array(), $coli_sn=0, $gri_sn=0) { - if ( $this->report_order_exists($coli_sn, $gri_sn) === TRUE ) { + $this->HT->query("DELETE from Report_Order where ordernumber = '" . $report_order_arr['ordernumber'] . "' AND orderstats=0 "); + if ( $this->report_order_exists($report_order_arr['ordernumber'], $gri_sn) === TRUE ) { $where = " ordernumber='" . $report_order_arr['ordernumber'] . "' "; $update_sql = $this->HT->update_string('tourmanager.dbo.report_order', $report_order_arr, $where); $this->HT->query($update_sql); @@ -390,7 +398,7 @@ class OrderFinance_model extends CI_Model { public function get_report_order($coli_id=0) { - return $this->HT->query("SELECT top 1 * from tourmanager.dbo.report_order WHERE ordernumber='$coli_id' order by orderID desc")->row(); + return $this->HT->query("SELECT top 1 * from tourmanager.dbo.report_order WHERE ordernumber='$coli_id' and orderstats=1 order by orderID desc")->row(); } public function convert_to_RMB($money=0, $fromCurrency='USD')