diff --git a/webht/third_party/dingtools/controllers/index.php b/webht/third_party/dingtools/controllers/index.php index bc673a72..9303e2be 100644 --- a/webht/third_party/dingtools/controllers/index.php +++ b/webht/third_party/dingtools/controllers/index.php @@ -151,21 +151,37 @@ class index extends CI_Controller { } public function recivecallback(){ - log_message('error',$recivejson); $recivejson = file_get_contents('php://input'); + log_message('error',$recivejson); + $recivejson = '{"processInstanceId":"acedfcf9-143a-4bbc-9988-0ecdbfdf87cf","finishTime":1579072931000,"corpId":"ding48bce8fd3957c96b","EventType":"bpms_instance_change","businessId":"202001151140000168820","title":"秦乾胜提交的团款审批","type":"finish","url":"https://aflow.dingtalk.com/dingtalk/mobile/homepage.htm?corpid=ding48bce8fd3957c96b&dd_share=false&showmenu=true&dd_progress=false&back=native&procInstId=acedfcf9-143a-4bbc-9988-0ecdbfdf87cf&taskId=&swfrom=isv&dinghash=approval&dd_from=corp#approval","result":"refuse","createTime":1579059616000,"processCode":"PROC-9D90693F-DE34-423C-9B92-A19FFFC87577","bizCategoryId":"","staffId":"04405068399170"}'; $recivedata = json_decode($recivejson); $data = array(); - $data['processInstanceId'] = $recivedata->processInstanceId; - $data['title'] = $recivedata->title; - $data['type'] = $recivedata->type; - $data['result'] = $recivedata->result; - $data['staffId'] = $recivedata->staffId; - if(isset($recivedata->content)){ - $data['content'] = $recivedata->content; - }else{ - $data['content'] = ''; + 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; + if(isset($recivedata->content)){ + $data['content'] = $recivedata->content; + }else{ + $data['content'] = ''; + } + + $this->dingtools_model->add_instance_id($data); } - $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; } } \ 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 index eee25cc2..892473fd 100644 --- a/webht/third_party/dingtools/models/dingtools_model.php +++ b/webht/third_party/dingtools/models/dingtools_model.php @@ -9,8 +9,7 @@ class dingtools_model extends CI_Model { public function add_instance_id($data){ $sql = 'insert into GroupPaymentAuditState - (PAS_Instance_id,PAS_Staffid,PAS_AuditType,PAS_AuditResult,PAS_AuditContent,PAS_CreateDate) values (?,?,?,?,?,GETDATE())'; - $query = $this->HT->query($sql,array($data['processInstanceId'],$data['staffId'],$data['type'],$data['result'],$data['content'])); - return $query->result(); + (PAS_Instance_id,PAS_Unionid,PAS_AuditType,PAS_AuditResult,PAS_AuditContent,PAS_CreateDate) values (?,?,?,?,?,GETDATE())'; + $query = $this->HT->query($sql,array($data['processInstanceId'],$data['unionid'],$data['type'],$data['result'],$data['content'])); } } \ No newline at end of file