赵鹏 6 years ago
commit 73ea8f4d01

@ -81,6 +81,7 @@ else
* 套件创建成功后的回调推送
*/
Log::i("DECRYPT MSG SUCCESS " . json_encode($_GET) . " " . $msg);
GetPost_http('http://www.mycht.cn/webht.php/apps/dingtools/index/recivecallback',$msg,'POST');
$eventMsg = json_decode($msg);
$eventType = $eventMsg->EventType;
/**
@ -182,3 +183,28 @@ else
Log::e("RESPONSE ERR: " . $errCode);
}
}
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; //返回数据
}

@ -6,27 +6,28 @@ if (!defined('BASEPATH'))
class index extends CI_Controller {
function __construct() {
parent::__construct();
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:POST, GET');
header('Access-Control-Max-Age:0');
header('Access-Control-Allow-Headers:x-requested-with, Content-Type');
header('Access-Control-Allow-Credentials:true');
$this->load->helper('dingtools');
$this->AppKey = 'dingjcbxgidah9uspeuc';
$this->AppSecret = 'C4-8rUDK1u5Twpsw7U3yo42s_bbYxFIqzLMp2j7uI80Sa8D-OPbtSoCMgZxHxo2d';
$this->load->model('dingtools_model');
}
public function index(){
echo json_encode(array('https://data.chinahighlights.com/pic/logo/logo-132x104.png','https://data.chinahighlights.com/image/homepage/holding-panda.jpg'));
exit('前方高能!!!');
}
public function sendApproval(){
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:POST, GET');
header('Access-Control-Max-Age:0');
header('Access-Control-Allow-Headers:x-requested-with, Content-Type');
header('Access-Control-Allow-Credentials:true');
//接收数据
$img = $this->input->post('img');
$money = $this->input->post('money');
$postunionid = $this->input->post('postunionid');
$approvers = $this->input->post('approvers');
$message = $this->input->post('message');
if(empty($postunionid)){
exit('参数错误');
@ -40,7 +41,16 @@ class index extends CI_Controller {
$originator_user_id = $this->getuserid($postunionid);
$dept_id = $this->getdeptid($originator_user_id);
$approversid = $this->getuserid($approvers);
$user_list = explode(',',$approvers);
$approversidstr = '';
if(count($user_list) > 1){
foreach($user_list as $userid){
$approversidstr .= $this->getuserid($userid).',';
}
$approversidstr = substr($approversidstr,0,strlen($approversidstr) - 1);
}else{
$approversidstr = $this->getuserid($user_list['0']);
}
$postData = array();
//表单code
@ -50,16 +60,22 @@ class index extends CI_Controller {
//发起人部门id
$postData['dept_id'] = $dept_id;
//审批人id
$postData['approvers'] = $approversid;
$postData['approvers'] = $approversidstr;
$postData['form_component_values'] = array();
$postData['form_component_values']['0']['name'] = '报账金额';
$postData['form_component_values']['0']['value'] = $money;
$postData['form_component_values']['1']['name'] = '附件';
$postData['form_component_values']['1']['value'] = json_decode($img);
$postData['form_component_values']['1']['name'] = '备注';
$postData['form_component_values']['1']['value'] = $message;
$postData['form_component_values']['2']['name'] = '附件';
$postData['form_component_values']['2']['value'] = json_decode($img);
//print_r(json_encode($postData));die();
$approoval = GetPost_http($url,json_encode($postData),'json');
print_r($approoval);
$response = GetPost_http($url,json_encode($postData),'json');
if(!empty($response)){
echo $response;
}
}
public function sendRefund(){
@ -135,14 +151,44 @@ class index extends CI_Controller {
}
public function recivecallback(){
/*$recivejson = file_get_contents('php://input');
$encrypt = json_decode($recivejson)->encrypt;
$signature = $_GET['signature'];
$timestamp = $_GET['timestamp'];
$nonce = $_GET['nonce'];
log_message('error','dingding回调'.$recivejson);
log_message('error','signature'.$_GET['signature']);
log_message('error','timestamp'.$_GET['timestamp']);
log_message('error','nonce'.$_GET['nonce']);*/
$recivejson = file_get_contents('php://input');
log_message('error',$recivejson);
$recivedata = json_decode($recivejson);
$data = array();
if(strpos($recivedata->title,'团款审批')){
$data['processInstanceId'] = $recivedata->processInstanceId;
$data['title'] = $recivedata->title;
$data['type'] = $recivedata->type;
$data['result'] = $recivedata->result;
$unionid = $this->get_unionid($recivedata->staffId);
$data['unionid'] = $unionid;
$data['EventType'] = $recivedata->EventType;
if(isset($recivedata->remark)){
$data['remark'] = $recivedata->remark;
}else{
$data['remark'] = '';
}
if(isset($recivedata->result)){
$data['result'] = $recivedata->result;
}else{
$data['result'] = '';
}
$this->dingtools_model->add_instance_id($data);
}
}
public function get_unionid($userid){
$access_url = 'https://oapi.dingtalk.com/gettoken?appkey='.$this->AppKey.'&appsecret='.$this->AppSecret;
$access_token = GetPost_http($access_url,'','');
$access_token = json_decode($access_token)->access_token;
$user_detail_url = 'https://oapi.dingtalk.com/user/get?access_token='.$access_token.'&userid='.$userid;
$user_detail = GetPost_http($user_detail_url,'','get');
$unionid = json_decode($user_detail)->unionid;
return $unionid;
}
}

@ -0,0 +1,15 @@
<?php
class dingtools_model extends CI_Model {
function __construct() {
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
}
public function add_instance_id($data){
$sql = 'insert into
GroupPaymentAuditState
(PAS_Instance_id,PAS_EventType,PAS_Unionid,PAS_AuditType,PAS_AuditResult,PAS_AuditContent,PAS_CreateDate) values (?,?,?,?,?,?,GETDATE())';
$query = $this->HT->query($sql,array($data['processInstanceId'],$data['EventType'],$data['unionid'],$data['type'],$data['result'],$data['remark']));
}
}

@ -1127,12 +1127,12 @@ 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');
// 通知客人, 客人邮箱
$customer_detail = $this->Paypal_model->get_customer_detail($advisor_info->COLI_SN, $orderid_info->ordertype);
// $customer_detail = $this->Paypal_model->get_customer_detail($advisor_info->COLI_SN, $orderid_info->ordertype);
$c_fromName = $advisor_detail->fullname ? $advisor_detail->fullname : $opi_firstname;
$opi_email_list = explode(";", $advisor_detail->email); // 解析外联的邮件
$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_toName = $item->pn_payer; // $customer_detail->fullname;
$c_toEmail = $item->pn_payer_email ; // $customer_detail->email;
$c_subject = $item->pn_mc_currency . " " . str_replace('-', '', $item->pn_mc_gross) . " Refunded to your account, booking number " . $item->pn_invoice;
$c_body = $this->load->view('refund_buyer', $item, true);
$c_M_RelatedInfo = $item->pn_sn;
@ -1518,7 +1518,7 @@ class Index extends CI_Controller {
$orderid_info = $this->analysis_orderid($data['note']->pn_invoice);
if (!empty($orderid_info)) {
$orderid_info = json_decode($orderid_info);
if ($orderid_info->ordertype === 'TP') {
if ($orderid_info->ordertype === 'TP' || $orderid_info->ordertype === 'A') {
$orderid_info->ordertype = 'B';
}
if ($orderid_info->ordertype === 'T') {
@ -1569,6 +1569,10 @@ class Index extends CI_Controller {
$old_ssje = $data['gai_info'][0]->GAI_SSJE;
$this->Paypal_model->delete_money_b($pn_txn_id);
}
} elseif ($orderid_info->ordertype === 'A') {
$this->send_note($pn_txn_id);
echo json_encode('已发送APP');
return true;
}
}
@ -1611,7 +1615,7 @@ class Index extends CI_Controller {
$post_body .= '&appkey=jdfk*$jfjdk1688';
$app_return = $this->async_curl("http://wx.chinatrainbooking.com/paypalend/", $post_body, 5);
if (intval($app_return)===200) {
return false; // 下一步更新为send
return false; // 下一步更新为send-app
}
return true; // 下一步: sendfail

@ -570,9 +570,9 @@ class Paypal_model extends CI_Model {
public function get_money_b($pn_invoice) {
$sql = "SELECT BIZ_GroupAccountInfo.*
from BIZ_GroupAccountInfo
where DeleteFlag=0 and GAI_AccreditNo=?
where DeleteFlag=0 and ( GAI_AccreditNo=? or GAI_Memo=? )
";
$query = $this->HT->query($sql, array($pn_invoice));
$query = $this->HT->query($sql, array($pn_invoice, $pn_invoice));
$result = $query->result();
return $result;
}

@ -211,7 +211,7 @@ echo "<option value=\"$vf->TEL_SN@" . strstr($vf->TEL_transactionDate, " ", true
$raw_content = json_decode($item->pn_memo);
$show_record = '查看录入状态';
if ($item->pn_send == 'send' || substr($item->pn_send, 0, 5) == "send-") {
$show_send = 'send';
$show_send = $item->pn_send;
} elseif ($item->pn_send == 'closeRecord') {
$show_send = $show_record = '已忽略';
} else if (strtolower($item->pn_payment_status) == 'completed') {

Loading…
Cancel
Save