Merge branch 'master' into feature/pay

feature/pay
lyt 7 years ago
commit 6456f898f3

@ -660,7 +660,7 @@ $config['media_image_url_remote2'] = 'http://116.251.217.48:3581/upload';
//是否开启权限控制
$config['check_access'] = TRUE;
//权限管理超级管理
$config['access_super_manage'] = array('ycc', 'lmr');
$config['access_super_manage'] = array('ycc', 'lmr', 'lyj');
//编辑器预览样式路径
$config['css_source_cht'] = '<link href="https://data.chinahighlights.com/css/min.php?f=/public/css/global.min.css,/css/festival-detail.css" rel="stylesheet">';

@ -113,7 +113,8 @@ class AlipayTradeService extends CI_Controller
}
$code = isset($asyns_resp->data->code) ? strval($asyns_resp->data->code) : NULL ;
$buyer = isset($asyns_resp->data->buyer_logon_id) ? strval($asyns_resp->data->buyer_logon_id) : NULL ;
if (strcmp(trim(strval($asyns_resp->data->trade_status)), "TRADE_SUCCESS") == 0) {
if (strcmp(trim(strval($asyns_resp->data->trade_status)), "TRADE_SUCCESS") == 0
|| strcmp(trim(strval($asyns_resp->data->trade_status)), "TRADE_FINISHED") == 0) {
if ($notify_type === "pay") {
$this->Alipay_note_model->save_alipay(
strval($asyns_resp->data->trade_no)
@ -358,7 +359,8 @@ class AlipayTradeService extends CI_Controller
}
//只处理完成状态,其他状态由陆燕处理
if (strcmp(trim($item->ALI_resultMsg), "TRADE_SUCCESS")) {
if (strcmp(trim($item->ALI_resultMsg), "TRADE_SUCCESS")
|| strcmp(trim($item->ALI_resultMsg), "TRADE_FINISHED")) {
$this->Alipay_note_model->update_send($item->ALI_dealId, 'send');
continue;
}
@ -622,7 +624,8 @@ var_dump($response->$responseNode);
/** 手动查询通过收钱码的收款, 必须输入交易号 */
if (empty($data['notelist'])) {
$query_pay = $this->query_pay($data["keywords"]);
if ( ! empty($query_pay) && strval($query_pay->code)==="10000" && strval($query_pay->trade_status)==="TRADE_SUCCESS") {
if ( ! empty($query_pay) && strval($query_pay->code)==="10000"
&& in_array(strval($query_pay->trade_status), array("TRADE_SUCCESS", "TRADE_FINISHED")) ) {
$pay_type = $query_pay->total_amount>0 ? "pay" : "refund";
$new_record = $this->Alipay_note_model->save_alipay(
strval($query_pay->trade_no)

File diff suppressed because it is too large Load Diff

@ -0,0 +1,436 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
error_reporting(0);
class Api extends CI_Controller {
public function __construct(){
parent::__construct();
mb_regex_encoding("UTF-8");
$this->load->helper('array');
$this->load->library('trippest');
$this->load->model('Orders_query', 'Orders_model');
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:POST, GET');
header('Access-Control-Max-Age:0');
header('Access-Control-Allow-Headers:x-requested-with, Content-Type');
header('Access-Control-Allow-Credentials:true');
}
public function index()
{
$this->operation_detail();
}
public function operation_detail($find=null)
{
($find===null) ? $find = $this->input->get_post('q') : null;
$find = (mb_strlen($find)<9) ? null : $find;
preg_match('/[\d]+\-?[\w]*/', characet($find, "UTF-8"), $temp_array);
$find = isset($temp_array[0]) ? $temp_array[0] : null;
$order_plan = null;
if ($find !== null) {
$order_plan = $this->Orders_model->get_order_vendorplan($find);
}
if ($find===null || $order_plan == null) {
$ret['status'] = 0;
$ret['msg'] = "Not Found.";
return $this->output->set_content_type('application/json')->set_output(json_encode($ret));
}
$ret['status'] = 1;
$ret['msg'] = "";
$gri_sn = $order_plan[0]->VAS_GRI_SN;
$group_number_info = analysis_groupCode($order_plan[0]->COLI_GroupCode);
$ret['group_number'] = $group_number_info["all"];
$operation_info = $ht_tourguide = $this->tourguide_common($gri_sn);
if (empty($operation_info)) {
return $this->operation_detail_tulanduo($find);
}
$ret['operation'] = $operation_info;
/** 外联信息 */
$raw_opi_id = 0;
if (intval($order_plan[0]->COLI_OPI_ID) === 435) {
$real_code_info = analysis_groupCode($ret['group_number']);
$raw_opi_id = $this->Orders_model->get_gri_opi_id($real_code_info['cut']);
} else {
$raw_opi_id = $order_plan[0]->COLI_OPI_ID;
}
$operator = $this->Orders_model->get_operator($raw_opi_id);
if ( ! empty($operator)) {
$ret['operator']['chinese_name'] = $operator->OPI_Name;
$ret['operator']['mobile'] = $operator->OPI_MoveTelephone;
$ret['operator']['email'] = $operator->OPI_Email;
$ret['operator']['english_name'] = $operator->OPI2_Name;
// 英文名没有
if ($operator->OPI_FirstName == null || $operator->OPI2_Name == null ) {
$ret['operator']['english_name'] = ucfirst(strstr($operator->OPI_Email, "@", true));
}
}
return $this->output->set_content_type('application/json')->set_output(json_encode($ret));
}
public function tourguide_common($gri_sn)
{
$operation = array();
$tourguide = $this->Orders_model->get_plan_tourguide($gri_sn);
if (empty($tourguide)) {
return null;
}
$order_detail = $this->Orders_model->get_order_detail($gri_sn);
foreach ($order_detail as $kd => $poi) {
$operation_tmp = array();
$operation_tmp['start_date'] = substr($poi->COLD_StartDate, 0, 10);
$out_datetime = strtotime($poi->COLD_StartDate);
$out_datetime2 = strtotime($poi->COLD_EndDate);
$operation_tmp['dateWeek_text'] = date('D', $out_datetime);
$operation_tmp['dateDay_text'] = date('d', $out_datetime);
$operation_tmp['dateMonth_text'] = date('M', $out_datetime);
$operation_tmp['dateYear_text'] = date('Y', $out_datetime);
if ($out_datetime !== $out_datetime2) {
$operation_tmp['start_date'] = $poi->COLD_StartDate . " to " . $poi->COLD_EndDate;
}
$operation_tmp['tour_name'] = $poi->PAG2_Name;
$code_name = $this->trippest->tour_name(strtoupper($poi->pag_code));
if ($code_name !== "") {
$operation_tmp['tour_name'] = $code_name;
}
// 领队名字
// $operation_tmp['full_leader_name'] = trim($poi->GUT_FirstName . " " . $poi->GUT_LastName);
$replace_cnt1 = $replace_cnt2 = 0;
if (mb_strlen($poi->GUT_FirstName, 'UTF-8') > 2) {
$replace_cnt1 = mb_strlen($poi->GUT_FirstName, 'UTF-8')-2;
}
if (mb_strlen($poi->GUT_LastName, 'UTF-8') > 2) {
$replace_cnt2 = mb_strlen($poi->GUT_LastName, 'UTF-8')-2;
}
$operation_tmp['leader_name'] = substr_replace($poi->GUT_FirstName,str_repeat('*', $replace_cnt1),1,-1) . " " . substr_replace($poi->GUT_LastName,str_repeat('*', $replace_cnt2),1,-1);
$operation_tmp['leader_name'] = trim($operation_tmp['leader_name']);
// 行程人数
$operation_tmp['personNum_text'] = $poi->COLD_PersonNum + $poi->COLD_ChildNum;
$operation_tmp['personNum_text'] .= " (" . $poi->COLD_PersonNum . " Adult(s)";
if ($poi->COLD_ChildNum > 0) {
$operation_tmp['personNum_text'] .= " " . $poi->COLD_ChildNum . " Child(ren)";
}
$operation_tmp['personNum_text'] .= ")" ;
// 人数
$operation_tmp['adult_number'] = $poi->COLD_PersonNum;
$operation_tmp['kid_number'] = $poi->COLD_ChildNum;
// 酒店
$operation_tmp['hotel_name'] = $poi->POI_Hotel;
$operation_tmp['hotel_address'] = $poi->POI_HotelAddress;
$operation_tmp['hotel_tel'] = $poi->POI_HotelPhone;
// 航班/车次
$operation_tmp['flights_no'] = $poi->POI_FlightsNo;
$operation_tmp['flights_airport'] = $poi->POI_AirPort;
// 接送信息
$operation_tmp['pick_up'] = "";
$operation_tmp['drop_off'] = "";
$decode_MemoText = $memo_text_tmp = "";
$operation_tmp['pick_up'] = trim(substr(strstr(strstr($poi->COLI_OrderDetailText, "Pick Up From:"), "\n", true), 13));
$operation_tmp['drop_off'] = trim(substr(strstr(strstr($poi->COLI_OrderDetailText, "Drop Off:"), "\n" , true), 9));
if ($operation_tmp['pick_up'] === "") {
if (strval($poi->PAGS_Direction) === '0') {
$operation_tmp['pick_up'] .= $poi->POI_FlightsNo . " " . $poi->POI_AirPort;
$operation_tmp['drop_off'] .= $poi->POI_Hotel;
} else if (strval($poi->PAGS_Direction) === '1') {
$operation_tmp['pick_up'] .= $poi->POI_Hotel;
$operation_tmp['drop_off'] .= $poi->POI_FlightsNo . " " . $poi->POI_AirPort;
} else { // if ($poi->POI_FlightsNo != "")
$operation_tmp['pick_up'] .= $poi->POI_Hotel;
// $operation_tmp['drop_off'] .= $poi->POI_FlightsNo . " " . $poi->POI_AirPort; // 结束后送机
}
}
$opd = new stdclass();
foreach ($tourguide as $key => $tgi) {
if ($poi->COLD_PlanVEI_SN === $tgi->EOI_VEI_SN
// && strcmp($operation_tmp['start_date_raw'], substr($poi->COLD_StartDate, 0, 10) ) === 0
) {
$opd = $tgi;
}
}
if (empty($opd)) {
$opd = $tgi[0];
}
$tourguide_tmp['guide_name'] = $opd->TGI2_Name;
$tourguide_tmp['guide_tel'] = $opd->TGI_Mobile;
$tourguide_tmp['guide_pic'] = "";
// $tourguide_tmp['using_startdate'] = $opd->GCOD_startDate;
// $tourguide_tmp['using_enddate'] = $opd->GCOD_endDate;
$operation_tmp['tourguide'][] = $tourguide_tmp;
$tourguide_tmp = array();
$operation[] = $operation_tmp;
}
return $operation;
}
public function operation_detail_tulanduo($find=null)
{
// ($find===null) ? $find = $this->input->get_post('q') : null;
// $find = (mb_strlen($find)<9) ? null : $this->input->get_post('q');
$order_project = $this->Orders_model->get_package_order($find);
if ($find===null || $order_project == null) {
$ret['status'] = 0;
$ret['msg'] = "Not Found.";
return $this->output->set_content_type('application/json')->set_output(json_encode($ret));
}
$ret['status'] = 1;
$ret['msg'] = "";
$group_number_info = analysis_groupCode($order_project[0]->COLI_GroupCode);
$ret['group_number'] = $group_number_info["all"];
$all_combine_no = array_unique(array_map(function($ele)
{
return $ele->GCI_combineNo;
}, $order_project));
$ret['operation'] = array();
$operation = $this->Orders_model->get_operation($all_combine_no);
// 司机, 导游
if ( ! empty($operation)) {
// 按照实际安排的日期分组
foreach ($operation as $key => $value) {
if ($value->GCOD_operationType === 'touristCarOperations') {
$tmp_car = array();
$tmp_car['car_type'] = $value->GCOD_subType;
$tmp_car['car_company'] = $value->GCOD_title;
$tmp_car['car_license'] = $value->GCOD_carLicense;
$tmp_car['driver_name'] = $value->GCOD_dutyName;
$tmp_car['driver_tel'] = $value->GCOD_dutyTel;
$tmp_car['driver_pic'] = $value->GCOD_dutyPhoto;
$tmp_car['car_remark'] = $value->GCOD_remark;
$tmp_car['using_startdate'] = $value->GCOD_startDate;
$tmp_car['using_enddate'] = $value->GCOD_endDate;
$ret['operation'][$value->GCOD_startDate]['cardriver'][] = $tmp_car;
// 出团时间
$ret['operation'][$value->GCOD_startDate]['start_date'] = $value->GCOD_startDate;
if ( ! isset($ret['operation'][$value->GCOD_startDate]['end_date'])
|| strtotime($ret['operation'][$value->GCOD_startDate]['end_date']) > strtotime($value->GCOD_endDate)
) {
$ret['operation'][$value->GCOD_startDate]['end_date'] = $value->GCOD_endDate;
}
}
else if ($value->GCOD_operationType === 'guiderOperations') {
$tmp_g = array();
$tmp_g['guide_name'] = $value->GCOD_dutyName;
$tmp_g['guide_tel'] = $value->GCOD_dutyTel;
$tmp_g['guide_pic'] = $value->GCOD_dutyPhoto;
$tmp_g['guide_remark'] = $value->GCOD_remark;
$tmp_g['using_startdate'] = $value->GCOD_startDate;
$tmp_g['using_enddate'] = $value->GCOD_endDate;
$ret['operation'][$value->GCOD_startDate]['tourguide'][] = $tmp_g;
// 出团时间
$ret['operation'][$value->GCOD_startDate]['start_date'] = $value->GCOD_startDate;
if ( ! isset($ret['operation'][$value->GCOD_startDate]['end_date'])
|| strtotime($ret['operation'][$value->GCOD_startDate]['end_date']) > strtotime($value->GCOD_endDate)
) {
$ret['operation'][$value->GCOD_startDate]['end_date']= $value->GCOD_endDate;
}
}
}
// 加上行程
$num_index = 0;
foreach ($ret['operation'] as $kro => &$vro) {
$vro['start_date_raw'] = $vro['start_date'];
$out_datetime = strtotime($vro['start_date']);
$out_datetime2 = strtotime($vro['end_date']);
$vro['dateWeek_text'] = date('D', $out_datetime);
$vro['dateDay_text'] = date('d', $out_datetime);
$vro['dateMonth_text'] = date('M', $out_datetime);
$vro['dateYear_text'] = date('Y', $out_datetime);
if ($out_datetime !== $out_datetime2) {
$vro['start_date'] = $vro['start_date'] . " to " . $vro['end_date'];
}
$poi = new stdclass();
foreach ($order_project as $kd => $poi_info) {
if (strcmp($vro['start_date_raw'], substr($poi_info->COLD_StartDate, 0, 10) ) === 0) {
if (count((array)$poi)===0) {
$poi = $poi_info;
} else if ($poi->POI_Hotel == "") {
$poi->POI_Hotel = $poi_info->POI_Hotel;
$poi->POI_HotelAddress = $poi_info->POI_HotelAddress;
$poi->POI_HotelPhone = $poi_info->POI_HotelPhone;
// } else if ($poi->POI_FlightsNo == "") {
} else if ($poi_info->POI_FlightsNo != "" && $poi_info->COLD_SN != $poi->COLD_SN) {
$poi->POI_FlightsNo .= "; " . $poi_info->POI_FlightsNo;
// $poi->POI_AirPort .= "; " . $poi_info->POI_AirPort;
}
}
}
if (count((array)$poi)===0) {
$poi = $order_project[0];
}
$vro['cold_date'] = $poi->COLD_StartDate;
$vro['cold_enddate'] = $poi->COLD_EndDate;
$vro['tour_name'] = $poi->PAG2_Name;
$code_name = $this->trippest->tour_name(strtoupper($poi->pag_code));
if ($code_name !== "") {
$vro['tour_name'] = $code_name;
}
// 领队名字
// $vro['full_leader_name'] = trim($poi->GUT_FirstName . " " . $poi->GUT_LastName);
$replace_cnt1 = $replace_cnt2 = 0;
if (mb_strlen($poi->GUT_FirstName, 'UTF-8') > 2) {
$replace_cnt1 = mb_strlen($poi->GUT_FirstName, 'UTF-8')-2;
}
if (mb_strlen($poi->GUT_LastName, 'UTF-8') > 2) {
$replace_cnt2 = mb_strlen($poi->GUT_LastName, 'UTF-8')-2;
}
$vro['leader_name'] = substr_replace($poi->GUT_FirstName, str_repeat('*', $replace_cnt1), 1,-1) . " " . substr_replace($poi->GUT_LastName,str_repeat('*', $replace_cnt2),1,-1);
$vro['leader_name'] = trim($vro['leader_name']);
// 行程人数
$vro['personNum_text'] = $poi->COLD_PersonNum + $poi->COLD_ChildNum;
$vro['personNum_text'] .= " (" . $poi->COLD_PersonNum . " Adult(s)";
if ($poi->COLD_ChildNum > 0) {
$vro['personNum_text'] .= " " . $poi->COLD_ChildNum . " Child(ren)";
}
$vro['personNum_text'] .= ")" ;
// 人数
$vro['adult_number'] = $order_project[0]->COLD_PersonNum;
$vro['kid_number'] = $order_project[0]->COLD_ChildNum;
// 酒店
$vro['hotel_name'] = $poi->POI_Hotel;
$vro['hotel_address'] = $poi->POI_HotelAddress;
$vro['hotel_tel'] = $poi->POI_HotelPhone;
// 航班/车次
$vro['flights_no'] = $poi->POI_FlightsNo;
$vro['flights_airport'] = $poi->POI_AirPort;
// 接送信息
$vro['pick_up'] = "";
$vro['drop_off'] = "";
$decode_MemoText = $memo_text_tmp = "";
if ($vro['pick_up'] === "" && $poi->COLD_MemoText != null && json_decode($poi->COLD_MemoText) != null) {
$decode_MemoText = json_decode($poi->COLD_MemoText, true);
$vro['pick_up'] = $decode_MemoText['Pick up'];
$vro['drop_off'] = $decode_MemoText['Drop off'];
}
if ($vro['pick_up'] === "" && $num_index == 0) {
$vro['pick_up'] = trim(substr(strstr(strstr($poi->COLI_OrderDetailText, "Pick Up From:"), "\n", true), 13));
$vro['drop_off'] = trim(substr(strstr(strstr($poi->COLI_OrderDetailText, "Drop Off:"), "\n" , true), 9));
}
if ($vro['pick_up'] === "") {
if (strval($poi->PAGS_Direction) === '0') {
$vro['pick_up'] .= $poi->POI_FlightsNo . " " . $poi->POI_AirPort;
$vro['drop_off'] .= $poi->POI_Hotel;
} else if (strval($poi->PAGS_Direction) === '1') {
$vro['pick_up'] .= $poi->POI_Hotel;
$vro['drop_off'] .= $poi->POI_FlightsNo . " " . $poi->POI_AirPort;
} else { // if ($poi->POI_FlightsNo != "")
$vro['pick_up'] .= $poi->POI_Hotel;
// $vro['drop_off'] .= $poi->POI_FlightsNo . " " . $poi->POI_AirPort; // 结束后送机
}
}
$num_index++;
}
unset($vro);
} else {
foreach ($order_project as $kd => $poi) {
$vro = array();
$vro['start_date_raw'] = $vro['start_date'] = substr($poi->COLD_StartDate, 0, 10);
$out_datetime = strtotime($poi->COLD_StartDate);
$out_datetime2 = strtotime($poi->COLD_EndDate);
$vro['dateWeek_text'] = date('D', $out_datetime);
$vro['dateDay_text'] = date('d', $out_datetime);
$vro['dateMonth_text'] = date('M', $out_datetime);
$vro['dateYear_text'] = date('Y', $out_datetime);
if ($out_datetime !== $out_datetime2) {
$vro['start_date'] = $poi->COLD_StartDate . " to " . $poi->COLD_EndDate;
}
$vro['cold_date'] = $poi->COLD_StartDate;
$vro['cold_enddate'] = $poi->COLD_EndDate;
$vro['tour_name'] = $poi->PAG2_Name;
$code_name = $this->trippest->tour_name(strtoupper($poi->pag_code));
if ($code_name !== "") {
$vro['tour_name'] = $code_name;
}
// 领队名字
// $vro['full_leader_name'] = trim($poi->GUT_FirstName . " " . $poi->GUT_LastName);
$replace_cnt1 = $replace_cnt2 = 0;
if (mb_strlen($poi->GUT_FirstName, 'UTF-8') > 2) {
$replace_cnt1 = mb_strlen($poi->GUT_FirstName, 'UTF-8')-2;
}
if (mb_strlen($poi->GUT_LastName, 'UTF-8') > 2) {
$replace_cnt2 = mb_strlen($poi->GUT_LastName, 'UTF-8')-2;
}
$vro['leader_name'] = substr_replace($poi->GUT_FirstName,str_repeat('*', $replace_cnt1),1,-1) . " " . substr_replace($poi->GUT_LastName,str_repeat('*', $replace_cnt2),1,-1);
$vro['leader_name'] = trim($vro['leader_name']);
// 行程人数
$vro['personNum_text'] = $poi->COLD_PersonNum + $poi->COLD_ChildNum;
$vro['personNum_text'] .= " (" . $poi->COLD_PersonNum . " Adult(s)";
if ($poi->COLD_ChildNum > 0) {
$vro['personNum_text'] .= " " . $poi->COLD_ChildNum . " Child(ren)";
}
$vro['personNum_text'] .= ")" ;
// 人数
$vro['adult_number'] = $order_project[0]->COLD_PersonNum;
$vro['kid_number'] = $order_project[0]->COLD_ChildNum;
// 酒店
$vro['hotel_name'] = $poi->POI_Hotel;
$vro['hotel_address'] = $poi->POI_HotelAddress;
$vro['hotel_tel'] = $poi->POI_HotelPhone;
// 航班/车次
$vro['flights_no'] = $poi->POI_FlightsNo;
$vro['flights_airport'] = $poi->POI_AirPort;
// 接送信息
$vro['pick_up'] = "";
$vro['drop_off'] = "";
$decode_MemoText = $memo_text_tmp = "";
if ($vro['pick_up'] === "" && $poi->COLD_MemoText != null && json_decode($poi->COLD_MemoText) != null) {
$decode_MemoText = json_decode($poi->COLD_MemoText, true);
$vro['pick_up'] = $decode_MemoText['Pick up'];
$vro['drop_off'] = $decode_MemoText['Drop off'];
}
if ($vro['pick_up'] === "" && $kd == 0) {
$vro['pick_up'] = trim(substr(strstr(strstr($poi->COLI_OrderDetailText, "Pick Up From:"), "\n", true), 13));
$vro['drop_off'] = trim(substr(strstr(strstr($poi->COLI_OrderDetailText, "Drop Off:"), "\n" , true), 9));
}
if ($vro['pick_up'] === "") {
if (strval($poi->PAGS_Direction) === '0') {
$vro['pick_up'] .= $poi->POI_FlightsNo . " " . $poi->POI_AirPort;
$vro['drop_off'] .= $poi->POI_Hotel;
} else if (strval($poi->PAGS_Direction) === '1') {
$vro['pick_up'] .= $poi->POI_Hotel;
$vro['drop_off'] .= $poi->POI_FlightsNo . " " . $poi->POI_AirPort;
} else { // if ($poi->POI_FlightsNo != "")
$vro['pick_up'] .= $poi->POI_Hotel;
// $vro['drop_off'] .= $poi->POI_FlightsNo . " " . $poi->POI_AirPort; // 结束后送机
}
}
$ret['operation'][] = $vro;
}
}
$ret['operation'] = array_values($ret['operation']);
$ret_operation = array();
foreach ($ret['operation'] as $ko => $vo) {
if (strtotime($vo['start_date_raw']) >= strtotime($vo['cold_date'])
&& strtotime($vo['start_date_raw']) <= strtotime($vo['cold_enddate'])) {
unset($vo['cold_date']);
unset($vo['cold_enddate']);
$ret_operation[] = $vo;
continue;
}
}
$ret['operation'] = $ret_operation;
/** 外联信息 */
$raw_opi_id = 0;
if (intval($order_project[0]->COLI_OPI_ID) === 435) {
$real_code_info = analysis_groupCode($ret['group_number']);
$raw_opi_id = $this->Orders_model->get_gri_opi_id($real_code_info['cut']);
} else {
$raw_opi_id = $order_project[0]->COLI_OPI_ID;
}
$operator = $this->Orders_model->get_operator($raw_opi_id);
if ( ! empty($operator)) {
$ret['operator']['chinese_name'] = $operator->OPI_Name;
$ret['operator']['mobile'] = $operator->OPI_MoveTelephone;
$ret['operator']['email'] = $operator->OPI_Email;
$ret['operator']['english_name'] = $operator->OPI2_Name;
// 英文名没有
if ($operator->OPI_FirstName == null || $operator->OPI2_Name == null ) {
$ret['operator']['english_name'] = ucfirst(strstr($operator->OPI_Email, "@", true));
}
}
return $this->output->set_content_type('application/json')->set_output(json_encode($ret));
}
}
/* End of file api.php */
/* Location: ./third_party/trippestOrderSync/controllers/api.php */

@ -0,0 +1,91 @@
## 客人查询目的地订单信息API
#### POST / GET
> `http://www.mycht.cn/webht.php/apps/trippestOrderSync/Api/operation_detail`
参数| 类型 | 示例 | -
--- | --- | --- | ---
q | string | 180807025 | 渠道订单, 不返回外联信息
| | 180524043M | 单接送+Day Tour,共4天
#### RETURN JSON
```json
{
"status": 1, // 查询结果; 1-成功; 0-失败
"msg": "", // 失败信息: Not Found.
"group_number": "CHBJ180621-BHJ180619085M", // 团号
// 团计划安排详情, 按日期顺序的多个对象
"operation": [
{
// 日期 输出可读
"start_date": "2018-06-21",
"dateWeek_text": "Thu",
"dateDay_text": "21",
"dateMonth_text": "Jun",
"dateYear_text": "2018",
// 行程名字
"tour_name": "One-way Private Transfer Between Beijing Airport/Train Station and Your Hotel (Driver Service Only)", // 行程名字
"leader_name": "Sarah Carbis", // 领队
"personNum_text": "1 (1 Adult(s))", // 人数 输出可读
"adult_number": 10, // 成人数量
"kid_number": 0, // 小孩数量
// 酒店相关
"hotel_name": "Capital Hotel",
"hotel_address": "",
"hotel_tel": "",
// 航班
"flights_no": "LH720",
"flights_airport": "",
// 接送信息
"pick_up": "",
"drop_off": "",
// 车辆安排详情 安排不同车分别接客人的订单示例: 180606288
"cardriver": [
{
"car_type": "丰田大马", // 车辆类型
"car_company": "北京-王会生13051277931奔面系列", // 车队,公司
"car_license": "京B06528/white/12 seats van", // 车辆牌照,车辆信息
// 司机
"driver_name": "Mr.Li 李胜利",
"driver_tel": "13522003813",
"driver_pic": null,
"car_remark": "单租车酒店接客人送大董烤鸭金宝汇店10人北京首都大酒店 ",
"using_startdate": "2018-06-21",
"using_enddate": "2018-06-21"
},
{
"car_type": "5座轿车",
"car_company": "凯美瑞车队-宋师傅13811026411",
"car_license": "*",
"driver_name": "a-TBC",
"driver_tel": "*",
"driver_pic": null,
"car_remark": "单租车接机1人首都大酒店接LH720Arr0830@T3",
"using_startdate": "2018-06-21",
"using_enddate": "2018-06-21"
}
],
// 导游安排, 单接送的订单没有这个对象
"tourguide": [
{
"guide_name": "北京徐宝宝Tom", // 导游姓名
"guide_tel": "18511135908", // 导游联系电话
"guide_pic": "", // 导游头像
"guide_remark": "",
"using_startdate": "2018-07-09",
"using_enddate": "2018-07-10"
}
],
}
],
// 外联信息
// 如果是渠道订单则没有这个对象
"operator": {
"chinese_name": "黄俊峻",
"mobile": "18807734970",
"email": "niko@trippest.com",
"english_name": "Niko Huang"
}
}
```

@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

@ -0,0 +1,553 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Order_finance extends CI_Controller {
/*!
* 基本流程
* * 获取拼团类别: PVT?
* * 获取拼团总人数, 价格人等
* * 分别计算每次拼团成本
* * * 写入report_tour
* * 所有产品总成本
* * * 写入report_order
* END
*/
/*!
* GCI_groupType
* 1 - PVT
* 2 - combine
*/
public function __construct(){
parent::__construct();
$this->load->helper('array');
$this->load->model('OrderFinance_model');
mb_regex_encoding("UTF-8");
bcscale(4);
}
public function index()
{
}
// 重新生成账单
// HT批量按钮调用
// 仅读取成本信息计算
public function single_order_report($coli_sn=0, $debug=false)
{
$order_info = $this->OrderFinance_model->get_order_info($coli_sn);
if (empty($order_info)) {
return;
}
$report_order_exists = $this->OrderFinance_model->get_report_order($order_info->ordernumber);
if ( ! empty($report_order_exists) && $debug===false) {
return $this->output->set_content_type('application/json')->set_output(json_encode($report_order_exists));
}
return $this->generate_report($order_info, $debug);
}
// 重新生成账单
// HT单团财务表页面调用, 先刷新一次成本
public function single_order_report_refresh($coli_sn=0, $debug=false)
{
// 刷新成本
$controller_name = "TulanduoApi";
require_once($controller_name . '.php');
$vendor_class = new $controller_name();
$ret = $vendor_class->insert_HT_order_operation($coli_sn);
$this->single_order_report($coli_sn, $debug);
}
/*!
* 单团财务表计算
* @date 2018-07-18
* @param integer $coli_sn 订单主表key
* 基本流程:
* * 获取拼团类别: PVT, 拼团
* * 获取拼团总人数, 价格人等
* * 分别计算每次拼团成本
* * * 写入report_tour
* * * 其他产品项目, report_train, report_hotel等
* * 所有产品总成本
* * * [此处不做]写入核算管理CK_GroupInfo
* * * 写入单团财务表report_order
* END
*/
public function generate_report($order_info=array(), $debug=false)
{
$coli_sn = $order_info->COLI_SN;
/** 单团财务表 */
$report_order = array();
$report_order['OrderYJLR'] = 0; //预计利润
$report_order['money'] = 0; // 总收入, 实收金额
$report_order['profitmoney'] = 0; // 利润
$report_order['adultnumber'] = 0;
$report_order['childnumber'] = 0;
$report_order['babynumber'] = 0;
$report_order['qtCost'] = 0;
$report_order['qtMoney'] = 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;
$report_order['Agenter'] = mb_substr($order_info->Agenter,0,10);
$report_order['ChinaName'] = $order_info->ChinaName;
$report_order['country'] = $order_info->country;
$report_order['reservedate'] = $order_info->reservedate;
$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->otherCost; // 总成本=SUM(COLD_TotalCOst)+COLI_OtherCost
// $report_order['OrderPrice'] = $order_info->OrderPrice; // 总报价
/** 订单支付信息 */
$order_payment = $this->OrderFinance_model->get_order_payment($coli_sn);
$report_order['paymodenew'] = 0;
$report_order['money'] = $order_payment->SSmoney;
$report_order['RO_PayDescribe'] = $order_payment->payTypeDesc;
$report_order['paydate'] = $order_payment->patDate;
$report_order['OrderPrice'] = $report_order['money'];
if (strval($order_info->operater) === '435') {
$report_order['money'] = $order_info->OrderPrice;
}
/** 订单人数 */
$person_num = $this->OrderFinance_model->get_order_person_num($coli_sn);
$report_order['adultnumber'] = $person_num->adult_num;
$report_order['childnumber'] = $person_num->child_num;
$ret = new stdClass();
$ret->pvt = array();
/** 图兰朵产品: 取拼团实际成本 */
$ret->combine_cost = array();
$ret->report_tour = array();
$combineNo_arr = $this->OrderFinance_model->get_order_combineNo($coli_sn); // 拼团,PVT按顺序处理
$group_type_arr = array_unique(array_map(function($ele){return $ele->GCI_groupType;}, $combineNo_arr));
$processed_code = array(); // 已处理的产品编号
foreach ($combineNo_arr as $kc => $vc) {
if (empty($vc->GCI_combineNo)) {
continue;
}
if ($vc->GCI_groupType == 1) {
// 除去只能PVT的. 避免预定接送*1+tour*1, tour拼团只有一个订单, 被视为整团pvt,漏算接送成本
$processed_code = array_diff($processed_code, $this->forbidden_combine());
$pvt_cost = $this->pvt_basic($vc->GCI_combineNo, $coli_sn, $processed_code);
if ($pvt_cost !== null) {
$ret->pvt[] = $pvt_cost;
}
if (isset($pvt_cost->processed_code) && $order_info->pag_cnt > 1) { // 单个产品可能重复,既拼又PVT
$processed_code = array_merge($processed_code, $pvt_cost->processed_code); // 多地pvt时需要区分
}
} else if ($vc->GCI_groupType == 2) {
// 这里不排除产品编号是否已处理, 因为重复的情况比较多. 如T180917-BHJ180716001M
$tmp_cost = $this->combine_basic($vc->GCI_combineNo, $coli_sn);
if ($order_info->pag_cnt > 1) { // 单个产品可能重复,既拼又PVT
$processed_code = array_merge($processed_code, $tmp_cost->combine_pags);
}
$ret->combine_cost[] = $tmp_cost;
$tmp_cost = null;
}
}
/** 保存图兰朵包价线路产品的成本到report_tour */
$processed_cold_sn = array();
// pvt
$report_tour_pvt = array();
if ( ! empty($ret->pvt)) {
foreach ($ret->pvt as $kpvt => $cpvt) {
$processed_cold_sn = array_merge($processed_cold_sn,$cpvt->cold_sn);
$report_tour_pvt = array();
$report_tour_pvt['ordernumber'] = $cpvt->coli_id;
$report_tour_pvt['tourCode'] = mb_substr($cpvt->PAG_Code, 0, 50);
$report_tour_pvt['tourname'] = substr($cpvt->pag_name, 0, 200);
$report_tour_pvt['tourtime'] = $cpvt->startdate;
$report_tour_pvt['tourRSd'] = $cpvt->adult_num;
$report_tour_pvt['tourRSx'] = $cpvt->child_num;
$report_tour_pvt['tourCostRsd'] = $cpvt->person_cost;
$report_tour_pvt['tourCostRSx'] = $cpvt->person_cost;
$report_tour_pvt['tourcost'] = $cpvt->cost_sum;
$report_tour_pvt['tourPrice'] = $this->OrderFinance_model->convert_to_RMB($cpvt->totalPrice);
$report_tour_pvt['tourProfit'] = ($report_tour_pvt['tourPrice']>0) ? bcsub($report_tour_pvt['tourPrice'], $report_tour_pvt['tourcost']) : 0;
$report_tour_pvt['tourProvide'] = mb_substr($cpvt->vendor_name, 0, 50);
$report_tour_pvt['tourBZ'] = mb_substr($cpvt->comment, 0, 150);
$report_tour_pvt['orderstats'] = 0;
// 成本详情
$report_tour_pvt['RPT_Car'] = $cpvt->cost_category['touristCarOperations'];
$report_tour_pvt['RPT_Meal'] = $cpvt->cost_category['restraurantOperations'];
$report_tour_pvt['RPT_Ticket'] = $cpvt->cost_category['sceneryOperations'];
$report_tour_pvt['RPT_Service'] = $cpvt->cost_category['guiderOperations'];
$report_tour_pvt['RPT_MealGrants'] = $cpvt->cost_category['guide_meal'];
$report_tour_pvt['RPT_Water'] = $cpvt->cost_category['water'];
$report_tour_pvt['RPT_Other'] = $cpvt->cost_category['otherCosts'];
$report_tour_pvt['RPT_Total'] = $cpvt->cost_sum;
$report_tour_pvt['RPT_PersonGrade'] = $cpvt->person_grade;
$ret->report_tour[] = $report_tour_pvt;
// 计算订单总成本
$report_order['basemoney'] = bcadd($report_order['basemoney'], $report_tour_pvt['tourcost']);
}
}
// 拼团
if ( ! empty($ret->combine_cost)) {
foreach ($ret->combine_cost as $kcc => $cost) {
$cost_c = array();
$cost_c['ordernumber'] = $cost->coli_id;
$cost_c['tourCode'] = mb_substr(implode(',', array_unique(array_map(function($ele){ return $ele->real_code; }, $cost->order_cost))), 0, 50);
$cost_c['tourname'] = substr($cost->pag_name, 0, 200) ;
$cost_c['tourtime'] = $cost->startdate;
$cost_c['tourRSd'] = $cost->order_cost[0]->adult_num;
$cost_c['tourRSx'] = $cost->order_cost[0]->child_num;
$cost_c['tourCostRsd'] = $cost->person_cost;
$cost_c['tourCostRSx'] = $cost->person_cost;
$cost_c['tourcost'] = $cost->order_cost[0]->order_cost_sum;
$cost_c_price = 0;
foreach ($cost->order_cost as $koc => $coc) {
if ($coc->PAG_code === $coc->real_code) {
$cost_c_price = bcadd($cost_c_price, $coc->totalPrice);
}
$processed_cold_sn[] = $coc->COLD_SN;
}
$cost_c['tourPrice'] = $this->OrderFinance_model->convert_to_RMB($cost_c_price);
$cost_c['tourProfit'] = ($cost_c['tourPrice']>0) ? bcsub($cost_c['tourPrice'], $cost_c['tourcost']) : 0;
$cost_c['tourProvide'] = mb_substr($cost->vendor_name, 0, 50);
$cost_c['tourBZ'] = mb_substr($cost->comment, 0, 150);
$cost_c['orderstats'] = 0;
// 成本详情
$cost_c['RPT_Car'] = $cost->cost_category['touristCarOperations'];
$cost_c['RPT_Meal'] = $cost->cost_category['restraurantOperations'];
$cost_c['RPT_Ticket'] = $cost->cost_category['sceneryOperations'];
$cost_c['RPT_Service'] = $cost->cost_category['guiderOperations'];
$cost_c['RPT_MealGrants'] = $cost->cost_category['guide_meal'];
$cost_c['RPT_Water'] = $cost->cost_category['water'];
$cost_c['RPT_Other'] = $cost->cost_category['otherCosts'];
$cost_c['RPT_Total'] = $cost->cost_sum;
$cost_c['RPT_PersonGrade'] = $cost->person_num;
$ret->report_tour[] = $cost_c;
// 计算订单总成本
$report_order['basemoney'] = bcadd($report_order['basemoney'], $cost_c['tourcost']);
}
}
$ret->processed_cold_sn = array_unique($processed_cold_sn);
if ($debug !== false) {
return $this->output->set_content_type('application/json')->set_output(json_encode($ret));
}
/** 开始写入数据库 */
/** 图兰朵供应商 */
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) || empty($ret->processed_cold_sn)) {
$ret->others = $this->OrderFinance_model->insert_report_tour_others($coli_sn);
foreach ($ret->others as $kro => $vro) {
$report_order['basemoney'] = bcadd($report_order['basemoney'], $vro->tourcost);
}
}
/** 火车票预定 */
$train_detail = $this->OrderFinance_model->get_order_detail($coli_sn, '2');
if( ! empty($train_detail)) {
$ret->train = $this->OrderFinance_model->insert_report_train($coli_sn);
foreach ($ret->train as $krt => $vrt) {
$report_order['basemoney'] = bcadd($report_order['basemoney'], $vrt->TotalCost);
}
}
/** 酒店预订 */
$hotel_detail = $this->OrderFinance_model->get_order_detail($coli_sn, 'A');
if ( ! empty($hotel_detail)) {
$ret->hotel = $this->OrderFinance_model->insert_report_hotel($coli_sn);
foreach ($ret->hotel as $krh => $vrh) {
$report_order['basemoney'] = bcadd($report_order['basemoney'], $vrh->roomcost);
}
}
// 订单利润
$report_order['profitmoney'] = $report_order['OrderYJLR'] = bcsub($report_order['money'], $report_order['basemoney']);
$report_order['builddate'] = date('Y-m-d H:i:s');
$report_order['xh'] = $this->OrderFinance_model->get_report_order_xh(); //序号
$ret->report_order = $this->OrderFinance_model->insert_report_order($report_order, $coli_sn, $report_order['RO_GRI_SN']);
$this->output->set_content_type('application/json')->set_output(json_encode($ret));
return;
}
/*!
* 拼团计算
* @example 180426360,180516007U
* @date 2018-07-18
* @param string $combineNo
*/
public function combine_basic($combineNo="", $coli_sn=0, $debug=false)
{
$ret = new stdClass();
$all_orders = $this->OrderFinance_model->get_all_combine_order($combineNo);
if (empty($all_orders)) {
return null;
}
if ($coli_sn !== 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();
$pvt_code = $this->forbidden_combine();
if (count($all_pag) > 1) {
// 多个产品, 找出拼团产品号
// 先处理拆分拼团的产品, 补全产品号
$allowed_spread = $this->spread_code();
$extra_code_cold = array();
$all_orders_arr = json_decode(json_encode($all_orders), true); // 避免foreach object 改变自身
foreach ($all_orders_arr as $ka => $va) {
$extra_arr = array();
if (isset($allowed_spread[$va['PAG_Code']])) {
foreach ($allowed_spread[$va['PAG_Code']] as $ks => $vs) {
$tmp_extra = new stdClass();
$tmp_extra = (object) $va;
$tmp_extra->real_code = $tmp_extra->PAG_Code;
$tmp_extra->real_pag_sn = $tmp_extra->COLD_ServiceSN;
$tmp_extra->PAG_Code = $vs;
$tmp_extra->COLD_ServiceSN = null;
$extra_arr[] = $tmp_extra;
}
}
$extra_code_cold = array_merge($extra_code_cold, $extra_arr);
}
// 不直接merge,避免覆盖key
foreach ($extra_code_cold as $ke => $ve) {
$all_orders[] = $ve;
}
// 重新计算重复次数
$all_pags = array_filter(array_map(function($ele){ return mb_strtoupper($ele->PAG_Code);}, $all_orders));
// 重复的产品号; 可混拼的产品
$repeat_code = array();
$code_count = array_count_values($all_pags);
foreach ($all_pag as $kp => $vp) {
if (in_array($vp, $pvt_code)) {
continue;
}
$tmp = null;
$tmp = $this->get_allowed_combine(mb_strtoupper($vp));
$this_allowed = ($tmp === null) ? null : array_diff($tmp, $all_pag); // diff((31,41), (31,41,47)) ==> ()
// $this_allowed = ($tmp === null) ? null : array_diff($all_pag, $tmp); // diff((31,41), (31,41,47)) ==> ()
if (empty($this_allowed) && $tmp !== null) {
$combine_pag_arr[] = $tmp; // push (31,41)
}
// 重复的产品即为拼团
if($code_count[$vp] > 1) {
$repeat_code[] = $vp;
}
}
if ( ! empty($repeat_code)) {
$combine_pag_arr[] = $repeat_code;
}
} else {
// 单个产品
$combine_pag_arr[] = ($all_pag);
}
// 预定多产品, 但是只有部分发了计划
// 预定多产品, 拼团只有一个订单, 相当于整团PVT
if (empty($combine_pag_arr)) {
// $combine_pag_arr[] = array_diff($all_pag, $pvt_code); // 此处排除PVT租车产品
$combine_pag_arr[] = $all_pag;
}
$ret->combine_pags = my_array_unique($combine_pag_arr);
$ret->combine_pags = $ret->combine_pags[0]; // 这里用0是因为一个拼团应该只有一组或一个产品
// 一些不在常规混拼的团, 仅有一个拼团号的订单则加上该团
foreach ($all_orders as $key => $value) {
if ($value->combine_cnt === 1) {
$ret->combine_pags[] = mb_strtoupper($value->PAG_Code);
}
}
$ret->combine_pags = array_values(array_unique($ret->combine_pags));
$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) {
if (in_array(mb_strtoupper($vo->PAG_Code), $ret->combine_pags)) {
$pag_sns[] = $vo->COLD_ServiceSN;
// 整团单拼时, 避免重复计算人数
// 订单人数不重复计
// 总人等
if ( ! in_array(mb_strtoupper($vo->PAG_Code), $pvt_code) && ! in_array($vo->COLI_SN, $unique_coli)) {
$unique_coli[] = $vo->COLI_SN;
$ret->person_num += $vo->COLD_PersonNum + $vo->COLD_ChildNum;
}
$ret->startdate = $vo->COLD_StartDate;
if ($coli_sn !== NULL) {
$tour_s = new stdClass();
if ($vo->COLI_SN == $coli_sn) {
$tour_s->COLD_SN = $vo->COLD_SN;
$tour_s->person_num = $vo->COLD_PersonNum + $vo->COLD_ChildNum;
$tour_s->adult_num = $vo->COLD_PersonNum;
$tour_s->child_num = $vo->COLD_ChildNum;
$tour_s->PAG_code = mb_strtoupper($vo->PAG_Code);
// $tour_s->real_code = isset($vo->real_code) ? $vo->real_code : $vo->PAG_Code;
$tour_s->real_code = isset($vo->real_code)&&in_array($vo->real_code, $ret->combine_pags) ? $vo->real_code : mb_strtoupper($vo->PAG_Code);
$tour_s->real_pag_sn = isset($vo->real_pag_sn) ? $vo->real_pag_sn : $vo->COLD_ServiceSN;
$tour_s->totalPrice = $vo->COLD_TotalPrice;
$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);
$pags_info = $this->OrderFinance_model->get_pag_info(implode(',', array_unique(array_filter($this_order_real_pag_sns)))); // $pag_sns
$ret->vendor_name = implode(",", array_values(array_unique(array_map(function($ele) {return $ele->VEI2_CompanyBN;}, $pags_info)))) ;
$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;
$ret->person_cost = bcdiv($ret->cost_sum, $ret->person_num);
foreach ($ret->order_cost as $kc => $voc) {
$ret->order_cost[$kc]->order_cost_sum = bcmul($voc->person_num, $ret->person_cost);
}
if ($debug!=false) {
return $this->output->set_content_type('application/json')->set_output(json_encode($ret));
}
return $ret;
}
/*!
* pvt计算
* @example 180515061M
* @date 2018-07-18
*/
public function pvt_basic($combineNo="", $coli_sn=0, $processed_code=array(), $debug=false)
{
$ret = new stdClass();
$ret->processed_code = array();
$all_orders_raw = $this->OrderFinance_model->get_all_combine_order($combineNo, $processed_code);
if (empty($all_orders_raw)) {
return null;
}
$all_orders = $all_orders_raw;
// 取出供应商id, 有多个供应商时, 说明拆分为多个pvt
// 多地PVT
$all_vei_cnt = count(array_unique(array_map(function($ele) {return mb_strtoupper($ele->COLD_PlanVEI_SN);}, $all_orders_raw)));
if ($all_vei_cnt > 1) {
$all_vei = array_unique(array_map(function($ele) {return mb_strtoupper($ele->COLD_PlanVEI_SN);}, $all_orders_raw));
$all_orders = array();
foreach ($all_orders_raw as $kor => $vor) {
if ($vor->COLD_PlanVEI_SN === $all_orders_raw[0]->COLD_PlanVEI_SN) {
$all_orders[] = $vor;
$ret->processed_code[] = $vor->PAG_Code;
}
}
}
$ret->coli_sn = $coli_sn;
$ret->coli_id = $all_orders[0]->coli_ID;
$ret->cold_sn = array_unique(array_map(function($ele) {return $ele->COLD_SN;}, $all_orders));
// 总报价
$ret->totalPrice = 0;
foreach ($all_orders as $kal => $val) {
$ret->totalPrice = bcadd($ret->totalPrice, $val->COLD_TotalPrice);
}
// 预定的产品数
$ret->tour_count = count(array_unique(array_map(function($ele) {return mb_strtoupper($ele->PAG_Code);}, $all_orders)));
$person_num = $this->OrderFinance_model->get_order_person_num($coli_sn);
$ret->person_num = $person_num->person_num;
$ret->adult_num = $person_num->adult_num;
$ret->child_num = $person_num->child_num;
$combine_cost = $this->OrderFinance_model->get_combine_sumMoney($combineNo);
$ret->startdate = $all_orders[0]->COLD_StartDate;
$ret->person_grade = ($all_orders[0]->COLD_PersonNum + $all_orders[0]->COLD_ChildNum );
$ret->cost_category = $combine_cost->cost_category;
$ret->cost_sum = $combine_cost->cost_sum;
$ret->person_cost = bcdiv($ret->cost_sum, $ret->person_num);
$ret->comment = "PVT[" . $combineNo . "],共" . $ret->person_num . "人";
$pag_sns = array_values(array_unique(array_map(function($ele) {return $ele->COLD_ServiceSN;}, $all_orders)));
$pags_info = $this->OrderFinance_model->get_pag_info(implode(',', $pag_sns));
$ret->PAG_Code = implode(",", array_values(array_unique(array_map(function($ele) {return mb_strtoupper($ele->PAG_Code);}, $pags_info))));
$ret->vendor_name = implode(",", array_values(array_unique(array_map(function($ele) {return $ele->VEI2_CompanyBN;}, $pags_info)))) ;
$ret->pag_name = implode(";\r\n", array_map(function($ele) {return $ele->PAG_Title;}, $pags_info)) ;
if ($debug!=false) {
return $this->output->set_content_type('application/json')->set_output(json_encode($ret));
}
return $ret;
}
/*!
* 获取允许拼团的数组
* @date 2018-07-18
* @param string $tour_code 产品编号
* @return array 含允许拼团产品编号的数组
*/
public function get_allowed_combine($tour_code="")
{
$allowed = null;
$all_allowed = $this->allowed_combine();
foreach ($all_allowed as $key => $va) {
if (in_array($tour_code, $va)) {
$allowed = $va;
break;
}
}
return $allowed;
}
/** 允许混合拼团的不同编号产品 */
public function allowed_combine()
{
return array(
// * 不同产品但部分行程相同所以允许拼团 *
array("XASIC-15", "XASIC-41"),
array("BJSIC-47", "BJSIC-41"),
// * 产品编号不同实际是同一产品 *
array("SHSIC-31", "SHSIC-41"),
array("SHSIC-32", "SHSIC-42"),
array("SHSIC-33", "SHSIC-43"),
array("SHSIC-34", "SHSIC-44")
);
}
/** 允许拆分再拼团的产品编号 */
public function spread_code()
{
return array(
"XASIC-42" => array("XASIC-41"),
"BJSIC-42" => array("BJSIC-41"),
"BJSIC-43" => array("BJSIC-41","BJSIC-42"),
"SHSIC-42" => array("SHSIC-41"),
"SHSIC-43" => array("SHSIC-41","SHSIC-42")
);
}
/** 肯定是PVT */
public function forbidden_combine()
{
return array(
"BJALC-209",
// "BJSIC-16",
"SHSIC-45",
"XASIC-16"
);
}
}
/* End of file order_finance.php */
/* Location: ./webht/third_party/trippestOrderSync/controllers/order_finance.php */

@ -0,0 +1,212 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Send_operation extends CI_Controller {
public function __construct(){
parent::__construct();
mb_regex_encoding("UTF-8");
bcscale(4);
$this->load->helper('array');
$this->load->model('Send_operation_model', 'send_model');
$this->send_url = 'https://www.mycht.cn/webht.php/apps/messagecenter/index/send_message/';
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:POST, GET');
header('Access-Control-Max-Age:0');
header('Access-Control-Allow-Headers:x-requested-with, Content-Type');
header('Access-Control-Allow-Credentials:true');
}
public function index()
{
$this->sms_log();
return;
}
public function sms_log()
{
$this->permission->is_admin(true);
$date = $this->input->get_post("date");
$date = $date ? $date : date('Y-m-d', strtotime("+1 day"));
$ready_order["date"] = $date;
$COLI_ID = $this->input->get_post("order_id");
$ready_order["order_id"] = $COLI_ID;
$ready_order["list"] = $this->send_model->daytour_order_ready_for_send(trim($COLI_ID), $date, "no_send_state");
$this->load->view('sms_log', $ready_order);
return;
}
public function order_sms_list($COLI_SN)
{
$data['list'] = $this->send_model->order_sms_list($COLI_SN);
$list_table = $this->load->view('order_sms_list', $data, true);
$this->output->set_content_type('application/json')->set_output(json_encode($list_table));
return;
}
/*!
* 通过短信发送导游信息给预定了Day Tour的客人
* * 每天9:00, 16:00 尝试发送
* * 第二次发送之后仍然发送失败或没有调度信息, 反馈到Alex邮箱
* * 这里只是Day Tour 订单, 不含单接送, 因此每个订单仅发送一次
* @date 2018-09-25
*/
/*!
* 模板内容
* 2018-10-22
* 【桂林海纳国旅】Hi {1}, your guide on {2} is {3}, localmobile is {4}. He/she'll call you at the hotel, or leave a message tonight. You can find more info by inputting booking No. {5} at https://www.trippest.com/track-your-trip. Wish you a wonderful day with Trippest!
*/
public function daytour($COLI_ID="")
{
$now_h = date("H");
$time_flag = "";
if ($now_h < 9 || $now_h > 19) {
echo "Break time.";
return false;
} else if ($now_h >= 9 && $now_h < 16) {
$time_flag = "try1";
} else {
$time_flag = "try2";
}
$date = date('Y-m-d', strtotime("+1 day"));
if (trim($COLI_ID) !== "") {
$date = null;
$time_flag = "handle";
}
$ready_order = $this->send_model->daytour_order_ready_for_send(trim($COLI_ID), $date, $time_flag);
if (empty($ready_order)) {
echo "Empty. ";
return false;
}
$order = $ready_order[0];
if (strtotime($order->COLD_StartDate) < strtotime(date('Y-m-d')) ) {
echo "已过期";
return;
}
$has_send = false;
$send_history = $this->send_model->order_sms_list($order->COLI_SN);
if ( ! empty($send_history)) {
$has_send = true;
$new_number = mb_ereg_replace('[\D]', '', $order->GUT_POST) . real_phone_number($order->GUT_TEL, mb_ereg_replace('[\D]', '', $order->GUT_POST));
$last_send = end($send_history);
$last_send_number = $last_send->TPSL_nationCode . $last_send->TPSL_mobile;
$last_send_cb = json_decode($last_send->TPSL_callbackJson);
if ($last_send_cb->result == 1016 && $new_number == $last_send_number) {
// 更新时间, 以免一直重复在这个订单
$update_cb_db['TPSL_logTime'] = date("Y-m-d H:i:s");
$update_where = " TPSL_SN=" . $last_send->TPSL_SN;
$ht_id = $this->send_model->update_trippest_sms_log($update_where, $update_cb_db);
echo "手机号错误且未变更";
return;
}
}
$last_update = "";
$guide_name = "";
if ($order->gcod != null) {
$split_gcod = explode("@", $order->gcod);
$guide_name = $split_gcod[0];
$guide_tel = $split_gcod[1];
$last_update = $split_gcod[2] . " " . $split_gcod[3];
} else {
$guide_name = strstr($order->eva, "@", true);
$guide_tel = substr(strstr($order->eva, "@"), 1);
}
$guide_name = mb_ereg_replace('[^a-zA-Z]', '', $guide_name);
$send_body = array(
"one" => trim($order->guest_name)
,"two" => substr($order->COLD_StartDate, 0, 10)
,"three" => $guide_name
,"four" => "+86 " . $guide_tel
,"five" => $order->COLI_ID
,"phone" => real_phone_number($order->GUT_TEL, mb_ereg_replace('[\D]', '', $order->GUT_POST))
,"nation_code" => mb_ereg_replace('[\D]', '', $order->GUT_POST)
);
$cb_db = array(
"TPSL_COLI_SN" => $order->COLI_SN
,"TPSL_nationCode" => $send_body['nation_code']
,"TPSL_mobile" => $send_body['phone']
,"TPSL_msgType" => 'guide'
,"TPSL_sendState" => 0
);
$ht_id = $this->send_model->insert_trippest_sms_log($cb_db);
$error_msg = "";
$send_time = date("Y-m-d H:i:s");
if ($guide_name != null) {
$send_cb = $this->excute_curl($this->send_url, $send_body);
$send_cb_obj = json_decode($send_cb);
$update_cb_db["TPSL_sendTime"] = $send_time;
$update_cb_db["TPSL_sendContent"] = json_encode($send_body);
$update_cb_db['TPSL_sendState'] = $send_cb_obj->result===0 ? 1 : 0;
$update_cb_db['TPSL_callbackJson'] = $send_cb;
$update_cb_db['TPSL_callbackTime'] = date("Y-m-d H:i:s");
$update_where = " TPSL_SN=" . $ht_id;
$ht_id = $this->send_model->update_trippest_sms_log($update_where, $update_cb_db);
$send_cb_obj->errmsg!=="OK" ? $error_msg=$send_cb_obj->errmsg : null;
}
// if ($time_flag === "try1") {
// return;
// }
if ($has_send == false) {
if ($guide_name == null || $error_msg !== "") {
// 没有调度或发送失败
// to Alex
$operator_mailbody = "<p> Dear Alex: </p>" .
"<p>导游信息发送客人失败:<br /></p>" .
"<p>订单号:" . $order->COLI_ID ."</p>" .
"<p>发团时间:" . substr($order->COLD_StartDate, 0, 10) ."</p>" .
"<p>导游信息:" . $guide_name . "(" . $guide_tel . ")" ."</p>" .
"<p>导游更新时间:" . $last_update ."</p>" .
"<p>发送时间:" . $send_time ."</p>";
if ($error_msg !== "") {
$operator_mailbody .= "<p>发送失败信息:" . $error_msg . "</p>";
}
$operator_mailbody .= "<p><a href='https://www.trippest.com/track-your-trip/'>Tracking Link</a>.</p>";
$operator_mailbody .= "<p> 此邮件由系统自动发送, 请勿回复.</p>";
$this->send_model->SendMail(
"chinahighlights",
"webform@chinahighlights.net",
"YSL",
"alex@chinahighlights.net", // ysl email alex@chinahighlights.net
'#SMS send fail# ' . $order->COLI_ID,
$operator_mailbody);
}
}
echo "已发送";
return;
}
protected function excute_curl($url, $postBody) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Accept: application/json"
));
if (empty($postBody)) {
return false;
}
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postBody);
$reponse = curl_exec($ch);
// $eval_resp = json_decode($reponse);
if (curl_errno($ch)) {
log_message('error', "curl error : ".curl_error($ch) . "; curl postBodyString: ".json_encode($postBody));
} else {
$httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (200 !== $httpStatusCode) {
log_message('error', "curl response Status Code: ".$httpStatusCode."; curl postBodyString: ".json_encode($postBody));
}
}
curl_close($ch);
return $reponse;
}
}
/* End of file send_operation.php */
/* Location: ./webht/third_party/trippestOrderSync/controllers/send_operation.php */

@ -0,0 +1,190 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Vendor_money extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->library('trippest');
$this->load->helper('array');
$this->load->model('Vendor_money_model', 'money_model');
mb_regex_encoding("UTF-8");
bcscale(2);
}
public function settlement()
{
$data['default_date1'] = date('Y-m-01', strtotime("last month"));
$data['default_date2'] = date('Y-m-d H:i:s', mktime(0,0,0,date('m'),1,date('Y'))-1);
$vendor_sourcetype = $this->trippest->vendor_sourcetype();
$data['default_vendor'] = array_keys($vendor_sourcetype);
$this->load->view('vendor_money_sum', $data);
}
public function index()
{
$this->permission->is_admin(true);
$date_range = $this->input->post("date_range");
preg_match_all('/\d{4}\-\d{2}\-\d{2}/', $date_range, $date_range_arr);
if (empty($date_range_arr[0])) {
return $this->settlement();
}
$start_date = $date_range_arr[0][0];
$end_date =$date_range_arr[0][1] . " 23:59:59";
if ($end_date == null) {
$end_date = date("Y-m-d H:i:s", strtotime("+1 month", strtotime($start_date))-1);
}
$vendors = $this->input->post("vendors");
$vendor_sourcetype = $this->trippest->vendor_sourcetype();
$result = array(
"default_date1" => $start_date
,"default_date2" => $end_date
,"default_vendor" => $vendors
,"trippest_order_vendor_money" => array()
,"transfer_sum" => 0
/** 列总计 */
,"col_sum" => array(
"trippest" => array(
"sum_trippest_cost" => 0
,"sum_vendor_cost" => 0
,"sum_trippest_sum" => 0
,"sum_vendor_sum" => 0
,"sum_profit" => 0
,"sum_trippest_profit" => 0
,"sum_vendor_profit" => 0
,"sum_payout" => 0
,"sum_other" => 0
),
"vendor" => array(
"sum_trippest_cost" => 0
,"sum_vendor_cost" => 0
,"sum_trippest_sum" => 0
,"sum_vendor_sum" => 0
,"sum_profit" => 0
,"sum_trippest_profit" => 0
,"sum_vendor_profit" => 0
,"sum_payout" => 0
,"sum_other" => 0
)
)
);
/** 团款 */
foreach ($vendors as $key => $vendor) {
$sourcetype = $vendor_sourcetype[strval($vendor)]["sourcetype"];
$opi_summoney = $this->money_model->checked_group_list($vendor, $sourcetype, $start_date, $end_date, implode(',', $vendors));
$ret = array(
"trippest" =>
array(
"trippest_sum" => 0,
"vendor_sum" => 0,
"other_sum_cost" => 0,
"other_sum" => 0
),
"vendor" =>
array(
"trippest_sum" => 0,
"vendor_sum" => 0,
"transfer_sum" => 0,
"other_sum_cost" => 0,
"other_sum" => 0
)
);
// 按照海纳的算法
foreach ($opi_summoney as $key => $opi_money) {
if (floatval($opi_money['vendor_sum']) > 0) {
$ret["trippest"]['vendor_sum'] = bcadd(floatval($ret["trippest"]['vendor_sum']), floatval($opi_money['vendor_sum'])) ;
}
if (floatval($opi_money['trippest_sum']) > 0) {
$ret["trippest"]['trippest_sum'] = bcadd(floatval($ret["trippest"]['trippest_sum']), floatval($opi_money['trippest_sum'])) ;
}
$ret['trippest']['other_sum'] = bcadd($ret['trippest']['other_sum'], $opi_money['other_price_sum']);
$ret['trippest']['other_sum_cost'] = bcadd($ret['trippest']['other_sum_cost'], $opi_money['other_cost_sum']);
$ret["trippest"]['trippest_sum'] = bcsub($ret["trippest"]['trippest_sum'], $opi_money['other_price_sum']);
}
// 按照图兰朵算法: Trippest自营订单的代收算在海纳收款
foreach ($opi_summoney as $kv => $opi_money_v) {
if (strval($opi_money_v['COLI_OPI_ID']) === '435') {
$ret["vendor"]['vendor_sum'] = bcadd(floatval($ret["vendor"]['vendor_sum']), floatval($opi_money_v['vendor_sum'])) ;
} else {
$ret["vendor"]['trippest_sum'] = bcadd(floatval($ret["vendor"]['trippest_sum']), floatval($opi_money_v['trippest_sum'])) ;
$ret["vendor"]['trippest_sum'] = bcadd(floatval($ret["vendor"]['trippest_sum']), floatval($opi_money_v['vendor_sum'])) ;
}
$ret['vendor']['other_sum'] = bcadd($ret['vendor']['other_sum'], $opi_money_v['other_price_sum']);
$ret['vendor']['other_sum_cost'] = bcadd($ret['vendor']['other_sum_cost'], $opi_money_v['other_cost_sum']);
$ret["vendor"]['trippest_sum'] = bcsub($ret["vendor"]['trippest_sum'], $opi_money_v['other_price_sum']);
}
$ret["vendor"]["transfer_sum"] = bcsub($ret["vendor"]['vendor_sum'], $ret["trippest"]['vendor_sum']);
if ($ret["vendor"]["transfer_sum"] != 0) {
$result['transfer_sum'] = bcadd($result['transfer_sum'], $ret["vendor"]["transfer_sum"]);
$result['trippest_order_vendor_money'] = array_merge($result['trippest_order_vendor_money'], $this->money_model->trippest_order_with_vendormoney($vendor, $sourcetype, $start_date, $end_date));
}
$result["money"][strval($vendor)] = $ret;
$result["money"][strval($vendor)]["vendor_code"] = $vendor;
$result["money"][strval($vendor)]["vendor_name"] = $vendor_sourcetype[strval($vendor)]["vendor_name"];
/** 团款合计 */
$result['col_sum']['trippest']['sum_trippest_sum'] = bcadd(
bcadd($result['col_sum']['trippest']['sum_trippest_sum'], $ret["trippest"]['trippest_sum'])
,$ret['trippest']['other_sum']);
$result['col_sum']['trippest']['sum_vendor_sum'] = bcadd($result['col_sum']['trippest']['sum_vendor_sum'], $ret["trippest"]['vendor_sum']);
$result['col_sum']['trippest']['sum_other'] = bcadd($result['col_sum']['trippest']['sum_other'], $ret['trippest']['other_sum']);
$result['col_sum']['vendor']['sum_trippest_sum'] = bcadd(
bcadd($result['col_sum']['vendor']['sum_trippest_sum'], $ret["vendor"]['trippest_sum'])
,$ret['vendor']['other_sum']);
$result['col_sum']['vendor']['sum_vendor_sum'] = bcadd($result['col_sum']['vendor']['sum_vendor_sum'], $ret["vendor"]['vendor_sum']);
$result['col_sum']['vendor']['sum_other'] = bcadd($result['col_sum']['vendor']['sum_other'], $ret['vendor']['other_sum']);
}
/** 成本 */
$vendors_cost = $this->money_model->vendor_cost(implode(',', $vendors), $start_date, $end_date);
foreach ($result['money'] as $km => &$vm) {
$vm['vendor_cost'] = $vm['trippest_cost'] = 0;
foreach ($vendors_cost as $kvc => $vvc) {
if (strval($vm['vendor_code']) === strval($vvc['vendor_code'])) {
$vm['vendor_cost'] = $vvc['vendor_cost'];
}
}
// 成本总计
$result['col_sum']['trippest']['sum_trippest_cost'] = $result['col_sum']['vendor']['sum_trippest_cost'] = bcadd($result['col_sum']['trippest']['sum_trippest_cost'], $vm['trippest_cost']);
$result['col_sum']['trippest']['sum_vendor_cost'] = $result['col_sum']['vendor']['sum_vendor_cost'] = bcadd(
bcadd($result['col_sum']['trippest']['sum_vendor_cost'], $vm['vendor_cost'])
,$vm['trippest']['other_sum_cost']);
}
foreach ($result['money'] as $kmi => &$vmi) {
/** 利润 */
$vmi['trippest']['total_profit'] = bcsub(
bcadd(bcadd($vmi['trippest']['trippest_sum'], $vmi['trippest']['vendor_sum']),$vmi['trippest']['other_sum']),
bcadd(bcadd($vmi['trippest_cost'], $vmi['vendor_cost']),$vmi['trippest']['other_sum_cost']));
$vmi['vendor']['total_profit'] = bcsub(
bcadd(bcadd($vmi['vendor']['trippest_sum'], $vmi['vendor']['vendor_sum']),$vmi['vendor']['other_sum']),
bcadd(bcadd($vmi['trippest_cost'], $vmi['vendor_cost']),$vmi['vendor']['other_sum_cost']));
/** 利润分成 */
$vmi['trippest']['vendor_profit'] = bcmul($vmi['trippest']['total_profit'], $vendor_sourcetype[strval($vmi['vendor_code'])]["profit_rate"]);
$vmi['trippest']['trippest_profit'] = bcmul($vmi['trippest']['total_profit'], bcsub(1, $vendor_sourcetype[strval($vmi['vendor_code'])]["profit_rate"]) );
$vmi['vendor']['vendor_profit'] = bcmul($vmi['vendor']['total_profit'], $vendor_sourcetype[strval($vmi['vendor_code'])]["profit_rate"]);
$vmi['vendor']['trippest_profit'] = bcmul($vmi['vendor']['total_profit'], bcsub(1, $vendor_sourcetype[strval($vmi['vendor_code'])]["profit_rate"]) );
/** Trippest应付地接 */
$vmi['trippest']['payout'] = bcsub(bcadd($vmi['vendor_cost'], $vmi['trippest']['vendor_profit'] ), $vmi['trippest']['vendor_sum']);
$vmi['vendor']['payout'] = bcsub(bcadd($vmi['vendor_cost'], $vmi['vendor']['vendor_profit'] ), $vmi['vendor']['vendor_sum']);
/** 利润总计 */
$result['col_sum']['trippest']['sum_profit'] = bcadd($result['col_sum']['trippest']['sum_profit'], $vmi['trippest']['total_profit']);
$result['col_sum']['trippest']['sum_trippest_profit'] = bcadd($result['col_sum']['trippest']['sum_trippest_profit'], $vmi['trippest']['trippest_profit']);
$result['col_sum']['trippest']['sum_vendor_profit'] = bcadd($result['col_sum']['trippest']['sum_vendor_profit'], $vmi['trippest']['vendor_profit']);
$result['col_sum']['vendor']['sum_profit'] = bcadd($result['col_sum']['vendor']['sum_profit'], $vmi['vendor']['total_profit']);
$result['col_sum']['vendor']['sum_trippest_profit'] = bcadd($result['col_sum']['vendor']['sum_trippest_profit'], $vmi['vendor']['trippest_profit']);
$result['col_sum']['vendor']['sum_vendor_profit'] = bcadd($result['col_sum']['vendor']['sum_vendor_profit'], $vmi['vendor']['vendor_profit']);
/** 应付总计 */
$result['col_sum']['trippest']['sum_payout'] = bcadd($result['col_sum']['trippest']['sum_payout'], $vmi['trippest']['payout']);
$result['col_sum']['vendor']['sum_payout'] = bcadd($result['col_sum']['vendor']['sum_payout'], $vmi['vendor']['payout']);
}
// return $this->output->set_content_type('application/json')->set_output(json_encode($result));
$this->load->view('vendor_money_sum', $result);
return ;
}
}
/* End of file vendor_money.php */
/* Location: ./third_party/trippestOrderSync/controllers/vendor_money.php */

@ -0,0 +1,27 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see http://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
$this->load->view('welcome_message');
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */

@ -0,0 +1,175 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
function array_unique_fb($array2D)
{
foreach ($array2D as $v)
{
$v = join(",",$v); //降维,也可以用implode,将一维数组转换为用逗号连接的字符串
$temp[] = $v;
}
$temp = array_unique($temp); //去掉重复的字符串,也就是重复的一维数组
foreach ($temp as $k => $v)
{
$temp[$k] = explode(",",$v); //再将拆开的数组重新组装
}
return $temp;
}
function my_array_unique($array, $keep_key_assoc = false)
{
$duplicate_keys = array();
$tmp = array();
foreach ($array as $key=>$val)
{
// convert objects to arrays, in_array() does not support objects
if (is_object($val))
$val = (array)$val;
if (!in_array($val, $tmp))
$tmp[] = $val;
else
$duplicate_keys[] = $key;
}
foreach ($duplicate_keys as $key)
unset($array[$key]);
return $keep_key_assoc ? $array : array_values($array);
}
//根据URL获取月份
function getaqiMonth($url){
$monArr = array('January','February','March','April','May','June','July','August','September','October','November','December');
$monObj = array(
'January' => '01',
'February' => '02',
'March' => '03',
'April' => '04',
'May' => '05' ,
'June' => '06',
'July' => '07',
'August' => '08',
'September' => '09',
'October' => '10',
'November' => '11',
'December' => '12');
$urlarr = explode("/",$url);
$tmp = $urlarr[(count($urlarr)-1)];
$tmp = ucfirst(str_ireplace('.htm','',$tmp));
//$d=strtotime("00:01am ".$tmp." 15 2015");
if(in_array($tmp,$monArr)){
return $monObj[$tmp];
}else{
return false;
}
}
/*
* 把数组元素组合为字符串
* $container:用来包含元素的符号
* $se:分隔符
* $arr需要重新组合的数组
* 例如:$arr=['aaaa','bbbb'];
* my_implode("'",",",$arr);得到
* 'aaaa','bbbb'
*/
function my_implode($container,$se,$arr)
{
$str = "";
if ($arr != '') {
$str = "";
$tcount = count($arr);
$tcountInt = 0;
foreach ($arr as $i) {
$tcountInt++;
if ($tcount == $tcountInt) {
$str .= $container . $i . $container;
} else {
$str .= $container . $i . $container . $se;
}
}
}
return $str;
}
/*!
* json_encode($a, JSON_UNESCAPED_UNICODE )
* for PHP Version < 5.4
*/
function raw_json_encode($input, $flags = 0) {
$fails = implode('|', array_filter(array(
'\\\\',
$flags & JSON_HEX_TAG ? 'u003[CE]' : '',
$flags & JSON_HEX_AMP ? 'u0026' : '',
$flags & JSON_HEX_APOS ? 'u0027' : '',
$flags & JSON_HEX_QUOT ? 'u0022' : '',
)));
$pattern = "/\\\\(?:(?:$fails)(*SKIP)(*FAIL)|u([0-9a-fA-F]{4}))/";
$callback = function ($m) {
return html_entity_decode("&#x$m[1];", ENT_QUOTES, 'UTF-8');
};
return preg_replace_callback($pattern, $callback, json_encode($input, $flags));
}
/*!
* 目的地项目组的订单计划的团号分析
* 去除添加的后缀, 只保留前两部分: XXXXXX-YYYYYYYYYYYY
* @date 2018-05-02
* @param [type] $groupCode 从地接系统获取到的团号
*/
function analysis_groupCode($groupCode)
{
mb_regex_encoding("UTF-8");
$groupCode = trim_str(trim($groupCode));
preg_match('/[\w\s\-]+/', characet($groupCode, "UTF-8"), $temp_array);
// $temp_array[0] = strrchr($temp_array[0], " ") ? mb_strstr($temp_array[0], " ",true) : $temp_array[0];
if (empty($temp_array)) {
return trim_str(trim($groupCode));
}
$tmp_groupCode = explode("-", trim($temp_array[0]));
$real_groupCode = $tmp_groupCode[0];
if (isset($tmp_groupCode[1])) {
$real_groupCode .= "-";
// $real_groupCode .= mb_strstr($tmp_groupCode[1], "", true)!==false ? mb_strstr($tmp_groupCode[1], "", true) : $tmp_groupCode[1];
$order_id = mb_strstr($tmp_groupCode[1], "", true)!==false ? mb_strstr($tmp_groupCode[1], "", true) : $tmp_groupCode[1];
$order_id = mb_strstr($order_id, " ", true)!==false ? mb_strstr($order_id, " ", true) : $order_id;
$real_groupCode .= $order_id;
}
$ret["cut"] = trim_str(trim($real_groupCode));
for ($i=2; $i < count($tmp_groupCode); $i++) {
if (strlen($tmp_groupCode[$i]) > 4) {
$real_groupCode .= "-";
$real_groupCode .= mb_strstr($tmp_groupCode[$i], "", true)!==false ? mb_strstr($tmp_groupCode[$i], "", true) : $tmp_groupCode[$i];
}
}
$real_groupCode = trim_str(trim($real_groupCode));
$ret["all"] = $real_groupCode;
if (strlen($ret['all']) < 9 ) {
$ret['all'] = trim_str(trim($groupCode));
}
return $ret;
}
function trim_str($groupCode)
{
return mb_ereg_replace('( | |)', '', $groupCode);
}
/*!
* 转换字符集编码
* @param $data
* @param $targetCharset
* @return string
*/
function characet($data, $targetCharset) {
if (!empty($data)) {
$fileType = "UTF-8";
if (strcasecmp($fileType, $targetCharset) != 0) {
$data = mb_convert_encoding($data, $targetCharset, $fileType);
// $data = iconv($fileType, $targetCharset.'//IGNORE', $data);
}
}
return $data;
}
function real_phone_number($phone, $nation_code)
{
$nation_str = "+" . $nation_code;
$cut_nation = str_replace($nation_str, "", $phone);
return mb_ereg_replace('[\D]', '', $cut_nation);
}

@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

@ -0,0 +1,111 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Trippest
{
protected $ci;
public function __construct()
{
$this->ci =& get_instance();
}
public function tour_name($pag_code)
{
$name = "";
switch ($pag_code) {
case 'BJSIC-41':
$name = "One Day Beijing Highlights Tour";
break;
case 'BJSIC-42':
$name = "Two-Day Beijing Boutique Small Group Tour";
break;
case 'BJSIC-43':
$name = "Three-Day Beijing Discovery Tour";
break;
default:
# code...
break;
}
return $name;
}
public function complex_tour()
{
return array(
"BJSIC-41" => array(
"name1" => "One Day Beijing Highlights Tour"
,"name2" => "北京精品一日游目的地BJSIC-41"
,"tours" => array(
"BJSIC-41"
)
)
,"BJSIC-42" => array(
"name1" => "Two-Day Beijing Boutique Small Group Tour"
,"name2" => "北京精品两日游目的地BJSIC-42"
,"tours" => array(
"BJSIC-41","BJSIC-42"
)
)
,"BJSIC-43" => array(
"name1" => "Three-Day Beijing Discovery Tour"
,"name2" => "北京精品三日游目的地BJSIC-43"
,"tours" => array(
"BJSIC-41","BJSIC-42","BJSIC-43"
)
)
,"XASIC-42" => array(
"name1" => " "
,"name2" => " "
,"tours" => array(
"XASIC-41","XASIC-42"
)
)
);
}
public function get_complex_pag($pag_code)
{
$all_set = $this->complex_tour();
if (isset($all_set[$pag_code])) {
return $all_set[$pag_code]['tours'];
}
return array($pag_code);
}
public function vendor_sourcetype()
{
return array(
// 北京图兰朵
"1343" => array(
"sourcetype" => "32090"
,"vendor_name" => "北京图兰朵"
,"profit_rate" => 0.4
)
// 上海图兰朵
,"29188" => array(
"sourcetype" => "32112"
,"vendor_name" => "上海图兰朵"
,"profit_rate" => 0.4
)
// 西安图兰朵
,"30548" => array(
"sourcetype" => "32116"
,"vendor_name" => "西安图兰朵"
,"profit_rate" => 0.4
)
// 桂林地接
// ,"628" => array(
// "sourcetype" => "32122"
// ,"vendor_name" => "桂林地接"
// ,"profit_rate" => 0.4
// )
);
}
}
/* End of file trippest.php */
/* Location: ./third_party/trippestOrderSync/libraries/trippest.php */

@ -0,0 +1,334 @@
<?php
class TuLanDuo_addOrUpdateRouteOrderContentBuilder extends CI_Model
{
private $userId;
private $Key;
private $bizContentarr = array();
private $bizContent = NULL;
private $orderData=array();
private $orderId; //”Integer”//订单ID,不为空代表修改
private $modifyLogInfo; //”String”//修改的日志记录信息.如果是修改订单的状态,这里传输修改简报
private $orderType; //”Integer” //订单类型 1=独立成团2=散客团
private $routeName; //”String”//行程名称
private $routeType; //”String”//线路类型
private $agcOrderNo; //”String”//组团社团号,团号格式 yyyy-mm-dd-cc(**)后面中括号号的对应团号的其他表达信息
private $adultNum; //”Integer”//大人数量
private $childNum; //”Integer”//小孩数量
private $guiderNum; //”Integer”//领队数量
private $guiderInfo; //”String”//领队信息
private $toTraffic; //”String”//抵达交通
private $backTraffic; //”String”//返回交通
private $roomStandard; //”String”//用房标准
private $orderRemark; //”String”//订单备注
private $routeStandard; //”String”//行程接待标准
private $destination; //”目的地名称”//目的地城市名称
private $travelDate; //”String”//出游时间yyyy-mm-dd
private $leavedDate; //”String”//离团时间 yyyy-mm-dd
// private $orderData['travelFees']=array(); //团款明细
// [{
// type:”String”//团款类型
// money:”Double”//单价
// num:”Double”//数量
// unit:”Double”//单位
// sumMoney:”Double//总金额”
// remark:”String”//备注
// }]
// private $orderData['replaceCollections']=array(); //代收明细
// [{
// type“String”//代收类型
// money:”Double”//金额
// remark:”String”//备注
// }]
// private $orderData['replacePays']=array(); //代付明细
// [{
// type“String”//代付类型
// money:”Double”//金额
// remark:”String”//备注
// }]
// private $orderData['scheduleDetails']=array(); //行程详细,数组类型,按照第一天往后有序排列
// [{
// title:”String”//行程标题
// content:”String”//行程内容
// traffic:”String”//交通号
// accommodation:”String”//住宿
// breakFirst:”Integer”//是否包含早餐 【1=包含 0=不含】
// dinner:”Integer”//是否包含中餐 【1=包含 0=不含】
// lunch:”Integer”//是否包含晚餐 【1=包含 0=不含】
// }]
// private $orderData['customers']=array(); //游客信息
// [{
// name:”String”//名字
// peopleType:”String”//类型 【成人,小孩,婴儿,老人,学生…】
// document Type:”String”//证件类型【护照,身份证,户口,驾驶证….】
// documentNo:”String”//证件号
// phoneNo:”String”//手机号
// otherInfo:”String”//其他信息
// }]
function __construct() {
parent::__construct();
$this->orderData['travelFees'] = array(); //团款明细
$this->orderData['replaceCollections'] = array(); //代收明细
$this->orderData['replacePays'] = array(); //代付明细
$this->orderData['scheduleDetails'] = array(); //行程详细,数组类型,按照第一天往后有序排列
$this->orderData['customers'] = array(); //游客信息
}
public function getBizContent()
{
if(!empty($this->orderData)){
$this->bizContentarr['orderData'] = $this->orderData;
$this->bizContent = json_encode($this->bizContentarr);
}
return $this->bizContent;
}
public function setUserId($userId)
{
$this->userId = $userId;
$this->bizContentarr['userId'] = $userId;
return $this;
}
public function setKey($Key)
{
$this->key = $Key;
$this->bizContentarr['key'] = $Key;
return $this;
}
/** 订单基本信息 */
public function setOrderId($orderId)
{
$this->orderData['orderId'] = $orderId;
return $this;
}
public function setModifyLogInfo($modifyLogInfo)
{
$this->orderData['modifyLogInfo'] = $modifyLogInfo;
return $this;
}
public function setOrderType($orderType)
{
$this->orderData['orderType'] = $orderType;
return $this;
}
public function setRouteName($routeName)
{
$this->orderData['routeName'] = $routeName;
return $this;
}
public function setRouteType($routeType)
{
$this->orderData['routeType'] = $routeType;
return $this;
}
public function setAgcOrderNo($agcOrderNo)
{
$this->orderData['agcOrderNo'] = $agcOrderNo;
return $this;
}
public function setAdultNum($adultNum)
{
$this->orderData['adultNum'] = $adultNum;
return $this;
}
public function setChildNum($childNum)
{
$this->orderData['childNum'] = $childNum;
return $this;
}
public function setGuiderNum($guiderNum)
{
$this->orderData['guiderNum'] = $guiderNum;
return $this;
}
public function setGuiderInfo($guiderInfo)
{
$this->orderData['guiderInfo'] = $guiderInfo;
return $this;
}
public function setToTraffic($toTraffic)
{
$this->orderData['toTraffic'] = $toTraffic;
return $this;
}
public function setBackTraffic($backTraffic)
{
$this->orderData['backTraffic'] = $backTraffic;
return $this;
}
public function setRoomStandard($roomStandard)
{
$this->orderData['roomStandard'] = $roomStandard;
return $this;
}
public function setOrderRemark($orderRemark)
{
$this->orderData['orderRemark'] = $orderRemark;
return $this;
}
public function setRouteStandard($routeStandard)
{
$this->orderData['routeStandard'] = $routeStandard;
return $this;
}
public function setDestination($destination)
{
$this->orderData['destination'] = $destination;
return $this;
}
public function setTravelDate($travelDate)
{
$this->orderData['travelDate'] = $travelDate;
return $this;
}
public function setLeavedDate($leavedDate)
{
$this->orderData['leavedDate'] = $leavedDate;
return $this;
}
/** 团款数组 */
public function setTravelFeesType($index, $type)
{
$this->orderData['travelFees'][$index]['type'] = $type;
return $this;
}
public function setTravelFeesMoney($index, $money)
{
$this->orderData['travelFees'][$index]['money'] = $money;
return $this;
}
public function setTravelFeesNum($index, $num)
{
$this->orderData['travelFees'][$index]['num'] = $num;
return $this;
}
public function setTravelFeesUnit($index, $unit)
{
$this->orderData['travelFees'][$index]['unit'] = $unit;
return $this;
}
public function setTravelFeesSumMoney($index, $sumMoney)
{
$this->orderData['travelFees'][$index]['sumMoney'] = $sumMoney;
return $this;
}
public function setTravelFeesRemark($index, $remark)
{
$this->orderData['travelFees'][$index]['remark'] = $remark;
return $this;
}
/** 代付数组 */
public function setReplacePaysType($index, $type)
{
$this->orderData['replacePays'][$index]['type'] = $type;
return $this;
}
public function setReplacePaysMoney($index, $money)
{
$this->orderData['replacePays'][$index]['money'] = $money;
return $this;
}
public function setReplacePaysRemark($index, $remark)
{
$this->orderData['replacePays'][$index]['remark'] = $remark;
return $this;
}
/** 代收数组 */
public function setReplaceCollectionsType($index, $type)
{
$this->orderData['replaceCollections'][$index]['type'] = $type;
return $this;
}
public function setReplaceCollectionsMoney($index, $money)
{
$this->orderData['replaceCollections'][$index]['money'] = $money;
return $this;
}
public function setReplaceCollectionsRemark($index, $remark)
{
$this->orderData['replaceCollections'][$index]['remark'] = $remark;
return $this;
}
/** 行程详细数组 */
public function setScheduleDetailsTitle($index, $title)
{
$this->orderData['scheduleDetails'][$index]['title'] = $title;
return $this;
}
public function setScheduleDetailsContent($index, $content)
{
$this->orderData['scheduleDetails'][$index]['content'] = $content;
return $this;
}
public function setScheduleDetailsTraffic($index, $traffic)
{
$this->orderData['scheduleDetails'][$index]['traffic'] = $traffic;
return $this;
}
public function setScheduleDetailsAccommodation($index, $accommodation)
{
$this->orderData['scheduleDetails'][$index]['accommodation'] = $accommodation;
return $this;
}
public function setScheduleDetailsBreakFirst($index, $breakFirst)
{
$this->orderData['scheduleDetails'][$index]['breakFirst'] = $breakFirst;
return $this;
}
public function setScheduleDetailsDinner($index, $dinner)
{
$this->orderData['scheduleDetails'][$index]['dinner'] = $dinner;
return $this;
}
public function setScheduleDetailsLunch($index, $lunch)
{
$this->orderData['scheduleDetails'][$index]['lunch'] = $lunch;
return $this;
}
/** 游客信息数组 */
public function setCustomersName($index, $name)
{
$this->orderData['customers'][$index]['name'] = $name;
return $this;
}
public function setCustomersPeopleType($index, $peopleType)
{
$this->orderData['customers'][$index]['peopleType'] = $peopleType;
return $this;
}
public function setCustomersDocumentType($index, $documentType)
{
$this->orderData['customers'][$index]['documentType'] = $documentType;
return $this;
}
public function setCustomersDocumentNo($index, $documentNo)
{
$this->orderData['customers'][$index]['documentNo'] = $documentNo;
return $this;
}
public function setCustomersPhoneNo($index, $phoneNo)
{
$this->orderData['customers'][$index]['phoneNo'] = $phoneNo;
return $this;
}
public function setCustomersOtherInfo($index, $otherInfo)
{
$this->orderData['customers'][$index]['otherInfo'] = $otherInfo;
return $this;
}
}
?>

@ -0,0 +1,142 @@
<?php
/*!
* 图兰朵系统对接:
* 查询接口业务参数
* @author LYT <lyt@hainatravel.com>
* @date 2018-03-31
*/
class TuLanDuo_queryContentBuilder extends CI_Model
{
private $userId;
private $Key;
private $pageSize=20; //”Integer”//每页数量 每页最多返回50行
private $pageIndex=1; //”Integer”//页码。第几页数据
private $orderType; //”Integer”//订单类型1=独立成团2=散客团 【精准查询】
private $orderStatus; //”Integer”//订单状态 1=已确认0=待确认
private $startTravelDate; //”String”//当前出游时间之后 【精准查询】
private $endTravelDate; //”String”//当前出游时间之前 【精准查询】
private $startOrderDate; //”String”//当前预定时间之后 【精准查询】
private $endOrderDate; //”String”//当前预定时间之前 【精准查询】
private $agcOrderNo; //”String”//组团社团号 【模糊查询】
private $adultNum; //”Integer”//大人数量 【精准查询】
private $childNum; //”Integer”//小孩数量 【精准查询】
private $customerName; //”String”//订单游客名单 【模糊查询】
private $routeName; //”String”//行程名称 。 【模糊查询】
private $operationDep; //”String”//操作部门 【精准查询】
private $orderId; //”Integer”//订单ID
private $bizContentarr = array();
private $bizContent = NULL;
public function getBizContent()
{
if(!empty($this->bizContentarr)){
$this->bizContent = json_encode($this->bizContentarr);
}
return $this->bizContent;
}
public function setUserId($userId)
{
$this->userId = $userId;
$this->bizContentarr['userId'] = $userId;
return $this;
}
public function setKey($Key)
{
$this->key = $Key;
$this->bizContentarr['key'] = $Key;
return $this;
}
public function getPageSize()
{
return $this->pageSize;
}
public function setPageSize($pageSize)
{
$this->pageSize = $pageSize;
$this->bizContentarr['pageSize'] = $pageSize;
return $this;
}
public function getPageIndex()
{
return $this->pageIndex;
}
public function setPageIndex($pageIndex)
{
$this->pageIndex = $pageIndex;
$this->bizContentarr['pageIndex'] = $pageIndex;
return $this;
}
public function getStartTravelDate()
{
return $this->startTravelDate;
}
public function setStartTravelDate($startTravelDate)
{
$this->startTravelDate = $startTravelDate;
$this->bizContentarr['startTravelDate'] = $startTravelDate;
return $this;
}
public function getEndTravelDate()
{
return $this->endTravelDate;
}
public function setEndTravelDate($endTravelDate)
{
$this->endTravelDate = $endTravelDate;
$this->bizContentarr['endTravelDate'] = $endTravelDate;
return $this;
}
public function getStartOrderDate()
{
return $this->startOrderDate;
}
public function setStartOrderDate($startOrderDate)
{
$this->startOrderDate = $startOrderDate;
$this->bizContentarr['startOrderDate'] = $startOrderDate;
return $this;
}
public function getEndOrderDate()
{
return $this->endOrderDate;
}
public function setEndOrderDate($endOrderDate)
{
$this->endOrderDate = $endOrderDate;
$this->bizContentarr['endOrderDate'] = $endOrderDate;
return $this;
}
public function getOrderId()
{
return $this->orderId;
}
public function setOrderId($orderId)
{
$this->orderId = $orderId;
$this->bizContentarr['orderId'] = $orderId;
return $this;
}
public function getAgcOrderNo()
{
return $this->agcOrderNo;
}
public function setAgcOrderNo($agcOrderNo)
{
$this->agcOrderNo = $agcOrderNo;
$this->bizContentarr['agcOrderNo'] = $agcOrderNo;
return $this;
}
// 其他还没用到先不写了...
}
?>

@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

@ -0,0 +1,480 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class OrderFinance_model extends CI_Model {
function __construct() {
parent::__construct();
$this->load->helper('array');
$this->HT = $this->load->database('HT', TRUE);
bcscale(4);
}
public function get_order_info($coli_sn=0)
{
$sql = "SELECT
coli.COLI_SN,coli.COLI_ID as ordernumber,
coli.COLI_WebCode as Agenter,
coli.COLI_ApplyDate as reservedate
,coli.COLI_Cost as basemoney
,ISNULL(coli.COLI_OtherCost,0) as otherCost
,dbo.ConvertToRMB(ISNULL(coli.COLI_Currency,'USD'),ISNULL(coli.COLI_Price,0)) OrderPrice
,gri.GRI_SN ,gri.GRI_No as TuanName
,opi.OPI_Name as ChinaName,opi.OPI_SN as operater,opi.OPI_DEI_SN
,gut.GUT_NationalityID,COI2_Country as country
,(
select top 1 BPE_GuestType
from BIZ_ConfirmLineDetail
inner join BIZ_BookPeopleList on BPL_COLD_SN=COLD_SN
inner join BIZ_BookPeople on BPE_SN=BPL_BPE_SN
where COLD_COLI_SN=coli.COLI_SN
) as guesttype
,(
select COUNT(0)
from BIZ_ConfirmLineDetail
where COLD_COLI_SN=coli.COLI_SN
and isnull(DeleteFlag,0)=0
and COLD_ServiceType='D'
and COLD_PlanVEI_SN in (1343,29188,30548,30016)
) as pag_cnt
from BIZ_ConfirmLineInfo coli
inner join GRoupInfo gri on coli.COLI_GRI_SN=gri.GRI_SN and gri.DeleteFlag=0
inner join OperatorInfo opi on opi.OPI_SN=coli.COLI_OPI_ID
left join BIZ_GUEST gut on gut.GUT_SN=coli.COLI_GUT_SN
left join CountryInfo2 on COI2_COI_SN=gut.GUT_NationalityID and COI2_LGC=2
where coli.COLI_SN=$coli_sn ";
return $this->HT->query($sql)->row();
}
public function get_order_detail($coli_sn=0, $service_type='D', $tulanduo=null)
{
$vei_sql = ($tulanduo===null) ? "" : " AND COLD_PlanVEI_SN NOT IN (1343,29188,30548,30016) ";
$sql = "SELECT * from
BIZ_ConfirmLineDetail cold
where isnull(cold.DeleteFlag,0)=0 and COLD_ServiceType=?
and COLD_COLI_SN=$coli_sn
$vei_sql
";
return $this->HT->query($sql, array($service_type))->result();
}
/** 订单的所有拼团号 */
public function get_order_combineNo($coli_sn=0)
{
$sql = "SELECT gci.GCI_combineNo,gci.GCI_groupType
from GroupCombineInfo gci
inner join BIZ_ConfirmLineInfo coli on gci.GCI_GRI_SN=COLI_GRI_SN and GCI_combineNo<>'cancel'
where coli.COLI_SN=$coli_sn
group by gci.GCI_combineNo,gci.GCI_groupType
order by gci.GCI_groupType desc";
return $this->HT->query($sql)->result();
}
/**
* 拼团号下的所有订单
* * 仅包价线路产品
* * 2018-10-10 增加按COLD_PersonNum降序排序, 计算拼团人数时按多的算.
* 180217342 订单中2人参加两个项目拼同一个团但是人数不同
*/
public function get_all_combine_order($combineNo="", $processed_code=array())
{
$processed_sql = empty($processed_code) ? "" : " and PAG_Code not in (" . my_implode("'",",",$processed_code) . ") ";
$sql = "SELECT gci.GCI_combineNo,gci.GCI_VendorOrderId
,COLI_SN,coli_ID--,COLI_ApplyDate,COLI_GroupCode
,COLD_SN,cold.COLD_ServiceSN--,COLD_EndDate
,cold.COLD_PlanVEI_SN
,PAG_Code ,pag_sub.PAGS_CN_Title, cold.COLD_StartDate,PAG_DefaultVEI_SN
,COLD_PersonNum ,COLD_ChildNum , cold.COLD_StartDate,COLD_EndDate, cold.COLD_TotalPrice
--,PAG_Title
,(select count(1) from GroupCombineInfo where gci_gri_sn=coli_gri_sn) as combine_cnt
from GroupCombineInfo gci
inner join BIZ_ConfirmLineInfo coli on gci.GCI_GRI_SN=COLI_GRI_SN and coli.COLI_State NOT IN (30,40,50)
inner join BIZ_ConfirmLineDetail cold on cold.COLD_COLI_SN=coli.COLI_SN
and cold.COLD_ServiceType='D' and cold.DeleteFlag=0 and COLD_PlanVEI_SN = GCI_VEI_SN
left join BIZ_PackageInfo pag on PAG_SN=COLD_ServiceSN
left join BIZ_PackageInfoSub pag_sub on pag_sub.PAGS_SN=COLD_ServiceSN2
where gci.GCI_combineNo =?
$processed_sql
order by GCI_combineNo asc,cold.COLD_StartDate asc,cold.COLD_PersonNum desc";
return $this->HT->query($sql, array($combineNo))->result();
}
/** 拼团的成本明细,总成本信息 */
public function get_combine_sumMoney($combineNo="")
{
$ret = new stdClass();
$sql = "SELECT GCOD_operationType,GCOD_subType,SUM(cast(gcod.GCOD_sumMoney as float)) cost
from GroupCombineOperationDetail gcod
where gcod.GCOD_GCI_combineNo =?
group by GCOD_GCI_combineNo,GCOD_operationType,GCOD_subType";
$ret->cost_detail = $this->HT->query($sql, array($combineNo))->result();
$ret->cost_sum = array_sum(array_map(function ($ele){return $ele->cost;}, $ret->cost_detail));
$ret->cost_category = array();
$ret->cost_category['water'] = 0;
$ret->cost_category['guide_meal'] = 0;
$ret->cost_category['otherCosts'] = 0;
$ret->cost_category['otherReceives'] = 0;
$ret->cost_category['guiderOperations'] = 0;
$ret->cost_category['touristCarOperations'] = 0;
$ret->cost_category['sceneryOperations'] = 0;
$ret->cost_category['restraurantOperations'] = 0;
foreach ($ret->cost_detail as $key => $value) {
if ($value->GCOD_operationType=='otherCosts' && $value->GCOD_subType=='客人水费') {
$ret->cost_category['water'] += $value->cost;
continue;
} elseif ($value->GCOD_operationType=='otherCosts' && $value->GCOD_subType=='餐补(司陪)') {
$ret->cost_category['guide_meal'] += $value->cost;
continue;
} elseif ($value->GCOD_operationType=='trafficOperations') {
$ret->cost_category['otherCosts'] += $value->cost;
continue;
}
$ret->cost_category[$value->GCOD_operationType] += $value->cost;
}
return $ret;
}
/** 子订单中人数最多的预定 */
public function get_max_cold_person_num($coli_sn=0)
{
$sql = "SELECT
ISNULL(MAX(COLD_PersonNum+COLD_ChildNum+ISNULL(COLD_BabyNum,0)), 0) person_num
,ISNULL(MAX(COLD_PersonNum), 0) adult_num
,ISNULL(MAX(COLD_ChildNum+ISNULL(COLD_BabyNum,0)), 0) child_num
from BIZ_ConfirmLineDetail
where COLD_COLI_SN=$coli_sn ";
$ret = $this->HT->query($sql)->row();
return $ret;
}
/** 订单人数 */
public function get_order_person_num($coli_sn=0)
{
$ret = new stdClass();
// 从订单客人名单列表中取
$sql = "SELECT BPL_BPE_SN,bp.BPE_GuestType
from BIZ_ConfirmLineDetail cold
inner join BIZ_BookPeopleList bpl on bpl.BPL_COLD_SN=cold.COLD_SN
inner join biz_bookpeople bp on bp.BPE_SN=bpl.BPL_BPE_SN
where cold.COLD_COLI_SN=$coli_sn
group by bpl.BPL_BPE_SN,bp.BPE_GuestType";
$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()));
// 从子订单的人数中取最大值
$max_person = $this->get_max_cold_person_num($coli_sn);
if ($ret->person_num === 0 || $ret->person_num < $max_person->person_num) {
// 没有客人名单时, 客人名单小于子订单人数(如新港接送)时
// 使用子订单结果
$ret->person_num = $max_person->person_num;
$ret->adult_num = $max_person->adult_num;
} else {
// 订单列表人数 >= 子订单最大人数, 如180606288
// 使用客人名单总数
$ret->adult_num = $guest_type_cnt['1'];
}
$ret->child_num = $ret->person_num-$ret->adult_num;
return $ret;
}
/** 获取产品信息:产品名称,供应商等 */
public function get_pag_info($PAG_SN_str="")
{
if ($PAG_SN_str=="") {
return array();
}
$sql = "SELECT pag.PAG_SN,PAG_Code,PAG_DefaultVEI_SN,PAG_Title,vei2.VEI2_CompanyBN
from BIZ_PackageInfo pag
inner join VEndorInfo2 vei2 on VEI2_VEI_SN=PAG_DefaultVEI_SN and VEI2_LGC=2
where PAG_SN in ($PAG_SN_str) ";
return $this->HT->query($sql)->result();
}
public function get_order_payment($coli_sn=0, $detail=false)
{
$ret = new stdClass();
$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 = "";
$ret->payTypeDesc = "";
if ( ! empty($payment)) {
foreach ($payment as $kp => $vp) {
$ret->SSmoney = bcadd($ret->SSmoney, $vp->GAI_SSJE);
}
$ret->patDate = $payment[0]->GAI_SSDate;
$ret->payType = $payment[0]->GAI_Type;
$ret->payTypeDesc = $this->HT
->query("SELECT SYC2_CodeDiscribe
FROM V_System_Code
WHERE SYC_Type=15 AND LGC_LGC=2
AND SYC_SN=?
", array($ret->payType))
->row()->SYC2_CodeDiscribe;
}
return $ret;
}
/** 判断各种项目的报表是否已存在 */
public function report_tour_exists($coli_id=null, $tourCode=null, $tourBz=null)
{
$sql = "SELECT top 10 ordernumber from report_tour where ordernumber=? ";
if ($tourBz) {
$tourBz = mb_ereg_replace('[^a-zA-Z0-9\-\[\]]$', '', strstr($tourBz, ",", true));
if (stripos($tourBz, "pvt") === false) {
$tourBz = str_replace("]", "", $tourBz);
}
$tourBz = str_replace("[", "[[]", $tourBz);
$sql .= " and (tourBz like '%" . $this->HT->escape_like_str($tourBz) . "%'
OR tourBz='') ";
} else {
$sql .= " AND tourCode='" . $tourCode . "' ";
}
$num_rows = $this->HT->query($sql, array($coli_id))->num_rows();
return $num_rows>0;
}
public function report_train_exists($coli_id=null, $TrainNo=null)
{
$sql = "SELECT top 1 OrderNumber from report_Train where OrderNumber=? and TrainNo=?";
$num_rows = $this->HT->query($sql, array($coli_id, $TrainNo))->num_rows();
return $num_rows>0;
}
public function report_room_exists($coli_id=null, $hotelName=null)
{
$sql = "SELECT top 1 ordernumber from report_room where ordernumber=? and hotelName=?";
$num_rows = $this->HT->query($sql, array($coli_id, $hotelName))->num_rows();
return $num_rows>0;
}
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=? and orderstats=1";
$num_rows = $this->HT->query($sql, array($coli_id, $gri_sn))->num_rows();
return $num_rows>0;
}
/** 图兰朵包价线路产品 */
public function insert_report_tour_tulanduo($report_tour_arr=array())
{
foreach ($report_tour_arr as $krt => $vrt) {
$tourBz_tmp = "";
if ($this->report_tour_exists($vrt['ordernumber'], $vrt['tourCode'], $vrt['tourBZ']) === TRUE) {
$where = " ordernumber='" . $vrt['ordernumber'] . "' "; //AND tourCode='" . $vrt['tourCode'] . "' ";
$tourBz_tmp = mb_ereg_replace('[^a-zA-Z0-9\-\[\]]$', '', strstr($vrt['tourBZ'], ",", true));
if (stripos($tourBz_tmp, "pvt") === false) {
$tourBz_tmp = str_replace("]", "", $tourBz_tmp);
}
$tourBz_tmp = str_replace("[", "[[]", $tourBz_tmp);
$where .= " AND (tourBZ like '%" . $this->HT->escape_like_str($tourBz_tmp) . "%'
OR tourBZ='') ";
$delete_sql = "DELETE FROM tourmanager.dbo.Report_Tour where " . $where;
// $update_sql = $this->HT->update_string('tourmanager.dbo.Report_Tour', $vrt, $where);
$this->HT->query($delete_sql);
}
// else {
$this->HT->insert('tourmanager.dbo.Report_Tour', $vrt);
// }
}
return TRUE;
}
/** 火车票 */
public function insert_report_train($coli_sn=0)
{
$train_cost = $this->get_train_cost($coli_sn);
foreach ($train_cost as $ktc => $vtc) {
if ($this->report_train_exists($vtc->OrderNumber, $vtc->TrainNo) === TRUE) {
$where = " OrderNumber='" . $vtc->OrderNumber . "' AND TrainNo='" . $vtc->TrainNo . "' ";
$update_sql = $this->HT->update_string('tourmanager.dbo.report_Train', json_decode(json_encode($vtc), TRUE), $where);
$this->HT->query($update_sql);
} else {
$this->HT->insert('tourmanager.dbo.report_Train', json_decode(json_encode($vtc), TRUE));
}
}
return $this->HT->query("SELECT * from tourmanager.dbo.report_Train inner join BIZ_ConfirmLineInfo on COLI_ID=OrderNumber WHERE COLI_SN=$coli_sn order by OrderID desc")->result();
}
public function get_train_cost($coli_sn=0)
{
$sql = "SELECT
dbo.BIZ_ConfirmLineInfo.COLI_ID OrderNumber,
FlightsNo TrainNo,
DepartureCity,
ArrivalCity,
left(convert(varchar,DepartureDate,120),10) as DepartureDate,
isnull(COLD_PersonNum,0)+ISNULL(COLD_ChildNum,0) as PassengerNo,
adultcost adultPrice,
COLD_TotalCost as TotalCost,
dbo.ConvertToRMB('USD',COLD_TotalPrice) as TotalPrice,
SUBSTRING(VEI2_CompanyBN,1,50) TrainProvide,
case when dbo.GetBIZTrainVEIDebt(COLD_SN)='YES' then '挂账' else ' ' end as TrainBZ,
0 as orderstats
from BIZ_ConfirmLineDetail
inner join BIZ_ConfirmLineInfo on COLI_SN=COLD_COLI_SN
inner join BIZ_FlightsOrderInfo on FOI_COLD_SN = COLD_SN
left join VEndorInfo2 on COLD_PlanVEI_SN = VEI2_VEI_SN and VEI2_LGC = 2
where COLD_COLI_SN = $coli_sn
and isnull(BIZ_ConfirmLineDetail.DeleteFlag,0)=0
and COLD_ServiceType = '2' ";
return $this->HT->query($sql)->result();
}
/** 酒店 */
public function insert_report_hotel($coli_sn=0)
{
$hotel_cost = $this->get_hotel_cost($coli_sn);
foreach ($hotel_cost as $khc => $vhc) {
if ($this->report_room_exists($vhc->ordernumber, $vhc->hotelName) === TRUE) {
$where = " ordernumber='" . $vhc->ordernumber . "' AND hotelName='" . $vhc->hotelName . "' ";
$update_sql = $this->HT->update_string('tourmanager.dbo.report_room', json_decode(json_encode($vhc), TRUE), $where);
$this->HT->query($update_sql);
} else {
$this->HT->insert('tourmanager.dbo.report_room', json_decode(json_encode($vhc), TRUE));
}
}
return $this->HT->query("SELECT * from tourmanager.dbo.report_room inner join BIZ_ConfirmLineInfo on COLI_ID=ordernumber WHERE COLI_SN=$coli_sn order by orderId desc")->result();
}
public function get_hotel_cost($coli_sn)
{
$sql = "
SELECT coli_id ordernumber,
SUBSTRING(v2.VEI2_CompanyBN,1,50) AS hotelName,
cityinfo2.CII2_Name AS cityName,
(SELECT SGC_ServiceGrade
FROM servicegradecode2
WHERE SGC2_LGC=2
AND SGC2_SGC_SN=Isnull(VEI_Grade,-1)) AS hotelStar,
(SELECT SUBSTRING(ROT2_TypeName,1,100) as ROT2_TypeName
FROM roomtype2
WHERE ROT2_ROT_SN=ISNULL(COLD_ServiceSN2,-1)
AND ROT2_LGC=1) AS roomtype,
left(convert(varchar,COLD_StartDate,120),10) AS starttime,
left(convert(varchar,COLD_EndDate,120),10) AS endtime,
COLD_Count roomnumber,
isnull(HOI_ExtraNum,0) AS ExtraBedNumber,
COLD_DayCount=DATEDIFF(DAY,COLD_StartDate,COLD_EndDate) as jianyeshu,
COLD_TotalCost*1.0/dbo.ZeroToOne(DATEDIFF(DAY,COLD_StartDate,COLD_EndDate)) as jianyecost,
0 as ExtraBedCost,
0 as ExtraBedPrice,
COLD_TotalCost roomcost,
dbo.ConvertToRMB('USD',COLD_TotalPrice) as roomprice,
dbo.ConvertToRMB('USD',(COLD_TotalPrice/1.03))-COLD_TotalCost as roomprofit,
SUBSTRING(VendorInfo2.VEI2_CompanyBN,1,50) AS roomprovide,
SUBSTRING(COLD_Describe,1,150) roombz,
0 as orderstats
FROM BIZ_ConfirmLineDetail
INNER JOIN BIZ_ConfirmLineInfo ON COLD_COLI_SN=COLI_SN
LEFT JOIN BIZ_HotelOrderInfo ON HOI_COLD_SN = COLD_SN
LEFT JOIN VEndorInfo2 ON COLD_PlanVEI_SN = VEI2_VEI_SN AND VEI2_LGC = 2
LEFT JOIN Vendorinfo2 AS V2 ON COLD_ServiceSN = V2.VEI2_VEI_SN AND V2.VEI2_LGC = 2
LEFT JOIN VendorInfo ON COLD_ServiceSN = VEI_SN
LEFT JOIN cityinfo2 ON vendorinfo.VEI_CII_Name=cityinfo2.CII2_CII_SN AND cityinfo2.CII2_LGC=2
WHERE COLD_COLI_SN = $coli_sn
AND BIZ_ConfirmLineDetail.DeleteFlag = 0
AND COLD_ServiceType = 'A'
";
return $this->HT->query($sql)->result();
}
/** 非图兰朵供应商的包价线路产品 */
public function insert_report_tour_others($coli_sn=0)
{
$other_tour_cost = $this->get_report_tour_others_cost($coli_sn);
foreach ($other_tour_cost as $kotc => $votc) {
if ($this->report_tour_exists($votc->ordernumber, $votc->tourCode, $votc->tourBZ) === TRUE) {
$where = " ordernumber='" . $votc->ordernumber . "' AND tourCode='" . $votc->tourCode . "'";
$where .= " AND tourBZ='" . $votc->tourBZ . "' ";
$update_sql = $this->HT->update_string('tourmanager.dbo.Report_Tour', json_decode(json_encode($votc), TRUE), $where);
$this->HT->query($update_sql);
} else {
$this->HT->insert('tourmanager.dbo.Report_Tour', json_decode(json_encode($votc), TRUE));
}
}
return $this->HT->query("SELECT top 1 * from tourmanager.dbo.report_tour inner join BIZ_ConfirmLineInfo on COLI_ID=ordernumber WHERE COLI_SN=$coli_sn order by orderId desc")->result();
}
public function get_report_tour_others_cost($coli_sn=0)
{
$sql = "SELECT
dbo.BIZ_ConfirmLineInfo.COLI_ID ordernumber,
dbo.BIZ_PackageInfo.PAG_Code tourCode,
SUBSTRING(dbo.BIZ_PackageInfo.PAG_Title,1,200) tourname,
SUBSTRING(CONVERT(varchar,dbo.BIZ_ConfirmLineDetail.COLD_StartDate, 120), 1, 10) AS tourtime,
dbo.BIZ_ConfirmLineDetail.COLD_PersonNum tourRSd,
dbo.BIZ_ConfirmLineDetail.COLD_ChildNum tourRSx,
--@AdultCost,
(select top 1 PKP_AdultCost
from BIZ_PackagePrice
where PKP_PAG_SN=COLD_ServiceSN
and PKP_VEI_SN=COLD_PlanVEI_SN
and PKP_PersonStart<=isnull(COLD_PersonNum,0)+isnull(COLD_ChildNum,0)
and PKP_PersonStop >=isnull(COLD_PersonNum,0)+isnull(COLD_ChildNum,0)
and PKP_ValidDate <= CONVERT(varchar(100),COLD_StartDate,23)
and PKP_InvalidDate >= CONVERT(varchar(100),COLD_StartDate,23)
ORDER BY PKP_PriceGrade
) as tourCostRsd,
--@ChildCost,
(select top 1 PKP_ChildCost
from BIZ_PackagePrice
where PKP_PAG_SN=COLD_ServiceSN
and PKP_VEI_SN=COLD_PlanVEI_SN
and PKP_PersonStart<=isnull(COLD_PersonNum,0)+isnull(COLD_ChildNum,0)
and PKP_PersonStop >=isnull(COLD_PersonNum,0)+isnull(COLD_ChildNum,0)
and PKP_ValidDate <= CONVERT(varchar(100),COLD_StartDate,23)
and PKP_InvalidDate >= CONVERT(varchar(100),COLD_StartDate,23)
ORDER BY PKP_PriceGrade
) as tourCostRSx,
dbo.BIZ_ConfirmLineDetail.COLD_TotalCost tourcost,
dbo.ConvertToRMB('USD',dbo.BIZ_ConfirmLineDetail.COLD_TotalPrice) tourPrice,
dbo.ConvertToRMB('USD',dbo.BIZ_ConfirmLineDetail.COLD_TotalPrice)-dbo.BIZ_ConfirmLineDetail.COLD_TotalCost as tourProfit,
SUBSTRING(isnull(dbo.VEndorInfo2.VEI2_CompanyBN,'.'),1,50) as tourProvide,
SUBSTRING(dbo.BIZ_ConfirmLineDetail.COLD_Describe,1,70) as tourBZ,
0 as orderstats
FROM dbo.BIZ_ConfirmLineDetail
inner join BIZ_ConfirmLineInfo on COLI_SN=COLD_COLI_SN
LEFT OUTER JOIN dbo.VEndorInfo2 ON dbo.VEndorInfo2.VEI2_VEI_SN = dbo.BIZ_ConfirmLineDetail.COLD_PlanVEI_SN AND dbo.VEndorInfo2.VEI2_LGC = 2
INNER JOIN dbo.BIZ_PackageInfo ON dbo.BIZ_ConfirmLineDetail.COLD_ServiceSN = dbo.BIZ_PackageInfo.PAG_SN
WHERE (dbo.BIZ_ConfirmLineDetail.COLD_ServiceType='D')
AND (dbo.BIZ_ConfirmLineDetail.DeleteFlag = 0)
AND (dbo.BIZ_ConfirmLineDetail.COLD_COLI_SN=$coli_sn) ";
return $this->HT->query($sql)->result();
}
/** 单团财务表 */
public function insert_report_order($report_order_arr=array(), $coli_sn=0, $gri_sn=0)
{
$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);
} else {
$this->HT->insert('tourmanager.dbo.report_order', $report_order_arr);
}
return $this->get_report_order($report_order_arr['ordernumber']);
}
public function get_report_order($coli_id=0)
{
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')
{
// [dbo].[ConvertToRMB](@TargetCurrency varchar(6), @SourceMoney decimal(18,5))
return $this->HT->query("SELECT tourmanager.dbo.[ConvertToRMB]('$fromCurrency',$money) as rmb ")->row()->rmb;
}
public function get_report_order_xh()
{
return $this->HT->query("SELECT MAX(xh)+1 as newxh from report_order")->row()->newxh;
}
}
/* End of file orderFinance_model.php */
/* Location: ./webht/third_party/trippestOrderSync/models/orderFinance_model.php */

@ -0,0 +1,95 @@
<?php
class Order_update extends CI_Model {
function __construct() {
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
//读取默认配置
$this->COLI_WebCode = $this->config->item('Site_Code');
$this->COLI_Area = $this->config->item('Site_Area');
$this->COLI_CustomerType = $this->config->item('Site_DepartmentID');
$this->COLI_department = $this->config->item('Site_Department');
$this->COLI_Currency = $this->config->item('Site_Currency');
$this->COLI_InterestRate = $this->config->item('Site_InterestRate');
$this->COLI_TrueCardRate = $this->config->item('Site_TrueCardRate');
$this->COLI_TouristLGC = $this->config->item('Site_ServiceLGC');
$this->COLI_OrderStartDate = null;
$this->COLI_Keywords = NULL;
}
public $coli_where_update = "";
public function biz_confirmlineinfo_update($column_data)
{
if ($this->coli_where_update == "" || empty($column_data)) {
return false;
}
$update_str = $this->HT->update_string('BIZ_ConfirmLineInfo', $column_data, $this->coli_where_update);
$update_exc = $this->HT->query($update_str);
return $update_exc;
}
public $cold_where_update = "";
public function biz_confirmlinedetail_update($column_data)
{
if ($this->cold_where_update == "" || empty($column_data)) {
return false;
}
$update_str = $this->HT->update_string('BIZ_ConfirmLineDetail', $column_data, $this->cold_where_update);
$update_exc = $this->HT->query($update_str);
return $update_exc;
}
/*!
* 更新拼团信息
* @date 2018-04-26
* @param array $column_data 需要更新的列数据数组
*/
public $gci_where_update = ""; // where 条件
public function biz_groupcombineinfo_update($column_data)
{
if ($this->gci_where_update == "" || empty($column_data)) {
return false;
}
$update_str = $this->HT->update_string('GroupCombineInfo', $column_data, $this->gci_where_update);
$update_exc = $this->HT->query($update_str);
return $update_exc;
}
/*!
* 更新团信息
*/
public $gri_where_update = ""; // where 条件
public function biz_groupinfo_update($column_data)
{
if ($this->gri_where_update == "" || empty($column_data)) {
return false;
}
$update_str = $this->HT->update_string('GroupInfo', $column_data, $this->gri_where_update);
$update_exc = $this->HT->query($update_str);
return $update_exc;
}
/*!
* 地接计划状态变更
* @param [type] $vas_sn [description]
* @param string $confirminfo [description]
*/
public function vendorStatus_update($vas_sn, $lmi_sn, $confirminfo="")
{
$sql = "UPDATE VendorArrangeState
SET VAS_IsConfirm=1
,VAS_ConfirmInfo=?
,VAS_ConfirmTime=getdate()
,VAS_ConfirmSN=?
WHERE VAS_SN=?";
$query = $this->HT->query($sql, array($confirminfo, $lmi_sn, $vas_sn));
// affected_rows() doesn't work with the 'sqlsrv' driver in CI2
// The solution: Upgrade to the latest CodeIgniter 3.0.x version
$ssql = "SELECT 1 as 'exist' from VendorArrangeState where VAS_IsConfirm=1 and VAS_SN=? ";
$squery = $this->HT->query($ssql, array($vas_sn));
$ret = $squery->result();
return !empty($ret);
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,125 @@
<?php
/*!
* 查询
*/
class Orders_query extends CI_Model {
function __construct() {
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
}
/** 获取海纳团的发团人 */
public function get_gri_opi_id($code)
{
$gri_sql = "SELECT top 1 GRI_SN,GRI_OPI_ID,isnull(GRI_operator,0) GRI_operator,GRI_No,GRI_Name
from GRoupInfo
where GRI_Name like '%$code%' ";
$gri_query = $this->HT->query($gri_sql);
if ($gri_query->num_rows() > 0) {
return $gri_query->row()->GRI_operator;
}
return 0;
}
public function get_order_vendorplan($COLI_ID)
{
$sql = "SELECT COLI_GroupCode,COLI_OPI_ID,vas.*
from BIZ_ConfirmLineInfo coli
left join VendorArrangeState vas on VAS_GRI_SN=COLI_GRI_SN
where COLI_GroupCode like '%" . $this->HT->escape_like_str($COLI_ID) . "%'
OR COLI_ID like '%" . $this->HT->escape_like_str($COLI_ID) . "%'
OR COLI_PriceMemo like '%" . $this->HT->escape_like_str($COLI_ID) . "%'
";
return $this->HT->query($sql)->result();
}
public function get_order_detail($GRI_SN)
{
$sql = "SELECT
pag2.PAG2_Name
,(select PAG_code from biz_packageinfo where pag_sn=COLD_ServiceSN) as pag_code
,pags.PAGS_Direction,pags.PAGS_describ
,poi.POI_Hotel,poi.POI_HotelAddress,poi.POI_HotelPhone
,poi.POI_AirPort,poi.POI_FlightsNo
,GUT_FirstName,GUT_LastName
,cold.*,coli.*
from BIZ_ConfirmLineDetail cold
inner join BIZ_ConfirmLineInfo coli on COLI_SN=COLD_COLI_SN and cold.DeleteFlag=0
inner join BIZ_PackageOrderInfo poi on poi.POI_COLD_SN=COLD_SN
inner join BIZ_GUEST g on g.GUT_SN=COLI_GUT_SN
left join BIZ_PackageInfo2 pag2 on pag2.PAG2_PAG_SN=COLD_ServiceSN and pag2.PAG2_LGC=1
left join BIZ_PackageInfoSub pags on pags.PAGS_SN=cold.COLD_ServiceSN2
where COLI_GRI_SN=$GRI_SN
order by COLD_StartDate ";
return $this->HT->query($sql)->result();
}
public function get_plan_tourguide($GRI_SN=0)
{
$GRI_SN = $GRI_SN==NULL ? 0 : $GRI_SN;
$sql = "SELECT tgi_info.TGI_SN,tgi_info.TGI2_Name,tgi_info.TGI_Mobile
,eoi.EOI_GetDate,eoi.EOI_Date,eoi.EOI_VEI_SN
from Eva_ObjectInfo eoi
left join
( select TGI_SN,TGI_Mobile,TGI2_Name from TouristGuideInfo tgi
left join TouristGuideInfo2 tgi2 on TGI2_TGI_SN=TGI_SN and TGI2_LGC=1
) as tgi_info on tgi_info.TGI_SN=eoi.EOI_ObjSN
where eoi.EOI_Type=3 and EOI_gri_sn=$GRI_SN
order by eoi.EOI_GetDate ";
return $this->HT->query($sql)->result();
}
function get_package_order($COLI_ID)
{
$order_info_sql = "SELECT
GCI_SN,GCI_VendorOrderId,GCI_combineNo
,(select PAG_code from biz_packageinfo where pag_sn=COLD_ServiceSN) as pag_code
,COLI_SN,COLI_ID,COLD_SN,COLI_GroupCode,COLI_OPI_ID,COLI_OrderDetailText,COLI_PriceMemo
,COLD_ServiceSN,COLD_PersonNum,COLD_ChildNum,COLD_StartDate,COLD_EndDate,cold.COLD_MemoText
,pags.PAGS_Direction,pags.PAGS_describ
,pag2.PAG2_Name
,poi.POI_Hotel,poi.POI_HotelAddress,poi.POI_HotelPhone
,poi.POI_AirPort,poi.POI_FlightsNo
,GUT_FirstName,GUT_LastName
FROM BIZ_ConfirmLineInfo coli
inner join GroupCombineInfo on COLI_GRI_SN=GCI_GRI_SN --and GCI_combineNo<>'cancel'
inner join BIZ_ConfirmLineDetail cold on COLD_COLI_SN=COLI_SN
inner join BIZ_PackageOrderInfo poi on poi.POI_COLD_SN=COLD_SN
inner join BIZ_GUEST g on g.GUT_SN=COLI_GUT_SN
inner join BIZ_PackageInfo2 pag2 on pag2.PAG2_PAG_SN=COLD_ServiceSN and pag2.PAG2_LGC=1
left join BIZ_PackageInfoSub pags on pags.PAGS_SN=cold.COLD_ServiceSN2
where COLI_GroupCode like '%" . $this->HT->escape_like_str($COLI_ID) . "%'
OR COLI_ID like '%" . $this->HT->escape_like_str($COLI_ID) . "%'
OR COLI_PriceMemo like '%" . $this->HT->escape_like_str($COLI_ID) . "%'
order by COLD_StartDate asc";
// OR COLI_ID like '%" . $this->HT->escape_like_str($COLI_ID) . "%'
$order_info_query = $this->HT->query($order_info_sql);
$ret = $order_info_query->result();
return $ret;
}
function get_operator($OPI_SN=0)
{
$operator_sql = "SELECT opi.OPI_SN,opi.OPI_Name,opi.OPI_FirstName,OPI_MoveTelephone,OPI_Email,opi2.OPI2_Name
from OperatorInfo opi
left join OperatorInfo2 opi2 on opi2.OPI2_OPI_SN=OPI_SN and opi2.OPI2_LGC=1
where OPI_SN=" . $OPI_SN . " AND OPI_SN<>435";
return $this->HT->query($operator_sql)->row();
}
function get_operation($combineNo)
{
$combineNos = my_implode("'",",",$combineNo);
$operation_sql = "SELECT gcod.*
from GroupCombineOperationDetail gcod
where GCOD_GCI_combineNo in ($combineNos)
and gcod.GCOD_operationType in ('touristCarOperations','guiderOperations')
order by GCOD_startDate";
$operation_info = $this->HT->query($operation_sql, array($combineNo));
return $operation_info->result();
}
}

@ -0,0 +1,160 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Send_operation_model extends CI_Model {
function __construct() {
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
$this->info = $this->load->database('INFO', TRUE);
}
public function daytour_order_ready_for_send($COLI_ID="", $date, $time_flag="no_send_state")
{
$today = date('Y-m-d 16:00:00');
switch ($time_flag) {
case 'try1':
$send_state = " ";
break;
case 'try2':
$send_state = " and (TPSL_sendState=1 OR TPSL_logTime > '$today') ";
break;
case 'handle':
$send_state = " and (TPSL_sendState=1) ";
break;
case '':
default:
$send_state = "";
break;
}
$send_state_sql = " and not exists (
select TPSL_SN from InfoManager.dbo.trippest_sms_log
where TPSL_COLI_SN=coli.COLI_SN
$send_state
) ";
$top = " TOP 1 ";
$sms_state = "";
if ($time_flag == "no_send_state") {
$send_state_sql = "";
$top = "";
$sms_state = " ,(SELECT top 1 TPSL_sendState from InfoManager.dbo.trippest_sms_log
where TPSL_COLI_SN=coli.COLI_SN
and TPSL_sendContent like '%'+CONVERT(VARCHAR(10),CONVERT(DATE, COLD_StartDate))+'%'
order by TPSL_sendState desc
) as send_state";
}
$search_sql = " AND COLD_StartDate ='$date' ";
if ($COLI_ID !== "") {
$search_sql = " AND COLI_ID='" . $COLI_ID . "'";
}
$sql = "SELECT $top
COLI_GroupCode,COLI_SN,COLI_ID
$sms_state
,GUT_POST,GUT_TEL
,PAG_Code
,g.GUT_FirstName+' '+g.GUT_LastName guest_name
,(
select top 1 GCOD_dutyName+'@'+GCOD_dutyTel+'@'+convert(varchar(20),GCOD_creatTime)+'@'+convert(varchar(20),GCI_createTime)
from GroupCombineInfo
inner join GroupCombineOperationDetail on GCOD_GCI_combineNo=GCI_combineNo
AND GCI_combineNo not IN ('cancel','forbidden')
where GCI_GRI_SN=COLI_GRI_SN
AND GCOD_operationType='guiderOperations'
) as gcod
,(
select top 1 TGI2_Name+'@'+TGI_Mobile from Eva_ObjectInfo
left join
( select TGI_SN,TGI_Mobile,TGI2_Name from TouristGuideInfo tgi
left join TouristGuideInfo2 tgi2 on TGI2_TGI_SN=TGI_SN and TGI2_LGC=1
) as tgi_info on tgi_info.TGI_SN=EOI_ObjSN
where EOI_GRI_SN=COLI_GRI_SN and EOI_Type=3
) as eva
,COLD_StartDate
from BIZ_ConfirmLineInfo coli
inner join BIZ_ConfirmLineDetail cold on COLI_SN=COLD_COLI_SN
INNER JOIN BIZ_GUEST g ON g.GUT_SN=COLI_GUT_SN
and GUT_TEL is not null and GUT_TEL<>'' and GUT_POST<>''
INNER JOIN BIZ_PackageInfo pag ON pag.PAG_SN=COLD_ServiceSN
WHERE 1=1
and COLI_State not in (30,40,50)
$search_sql
AND '39009'<>PAG_ExtendType
$send_state_sql
and (exists (
select top 1 1 from GroupCombineInfo
inner join GroupCombineOperationDetail on GCOD_GCI_combineNo=GCI_combineNo
AND GCI_combineNo not IN ('cancel','forbidden')
where GCI_GRI_SN=COLI_GRI_SN
AND GCOD_operationType='guiderOperations'
)
OR exists (
select top 1 1 from Eva_ObjectInfo
where EOI_GRI_SN=COLI_GRI_SN and EOI_Type=3
)
)
ORDER BY COLD_StartDate, COLI_SN";
$query = $this->HT->query($sql);
return $query->result();
}
public function insert_trippest_sms_log($column)
{
$this->info->insert("trippest_sms_log", $column);
return $this->info->insert_id();
}
public function update_trippest_sms_log($where, $column)
{
if ($where == "" || empty($column)) {
return false;
}
$update_str = $this->info->update_string('trippest_sms_log', $column, $where);
$update_exc = $this->info->query($update_str);
return $update_exc;
}
/** 暂时不用了 */
public function if_order_sent($COLI_SN, $msgType='guide')
{
$sql = "SELECT *
FROM [infomanager].[dbo].[trippest_sms_log]
where [TPSL_COLI_SN]=$COLI_SN
and [TPSL_sendState]=1
and TPSL_msgType='$msgType'
";
return $this->info->query($sql)->row();
}
/*
* 发送邮件
*/
function SendMail($fromName, $fromEmail, $toName, $toEmail, $subject, $body) {
$sql = "INSERT INTO tourmanager.dbo.Email_AutomaticSend \n"
. " ( \n"
. " M_ReplyToName, M_ReplyToEmail, M_ToName, M_ToEmail, M_Title, M_Body, M_Web, \n"
. " M_FromName, M_State \n"
. " ) \n"
. "VALUES \n"
. " ( \n"
. " ?, ?, ?, ?, ?, N?, ?, ?, 0 \n"
. " ) ";
$query = $this->info->query($sql,
array(substr($fromName, 0, 127), $fromEmail, substr($toName, 0, 127), $toEmail, $subject, $body, 'trippest SMS send fail', 'chinahighlighgts')
);
return $query;
}
function order_sms_list($COLI_SN=0)
{
$sql = "SELECT *
FROM [infomanager].[dbo].[trippest_sms_log]
where [TPSL_COLI_SN]=$COLI_SN
order by TPSL_logTime ";
return $this->HT->query($sql)->result();
}
}
/* End of file send_operation_model.php */
/* Location: ./webht/third_party/trippestOrderSync/models/send_operation_model.php */

@ -0,0 +1,72 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Tulanduo_sync_model extends CI_Model {
function __construct() {
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
}
/*!
* 查询图兰朵订单id是否已存在
* @param string $vendorOrderIds [description]
*/
public function get_exists_vendorOrderId($vendorOrderIds="")
{
$sql = "SELECT GCI_VendorOrderId FROM GroupCombineInfo
WHERE GCI_VendorOrderId IN ($vendorOrderIds) ";
return $this->HT->query($sql)->result();
}
/*!
* 从图兰朵同步历史数据的日期偏移
* 获取HT内图兰朵订单的最老出发日期
* * 由于获取列表时根据发团日期或得到更早时间的发团日期
* * 因此这里取最早的10个, 找出不连续的为滚动日期的开始
*/
public function get_oldest_offset()
{
$ret_date = "";
$sql = "SELECT DISTINCT TOP 10 CAST(GCI_travelDate as DATE) old_date from GroupCombineInfo
order by old_date asc";
$all_date = $this->HT->query($sql)->result();
$all_date_arr = array_map(function($ele)
{
return $ele->old_date;
}, $all_date);
for ($i=count($all_date_arr)-1; $i > 0; $i--) {
$d1 = new DateTime($all_date_arr[$i]);
$d2 = new DateTime($all_date_arr[$i-1]);
$date_diff = $d2->diff($d1);
if (intval($date_diff->format('%R%a')) > 1 && !in_array($all_date_arr[$i], $this->empty_date()) ) {
$ret_date = $all_date_arr[$i];
break;
}
}
if ($ret_date==="") {
$ret_date = $all_date_arr[0];
}
return $ret_date;
}
private function empty_date()
{
return array(
"2018-02-06" // 2018-02-05 没有团
,"2017-01-17"
);
}
/*!
* 图兰朵订单在HT内的信息
* @param [type] $code [description]
* @param [type] $vendorOrderId [description]
*/
public function get_vendorOrder_HTinfo($code, $vendorOrderId=NULL)
{
# code...
}
}
/* End of file tulanduo_sync_model.php */
/* Location: ./webht/third_party/trippestOrderSync/models/tulanduo_sync_model.php */

@ -0,0 +1,157 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
define('PAY_OTHER','15017,15008,15006,15020');
class Vendor_money_model extends CI_Model {
function __construct() {
parent::__construct();
$this->load->helper('array');
$this->HT = $this->load->database('HT', TRUE);
bcscale(4);
}
public function checked_group_list($vendor, $sourcetype, $start_date, $end_date, $all_vendor)
{
$sql = "SELECT sum_opi.COLI_OPI_ID,sum(sum_opi.海纳收款) as trippest_sum,sum(sum_opi.地接社收款) as vendor_sum,
sum(sum_opi.other_price_RMB) as other_price_sum
, sum(sum_opi.other_cost_RMB) as other_cost_sum
from (
SELECT
(select isnull(SUM(COLD_TotalPrice),0) from BIZ_ConfirmLineDetail cold
where cold.COLD_COLI_SN=cgi_group.COLI_SN
and COLD_ServiceType <> 'D'
and COLD_PlanVEI_SN IN ($all_vendor)
and cold.DeleteFlag=0
)*cgi_group.汇率 as other_price_RMB,
(select isnull(SUM(COLD_TotalCost),0) from BIZ_ConfirmLineDetail cold
where cold.COLD_COLI_SN=cgi_group.COLI_SN
and COLD_ServiceType <> 'D'
and COLD_PlanVEI_SN IN ($all_vendor)
and cold.DeleteFlag=0
) as other_cost_RMB,
*
from (
select
COLI_SN,
(select COUNT(0) from BIZ_ConfirmLineDetail
where COLD_COLI_SN=COLI_SN
and COLD_ServiceType='D'
and DeleteFlag=0
) as service_cnt,
COLI.COLI_sourcetype,
COLI.COLI_Price,
coli.COLI_Currency,
case when coli.COLI_Price <> 0 then
convert(decimal(10,2),round((select isnull(SUM(GAI_SSJE),0) from BIZ_GroupAccountInfo
where DeleteFlag=0 and GAI_COLI_SN=COLI_SN
)/isnull(COLI.COLI_Price,1),2))
else 0 end as 汇率,
(select isnull(SUM(GAI_SSJE),0) from BIZ_GroupAccountInfo
where DeleteFlag=0 and GAI_COLI_SN=COLI_SN
) as 总收款,
(select isnull(SUM(GAI_SSJE),0) from BIZ_GroupAccountInfo
where DeleteFlag=0 and GAI_COLI_SN=COLI_SN
and GAI_Type not in (" . PAY_OTHER . ")
) as 海纳收款,
(select isnull(SUM(GAI_SSJE),0) from BIZ_GroupAccountInfo
where DeleteFlag=0 and GAI_COLI_SN=COLI_SN
and GAI_Type in (" . PAY_OTHER . ")
) as 地接社收款
,coli.COLI_OPI_ID
from CK_GroupInfo cgi
inner join GRoupInfo gri on CGI_GRI_SN=GRI_SN
inner join BIZ_ConfirmLineInfo coli on COLI_GRI_SN=GRI_SN
where 1=1
and CGI_ArriveDate between '$start_date' and '$end_date'
and exists (
select 1 from OperatorInfo where OPI_DEI_SN=30 and OPI_SN=CGI_OPI_SN
)
and CGI_Checked=1
and GRI_OrderType=227002
and COLI_sourcetype=$sourcetype
) as cgi_group
) as sum_opi
group by sum_opi.COLI_OPI_ID
order by case sum_opi.COLI_OPI_ID when '435' then 0 else 1 end ";
$query = $this->HT->query($sql);
$opi_sum_money = $query->result_array();
return $opi_sum_money;
}
// Trippest自营订单,含地接代收的
public function trippest_order_with_vendormoney($vendor, $sourcetype, $start_date, $end_date)
{
$sql = "SELECT COLI_SN,coli_id,COLI_GroupCode,
convert(date,cgi.CGI_ArriveDate) CGI_ArriveDate,
COLI.COLI_sourcetype, COLI.COLI_Price, coli.COLI_Currency,
(SELECT isnull(SUM(GAI_SSJE),0)
FROM BIZ_GroupAccountInfo
WHERE DeleteFlag=0
AND GAI_COLI_SN=COLI_SN
AND GAI_Type IN (" . PAY_OTHER . ")) AS vendor_sum ,
coli.COLI_OPI_ID
FROM CK_GroupInfo cgi
INNER JOIN GRoupInfo gri ON CGI_GRI_SN=GRI_SN
INNER JOIN BIZ_ConfirmLineInfo coli ON COLI_GRI_SN=GRI_SN
WHERE 1=1
AND CGI_ArriveDate BETWEEN '$start_date' AND '$end_date'
AND EXISTS
(SELECT 1
FROM OperatorInfo
WHERE OPI_DEI_SN=30
AND OPI_SN=CGI_OPI_SN)
AND CGI_Checked=1
AND GRI_OrderType=227002
AND COLI_sourcetype=$sourcetype
AND COLI_OPI_ID <> 435
AND exists (
select 1 from BIZ_ConfirmLineDetail where COLD_COLI_SN=COLI_SN and COLD_PlanVEI_SN=$vendor
)
AND exists(
SELECT 1
FROM BIZ_GroupAccountInfo
WHERE DeleteFlag=0
AND GAI_COLI_SN=COLI_SN
AND GAI_SSJE>0
AND GAI_Type IN (" . PAY_OTHER . ")
)
ORDER BY vendor_sum ";
$query = $this->HT->query($sql);
return $query->result_array();
}
public function vendor_cost($vendor_str, $start_date, $end_date)
{
$sql = "SELECT group_cost.GCI_VEI_SN vendor_code,
SUM(group_cost.cost) vendor_cost
FROM
(SELECT DISTINCT gci.GCI_combineNo,
(SELECT SUM(CONVERT(float, gcod.GCOD_sumMoney))
FROM GroupCombineOperationDetail gcod
WHERE gcod.GCOD_GCI_combineNo=GCI_combineNo
AND gcod.GCOD_operationType <> 'otherReceives' ) AS cost ,
GCI_VEI_SN
FROM GroupCombineInfo gci
WHERE 1=1
AND GCI_VEI_SN IN ($vendor_str)
AND EXISTS
( SELECT 1
FROM CK_GroupInfo
WHERE CGI_Checked=1
AND CGI_GRI_SN=GCI_GRI_SN
AND CGI_ArriveDate BETWEEN '$start_date' AND '$end_date')
) AS group_cost
GROUP BY group_cost.GCI_VEI_SN";
$query = $this->HT->query($sql);
return $query->result_array();
}
}
/* End of file vendor_money.php */
/* Location: ./third_party/trippestOrderSync/models/vendor_money.php */

File diff suppressed because one or more lines are too long

@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

@ -0,0 +1,61 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<title>operation</title>
<style type=text/css>* { margin:0; font-family: Verdana, Arial, Helvetica, sans-serif; }body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:13px; color:#545454; right: auto; background-color: #FFFBF0;}img, ul, ul li { padding:0; margin:0; border:0; }#warp { border-top:8px solid #a31022!important; }#logo { border: none!important}#logo, #surveyContent { width:160mm; margin:5px auto; padding:5px; }h1 { margin:15px 0 10px 0; font-size:24px; border-bottom:1px solid #d9d9d9; color:#545454; }h2 { margin:15px 0 10px 0; font-size:20px; color:#545454; } h3{background-color: #ccc; font-size: 14px; font-weight: bold;margin:5px 0;padding: 10px 0;} .tableSurvey table td { padding:5px; }.tableSurvey table td strong { margin-top:8px; }.tableSurvey1 { border:1px solid #e1e1e1; }.tableSurvey1 th { border:1px solid #fff; height:30px; padding-right:10px; text-align:right; background:#f1f1f1; }.tableSurvey1 td { border:1px solid #f9f9f9; padding:5px; text-align:center; width:80px; }.tableSurvey2 { border:1px solid #e1e1e1; }.tableSurvey2 th { border:1px solid #fff; padding:5px 10px; text-align:right; background:#f1f1f1; font-weight:normal; }.tableSurvey2 td { border:1px solid #f9f9f9; padding:5px; text-align:center; width:80px; }.blue{ color:#0070C0}
</style>
</head>
<body>
<?php
$operation_type = array(
"guiderOperations" => "导服",
"otherCosts" => "其他",
"touristCarOperations" => "用车",
"sceneryOperations" => "门票",
"restraurantOperations" => "用餐"
);
?>
<div id=warp>
<div id=surveyContent>
<?php foreach ($combineNo_arr as $kcn => $vcn) { ?>
<h3 height=33 colspan=2 class=captd align=center>
<?php echo intval($vcn->GCI_groupType)===1 ? "PVT" : "拼团号" ?>&nbsp;&nbsp;
<?php echo $vcn->GCI_combineNo; ?>
</h3>
<table border=1 cellspacing=0 cellpadding=3 width=100%>
<tr>
<td colspan=2 bgcolor=#ECECEC>
<b>总成本: ¥&nbsp;<?php echo $vcn->cost->cost_sum; ?></b>
</td>
</tr>
<tr>
<td colspan=2 bgcolor=#ECECEC>
<b>成本明细: </b>
</td>
</tr>
<?php foreach ($vcn->cost->cost_detail as $kc => $vc) { ?>
<tr>
<td width=60% >
<p>
<?php echo $operation_type[$vc->GCOD_operationType]; ?>
<?php //echo $vc->GCOD_subType;
if ($vc->GCOD_subType) {
echo " - " . $vc->GCOD_subType;
}
?>
</p>
</td>
<td width=40% align="right">
<div>
<?php echo ($vc->cost); ?>
</div>
</td>
</tr>
<?php } ?>
</table>
<?php } ?>
</div>
</div>
</body>
</html>

@ -0,0 +1,27 @@
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>发送时间</th>
<th>接收号码</th>
<th>失败原因</th>
</tr>
</thead>
<tbody>
<?php
foreach ($list as $key => $value) {
$tmp_msg = null;
if ($value->TPSL_callbackJson == null) {
$tmp_msg = "无导游安排";
} else {
$tmp_msg = json_decode($value->TPSL_callbackJson);
$tmp_msg = $tmp_msg->errmsg;
}
?>
<tr>
<td> <?php echo $value->TPSL_logTime; ?> </td>
<td> <?php echo "+$value->TPSL_nationCode $value->TPSL_mobile"; ?> </td>
<td> <?php echo $tmp_msg; ?> </td>
</tr>
<?php } ?>
</tbody>
</table>

File diff suppressed because one or more lines are too long

@ -0,0 +1,236 @@
<?php
/**
* 账单结算
*/
?>
<!DOCTYPE html>
<html>
<head>
<title>Trippest &amp; 地接账单结算</title>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1.0, user-scalable=no" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta name="referrer" content="always">
<link href="http://www.mycht.cn/css/webht/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="http://www.mycht.cn/css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<!-- <?php // include 'flatpickr.css.php'; ?> -->
<style type="text/css">
form{border-bottom: 1px solid #ccc;}
.navbar-header h1{display: inline-block;margin-left: 30px;margin-right: 30px;}
label {display: inline-block;max-width: none;margin-bottom: 5px;font-weight: bold; }
.form-check-label{font-weight: normal; margin-left: 5px;}
thead th {text-align: center;}
tbody td {text-align: right;}
.bg-grey {background-color: #f5f5f5;}
.text-left {text-align: left;}
.text-right {text-align: right;}
.text-bold {font-weight: bold;}
</style>
</head>
<body>
<div id="wrapper" class="chkVisible print-none">
<div class="navbar-header" style="float:none;border-bottom: 1px solid #ccc;">
<a class="navbar-brand text-muted" style="height: 52px;padding-top: 7px;padding-left: 30px;" href="http://www.mycht.cn/webht.php/index/index">
<img width="150" style="height:40px;" src="/css/nav/img/6000.png">
</a>
<h1>Trippest &amp; 地接账单结算</h1>
<ul class="nav navbar-nav navbar-right pull-right" style="margin:7.5px 0;">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><?php $userdata=$this->session->userdata('admin_chtcdn'); echo $userdata['OPI_Name']; ?> <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="<?php echo site_url('login/logout'); ?>">退出</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="container-fluid">
<p></p>
<form action="/webht.php/apps/trippestordersync/vendor_money/index" method="POST" role="form">
<div class="form-group row">
<label for="" class="col-md-2">地接社</label>
<div class="">
<label class="form-check-label"><input type="checkbox" class="" name="vendors[]" id="" value="1343" <?php if(in_array(1343, $default_vendor)) { ?>checked<?php } ?> >北京图兰朵</label>
<label class="form-check-label"><input type="checkbox" class="" name="vendors[]" id="" value="29188" <?php if(in_array(29188, $default_vendor)) { ?>checked<?php } ?>>上海图兰朵</label>
<label class="form-check-label"><input type="checkbox" class="" name="vendors[]" id="" value="30548" <?php if(in_array(30548, $default_vendor)) { ?>checked<?php } ?>>西安图兰朵</label>
<!-- <label class="form-check-label"><input type="checkbox" class="" name="vendors[]" id="" value="628">桂林地接</label> -->
</div>
</div>
<div class="form-group row">
<label for="" class="col-md-2">发团日期</label>
<div class="col-md-6">
<input type="text" class="form-control" name="date_range" id="date_range" placeholder="选择日期范围" required>
</div>
<div class="col-md-3">
<!-- <input type="text" class="form-control" id="end_date" placeholder="结束日期"> -->
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</form>
<p></p>
<table class="table table-bordered table-hover">
<thead>
<tr>
<th rowspan="2">目的地</th>
<th colspan="2">总营收</th>
<th colspan="2">总成本</th>
<th rowspan="2">⑤利润</th>
<th rowspan="2">⑥海纳利润</th>
<th rowspan="2">⑦地接利润</th>
<th rowspan="2">⑧海纳应付地接</th>
</tr>
<tr>
<th >①海纳代收</th>
<th >②地接代收</th>
<th rowspan="2">③海纳成本</th>
<th rowspan="2">④地接成本</th>
</tr>
</thead>
<tbody>
<?php if ( ! empty($money)) {
foreach ($money as $kt => $trippest) {
?>
<tr>
<td class="text-left"><?php echo $trippest['vendor_name'] ?></td>
<td><?php echo $trippest['trippest']['trippest_sum'] ?></td>
<td><?php echo $trippest['trippest']['vendor_sum'] ?></td>
<td><?php echo $trippest['trippest_cost'] ?></td>
<td><?php echo $trippest['vendor_cost'] ?></td>
<td><?php echo $trippest['trippest']['total_profit'] ?></td>
<td><?php echo $trippest['trippest']['trippest_profit'] ?></td>
<td><?php echo $trippest['trippest']['vendor_profit'] ?></td>
<td><?php echo $trippest['trippest']['payout'] ?></td>
</tr>
<?php
if ($trippest['trippest']['other_sum'] > 0) {
?>
<tr class="bg-grey">
<td >非包价产品的收款 <br></td>
<td ><?php echo $trippest['trippest']['other_sum'] ?></td>
<td ></td>
<td ></td>
<td ><?php echo $trippest['trippest']['other_sum_cost'] ?></td>
<td ></td>
<td colspan="4"></td>
</tr>
<?php
}
?>
<?php
}
} ?>
<?php if ( ! empty($col_sum)) {
?>
<tr class="text-bold">
<td class="text-left">合计(仅包价产品)</td>
<td><?php echo $col_sum['trippest']['sum_trippest_sum'] ?></td>
<td><?php echo $col_sum['trippest']['sum_vendor_sum'] ?></td>
<td><?php echo $col_sum['trippest']['sum_trippest_cost'] ?></td>
<td><?php echo $col_sum['trippest']['sum_vendor_cost'] ?></td>
<td><?php echo $col_sum['trippest']['sum_profit'] ?></td>
<td><?php echo $col_sum['trippest']['sum_trippest_profit'] ?></td>
<td><?php echo $col_sum['trippest']['sum_vendor_profit'] ?></td>
<td><?php echo $col_sum['trippest']['sum_payout'] ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<p>旧的算法, 需扣除Trippest自营订单的地接代收款项:</p>
<table class="table table-bordered table-hover">
<thead>
<tr>
<th rowspan="2">目的地</th>
<th colspan="2">总营收</th>
<th colspan="2">总成本</th>
<th rowspan="2">⑤利润</th>
<th rowspan="2">⑥海纳利润</th>
<th rowspan="2">⑦地接利润</th>
<th rowspan="2">⑧海纳应付地接</th>
</tr>
<tr>
<th >①海纳代收</th>
<th >②地接代收</th>
<th rowspan="2">③海纳成本</th>
<th rowspan="2">④地接成本</th>
</tr>
</thead>
<tbody>
<?php if ( ! empty($money)) {
foreach ($money as $kv => $vendor) {
?>
<tr>
<td class="text-left"><?php echo $vendor['vendor_name'] ?></td>
<td><?php echo $vendor['vendor']['trippest_sum'] ?></td>
<td><?php echo $vendor['vendor']['vendor_sum'] ?></td>
<td><?php echo $vendor['trippest_cost'] ?></td>
<td><?php echo $vendor['vendor_cost'] ?></td>
<td><?php echo $vendor['vendor']['total_profit'] ?></td>
<td><?php echo $vendor['vendor']['trippest_profit'] ?></td>
<td><?php echo $vendor['vendor']['vendor_profit'] ?></td>
<td><?php echo $vendor['vendor']['payout'] ?></td>
</tr>
<?php
if ($vendor['vendor']['other_sum'] > 0) {
?>
<tr class="bg-grey">
<td >非包价产品的收款 <br></td>
<td ><?php echo $vendor['vendor']['other_sum'] ?></td>
<td ></td>
<td ></td>
<td ><?php echo $vendor['vendor']['other_sum_cost'] ?></td>
<td ></td>
<td colspan="4"></td>
</tr>
<?php
}
?>
<?php }
} ?>
<?php if ( ! empty($col_sum)) {
?>
<tr class="text-bold">
<td class="text-left">合计(仅包价产品)</td>
<td><?php echo $col_sum['vendor']['sum_trippest_sum'] ?></td>
<td><?php echo $col_sum['vendor']['sum_vendor_sum'] ?></td>
<td><?php echo $col_sum['vendor']['sum_trippest_cost'] ?></td>
<td><?php echo $col_sum['vendor']['sum_vendor_cost'] ?></td>
<td><?php echo $col_sum['vendor']['sum_profit'] ?></td>
<td><?php echo $col_sum['vendor']['sum_trippest_profit'] ?></td>
<td><?php echo $col_sum['vendor']['sum_vendor_profit'] ?></td>
<td><?php echo $col_sum['vendor']['sum_payout'] ?></td>
</tr>
<?php } ?>
<?php if ( ! empty($trippest_order_vendor_money)) {
?>
<tr class="text-bold">
<th colspan="2">团号</th>
<th colspan="7">应扣除地接收款: 总计 <?php echo $transfer_sum ?></th>
</tr>
<?php foreach ($trippest_order_vendor_money as $ko => $order) {
?>
<tr>
<td colspan="2" class="text-left"><?php echo $order['COLI_GroupCode'] ?></td>
<td colspan="7" class="text-left"><?php echo $order["vendor_sum"] ?></td>
</tr>
<?php } } ?>
</tbody>
</table>
</div>
</body>
<script src="/js/jquery.min.js" type="text/javascript"></script>
<script src="/js/bootstrap.min.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#date_range").flatpickr({
dateFormat: 'Y-m-d'
,mode: 'range'
,allowInput: true
,defaultDate:['<?php echo $default_date1 ?>', '<?php echo $default_date2 ?>']
});
})
</script>
</html>

@ -0,0 +1,88 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Welcome to CodeIgniter</title>
<style type="text/css">
::selection{ background-color: #E13300; color: white; }
::moz-selection{ background-color: #E13300; color: white; }
::webkit-selection{ background-color: #E13300; color: white; }
body {
background-color: #fff;
margin: 40px;
font: 13px/20px normal Helvetica, Arial, sans-serif;
color: #4F5155;
}
a {
color: #003399;
background-color: transparent;
font-weight: normal;
}
h1 {
color: #444;
background-color: transparent;
border-bottom: 1px solid #D0D0D0;
font-size: 19px;
font-weight: normal;
margin: 0 0 14px 0;
padding: 14px 15px 10px 15px;
}
code {
font-family: Consolas, Monaco, Courier New, Courier, monospace;
font-size: 12px;
background-color: #f9f9f9;
border: 1px solid #D0D0D0;
color: #002166;
display: block;
margin: 14px 0 14px 0;
padding: 12px 10px 12px 10px;
}
#body{
margin: 0 15px 0 15px;
}
p.footer{
text-align: right;
font-size: 11px;
border-top: 1px solid #D0D0D0;
line-height: 32px;
padding: 0 10px 0 10px;
margin: 20px 0 0 0;
}
#container{
margin: 10px;
border: 1px solid #D0D0D0;
-webkit-box-shadow: 0 0 8px #D0D0D0;
}
</style>
</head>
<body>
<div id="container">
<h1>Welcome to CodeIgniter!</h1>
<div id="body">
<p>The page you are looking at is being generated dynamically by CodeIgniter.</p>
<p>If you would like to edit this page you'll find it located at:</p>
<code>application/views/welcome_message.php</code>
<p>The corresponding controller for this page is found at:</p>
<code>application/controllers/welcome.php</code>
<p>If you are exploring CodeIgniter for the very first time, you should start by reading the <a href="user_guide/">User Guide</a>.</p>
</div>
<p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds</p>
</div>
</body>
</html>
Loading…
Cancel
Save