hotfix/远程访问多媒体中心
赵鹏 6 years ago
commit b69668a905

@ -0,0 +1,85 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class login extends CI_Controller{
public function __construct(){
parent::__construct();
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');
$this->load->helper('dinglogin');
$this->load->helper('cookie');
$this->appid = 'dingoalutppbmywhkyorfp';
$this->appsecret = '6vAG1GwqwUE0b3g-8g0ZooKXt0SVVwcypIYbDLVy_MyS0jDV89rE68hXOV6WL0HO';
$this->AppKey = 'dingjcbxgidah9uspeuc';
$this->AppSecret = 'C4-8rUDK1u5Twpsw7U3yo42s_bbYxFIqzLMp2j7uI80Sa8D-OPbtSoCMgZxHxo2d';
$this->load->model('ding_login_model');
}
//展示第三方登录页HTTP_REFERER
public function index(){
delete_cookie('returnurl');
if(isset($_REQUEST['returnurl'])){
$returnurl = $_REQUEST['returnurl'];
}else{
$returnurl = 'http://www.mycht.cn';
}
$this->input->set_cookie('returnurl',$returnurl,60);
$this->load->view('login-indx');
}
//判断是否存在该用户
public function auth_login(){
$code = $_REQUEST['code'];
$microtime = get_microtime();
$signature = get_loginsign($microtime,$this->appsecret);
$url = 'https://oapi.dingtalk.com/sns/getuserinfo_bycode?accessKey='.urlencode($this->appid).'&timestamp='.urlencode($microtime).'&signature='.urlencode($signature);
$data = array();
$data['tmp_auth_code'] = $code;
$userinfo = GetPost_http($url,json_encode($data),'json');
$userinfo_data = json_decode($userinfo);
//如果不存在unionid,则不往下执行
if(!isset($userinfo_data->user_info->unionid)){
header("HTTP/1.1 404 Not Found");
exit('{"errcode":404,"errmsg":"不存在unionid"}');
}
$unionid = $userinfo_data->user_info->unionid;
//获取access_token
$access_url = 'https://oapi.dingtalk.com/gettoken?appkey='.$this->AppKey.'&appsecret='.$this->AppSecret;
$access_token = GetPost_http($access_url,'','');
$access_token = json_decode($access_token)->access_token;
//通过unionid获取userid(在公司内部进行查找,如果人员不存在则不会返回userid)
$userid_url = 'https://oapi.dingtalk.com/user/getUseridByUnionid?access_token='.$access_token.'&unionid='.$unionid;
$userid_json = GetPost_http($userid_url,'','');
if(!isset(json_decode($userid_json)->userid)){
header("HTTP/1.1 404 Not Found");
exit($userid_json);
}
$userid = json_decode($userid_json)->userid;
$user_url = 'https://oapi.dingtalk.com/user/get?access_token='.$access_token.'&userid='.$userid;
$user_info = GetPost_http($user_url,'','');
$user_data = json_decode($user_info);
$userinfo = array();
$userinfo['name'] = $user_data->name;
$userinfo['position'] = $user_data->position;
$userinfo['unionid'] = $user_data->unionid;
$userinfo['avatar'] = $user_data->avatar;
$userinfo['orgEmail'] = $user_data->orgEmail;
$userinfo['mobile'] = $user_data->mobile;
$userinfo['datetime'] = time();
$this->ding_login_model->addorupdateuser($userinfo);
$this->input->set_cookie('dingname',$user_data->name,2592000);
$this->input->set_cookie('dingunionid',$user_data->unionid,2592000);
redirect(get_cookie('returnurl'));
}
}

@ -0,0 +1,49 @@
<?php
//获取毫秒
function get_microtime (){
list($s1, $s2) = explode(' ', microtime());
return (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000);
}
//获取钉钉登录sign
function get_loginsign($microtime,$appsecret){
$microtime = $microtime;
$sign = hash_hmac('sha256',$microtime,$appsecret,true);
$signature = base64_encode($sign);
return $signature;
}
//发送请求函数
function GetPost_http($url, $data = '',$format='') {
if(!isset($_SERVER['HTTP_USER_AGENT'])){
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.104 Safari/537.36 Core/1.53.2372.400 QQBrowser/9.5.10548.400';
}
$curl = curl_init(); // 启动一个CURL会话
curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转
curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer
if (!empty($data)) {
curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
if($format == 'json'){
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json; charset=utf-8"));
}
}
curl_setopt($curl, CURLOPT_TIMEOUT, 40); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_TIMEOUT_MS, 40000); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
$tmpInfo = curl_exec($curl); // 执行操作
$errno = curl_errno($curl);
if ($errno !== 0) {
log_message('error', 'dingding'.$errno.curl_error($curl));
}
curl_close($curl); //关闭CURL会话
return $tmpInfo; //返回数据
}
?>

@ -0,0 +1,34 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class ding_login_model extends CI_Model {
function __construct(){
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
}
public function addorupdateuser($data){
$sql = "
IF NOT EXISTS(
select * from Dingding_User where ddu_Unionid = ?
)
INSERT INTO Dingding_User (ddu_Name,ddu_Unionid,ddu_Mobile,ddu_Email,ddu_Position,ddu_Avatar,ddu_Datetime) VALUES (N?,?,?,?,N?,?,?)
ELSE
UPDATE Dingding_User SET
ddu_Name = N?,
ddu_Mobile = ?,
ddu_Email = ?,
ddu_Position = N?,
ddu_Avatar = ?,
ddu_Datetime = ?
WHERE ddu_Unionid = ?
";
$query = $this->HT->query($sql,array($data['unionid'],$data['name'],$data['unionid'],$data['mobile'],$data['orgEmail'],$data['position'],$data['avatar'],$data['datetime'],$data['name'],$data['mobile'],$data['orgEmail'],$data['position'],$data['avatar'],$data['datetime'],$data['unionid']));
}
}
?>

@ -0,0 +1,124 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>value系统登录</title>
<link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="/js/poshytip/tip-yellow/tip-yellow.css" type="text/css" />
<link rel="stylesheet" href="/js/modaldialog/css/jquery.modaldialog.css" type="text/css" />
<link rel="stylesheet" href="/js/kindeditor/themes/default/default.css" type="text/css" media="screen" />
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/js/poshytip/jquery.poshytip.min.js"></script>
<script type="text/javascript" src="/js/jquery.form.min.js"></script>
<script type="text/javascript" src="/js/modaldialog/jquery.modaldialog.js"></script>
<script type="text/javascript" src="/js/kindeditor/kindeditor-min.js"></script>
<script type="text/javascript" src="/js/basic.js"></script>
<script src="https://g.alicdn.com/dingding/dinglogin/0.0.2/ddLogin.js"></script>
<link rel="shortcut icon" href="http://data.chtcdn.com/bootstrap/img/glyphicons_290_skull.png">
</head>
<style>
.ding_login{
width:365px;
height:400px;
margin:0 auto;
}
.login_header{
width: 100%;
height: 64px;
font-size: 18px;
color: #898d90;
overflow: hidden;
border-bottom: 1px solid #e8e8e8;
}
.login_type{
width: 50%;
line-height: 60px;
text-align: center;
border-bottom: 4px solid transparent;
float: left;
cursor: pointer;
}
.login_type_active{
color: #38adff;
border-bottom: 4px solid #38adff;
cursor: default;
}
.hide{
display: none;
}
</style>
<body>
<div class="row-fluid">
<div class="span3"></div>
<div class="span6">
<form action="<?php echo site_url('login/check') ?>" class="form-horizontal" name="form_login" id="form_login" method="post">
<legend>
<p>Welcome</p>
<div class="login_header">
<div class="login_type login_type_active">钉钉扫码登录</div>
<div class="login_type"><a href="https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoalutppbmywhkyorfp&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=http://www.mycht.cn/info.php/apps/dinglogin/login/auth_login">钉钉账号密码登录</a></div>
</div>
</legend>
<div class="ding_login">
<div id="login_container"></div>
</div>
</form>
<div class="alert alert-error">
<h4>IE6 isn't allowed!</h4>
Please use Google Chrome, Firefox, Safair, or IE7+.
</div>
</div>
<div class="span3"></div>
</div>
</body>
<script>
$(function(){
var url = encodeURIComponent("https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoalutppbmywhkyorfp&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=http://www.mycht.cn/info.php/apps/dinglogin/login/auth_login");
var obj = DDLogin({
id:"login_container",//这里需要你在自己的页面定义一个HTML标签并设置id例如<div id="login_container"></div><span id="login_container"></span>
goto: url,
style: "",
href: "",
width : "300px",
height: "300px"
});
var hanndleMessage = function (event) {
var loginTmpCode = event.data; //拿到loginTmpCode后就可以在这里构造跳转链接进行跳转了
var origin = event.origin;
login_url = 'https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoalutppbmywhkyorfp&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=http://www.mycht.cn/info.php/apps/dinglogin/login/auth_login&loginTmpCode='+loginTmpCode;
window.location.href = login_url;
};
if (typeof window.addEventListener != 'undefined') {
window.addEventListener('message', hanndleMessage, false);
} else if (typeof window.attachEvent != 'undefined') {
window.attachEvent('onmessage', hanndleMessage);
}
$('.login_type').click(function(){
console.log($(this).html());
if($(this).html() == '钉钉帐号密码登录'){
$('.pc_login').removeClass('hide');
$('#login_container').addClass('hide');
$('.ding_login').addClass('hide');
$(this).addClass('login_type_active');
$(this).prev().removeClass('login_type_active');
}
if($(this).html() == '钉钉扫码登录'){
$('.ding_login').removeClass('hide');
$('#login_container').removeClass('hide');
$('.pc_login').addClass('hide');
$(this).addClass('login_type_active');
$(this).next().removeClass('login_type_active');
}
});
});
</script>
</html>

@ -248,30 +248,6 @@ class api extends CI_Controller{
}
}
//登录验证
public function check_login(){
$code = $this->input->get('code');
$signature = getDingSignature();
$urlencode_signature = urlencode($signature);
$personInfoUrl = 'https://oapi.dingtalk.com/sns/getuserinfo_bycode?signature='.$urlencode_signature.'&timestamp='.time().'&accessKey=dingoaystremzlahfew1tb';
$post_data = '{"tmp_auth_code":"'.$code.'"}';
$returnJson = GetPost_http($personInfoUrl,$post_data,'json');
$returnData = json_decode($returnJson);
if(!empty($returnData->user_info)){
//创建session
$this->session->set_userdata('dingname', $returnData->user_info->nick);
$this->session->set_userdata('dingunionid', $returnData->user_info->unionid);
redirect('http://www.mycht.cn/info.php/apps/trainsystem/pages/');
}else{
redirect('http://www.mycht.cn/info.php/apps/trainsystem/pages/login');
}
}
public function check_session(){
print_r($this->session->userdata('dingunionid'));
}
//订单同步到trainsystem
public function sync_orders(){
die();

@ -9,13 +9,15 @@ class pages extends CI_Controller{
$this->load->model("train_system_model");
$this->load->model("BIZ_train_model");
$this->load->helper('train');
$this->load->helper('cookie');
$this->order_status_msg = $this->config->item('train_order_status_msg');
}
public function index($coli_id = null){
/*if($this->session->userdata('dingname') == '' && $this->session->userdata('dingunionid') == ''){
dingLogin();
}*/
if(get_cookie('dingname') == '' && get_cookie('dingunionid') == ''){
redirect('/apps/dinglogin/login/?returnurl=/apps/trainsystem/pages/');
}
if($coli_id == null){
$cols_id = $this->input->post("ht_order");
}else{
@ -54,9 +56,9 @@ class pages extends CI_Controller{
//系统列表页面
public function order_list(){
/*if($this->session->userdata('dingname') == '' && $this->session->userdata('dingunionid') == ''){
dingLogin();
}*/
if(get_cookie('dingname') == '' && get_cookie('dingunionid') == ''){
redirect('/apps/dinglogin/login/?returnurl=/apps/trainsystem/pages/');
}
$page_size = 10;
$page = $this->input->get("page");
$order = $this->input->get("order");
@ -110,9 +112,9 @@ class pages extends CI_Controller{
//订单详情页面
public function order(){
/*if($this->session->userdata('dingname') == '' && $this->session->userdata('dingunionid') == ''){
dingLogin();
}*/
if(get_cookie('dingname') == '' && get_cookie('dingunionid') == ''){
redirect('/apps/dinglogin/login/?returnurl=/apps/trainsystem/pages/');
}
$ordernumber = $order=$this->input->get("order");
if(empty($ordernumber)){
@ -159,9 +161,9 @@ class pages extends CI_Controller{
//退票页面
public function refund(){
/*if($this->session->userdata('dingname') == '' && $this->session->userdata('dingunionid') == ''){
dingLogin();
}*/
if(get_cookie('dingname') == '' && get_cookie('dingunionid') == ''){
redirect('/apps/dinglogin/login/?returnurl=/apps/trainsystem/pages/');
}
$ordernumber = $order=$this->input->get("order");
if(empty($ordernumber)){
@ -198,9 +200,9 @@ class pages extends CI_Controller{
}
public function export(){
/*if($this->session->userdata('dingname') == '' && $this->session->userdata('dingunionid') == ''){
dingLogin();
}*/
if(get_cookie('dingname') == '' && get_cookie('dingunionid') == ''){
redirect('/apps/dinglogin/login/?returnurl=/apps/trainsystem/pages/');
}
$this->load->view('header');
$this->load->view('export');
$this->load->view('footer');

@ -74,16 +74,4 @@ function GetPost_http($url, $data = '',$format='') {
return $tmpInfo; //返回数据
}
function getDingSignature(){
$timestamp = time();
$signature = hash_hmac('sha256',$timestamp,'emCK5vYFJc-HtMNNgbyGpmbYaNyPkNXn_ayoFd6q2m6rpljhxBn2JQEx9gy8H6DQ',true);
$signature = base64_encode($signature);
return $signature;
}
function dingLogin(){
redirect('https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoaystremzlahfew1tb&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=http://www.mycht.cn/info.php/apps/trainsystem/api/check_login');
}
?>

@ -0,0 +1,205 @@
<?php
header("Cache-Control: no-cache");
/*
*---------------------------------------------------------------
* APPLICATION ENVIRONMENT
*---------------------------------------------------------------
*
* You can load different configurations depending on your
* current environment. Setting the environment also influences
* things like logging and error reporting.
*
* This can be set to anything, but default usage is:
*
* development
* testing
* production
*
* NOTE: If you change these, also change the error_reporting() code below
*
*/
define('ENVIRONMENT', 'development');
/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*
* Different environments will require different levels of error reporting.
* By default development will show errors but testing and live will hide them.
*/
if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
case 'development':
error_reporting(E_ALL);
break;
case 'testing':
case 'production':
error_reporting(0);
break;
default:
exit('The application environment is not set correctly.');
}
}
/*
*---------------------------------------------------------------
* SYSTEM FOLDER NAME
*---------------------------------------------------------------
*
* This variable must contain the name of your "system" folder.
* Include the path if the folder is not in the same directory
* as this file.
*
*/
$system_path = '../system';
/*
*---------------------------------------------------------------
* APPLICATION FOLDER NAME
*---------------------------------------------------------------
*
* If you want this front controller to use a different "application"
* folder then the default one you can set its name here. The folder
* can also be renamed or relocated anywhere on your server. If
* you do, use a full server path. For more info please see the user guide:
* http://codeigniter.com/user_guide/general/managing_apps.html
*
* NO TRAILING SLASH!
*
*/
$application_folder = 'webht';
/*
* --------------------------------------------------------------------
* DEFAULT CONTROLLER
* --------------------------------------------------------------------
*
* Normally you will set your default controller in the routes.php file.
* You can, however, force a custom routing by hard-coding a
* specific controller class/function here. For most applications, you
* WILL NOT set your routing here, but it's an option for those
* special instances where you might want to override the standard
* routing in a specific front controller that shares a common CI installation.
*
* IMPORTANT: If you set the routing here, NO OTHER controller will be
* callable. In essence, this preference limits your application to ONE
* specific controller. Leave the function name blank if you need
* to call functions dynamically via the URI.
*
* Un-comment the $routing array below to use this feature
*
*/
// The directory name, relative to the "controllers" folder. Leave blank
// if your controller is not in a sub-folder within the "controllers" folder
// $routing['directory'] = '';
// The controller class file name. Example: Mycontroller.php
// $routing['controller'] = '';
// The controller function you wish to be called.
// $routing['function'] = '';
/*
* -------------------------------------------------------------------
* CUSTOM CONFIG VALUES
* -------------------------------------------------------------------
*
* The $assign_to_config array below will be passed dynamically to the
* config class when initialized. This allows you to set custom config
* items or override any default config values found in the config.php file.
* This can be handy as it permits you to share one application between
* multiple front controller files, with each file containing different
* config values.
*
* Un-comment the $assign_to_config array below to use this feature
*
*/
// $assign_to_config['name_of_config_item'] = 'value of config item';
// --------------------------------------------------------------------
// END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE
// --------------------------------------------------------------------
/*
* ---------------------------------------------------------------
* Resolve the system path for increased reliability
* ---------------------------------------------------------------
*/
// Set the current directory correctly for CLI requests
if (defined('STDIN'))
{
chdir(dirname(__FILE__));
}
if (realpath($system_path) !== FALSE)
{
$system_path = realpath($system_path).'/';
}
// ensure there's a trailing slash
$system_path = rtrim($system_path, '/').'/';
// Is the system path correct?
if ( ! is_dir($system_path))
{
exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
}
/*
* -------------------------------------------------------------------
* Now that we know the path, set the main path constants
* -------------------------------------------------------------------
*/
// The name of THIS file
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
// The PHP file extension
define('EXT', '.php');
// Path to the system folder
define('BASEPATH', str_replace("\\", "/", $system_path));
// Path to the front controller (this file)
define('FCPATH', str_replace(SELF, '', __FILE__));
// Name of the "system folder"
define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
// The path to the "application" folder
if (is_dir($application_folder))
{
define('APPPATH', $application_folder.'/');
}
else
{
if ( ! is_dir(BASEPATH.$application_folder.'/'))
{
exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
}
define('APPPATH', BASEPATH.$application_folder.'/');
}
/*
* --------------------------------------------------------------------
* LOAD THE BOOTSTRAP FILE
* --------------------------------------------------------------------
*
* And away we go...
*
*/
require_once BASEPATH.'core/CodeIgniter'.EXT;
/* End of file index.php */
/* Location: ./index.php */

@ -32,11 +32,9 @@ class Index extends CI_Controller {
public function push($GRI_SN=0, $vendor_str=null)
{
// log_message('error',"\n\n---------------------------------------------------PUSH------------------------------------------------------------\n");
$start_date = date('Y-m-d');
$end_date = date('Y-m-d 23:59:59', strtotime("+2 months"));
$ready_to_send = $this->Group_model->get_plan_not_received(1, $GRI_SN, $vendor_str, $start_date, $end_date);
// log_message('error',var_export($ready_to_send, 1));
if (empty($ready_to_send)) {
return $this->output->set_output("empty");
}
@ -54,6 +52,7 @@ class Index extends CI_Controller {
public function verify_user()
{
return false;
$open_id = $this->input->post('openId');
$open_key = $this->input->post('key');
$match = $this->UserAuth_model->if_user_key($open_id, $open_key, 1);
@ -82,6 +81,10 @@ class Index extends CI_Controller {
{
$input = $this->input->post();
log_message('error',"Call [Tulanduo>uploadOperation]: " . json_encode($input));
$ret['status'] = 1;
$ret['errMsg'] = "";
return $this->output->set_content_type('application/json')->set_output(json_encode($ret));
;
$ret['status'] = -1;
$ret['errMsg'] = "未知错误";
$user_verify = $this->verify_user();
@ -123,6 +126,7 @@ class Index extends CI_Controller {
public function plan_confirm($input, $vps)
{
return false;
$ret['status'] = -1;
$ret['errMsg'] = "";
$vendor_manager = $this->Group_model->get_vendorContact($input['openId']);
@ -160,6 +164,7 @@ class Index extends CI_Controller {
public function fill_tourguide($input, $vps)
{
return false;
$ret['status'] = -1;
$ret['errMsg'] = "";
$eva = $this->Group_model->get_plan_eva($vps->VAS_SN);
@ -198,6 +203,7 @@ class Index extends CI_Controller {
public function calc_key($userId, $key)
{
return false;
$default = "b825e39422a54875a95752fc7ed6f5d2";
$ret = md5(hash("sha256", $userId.$default));
return $ret;

@ -54,6 +54,9 @@ class Tulanduo
public $detail_url = "http://djb3c.ltsoftware.net:9921/action/api/detailRouteOrder/";
public $neworder_url = "http://djb3c.ltsoftware.net:9921/action/api/addOrUpdateRouteOrder/";
private $tulanduo_trippest_pag = array();
private $tulanduo_trippest_code = array();
public function __construct(){
$this->ci =& get_instance();
mb_regex_encoding("UTF-8");
@ -72,6 +75,11 @@ class Tulanduo
public function order_push($order=null)
{
// 初始化所有Trippest合作项目的包价产品
$this->tulanduo_trippest_pag = $this->ci->BIZ_order->get_packageDetails('', implode(',', $this->vendor_ids));
$this->tulanduo_trippest_code = array_map(function($ele){return mb_strtoupper($ele->PAG_Code);}, $this->tulanduo_trippest_pag);
$this->tulanduo_trippest_pag = array_combine($this->tulanduo_trippest_code, $this->tulanduo_trippest_pag);
// 目的地计划
if (strval($order->GRI_OrderType) === "227002" && strval($order->department) === "30") {
return $this->push_trippest($order);
@ -79,12 +87,12 @@ class Tulanduo
// 商务
if (strval($order->GRI_OrderType) === "227002") {
return false; // for Trippest deploy
return $this->push_tour($order);
return $this->push_biz($order, strval($order->GRI_OrderType));
}
// 传统订单
if (strval($order->GRI_OrderType) === "227001") {
return false; // for Trippest deploy
return $this->push_tour($order);
return $this->push_tour($order, strval($order->GRI_OrderType));
}
return "[Tulanduo>order_push] No function match. ";
@ -92,147 +100,283 @@ class Tulanduo
/*!
* 发送线路订单计划
* @date 2018-11-22
*/
public function push_tour($vas=null)
public function push_tour($vas=null, $gri_ordertype='227001')
{
return false; // for Trippest deploy
$userId = $this->send_host["1"]["userId"];
$userKey = $this->send_host["1"]["key"];
$gri_sn = $vas->GRI_SN;
$vas_sn = $vas->VAS_SN;
$vei_sn = $vas->VAS_VEI_SN;
$is_send_vary = $vas->VAS_SendVary;
$change_info = $vas->VAS_ChangeText;
if (trim($change_info) !== "") {
preg_match_all('/(.*)={6}(.*)(\d{4}\-\d{2}\-\d{2})/ismU', characet($change_info,'UTF-8'), $change_arr);
$change_info = $change_arr[0][0];
}
$change_info = str_replace("\n", "<br>", $change_info);
$grd_info = $this->ci->Group_model->get_vendor_plan_info($gri_sn, $vei_sn);
if (empty($grd_info)) {
$this->ci->Group_model->set_plan_received($vas_sn);
return false;
}
$all_day_no = array_map(function($ele){return $ele->GRD_DayNo;}, $grd_info);
$arrange_info = $this->ci->Group_model->get_arrange_info($gri_sn, $vei_sn);
$routeName = "中华游" . $arrange_info[0]->tocity . "线路"; // TODO 线路名称
$routeType = "桂林海纳国旅"; // TODO 线路类型
$agcOrderNo = $vas->GRI_Name . "-" . $arrange_info[0]->citycode;
$agcOrderNo .= "(" . $vas->operator . ")";
$first_date = $grd_info[0]->day_no_raw;
$last_date = count($grd_info)-1;
$end_date = $grd_info[$last_date]->day_no_raw;
$request_info = $this->ci->Group_model->get_plan_request($gri_sn);
$order_type = 1;
$this->ci->tldOrderBuilder->setUserId($userId)
->setKey($userKey)
->setOrderType($order_type)
->setRouteName($routeName)
->setRouteType($routeType)
->setAgcOrderNo($agcOrderNo)
->setAdultNum(intval($arrange_info[0]->ACI_PersonNum))
->setChildNum(intval(bcadd($arrange_info[0]->ACI_ChildNum, $arrange_info[0]->ACI_BabyNum)))
->setDestination($arrange_info[0]->tocity)
->setTravelDate($first_date)
->setLeavedDate($end_date)
// ->setOrderRemark($order_remark) // 订单备注 TODO
->setRoomStandard($request_info->GCI_HotelRequest) // 住房标准
->setRouteStandard($request_info->GCI_Request) // 行程服务标准
;
$guestlist = $this->ci->orders_model->get_customer_list($gri_sn);
foreach ($guestlist as $key => $vg) {
$this->ci->tldOrderBuilder->setCustomersName($key, $vg->MemberName )
->setCustomersPeopleType($key, (calc_age_type($vg->BirthDay)==1 ? "成人" : "儿童"))
->setCustomersDocumentType($key, "护照") // Passport No.
->setCustomersDocumentNo($key, $vg->PassportNo)
->setCustomersOtherInfo($key, $vg->Country);
$request_info = $this->ci->Group_model->get_plan_request($vas->GRI_SN);
/**
* TODO:团队类型? 先写2
* ??是否同一天含多个包价项目
*/
/*!
// 同一天含多个包价产品时, 需要先合并.避免丢失
$all_trippest_package = array_filter(array_map(function ($ele){return $ele->pag_code_arr;}, $grd_info));
$reduce_package_code = array();
foreach ($all_trippest_package as $ktp => $vtp) {
$reduce_package_code = array_merge($reduce_package_code, $vtp);
}
// $travel_fee = 0;
// foreach ($arrange_info as $kaci => $vaci) {
// $travel_fee = bcadd($travel_fee, $vaci->ACI_Amount);
// }
// // TODO 是否需要travelFee
// $this->ci->tldOrderBuilder->setTravelFeesType(0, "Per Group")
// ->setTravelFeesMoney(0, $travel_fee)
// ->setTravelFeesNum(0, 1)
// ->setTravelFeesUnit(0, 1)
// ->setTravelFeesSumMoney(0, $travel_fee)
// ->setTravelFeesRemark(0, "");
// 补全空的日期,行程为空
$date1 = new DateTime($first_date);
$date_end = new DateTime($end_date);
$date_diff = $date_end->diff($date1);
$d = ($date_diff->format("%a"));
$all_date = array();
for ($j=0; $j < ($d+1); $j++) {
$all_date[] = date('Y-m-d', strtotime("+$j day", strtotime($first_date)));
$reduce_package_code = array_filter($reduce_package_code);
*/
$grd_apart_info = $this->tour_apart($grd_info);
$big_order_index = 0;
$expect_order_cnt = count($grd_apart_info['com'])+intval(!empty($grd_apart_info['big_pvt']))+intval(!empty($grd_apart_info['pvt']));
// echo json_encode($grd_info);exit;
foreach ($grd_apart_info as $group_key => $grd_a) {
$big_order_index = $this->tour_apart_order_exec($group_key, $vas, $request_info, $guestlist, $grd_a, $big_order_index);
}
$real_date = array_map(function ($ele){return $ele->day_no_raw;}, $grd_info);
foreach ($all_date as $kd => $vd) {
if ( ! in_array($vd, $real_date)) {
$this->ci->tldOrderBuilder->setScheduleDetailsTitle($kd, "无")
->setScheduleDetailsContent($kd, "无")
->setScheduleDetailsAccommodation($kd, "")
// ->setScheduleDetailsTraffic($kd, ($vso->PAG_Vehicle>60001 ? 1 : 0))
->setScheduleDetailsBreakFirst($kd, 0 )
->setScheduleDetailsDinner($kd, 0)
->setScheduleDetailsLunch($kd, 0)
;
continue;
if ($big_order_index === $expect_order_cnt) {
/** VendorArrangeState VAS_IsReceive */
$this->ci->Group_model->set_plan_received($vas_sn);
}
return "[Tulanduo>push_tour] Done. ";
}
/*!
* @Author: LYT
* @Date: 2019-05-30 16:11:34
* @Desc: 执行发送订单计划信息. 参数已拆分归类好的行程
*/
public function tour_apart_order_exec($group_type, $vas, $request_info, $guestlist, $grd, $total_order_index)
{
if (empty($grd)) {
return $total_order_index;
}
$userId = $this->send_host["1"]["userId"];
$userKey = $this->send_host["1"]["key"];
switch ($group_type) {
case 'big_pvt':
$total_order_index ++;
$all_grd = array($grd);
$routeName = "中华游" . $grd['details'][0]->tocity . "常规线路";
$routeType = $routeName;
$agcOrderNo = $vas->GRI_Name . "-" . $grd['details'][0]->citycode . "-" . $total_order_index;
$agcOrderNo .= "(" . $vas->operator . ")";
$order_type = 1;
break;
case 'pvt':
$total_order_index ++;
$all_grd = array($grd);
$routeName = empty($grd['details'][0]->GRD_Landscape) ? $grd['details'][0]->PAG_Title : $grd['details'][0]->GRD_Landscape;
$routeName .= "(" . $grd['details'][0]->PAG_Code . ")";
$routeType = $grd['details'][0]->tocity . "目的地线路";
$agcOrderNo = $vas->GRI_Name . "-" . $grd['details'][0]->citycode . "-" . $total_order_index;
$agcOrderNo .= "(" . $vas->operator . ")";
$order_type = 1;
break;
case 'com':
default:
$all_grd = ($grd);
$order_type = 2;
break;
}
foreach ($all_grd as $ko => $vo) {
if ($order_type === 2) {
$total_order_index ++;
$routeName = $vo['PAG_Name'];
if (empty($routeName)) {
$routeName = $vo['details'][0]->GRD_Landscape . "(" . $vo['details'][0]->PAG_Code . ")";
}
$routeType = $vo['details'][0]->tocity . "目的地线路";
$agcOrderNo = $vas->GRI_Name . "-" . $vo['details'][0]->citycode . "-" . $total_order_index;
$agcOrderNo .= "(" . $vas->operator . ")";
}
foreach ($grd_info as $kgrd => $vgrd) {
if ($vd==$vgrd->day_no_raw) {
$this->ci->tldOrderBuilder->setScheduleDetailsTitle($kd, $vgrd->GRD_OrderDate)
->setScheduleDetailsContent($kd, $vgrd->GRD_Landscape)
->setScheduleDetailsAccommodation($kd, $vgrd->GRD_Hotel)
->setScheduleDetailsTraffic($kd, ($vgrd->GRD_Traffic))
->setScheduleDetailsBreakFirst($kd, 0 )
->setScheduleDetailsDinner($kd, (trim($vgrd->GRD_Meal_S)==="" ? 0 : 1 ))
->setScheduleDetailsLunch($kd, (trim($vgrd->GRD_Meal_L)==="" ? 0 : 1 ))
;
$first_date = $vo['details'][0]->day_no_raw;
$last_date = COUNT($vo['details'])-1;
$end_date = $vo['details'][$last_date]->day_no_raw;
$this->ci->tldOrderBuilder->resetBizContent();
$this->ci->tldOrderBuilder->setUserId($userId)
->setKey($userKey)
->setOrderType($order_type)
->setRouteName($routeName)
->setRouteType($routeType)
->setAgcOrderNo($agcOrderNo)
->setAdultNum(intval($vo['details'][0]->ACI_PersonNum))
->setChildNum(intval(bcadd($vo['details'][0]->ACI_ChildNum, $vo['details'][0]->ACI_BabyNum)))
->setDestination($vo['details'][0]->tocity)
->setTravelDate($first_date)
->setLeavedDate($end_date)
// ->setOrderRemark($order_remark) // 订单备注 TODO:
// ->setRoomStandard($request_info->GCI_HotelRequest) // 住房标准
->setRouteStandard($request_info->GCI_Request) // 行程服务标准
;
foreach ($guestlist as $key => $vg) {
$this->ci->tldOrderBuilder->setCustomersName($key, $vg->MemberName )
->setCustomersPeopleType($key, (calc_age_type($vg->BirthDay)==1 ? "成人" : "儿童"))
->setCustomersDocumentType($key, "护照") // Passport No.
->setCustomersDocumentNo($key, $vg->PassportNo)
->setCustomersOtherInfo($key, $vg->Country . "; " . $vg->phone);
}
// 补全空的日期,行程为空
$date1 = new DateTime($first_date);
$date_end = new DateTime($end_date);
$date_diff = $date_end->diff($date1);
$d = ($date_diff->format("%a"));
$all_date = array();
for ($j=0; $j < ($d+1); $j++) {
$all_date[] = date('Y-m-d', strtotime("+$j day", strtotime($first_date)));
}
$real_date = array_map(function ($ele){return $ele->day_no_raw;}, $vo['details']);
foreach ($all_date as $kd => $vd) {
if ( ! in_array($vd, $real_date)) {
$this->ci->tldOrderBuilder->setScheduleDetailsTitle($kd, "无")
->setScheduleDetailsContent($kd, "无")
->setScheduleDetailsAccommodation($kd, "")
// ->setScheduleDetailsTraffic($kd, ($vso->PAG_Vehicle>60001 ? 1 : 0))
->setScheduleDetailsBreakFirst($kd, 0 )
->setScheduleDetailsDinner($kd, 0)
->setScheduleDetailsLunch($kd, 0)
;
continue;
}
foreach ($vo['details'] as $kgrd => $vgrd) {
if ($vd==$vgrd->day_no_raw) {
$this->ci->tldOrderBuilder->setScheduleDetailsTitle($kd, $vgrd->GRD_OrderDate)
->setScheduleDetailsContent($kd,
$vgrd->GRD_LeaveCity . "-" . $vgrd->GRD_ServiceCity . "\r\n" .
$vgrd->GRD_Landscape . "\r\n" . $vgrd->GRD_Traffic)
->setScheduleDetailsAccommodation($kd, $vgrd->GRD_Hotel)
->setScheduleDetailsTraffic($kd, ($vgrd->GRD_Traffic))
->setScheduleDetailsBreakFirst($kd, 0 )
->setScheduleDetailsDinner($kd, (trim($vgrd->GRD_Meal_S)==="" ? 0 : 1 ))
->setScheduleDetailsLunch($kd, (trim($vgrd->GRD_Meal_L)==="" ? 0 : 1 ))
;
}
}
}
}
// 查询是否变更 TODO deprecated
$sync_orderstate = 10;
$vps_sn = 0;
$vendor_orderid = 0;
$this->ci->tldOrderBuilder->clearModifyLogInfo();
// $resp = $this->excute_curl($this->neworder_url, $this->ci->tldOrderBuilder);
$resp = '{"status":1,"errMsg":"","responseData":{"orderId":' . rand(1000,9999) . '}}'; // test
// 查询是否变更 TODO: deprecated at 2019-05
$sync_orderstate = 10;
$this->ci->tldOrderBuilder->clearModifyLogInfo();
$resp = $this->excute_curl($this->neworder_url, $this->ci->tldOrderBuilder);
// $resp = '{"status":1,"errMsg":"","responseData":{"orderId":' . rand(1000,9999) . '}}'; // test:
echo $this->ci->tldOrderBuilder->getBizContent();
log_message('error',$resp);
$response = json_decode($resp);
if ($response->status == 1) {
/** VendorPlanSync */
$sync_ret = array(
"VPS_VAS_SN" => $vas_sn
,"VPS_GRI_SN" => $gri_sn
,"VPS_VEI_SN" => $vei_sn
,"VPS_startDate" => $first_date
,"VPS_endDate" => $end_date
,"VPS_sendHost" => $userId
,"VPS_externalId" => $response->responseData->orderId
,"VPS_externalorderType" => $order_type
,"VPS_externalorderState" => $sync_orderstate
,"VPS_sendTime" => date('Y-m-d H:i:s')
);
if ($vps_sn === 0) {
$response = json_decode($resp);
if ($response->status == 1) {
/** VendorPlanSync */
$sync_ret = array(
"VPS_VAS_SN" => $vas->VAS_SN
,"VPS_GRI_SN" => $vas->GRI_SN
,"VPS_VEI_SN" => $vas->VAS_VEI_SN
,"VPS_startDate" => $first_date
,"VPS_endDate" => $end_date
,"VPS_sendHost" => $userId
,"VPS_externalId" => $response->responseData->orderId
,"VPS_externalorderType" => $order_type
,"VPS_externalorderState" => $sync_orderstate
,"VPS_sendTime" => date('Y-m-d H:i:s')
);
$sync_id = $this->ci->Group_model->insert_VendorPlanSync($sync_ret);
}
}
return $total_order_index;
}
/*!
* @Author: LYT
* @Date: 2019-05-29 14:54:17
* @Desc: 线路订单计划拆分.
* 合并同样的行程
* 根据行程类型拆分
* @return $ret = array(
* 'big_pvt'=>array(), // 不是合作项目的产品
* 'pvt'=>array(), // 合作项目中的pvt
* 'com'=>array( // 合作项目中的拼团
* 'details' => [],'PAG_Code'=> 'XXX'
* )
* )
*/
public function tour_apart($all_pag_info)
{
$apart = array(); $ret = array();
foreach ($all_pag_info as $key => $pag) {
// CH下的产品编号修正
if (intval($pag->PAG_DEI_SN)===1 && ! empty($pag->PAG_Code)) {
$pag->PAG_Code = $this->ci->trippest->ch_code_transfer( mb_strtoupper($pag->PAG_Code));
$pag->PAG_ExtendType = $this->tulanduo_trippest_pag[$pag->PAG_Code]->PAG_ExtendType;
}
if (empty($pag->PAG_Code)) // 已在grd查询中增加是否目的地产品的判断
{
$apart['big_pvt']['details'][] = $pag;
continue;
}
if (empty($pag->PAG_Title) ) {
$pag->PAG_Title = $this->tulanduo_trippest_pag[$pag->PAG_Code]->PAG_Title;
}
// 合作的产品
if ($this->ci->trippest->if_tour_pvt(array($pag))===1) {
$apart["pvt"]['details'][] = $pag;
} else {
$update = $this->ci->Group_model->update_VendorPlanSync($vps_sn, $sync_ret);
$apart["com"]['details'][$pag->PAG_Code][] = $pag;
}
/** VendorArrangeState VAS_IsReceive */
}
$apart_com = array();
if ( ! empty($apart['com'])) {
$all_com_pag = array_keys($apart['com']['details']);
$full_pag = array();
$process_pag = array();
foreach ($all_com_pag as $kp => $vp) {
$apart_com[$vp]['details'] = array();
$this_include_pags = $this->ci->trippest->tour_code($vp);
if( isset($this->ci->trippest->special_route[$vp]) ) {
$full_pag = array_diff($this_include_pags, array_merge($full_pag,$process_pag));
foreach ($this_include_pags as $vi) {
if ($vi !== $vp) {
unset($apart_com[$vi]);
}
// $apart_com[$vp]['details'][] = $apart['com']['details'][$vi];
$apart_com[$vp]['details'] = array_merge($apart_com[$vp]['details'], $apart['com']['details'][$vi]);
$apart_com[$vp]['PAG_Code'] = $vp;
$apart_com[$vp]['PAG_Name'] = $this->ci->trippest->special_route[$vp]['name'];
}
} else {
$full_pag = array_merge($full_pag, $this_include_pags);
// $apart_com[$vp]['details'][] = $apart['com']['details'][$vp];
$apart_com[$vp]['details'] = array_merge($apart_com[$vp]['details'], $apart['com']['details'][$vp]);
$apart_com[$vp]['PAG_Code'] = $vp;
$apart_com[$vp]['PAG_Name'] = "";
}
$process_pag[] = $vp;
$this_include_pags = array();
}
}
$ret['big_pvt'] = empty($apart['big_pvt']) ? null : $apart['big_pvt'];
$ret['pvt'] = empty($apart['pvt']['details']) ? null : ($apart['pvt']);
$ret['com'] = array_values($apart_com);
return $ret;
}
/*!
* @Author: LYT
* @Date: 2019-06-04 11:47:38
* @Desc: 发送商务订单计划
*/
public function push_biz($vas=null, $gri_ordertype='227002')
{
$gri_sn = $vas->GRI_SN;
$vas_sn = $vas->VAS_SN;
$vei_sn = $vas->VAS_VEI_SN;
$grd_info = $this->ci->Group_model->get_vendor_plan_info($gri_sn, $vei_sn);
if (empty($grd_info)) {
$this->ci->Group_model->set_plan_received($vas_sn);
return false;
}
// return $this->ci->tldOrderBuilder->getBizContent() . "[Tulanduo>push_tour] Done. ";
return "[Tulanduo>push_tour] Done. ";
$COLD_SN_str = implode(',', array_map( function($element){return $element->GRD_COLD_SN;}, $grd_info )) ;
$all_colds = $this->ci->BIZ_order->get_all_cold($COLD_SN_str);
return false;
}
/*!
* 发送目的地项目组预订计划到图兰朵地接系统
* 地接社未接收的或有变更的
* @date 2018-10-26
*/
public function push_trippest($vas=null)
{
@ -243,13 +387,6 @@ log_message('error',$resp);
$gri_sn = $vas->GRI_SN;
$vas_sn = $vas->VAS_SN;
$vei_sn = $vas->VAS_VEI_SN;
$is_send_vary = $vas->VAS_SendVary;
$change_info = $vas->VAS_ChangeText;
if (trim($change_info) !== "") {
preg_match_all('/(.*)={6}(.*)(\d{4}\-\d{2}\-\d{2})/ismU', characet($change_info,'UTF-8'), $change_arr);
$change_info = $change_arr[0][0];
}
$change_info = str_replace("\n", "<br>", $change_info);
$vei_sn_str = implode(",", $this->vendor_ids);
$orderinfo = $this->ci->BIZ_order->get_orderinfo_detail($gri_sn, $vei_sn_str);
if(empty($orderinfo)) {return "[Tulanduo>push_trippest] Not found order detail. ";}
@ -321,8 +458,7 @@ log_message('error',$resp);
$this->ci->tldOrderBuilder->resetBizContent();
$order_type = $set_pvt;
if ($set_pvt==='0') {
$code_type_arr = array_map(function($pag) { return intval($pag->PAG_ExtendType); }, $vf["package_info"]);
$order_type = in_array(39009, $code_type_arr) ? 1 : 2;
$order_type = $this->ci->trippest->if_tour_pvt($vf["package_info"]);
}
$last_code = count($vf["package_info"])-1;
$last_date = count($vf["cold"])-1;
@ -361,7 +497,7 @@ log_message('error',$resp);
->setTravelDate(strstr($vf["cold"][0]->COLD_StartDate, " ", true))
->setLeavedDate($end_date)
->setOrderRemark($order_remark)
// todo 抵离交通
// todo: 抵离交通
// ->setToTraffic($toTraffic)
// ->setBackTraffic($backTraffic)
;
@ -408,8 +544,17 @@ log_message('error',$resp);
if (trim($hotels[0]->POI_HotelAddress) != "") {
$this_content .= "\r\n酒店地址:" . $hotels[0]->POI_HotelAddress;
}
$this_content .= trim($hotels[0]->POI_HotelCheckInName)!=="" ? "\r\n入住人:".$hotels[0]->POI_HotelCheckInName : "";
$this_content .= trim($hotels[0]->POI_HotelCheckIn)!=="" ? "\r\n入住日期:".$hotels[0]->POI_HotelCheckIn : "";
if (trim($hotels[0]->POI_Hotel) != '') {
$this->ci->tldOrderBuilder->setToTraffic($hotels[0]->POI_Hotel);
$this->ci->tldOrderBuilder->setBackTraffic($hotels[0]->POI_Hotel);
}
$checkin_name = trim($hotels[0]->POI_HotelCheckInName)!=="" ? "\r\n入住人:".$hotels[0]->POI_HotelCheckInName : "";
$checkin_date = trim($hotels[0]->POI_HotelCheckIn)!=="" ? "\r\n入住日期:".$hotels[0]->POI_HotelCheckIn : "";
$this_content .= $checkin_name;
$this_content .= $checkin_date;
if ($checkin_name!=='' || $checkin_date!=='') {
$this->ci->tldOrderBuilder->setRoomStandard(trim($checkin_name) . ", " . trim($checkin_date));
}
if ($hotels[0]->POI_FlightsNo) {
$this_content .= "\r\n航/车次:" . $hotels[0]->POI_FlightsNo;
if ($hotels[0]->POI_FromCity || $hotels[0]->POI_ToCity) {
@ -458,7 +603,7 @@ log_message('error',$resp);
$date_s = new DateTime(strstr($vs->COLD_StartDate, " ", TRUE));
$date_e = new DateTime(strstr($vs->COLD_EndDate, " ", TRUE));
$date_d = $date_e->diff($date_s);
$d_t = ($date_d->format("%d"));
$d_t = ($date_d->format("%a"));
if ($d_t > 0) {
for ($d_i=0; $d_i < ($d_t+1); $d_i++) {
$f_d = date('Y-m-d', strtotime("+$d_i day", strtotime(substr($vs->COLD_StartDate, 0, 10))));
@ -504,20 +649,28 @@ log_message('error',$resp);
}
// 拆分的订单团款录第一个
if ($i===1) {
$fee_index=0;
if ( ! empty($travel_fees) ) {
$this->ci->tldOrderBuilder->setTravelFeesType(0, "Per Group")
->setTravelFeesMoney(0, $travel_fees->SUM_SSJE)
->setTravelFeesNum(0, 1)
->setTravelFeesUnit(0, 1)
->setTravelFeesSumMoney(0, $travel_fees->SUM_SSJE);
$this->ci->tldOrderBuilder->setTravelFeesType($fee_index, "Per Group")
->setTravelFeesMoney($fee_index, $travel_fees->SUM_SSJE)
->setTravelFeesNum($fee_index, 1)
->setTravelFeesUnit($fee_index, 1)
->setTravelFeesSumMoney($fee_index, $travel_fees->SUM_SSJE);
++$fee_index;
}
if ( ! empty($replace_collections) ) {
$this->ci->tldOrderBuilder->setReplaceCollectionsType(0, "Per Group")
->setReplaceCollectionsMoney(0, $replace_collections->SUM_SSJE)
->setReplaceCollectionsRemark(0, $replace_collections->ALL_Memo);
$this->ci->tldOrderBuilder->setTravelFeesType($fee_index, "Per Group")
->setTravelFeesMoney($fee_index, $replace_collections->SUM_SSJE)
->setTravelFeesNum($fee_index, 1)
->setTravelFeesUnit($fee_index, 1)
->setTravelFeesSumMoney($fee_index, $replace_collections->SUM_SSJE)
->setTravelFeesRemark($fee_index, "代收; " . $replace_collections->ALL_Memo);
}
}
// 查询是否变更 TODO deprecated
// 查询是否变更 TODO: deprecated
$sync_orderstate = 10;
$vps_sn = 0;
$vendor_orderid = 0;
@ -571,7 +724,7 @@ log_message('error',$resp);
->setUserId($userId)
->setKey($userKey);
$detail_resp = $this->excute_curl($this->detail_url, $this->tld_order);
// $detail_resp = '{"status":1,"errMsg":"","orderDetail":{"orderId":' . rand(1000,9999) . ',"operationDetails": {"guiderOperations":[{"name":"北京翟梦琪Susie","mobelPhone":"18801326155","startDate":"2017-04-25","endDate":"2017-04-25","sumMoney":400,"remark":"","guiderPhoto":"http://djb3c.ltsoftware.net:9921/projects/djb3c//uploadImages/guider/1526898234415.png"}]}}}'; // test
// $detail_resp = '{"status":1,"errMsg":"","orderDetail":{"orderId":' . rand(1000,9999) . ',"operationDetails": {"guiderOperations":[{"name":"北京翟梦琪Susie","mobelPhone":"18801326155","startDate":"2017-04-25","endDate":"2017-04-25","sumMoney":400,"remark":"","guiderPhoto":"http://djb3c.ltsoftware.net:9921/projects/djb3c//uploadImages/guider/1526898234415.png"}]}}}'; // test:
$detail_jsonResp = json_decode($detail_resp);
// 判断
if ($detail_jsonResp->status !== 1) {
@ -640,7 +793,7 @@ log_message('error',$resp);
$ret['errMsg'] = "身份验证失败.";
return $this->output->set_content_type('application/json')->set_output(json_encode($ret));
}
// $vendorID = 29188;//29188 1343; // test
// $vendorID = 29188;//29188 1343; // test:
$vas_info = array();
if (in_array($input['agcName'], array("D目的地桂林组", "Trippest"))) {
$vas_info = $this->BIZ_order->get_vendorarrangestate_byVendor($input['orderId'], $vendorID);
@ -693,7 +846,6 @@ log_message('error',$resp);
return $this->output->set_content_type('application/json')->set_output(json_encode($ret));
}
private function excute_curl($url, $content_builder)
{
$ch = curl_init();

@ -56,6 +56,58 @@ class Trippest
return $ret;
}
public function ch_code_transfer($code)
{
$trippest_code = $code;
switch ($code) {
case 'SHALC-6':
case 'SHALC-7':
case 'SHALC-8':
case 'SHALC-9':
$trippest_code = "SHSIC-45";
break;
case 'SHSIC-31':
$trippest_code = "SHSIC-41";
break;
case 'SHSIC-32':
$trippest_code = "SHSIC-42";
break;
case 'SHSIC-33':
$trippest_code = "SHSIC-43";
break;
default:
break;
}
return $trippest_code;
}
/*!
* @Author: LYT
* @Date: 2019-05-28 15:17:11
* @Desc: 判断产品是否需要发送PVT计划
* @param $all_pag_info = array((pag.*),(pag.*))
* @return 1-pvt;2-combine
*/
public function if_tour_pvt($all_pag_info)
{
$tour_pvt_arr = array_filter(array_map(function($pag) {
if(intval($pag->PAG_ExtendType)===39009)
{
return 1;
} else if (stripos($pag->PAG_Title,"PVT") !== false) {
return 1;
} else if (stripos($pag->PAG_Title,"private") !== false) {
return 1;
} else {
return null;
}
}, $all_pag_info));
$order_type = empty($tour_pvt_arr) ? 2 : 1;
return $order_type;
}
}

File diff suppressed because it is too large Load Diff

@ -20,15 +20,14 @@ class Group_model extends CI_Model {
from VendorArrangeState vas
inner join Eva_ObjectInfo eoi on EOI_GRI_SN=VAS_GRI_SN and EOI_Type=1 and EOI_ObjSN=VAS_VEI_SN
inner join GRoupInfo gri on GRI_SN=VAS_GRI_SN
where 1=1 ";
where 1=1 AND VAS_VEI_SN in ($vendor_str) ";
$sql .= $gri_sn!==0 ? $gri_sql : "
AND VAS_IsCancel=0 AND VAS_Delete=0 AND vas.DeleteFlag=0
AND VAS_IsSendSucceed=1 AND VAS_IsReceive=0
AND isnull(VAS_IsCancel,0)=0 AND isnull(VAS_Delete,0)=0 AND isnull(vas.DeleteFlag,0)=0
AND VAS_IsSendSucceed=1 AND isnull(VAS_IsReceive,0)=0
AND EOI_GetDate between '$start_date' AND '$end_date'
AND VAS_VEI_SN in ($vendor_str)
-- Trippest, not confirm, not change -- for Trippest deploy
AND isnull(VAS_IsConfirm,0)=0 AND isnull(VAS_SendVary,0)=0
AND GRI_OrderType=227002
AND VAS_IsConfirm=0 AND VAS_SendVary=0
AND EXISTS (
select 1 from OperatorInfo where OPI_SN=GRI_operator AND OPI_DEI_SN=30
)
@ -68,16 +67,16 @@ class Group_model extends CI_Model {
'ReturnDatesAsStrings' => 1
);
$conn = sqlsrv_connect($db['HT']['hostname'], $connection);
$stmt = sqlsrv_query($conn, "EXEC Tourmanager.dbo.SP_VendorPlan_GetPlanInfo $gri_sn, $vendor_id, 0 ");
$stmt = sqlsrv_query($conn, "SET NOCOUNT ON;EXEC Tourmanager.dbo.SP_VendorPlan_GetPlanInfo $gri_sn, $vendor_id, 0 ");
$result_object = array();
if (false !== $stmt) { // 无权限返回false,会导致下列sqlsrv_has_rows,sqlsrv_next_result死循环
//存储过程中每个select都产生一个结果集,取某个结果集就需要从第一个移动到需要的那个结果集
//如果结果集为空就移到下一个
while (sqlsrv_has_rows($stmt) !== TRUE) {
sqlsrv_next_result($stmt);
}
while ($row = sqlsrv_fetch_object($stmt)) {
$result_object[] = $row;
if (false !== $stmt ) { // 无权限或执行错误返回false
// 存储过程中每个select都产生结果集
// 设置了SET NOCOUNT ON;就只有输出的结果集
$a = true;
while ($a !== false) {
$row = sqlsrv_fetch_object($stmt); // Retrieves the next row of data as a PHP object.
$a = !empty($row);
$a===true ? $result_object[] = $row : null;
}
sqlsrv_free_stmt($stmt);
}
@ -85,12 +84,25 @@ class Group_model extends CI_Model {
$grd_info = $result_object;
$all_day_no = array_map(function($ele){return $ele->GRD_DayNo;}, $grd_info);
$day_no_str = implode(",", $all_day_no);
$all_aci = $this->get_arrange_info($gri_sn, 0, $day_no_str);
$all_aci = $this->get_arrange_info($gri_sn, $vendor_id, $day_no_str);
foreach ($grd_info as $kgrd => &$vgrd) {
$vgrd->pag_code_arr = array();
$vgrd->PAG_Title = $vgrd->GRD_Landscape;
foreach ($all_aci as $kaci => $vaci) {
if ($vgrd->GRD_DayNo == $vaci->ACI_DayNo) {
$vgrd->day_no_raw = strstr($vaci->ACI_OrderDate, " ", true);
break;
$vgrd->day_no_raw = strstr($vaci->ACI_OrderDate, " ", true);
$vgrd->tocity = $vaci->tocity;
$vgrd->citycode = $vaci->citycode;
$vgrd->ACI_PersonNum = intval($vaci->ACI_PersonNum);
$vgrd->ACI_ChildNum = intval($vaci->ACI_ChildNum);
$vgrd->ACI_BabyNum = intval($vaci->ACI_BabyNum);
$vgrd->PAG_DEI_SN = $vaci->PAG_DEI_SN;
if ( strval($vaci->ACI_ServiceType)==='D') {
$vgrd->PAG_Code = mb_strtoupper($vaci->PAG_Code);
$vgrd->PAG_ExtendType = mb_strtoupper($vaci->PAG_ExtendType);
$vgrd->pag_code_arr[] = mb_strtoupper($vaci->PAG_Code);
break;
}
}
}
}
@ -122,8 +134,13 @@ class Group_model extends CI_Model {
where CII2_CII_SN=ACI_ToCity and CII2_LGC=2) as tocity,
(select CII_PKCode from CItyInfo
where CII_SN=ACI_ToCity ) as citycode,
PAG_Code,PAG_ExtendType,PAG_DEI_SN,
*
from ArrangeConfirmInfo aci
left join BIZ_PackageInfo on PAG_SN=ACI_ServiceSN
and ACI_ServiceType='D' and PAG_DefaultVEI_SN=ACI_VEI_SN
-- 增加是否目的地产品的判断
and SUBSTRING(CONVERT(varchar(10), PAG_SourceType) ,1,3)='132'
where 1=1
and aci.ACI_GRI_SN=?
$vendor_sql
@ -273,8 +290,6 @@ class Group_model extends CI_Model {
return $this->HT->query($update_sql);
}
/*
* 发送邮件
*/

@ -213,7 +213,10 @@ class TuLanDuo_addOrUpdateRouteOrderContentBuilder extends CI_Model
return $this;
}
/** 行程详细数组 */
/**
* 行程详细数组
* 已存在的日期则拼接内容
*/
public function setScheduleDetailsTitle($index, $title)
{
$this->orderData['scheduleDetails'][$index]['title'] = $title;
@ -221,32 +224,38 @@ class TuLanDuo_addOrUpdateRouteOrderContentBuilder extends CI_Model
}
public function setScheduleDetailsContent($index, $content)
{
$this->orderData['scheduleDetails'][$index]['content'] = $content;
$this->orderData['scheduleDetails'][$index]['content'] = isset($this->orderData['scheduleDetails'][$index]['content']) ?
($this->orderData['scheduleDetails'][$index]['content'] . "\r\n" . $content) : $content;
return $this;
}
public function setScheduleDetailsTraffic($index, $traffic)
{
$this->orderData['scheduleDetails'][$index]['traffic'] = $traffic;
$this->orderData['scheduleDetails'][$index]['traffic'] = isset($this->orderData['scheduleDetails'][$index]['traffic']) ?
($this->orderData['scheduleDetails'][$index]['traffic'] . "\r\n" . $traffic) : $traffic;
return $this;
}
public function setScheduleDetailsAccommodation($index, $accommodation)
{
$this->orderData['scheduleDetails'][$index]['accommodation'] = $accommodation;
$this->orderData['scheduleDetails'][$index]['accommodation'] = isset($this->orderData['scheduleDetails'][$index]['accommodation']) ?
($this->orderData['scheduleDetails'][$index]['accommodation'] . "\r\n" . $accommodation) : $accommodation;
return $this;
}
public function setScheduleDetailsBreakFirst($index, $breakFirst)
{
$this->orderData['scheduleDetails'][$index]['breakFirst'] = $breakFirst;
$this->orderData['scheduleDetails'][$index]['breakFirst'] = isset($this->orderData['scheduleDetails'][$index]['breakFirst']) ?
$breakFirst+$this->orderData['scheduleDetails'][$index]['breakFirst'] : $breakFirst;
return $this;
}
public function setScheduleDetailsDinner($index, $dinner)
{
$this->orderData['scheduleDetails'][$index]['dinner'] = $dinner;
$this->orderData['scheduleDetails'][$index]['dinner'] = isset($this->orderData['scheduleDetails'][$index]['dinner']) ?
$dinner+$this->orderData['scheduleDetails'][$index]['dinner'] : $dinner;
return $this;
}
public function setScheduleDetailsLunch($index, $lunch)
{
$this->orderData['scheduleDetails'][$index]['lunch'] = $lunch;
$this->orderData['scheduleDetails'][$index]['lunch'] = isset($this->orderData['scheduleDetails'][$index]['lunch']) ?
$lunch+$this->orderData['scheduleDetails'][$index]['lunch'] : $lunch;
return $this;
}

@ -27,10 +27,14 @@ class Orders_model extends CI_Model {
where LGC_LGC = 2
and COI_SN in (select MEI_Country from MemberInfo where MEI_SN=CUL_CUI_SN)
) as Country,
(select MEI_PassportNo from MemberInfo where MEI_SN=CUL_CUI_SN) PassportNo,
(select MEI_PassportValidDate from MemberInfo where MEI_SN=CUL_CUI_SN) PassportValidDate
MEI_Phone phone,
MEI_PassportNo PassportNo,
MEI_PassportValidDate PassportValidDate
-- (select MEI_PassportNo from MemberInfo where MEI_SN=CUL_CUI_SN) PassportNo,
-- (select MEI_PassportValidDate from MemberInfo where MEI_SN=CUL_CUI_SN) PassportValidDate
-- ,(select dbo.GetSysCodeName(MEI_Occupation,2) from MemberInfo where MEI_SN=CUL_CUI_SN) as Occupation
from CustomerList
inner join MemberInfo on MEI_SN=CUL_CUI_SN
where isnull(CUL_IsAgent,0)=0
and isnull(CUL_IsEmergency,0)=0
and isnull(CUL_IsTJR,0)=0

Loading…
Cancel
Save