Merge branch 'dev' into wanfang

dev
曾超新 5 years ago
commit 96a49d9aef
  1. 6
      frontend/config/params.php
  2. 142
      frontend/controllers/PhoneCenterController.php
  3. 24
      frontend/controllers/PhoneController.php

@ -1,4 +1,10 @@
<?php <?php
return [ return [
'adminEmail' => 'admin@example.com', 'adminEmail' => 'admin@example.com',
'userPanel' => [
'token' => 'ff7dc73536475c11981a1c52531f2ff7',
'phone_url' => 'http://user.banmacar.com/api/phone/op',
'sms_url' => 'http://user.banmacar.com/api/sms/single-send',
'myinfo_url' => 'http://user.banmacar.com/api/user/myinfo',
],
]; ];

@ -10,6 +10,7 @@ namespace frontend\controllers;
use common\models\FixCarT; use common\models\FixCarT;
use common\models\UserT; use common\models\UserT;
use GuzzleHttp\Client;
use yii\base\Controller; use yii\base\Controller;
use common\libs\MyLib; use common\libs\MyLib;
use common\models\AppointmentT; use common\models\AppointmentT;
@ -319,7 +320,6 @@ public function actionDownload(){
$phone = $request->post('phone',''); $phone = $request->post('phone','');
$is_double = $request->post('is_double',0); $is_double = $request->post('is_double',0);
if($user_id == 0) { if($user_id == 0) {
$result['msg'] = '请输入人员名称!'; $result['msg'] = '请输入人员名称!';
return $result; return $result;
@ -330,14 +330,33 @@ public function actionDownload(){
return $result; return $result;
} }
$tran = NetworkPhoneAssignT::getDb()->beginTransaction(); $tran = NetworkPhoneAssignT::getDb()->beginTransaction();
try { try {
$row = null; $row = null;
if($id > 0) { if($id > 0) {
$row = NetworkPhoneAssignT::findOne(['id'=>$id]); $row = NetworkPhoneAssignT::findOne(['id'=>$id]);
$url = Yii::$app->params['userPanel']['phone_url'];
$token = Yii::$app->params['userPanel']['token'];
$params = [
'token' => $token,
'op' => 'edit',
'phone' => $phone,
'old_phone' => $row->phone
];
$client = new Client();
$res = $client->request('POST', $url, [
'form_params' => $params,
'http_errors' => false,
]);
if($res->getStatusCode() == 200) {
$obj = json_decode($res->getBody());
if($obj->code == 400) {
$result['msg'] = $obj->msg;
return $result;
}
}
} else { } else {
if($is_double == 0) { if($is_double == 0) {
$t = NetworkPhoneAssignT::findOne(['phone' => $phone]); $t = NetworkPhoneAssignT::findOne(['phone' => $phone]);
@ -346,6 +365,26 @@ public function actionDownload(){
return $result; return $result;
} }
} }
$url = Yii::$app->params['userPanel']['phone_url'];
$token = Yii::$app->params['userPanel']['token'];
$params = [
'token' => $token,
'op' => 'add',
'phone' => $phone
];
$client = new Client();
$res = $client->request('POST', $url, [
'form_params' => $params,
'http_errors' => false,
]);
if($res->getStatusCode() == 200) {
$obj = json_decode($res->getBody());
if($obj->code == 400) {
$result['msg'] = $obj->msg;
return $result;
}
}
$row = new NetworkPhoneAssignT(); $row = new NetworkPhoneAssignT();
} }
$row->user_id = $user_id; $row->user_id = $user_id;
@ -386,6 +425,27 @@ public function actionDownload(){
return $result; return $result;
} }
$row = NetworkPhoneAssignT::findOne(['id'=>$id]); $row = NetworkPhoneAssignT::findOne(['id'=>$id]);
$url = Yii::$app->params['userPanel']['phone_url'];
$token = Yii::$app->params['userPanel']['token'];
$params = [
'token' => $token,
'op' => 'delete',
'phone' => $row->phone
];
$client = new Client();
$res = $client->request('POST', $url, [
'form_params' => $params,
'http_errors' => false,
]);
if($res->getStatusCode() == 200) {
$obj = json_decode($res->getBody());
if($obj->code == 400) {
$result['msg'] = $obj->msg;
return $result;
}
}
$row->delete(); $row->delete();
$result['success'] = true; $result['success'] = true;
@ -394,7 +454,7 @@ public function actionDownload(){
$tran->commit(); $tran->commit();
} catch(\Exception $e) { } catch(\Exception $e) {
$tran->rollBack(); $tran->rollBack();
throw $e; $result['msg'] = $e->getMessage();
} }
} }
} }
@ -412,7 +472,6 @@ public function actionDownload(){
$info = new NetworkPhoneSubT(); $info = new NetworkPhoneSubT();
} }
return $this->render('sub-edit',[ return $this->render('sub-edit',[
'info' => $info, 'info' => $info,
'assign_id'=>$assign_id 'assign_id'=>$assign_id
@ -434,13 +493,12 @@ public function actionDownload(){
$is_called = $request->post('is_called'); $is_called = $request->post('is_called');
$is_double = $request->post('is_double'); $is_double = $request->post('is_double');
if($phone == '') { if($phone == '') {
$result['msg'] = '请输入电话号码!'; $result['msg'] = '请输入电话号码!';
return $result; return $result;
} }
$phone_info = NetworkPhoneAssignT::findOne(['id'=>$assign_id]);
$tran = NetworkPhoneSubT::getDb()->beginTransaction(); $tran = NetworkPhoneSubT::getDb()->beginTransaction();
@ -448,6 +506,28 @@ public function actionDownload(){
$row = null; $row = null;
if($id > 0) { if($id > 0) {
$row = NetworkPhoneSubT::findOne(['id'=>$id]); $row = NetworkPhoneSubT::findOne(['id'=>$id]);
$url = Yii::$app->params['userPanel']['phone_url'];
$token = Yii::$app->params['userPanel']['token'];
$params = [
'token' => $token,
'op' => 'sub_edit',
'phone' => $phone_info->phone,
'sub_phone' => $phone,
'old_sub_phone' => $row->phone
];
$client = new Client();
$res = $client->request('POST', $url, [
'form_params' => $params,
'http_errors' => false,
]);
if($res->getStatusCode() == 200) {
$obj = json_decode($res->getBody());
if($obj->code == 400) {
$result['msg'] = $obj->msg;
return $result;
}
}
} else { } else {
if($is_double == 0) { if($is_double == 0) {
$t = NetworkPhoneSubT $t = NetworkPhoneSubT
@ -457,6 +537,28 @@ public function actionDownload(){
return $result; return $result;
} }
} }
$url = Yii::$app->params['userPanel']['phone_url'];
$token = Yii::$app->params['userPanel']['token'];
$params = [
'token' => $token,
'op' => 'sub_add',
'phone' => $phone_info->phone,
'sub_phone' => $phone
];
$client = new Client();
$res = $client->request('POST', $url, [
'form_params' => $params,
'http_errors' => false,
]);
if($res->getStatusCode() == 200) {
$obj = json_decode($res->getBody());
if($obj->code == 400) {
$result['msg'] = $obj->msg;
return $result;
}
}
$row = new NetworkPhoneSubT(); $row = new NetworkPhoneSubT();
} }
$row->assign_id = $assign_id; $row->assign_id = $assign_id;
@ -467,7 +569,7 @@ public function actionDownload(){
$tran->commit(); $tran->commit();
} catch(\Exception $e) { } catch(\Exception $e) {
$tran->rollBack(); $tran->rollBack();
throw $e; $result['msg'] = $e->getMessage();
} }
$result['success'] = true; $result['success'] = true;
@ -492,6 +594,26 @@ public function actionDownload(){
try { try {
$row = NetworkPhoneSubT::findOne(['id'=>$id]); $row = NetworkPhoneSubT::findOne(['id'=>$id]);
if($row->bind_id == ''){ if($row->bind_id == ''){
$url = Yii::$app->params['userPanel']['phone_url'];
$token = Yii::$app->params['userPanel']['token'];
$params = [
'token' => $token,
'op' => 'sub_delete',
'sub_phone' => $row->phone
];
$client = new Client();
$res = $client->request('POST', $url, [
'form_params' => $params,
'http_errors' => false,
]);
if($res->getStatusCode() == 200) {
$obj = json_decode($res->getBody());
if($obj->code == 400) {
$result['msg'] = $obj->msg;
return $result;
}
}
$row->delete(); $row->delete();
$result['success'] = true; $result['success'] = true;
@ -502,7 +624,7 @@ public function actionDownload(){
$tran->commit(); $tran->commit();
} catch(\Exception $e) { } catch(\Exception $e) {
$tran->rollBack(); $tran->rollBack();
throw $e; $result['msg'] = $e->getMessage();
} }
} }
} }

@ -16,6 +16,7 @@ use common\models\NetworkPhoneAssignT;
use common\models\NetworkPhoneSubT; use common\models\NetworkPhoneSubT;
use common\models\NetworkPhoneT; use common\models\NetworkPhoneT;
use GuzzleHttp\Client;
use Yii; use Yii;
use yii\console\Request; use yii\console\Request;
use yii\web\Response; use yii\web\Response;
@ -723,11 +724,30 @@ class PhoneController extends \yii\web\Controller
$phone = $request->get('phone',''); $phone = $request->get('phone','');
$user_id = $request->get('user_id',0); $user_id = $request->get('user_id',0);
//检查通话剩余分钟
$url = Yii::$app->params['userPanel']['myinfo_url'];
$token = Yii::$app->params['userPanel']['token'];
$client = new Client();
$res = $client->request('GET', $url.'?token='.$token);
$phone_time = 0;
if($res->getStatusCode() == 200) {
$obj = json_decode($res->getBody(), true);
if($obj['code'] == 400) {
$result['msg'] = $obj['msg'];
return $result;
}
$phone_time = intval($obj['data']['phone_time']);
}
if($phone_time <= 0) {
$result['msg'] = '电话剩余话费不足,请联系管理员充值';
return $result;
}
$headers = array( $headers = array(
"Content-Type: application/json;charset=UTF-8", "Content-Type: application/json;charset=UTF-8",
"Accept:application/json", "Accept:application/json",
); );
$uri = "http://api.1ketong.com/ykt-pool/number/ax2/call_out"; $uri = "http://api.1ketong.com/ykt-pool/number/ax2/call_out";
$app_key = '0946239060682011'; $app_key = '0946239060682011';

Loading…
Cancel
Save