diff --git a/webht/third_party/trippestOrderSync/controllers/order_finance.php b/webht/third_party/trippestOrderSync/controllers/order_finance.php index 52ac2aac..3fd1717e 100644 --- a/webht/third_party/trippestOrderSync/controllers/order_finance.php +++ b/webht/third_party/trippestOrderSync/controllers/order_finance.php @@ -262,6 +262,16 @@ class Order_finance extends CI_Controller { return null; } $ret->coli_sn = $coli_sn; + $payment_currency = "USD"; + $currency_rate = 1; + $order_payment = $this->OrderFinance_model->get_order_payment($coli_sn, TRUE); + foreach ($order_payment as $kp => $vp) { + if ($vp->GAI_SQJE > 0) { + $payment_currency = trim($vp->GAI_SQJECurrency); + $currency_rate = bcdiv($vp->GAI_SSJE, $vp->GAI_SQJE); + break; + } + } $all_pags = array_map(function($ele){ return mb_strtoupper($ele->PAG_Code);}, $all_orders); $all_pag = array_unique($all_pags); $combine_pag_arr = array(); @@ -337,6 +347,7 @@ class Order_finance extends CI_Controller { $ret->person_num = 0; $ret->PAG_Code = ""; $ret->order_cost = array(); + $ret->totalPrice_RMB = 0; $pag_sns = array(); $unique_coli = array(); foreach ($all_orders as $ko => $vo) { @@ -363,6 +374,16 @@ class Order_finance extends CI_Controller { $ret->order_cost[] = $tour_s; $ret->coli_id = $vo->coli_ID; } + // 预定产品的团款转换人民币, 写入财务表产品的备注 + // 补充的产品不算 + if ( ! isset($vo->real_pag_sn) && $vo->COLI_SN == $coli_sn) { + $vo->COLD_TotalPrice = $vo->COLD_TotalPrice===NULL ? 0 : $vo->COLD_TotalPrice; + if ($payment_currency == "USD" ) { + $ret->totalPrice_RMB = bcadd($ret->totalPrice_RMB, bcmul($vo->COLD_TotalPrice, $currency_rate)); + } else { + $ret->totalPrice_RMB = bcadd($ret->totalPrice_RMB, $this->OrderFinance_model->convert_to_RMB($vo->COLD_TotalPrice, 'USD')); + } + } } } $this_order_real_pag_sns = array_map(function($ele) {return $ele->real_pag_sn;}, $ret->order_cost); @@ -371,6 +392,7 @@ class Order_finance extends CI_Controller { $ret->pag_name = implode(";\r\n", array_map(function($ele) {return $ele->PAG_Title;}, $pags_info)) ; $ret->PAG_Code = implode(",", $ret->combine_pags); $ret->comment = "拼团" . $combineNo . ", 按" . $ret->person_num . "人等"; + $ret->comment .= $ret->totalPrice_RMB>0 ? (", 报价RMB " . $ret->totalPrice_RMB) : ""; $combine_cost = $this->OrderFinance_model->get_combine_sumMoney($combineNo); $ret->cost_category = $combine_cost->cost_category; $ret->cost_sum = $combine_cost->cost_sum; diff --git a/webht/third_party/trippestOrderSync/models/orderFinance_model.php b/webht/third_party/trippestOrderSync/models/orderFinance_model.php index c8d67668..e1ddd1e7 100644 --- a/webht/third_party/trippestOrderSync/models/orderFinance_model.php +++ b/webht/third_party/trippestOrderSync/models/orderFinance_model.php @@ -190,13 +190,16 @@ class OrderFinance_model extends CI_Model { return $this->HT->query($sql)->result(); } - public function get_order_payment($coli_sn=0) + public function get_order_payment($coli_sn=0, $detail=false) { $ret = new stdClass(); - $sql = "SELECT gai.GAI_SSDate,gai.GAI_SSJE,gai.GAI_Type + $sql = "SELECT gai.GAI_SSDate,gai.GAI_SQJE,gai.GAI_SSJE,gai.GAI_Type,gai.GAI_SQJECurrency from BIZ_GroupAccountInfo gai where gai.GAI_COLI_SN=$coli_sn and gai.DeleteFlag=0"; $payment = $this->HT->query($sql)->result(); + if ($detail === TRUE) { + return $payment; + } $ret->SSmoney = 0; $ret->patDate = ""; $ret->payType = "";