94 lines
3.7 KiB
PHP
94 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace app\DeviceEnter\controller;
|
|
|
|
use think\Db;
|
|
use think\Cache;
|
|
|
|
class Appinterface extends Base{
|
|
|
|
|
|
protected $device_name_list = [
|
|
'C03',
|
|
];
|
|
|
|
################################################################接口################################################################
|
|
################################################################接口################################################################
|
|
################################################################接口################################################################
|
|
|
|
|
|
public function check_device_msg(){
|
|
try {
|
|
// 你的业务逻辑
|
|
if(count(input('post.')) > 0){
|
|
$data = input('post.');
|
|
}else{
|
|
$data = [];
|
|
}
|
|
if(!array_key_exists('mac', $data)){
|
|
return $this->msg(10001);
|
|
}
|
|
// if(!array_key_exists('device_name', $data)){
|
|
// return $this->msg(10001);
|
|
// }
|
|
if(!$this->verify_data_is_ok($data['mac'],'str')){
|
|
return $this->msg(10005);
|
|
}
|
|
// if(!$this->verify_data_is_ok($data['device_name'],'str')){
|
|
// return $this->msg(10005);
|
|
// }
|
|
|
|
return $this->check_device_msg_action($data);
|
|
} catch (\Exception $e) {
|
|
// 捕获异常
|
|
$logContent["flie"] = $e->getFile();
|
|
$logContent["line"] = $e->getLine();
|
|
$logContent['all_content'] = "异常信息:\n";
|
|
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
|
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
|
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
|
$logContent['all_content'] .= "函数名: " . __FUNCTION__ . "\n";
|
|
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
|
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
|
// dump($data);
|
|
// die;
|
|
$this->record_api_log($data, $logContent, null);
|
|
return $this->msg(99999);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
########################################################################action########################################################################
|
|
########################################################################action########################################################################
|
|
########################################################################action########################################################################
|
|
|
|
public function check_device_msg_action($data){
|
|
|
|
// if(!in_array($data['device_name'], $this->device_name_list)){
|
|
// return $this->msg(10003);
|
|
// }
|
|
$device_enter = Db::connect('device_enter_db');
|
|
// $db_name = 'device_'.$data['device_name'];
|
|
$result = $device_enter->table('device_C03')->where(['device_mac'=>$data['mac'],'is_activate'=>1])->find();
|
|
if($result){
|
|
return $this->msg([]);
|
|
}else{
|
|
return $this->msg(10010,'设备未登记,请联系出售方进行系统认证');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
################################################################测试################################################################
|
|
################################################################测试################################################################
|
|
################################################################测试################################################################
|
|
|
|
|
|
|
|
|
|
} |