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

@ -920,6 +920,14 @@ $config['InfoType_ct'] = array(
'一日游线路详细' => 'c_day_tour'
);
//AH站点用到了
$config['InfoType_ah'] = array(
'国家信息' => 'country_info',
'区域信息' => 'area_info',
'国家信息列表页' => 'country_info_list',
'区域信息列表页' => 'area_info_list'
);
//可选模板
$config['templates'] = array(
'通用内容模板' => 'guide_info_detail',

@ -198,8 +198,9 @@ class Information extends CI_Controller
if ($Structure->is_sitecode == 'ct') {
$data['infoTypeList'] = $this->config->item('InfoType_ct');
} elseif($Structure->is_sitecode == 'ah'){
$data['infoTypeList'] = $this->config->item('InfoType_ah');
}else {
switch ($data['rootInformation']->ic_ht_area_type) {
case 'c': //城市
$data['infoTypeList'] = $this->config->item('InfoType_city');

@ -62,6 +62,7 @@
<li ><a href="/thailand/" >THAILAND</a></li>
<li ><a href="/vietnam/" >VIETNAM</a></li>
<li ><a href="/myanmar/" >MYANMAR</a></li>
<li ><a href="/japan/" >JAPAN</a></li>
<li ><a href="/cambodia/" >CAMBODIA</a></li>
<li ><a href="/laos/" >LAOS</a></li>
<li ><a href="/tours/year.htm" >SOUTHEAST ASIA</a></li>
@ -107,6 +108,7 @@
<div class="fixed-addthis"><amp-addthis width="320" height="40" layout="responsive" data-pub-id="ra-598408c3e2fb90c3" data-widget-id="o2ei"></amp-addthis></div>
<amp-animation id="showAnim"layout="nodisplay"><script type="application/json">{"duration":"200ms","fill":"both","iterations":"1","direction":"alternate","animations":[{"selector":"#scrollToTopButton","keyframes":[{"opacity":"1","visibility":"visible"}]}]}</script></amp-animation><amp-animation id="hideAnim"layout="nodisplay"><script type="application/json">{"duration":"200ms","fill":"both","iterations":"1","direction":"alternate","animations":[{"selector":"#scrollToTopButton","keyframes":[{"opacity":"0","visibility":"hidden"}]}]}</script></amp-animation><div id="marker"><amp-position-observer on="enter:hideAnim.start; exit:showAnim.start"layout="nodisplay"></amp-position-observer></div><a id="scrollToTopButton"on="tap:top-page.scrollTo(duration=200)"class="scrollToTop"></a>
@AMP-GOOGLE-ANALYTICS@
@AMP-CONSTRUCT-TAG@
<!--AMP Builder-->
</body>
</html>

@ -16,6 +16,7 @@
<script async custom-element="amp-position-observer" src="https://cdn.ampproject.org/v0/amp-position-observer-0.1.js"></script>
<script async custom-element="amp-animation" src="https://cdn.ampproject.org/v0/amp-animation-0.1.js"></script>
<script async custom-element="amp-addthis" src="https://cdn.ampproject.org/v0/amp-addthis-0.1.js"></script>
<script async custom-element="amp-user-notification" src="https://cdn.ampproject.org/v0/amp-user-notification-0.1.js"></script>
<style amp-custom>
/*@COMMON-CSS@*/
/*@CUSTOM-CSS@*/
@ -37,7 +38,12 @@
<!--@CUSTOM-CONENT@-->
@AMP-COMMON-FOOTER@
<amp-user-notification
layout=nodisplay
id="amp-user-notification">
Unsere Webseite verwendet Cookies um die Webseite st?ndig zu verbessern. Wenn Sie auf unserer Seite weitersurfen, stimmen Sie der Datenschutzerkl?rung zu.
<a class="btn cookiesAlertBtn" on="tap:amp-user-notification.dismiss">Ich stimme zu.</a>
</amp-user-notification>
<div class="fixed-addthis"><amp-addthis width="320" height="48" layout="responsive" data-pub-id="ra-58255ecaa2c44e0d" data-widget-id="mip1"></amp-addthis></div>
<amp-animation id="showAnim"layout="nodisplay"><script type="application/json">{"duration":"200ms","fill":"both","iterations":"1","direction":"alternate","animations":[{"selector":"#scrollToTopButton","keyframes":[{"opacity":"1","visibility":"visible"}]}]}</script></amp-animation><amp-animation id="hideAnim"layout="nodisplay"><script type="application/json">{"duration":"200ms","fill":"both","iterations":"1","direction":"alternate","animations":[{"selector":"#scrollToTopButton","keyframes":[{"opacity":"0","visibility":"hidden"}]}]}</script></amp-animation><div id="marker"><amp-position-observer on="enter:hideAnim.start; exit:showAnim.start"layout="nodisplay"></amp-position-observer></div><a id="scrollToTopButton"on="tap:top-page.scrollTo(duration=200)"class="scrollToTop"></a>
<!--AMP Builder-->

@ -86,11 +86,12 @@ class search extends CI_Controller{
}
if(!empty(json_decode($search_return)->result)){
$this->BIZ_train_model->addOrUpdate($fromStation,$toStation,$search_return);
//$this->BIZ_train_model->addOrUpdate($fromStation,$toStation,$search_return);
$operate_data = $search_return;
}else{
$operate_data = null;
//添加缓存调用时间判断
if($this->differ_time <= 5){
/*if($this->differ_time <= 5){
$cache_train_info = NULL;
}else{
$cache_train_info = $this->BIZ_train_model->get_train_cache($fromStation,$toStation);
@ -113,7 +114,7 @@ class search extends CI_Controller{
$operate_data = $cache_train_info->tpc_content;
log_message('error','TRAIN 查询为空的链接:'.$this->url.'|出错的原因:'.$this->reason.'|调用缓存号:'.$cache_train_info->tpc_sn.'|缓存生成的时间:'.$cache_train_info->tpc_datetime);
}
}
}*/
}
return $operate_data;
}

@ -544,14 +544,15 @@ class addorders extends CI_Controller{
$OrderNumber = ORDERUSER.time();
//拼接发送的报文
$PostData = array();
$TimeStamp = time();
$time = date('Y-m-d H:i:s',$TimeStamp);
$time = date('Y-m-d H:i:s',time());
$PostData['Authentication'] = new stdClass();
$PostData['Authentication']->TimeStamp = $time;
$PostData['Authentication']->ServiceName = 'order.PartnerAddOrder';
$PostData['Authentication']->PartnerName = ORDERUSER;
$MessageIdentity = md5($time.'order.PartnerAddOrder'.ORDERKEY);
$PostData['Authentication']->MessageIdentity = $MessageIdentity;
$PostData['TrainOrderService'] = new stdClass();
$PostData['TrainOrderService']->PartnerName = ORDERUSER;
$PostData['TrainOrderService']->Operation = '';
$PostData['TrainOrderService']->OrderType = '电子';
@ -559,12 +560,14 @@ class addorders extends CI_Controller{
$PostData['TrainOrderService']->OrderNumber = $OrderNumber;
$PostData['TrainOrderService']->ChannelName = ORDERUSER;
$PostData['TrainOrderService']->Order = new stdClass();
$PostData['TrainOrderService']->Order->OrderTime = $time;
$PostData['TrainOrderService']->Order->OrderMedia = 'pc';
$PostData['TrainOrderService']->Order->Insurance = 'N';
$PostData['TrainOrderService']->Order->Invoice = 'N';
$PostData['TrainOrderService']->Order->PrivateCustomization = '0';
$PostData['TrainOrderService']->Order->TicketItem = new stdClass();
$PostData['TrainOrderService']->Order->TicketItem->FromStationName = $data['train']->DepartAirport_cn;
$PostData['TrainOrderService']->Order->TicketItem->ToStationName = $data['train']->ArrivalAirport_cn;
$PostData['TrainOrderService']->Order->TicketItem->TicketTime = date('Y-m-d H:i:s',strtotime($data['train']->DepartureTime));
@ -640,6 +643,7 @@ class addorders extends CI_Controller{
$PostData['TrainOrderService']->Order->FrontSeatFlag = '0';
$PostData['TrainOrderService']->Order->User = new stdClass();
$PostData['TrainOrderService']->Order->User->UserID = '';
$PostData['TrainOrderService']->Order->User->UserName = 'guilintravel';
$PostData['TrainOrderService']->Order->User->userLoginName = 'guilintravel';

@ -21,7 +21,8 @@ $config['tripadvisor_website'] = array(
'tp_Beijing' => 'https://www.tripadvisor.com/Attraction_Review-g294212-d4006739-Reviews{PAGENUM}-The_Trippest_Mini_Group_Tours-Beijing.html',
'tp_Xian' => 'https://www.tripadvisor.com/Attraction_Review-g298557-d10999897-Reviews{PAGENUM}-Xi_an_Trippest_Mini_Group_Tours-Xi_an_Shaanxi.html',
'tp_Shanghai' => 'https://www.tripadvisor.com/Attraction_Review-g308272-d6222868-Reviews{PAGENUM}-Shanghai_Trippest_Mini_Group_Tours-Shanghai.html',
'tp_Guilin' => 'https://www.tripadvisor.com/Attraction_Review-g298556-d14121459-Reviews{PAGENUM}-Trippest_Mini_Group_Tours-Guilin_Guangxi.html'
'tp_Guilin' => 'https://www.tripadvisor.com/Attraction_Review-g298556-d14121459-Reviews{PAGENUM}-Trippest_Mini_Group_Tours-Guilin_Guangxi.html',
'train' => 'https://www.tripadvisor.com/Attraction_Review-g298556-d16700226-Reviews-Train_Spread-Guilin_Guangxi.html'
);

@ -76,6 +76,7 @@
<option value="tp_Beijing">tp_Beijing</option>
<option value="tp_Shanghai">tp_Shanghai</option>
<option value="tp_Guilin">tp_Guilin</option>
<option value="train">train</option>
</select>
</div>
<div class="col-md-9">
@ -100,6 +101,7 @@
<option value="tp_Beijing">tp_Beijing</option>
<option value="tp_Shanghai">tp_Shanghai</option>
<option value="tp_Guilin">tp_Guilin</option>
<option value="train">train</option>
</select>
</div>
<div class="col-md-9">

@ -0,0 +1,83 @@
<?php
function GetPost_http($url, $data = '', $method = 'GET') {
$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 ($method == 'POST' && !empty($data)) {
curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
}
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', 'ctripost'.$errno.curl_error($curl));
}
curl_close($curl); //关闭CURL会话
return $tmpInfo; //返回数据
}
$BackXml = file_get_contents('php://input');
/*$BackXml = '';
$BackXml .= '<?xml version="1.0"?>';
$BackXml .= "<OrderProcessRequest xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
$BackXml .= '<Authentication>
<ServiceName>web.order.requestRefund</ServiceName>
<PartnerName>tieyou</PartnerName>
<TimeStamp>2016-05-26 16:26:47</TimeStamp>
<MessageIdentity>263A1E3FDCEBA0AEE61E49952E34C27D</MessageIdentity>
</Authentication>
<TrainOrderService>
<OrderInfo>
<OrderNumber>elonge20160526261753244</OrderNumber>
<OrderTid>882c5548-b672-4484</OrderTid>
<OrderTradeNo>882c5548-b672-4484</OrderTradeNo>
</OrderInfo>
<OrderTotleFee></OrderTotleFee>
<TotalRefundAmount>5.50</TotalRefundAmount>
<Reason>Test</Reason>
<RefundType>T</RefundType>
</TrainOrderService>
</OrderProcessRequest>';*/
$BackArr = simplexml_load_string($BackXml);
$ServiceName = $BackArr->Authentication->ServiceName;
if($ServiceName == 'web.order.returnTicketNotice'){
$OrderNumber = $BackArr->TrainOrderService->OrderNumber;
}else{
$OrderNumber = $BackArr->TrainOrderService->OrderInfo->OrderNumber;
}
$responsexml = '
<?xml version="1.0" encoding="utf-8"?>
<OrderResponse>
<ServiceName>'.$ServiceName.'</ServiceName>
<OperationDateTime>'.date('Y-m-d H:i:s').'</OperationDateTime>
<OrderNumber>'.$OrderNumber.'</OrderNumber>
<Status>SUCCESS</Status>
<ErrorResponse>
<ErrorMessage>null</ErrorMessage>
<ErrorCode/>
</ErrorResponse>
</OrderResponse>
';
echo $responsexml;
$BackJson = json_encode($BackArr);
$Url = 'http://www.mycht.cn/info.php/apps/trainsystem/callback/ctripcallback';
//发送数据
GetPost_http($Url,$BackJson,'POST');
?>

@ -7,24 +7,25 @@ class Index extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('ding_value_model');
$this->load->helper('cookie');
}
public function test_cookie(){
//https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoagxeeheunc0p95eu8&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=http://www.mycht.cn/webht.php/apps/dingmail/index/test_cookie
public function test_session(){
$unionid = 'JbHXZ0DtTj2fOwkk4nfLpgiEiE';
$user = $this->ding_value_model->get_dingding_user($unionid);
//$this->session->set_userdata('dingdinguserinfo',$user);
//echo get_cookie('ci_session');
print_r($this->session->userdata('dingdinguserinfo'));
}
public function index($unionid = null,$type = null){
if($this->session->userdata('dingding_user_info') === false){
$this->session->set_userdata('unionid', $unionid);
$this->session->set_userdata('type',$type);
$this->load->view('login');
if(get_cookie('dingunionid') == ''){
redirect('http://www.mycht.cn/info.php/apps/dinglogin/login/?returnurl=http://www.mycht.cn/webht.php/apps/dingmail/index/');
}else{
if($unionid != null && $type != null){
$user_info = $this->session->userdata('dingding_user_info');
$data['type'] = $type;
$data['user'] = $user_info->ddu_Name;
$data['user_unionid'] = $user_info->ddu_Unionid;
$data['user'] = get_cookie('dingname');
$data['user_unionid'] = get_cookie('dingunionid');
if($this->ding_value_model->get_dingding_user($unionid) == null){
echo '该用户还未登录过,请告知他登录后才能对他点赞或拍砖!<br>';
echo '有问题请联系CYC!';
@ -55,9 +56,11 @@ class Index extends CI_Controller {
}
}
}else{
//访问自己的主页
if($unionid == null){
$unionid = $this->session->userdata('dingding_user_info')->ddu_Unionid;
$unionid = get_cookie('dingunionid');
}
$mdata['user'] = $this->ding_value_model->get_dingding_user($unionid);
$mdata['user_unionid'] = $unionid;
$mdata['like_count'] = $this->ding_value_model->count_like($unionid);
@ -65,7 +68,11 @@ class Index extends CI_Controller {
$mdata['whos_like'] = $this->ding_value_model->whos_like($unionid);
$mdata['whos_unlike'] = $this->ding_value_model->whos_unlike($unionid);
$mdata['all_comment'] = $this->ding_value_model->all_comment($unionid);
//print_r($this->session->userdata('dingding_user_info'));
//print_r($this->session->userdata('dingdinguserinfo'));
//如果传入的unionid和cookie的相等就再存一个userinfo的cookie访问个人主页反之不存就是访问他人主页
if($unionid == get_cookie('dingunionid')){
$this->session->set_userdata('dingdinguserinfo', $mdata['user']);
}
$this->load->view('user',$mdata);
}
}
@ -73,10 +80,10 @@ class Index extends CI_Controller {
//value邮件页面
public function mail_index(){
if($this->session->userdata('dingding_user_info') === false){
$this->load->view('login');
if($this->session->userdata('dingdinguserinfo') === false){
redirect('http://www.mycht.cn/webht.php/apps/dingmail/index/');
}else{
//print_r($this->session->userdata('dingding_user_info'));
//print_r($this->session->userdata('dingdinguserinfo'));
$this->load->view('mail');
}
}
@ -87,7 +94,7 @@ class Index extends CI_Controller {
echo -1;
return;
}
$user_info = $this->session->userdata('dingding_user_info');
$user_info = $this->session->userdata('dingdinguserinfo');
$data['mail_content'] = htmlspecialchars($this->input->post('emailcontent'));
$data['mail_fromuser'] = $user_info->ddu_Name;
$data['mail_subject'] = $this->input->post('mail_subject');
@ -286,12 +293,12 @@ class Index extends CI_Controller {
//钉邮群体点赞功能
public function like($identify = null,$type = null){
if($this->session->userdata('dingding_user_info') === false){
if($this->session->userdata('dingdinguserinfo') === false){
$this->session->set_userdata('identify',$identify);
$this->session->set_userdata('mail_type',$type);
$this->load->view('login');
redirect('http://www.mycht.cn/webht.php/apps/dingmail/index/');
}else{
$user_info = $this->session->userdata('dingding_user_info');
$user_info = $this->session->userdata('dingdinguserinfo');
if(!empty($user_info)){
$data['user'] = $user_info->ddu_Name;
if(($type == 'like' || $type == 'unlike') && $identify){
@ -360,8 +367,8 @@ class Index extends CI_Controller {
$data['user_unionid'] = 'xxxxxxx';
$data['type'] = 'hidden_comment';
}else{
$data['user'] = $this->session->userdata('dingding_user_info')->ddu_Name;
$data['user_unionid'] = $this->session->userdata('dingding_user_info')->ddu_Unionid;
$data['user'] = $this->session->userdata('dingdinguserinfo')->ddu_Name;
$data['user_unionid'] = $this->session->userdata('dingdinguserinfo')->ddu_Unionid;
$data['type'] = 'comment';
}
@ -397,11 +404,11 @@ class Index extends CI_Controller {
//点赞排行榜
public function rank_person() {
if($this->session->userdata('dingding_user_info') === false){
$this->load->view('login');
if($this->session->userdata('dingdinguserinfo') === false){
redirect('http://www.mycht.cn/webht.php/apps/dingmail/index/');
}else{
$data = array();
$user_info = $this->session->userdata('dingding_user_info');
$user_info = $this->session->userdata('dingdinguserinfo');
if (!empty($user_info)) {
$data['uname'] = $user_info->ddu_Name;
}
@ -459,7 +466,7 @@ class Index extends CI_Controller {
exit('新增用户失败!');
}else{
$user_info = $this->ding_value_model->get_dingding_user($data['ddu_Unionid']);
$this->session->set_userdata('dingding_user_info',$user_info);
$this->session->set_userdata('dingdinguserinfo',$user_info);
if($this->session->userdata('unionid') && $this->session->userdata('type')){
redirect(site_url('apps/dingmail/index/index/'.$this->session->userdata('unionid').'/'.$this->session->userdata('type')));
}elseif($this->session->userdata('identify') && $this->session->userdata('mail_type')){
@ -480,7 +487,7 @@ class Index extends CI_Controller {
$this->ding_value_model->update_dingding_user($data['ddu_Name'],$data['ddu_Unionid'],$data['ddu_Mobile'],$data['ddu_Email'],$data['ddu_Position'],$data['ddu_Avatar'],$data['ddu_Datetime']);
$check_login = $this->ding_value_model->get_dingding_user($unionid);
}
$this->session->set_userdata('dingding_user_info', $check_login);
$this->session->set_userdata('dingdinguserinfo', $check_login);
if($this->session->userdata('unionid') && $this->session->userdata('type')){
redirect(site_url('apps/dingmail/index/index/'.$this->session->userdata('unionid').'/'.$this->session->userdata('type')));
}elseif($this->session->userdata('identify') && $this->session->userdata('mail_type')){
@ -599,12 +606,14 @@ class Index extends CI_Controller {
//退出
public function logout(){
$this->session->unset_userdata('dingding_user_info');
$this->session->unset_userdata('dingdinguserinfo');
$this->session->unset_userdata('unionid');
$this->session->unset_userdata('type');
$this->session->unset_userdata('identify');
$this->session->unset_userdata('mail_type');
$this->input->set_cookie('userdata', '', '');
delete_cookie('dingunionid');
delete_cookie('dingname');
redirect(site_url('apps/dingmail/index/index/'));
}

@ -344,7 +344,7 @@ class ding_value_model extends CI_Model {
}
public function test(){
$sql = "delete from Dingding_Value where ddv_Sn = '9125'";
$sql = "delete from Dingding_Value where ddv_Sn in ('10903','10904','10905')";
$query = $this->HT->query($sql);
}

@ -43,7 +43,7 @@
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="<?php echo site_url('apps/dingmail/index/mail_index');?>">Value发送</a></li>
<li><a href="<?php echo site_url('apps/dingmail/index/index/'.$this->session->userdata('dingding_user_info')->ddu_Unionid);?>">个人中心</a></li>
<li><a href="<?php echo site_url('apps/dingmail/index/index/'.get_cookie('dingunionid'));?>">个人中心</a></li>
<li><a href="<?php echo site_url('apps/dingmail/index/rank_person');?>">排行榜</a></li>
</ul>
</div>

@ -46,7 +46,7 @@
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="<?php echo site_url('apps/dingmail/index/mail_index');?>">Value发送</a></li>
<li><a href="<?php echo site_url('apps/dingmail/index/index/'.$this->session->userdata('dingding_user_info')->ddu_Unionid);?>">个人中心</a></li>
<li><a href="<?php echo site_url('apps/dingmail/index/index/'.$this->session->userdata('dingdinguserinfo')->ddu_Unionid);?>">个人中心</a></li>
<li><a href="<?php echo site_url('apps/dingmail/index/rank_person');?>">排行榜</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">

@ -45,7 +45,7 @@
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="<?php echo site_url('apps/dingmail/index/mail_index');?>">Value发送</a></li>
<li><a href="<?php echo site_url('apps/dingmail/index/index/'.$this->session->userdata('dingding_user_info')->ddu_Unionid);?>">个人中心</a></li>
<li><a href="<?php echo site_url('apps/dingmail/index/index/'.$this->session->userdata('dingdinguserinfo')->ddu_Unionid);?>">个人中心</a></li>
<li><a href="<?php echo site_url('apps/dingmail/index/rank_person');?>">排行榜</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">

@ -43,7 +43,7 @@
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="<?php echo site_url('apps/dingmail/index/mail_index');?>">Value发送</a></li>
<li><a href="<?php echo site_url('apps/dingmail/index/index/'.$this->session->userdata('dingding_user_info')->ddu_Unionid);?>">个人中心</a></li>
<li><a href="<?php echo site_url('apps/dingmail/index/index/'.get_cookie('dingunionid'));?>">个人中心</a></li>
<li><a href="<?php echo site_url('apps/dingmail/index/rank_person');?>">排行榜</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
@ -110,7 +110,7 @@
<div class="clearfix"></div>
</div>
</div>
<?php if($this->session->userdata('dingding_user_info')->ddu_Name == $user->ddu_Name ){ ?>
<?php if(get_cookie('dingname') == $user->ddu_Name ){ ?>
<div class="panel">
<div class="panel-body">
<legend>
@ -121,10 +121,10 @@
<a href="http://www.mycht.cn/webht.php/apps/dingmail/index/mail_index">
<img src="http://www.mycht.cn/css/images/+valuemail.png">
</a>
<a href="http://www.mycht.cn/webht.php/apps/dingmail/index/index/<?php echo $this->session->userdata('dingding_user_info')->ddu_Unionid?>/like">
<a href="http://www.mycht.cn/webht.php/apps/dingmail/index/index/<?php echo $this->session->userdata('dingdinguserinfo')->ddu_Unionid?>/like">
<img src="http://www.mycht.cn/css/images/+like.png">
</a>
<a href="http://www.mycht.cn/webht.php/apps/dingmail/index/index/<?php echo $this->session->userdata('dingding_user_info')->ddu_Unionid?>/unlike">
<a href="http://www.mycht.cn/webht.php/apps/dingmail/index/index/<?php echo $this->session->userdata('dingdinguserinfo')->ddu_Unionid?>/unlike">
<img src="http://www.mycht.cn/css/images/+unlike.png">
</a>
</div>

@ -174,6 +174,7 @@ class Index extends CI_Controller {
$this->load->model('messagecenter_model');
$from_time = $this->input->get_post('from_time');
$to_time = $this->input->get_post('to_time');
$rate = $this->input->get_post('rate');
$sms_price_list = array("376"=>"0.0651","971"=>"0.0415","93"=>"0.0731","1268"=>"0.0781","1264"=>"0.0454","355"=>"0.0949","374"=>"0.0813","244"=>"0.0633","54"=>"0.0301","1684"=>"0.1100","43"=>"0.1287","61"=>"0.0804","297"=>"0.0553","994"=>"0.1462","387"=>"0.0772","1246"=>"0.0521","880"=>"0.0846","32"=>"0.0825","226"=>"0.0776","359"=>"0.0737","973"=>"0.0229","257"=>"0.0383","229"=>"0.0498","1441"=>"0.0548","673"=>"0.0173","591"=>"0.0649","599"=>"0.0443","55"=>"0.0167","1242"=>"0.0390","975"=>"0.0396","267"=>"0.0427","375"=>"0.0638","501"=>"0.0330","1"=>"0.0080","243"=>"0.0513","236"=>"0.0633","242"=>"0.0664","41"=>"0.0712","225"=>"0.0819","682"=>"0.0403","56"=>"0.0680","237"=>"0.0548","57"=>"0.0414","506"=>"0.0694","238"=>"0.0869","599"=>"0.0489","357"=>"0.0335","420"=>"0.0801","49"=>"0.1000","253"=>"0.1106","45"=>"0.0532","1767"=>".0550","1809"=>"0.0519","213"=>"0.1656","593"=>"0.1068","372"=>"0.1141","20"=>"0.0492","291"=>"0.0915","34"=>"0.0988","251"=>"0.0336","358"=>"0.1390","679"=>"0.0367","691"=>"0.1491","298"=>"0.0158","33"=>"0.0778","241"=>"0.0357","44"=>"0.0464","1473"=>"0.0489","995"=>"0.0218","594"=>"0.1515","233"=>"0.0244","350"=>"0.0201","299"=>"0.0128","220"=>"0.0454","224"=>"0.0884","590"=>"0.2772","240"=>"0.0863","30"=>"0.1013","502"=>"0.0555","1671"=>"0.0564","245"=>"0.0978","592"=>"0.0726","852"=>"0.0448","504"=>"0.0645","385"=>"0.0801","509"=>"0.0848","36"=>"0.1197","62"=>"0.0334","353"=>"0.0824","972"=>"0.0173","91"=>"0.0085","964"=>"0.0611","354"=>"0.0333","39"=>"0.0823","1876"=>"0.0374","962"=>"0.0700","81"=>"0.0750","254"=>"0.0299","996"=>"0.0564","855"=>"0.0561","686"=>"0.0510","269"=>"0.0459","1869"=>"0.0947","82"=>"0.0357","965"=>"0.0518","1345"=>"0.0463","7"=>"0.0783","856"=>"0.0456","961"=>"0.0464","1758"=>"0.0414","423"=>"0.0297","94"=>"0.0690","231"=>"0.0709","266"=>"0.0589","370"=>"0.0419","352"=>"0.0157","371"=>"0.0696","218"=>"0.0569","212"=>"0.0832","377"=>"0.0638","373"=>"0.0954","382"=>"0.0358","261"=>"0.0564","692"=>"0.1323","389"=>"0.0303","223"=>"0.1927","95"=>"0.0940","976"=>"0.0645","853"=>"0.0267","222"=>"0.0800","1664"=>"0.0685","356"=>"0.0316","230"=>"0.0509","960"=>"0.0340","265"=>"0.0486","52"=>"0.0332","60"=>"0.0362","258"=>"0.0315","264"=>"0.0429","687"=>"0.2356","227"=>"0.0769","234"=>"0.0314","505"=>"0.0726","31"=>"0.1564","47"=>"0.0942","977"=>"0.1029","674"=>"0.0842","64"=>"0.1162","968"=>"0.0750","507"=>"0.0723","51"=>"0.0440","689"=>"0.1246","675"=>"0.0692","63"=>"0.0355","92"=>"0.0226","48"=>"0.0411","508"=>"0.0580","1787"=>"0.0564","351"=>"0.0522","680"=>"0.0855","595"=>"0.0306","974"=>"0.0526","262"=>"0.2108","40"=>"0.0744","381"=>"0.0472","7"=>"0.0321","250"=>"0.0366","966"=>"0.0357","677"=>"0.0303","248"=>"0.0644","249"=>"0.0510","46"=>"0.1066","65"=>"0.0380","386"=>"0.0383","421"=>"0.0999","232"=>"0.0305","378"=>"0.0587","221"=>"0.0719","252"=>"0.0873","597"=>"0.0495","239"=>"0.1149","503"=>"0.0574","268"=>"0.0748","1649"=>"0.0411","235"=>"0.0378","228"=>"0.0348","66"=>"0.0192","992"=>"0.0607","670"=>"0.0656","993"=>"0.0580","216"=>"0.1255","676"=>"0.0371","90"=>"0.0090","1868"=>"0.0384","886"=>"0.0540","255"=>"0.0422","380"=>"0.0533","256"=>"0.0776","1"=>"0.0063","598"=>"0.1093","998"=>"0.1411","1784"=>"0.0619","58"=>"0.0203","1284"=>"0.0480","84"=>"0.0399","678"=>"0.0611","685"=>"0.0774","967"=>"0.0284","269"=>"0.1589","27"=>"0.0319","260"=>"0.0422","263"=>"0.0253");
@ -186,7 +187,7 @@ class Index extends CI_Controller {
$tp_total_price += 2 * 0.1;
}else{
//echo $sms_price_list[$tp_item->TPSL_nationCode];
$tp_total_price += (2 * $sms_price_list[$tp_item->TPSL_nationCode]) * 6.7335;
$tp_total_price += (2 * $sms_price_list[$tp_item->TPSL_nationCode]) * $rate;
}
}
@ -198,7 +199,7 @@ class Index extends CI_Controller {
$cht_total_price += 2 * 0.1;
}else{
//echo $sms_price_list[$tp_item->TPSL_nationCode];
$cht_total_price += $sms_price_list[$cht_item->nation_code] * 6.7335;
$cht_total_price += $sms_price_list[$cht_item->nation_code] * $rate;
}
}

@ -54,12 +54,15 @@
<div role="tabpanel" class="tab-pane" id="count_price">
<div class="row">
<div class="col-md-10">
<div class="col-md-8">
起始时间:<input id="from_time" class="form-control"/>
</div>
<div class="col-md-10">
<div class="col-md-8">
截止时间:<input id="to_time" class="form-control"/>
</div>
<div class="col-md-4">
汇率:<input type="text" id="rate" class="form-control"/>
</div>
<div class="col-md-4">
<a href="#" class="btn btn-default" id="get_price">查询</a>
</div>
@ -87,10 +90,11 @@ $(function(){
$('#get_price').click(function(){
var from_time = $('#from_time').val();
var to_time = $('#to_time').val();
var rate = $('#rate').val();
if(from_time != '' && to_time != ''){
$.ajax({
url:'/webht.php/apps/messagecenter/index/count_price?from_time='+from_time+'&to_time='+to_time,
url:'/webht.php/apps/messagecenter/index/count_price?from_time='+from_time+'&to_time='+to_time+'&rate='+rate,
success:function(json,status){
var data = JSON.parse(json);
$('#tp_price').html('tp费用:'+data.tp);

@ -7,6 +7,7 @@ $config["method_code"] = 15016;
/*!
* 各账号的设置
*/
$config['all_account'] = "cht,trippest";
// test
$config['test']["notify_url"] = "https://www.mycht.cn/webht.php/apps/pay/wxpayservice/notify/test";
$config['test']["app_id"] = "wx426b3015555a46be";

@ -6,6 +6,7 @@ class PaymentService extends CI_Controller {
public function __construct(){
parent::__construct();
bcscale(2);
mb_regex_encoding("UTF-8");
$this->load->helper('payment');
$this->config->load('wxpay', true);
$this->config->load('paypal', true);
@ -54,8 +55,7 @@ class PaymentService extends CI_Controller {
public function send_notify($opn_id=NULL, $old_ssje=NULL)
{
log_message('error','send_notify begin ----');
// exit();
ignore_user_abort(true);
$data = array();
$show_index = 0;
//优先处理指定的交易号,用于修正交易号直接发送通知
@ -64,7 +64,7 @@ log_message('error','send_notify begin ----');
}
// 待处理的
if (empty($data['unsend_list'])) {
$data['unsend_list'] = $this->note_model->unsend_note(10);
$data['unsend_list'] = $this->note_model->unsend_note(20);
}
//没有未处理的数据再查找处理失败的数据
if (empty($data['unsend_list'])) {
@ -73,18 +73,23 @@ log_message('error','send_notify begin ----');
// 开始处理
foreach ($data['unsend_list'] as $key => $item) {
// 只处理完成状态
if ($item->OPN_transactionResult != 'completed') {
if (mb_strtolower($item->OPN_transactionResult) !== 'completed') {
continue;
}
if ($item->OPN_noticeType == 'Refunded') {
// 退款处理
continue ;
$is_refund = false;
$ht_memo = '交易号(自动录入):' . $item->OPN_transactionId;
if (mb_strtolower($item->OPN_noticeType) == 'refund') {
$is_refund = true;
$ht_memo = '(自动)退款号:' . $item->OPN_transactionId . "\n. ";
// todo:
// $ht_memo .= '原交易号:' . $parent_dealId;
// continue ;
}
// 提取订单号
$orderid_info = analysis_orderid($item->OPN_orderId); // 先用已设置过的
if (empty($orderid_info)) {
$orderid_info = $this->method_analysis_orderid($item->OPN_accountMethod, $item->OPN_rawContent);
$orderid_info = $this->method_analysis_orderid($item);
if (empty($orderid_info)) {
$this->note_model->update_send($item->OPN_SN, $item->OPN_transactionId, 'sendfail');
continue;
@ -95,18 +100,22 @@ log_message('error','send_notify begin ----');
// 填入提取到的订单号
$this->note_model->set_invoice($item->OPN_SN, $orderid_info->orderid . '_' . $orderid_info->ordertype);
$send_email = true;
// APP自动出票的收款 跳过
if ($orderid_info->ordertype === 'A' && $item->OPN_noticeType === 'pay') {
$this->note_model->update_send($item->OPN_SN, $item->OPN_transactionId, 'closed');
continue;
$send_email = false;
// $this->note_model->update_send($item->OPN_SN, $item->OPN_transactionId, 'closed');
// continue;
}
// 开始查找订单和录入
$handpick = empty($opn_id) ? false : true;
$advisor_info = $this->account_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype, $handpick);
$ssje = $this->account_model->get_ssje($item->OPN_orderAmount, mb_strtoupper($item->OPN_currency), $item->OPN_accountMethod);
$advisor_info = $this->account_model->get_order($orderid_info->orderid, true, $orderid_info->ordertype, $handpick);
// $ssje = $this->account_model->get_ssje($item->OPN_orderAmount, mb_strtoupper($item->OPN_currency), $item->OPN_accountMethod);
$ssje = $item->OPN_entryAmountCNY;
$ssje = $old_ssje===NULL ? $ssje : $old_ssje;
$ht_memo = '交易号(自动录入):' . $item->OPN_transactionId;
$currencyCode = str_replace("CNY", "RMB", trim(mb_strtoupper($item->OPN_currency)));
$currencyCode = mb_strtoupper(trim($currencyCode));
if ( empty($advisor_info)) {
// record fail
$this->note_model->update_send($item->OPN_SN, $item->OPN_transactionId, 'sendfail');
@ -116,7 +125,8 @@ log_message('error','send_notify begin ----');
$update_note_column = array();
if ($advisor_info->order_type == 0) {
/* 商务订单 */
if (substr($advisor_info->COLI_WebCode, 0, 6) == 'CHTAPP') {
// todo: 检测收/退款是否存在
if (substr($advisor_info->COLI_WebCode, 0, 6) == 'CHTAPP' && strstr($advisor_info->COLI_WebCode, "-") !== '-biz') {
/* APP */
$this->account_model->add_account_info_forAPP(
$COLI_SN,
@ -124,7 +134,7 @@ log_message('error','send_notify begin ----');
$advisor_info->COLI_ID,
$item->OPN_orderAmount,
$item->OPN_completeTime,
mb_strtoupper($item->OPN_currency),
$currencyCode,
$ssje,
$item->OPN_completeTime,
$item->OPN_completeTime,
@ -134,7 +144,8 @@ log_message('error','send_notify begin ----');
$item->OPN_transactionId,
$ht_memo
);
if ($advisor_info->COLI_WebCode == 'CHTAPP' && $advisor_info->COLI_State == 11) {
if ($advisor_info->COLI_WebCode == 'CHTAPP' && $advisor_info->COLI_State == 11
&& false===$is_refund) {
//只修改APP组的订单状态并且订单进度是我的订单
$this->account_model->update_biz_coli_state($COLI_SN, 8); //把订单状态改为已付款
$this->account_model->insert_biz_order_log($COLI_SN, 'BS8');
@ -142,9 +153,13 @@ log_message('error','send_notify begin ----');
} else {
/* 其他商务订单 */
// 第一次录入收款记录时变更状态,记录日志
if (false == $this->account_model->if_biz_gai_exists($item->OPN_transactionId) ) {
if (false == $this->account_model->if_biz_gai_exists($item->OPN_transactionId)
&& false===$is_refund
) {
$this->account_model->update_biz_coli_state($COLI_SN, 13);
$this->account_model->insert_biz_order_log($COLI_SN, 'BS13');
} else {
$this->account_model->insert_biz_order_log($COLI_SN, 'Refunded');
}
$this->account_model->add_account_info(
$COLI_SN,
@ -152,7 +167,7 @@ log_message('error','send_notify begin ----');
$advisor_info->COLI_ID,
$item->OPN_orderAmount,
$item->OPN_completeTime,
mb_strtoupper($item->OPN_currency),
$currencyCode,
$ssje,
$item->OPN_completeTime,
$item->OPN_completeTime,
@ -176,7 +191,7 @@ log_message('error','send_notify begin ----');
$item->OPN_accountMethod,
$item->OPN_orderAmount,
$item->OPN_completeTime,
mb_strtoupper($item->OPN_currency),
$currencyCode,
$ssje,
$item->OPN_completeTime,
$item->OPN_completeTime,
@ -186,10 +201,12 @@ log_message('error','send_notify begin ----');
$item->OPN_transactionId,
$ht_memo
);
if ($is_refund === false) {
//添加汉特的订单提醒
$this->account_model->update_coli_introduction($COLI_SN, '已支付 ' . mb_strtoupper($item->OPN_currency) . $item->OPN_orderAmount);
// 添加HT任务
$this->account_model->update_coli_introduction($COLI_SN, '已支付 ' . $currencyCode . $item->OPN_orderAmount);
// 收款:添加HT任务
$this->account_model->exec_addToTask($gai_sn);
}
// 更新note
$update_note_column['OPN_accountType'] = 'B';
$update_note_column['OPN_accountStatus'] = 'recorded';
@ -200,6 +217,10 @@ log_message('error','send_notify begin ----');
$where = " OPN_SN=" . $item->OPN_SN;
$this->note_model->update_note($where, $update_note_column);
}
if ($send_email===false) {
$this->note_model->update_send($item->OPN_SN, $item->OPN_transactionId, 'closed');
continue; // 这里不跳出, 退款后续需要检测是否发送财务
}
// 邮件外联
$opi_email = !empty($advisor_info->OPI_Email) ? $advisor_info->OPI_Email : '';
$opi_firstname = !empty($advisor_info->OPI_FirstName) ? $advisor_info->OPI_FirstName : !empty($advisor_info->OPI_Name) ? $advisor_info->OPI_Name : '';
@ -210,6 +231,7 @@ log_message('error','send_notify begin ----');
}
//添加邮件发送记录
//给外联发送通知邮件
if ($send_email===true && $handpick===false && $item->OPN_noticeSendStatus !== 'send' && substr($item->OPN_noticeSendStatus, 0, 5) !== 'send-') {
$fromName = !empty($item->OPN_payerName) ? $item->OPN_payerName : '';
$fromEmail = !empty($item->OPN_payerEmail) ? $item->OPN_payerEmail : '';
$toName = !empty($opi_firstname) ? $opi_firstname : '';
@ -221,9 +243,14 @@ log_message('error','send_notify begin ----');
$M_State = 0;
$this->account_model->save_automail($fromName, $fromEmail, $toName, $toEmail, $subject, $body, $M_RelatedInfo, $M_State, $M_AddTime, 'payment note', 'payment note');
//添加邮件发送记录 end
// 2. 给客人发邮件,通知账单 todo ?? 是否需要
$this->note_model->update_send($item->OPN_SN, $item->OPN_transactionId, 'send');
}
// 2. 给客人发邮件,通知账单
// todo:iPaylinks需要发收款, 退款发所有
// 3. 更新是否发送财务
if($is_refund === true ) {
$this->send_refund($send_email, $item, $orderid_info, $advisor_info);
}
//显示处理记录
if (empty($opn_id)) {
@ -235,6 +262,67 @@ log_message('error','send_notify begin ----');
// return $this->output->set_content_type('application/json')->set_output(json_encode($data));
}
public function send_refund($send_email, $item, $orderid_info, $advisor_info)
{
// 发送客人
if ($send_email===true
&& $item->OPN_noticeSendStatus !== 'send' && substr($item->OPN_noticeSendStatus, 0, 5) !== 'send-'
) {
// 客人邮件中的外联落款
// $web_code = 'cht'; // 默认cht
$web_lgc = 1;
$web_code = strtolower($advisor_info->COLI_WebCode);
$site_info = $this->config->item('site');
if (isset($site_info[$web_code])) {
$site_info = $site_info[$web_code];
$item->site = $site_info['site_url'];
$web_lgc = $site_info['site_lgc'];
}
$advisor_detail = $this->account_model->get_advisor_detail($advisor_info->COLI_SN, $advisor_info->OPI_SN, $web_lgc);
$item->advisor_detail = $advisor_detail;
$customer_detail = $this->account_model->get_customer_detail($advisor_info->COLI_SN, $orderid_info->ordertype);
$c_fromName = $advisor_detail->fullname;
$opi_email_list = explode(";", $advisor_detail->email); // 解析外联的邮件
$c_fromEmail = trim($opi_email_list[0]);
$c_toName = $customer_detail->fullname;
$c_toEmail = $customer_detail->email;
$c_subject = mb_strtoupper($item->OPN_currency) . " " . str_replace('-', '', $item->OPN_orderAmount) . " Refunded to your account, booking number " . $item->OPN_orderId;
// 修改一些字段名, 为了和Alipay等用同一个邮件模板
$item->payer = $customer_detail->fullname;
$item->payer_email = $customer_detail->email;
$item->total_amount = $item->OPN_orderAmount;
$item->payment_date = $item->OPN_completeTime;
$item->payment_status = "Refunfed";
$item->currency = mb_strtoupper($item->OPN_currency);
$item->invoice = $item->OPN_orderId;
$c_body = $this->load->view('refund_buyer', $item, true);
$c_M_RelatedInfo = $item->OPN_SN;
$c_M_AddTime = $item->OPN_completeTime;
$c_M_State = 0;
$this->account_model->save_automail(
$c_fromName,
$c_fromEmail,
$c_toName,
$c_toEmail,
$c_subject,
$c_body,
$c_M_RelatedInfo,
$c_M_State,
$c_M_AddTime,
'ChinaHighlights refund receipt',
'payment note');
$this->note_model->update_send($item->OPN_SN, $item->OPN_transactionId, 'send-customer');
}
// 更新是否需要发送财务
$refund_finance_day = 20;
$now_day = date('d');
$late_entry_date_set = $now_day<$refund_finance_day ? date('Y-m-01', strtotime("-1 month")) : date('Y-m-01');
if ($this->account_model->if_finance_done($advisor_info->COLI_GRI_SN, $late_entry_date_set) === true) {
$this->note_model->update_send($item->OPN_SN, $item->OPN_transactionId, 'send-to-finance');
}
return;
}
/** 支付方式参数对应的配置文件名 */
/** @Deprecated */
public function method_name($name)
@ -261,11 +349,12 @@ log_message('error','send_notify begin ----');
return $config_name;
}
private function method_analysis_orderid($name, $raw_content)
private function method_analysis_orderid($opn_obj)
{
$content_obj = json_decode($raw_content);
// $orderid_info = $this->method_analysis_orderid($item->OPN_accountMethod, $item->OPN_rawContent);
$content_obj = json_decode($opn_obj->OPN_rawContent);
$orderid_info = array();
switch (strval($name)) {
switch (strval($opn_obj->OPN_accountMethod)) {
case '15002':
case '15010': // paypal
$orderid_info = analysis_orderid($content_obj->invoice);
@ -279,6 +368,9 @@ log_message('error','send_notify begin ----');
case '15016': // wxpay
$orderid_info = analysis_orderid($content_obj->out_trade_no);
if (empty($orderid_info) && $opn_obj->OPN_fundSource==='cht' && $content_obj->trade_type==='APP') {
$orderid_info = analysis_orderid($content_obj->out_trade_no . "_A");
}
break;
// TODO
case '15018': // iPaylinks

@ -24,7 +24,7 @@ class WxpayService extends CI_Controller {
public function notify($site='cht')
{
error_reporting(0);
log_message('error','notify begin ----');
// log_message('error','notify begin ----');
$response['return_code'] = 'FAIL';
$response['return_msg'] = '';
$GLOBALS['__WX_SITE_NAME__'] = $site;
@ -48,7 +48,7 @@ log_message('error','notify begin ----');
$response['return_msg'] = 'OK';
} else {
$xml_arr['total_fee'] = bcdiv($xml_arr['total_fee'], $this->config->item('currency_unit', 'wxpay'));
$ssje = $this->account_model->get_ssje($xml_arr['total_fee'], $xml_arr['fee_type'], $this->config->item('currency_unit', 'wxpay'));
$ssje = $this->account_model->get_ssje($xml_arr['total_fee'], str_replace("CNY", "RMB", strtoupper($xml_arr['fee_type'])), $this->config->item('method_code', 'wxpay'));
$save_column = array();
$save_column['OPN_transactionId'] = $xml_arr['transaction_id'];
$save_column['OPN_orderId'] = $xml_arr['out_trade_no'];
@ -58,7 +58,7 @@ log_message('error','notify begin ----');
$save_column['OPN_currency'] = $xml_arr['fee_type'];
$save_column['OPN_orderAmount'] = $xml_arr['total_fee'];
$save_column['OPN_payAmount'] = $xml_arr['total_fee'];
$save_column['OPn_transactionResult'] = 'completed';
$save_column['OPN_transactionResult'] = 'completed';
$save_column['OPN_resultCode'] = $xml_arr['result_code'];
$save_column['OPN_resultMsg'] = isset($xml_arr['return_msg']) ? $xml_arr['return_msg'] : $xml_arr['result_code'];
$save_column['OPN_errCode'] = isset($xml_arr['err_code']) ? $xml_arr['err_code'] : NULL;
@ -68,7 +68,7 @@ log_message('error','notify begin ----');
$save_column['OPN_remark'] = $xml_arr['attach'];
$save_column['OPN_payerLogId'] = $xml_arr['openid'];
$save_column['OPN_payerStatus'] = $xml_arr['is_subscribe']==='Y' ? "subscribed" : NULL;
$save_column['OPN_fundSource'] = $xml_arr['bank_type'];
$save_column['OPN_fundSource'] = $site;
$save_column['OPN_entryAmountCNY'] = floatval($ssje);
$save_column['OPN_rawContent'] = json_encode($xml_arr);
$save_column['OPN_noticeTime'] = date('Y-m-d H:i:s');
@ -85,12 +85,79 @@ log_message('error','notify begin ----');
return $this->response_to_wx($response);
}
public function download_all_bill()
{
$all_account = explode(",", $this->config->item('all_account', 'wxpay'));
foreach ($all_account as $account) {
$this->download_bill($account);
}
return;
}
public function download_bill($target_account)
{
$GLOBALS['__WX_SITE_NAME__'] = $target_account;
// 只能下载最近三个月内的账单
$bill_date = $this->input->get_post("date");
$bill_date = $bill_date ? $bill_date : date("Ymd", strtotime("-1 day"));
$bill_type = 'ALL';
$this->load->model('WxpayQueryContentBuilder', 'query_builder');
$this->query_builder->set_bill_date($bill_date);
$this->query_builder->set_bill_type($bill_type);
$this->load->library('Wxpay_call');
$result = $this->wxpay_call->get_bill_data($this->query_builder);
if ($result['status'] !== true) {
log_message('error',"get wxpay bill failed. $target_account $bill_date");
}
foreach ($result['data'] as $key => $row) {
$save_column = array();
$save_column['OPN_accountMethod'] = $this->config->item('method_code', 'wxpay');
if ($row['refund_id'] != '0') {
// 退款
$ssje = $this->account_model->get_ssje($row['settlement_refund_fee'], str_replace("CNY", "RMB", strtoupper($row['currency_type'])), $save_column['OPN_accountMethod']);
$save_column['OPN_transactionId'] = $row['refund_id'];
$save_column['OPN_orderAmount'] = "-" . $row['settlement_refund_fee'];
$save_column['OPN_payAmount'] = "-" . $row['settlement_refund_fee'];
$save_column['OPN_resultCode'] = $row['refund_status'];
$save_column['OPN_resultMsg'] = $row['refund_status'];
$save_column['OPN_entryAmountCNY'] = floatval("-" . $ssje);
$save_column['OPN_noticeType'] = 'refund';
} else {
// 收款
$ssje = $this->account_model->get_ssje($row['settlement_total_fee'], str_replace("CNY", "RMB", strtoupper($row['currency_type'])), $save_column['OPN_accountMethod']);
$save_column['OPN_transactionId'] = $row['transaction_id'];
$save_column['OPN_orderAmount'] = $row['settlement_total_fee'];
$save_column['OPN_payAmount'] = $row['settlement_total_fee'];
$save_column['OPN_resultCode'] = $row['trade_state'];
$save_column['OPN_resultMsg'] = $row['trade_state'];
$save_column['OPN_entryAmountCNY'] = floatval($ssje);
$save_column['OPN_noticeType'] = 'pay';
}
$save_column['OPN_noticeSendStatus'] = 'unsend';
$save_column['OPN_transactionResult'] = 'completed';
$save_column['OPN_orderId'] = $row['out_trade_no'];
$save_column['OPN_rawOrderId'] = $row['out_trade_no'];
$save_column['OPN_invoiceId'] = $row['out_trade_no'];
$save_column['OPN_subject'] = $row['item_name'];
$save_column['OPN_currency'] = $row['currency_type'];
$save_column['OPN_acquiringTime'] = date('Y-m-d H:i:s',strtotime($row['complete_time']));
$save_column['OPN_completeTime'] = date('Y-m-d H:i:s',strtotime($row['complete_time']));
$save_column['OPN_remark'] = $row['attach'];
$save_column['OPN_payerLogId'] = $row['openid'];
$save_column['OPN_fundSource'] = $target_account;
$save_column['OPN_rawContent'] = json_encode($row);
$save_column['OPN_noticeTime'] = date('Y-m-d H:i:s');
$this->note_model->insert_note($save_column) ;
}
return;
}
public function response_to_wx($response_arr)
{
$response_body = to_xml($response_arr);
// log_message('error',var_export($response_body, 1));
echo $response_body;
# exit(); // end
}
public function check_sign($xml_arr)

@ -138,6 +138,8 @@ function analysis_orderid($note_invoice_string) {
$ordertype = 'T';
} elseif (substr($ordertype_temp, 0, 1) == 'B') {
$ordertype = 'B';
} elseif (substr($ordertype_temp, 0, 1) == 'A') {
$ordertype = 'A';
}
}
// 2018.05.28 for Trippest, tourMaster的订单号是01开头

@ -0,0 +1,282 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Wxpay_call
{
protected $ci;
private $api_info_arr = array();
public function __construct()
{
$this->ci =& get_instance();
$this->ci->load->helper('payment');
$this->ci->config->load('wxpay', true);
// $this->ci->load->model('WxpayQueryContentBuilder', 'query_builder');
}
private function init_api()
{
$this->wx_site_config = $this->ci->config->item($GLOBALS['__WX_SITE_NAME__'], 'wxpay');
$this->api_info_arr['appid'] = $this->wx_site_config['app_id'];
$this->api_info_arr['mch_id'] = $this->wx_site_config['mch_id'];
$this->api_info_arr['key'] = $this->wx_site_config['key'];
$this->api_info_arr['app_secret'] = $this->wx_site_config['app_secret'];
}
/**
* 下载对账单WxPayDownloadBill中bill_date为必填参数
* appid、mchid、spbill_create_ip、nonce_str不需要填入
* @param WxPayDownloadBill $inputObj
* @param int $timeOut
* @throws WxPayException
* @return 成功时返回,其他抛异常
*/
public function get_bill_data($query_content)
{
$ret = array('status'=>false, 'data'=>array());
$this->init_api();
// return false;
$url = "https://api.mch.weixin.qq.com/pay/downloadbill";
$query_content_input = $query_content->getBizContent(true);
//检测必填参数
if(!$query_content_input['bill_date']) {
throw new WxPayException("对账单接口中缺少必填参数bill_date");
}
$this->api_info_arr['nonce_str'] = ($this->get_nonce_str());//随机字符串
$this->api_info_arr['sign'] = $this->make_sign(array_merge($this->api_info_arr, $query_content_input));//签名
$xml = to_xml(array_merge($this->api_info_arr, $query_content_input));
$response = $this->post_xml_curl($this->api_info_arr, $xml, $url, 20);
if(substr($response, 0 , 5) == "<xml>"){
log_message('error',"Wxpay bill error \r\n" . var_export($response, 1));
return $ret;
}
$ret['status'] = true;
$response_arr = explode("\n",$response);
$data_title = $this->bill_data_title();
for ($i=1; $i < count($response_arr)-1; $i++) {
if (empty($response_arr[$i])) {
continue;
}
$row = explode(",", $response_arr[$i]);
$row_arr = array();
foreach ($data_title as $key => $title) {
if ( ! isset($row[$key])) {
continue;
}
$row_arr[$title] = str_replace("`","",trim($row[$key]));
}
!empty($row_arr['trade_type']) ? $ret['data'][] = $row_arr : false;
}
return $ret;
}
/*!
* @Author: LYT
* @Date: 2019-06-18 15:23:15
* @Desc: 账单数据的格式
* 交易时间,公众账号ID,商户号,特约商户号,设备号,微信订单号,商户订单号,用户标识,交易类型,交易状态,付款银行,货币种类,应结订单金额,代金券金额,微信退款单号,商户退款单号,退款金额,充值券退款金额,退款类型,退款状态,商品名称,商户数据包,手续费,费率,订单金额,申请退款金额,费率备注
*/
private function bill_data_title()
{
return array(
"complete_time", // 交易时间
"app_id", // 公众账号ID
"mch_id", // 商户号
"special_mch_id", // 特约商户号
"device_info", // 设备号
"transaction_id", // 微信订单号
"out_trade_no", // 商户订单号
"openid", // 用户标识
"trade_type", // 交易类型
"trade_state", // 交易状态
"bank_type", // 付款银行
"currency_type", // 货币种类
"settlement_total_fee", // 应结订单金额
"coupon_fee", // 代金券金额
"refund_id", // 微信退款单号
"out_refund_id",// 商户退款单号
"settlement_refund_fee", // 退款金额
"refund_coupon_fee", // 充值券退款金额
"refund_type", // 退款类型
"refund_status", // 退款状态
"item_name", // 商品名称
"attach", // 商户数据包
"wxpay_fee", // 手续费
"rate", // 费率
"total_fee", // 订单金额
"call_refund_fee", // 申请退款金额
"rate_memo" // 费率备注
);
}
/**
* 以post方式提交xml到对应的接口url
*
* @param WxPayConfigInterface $config 配置对象
* @param string $xml 需要post的xml数据
* @param string $url url
* @param bool $useCert 是否需要证书,默认不需要
* @param int $second url执行超时时间默认30s
* @throws WxPayException
*/
private function post_xml_curl($config, $xml, $url, $second = 30)
{
$ch = curl_init();
$curlVersion = curl_version();
$ua = "WXPaySDK/3.0.9 (".PHP_OS.") PHP/".PHP_VERSION." CURL/".$curlVersion['version']." "
.$config['mch_id'];
//设置超时
curl_setopt($ch, CURLOPT_TIMEOUT, $second);
curl_setopt($ch,CURLOPT_URL, $url);
// curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,TRUE);
// curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2);//严格校验
if(stripos($url,"https://")!==FALSE){
curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
} else {
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,TRUE);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2);//严格校验
}
curl_setopt($ch,CURLOPT_USERAGENT, $ua);
//设置header
curl_setopt($ch, CURLOPT_HEADER, FALSE);
//要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
//post提交方式
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
//运行curl
$data = curl_exec($ch);
//返回结果
if($data){
curl_close($ch);
return $data;
} else {
$error = curl_errno($ch);
log_message('error',"curl出错错误码:$error " . curl_error($ch));
curl_close($ch);
}
}
public function check_sign($xml_arr)
{
if ( ! array_key_exists('sign', $xml_arr)) {
log_message('error','Wxpay notify error: no sign.');
return false;
}
if ($this->make_sign($xml_arr) !== $xml_arr['sign']) {
log_message('error','Wxpay notify error: sign.' . $this->make_sign($xml_arr));
return false;
}
if ($this->wx_site_config['app_id'] !== $xml_arr['appid']) {
log_message('error','Wxpay notify error: appid.');
return false;
}
if ($this->wx_site_config['mch_id'] !== $xml_arr['mch_id']) {
log_message('error','Wxpay notify error: mch_id.');
return false;
}
return true;
}
public function make_sign($xml_arr, $needSignType = false)
{
//签名步骤一:按字典序排序参数
ksort($xml_arr);
$string = $this->to_url_params($xml_arr);
//签名步骤二在string后加入KEY
$string = $string . "&key=" . $this->wx_site_config['key'];
//签名步骤三MD5加密或者HMAC-SHA256
if(!isset($xml_arr['sign']) || strlen($xml_arr['sign']) <= 32){
//如果签名小于等于32个,则使用md5验证
$string = md5($string);
} else {
//是用sha256校验
$string = hash_hmac("sha256", $string , $this->wx_site_config['key']);
}
//签名步骤四:所有字符转为大写
$result = strtoupper($string);
return $result;
}
/**
* 格式化参数格式化成url参数
*/
public function to_url_params($xml_arr)
{
$buff = "";
foreach ($xml_arr as $k => $v)
{
if($k != "sign" && $v != "" && !is_array($v)){
$buff .= $k . "=" . $v . "&";
}
}
$buff = trim($buff, "&");
return $buff;
}
/**
* 产生随机字符串不长于32位
* @param int $length
* @return 产生的随机字符串
*/
public static function get_nonce_str($length = 32)
{
$chars = "abcdefghijklmnopqrstuvwxyz0123456789";
$str ="";
for ( $i = 0; $i < $length; $i++ ) {
$str .= substr($chars, mt_rand(0, strlen($chars)-1), 1);
}
return $str;
}
protected function curl($url, $postFields = null) {
$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);
$postBodyString = "";
if (is_array($postFields) && 0 < count($postFields)) {
foreach ($postFields as $k => $v) {
if ("@" != substr($v, 0, 1)) //判断是不是文件上传
{
$postBodyString .= "$k=" . urlencode($this->characet($v, "UTF-8")) . "&";
}
}
unset($k, $v);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, substr($postBodyString, 0, -1));
}
$headers = array('content-type: application/x-www-form-urlencoded;charset=UTF-8');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$reponse = curl_exec($ch);
if (curl_errno($ch)) {
log_message('error', " iPayLinks curl error code: ".curl_error($ch)."; curl postBodyString: ".substr($postBodyString, 0, -1));
} else {
$httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (200 !== $httpStatusCode) {
log_message('error', " iPayLinks Request html Status Code: ".$httpStatusCode."; curl postBodyString: ".substr($postBodyString, 0, -1));
}
}
curl_close($ch);
return $reponse;
}
}
/* End of file Wxpay_call.php */

@ -17,6 +17,7 @@ class Online_payment_account_model extends CI_Model {
$sql = "SELECT dbo.GetSSJEFromSQJE(?, ?, ?) as ssje";
$query = $this->HT->query($sql,array($code, $currency, $amount));
$result = $query->result();
if ( ! empty($result)) {
return $result[0]->ssje;
}
@ -96,8 +97,15 @@ class Online_payment_account_model extends CI_Model {
return $result;
}
public function if_biz_gai_exists($GAI_AccreditNo)
public function if_biz_gai_exists($GAI_AccreditNo, $is_app=false, $coli_sn=null, $je=null, $type=null)
{
if ($is_app===true && $coli_sn!==null) {
$sql = " SELECT TOP 1 1
FROM BIZ_GroupAccountInfo
WHERE GAI_COLI_SN = ? AND GAI_SQJE=? AND DeleteFlag=0 AND GAI_Type=?";
$result = $this->HT->query($sql, array($coli_sn, $je, $type));
return ($result->num_rows() > 0);
}
$sql = " SELECT TOP 1 1 FROM BIZ_GroupAccountInfo
WHERE (GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%')
AND DeleteFlag=0";
@ -338,7 +346,25 @@ class Online_payment_account_model extends CI_Model {
inner join Tourmanager.dbo.CK_GroupInfo cgi on gz.GZD_CGI_SN=cgi.CGI_SN
where ISNULL(GZD_DeleteFlag,0)=0 and isnull(DelFlag,0)=0
and cgi.CGI_GRI_SN=? ";
return $this->HT->query($sql, $gri_sn)->num_rows() > 0;
return $this->HT->query($sql, array($gri_sn))->num_rows() > 0;
}
// 商务订单没有生成团信息
public function if_finance_done($gri_sn, $late_date)
{
$sql = "SELECT top 1 1
from groupinfo gri
where GRI_SN=?
and GRI_EntranceDate < ?
";
if ($this->HT->query($sql, array($gri_sn,$late_date))->num_rows() === 0) {
$sql = "SELECT top 1 1
from BIZ_ConfirmLineInfo coli
inner join BIZ_ConfirmLineDetail cold on COLD_COLI_SN=COLI_SN and isnull(cold.DeleteFlag,0)=0
where COLI_GRI_SN=?
and COLD_StartDate<?";
return $this->HT->query($sql, array($gri_sn,$late_date))->num_rows() > 0;
}
return false;
}
/*!
@ -426,5 +452,49 @@ class Online_payment_account_model extends CI_Model {
return $this->HT->query($sql, $note_sn);
}
public function get_advisor_detail($COLI_SN, $OPI_SN, $lgc=1)
{
$advisor_signature = $this->get_advisor_signature($COLI_SN);
if (empty($advisor_signature)) {
$sql = "SELECT OPI_SN, '+86-'+OPI_MoveTelephone mobile,'+86-773-'+OPI_Telephone tel,OPI_Email email,OPI2_Name fullname,OPI2_FirstName,OPI2_LastName
FROM [Tourmanager].[dbo].[V_Operator_Info]
where OPI_SN=? and LGC_LGC=? ";
$advisor_signature = $this->HT->query($sql, array($OPI_SN, $lgc))->row();
}
return $advisor_signature;
}
public function get_advisor_signature($COLI_SN)
{
$sql = "SELECT top 1 dbo.agenter_user.Name fullname, dbo.agenter_user.tel,
dbo.agenter_user.Email email, dbo.agenter_user.mobile, OPI_DEI_SN, COLI_OPI_ID
FROM dbo.BIZ_ConfirmLineInfo
INNER JOIN dbo.agenter_user ON dbo.BIZ_ConfirmLineInfo.COLI_OPI_ID = dbo.agenter_user.AU_OPI_SN
AND
(dbo.BIZ_ConfirmLineInfo.COLI_WebCode = dbo.agenter_user.agenter
OR (COLI_WebCode in ('EXPCH','MESENLLA','traba','wayaway','guias') and agenter='VAC')
)
LEFT JOIN OperatorInfo on COLI_OPI_ID = OPI_SN
WHERE (dbo.BIZ_ConfirmLineInfo.COLI_SN = ?)";
return $this->HT->query($sql, array($COLI_SN))->row();
}
public function get_customer_detail($COLI_SN, $ordertype)
{
if ($ordertype === 'T') {
$sql = "SELECT mei.MEI_FirstName+' '+isnull(mei.MEI_MiddleName,'')+' '+isnull(mei.MEI_LastName,'') fullname,
mei.MEI_MailList email
FROM MEmberInfo mei
INNER JOIN CUstomerList cul on mei.MEI_SN=cul.CUL_CUI_SN --and cul.CUL_IsLinkMan=1
WHERE CUL_COLI_SN=? and isnull(mei.MEI_MailList,'')<>''
order by cul.CUL_IsLinkMan desc";
return $this->HT->query($sql, $COLI_SN)->row();
} else {
$sql = "SELECT GUT_FirstName+' '+GUT_LastName fullname,GUT_Email email from BIZ_GUEST g
INNER JOIN BIZ_ConfirmLineInfo coli on coli.COLI_GUT_SN=g.GUT_SN
WHERE COLI_SN=? ";
return $this->HT->query($sql, $COLI_SN)->row();
}
}
}

@ -0,0 +1,56 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class WxpayQueryContentBuilder extends CI_Model
{
private $appid; // 微信分配的公众账号ID
private $mch_id; // 微信支付分配的商户号
private $nonce_str; // 随机字符串不长于32位。推荐随机数生成算法
private $sign; // 签名,详见签名生成算法
private $bill_date; // 下载对账单的日期格式20140603
private $bill_type;
/*
ALL默认值返回当日所有订单信息不含充值退款订单
SUCCESS返回当日成功支付的订单不含充值退款订单
REFUND返回当日退款订单不含充值退款订单
RECHARGE_REFUND返回当日充值退款订单
*/
private $tar_type; // 非必传参数固定值GZIP返回格式为.gzip的压缩包账单。不传则默认为数据流形式。
private $bizContentarr = array();
private $bizContent = NULL;
public function getBizContent($arr=false)
{
if(!empty($this->bizContentarr)){
$this->bizContent = json_encode($this->bizContentarr); // 5.4增加的常量 JSON_UNESCAPED_UNICODE
}
$ret = ($arr===false) ? $this->bizContent : $this->bizContentarr ;
return $ret;
}
public function set_bill_date($bill_date)
{
$this->bill_date = $bill_date;
$this->bizContentarr['bill_date'] = $bill_date;
}
public function set_bill_type($bill_type)
{
$this->bill_type = $bill_type;
$this->bizContentarr['bill_type'] = $bill_type;
}
public function set_tar_type($tar_type)
{
$this->tar_type = $tar_type;
$this->bizContentarr['tar_type'] = $tar_type;
}
}
/* End of file WxpayQueryContentBuilder.php */
?>

@ -115,7 +115,14 @@
<img width="150" style="height:40px;" src="/css/nav/img/6000.png">
</a>
<h1>Payment List</h1>
<a class="text-muted" href="#">微信</a>
&NonBreakingSpace;
<a href="http://www.mycht.cn/webht.php/apps/paypal/index/note_list">PayPal&raquo;</a>
&NonBreakingSpace;
<a href="https://www.mycht.cn/webht.php/apps/pay/ipaylinksservice/note_list">信用卡&raquo;</a>
&NonBreakingSpace;
<a href="https://www.mycht.cn/webht.php/apps/pay/AlipayTradeService/index">支付宝&raquo;</a>
&NonBreakingSpace;
<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>
@ -200,7 +207,7 @@
if ($item->OPN_accountStatus !== 'recorded') {
$send_class = 'btn-danger';
}
if ($item->OPN_noticeSendStatus !== 'send' ) {
if ($item->OPN_noticeSendStatus !== 'send' && substr($item->OPN_noticeSendStatus, 0, 5) !== 'send-') {
$send_class = 'btn-danger';
}
if ($item->OPN_noticeSendStatus === 'closed') {

@ -834,10 +834,15 @@ class Index extends CI_Controller {
// $this->Note_model->update_send($item->pn_txn_id, 'send');
continue;
}
// 撤销付款:允许手动处理
if (strtolower($item->pn_payment_status) == 'reversed' && $handpick===true ) {
$this->send_refund($item, $handpick, $old_ssje);
continue;
}
//只处理完成状态,其他状态由陆燕处理
if (strtolower($item->pn_payment_status) !== 'completed') {
$this->Note_model->update_send($item->pn_txn_id, 'sendfail');
$this->Note_model->update_send($item->pn_txn_id, 'sendfail', $item->pn_sn);
continue;
}
@ -859,7 +864,7 @@ class Index extends CI_Controller {
//找不到订单号,设置为发送失败标示
if (empty($orderid_info)) {
$this->Note_model->update_send($item->pn_txn_id, 'sendfail');
$this->Note_model->update_send($item->pn_txn_id, 'sendfail', $item->pn_sn);
continue;
}
$orderid_info = json_decode($orderid_info);
@ -895,7 +900,7 @@ class Index extends CI_Controller {
//查不到订单信息
if (empty($advisor_info)) {
$this->Note_model->update_send($item->pn_txn_id, 'sendfail');
$this->Note_model->update_send($item->pn_txn_id, 'sendfail', $item->pn_sn);
continue;
}
@ -968,12 +973,12 @@ class Index extends CI_Controller {
//没有外联信息表示订单未分配
if (empty($opi_email) || empty($opi_firstname)) {
$this->Note_model->update_send($item->pn_txn_id, 'sendfail');
$this->Note_model->update_send($item->pn_txn_id, 'sendfail', $item->pn_sn);
continue;
}
//添加邮件发送记录
if ($item->pn_send !== 'send' && false===$is_webhook) {
if ( ($item->pn_send !== 'send' && false===$is_webhook ) || true===$handpick) {
//给外联发送通知邮件
$fromName = !empty($item->pn_payer) ? $item->pn_payer : '';
$fromEmail = !empty($item->pn_payer_email) ? $item->pn_payer_email : '';
@ -987,9 +992,9 @@ class Index extends CI_Controller {
$this->Paypal_model->save_automail($fromName, $fromEmail, $toName, $toEmail, $subject, $body, $M_RelatedInfo, $M_State, $M_AddTime, 'paypal note');
//添加邮件发送记录 end
$this->Note_model->update_send($item->pn_txn_id, 'send');
$this->Note_model->update_send($item->pn_txn_id, 'send', $item->pn_sn);
} else {
$this->Note_model->update_send($item->pn_txn_id, 'send');
$this->Note_model->update_send($item->pn_txn_id, 'send', $item->pn_sn);
}
}
//echo 'done!';
@ -1106,9 +1111,9 @@ class Index extends CI_Controller {
$this->Paypal_model->save_automail($fromName, $fromEmail, $toName, $toEmail, $subject, $body, $M_RelatedInfo, $M_State, $M_AddTime, 'paypal note');
// 通知客人, 客人邮箱
$customer_detail = $this->Paypal_model->get_customer_detail($advisor_info->COLI_SN, $orderid_info->ordertype);
$c_fromName = $advisor_detail->fullname;
$c_fromName = $advisor_detail->fullname ? $advisor_detail->fullname : $opi_firstname;
$opi_email_list = explode(";", $advisor_detail->email); // 解析外联的邮件
$c_fromEmail = trim($opi_email_list[0]);
$c_fromEmail = isset($opi_email_list[0]) ? trim($opi_email_list[0]) : $opi_email;
$c_toName = $customer_detail->fullname;
$c_toEmail = $customer_detail->email;
$c_subject = $item->pn_mc_currency . " " . str_replace('-', '', $item->pn_mc_gross) . " Refunded to your account, booking number " . $item->pn_invoice;
@ -1127,12 +1132,12 @@ class Index extends CI_Controller {
$c_M_State,
$c_M_AddTime,
'ChinaHighlights refund receipt');
$this->Note_model->update_send($item->pn_txn_id, 'send-customer');
$this->Note_model->update_send($item->pn_txn_id, 'send-customer', $item->pn_sn);
}
//添加邮件发送记录 end
// 如果已做账, 标记需要通知财务send-to-finance, 通知时间用订单日志记录
if ($this->Paypal_model->if_finance_exists($advisor_info->COLI_GRI_SN)===true) {
$this->Note_model->update_send($item->pn_txn_id, 'send-to-finance');
$this->Note_model->update_send($item->pn_txn_id, 'send-to-finance', $item->pn_sn);
}
return ;
}
@ -1206,7 +1211,7 @@ class Index extends CI_Controller {
$send_type = "send";
}
$this->Note_model->update_send($paypal_msg->pn_txn_id, $send_type);
$this->Note_model->update_send($paypal_msg->pn_txn_id, $send_type, $paypal_msg->pn_sn);
}
//所有记录列表
@ -1602,7 +1607,7 @@ class Index extends CI_Controller {
$M_State = 0;
$this->Paypal_model->save_automail($fromName, $fromEmail, $toName, $toEmail, $subject, $body, $M_RelatedInfo, $M_State, $M_AddTime, 'paypal note');
//添加邮件发送记录 end
$this->Note_model->update_send($item->pn_txn_id, 'send');
$this->Note_model->update_send($item->pn_txn_id, 'send', $item->pn_sn);
}
$order_gai = $this->Paypal_model->get_money_list($orderid_info->orderid);
return empty($order_gai);

@ -647,8 +647,10 @@ class Paypal_model extends CI_Model {
$sql = "SELECT mei.MEI_FirstName+' '+isnull(mei.MEI_MiddleName,'')+' '+isnull(mei.MEI_LastName,'') fullname,
mei.MEI_MailList email
FROM MEmberInfo mei
INNER JOIN CUstomerList cul on mei.MEI_SN=cul.CUL_CUI_SN and cul.CUL_IsLinkMan=1
WHERE CUL_COLI_SN=? ";
INNER JOIN CUstomerList cul on mei.MEI_SN=cul.CUL_CUI_SN -- and cul.CUL_IsLinkMan=1
WHERE CUL_COLI_SN=?
and isnull(mei.MEI_MailList,'')<>''
order by cul.CUL_IsLinkMan desc";
return $this->HT->query($sql, $COLI_SN)->row();
} else {
$sql = "SELECT GUT_FirstName+' '+GUT_LastName fullname,GUT_Email email from BIZ_GUEST g

@ -156,7 +156,7 @@ class Order_finance extends CI_Controller {
$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['tourname'] = mb_convert_encoding(substr($cpvt->pag_name, 0, 200), 'UTF-8');
$report_tour_pvt['tourtime'] = $cpvt->startdate;
$report_tour_pvt['tourRSd'] = $cpvt->adult_num;
$report_tour_pvt['tourRSx'] = $cpvt->child_num;
@ -190,7 +190,7 @@ class Order_finance extends CI_Controller {
$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'] = mb_substr($cost->pag_name, 0, 200) ;
$cost_c['tourname'] = mb_convert_encoding( substr($cost->pag_name, 0, 200), 'UTF-8') ;
$cost_c['tourtime'] = $cost->startdate;
$cost_c['tourRSd'] = $cost->order_cost[0]->adult_num;
$cost_c['tourRSx'] = $cost->order_cost[0]->child_num;
@ -417,7 +417,7 @@ class Order_finance extends CI_Controller {
$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_name = implode("; ", 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) : "";
@ -486,7 +486,7 @@ class Order_finance extends CI_Controller {
$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)) ;
$ret->pag_name = implode("; ", 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));
}

@ -276,9 +276,7 @@ class OrderFinance_model extends CI_Model {
// $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;
}

@ -176,8 +176,8 @@ class Orders_model extends CI_Model {
public function get_groupCombineInfo_finance()
{
// return array(); // 历史数据已获取完毕
$to_update_month_begin = date('Y-m-01', strtotime("-4 months", strtotime(date("Y-m-d"))));
$to_update_month_end = date('Y-m-01', strtotime("-3 months", strtotime(date("Y-m-d"))));
$to_update_month_begin = date('Y-m-01', strtotime("-3 months", strtotime(date("Y-m-d"))));
$to_update_month_end = date('Y-m-01', strtotime("-2 months", strtotime(date("Y-m-d"))));
$end_d = strtotime($to_update_month_end)-1;
$to_update_month_end = date("Y-m-d 23:59:59", $end_d);
$set_time = date("Y-m-d 00:00:00", strtotime("+50 days",$end_d));
@ -544,7 +544,7 @@ class Orders_model extends CI_Model {
$sql = "SELECT TOP 1 coli.COLI_GRI_SN,coli.COLI_SN,gci.GCI_SN
FROM GroupCombineInfo gci
INNER JOIN BIZ_ConfirmLineInfo coli ON coli.COLI_GRI_SN=gci.GCI_GRI_SN
WHERE gci.GCI_VendorOrderId='$vendorOrderId' and GCI_VEI_SN='$vendorID'";
WHERE gci.GCI_VendorOrderId='$vendorOrderId' "; // and GCI_VEI_SN='$vendorID'
$query = $this->HT->query($sql);
if ($query->row()) {
$this->BIZ_COLI_SN = $query->row()->COLI_SN;

@ -126,14 +126,17 @@ class Vendor_money_model extends CI_Model {
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,
$sql = "SELECT tmp.vendor_code ,
SUM(tmp.cost) vendor_cost
from
(
SELECT group_cost.GCI_VEI_SN vendor_code,
(SELECT SUM(CONVERT(float, gcod.GCOD_sumMoney))
FROM GroupCombineOperationDetail gcod
WHERE gcod.GCOD_GCI_combineNo=GCI_combineNo
AND gcod.GCOD_operationType <> 'otherReceives' ) AS cost ,
AND gcod.GCOD_operationType <> 'otherReceives' ) AS cost
FROM
(SELECT DISTINCT gci.GCI_combineNo,
GCI_VEI_SN
FROM GroupCombineInfo gci
WHERE 1=1
@ -145,7 +148,8 @@ class Vendor_money_model extends CI_Model {
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";
) as tmp
GROUP BY tmp.vendor_code ";
$query = $this->HT->query($sql);
return $query->result_array();
}

@ -24,9 +24,9 @@ class Index extends CI_Controller {
* * 使用供应商平台登陆账号获取接口的key
*/
public function index($GRI_SN=0)
public function index($GRI_SN=0, $vendor=null)
{
$auto_vendor_str = implode(",", $this->vendor->auto_vendor);
$auto_vendor_str = $vendor===null ? implode(",", $this->vendor->auto_vendor) : $vendor;
return $this->push($GRI_SN, $auto_vendor_str);
}

@ -27,7 +27,7 @@ class Tulanduo
)
);
/*!
* test
* test:
*/
// private $send_host = array(
// "30" => array(
@ -45,10 +45,11 @@ class Tulanduo
// 29188 95c3b0d958a79a1216e651df182b3cb4
// 30548 9db75a2dc17156eb122364295804b7a2
// test
// test:
// public $list_url = "http://ltdj.ltsoftware.net:19919/action/api/searchRouteOrder/";
// public $detail_url = "http://ltdj.ltsoftware.net:19919/action/api/detailRouteOrder/";
// public $neworder_url = "http://ltdj.ltsoftware.net:19919/action/api/addOrUpdateRouteOrder/";
// public $neworder_url = "http://ltdj.ltsoftware.net:18888/action/api/addOrUpdateRouteOrder/";
// Live
public $list_url = "http://djb3c.ltsoftware.net:9921/action/api/searchRouteOrder/";
public $detail_url = "http://djb3c.ltsoftware.net:9921/action/api/detailRouteOrder/";
@ -86,13 +87,11 @@ class Tulanduo
}
// 商务
if (strval($order->GRI_OrderType) === "227002") {
return false; // for Trippest deploy
return $this->push_biz($order, strval($order->GRI_OrderType));
return $this->push_biz($order);
}
// 传统订单
if (strval($order->GRI_OrderType) === "227001") {
return false; // for Trippest deploy
return $this->push_tour($order, strval($order->GRI_OrderType));
return $this->push_tour($order);
}
return "[Tulanduo>order_push] No function match. ";
@ -101,9 +100,8 @@ class Tulanduo
/*!
* 发送线路订单计划
*/
public function push_tour($vas=null, $gri_ordertype='227001')
public function push_tour($vas=null)
{
return false; // for Trippest deploy
$gri_sn = $vas->GRI_SN;
$vas_sn = $vas->VAS_SN;
$vei_sn = $vas->VAS_VEI_SN;
@ -130,7 +128,6 @@ class Tulanduo
$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);
}
@ -146,7 +143,7 @@ class Tulanduo
* @Date: 2019-05-30 16:11:34
* @Desc: 执行发送订单计划信息. 参数已拆分归类好的行程
*/
public function tour_apart_order_exec($group_type, $vas, $request_info, $guestlist, $grd, $total_order_index)
public function tour_apart_order_exec($group_type, $vas, $request_info, $guestlist=null, $grd, $total_order_index)
{
if (empty($grd)) {
return $total_order_index;
@ -159,8 +156,8 @@ class Tulanduo
$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 . ")";
$agcOrderNo = $vas->GRI_Name;
// $agcOrderNo .= "(" . $vas->operator . ")";
$order_type = 1;
break;
case 'pvt':
@ -169,8 +166,8 @@ class Tulanduo
$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 . ")";
$agcOrderNo = $vas->GRI_Name;
// $agcOrderNo .= "(" . $vas->operator . ")";
$order_type = 1;
break;
case 'com':
@ -187,8 +184,8 @@ class Tulanduo
$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 . ")";
$agcOrderNo = $vas->GRI_Name;
// $agcOrderNo .= "(" . $vas->operator . ")";
}
$first_date = $vo['details'][0]->day_no_raw;
$last_date = COUNT($vo['details'])-1;
@ -209,6 +206,10 @@ class Tulanduo
// ->setRoomStandard($request_info->GCI_HotelRequest) // 住房标准
->setRouteStandard($request_info->GCI_Request) // 行程服务标准
;
if ($guestlist===null) {
$g_cold_str = array_map(function ($ele){return $ele->GRD_COLD_SN;}, $vo['details']);
$guestlist = $this->ci->BIZ_order->get_guestlist(implode(',',$g_cold_str));
}
foreach ($guestlist as $key => $vg) {
$this->ci->tldOrderBuilder->setCustomersName($key, $vg->MemberName )
->setCustomersPeopleType($key, (calc_age_type($vg->BirthDay)==1 ? "成人" : "儿童"))
@ -250,16 +251,25 @@ class Tulanduo
->setScheduleDetailsDinner($kd, (trim($vgrd->GRD_Meal_S)==="" ? 0 : 1 ))
->setScheduleDetailsLunch($kd, (trim($vgrd->GRD_Meal_L)==="" ? 0 : 1 ))
;
if (isset($vgrd->hotel_checkin)) {
$this->ci->tldOrderBuilder->setRoomStandard(trim($vgrd->hotel_checkin));
}
if (isset($vgrd->to_traffic)) {
$this->ci->tldOrderBuilder->setToTraffic(trim($vgrd->to_traffic));
}
if (isset($vgrd->back_traffic)) {
$this->ci->tldOrderBuilder->setBackTraffic(trim($vgrd->back_traffic));
}
if (isset($vgrd->vendor_memo)) {
$this->ci->tldOrderBuilder->setOrderRemark(trim($vgrd->vendor_memo));
}
}
// 查询是否变更 TODO: deprecated at 2019-05
}
}
// 查询是否变更 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 */
@ -299,6 +309,10 @@ log_message('error',$resp);
{
$apart = array(); $ret = array();
foreach ($all_pag_info as $key => $pag) {
if ( ! isset($pag->PAG_DEI_SN)) {
// 通宵火车或其他, 不含该社行程
continue;
}
// 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));
@ -360,20 +374,204 @@ log_message('error',$resp);
* @Date: 2019-06-04 11:47:38
* @Desc: 发送商务订单计划
*/
public function push_biz($vas=null, $gri_ordertype='227002')
public function push_biz($vas=null)
{
$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;
$grd_info = $this->ci->Group_model->get_vendor_plan_info($gri_sn, $vei_sn);
$grd_info = $this->ci->Group_model->get_vendor_plan_info($gri_sn, $vei_sn, true);
if (empty($grd_info)) {
$this->ci->Group_model->set_plan_received($vas_sn);
return false;
}
$route_name = "";
$order_type = 1;
$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);
$coli_sn = $all_colds[0]->COLI_SN;
$train_coldsn_arr = array();$train_order = array();
$pag_coldsn_arr = array();$pag_order = array();
foreach ($all_colds as $kd => $vcold) {
if (strval($vcold->COLD_ServiceType)==='2') {
$train_coldsn_arr[] = $vcold->COLD_SN;
continue;
}
if (strval($vcold->COLD_ServiceType)==='D') {
$pag_coldsn_arr[] = $vcold->COLD_SN;
continue;
}
}
if ( ! empty($train_coldsn_arr)) {
$route_name .= $route_name==="" ? "" : "+";
$route_name .= "火车票预订";
$order_type = 1;
$train_order = $this->ci->BIZ_order->get_train_flight_order(implode(',', $train_coldsn_arr));
$agcOrderNo = $vas->GRI_Name;
$last_date = count($train_order)-1;
$end_date = strstr($train_order[$last_date]->COLD_EndDate, " ", true);
$end_date = $end_date ? $end_date : strstr($train_order[0]->COLD_StartDate, " ", true);
$this->ci->tldOrderBuilder->setUserId($userId)
->setKey($userKey)
->setOrderType($order_type)
->setRouteName($route_name)
->setRouteType("火车票预订")
->setAgcOrderNo($agcOrderNo)
->setAdultNum($train_order[0]->adult_num)
->setChildNum($train_order[0]->child_num)
->setDestination($train_order[0]->city_name)
->setTravelDate(strstr($train_order[0]->COLD_StartDate, " ", true))
->setLeavedDate($end_date)
;
$train_guest_list = $this->ci->BIZ_order->get_guestlist(implode(',', $train_coldsn_arr));
// 客人列表
foreach ($train_guest_list as $key => $vg) {
$this_otherinfo = "";
$this->ci->tldOrderBuilder->setCustomersName($key, $vg->BPE_FirstName . " " . $vg->BPE_LastName )
->setCustomersPeopleType($key, ($vg->BPE_GuestType==1 ? "成人" : "儿童"))
->setCustomersDocumentType($key, "护照") // Passport No.
->setCustomersDocumentNo($key, $vg->BPE_Passport)
;
$this_otherinfo .= $this->ci->BIZ_order->GetNationalityName($vg->BPE_Nationality);
// todo:电话
// if (trim($vf['cold'][0]->GUT_TEL) != "" && $key===0) {
// $this_otherinfo .= "; 电话:";
// $this_otherinfo .= trim($vf["cold"][0]->GUT_POST)!=="" ? "+".trim($vf["cold"][0]->GUT_POST) : "" ;
// $this_otherinfo .= " " . trim($vf["cold"][0]->GUT_TEL);
// $this->ci->tldOrderBuilder->setCustomersOtherInfo($key, $this_otherinfo);
// }
}
$s_index = 0;
foreach ($train_order as $train) {
$this_content = '';
$this_content .= $train->departure_date . " " . $train->depart_station . "-" . $train->arrival_station . " " . $train->FlightsNo ;
$this_content .= "(" . $train->duration . ")" . " " . $train->cabin_name . " " . $train->adultcost . "元\r\n";
$this_content .= "请购票成功后通知外联。";
if (trim($train->TicketAddress) != '') {
$this_content .= "并于客人入住前两天,快递送达客人酒店,谢谢!\r\n";
$this_content .= $train->TicketAddress;
}
$this->ci->tldOrderBuilder->setScheduleDetailsTitle($s_index, $train->departure_date)
->setScheduleDetailsContent($s_index, $this_content)
;
$s_index++;
}
$this->ci->tldOrderBuilder->clearModifyLogInfo();
// echo $this->ci->tldOrderBuilder->getBizContent();exit;
$resp = $this->excute_curl($this->neworder_url, $this->ci->tldOrderBuilder);
$response = json_decode($resp);
$sync_orderstate = 10;
$vps_sn = 0;
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" => strstr($train_order[0]->COLD_StartDate, " ", true)
,"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) {
$sync_id = $this->ci->Group_model->insert_VendorPlanSync($sync_ret);
$this->ci->BIZ_order->insert_biz_order_log($coli_sn, "vendorPlanSendout_");
}
/** VendorArrangeState VAS_IsReceive */
$this->ci->Group_model->set_plan_received($vas_sn);
}
}
if ( ! empty($pag_coldsn_arr)) {
$this->biz_pag_order_exec($vas,$grd_info);
}
return false;
}
private function biz_pag_order_exec($vas, $grd)
{
if (empty($grd)) {
return false;
}
// 补全小包价的日程
$complete_grd = array();
$special_grd = array();
$normal_grd = array();
// object 在foreach中自身会被改变, 先转换成array
$grd = json_decode(json_encode($grd), true);
foreach ($grd as $kp => $vpag) {
$hotels_traffic = $this->ci->BIZ_order->get_package_order($vpag['GRD_COLD_SN']);
$vpag['GRD_Hotel'] = $hotels_traffic[0]->POI_Hotel;
$vpag['to_traffic'] = $hotels_traffic[0]->POI_Hotel;
$vpag['back_traffic'] = $hotels_traffic[0]->POI_Hotel;
// if (trim($hotels_traffic[0]->POI_HotelAddress) != "") {
// $vpag['GRD_Hotel'] .= "\r\n酒店地址:" . $hotels_traffic[0]->POI_HotelAddress;
// }
$vpag['hotel_checkin'] = trim($hotels_traffic[0]->POI_HotelCheckInName)!=="" ? "入住人:".$hotels_traffic[0]->POI_HotelCheckInName : "";
$vpag['hotel_checkin'] .= trim($hotels_traffic[0]->POI_HotelCheckIn)!=="" ? " 入住日期:".$hotels_traffic[0]->POI_HotelCheckIn : "";
if ($hotels_traffic[0]->POI_FlightsNo) {
$vpag['GRD_Traffic'] = $hotels_traffic[0]->POI_FlightsNo;
if ($hotels_traffic[0]->POI_FromCity || $hotels_traffic[0]->POI_ToCity) {
$vpag['GRD_Traffic'] .= ", (" . $hotels_traffic[0]->POI_FromCity . "-" . $hotels_traffic[0]->POI_ToCity . ")";
}
if ($hotels_traffic[0]->POI_Time || $hotels_traffic[0]->POI_EndTime) {
$vpag['GRD_Traffic'] .= ", " . $hotels_traffic[0]->POI_Time . " " . $hotels_traffic[0]->POI_EndTime;
}
if ($hotels_traffic[0]->POI_AirPort) {
$vpag['GRD_Traffic'] .= ", " . $hotels_traffic[0]->POI_AirPort;
}
}
if (isset($this->ci->trippest->special_route[$vpag['PAG_Code']])) {
$this_pag_total_day = $this->ci->trippest->special_route[$vpag['PAG_Code']]['day'];
$this_code = $vpag['PAG_Code'];
for($p=0; $p<$this_pag_total_day; $p++) {
$vpag['GRD_OrderDate'] = date("Y-m-d", strtotime("+$p day", strtotime($vpag['day_no_raw'])));
$vpag['day_no_raw'] = $vpag['GRD_OrderDate'];
$vpag['PAG_Code'] = $this->ci->trippest->special_route[$this_code]['code'][$p];
$pag_detail = $this->ci->BIZ_order->get_packageDetails("'" . $vpag['PAG_Code'] . "'", implode(",",$this->vendor_ids), false);
$vpag['PAG_Title'] = $pag_detail[0]->PAG2_Name;
$vpag['GRD_Landscape'] = $vpag['PAG_Title'];
$vpag['GRD_Meal_L'] = (in_array($pag_detail[0]->PAG_Meal, array('61002', '61004')) ? "1" : "");
$vpag['GRD_Meal_S'] = (in_array($pag_detail[0]->PAG_Meal, array('61003', '61004')) ? "1" : "");
$special_grd[] = $vpag;
}
} else {
$pag_detail = $this->ci->BIZ_order->get_packageDetails("'" . $vpag['PAG_Code'] . "'", implode(",",$this->vendor_ids), false);
$vpag['GRD_Meal_L'] = (in_array($pag_detail[0]->PAG_Meal, array('61002', '61004')) ? "1" : "");
$vpag['GRD_Meal_S'] = (in_array($pag_detail[0]->PAG_Meal, array('61003', '61004')) ? "1" : "");
// 接送的子订单行程
if (isset($vpag['PAG_sub_sn']) && $vpag['PAG_sub_sn'] != 0) {
$sub_pag = $this->ci->BIZ_order->get_sub_pag_info($vpag['PAG_sub_sn']);
if (! empty($sub_pag)) {
$vpag['GRD_Landscape'] = "[" . $sub_pag->PAGS_CN_Title . "] " . $vpag['GRD_Landscape'];
if (strval($sub_pag->PAGS_Direction) === '0') {
$vpag['to_traffic'] = $vpag['GRD_Traffic'];
} else {
$vpag['back_traffic'] = $vpag['GRD_Traffic'];
}
}
}
$normal_grd[] = $vpag;
}
}
$complete_grd = array_merge($special_grd, $normal_grd);
$complete_grd = json_decode(json_encode($complete_grd));
$grd_apart_info = $this->tour_apart($complete_grd);
// echo json_encode($grd_apart_info);exit;
$request_info = $this->ci->Group_model->get_plan_request($vas->GRI_SN);
$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']));
foreach ($grd_apart_info as $group_key => $grd_part) {
$big_order_index = $this->tour_apart_order_exec($group_key, $vas, $request_info, null, $grd_part, $big_order_index);
}
if ($big_order_index === $expect_order_cnt) {
/** VendorArrangeState VAS_IsReceive */
$this->ci->Group_model->set_plan_received($vas->VAS_SN);
}
}
/*!
* 发送目的地项目组预订计划到图兰朵地接系统
@ -430,7 +628,7 @@ log_message('error',$resp);
if ( ! in_array($cold->COLD_SN, $processed_cold) && $cold->pag_code != '') {
$processed_cold[] = $cold->COLD_SN;
$all_package = $this->ci->trippest->tour_code($cold->pag_code);
$pag_info = $this->ci->BIZ_order->get_packageDetails(my_implode("'",",",$all_package));
$pag_info = $this->ci->BIZ_order->get_packageDetails(my_implode("'",",",$all_package), implode(",",$this->vendor_ids));
if ($set_pvt==='1') {
$fill_order[0]["cold"][] = $cold;
} else {
@ -446,7 +644,7 @@ log_message('error',$resp);
$multi_package = $this->ci->trippest->tour_code($vcd->pag_code);
$pvt_pagcode = array_merge($pvt_pagcode, $multi_package);
}
$fill_order[0]["package_info"] = $this->ci->BIZ_order->get_packageDetails(my_implode("'",",",$pvt_pagcode));
$fill_order[0]["package_info"] = $this->ci->BIZ_order->get_packageDetails(my_implode("'",",",$pvt_pagcode), implode(",",$this->vendor_ids));
}
// $fill_order = array_values($fill_order);
$i=0;
@ -471,12 +669,16 @@ log_message('error',$resp);
$extra_day = $this->ci->trippest->special_route[$vf["cold"][0]->pag_code]["day"]-1;
$end_date = date("Y-m-d", strtotime("+$extra_day day", strtotime($vf["cold"][0]->COLD_StartDate)));
}
$agcOrderNo = $vf["cold"][0]->COLI_GroupCode . "-" . $vf["package_info"][0]->city_code;
// $agcOrderNo = $vf["cold"][0]->COLI_GroupCode . "-" . $vf["package_info"][0]->city_code;
if ($take_apart===true) {
$agcOrderNo .= "-" . $i;
// $agcOrderNo .= "-" . $i;
$tour_code = mb_strtoupper($vf["cold"][0]->pag_code);
}
$agcOrderNo .= "(" . $vf["cold"][0]->operator . ")";
// $agcOrderNo .= "(" . $vf["cold"][0]->operator . ")";
$agcOrderNo = $vf["cold"][0]->COLI_GroupCode;
if (trim($vf["cold"][0]->COLI_PriceMemo) !== '') {
$agcOrderNo .= " (" . $vf["cold"][0]->COLI_PriceMemo . ")";
}
$order_remark = "";
if ($i===1) { // 只写一次备注.备注中可能包含代收信息,避免多次收取
$order_remark_arr = array_filter(array_map( function($element){return $element->COLD_vendorMemo;}, $vf["cold"] )) ;
@ -580,7 +782,7 @@ log_message('error',$resp);
$schedule_obj[$e_day]['date'] = $e_day;
$fill_date[] = $e_day;
$schedule_obj[$e_day]['code'] = $this->ci->trippest->special_route[$vs->PAG_Code]['code'][$j];
$pag_detail = $this->ci->BIZ_order->get_packageDetails("'" . $schedule_obj[$e_day]['code'] . "'");
$pag_detail = $this->ci->BIZ_order->get_packageDetails("'" . $schedule_obj[$e_day]['code'] . "'", implode(",",$this->vendor_ids));
$schedule_obj[$e_day]['title'] = $pag_detail[0]->PAG2_Name;
$schedule_obj[$e_day]['lunch'] = (in_array($pag_detail[0]->PAG_Meal, array('61002', '61004')) ? 1 : 0);
$schedule_obj[$e_day]['dinner'] = (in_array($pag_detail[0]->PAG_Meal, array('61003', '61004')) ? 1 : 0);
@ -604,7 +806,7 @@ log_message('error',$resp);
$date_e = new DateTime(strstr($vs->COLD_EndDate, " ", TRUE));
$date_d = $date_e->diff($date_s);
$d_t = ($date_d->format("%a"));
if ($d_t > 0) {
if ($d_t > 0 && empty($fill_date)) {
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))));
$schedule_obj[$f_d] = $schedule_obj[substr($vs->COLD_StartDate, 0, 10)];
@ -700,7 +902,7 @@ log_message('error',$resp);
$this->ci->BIZ_order->insert_biz_order_log($coli_sn, "vendorPlanUpdateSendout_" . $tour_code);
}
/** VendorArrangeState VAS_IsReceive */
$this->ci->Group_model->set_plan_received($vas_sn);
$this->ci->Group_model->set_plan_received($vas_sn, $gri_sn);
}
}
return "[Tulanduo>push_trippest] Done. " . $COLI_ID;
@ -708,7 +910,7 @@ log_message('error',$resp);
public function tourguide_update($input, $vps, $eva)
{
return false; // for Trippest deploy
return false;
$ret['status'] = -1;
$ret['err'] = 100;
$ret['errMsg'] = "未知错误";
@ -782,7 +984,7 @@ log_message('error',$resp);
*/
public function order_change()
{
return false; // for Trippest deploy
return false;
$this->load->model('Order_update');
$ret['status'] = -1;
$ret['errMsg'] = "未知错误";

@ -36,7 +36,22 @@ class BIZ_Orders_model extends CI_Model {
public function get_guestlist($COLD_SN_str)
{
$sql = "SELECT *
$sql = "SELECT
BPE.BPE_FirstName+' '+BPE.BPE_MiddleName+' '+BPE.BPE_LastName as MemberName,
BPE.BPE_BirthDate BirthDay,
ISNULL((select SYC2_CodeDiscribe
from V_System_Code
where LGC_LGC=2
and SYC_SN=BPE.BPE_SEX),''
) Gender,
(select COI2_Country from V_Country_Info
where LGC_LGC = 2
and COI_SN = BPE.BPE_Nationality
) as Country,
'' as phone,
BPE.BPE_Passport PassportNo,
BPE.BPE_PassExpdate PassportValidDate
,*
FROM BIZ_BookPeopleList BPL
INNER JOIN BIZ_BookPeople BPE ON BPL_BPE_SN=BPE_SN
WHERE BPL_COLD_SN IN ($COLD_SN_str)";
@ -64,15 +79,17 @@ class BIZ_Orders_model extends CI_Model {
return $query->result();
}
/** 根据线路代号 */
public function get_packageDetails($pag_code_str='', $vei_sn_str='')
public function get_packageDetails($pag_code_str='', $vei_sn_str='', $is_trippest=true)
{
$code_sql = $pag_code_str=='' ? " " : " and pag.PAG_Code IN ($pag_code_str) ";
$vei_sql = $vei_sn_str=='' ? " " : " and pag.PAG_DefaultVEI_SN IN ($vei_sn_str) ";
$trippest_sql = $is_trippest===true ? " and pag.PAG_DEI_SN=30 " : " ";
$sql = "SELECT *,
(select CII2_name from CItyInfo2 where CII2_CII_SN=PAG_CII_SN and CII2_LGC=2) as city_chinese,
(select CII_PKCode from CItyInfo where CII_SN=PAG_CII_SN) as city_code
FROM BIZ_PackageInfo2 pag2
INNER JOIN BIZ_PackageInfo pag ON pag.PAG_SN=pag2.PAG2_PAG_SN and pag2.PAG2_LGC=2 and pag.PAG_DEI_SN=30
INNER JOIN BIZ_PackageInfo pag ON pag.PAG_SN=pag2.PAG2_PAG_SN and pag2.PAG2_LGC=2
$trippest_sql
WHERE 1=1
$code_sql
$vei_sql
@ -309,10 +326,25 @@ class BIZ_Orders_model extends CI_Model {
[dbo].[GetStationCNName_LGC](f.DepartureCity, f.DepartAirport, 2) as depart_station
,[dbo].[GetStationCNName_LGC](f.ArrivalCity, f.ArrivalAirport, 2) as arrival_station
,[dbo].[GetStationCabinName_LGC](f.Cabin,2) as cabin_name
,* from BIZ_FlightsOrderInfo f
,CONVERT(date,f.DepartureDate) departure_date
,SUBSTRING(f.DepartureTime,1,7)+'-'+SUBSTRING(f.ArrivalTime,1,7) as duration
,f.adultcost
,f.TicketAddress
,cold.COLD_PersonNum as adult_num
,cold.COLD_ChildNum+cold.COLD_BabyNum as child_num
,cold.COLD_StartDate,cold.COLD_EndDate
,(select CII2_Name from CItyInfo2
inner join VEndorInfo on VEI_CII_Name=CII2_CII_SN
where VEI_SN=cold.COLD_PlanVEI_SN and CII2_LGC=2) as city_name
,(select CII_PKCode from CItyInfo
inner join VEndorInfo on VEI_CII_Name=CII_SN
where VEI_SN=cold.COLD_PlanVEI_SN ) as city_code
,f.* from BIZ_FlightsOrderInfo f
inner join BIZ_ConfirmLineDetail cold on COLD_SN=FOI_COLD_SN
where f.FOI_COLD_SN in (
$COLD_SN_str
)";
)
order by COLD_StartDate ";
return $this->HT->query($sql)->result();
}
@ -337,4 +369,16 @@ class BIZ_Orders_model extends CI_Model {
and COLD_SN in ($COLD_SN_str)";
return $this->HT->query($sql)->result();
}
/*!
* @Author: LYT
* @Date: 2019-06-11 17:54:12
* @Desc: 获取小包价子产品的信息
*/
public function get_sub_pag_info($PAGS_SN)
{
$sql = "SELECT * from BIZ_PackageInfoSub p
where p.PAGS_SN=$PAGS_SN ";
return $this->HT->query($sql)->row();
}
}

@ -24,12 +24,11 @@ class Group_model extends CI_Model {
$sql .= $gri_sn!==0 ? $gri_sql : "
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'
-- 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 EXISTS (
select 1 from OperatorInfo where OPI_SN=GRI_operator AND OPI_DEI_SN=30
-- AND EOI_GetDate between '$start_date' AND '$end_date'
AND EOI_GetDate > CONVERT(date, GETDATE())
AND isnull(VAS_IsConfirm,0)=0 AND VAS_ConfirmSN IS NULL
and not exists (
select 1 from VendorPlanSendout where VPS_VAS_SN=VAS_SN
)
";
$sql .= " order by EOI_GetDate asc,vas.VAS_SendTime asc, vas.VAS_IsConfirm asc";
@ -52,7 +51,7 @@ class Group_model extends CI_Model {
return $this->HT->query($sql, array($vas))->result();
}
public function get_vendor_plan_info($gri_sn, $vendor_id)
public function get_vendor_plan_info($gri_sn, $vendor_id, $from_cold=false)
{
// SET NOCOUNT ON 才能这样调用, 否则需要遍历结果集
// $sql = " Tourmanager.dbo.SP_VendorPlan_GetPlanInfo ?, ?, 0 ";
@ -84,6 +83,8 @@ 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);
$cold_sn_str = implode(",", array_map(function ($ele){return $ele->GRD_COLD_SN;}, $grd_info));
if ($from_cold===false) {
$all_aci = $this->get_arrange_info($gri_sn, $vendor_id, $day_no_str);
foreach ($grd_info as $kgrd => &$vgrd) {
$vgrd->pag_code_arr = array();
@ -96,7 +97,7 @@ class Group_model extends CI_Model {
$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;
$vgrd->PAG_DEI_SN = $vaci->PAG_DEI_SN ? $vaci->PAG_DEI_SN : 0;
if ( strval($vaci->ACI_ServiceType)==='D') {
$vgrd->PAG_Code = mb_strtoupper($vaci->PAG_Code);
$vgrd->PAG_ExtendType = mb_strtoupper($vaci->PAG_ExtendType);
@ -106,6 +107,32 @@ class Group_model extends CI_Model {
}
}
}
} else {
$all_cold = $this->get_arrange_info_from_biz_cold($cold_sn_str);
foreach ($grd_info as $kgrd => &$vgrd) {
$vgrd->pag_code_arr = array();
$vgrd->PAG_Title = $vgrd->GRD_Landscape;
foreach ($all_cold as $kcold => $vcold) {
if ($vgrd->GRD_COLD_SN == $vcold->COLD_SN) {
$vgrd->day_no_raw = strstr($vcold->COLD_StartDate, " ", true);
$vgrd->tocity = $vcold->tocity;
$vgrd->citycode = $vcold->citycode;
$vgrd->ACI_PersonNum = intval($vcold->COLD_PersonNum);
$vgrd->ACI_ChildNum = intval($vcold->COLD_ChildNum);
$vgrd->ACI_BabyNum = intval($vcold->COLD_BabyNum);
$vgrd->PAG_DEI_SN = $vcold->PAG_DEI_SN;
$vgrd->PAG_sub_sn = intval($vcold->COLD_ServiceSN2);
$vgrd->vendor_memo = trim($vcold->COLD_vendorMemo);
if ( strval($vcold->COLD_ServiceType)==='D') {
$vgrd->PAG_Code = mb_strtoupper($vcold->PAG_Code);
$vgrd->PAG_ExtendType = mb_strtoupper($vcold->PAG_ExtendType);
$vgrd->pag_code_arr[] = mb_strtoupper($vcold->PAG_Code);
break;
}
}
}
}
}
return $grd_info;
}
@ -149,6 +176,26 @@ class Group_model extends CI_Model {
return $this->HT->query($sql, $param_arr)->result();
}
public function get_arrange_info_from_biz_cold($cold_sn_str)
{
$sql = "SELECT
(select CII2_Name from CItyInfo2
where CII2_CII_SN=PAG_CII_SN and CII2_LGC=2) as tocity,
(select CII_PKCode from CItyInfo
where CII_SN=PAG_CII_SN ) as citycode,
PAG_Code,PAG_ExtendType,PAG_DEI_SN,
* from BIZ_ConfirmLineDetail cold
left join BIZ_PackageInfo on PAG_SN=COLD_ServiceSN
and COLD_ServiceType='D' and PAG_DefaultVEI_SN=COLD_PlanVEI_SN
and SUBSTRING(CONVERT(varchar(10), PAG_SourceType) ,1,3)='132'
where 1=1
and COLD_SN in (
$cold_sn_str
)
order by COLD_StartDate asc ";
return $this->HT->query($sql)->result();
}
public function get_sync_info($vas, $tour_code="")
{
$sql = "SELECT *
@ -247,10 +294,13 @@ class Group_model extends CI_Model {
return $eva_g_sn;
}
public function set_plan_received($vas_sn=0)
public function set_plan_received($vas_sn=0, $gri_sn=null)
{
$sql = "UPDATE VendorArrangeState set VAS_IsReceive=1,VAS_ReceiveTime=GETDATE() where VAS_SN=? ";
return $this->HT->query($sql, array($vas_sn));
$sql = "UPDATE VendorArrangeState set VAS_IsReceive=1,VAS_ReceiveTime=GETDATE() where VAS_SN=$vas_sn ";
if ($gri_sn !== null) {
$sql = "UPDATE VendorArrangeState set VAS_IsReceive=1,VAS_ReceiveTime=GETDATE() where VAS_GRI_SN=$gri_sn ";
}
return $this->HT->query($sql);
}
/*!

@ -118,12 +118,12 @@ class TuLanDuo_addOrUpdateRouteOrderContentBuilder extends CI_Model
}
public function setRoomStandard($roomStandard)
{
$this->orderData['roomStandard'] = $roomStandard;
$this->orderData['roomStandard'] = isset($this->orderData['roomStandard']) ? ($this->orderData['roomStandard'] . "\r\n" . $roomStandard) : $roomStandard;
return $this;
}
public function setOrderRemark($orderRemark)
{
$this->orderData['orderRemark'] = $orderRemark;
$this->orderData['orderRemark'] = isset($this->orderData['orderRemark']) ? ($this->orderData['orderRemark'] . "\r\n" . $orderRemark) : $orderRemark;
return $this;
}
public function setRouteStandard($routeStandard)
@ -133,7 +133,7 @@ class TuLanDuo_addOrUpdateRouteOrderContentBuilder extends CI_Model
}
public function setDestination($destination)
{
$this->orderData['destination'] = $destination;
$this->orderData['destination'] = $destination . "分公司";
return $this;
}
public function setTravelDate($travelDate)

Loading…
Cancel
Save