|
@@ -180,8 +180,8 @@ class CommonController extends Controller
|
|
$user = Docter::create($docter_list);
|
|
$user = Docter::create($docter_list);
|
|
$nickname = '医生' . base_convert($user['id'], 10, 16);
|
|
$nickname = '医生' . base_convert($user['id'], 10, 16);
|
|
Docter::where('id', $user['id'])->update(['name' => $nickname]);
|
|
Docter::where('id', $user['id'])->update(['name' => $nickname]);
|
|
- }else{
|
|
|
|
- Docter::where('id', $find['id'])->update(['openid' => $data['openid'],'session_key'=>$session_key]);
|
|
|
|
|
|
+ } else {
|
|
|
|
+ Docter::where('id', $find['id'])->update(['openid' => $data['openid'], 'session_key' => $session_key]);
|
|
}
|
|
}
|
|
return out($decryptedData);
|
|
return out($decryptedData);
|
|
}
|
|
}
|
|
@@ -192,20 +192,21 @@ class CommonController extends Controller
|
|
* Date:2020/10/18 19:17 *
|
|
* Date:2020/10/18 19:17 *
|
|
* @return \Illuminate\Http\JsonResponse
|
|
* @return \Illuminate\Http\JsonResponse
|
|
*/
|
|
*/
|
|
- public function phoneLogin(){
|
|
|
|
|
|
+ public function phoneLogin()
|
|
|
|
+ {
|
|
$req = request()->post();
|
|
$req = request()->post();
|
|
$this->validate(request(), [
|
|
$this->validate(request(), [
|
|
'phone|手机号' => 'required|integer',
|
|
'phone|手机号' => 'required|integer',
|
|
'verify|验证码' => 'required|integer',
|
|
'verify|验证码' => 'required|integer',
|
|
]);
|
|
]);
|
|
$verify = (int)$req['verify'];
|
|
$verify = (int)$req['verify'];
|
|
- $verifyCode = Cache::get($req['phone'].'-', $verify, config('config.aly_sms.sms_verify_code_expire'));
|
|
|
|
|
|
+ $verifyCode = Cache::get($req['phone'] . '-', $verify, config('config.aly_sms.sms_verify_code_expire'));
|
|
|
|
|
|
- if ($verifyCode!=$verify){
|
|
|
|
- return out('',401,'验证码错误!');
|
|
|
|
|
|
+ if ($verifyCode != $verify) {
|
|
|
|
+ return out('', 401, '验证码错误!');
|
|
}
|
|
}
|
|
- $find = Docter::where('phone','=',$req['phone'])->first();
|
|
|
|
- if (empty($find)){
|
|
|
|
|
|
+ $find = Docter::where('phone', '=', $req['phone'])->first();
|
|
|
|
+ if (empty($find)) {
|
|
$docter_list = [
|
|
$docter_list = [
|
|
'type' => 1,
|
|
'type' => 1,
|
|
'name' => '医生' . base_convert($find['id'], 10, 16),
|
|
'name' => '医生' . base_convert($find['id'], 10, 16),
|
|
@@ -239,16 +240,16 @@ class CommonController extends Controller
|
|
'card_id' => 0,
|
|
'card_id' => 0,
|
|
];
|
|
];
|
|
$list = Docter::create($docter_list)->toArray();
|
|
$list = Docter::create($docter_list)->toArray();
|
|
- if (!empty($list)){
|
|
|
|
|
|
+ if (!empty($list)) {
|
|
$datas = [
|
|
$datas = [
|
|
'avatar' => $list['avatar'],
|
|
'avatar' => $list['avatar'],
|
|
'name' => $list['name'],
|
|
'name' => $list['name'],
|
|
- 'flag' => 'doctor_'.$list['id'],
|
|
|
|
|
|
+ 'flag' => 'doctor_' . $list['id'],
|
|
];
|
|
];
|
|
$token = aes_encrypt(['doctor_id' => $list['id'], 'time' => time()]);
|
|
$token = aes_encrypt(['doctor_id' => $list['id'], 'time' => time()]);
|
|
- return out(['token' => $token,'data'=>$datas]);
|
|
|
|
- }else{
|
|
|
|
- return out('',401,'用户不存在,注册失败!');
|
|
|
|
|
|
+ return out(['token' => $token, 'data' => $datas]);
|
|
|
|
+ } else {
|
|
|
|
+ return out('', 401, '用户不存在,注册失败!');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -260,13 +261,13 @@ class CommonController extends Controller
|
|
$datas = [
|
|
$datas = [
|
|
'avatar' => $find['avatar'],
|
|
'avatar' => $find['avatar'],
|
|
'name' => $find['name'],
|
|
'name' => $find['name'],
|
|
- 'flag' => 'doctor_'.$find['id'],
|
|
|
|
|
|
+ 'flag' => 'doctor_' . $find['id'],
|
|
];
|
|
];
|
|
// 验证是否正确
|
|
// 验证是否正确
|
|
$token = aes_encrypt(['doctor_id' => $find['id'], 'time' => time()]);
|
|
$token = aes_encrypt(['doctor_id' => $find['id'], 'time' => time()]);
|
|
Cache::delete($req['phone'] . '-', $verify);
|
|
Cache::delete($req['phone'] . '-', $verify);
|
|
|
|
|
|
- return out(['token' => $token,'data'=>$datas]);
|
|
|
|
|
|
+ return out(['token' => $token, 'data' => $datas]);
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -277,14 +278,15 @@ class CommonController extends Controller
|
|
* Date:2020/10/18 19:17 *
|
|
* Date:2020/10/18 19:17 *
|
|
* @return \Illuminate\Http\JsonResponse
|
|
* @return \Illuminate\Http\JsonResponse
|
|
*/
|
|
*/
|
|
- public function passLogin(){
|
|
|
|
|
|
+ public function passLogin()
|
|
|
|
+ {
|
|
$req = request()->post();
|
|
$req = request()->post();
|
|
$this->validate(request(), [
|
|
$this->validate(request(), [
|
|
'phone|手机号' => 'required|integer',
|
|
'phone|手机号' => 'required|integer',
|
|
'password|密码' => 'required',
|
|
'password|密码' => 'required',
|
|
]);
|
|
]);
|
|
- $find = Docter::where('phone','=',$req['phone'])->first();
|
|
|
|
- if (empty($find)){
|
|
|
|
|
|
+ $find = Docter::where('phone', '=', $req['phone'])->first();
|
|
|
|
+ if (empty($find)) {
|
|
return out(null, 401, '账号不存在');
|
|
return out(null, 401, '账号不存在');
|
|
}
|
|
}
|
|
if ($find['status'] == 0) {
|
|
if ($find['status'] == 0) {
|
|
@@ -293,18 +295,18 @@ class CommonController extends Controller
|
|
$find = $find->toArray();
|
|
$find = $find->toArray();
|
|
// 验证密码
|
|
// 验证密码
|
|
$password = md5(md5(md5($req['password'])));
|
|
$password = md5(md5(md5($req['password'])));
|
|
- if ($password==$find['password']){
|
|
|
|
|
|
+ if ($password == $find['password']) {
|
|
|
|
|
|
$datas = [
|
|
$datas = [
|
|
'avatar' => $find['avatar'],
|
|
'avatar' => $find['avatar'],
|
|
'name' => $find['name'],
|
|
'name' => $find['name'],
|
|
- 'flag' => 'doctor_'.$find['id'],
|
|
|
|
|
|
+ 'flag' => 'doctor_' . $find['id'],
|
|
];
|
|
];
|
|
$token = aes_encrypt(['doctor_id' => $find['id'], 'time' => time()]);
|
|
$token = aes_encrypt(['doctor_id' => $find['id'], 'time' => time()]);
|
|
|
|
|
|
- return out(['token' => $token,'data'=>$datas]);
|
|
|
|
- }else{
|
|
|
|
- return out(null, 401, '密码错误');
|
|
|
|
|
|
+ return out(['token' => $token, 'data' => $datas]);
|
|
|
|
+ } else {
|
|
|
|
+ return out(null, 401, '密码错误');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -314,7 +316,8 @@ class CommonController extends Controller
|
|
* @author Liu-Yh
|
|
* @author Liu-Yh
|
|
* Create By 2020/11/6 10:45
|
|
* Create By 2020/11/6 10:45
|
|
*/
|
|
*/
|
|
- public function putverfiy(){
|
|
|
|
|
|
+ public function putverfiy()
|
|
|
|
+ {
|
|
|
|
|
|
//防止恶意刷验证码接口,一分钟最多10次
|
|
//防止恶意刷验证码接口,一分钟最多10次
|
|
check_repeat_request(60, 10);
|
|
check_repeat_request(60, 10);
|
|
@@ -322,13 +325,13 @@ class CommonController extends Controller
|
|
$this->validate(request(), [
|
|
$this->validate(request(), [
|
|
'phone|手机号' => 'required|integer',
|
|
'phone|手机号' => 'required|integer',
|
|
]);
|
|
]);
|
|
- $mobile =$req['phone']; //获取传入的手机号
|
|
|
|
|
|
+ $mobile = $req['phone']; //获取传入的手机号
|
|
$verify_code = generate_code();
|
|
$verify_code = generate_code();
|
|
- $result = send_sms($mobile,'verify_template_code',['code'=>$verify_code]);
|
|
|
|
- if (empty($result['Code']) || $result['Code'] != 'OK'){
|
|
|
|
|
|
+ $result = send_sms($mobile, 'verify_template_code', ['code' => $verify_code]);
|
|
|
|
+ if (empty($result['Code']) || $result['Code'] != 'OK') {
|
|
return out(null, 30010, '验证码发送失败,请稍后重试');
|
|
return out(null, 30010, '验证码发送失败,请稍后重试');
|
|
}
|
|
}
|
|
- Cache::set($req['phone'].'-', $verify_code, config('config.aly_sms.sms_verify_code_expire'));
|
|
|
|
|
|
+ Cache::set($req['phone'] . '-', $verify_code, config('config.aly_sms.sms_verify_code_expire'));
|
|
|
|
|
|
return out();
|
|
return out();
|
|
}
|
|
}
|
|
@@ -339,7 +342,8 @@ class CommonController extends Controller
|
|
* Date:2020/10/18 20:17 *
|
|
* Date:2020/10/18 20:17 *
|
|
* @return \Illuminate\Http\JsonResponse
|
|
* @return \Illuminate\Http\JsonResponse
|
|
*/
|
|
*/
|
|
- public function phoneRegister(){
|
|
|
|
|
|
+ public function phoneRegister()
|
|
|
|
+ {
|
|
$req = request()->post();
|
|
$req = request()->post();
|
|
$this->validate(request(), [
|
|
$this->validate(request(), [
|
|
'phone|手机号' => 'required|integer',
|
|
'phone|手机号' => 'required|integer',
|
|
@@ -347,16 +351,16 @@ class CommonController extends Controller
|
|
'verify|验证码' => 'required|integer',
|
|
'verify|验证码' => 'required|integer',
|
|
]);
|
|
]);
|
|
$verify = (int)$req['verify'];
|
|
$verify = (int)$req['verify'];
|
|
- $verifyCode = Cache::get($req['phone'].'-', $verify, config('config.aly_sms.sms_verify_code_expire'));
|
|
|
|
- if ($verifyCode!=$verify){
|
|
|
|
- return out('',401,'验证码错误!');
|
|
|
|
|
|
+ $verifyCode = Cache::get($req['phone'] . '-', $verify, config('config.aly_sms.sms_verify_code_expire'));
|
|
|
|
+ if ($verifyCode != $verify) {
|
|
|
|
+ return out('', 401, '验证码错误!');
|
|
}
|
|
}
|
|
|
|
|
|
// 查询是否注册过!
|
|
// 查询是否注册过!
|
|
- $docters = Docter::where('phone','=',$req['phone'])->first();
|
|
|
|
|
|
+ $docters = Docter::where('phone', '=', $req['phone'])->first();
|
|
|
|
|
|
- if (!empty($docters)){
|
|
|
|
- return out('',500,'此手机号已被注册!');
|
|
|
|
|
|
+ if (!empty($docters)) {
|
|
|
|
+ return out('', 500, '此手机号已被注册!');
|
|
}
|
|
}
|
|
|
|
|
|
$password = md5(md5(md5($req['password'])));
|
|
$password = md5(md5(md5($req['password'])));
|
|
@@ -394,17 +398,17 @@ class CommonController extends Controller
|
|
'card_id' => 0,
|
|
'card_id' => 0,
|
|
];
|
|
];
|
|
$list = Docter::create($docter_list)->toArray();
|
|
$list = Docter::create($docter_list)->toArray();
|
|
- if (!empty($list)){
|
|
|
|
|
|
+ if (!empty($list)) {
|
|
|
|
|
|
$datas = [
|
|
$datas = [
|
|
'avatar' => $list['avatar'],
|
|
'avatar' => $list['avatar'],
|
|
'name' => $list['name'],
|
|
'name' => $list['name'],
|
|
- 'flag' => 'doctor_'.$list['id'],
|
|
|
|
|
|
+ 'flag' => 'doctor_' . $list['id'],
|
|
];
|
|
];
|
|
$token = aes_encrypt(['doctor_id' => $list['id'], 'time' => time()]);
|
|
$token = aes_encrypt(['doctor_id' => $list['id'], 'time' => time()]);
|
|
- return out(['token' => $token,'data'=>$datas]);
|
|
|
|
- }else{
|
|
|
|
- return out('',500,'注册失败!');
|
|
|
|
|
|
+ return out(['token' => $token, 'data' => $datas]);
|
|
|
|
+ } else {
|
|
|
|
+ return out('', 500, '注册失败!');
|
|
}
|
|
}
|
|
|
|
|
|
// return out();
|
|
// return out();
|
|
@@ -417,11 +421,12 @@ class CommonController extends Controller
|
|
return out($data);
|
|
return out($data);
|
|
}
|
|
}
|
|
|
|
|
|
- public function getUserIdByDoctorId($phone=null){
|
|
|
|
|
|
+ public function getUserIdByDoctorId($phone = null)
|
|
|
|
+ {
|
|
$list = Docter::where('phone', $phone)->first();
|
|
$list = Docter::where('phone', $phone)->first();
|
|
- if ($list){
|
|
|
|
|
|
+ if ($list) {
|
|
return $list->id;
|
|
return $list->id;
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -433,7 +438,7 @@ class CommonController extends Controller
|
|
return out(null, 10001, '文件不能为空');
|
|
return out(null, 10001, '文件不能为空');
|
|
}
|
|
}
|
|
|
|
|
|
- $path = $file->store('upload/docter/'.date('Ymd'));
|
|
|
|
|
|
+ $path = $file->store('upload/docter/' . date('Ymd'));
|
|
// $url = request()->getScheme().'://'.request()->getHost().'/'.$path;
|
|
// $url = request()->getScheme().'://'.request()->getHost().'/'.$path;
|
|
|
|
|
|
return out(['url' => $path]);
|
|
return out(['url' => $path]);
|
|
@@ -445,30 +450,29 @@ class CommonController extends Controller
|
|
$prefix = env('DB_PREFIX');
|
|
$prefix = env('DB_PREFIX');
|
|
$exclude_tables = "'bm_password_resets','bm_admin_menu','bm_admin_users','bm_failed_jobs','bm_migrations'";
|
|
$exclude_tables = "'bm_password_resets','bm_admin_menu','bm_admin_users','bm_failed_jobs','bm_migrations'";
|
|
|
|
|
|
- $sql = "select TABLE_NAME name,TABLE_COMMENT comment from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='".$database."' and TABLE_NAME not in (".$exclude_tables.")";
|
|
|
|
|
|
+ $sql = "select TABLE_NAME name,TABLE_COMMENT comment from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='" . $database . "' and TABLE_NAME not in (" . $exclude_tables . ")";
|
|
$tables = \DB::select($sql);
|
|
$tables = \DB::select($sql);
|
|
$map1 = $map2 = [];
|
|
$map1 = $map2 = [];
|
|
- $i = round(count($tables)/2);
|
|
|
|
|
|
+ $i = round(count($tables) / 2);
|
|
foreach ($tables as $k => $v) {
|
|
foreach ($tables as $k => $v) {
|
|
$name = str_replace($prefix, '', $v->name);
|
|
$name = str_replace($prefix, '', $v->name);
|
|
if ($k >= $i) {
|
|
if ($k >= $i) {
|
|
- $map1[$v->name] = $name.'('.$v->comment.')';
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- $map2[$v->name] = $name.'('.$v->comment.')';
|
|
|
|
|
|
+ $map1[$v->name] = $name . '(' . $v->comment . ')';
|
|
|
|
+ } else {
|
|
|
|
+ $map2[$v->name] = $name . '(' . $v->comment . ')';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
$data1 = [];
|
|
$data1 = [];
|
|
- foreach ($map1 as $k => $v){
|
|
|
|
- $sql = "select COLUMN_NAME name, DATA_TYPE type, COLUMN_COMMENT comment from INFORMATION_SCHEMA.COLUMNS where table_schema = '".$database."' AND table_name = '".$k."'";
|
|
|
|
|
|
+ foreach ($map1 as $k => $v) {
|
|
|
|
+ $sql = "select COLUMN_NAME name, DATA_TYPE type, COLUMN_COMMENT comment from INFORMATION_SCHEMA.COLUMNS where table_schema = '" . $database . "' AND table_name = '" . $k . "'";
|
|
$comment = \DB::select($sql);
|
|
$comment = \DB::select($sql);
|
|
$data1[$v] = $comment;
|
|
$data1[$v] = $comment;
|
|
}
|
|
}
|
|
|
|
|
|
$data2 = [];
|
|
$data2 = [];
|
|
- foreach ($map2 as $k => $v){
|
|
|
|
- $sql = "select COLUMN_NAME name, DATA_TYPE type, COLUMN_COMMENT comment from INFORMATION_SCHEMA.COLUMNS where table_schema = '".$database."' AND table_name = '".$k."'";
|
|
|
|
|
|
+ foreach ($map2 as $k => $v) {
|
|
|
|
+ $sql = "select COLUMN_NAME name, DATA_TYPE type, COLUMN_COMMENT comment from INFORMATION_SCHEMA.COLUMNS where table_schema = '" . $database . "' AND table_name = '" . $k . "'";
|
|
$comment = \DB::select($sql);
|
|
$comment = \DB::select($sql);
|
|
$data2[$v] = $comment;
|
|
$data2[$v] = $comment;
|
|
}
|
|
}
|
|
@@ -484,7 +488,8 @@ class CommonController extends Controller
|
|
* @param array $data 参数
|
|
* @param array $data 参数
|
|
* @return mixed
|
|
* @return mixed
|
|
*/
|
|
*/
|
|
- public function BindAxb($phone1,$phone2,$data=[]){
|
|
|
|
|
|
+ public function BindAxb($phone1, $phone2, $data = [])
|
|
|
|
+ {
|
|
$config = config('config.axb');
|
|
$config = config('config.axb');
|
|
AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
|
|
AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
|
|
->regionId('cn-kunming')
|
|
->regionId('cn-kunming')
|
|
@@ -498,7 +503,7 @@ class CommonController extends Controller
|
|
->host('dyplsapi.aliyuncs.com')
|
|
->host('dyplsapi.aliyuncs.com')
|
|
->options([
|
|
->options([
|
|
'query' => [
|
|
'query' => [
|
|
- "Expiration" => date("Y-m-d H:i:s",strtotime("+1 day")),
|
|
|
|
|
|
+ "Expiration" => date("Y-m-d H:i:s", strtotime("+1 day")),
|
|
'RegionId' => "cn-kunming",
|
|
'RegionId' => "cn-kunming",
|
|
'PhoneNoA' => $phone1,
|
|
'PhoneNoA' => $phone1,
|
|
'PhoneNoB' => $phone2,
|
|
'PhoneNoB' => $phone2,
|
|
@@ -519,7 +524,8 @@ class CommonController extends Controller
|
|
* 释放虚拟号码
|
|
* 释放虚拟号码
|
|
* @param int $phone
|
|
* @param int $phone
|
|
*/
|
|
*/
|
|
- public function ReleaseSecretNo($phone){
|
|
|
|
|
|
+ public function ReleaseSecretNo($phone)
|
|
|
|
+ {
|
|
$config = config('config.axb');
|
|
$config = config('config.axb');
|
|
AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
|
|
AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
|
|
->regionId('cn-kunming')
|
|
->regionId('cn-kunming')
|
|
@@ -542,7 +548,7 @@ class CommonController extends Controller
|
|
])
|
|
])
|
|
->request();
|
|
->request();
|
|
$res = $result->toArray();
|
|
$res = $result->toArray();
|
|
- return $res;
|
|
|
|
|
|
+ return $res;
|
|
|
|
|
|
} catch (ClientException $e) {
|
|
} catch (ClientException $e) {
|
|
echo $e->getErrorMessage() . PHP_EOL;
|
|
echo $e->getErrorMessage() . PHP_EOL;
|
|
@@ -557,7 +563,8 @@ class CommonController extends Controller
|
|
* @param $phone
|
|
* @param $phone
|
|
* @return mixed
|
|
* @return mixed
|
|
*/
|
|
*/
|
|
- public function QuerySubscriptionDetail($phone,$SubsId){
|
|
|
|
|
|
+ public function QuerySubscriptionDetail($phone, $SubsId)
|
|
|
|
+ {
|
|
$config = config('config.axb');
|
|
$config = config('config.axb');
|
|
AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
|
|
AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
|
|
->regionId('cn-kunming')
|
|
->regionId('cn-kunming')
|
|
@@ -584,7 +591,7 @@ class CommonController extends Controller
|
|
->request();
|
|
->request();
|
|
|
|
|
|
$res = $result->toArray();
|
|
$res = $result->toArray();
|
|
- return $res;
|
|
|
|
|
|
+ return $res;
|
|
|
|
|
|
} catch (ClientException $e) {
|
|
} catch (ClientException $e) {
|
|
echo $e->getErrorMessage() . PHP_EOL;
|
|
echo $e->getErrorMessage() . PHP_EOL;
|
|
@@ -599,7 +606,8 @@ class CommonController extends Controller
|
|
* @param $phone
|
|
* @param $phone
|
|
* @return mixed
|
|
* @return mixed
|
|
*/
|
|
*/
|
|
- public function UnbindSubscription($phone,$subId){
|
|
|
|
|
|
+ public function UnbindSubscription($phone, $subId)
|
|
|
|
+ {
|
|
$config = config('config.axb');
|
|
$config = config('config.axb');
|
|
AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
|
|
AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
|
|
->regionId('cn-kunming')
|
|
->regionId('cn-kunming')
|
|
@@ -636,7 +644,8 @@ class CommonController extends Controller
|
|
* @param $phone X号码
|
|
* @param $phone X号码
|
|
* @return mixed
|
|
* @return mixed
|
|
*/
|
|
*/
|
|
- public function QuerySubsId($phone){
|
|
|
|
|
|
+ public function QuerySubsId($phone)
|
|
|
|
+ {
|
|
$config = config('config.axb');
|
|
$config = config('config.axb');
|
|
AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
|
|
AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
|
|
->regionId('cn-kunming')
|
|
->regionId('cn-kunming')
|
|
@@ -674,11 +683,12 @@ class CommonController extends Controller
|
|
* @author Liu-Yh
|
|
* @author Liu-Yh
|
|
* Create By 2020/11/25 18:36
|
|
* Create By 2020/11/25 18:36
|
|
*/
|
|
*/
|
|
- public function unLokPhone($phone,$SubsId){
|
|
|
|
- $unlok = $this->UnbindSubscription($phone,$SubsId);
|
|
|
|
- if ($unlok['Code']!='OK'){
|
|
|
|
|
|
+ public function unLokPhone($phone, $SubsId)
|
|
|
|
+ {
|
|
|
|
+ $unlok = $this->UnbindSubscription($phone, $SubsId);
|
|
|
|
+ if ($unlok['Code'] != 'OK') {
|
|
return out($unlok);
|
|
return out($unlok);
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -686,10 +696,11 @@ class CommonController extends Controller
|
|
/**
|
|
/**
|
|
* 测试解除绑定电话的方法
|
|
* 测试解除绑定电话的方法
|
|
*/
|
|
*/
|
|
- public function testunlockphone(){
|
|
|
|
|
|
+ public function testunlockphone()
|
|
|
|
+ {
|
|
$phone = 17052201940;
|
|
$phone = 17052201940;
|
|
$sub_id = 1000027059330181;
|
|
$sub_id = 1000027059330181;
|
|
- var_dump($this->unLokPhone($phone,$sub_id));
|
|
|
|
|
|
+ var_dump($this->unLokPhone($phone, $sub_id));
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -699,7 +710,8 @@ class CommonController extends Controller
|
|
* @author Liu-Yh
|
|
* @author Liu-Yh
|
|
* Create By 2020/11/26 10:51
|
|
* Create By 2020/11/26 10:51
|
|
*/
|
|
*/
|
|
- public function QueryCallStatus($phone,$SubsId){
|
|
|
|
|
|
+ public function QueryCallStatus($phone, $SubsId)
|
|
|
|
+ {
|
|
$config = config('config.axb');
|
|
$config = config('config.axb');
|
|
AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
|
|
AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
|
|
->regionId('cn-kunming')
|
|
->regionId('cn-kunming')
|
|
@@ -736,7 +748,8 @@ class CommonController extends Controller
|
|
* @author Liu-Yh
|
|
* @author Liu-Yh
|
|
* Create By 2020/11/25 14:44
|
|
* Create By 2020/11/25 14:44
|
|
*/
|
|
*/
|
|
- public function StartSecretReport(){
|
|
|
|
|
|
+ public function StartSecretReport()
|
|
|
|
+ {
|
|
$config = config('config.axb');
|
|
$config = config('config.axb');
|
|
AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
|
|
AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
|
|
->regionId('cn-kunming')
|
|
->regionId('cn-kunming')
|
|
@@ -774,7 +787,7 @@ class CommonController extends Controller
|
|
$mnsRequest = new BatchReceiveMessage(10, 5);
|
|
$mnsRequest = new BatchReceiveMessage(10, 5);
|
|
$mnsRequest->setQueueName($queueName);
|
|
$mnsRequest->setQueueName($queueName);
|
|
$mnsResponse = $mnsClient->sendRequest($mnsRequest);
|
|
$mnsResponse = $mnsClient->sendRequest($mnsRequest);
|
|
- $receiptHandles = Array();
|
|
|
|
|
|
+ $receiptHandles = array();
|
|
foreach ($mnsResponse->Message as $message) {
|
|
foreach ($mnsResponse->Message as $message) {
|
|
// 用户逻辑:
|
|
// 用户逻辑:
|
|
// 入库
|
|
// 入库
|
|
@@ -782,7 +795,7 @@ class CommonController extends Controller
|
|
// var_dump(json_decode(base64_decode($message->MessageBody),true));
|
|
// var_dump(json_decode(base64_decode($message->MessageBody),true));
|
|
|
|
|
|
// $receiptHandles[] = $message->ReceiptHandle; // 加入$receiptHandles数组中的记录将会被删除
|
|
// $receiptHandles[] = $message->ReceiptHandle; // 加入$receiptHandles数组中的记录将会被删除
|
|
- $messageBody = json_decode(base64_decode($message->MessageBody),true); // base64解码后的JSON字符串
|
|
|
|
|
|
+ $messageBody = json_decode(base64_decode($message->MessageBody), true); // base64解码后的JSON字符串
|
|
echo "进来了";
|
|
echo "进来了";
|
|
|
|
|
|
var_dump($messageBody);
|
|
var_dump($messageBody);
|
|
@@ -804,13 +817,13 @@ class CommonController extends Controller
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 接收通话结束时的通话记录报告内容,可以在呼叫结束后获取通话记录信息,包括通话开始时间、通话结束时间、主被叫号码等,
|
|
* 接收通话结束时的通话记录报告内容,可以在呼叫结束后获取通话记录信息,包括通话开始时间、通话结束时间、主被叫号码等,
|
|
* @author Liu-Yh
|
|
* @author Liu-Yh
|
|
* Create By 2020/11/25 12:29
|
|
* Create By 2020/11/25 12:29
|
|
*/
|
|
*/
|
|
- public function SecretPullReport(){
|
|
|
|
|
|
+ public function SecretPullReport()
|
|
|
|
+ {
|
|
$config = config('config.axb');
|
|
$config = config('config.axb');
|
|
AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
|
|
AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
|
|
->regionId('cn-kunming')
|
|
->regionId('cn-kunming')
|
|
@@ -848,85 +861,85 @@ class CommonController extends Controller
|
|
$mnsRequest = new BatchReceiveMessage(10, 5);
|
|
$mnsRequest = new BatchReceiveMessage(10, 5);
|
|
$mnsRequest->setQueueName($queueName);
|
|
$mnsRequest->setQueueName($queueName);
|
|
$mnsResponse = $mnsClient->sendRequest($mnsRequest);
|
|
$mnsResponse = $mnsClient->sendRequest($mnsRequest);
|
|
- $receiptHandles = Array();
|
|
|
|
|
|
+ $receiptHandles = array();
|
|
$getList = CallLog::get();
|
|
$getList = CallLog::get();
|
|
- if ($getList){
|
|
|
|
|
|
+ if ($getList) {
|
|
$getList = $getList->toArray();
|
|
$getList = $getList->toArray();
|
|
}
|
|
}
|
|
$msgs = $mnsResponse->Message;
|
|
$msgs = $mnsResponse->Message;
|
|
- if (!is_array($msgs)){
|
|
|
|
- $messageBody = json_decode(base64_decode($msgs->MessageBody),true); // base64解码后的JSON字符
|
|
|
|
- if (count($getList)==0){
|
|
|
|
|
|
+ if (!is_array($msgs)) {
|
|
|
|
+ $messageBody = json_decode(base64_decode($msgs->MessageBody), true); // base64解码后的JSON字符
|
|
|
|
+ if (count($getList) == 0) {
|
|
CallLog::create([
|
|
CallLog::create([
|
|
- 'call_time'=>$messageBody['call_time'],
|
|
|
|
- 'ring_time'=>$messageBody['release_time'],
|
|
|
|
- 'release_dir'=>$messageBody['release_dir'],
|
|
|
|
- 'call_type'=>$messageBody['call_type'],
|
|
|
|
- 'aphone'=>$messageBody['phone_no'],
|
|
|
|
- 'bphone'=>$messageBody['peer_no'],
|
|
|
|
- 'call_id'=>$messageBody['call_id'],
|
|
|
|
- 'secret_no'=>$messageBody['secret_no'],
|
|
|
|
- 'sub_id'=>$messageBody['sub_id'],
|
|
|
|
- 'talk_time'=> strtotime($messageBody['release_time'])-strtotime($messageBody['start_time']),
|
|
|
|
|
|
+ 'call_time' => $messageBody['call_time'],
|
|
|
|
+ 'ring_time' => $messageBody['release_time'],
|
|
|
|
+ 'release_dir' => $messageBody['release_dir'],
|
|
|
|
+ 'call_type' => $messageBody['call_type'],
|
|
|
|
+ 'aphone' => $messageBody['phone_no'],
|
|
|
|
+ 'bphone' => $messageBody['peer_no'],
|
|
|
|
+ 'call_id' => $messageBody['call_id'],
|
|
|
|
+ 'secret_no' => $messageBody['secret_no'],
|
|
|
|
+ 'sub_id' => $messageBody['sub_id'],
|
|
|
|
+ 'talk_time' => strtotime($messageBody['release_time']) - strtotime($messageBody['start_time']),
|
|
]);
|
|
]);
|
|
- }else{
|
|
|
|
- foreach ($getList as $k=>$v){
|
|
|
|
- if ($v['call_id']==$messageBody['call_id']){
|
|
|
|
|
|
+ } else {
|
|
|
|
+ foreach ($getList as $k => $v) {
|
|
|
|
+ if ($v['call_id'] == $messageBody['call_id']) {
|
|
unset($messageBody);
|
|
unset($messageBody);
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
CallLog::create([
|
|
CallLog::create([
|
|
- 'call_time'=>$messageBody['call_time'],
|
|
|
|
- 'ring_time'=>$messageBody['release_time'],
|
|
|
|
- 'release_dir'=>$messageBody['release_dir'],
|
|
|
|
- 'call_type'=>$messageBody['call_type'],
|
|
|
|
- 'aphone'=>$messageBody['phone_no'],
|
|
|
|
- 'bphone'=>$messageBody['peer_no'],
|
|
|
|
- 'call_id'=>$messageBody['call_id'],
|
|
|
|
- 'secret_no'=>$messageBody['secret_no'],
|
|
|
|
- 'sub_id'=>$messageBody['sub_id'],
|
|
|
|
- 'talk_time'=> strtotime($messageBody['release_time'])-strtotime($messageBody['start_time']),
|
|
|
|
|
|
+ 'call_time' => $messageBody['call_time'],
|
|
|
|
+ 'ring_time' => $messageBody['release_time'],
|
|
|
|
+ 'release_dir' => $messageBody['release_dir'],
|
|
|
|
+ 'call_type' => $messageBody['call_type'],
|
|
|
|
+ 'aphone' => $messageBody['phone_no'],
|
|
|
|
+ 'bphone' => $messageBody['peer_no'],
|
|
|
|
+ 'call_id' => $messageBody['call_id'],
|
|
|
|
+ 'secret_no' => $messageBody['secret_no'],
|
|
|
|
+ 'sub_id' => $messageBody['sub_id'],
|
|
|
|
+ 'talk_time' => strtotime($messageBody['release_time']) - strtotime($messageBody['start_time']),
|
|
]);
|
|
]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
foreach ($msgs as $message) {
|
|
foreach ($msgs as $message) {
|
|
// 用户逻辑:
|
|
// 用户逻辑:
|
|
- $messageBody = json_decode(base64_decode($message->MessageBody),true); // base64解码后的JSON字符串
|
|
|
|
- if (count($getList)==0) {
|
|
|
|
|
|
+ $messageBody = json_decode(base64_decode($message->MessageBody), true); // base64解码后的JSON字符串
|
|
|
|
+ if (count($getList) == 0) {
|
|
CallLog::create([
|
|
CallLog::create([
|
|
- 'call_time'=>$messageBody['call_time'],
|
|
|
|
- 'ring_time'=>$messageBody['release_time'],
|
|
|
|
- 'release_dir'=>$messageBody['release_dir'],
|
|
|
|
- 'call_type'=>$messageBody['call_type'],
|
|
|
|
- 'aphone'=>$messageBody['phone_no'],
|
|
|
|
- 'bphone'=>$messageBody['peer_no'],
|
|
|
|
- 'call_id'=>$messageBody['call_id'],
|
|
|
|
- 'secret_no'=>$messageBody['secret_no'],
|
|
|
|
- 'sub_id'=>$messageBody['sub_id'],
|
|
|
|
- 'talk_time'=> strtotime($messageBody['release_time'])-strtotime($messageBody['start_time']),
|
|
|
|
|
|
+ 'call_time' => $messageBody['call_time'],
|
|
|
|
+ 'ring_time' => $messageBody['release_time'],
|
|
|
|
+ 'release_dir' => $messageBody['release_dir'],
|
|
|
|
+ 'call_type' => $messageBody['call_type'],
|
|
|
|
+ 'aphone' => $messageBody['phone_no'],
|
|
|
|
+ 'bphone' => $messageBody['peer_no'],
|
|
|
|
+ 'call_id' => $messageBody['call_id'],
|
|
|
|
+ 'secret_no' => $messageBody['secret_no'],
|
|
|
|
+ 'sub_id' => $messageBody['sub_id'],
|
|
|
|
+ 'talk_time' => strtotime($messageBody['release_time']) - strtotime($messageBody['start_time']),
|
|
]);
|
|
]);
|
|
- }else{
|
|
|
|
- foreach ($getList as $k=>$v){
|
|
|
|
- if ($v['call_id']==$messageBody['call_id']){
|
|
|
|
|
|
+ } else {
|
|
|
|
+ foreach ($getList as $k => $v) {
|
|
|
|
+ if ($v['call_id'] == $messageBody['call_id']) {
|
|
unset($messageBody);
|
|
unset($messageBody);
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
CallLog::create([
|
|
CallLog::create([
|
|
- 'call_time'=>$messageBody['call_time'],
|
|
|
|
- 'ring_time'=>$messageBody['release_time'],
|
|
|
|
- 'release_dir'=>$messageBody['release_dir'],
|
|
|
|
- 'call_type'=>$messageBody['call_type'],
|
|
|
|
- 'aphone'=>$messageBody['phone_no'],
|
|
|
|
- 'bphone'=>$messageBody['peer_no'],
|
|
|
|
- 'call_id'=>$messageBody['call_id'],
|
|
|
|
- 'secret_no'=>$messageBody['secret_no'],
|
|
|
|
- 'sub_id'=>$messageBody['sub_id'],
|
|
|
|
- 'talk_time'=> strtotime($messageBody['release_time'])-strtotime($messageBody['start_time']),
|
|
|
|
|
|
+ 'call_time' => $messageBody['call_time'],
|
|
|
|
+ 'ring_time' => $messageBody['release_time'],
|
|
|
|
+ 'release_dir' => $messageBody['release_dir'],
|
|
|
|
+ 'call_type' => $messageBody['call_type'],
|
|
|
|
+ 'aphone' => $messageBody['phone_no'],
|
|
|
|
+ 'bphone' => $messageBody['peer_no'],
|
|
|
|
+ 'call_id' => $messageBody['call_id'],
|
|
|
|
+ 'secret_no' => $messageBody['secret_no'],
|
|
|
|
+ 'sub_id' => $messageBody['sub_id'],
|
|
|
|
+ 'talk_time' => strtotime($messageBody['release_time']) - strtotime($messageBody['start_time']),
|
|
]);
|
|
]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- $receiptHandles[] = $message->ReceiptHandle; // 加入$receiptHandles数组中的记录将会被删除
|
|
|
|
|
|
+ $receiptHandles[] = $message->ReceiptHandle; // 加入$receiptHandles数组中的记录将会被删除
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (count($receiptHandles) > 0) {
|
|
if (count($receiptHandles) > 0) {
|
|
@@ -946,35 +959,34 @@ class CommonController extends Controller
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 通话开始时候回调数据
|
|
* 通话开始时候回调数据
|
|
* @return false|string
|
|
* @return false|string
|
|
* 返回参数
|
|
* 返回参数
|
|
* [{
|
|
* [{
|
|
- "phone_no": "18831138292",
|
|
|
|
- "pool_key": "FC100000115024469", 对应的号池Key。
|
|
|
|
- "city": "昆明",
|
|
|
|
- "sub_id": 1000027052283144, 通话对应的三元组的绑定关系ID。
|
|
|
|
- "unconnected_cause": 0,
|
|
|
|
- "call_time": "2020-12-21 17:23:56", 主叫拨打时间。
|
|
|
|
- "peer_no": "15222021008", AXB中的B号码或者N号码。
|
|
|
|
- "called_display_no": "17052201941", 被叫显号X号码
|
|
|
|
- "call_id": "31343639616333323735", 唯一标识一通通话记录的ID。
|
|
|
|
- "partner_key": "FC100000115024469",
|
|
|
|
- "control_msg": "OK",
|
|
|
|
- "id": 1007221453890,
|
|
|
|
- "secret_no": "17052201941",
|
|
|
|
- "call_type": 0,0:主叫(phone_no打给peer_no);1:被叫(peer_no打给phone_no);2:短信发送;3:短信接收;4:呼叫拦截;5:短信收发拦截;
|
|
|
|
- "control_type": "CONTINUE"
|
|
|
|
- }]
|
|
|
|
|
|
+ * "phone_no": "18831138292",
|
|
|
|
+ * "pool_key": "FC100000115024469", 对应的号池Key。
|
|
|
|
+ * "city": "昆明",
|
|
|
|
+ * "sub_id": 1000027052283144, 通话对应的三元组的绑定关系ID。
|
|
|
|
+ * "unconnected_cause": 0,
|
|
|
|
+ * "call_time": "2020-12-21 17:23:56", 主叫拨打时间。
|
|
|
|
+ * "peer_no": "15222021008", AXB中的B号码或者N号码。
|
|
|
|
+ * "called_display_no": "17052201941", 被叫显号X号码
|
|
|
|
+ * "call_id": "31343639616333323735", 唯一标识一通通话记录的ID。
|
|
|
|
+ * "partner_key": "FC100000115024469",
|
|
|
|
+ * "control_msg": "OK",
|
|
|
|
+ * "id": 1007221453890,
|
|
|
|
+ * "secret_no": "17052201941",
|
|
|
|
+ * "call_type": 0,0:主叫(phone_no打给peer_no);1:被叫(peer_no打给phone_no);2:短信发送;3:短信接收;4:呼叫拦截;5:短信收发拦截;
|
|
|
|
+ * "control_type": "CONTINUE"
|
|
|
|
+ * }]
|
|
*/
|
|
*/
|
|
- public function SecretStartReport(){
|
|
|
|
|
|
+ public function SecretStartReport()
|
|
|
|
+ {
|
|
// 开始json
|
|
// 开始json
|
|
$req = request()->post();
|
|
$req = request()->post();
|
|
// 首先创建记录
|
|
// 首先创建记录
|
|
- if ($req){
|
|
|
|
|
|
+ if ($req) {
|
|
try {
|
|
try {
|
|
$data = [];
|
|
$data = [];
|
|
$data['call_time'] = $req[0]['call_time'];
|
|
$data['call_time'] = $req[0]['call_time'];
|
|
@@ -985,15 +997,15 @@ class CommonController extends Controller
|
|
$data['secret_no'] = $req[0]['called_display_no'];
|
|
$data['secret_no'] = $req[0]['called_display_no'];
|
|
$data['sub_id'] = $req[0]['sub_id'];
|
|
$data['sub_id'] = $req[0]['sub_id'];
|
|
CallLog::create($data);
|
|
CallLog::create($data);
|
|
- }catch (\Exception $e){
|
|
|
|
- var_dump($e->getFile().$e->getLine().$e->getMessage());
|
|
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
+ var_dump($e->getFile() . $e->getLine() . $e->getMessage());
|
|
|
|
|
|
- }catch (\PDOException $e){
|
|
|
|
- var_dump($e->getFile().$e->getLine().$e->getMessage());
|
|
|
|
|
|
+ } catch (\PDOException $e) {
|
|
|
|
+ var_dump($e->getFile() . $e->getLine() . $e->getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- return json_encode(['code'=>0,'msg'=>"成功"],JSON_UNESCAPED_UNICODE);
|
|
|
|
|
|
+ return json_encode(['code' => 0, 'msg' => "成功"], JSON_UNESCAPED_UNICODE);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1002,73 +1014,74 @@ class CommonController extends Controller
|
|
* @return false|string
|
|
* @return false|string
|
|
* 回调数据
|
|
* 回调数据
|
|
* [{
|
|
* [{
|
|
- "phone_no": "18831138292", 主叫号码
|
|
|
|
- "pool_key": "FC100000115024469", 对应的号池Key。
|
|
|
|
- "city": "昆明",
|
|
|
|
- "sub_id": 1000027052283144, 通话对应的三元组的绑定关系ID。
|
|
|
|
- "unconnected_cause": 0, 0表示正常通话,1表示黑名单拦截,2表示无绑定关系,3表示呼叫限制,4表示其他
|
|
|
|
- "call_time": "2020-12-21 17:23:56", 主叫拨打时间
|
|
|
|
- "call_out_time": "2020-12-21 17:23:56", 呼叫由X送给B端局的时间
|
|
|
|
- "peer_no": "15222021008", AXB中的B号码或者N号码
|
|
|
|
- "called_display_no": "17052201941", 被叫显号
|
|
|
|
- "release_dir": 2, 通话释放方向。0表示平台释放,1表示主叫挂断,2表示被叫挂断
|
|
|
|
- "ring_time": "2020-12-21 17:23:56", 呼叫送被叫端局时,被叫端局响应的时间。
|
|
|
|
- "call_id": "31343639616333323735", 唯一标识一通通话记录的ID。
|
|
|
|
- "start_time": "2020-12-21 17:24:05", 被叫接听时间
|
|
|
|
- "free_ring_time": "2020-12-21 17:24:03",被叫手机真实的振铃时间。free_ring_time 大于call_out_time表示被叫真实发生了振铃事件。free_ring_time 和call_out_time相等表示未振铃。
|
|
|
|
- "partner_key": "FC100000115024469",
|
|
|
|
- "control_msg": "OK",
|
|
|
|
- "id": 1007221453890,
|
|
|
|
- "secret_no": "17052201941", AXB中的X号码
|
|
|
|
- "call_type": 0, 呼叫类型,包括:0:主叫,即phone_no打给peer_no。1:被叫,即peer_no打给phone_no。2:短信发送。3:短信接收。4:呼叫拦截5:短信收发拦截
|
|
|
|
- "release_cause": 16, 释放原因。请根据编号在释放原因中查看。
|
|
|
|
- "control_type": "CONTINUE",
|
|
|
|
- "release_time": "2020-12-21 17:24:09" 被叫挂断时间。release_time和start_time之差表示通话时长, 如果结果为0,说明呼叫未接通
|
|
|
|
- }]
|
|
|
|
|
|
+ * "phone_no": "18831138292", 主叫号码
|
|
|
|
+ * "pool_key": "FC100000115024469", 对应的号池Key。
|
|
|
|
+ * "city": "昆明",
|
|
|
|
+ * "sub_id": 1000027052283144, 通话对应的三元组的绑定关系ID。
|
|
|
|
+ * "unconnected_cause": 0, 0表示正常通话,1表示黑名单拦截,2表示无绑定关系,3表示呼叫限制,4表示其他
|
|
|
|
+ * "call_time": "2020-12-21 17:23:56", 主叫拨打时间
|
|
|
|
+ * "call_out_time": "2020-12-21 17:23:56", 呼叫由X送给B端局的时间
|
|
|
|
+ * "peer_no": "15222021008", AXB中的B号码或者N号码
|
|
|
|
+ * "called_display_no": "17052201941", 被叫显号
|
|
|
|
+ * "release_dir": 2, 通话释放方向。0表示平台释放,1表示主叫挂断,2表示被叫挂断
|
|
|
|
+ * "ring_time": "2020-12-21 17:23:56", 呼叫送被叫端局时,被叫端局响应的时间。
|
|
|
|
+ * "call_id": "31343639616333323735", 唯一标识一通通话记录的ID。
|
|
|
|
+ * "start_time": "2020-12-21 17:24:05", 被叫接听时间
|
|
|
|
+ * "free_ring_time": "2020-12-21 17:24:03",被叫手机真实的振铃时间。free_ring_time 大于call_out_time表示被叫真实发生了振铃事件。free_ring_time 和call_out_time相等表示未振铃。
|
|
|
|
+ * "partner_key": "FC100000115024469",
|
|
|
|
+ * "control_msg": "OK",
|
|
|
|
+ * "id": 1007221453890,
|
|
|
|
+ * "secret_no": "17052201941", AXB中的X号码
|
|
|
|
+ * "call_type": 0, 呼叫类型,包括:0:主叫,即phone_no打给peer_no。1:被叫,即peer_no打给phone_no。2:短信发送。3:短信接收。4:呼叫拦截5:短信收发拦截
|
|
|
|
+ * "release_cause": 16, 释放原因。请根据编号在释放原因中查看。
|
|
|
|
+ * "control_type": "CONTINUE",
|
|
|
|
+ * "release_time": "2020-12-21 17:24:09" 被叫挂断时间。release_time和start_time之差表示通话时长, 如果结果为0,说明呼叫未接通
|
|
|
|
+ * }]
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
- public function SecretReport(){
|
|
|
|
|
|
+ public function SecretReport()
|
|
|
|
+ {
|
|
|
|
|
|
$req = request()->post();
|
|
$req = request()->post();
|
|
- $callids = CallLog::where('call_id',$req[0]['call_id'])->first();
|
|
|
|
|
|
+ $callids = CallLog::where('call_id', $req[0]['call_id'])->first();
|
|
if ($req && $callids) {
|
|
if ($req && $callids) {
|
|
try {
|
|
try {
|
|
- if ($callids){
|
|
|
|
- if($req[0]['release_dir']==0||(strtotime($req[0]['release_time'])-strtotime($req[0]['start_time']))==0||$req[0]['unconnected_cause']!=0){
|
|
|
|
- CallLog::where('call_id',$req[0]['call_id'])->delete();
|
|
|
|
- }else{
|
|
|
|
|
|
+ if ($callids) {
|
|
|
|
+ if ($req[0]['release_dir'] == 0 || (strtotime($req[0]['release_time']) - strtotime($req[0]['start_time'])) == 0 || $req[0]['unconnected_cause'] != 0) {
|
|
|
|
+ CallLog::where('call_id', $req[0]['call_id'])->delete();
|
|
|
|
+ } else {
|
|
// 修改信息
|
|
// 修改信息
|
|
- $axbId = Axb::where(['xphone'=>$req[0]['called_display_no'],'subs_id'=>$req[0]['sub_id']])->first();
|
|
|
|
- if($axbId){
|
|
|
|
|
|
+ $axbId = Axb::where(['xphone' => $req[0]['called_display_no'], 'subs_id' => $req[0]['sub_id']])->first();
|
|
|
|
+ if ($axbId) {
|
|
$where['docter_id'] = $axbId['docter_id'];
|
|
$where['docter_id'] = $axbId['docter_id'];
|
|
$where['user_id'] = $axbId['user_id'];
|
|
$where['user_id'] = $axbId['user_id'];
|
|
- $where['product_type'] =1;
|
|
|
|
- $where['order_status'] =3;
|
|
|
|
- $where['payment_status'] =2;
|
|
|
|
|
|
+ $where['product_type'] = 1;
|
|
|
|
+ $where['order_status'] = 3;
|
|
|
|
+ $where['payment_status'] = 2;
|
|
$order_id = Order::where($where)->first();
|
|
$order_id = Order::where($where)->first();
|
|
- if ($order_id){
|
|
|
|
|
|
+ if ($order_id) {
|
|
$order_id = $order_id->id;
|
|
$order_id = $order_id->id;
|
|
$save_data = [];
|
|
$save_data = [];
|
|
$save_data['order_id'] = $order_id;
|
|
$save_data['order_id'] = $order_id;
|
|
$save_data['ring_time'] = $req[0]['release_time'];
|
|
$save_data['ring_time'] = $req[0]['release_time'];
|
|
$save_data['docter_id'] = $axbId['docter_id'];
|
|
$save_data['docter_id'] = $axbId['docter_id'];
|
|
$save_data['release_dir'] = $req[0]['release_dir'];
|
|
$save_data['release_dir'] = $req[0]['release_dir'];
|
|
- $save_data['talk_time'] = strtotime($req[0]['release_time'])-strtotime($req[0]['start_time']);
|
|
|
|
- $save_data['text'] = json_encode($req,JSON_UNESCAPED_UNICODE);
|
|
|
|
|
|
+ $save_data['talk_time'] = strtotime($req[0]['release_time']) - strtotime($req[0]['start_time']);
|
|
|
|
+ $save_data['text'] = json_encode($req, JSON_UNESCAPED_UNICODE);
|
|
// 解除号码绑定,并且删除数据库绑定信息
|
|
// 解除号码绑定,并且删除数据库绑定信息
|
|
// $this->unLokPhone($req[0]['called_display_no'],$req[0]['sub_id']);
|
|
// $this->unLokPhone($req[0]['called_display_no'],$req[0]['sub_id']);
|
|
// Axb::where(['subs_id'=>$req[0]['sub_id']])->delete();
|
|
// Axb::where(['subs_id'=>$req[0]['sub_id']])->delete();
|
|
- CallLog::where('call_id',$req[0]['call_id'])->update($save_data);
|
|
|
|
- return json_encode(['code'=>0,'msg'=>"成功"],JSON_UNESCAPED_UNICODE);
|
|
|
|
|
|
+ CallLog::where('call_id', $req[0]['call_id'])->update($save_data);
|
|
|
|
+ return json_encode(['code' => 0, 'msg' => "成功"], JSON_UNESCAPED_UNICODE);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- }catch (\Exception $e){
|
|
|
|
- CallLog::create(['text'=>json_encode($e->getFile().$e->getCode().$e->getMessage(),JSON_UNESCAPED_UNICODE)]);
|
|
|
|
- }catch (\PDOException $e){
|
|
|
|
- CallLog::create(['text'=>json_encode($e->getFile().$e->getCode().$e->getMessage(),JSON_UNESCAPED_UNICODE)]);
|
|
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
+ CallLog::create(['text' => json_encode($e->getFile() . $e->getCode() . $e->getMessage(), JSON_UNESCAPED_UNICODE)]);
|
|
|
|
+ } catch (\PDOException $e) {
|
|
|
|
+ CallLog::create(['text' => json_encode($e->getFile() . $e->getCode() . $e->getMessage(), JSON_UNESCAPED_UNICODE)]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return json_encode(['code' => 0, 'msg' => "成功"], JSON_UNESCAPED_UNICODE);
|
|
return json_encode(['code' => 0, 'msg' => "成功"], JSON_UNESCAPED_UNICODE);
|
|
@@ -1078,9 +1091,10 @@ class CommonController extends Controller
|
|
* 录音文件返回
|
|
* 录音文件返回
|
|
* @return false|string
|
|
* @return false|string
|
|
*/
|
|
*/
|
|
- public function Recording_status(){
|
|
|
|
|
|
+ public function Recording_status()
|
|
|
|
+ {
|
|
$req = request()->post();
|
|
$req = request()->post();
|
|
- trace(['录音文件返回'=>'成功','入库数据'=>$req[0]],'info');
|
|
|
|
|
|
+ trace(['录音文件返回' => '成功', '入库数据' => $req[0]], 'info');
|
|
$config = config('config.axb');
|
|
$config = config('config.axb');
|
|
AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
|
|
AlibabaCloud::accessKeyClient($config['appid'], $config['appscret'])
|
|
->regionId('cn-kunming')
|
|
->regionId('cn-kunming')
|
|
@@ -1089,18 +1103,18 @@ class CommonController extends Controller
|
|
$result = AlibabaCloud::dyplsapi()
|
|
$result = AlibabaCloud::dyplsapi()
|
|
->v20170525()
|
|
->v20170525()
|
|
->queryRecordFileDownloadUrl()
|
|
->queryRecordFileDownloadUrl()
|
|
- ->withCallTime(date('Y-m-d H:i:s',substr($req[0]['call_time'], 0, 10)))
|
|
|
|
|
|
+ ->withCallTime(date('Y-m-d H:i:s', substr($req[0]['call_time'], 0, 10)))
|
|
->withCallId($req[0]['call_id'])
|
|
->withCallId($req[0]['call_id'])
|
|
->withPoolKey($req[0]['pool_key'])
|
|
->withPoolKey($req[0]['pool_key'])
|
|
->request()->toArray();
|
|
->request()->toArray();
|
|
- trace(['录音文件返回1'=>'成功1','入库数据'=>$result],'info');
|
|
|
|
- if ($result['Message']=='OK'){
|
|
|
|
- $file = $this->downImgRar($result['DownloadUrl'],$req[0]['call_id']);
|
|
|
|
- CallLog::where('call_id',$req[0]['call_id'])->update(['files'=>$file]);
|
|
|
|
- trace(['录音文件完成'=>'成功','入库链接'=>$file],'info');
|
|
|
|
|
|
+ trace(['录音文件返回1' => '成功1', '入库数据' => $result], 'info');
|
|
|
|
+ if ($result['Message'] == 'OK') {
|
|
|
|
+ $file = $this->downImgRar($result['DownloadUrl'], $req[0]['call_id']);
|
|
|
|
+ CallLog::where('call_id', $req[0]['call_id'])->update(['files' => $file]);
|
|
|
|
+ trace(['录音文件完成' => '成功', '入库链接' => $file], 'info');
|
|
}
|
|
}
|
|
- }catch (\Exception $e){
|
|
|
|
- trace(['录音文件返回'=>'失败','入库数据'=>$req,'录音文件返回'=>isset($result)?$result:''],'info');
|
|
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
+ trace(['录音文件返回' => '失败', '入库数据' => $req, '录音文件返回' => isset($result) ? $result : ''], 'info');
|
|
}
|
|
}
|
|
return json_encode(['code' => 0, 'msg' => "成功"], JSON_UNESCAPED_UNICODE);
|
|
return json_encode(['code' => 0, 'msg' => "成功"], JSON_UNESCAPED_UNICODE);
|
|
}
|
|
}
|
|
@@ -1113,29 +1127,30 @@ class CommonController extends Controller
|
|
* @param $ext
|
|
* @param $ext
|
|
* @return string
|
|
* @return string
|
|
*/
|
|
*/
|
|
- public function downImgRar($url,$rename,$ext='mp3'){
|
|
|
|
- trace(['开始转换'=>'1','链接'=>$url],'info');
|
|
|
|
|
|
+ public function downImgRar($url, $rename, $ext = 'mp3')
|
|
|
|
+ {
|
|
|
|
+ trace(['开始转换' => '1', '链接' => $url], 'info');
|
|
try {
|
|
try {
|
|
$dir = iconv("UTF-8", "GBK", "upload/callLog/");
|
|
$dir = iconv("UTF-8", "GBK", "upload/callLog/");
|
|
- if (!file_exists($dir)){
|
|
|
|
- mkdir ($dir,0777,true);
|
|
|
|
|
|
+ if (!file_exists($dir)) {
|
|
|
|
+ mkdir($dir, 0777, true);
|
|
}
|
|
}
|
|
$file_path = 'upload/callLog/';
|
|
$file_path = 'upload/callLog/';
|
|
$ch = curl_init($url);
|
|
$ch = curl_init($url);
|
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
- curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
|
|
|
|
- $rawdata=curl_exec ($ch);
|
|
|
|
- curl_close ($ch);
|
|
|
|
|
|
+ curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
|
|
|
|
+ $rawdata = curl_exec($ch);
|
|
|
|
+ curl_close($ch);
|
|
// 使用中文文件名需要转码
|
|
// 使用中文文件名需要转码
|
|
- $fp = fopen($file_path.iconv('UTF-8', 'GBK', $rename).".".$ext,'w');
|
|
|
|
|
|
+ $fp = fopen($file_path . iconv('UTF-8', 'GBK', $rename) . "." . $ext, 'w');
|
|
fwrite($fp, $rawdata);
|
|
fwrite($fp, $rawdata);
|
|
fclose($fp);
|
|
fclose($fp);
|
|
// 返回路径
|
|
// 返回路径
|
|
- trace(['转换成功!'=>'1','地址'=>$_SERVER['DOCUMENT_ROOT'].$file_path.$rename.".".$ext],'info');
|
|
|
|
- return $file_path.$rename.".".$ext;
|
|
|
|
- }catch (\Exception $e){
|
|
|
|
- trace(['转换失败'=>'1','错误'=>$e->getFile().'文件'.$e->getLine().'行'.$e->getMessage().'错误!'],'info');
|
|
|
|
|
|
+ trace(['转换成功!' => '1', '地址' => $_SERVER['DOCUMENT_ROOT'] . $file_path . $rename . "." . $ext], 'info');
|
|
|
|
+ return $file_path . $rename . "." . $ext;
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
+ trace(['转换失败' => '1', '错误' => $e->getFile() . '文件' . $e->getLine() . '行' . $e->getMessage() . '错误!'], 'info');
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1146,22 +1161,23 @@ class CommonController extends Controller
|
|
* goEasy聊天记录存入数据库
|
|
* goEasy聊天记录存入数据库
|
|
* * @return false|string
|
|
* * @return false|string
|
|
*/
|
|
*/
|
|
- public function easyMessage(){
|
|
|
|
|
|
+ public function easyMessage()
|
|
|
|
+ {
|
|
$req = request()->post();
|
|
$req = request()->post();
|
|
- try {
|
|
|
|
- $data = json_decode($req['content'],true);
|
|
|
|
- $reminderController = new PatientController();
|
|
|
|
- $list = [];
|
|
|
|
- if($data){
|
|
|
|
|
|
+ $data = json_decode($req['content'], true);
|
|
|
|
+ if ($data) {
|
|
|
|
+ try {
|
|
|
|
+ $reminderController = new PatientController();
|
|
|
|
+ $list = [];
|
|
$ImList = ImMessage::select('messageId')->groupBy('messageId')->get();
|
|
$ImList = ImMessage::select('messageId')->groupBy('messageId')->get();
|
|
- $newList=[];
|
|
|
|
- if ($ImList){
|
|
|
|
- foreach ($ImList as $k=>$v){
|
|
|
|
|
|
+ $newList = [];
|
|
|
|
+ if ($ImList) {
|
|
|
|
+ foreach ($ImList as $k => $v) {
|
|
$newList[$k] = $v['messageId'];
|
|
$newList[$k] = $v['messageId'];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- foreach ($data as $k=>$v){
|
|
|
|
- if(!in_array($v['messageId'],$newList)){
|
|
|
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
|
+ if (!in_array($v['messageId'], $newList)) {
|
|
$list[$k]['messageId'] = $v['messageId'];
|
|
$list[$k]['messageId'] = $v['messageId'];
|
|
$list[$k]['type'] = $v['type'];
|
|
$list[$k]['type'] = $v['type'];
|
|
$list[$k]['senderId'] = $v['senderId'];
|
|
$list[$k]['senderId'] = $v['senderId'];
|
|
@@ -1170,40 +1186,39 @@ class CommonController extends Controller
|
|
$list[$k]['payload'] = $v['payload'];
|
|
$list[$k]['payload'] = $v['payload'];
|
|
$list[$k]['text'] = $req['content'];
|
|
$list[$k]['text'] = $req['content'];
|
|
$list[$k]['create_time'] = time();
|
|
$list[$k]['create_time'] = time();
|
|
- if (substr($v['senderId'],0,6)=='doctor'){
|
|
|
|
|
|
+ if (substr($v['senderId'], 0, 6) == 'doctor') {
|
|
// 说明是用户给医生发的, 就给医生端发消息
|
|
// 说明是用户给医生发的, 就给医生端发消息
|
|
$docter_id = substr($v['senderId'], 7);
|
|
$docter_id = substr($v['senderId'], 7);
|
|
$docter = Docter::where('id', $docter_id)->first()->toArray();
|
|
$docter = Docter::where('id', $docter_id)->first()->toArray();
|
|
|
|
|
|
- $user_id = substr($v['receiverId'],7);
|
|
|
|
|
|
+ $user_id = substr($v['receiverId'], 7);
|
|
$user = User::where('id', $user_id)->first()->toArray();
|
|
$user = User::where('id', $user_id)->first()->toArray();
|
|
|
|
|
|
- $send_time = date('Y-m-d H:i', round($v['timestamp']/1000));
|
|
|
|
|
|
+ $send_time = date('Y-m-d H:i', round($v['timestamp'] / 1000));
|
|
if ($v['type'] != 'text') {
|
|
if ($v['type'] != 'text') {
|
|
$text = '图片语音类消息';
|
|
$text = '图片语音类消息';
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
$payload = json_decode($v['payload'], true);
|
|
$payload = json_decode($v['payload'], true);
|
|
$text = !empty($payload['text']) ? $payload['text'] : '文字类消息';
|
|
$text = !empty($payload['text']) ? $payload['text'] : '文字类消息';
|
|
}
|
|
}
|
|
$official_arr = [$docter['openid'], $user['nickname'], $text, $send_time];
|
|
$official_arr = [$docter['openid'], $user['nickname'], $text, $send_time];
|
|
send_wechat_message_to_docter(12, $official_arr);
|
|
send_wechat_message_to_docter(12, $official_arr);
|
|
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
// 说明是医生给用户发的, 就给用户端发消息
|
|
// 说明是医生给用户发的, 就给用户端发消息
|
|
- $reminderController->ReplyReminder(substr($v['receiverId'],7),substr($v['senderId'],7));
|
|
|
|
|
|
+ $reminderController->ReplyReminder(substr($v['receiverId'], 7), substr($v['senderId'], 7));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ ImMessage::insert($list);
|
|
}
|
|
}
|
|
- ImMessage::insert($list);
|
|
|
|
|
|
+ return json_encode(['code' => 200, 'content' => 'success']);
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
+ ImMessage::create(['text' => json_encode($e->getFile() . '的第 ' . $e->getLine() . '行报错:' . $e->getMessage(), true)]);
|
|
|
|
+ } catch (\PDOException $e) {
|
|
|
|
+ ImMessage::create(['text' => json_encode($e->getFile() . '的第 ' . $e->getLine() . '行报错:' . $e->getMessage(), true)]);
|
|
}
|
|
}
|
|
- return json_encode(['code'=>200,'content'=>'success']);
|
|
|
|
- }catch (\Exception $e){
|
|
|
|
- ImMessage::create(['text'=>json_encode($e->getFile().'的第 '.$e->getLine().'行报错:'.$e->getMessage(),true)]);
|
|
|
|
- }catch (\PDOException $e){
|
|
|
|
- ImMessage::create(['text'=>json_encode($e->getFile().'的第 '.$e->getLine().'行报错:'.$e->getMessage(),true)]);
|
|
|
|
}
|
|
}
|
|
|
|
+ return json_encode(['code' => 200, 'content' => 'success']);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1211,13 +1226,14 @@ class CommonController extends Controller
|
|
* @return \Illuminate\Http\JsonResponse
|
|
* @return \Illuminate\Http\JsonResponse
|
|
* @throws \Illuminate\Validation\ValidationException
|
|
* @throws \Illuminate\Validation\ValidationException
|
|
*/
|
|
*/
|
|
- public function delFile(){
|
|
|
|
|
|
+ public function delFile()
|
|
|
|
+ {
|
|
$req = request()->post();
|
|
$req = request()->post();
|
|
$this->validate(request(), [
|
|
$this->validate(request(), [
|
|
'url' => 'required|url'
|
|
'url' => 'required|url'
|
|
]);
|
|
]);
|
|
$tem = parse_url($req['url']);
|
|
$tem = parse_url($req['url']);
|
|
- $allPath = public_path().$tem['path'];
|
|
|
|
|
|
+ $allPath = public_path() . $tem['path'];
|
|
unlink($allPath);
|
|
unlink($allPath);
|
|
return out();
|
|
return out();
|
|
|
|
|