From 66d50aebf95212b24b1159255af8f83af55f4fce Mon Sep 17 00:00:00 2001 From: cyc Date: Wed, 15 Jan 2020 14:44:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AC=E5=8F=91=E5=9B=9E=E8=B0=83=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dingtools/controllers/index.php | 52 +++++++++++-------- .../dingtools/models/dingtools_model.php | 10 ++++ 2 files changed, 41 insertions(+), 21 deletions(-) create mode 100644 webht/third_party/dingtools/models/dingtools_model.php diff --git a/webht/third_party/dingtools/controllers/index.php b/webht/third_party/dingtools/controllers/index.php index d267a6a2..377e8cf8 100644 --- a/webht/third_party/dingtools/controllers/index.php +++ b/webht/third_party/dingtools/controllers/index.php @@ -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,8 @@ 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); } } \ No newline at end of file diff --git a/webht/third_party/dingtools/models/dingtools_model.php b/webht/third_party/dingtools/models/dingtools_model.php new file mode 100644 index 00000000..84810bfe --- /dev/null +++ b/webht/third_party/dingtools/models/dingtools_model.php @@ -0,0 +1,10 @@ +HT = $this->load->database('HT', TRUE); + } + + +} \ No newline at end of file