Commit 1140f218 authored by hujun's avatar hujun

拨打界面新增号码限制

parent 4f4cbc0a
......@@ -31,6 +31,7 @@ class CellPhone extends Basic
* @throws \think\exception\DbException
*/
public function bindAXB() {
header('Access-Control-Allow-Origin:*');
$params = $this->request->param();
if ($params['phone_a'] || $params['phone_b']) {
$phone_a = $this->params['phone_a'];//经纪人手机号
......@@ -88,6 +89,7 @@ class CellPhone extends Basic
* @return \think\Response
*/
public function updateBindAXB() {
header('Access-Control-Allow-Origin:*');
$params = $this->request->param();
if ($params['phone_x'] && ($params['phone_a'] || $params['phone_b'])) {
$bind = new BindingPhone();
......@@ -121,6 +123,7 @@ class CellPhone extends Basic
* @throws \think\exception\DbException
*/
public function agentsUnBind() {
header('Access-Control-Allow-Origin:*');
$phone_x = $this->params['phone_x'];
$phone_a = $this->params['phone_a'];
$phone_b = $this->params['phone_b'];
......
......@@ -12,6 +12,7 @@ namespace app\api_broker\extend;
use app\model\AAgents;
use app\model\Users;
use app\model\GOperatingRecords;
use Firebase\JWT\JWT;
use think\Controller;
use think\Db;
use think\Request;
......
......@@ -20,27 +20,34 @@ class AAgentsPhone extends BaseModel
* @throws \Exception
*/
public function add($id, $phone) {
if (is_array($phone)) {
$insert_data = [];
$phone = array_unique($phone);
foreach ($phone as $k=>$v) {
$is = $this->get(['phone'=>$v,'agents_id'=>$id,'status'=>0]);//去重
if (empty($is->id)) {
$insert_data[$k]['agents_id'] = $id;
$insert_data[$k]['phone'] = $v;
}
}
$num = $this->where(['agents_id'=>$id,'status'=>0])->count();
$result = $this->saveAll($insert_data);
$phone_num = count($phone);
if (($num > 2) || ($phone_num > 2)) {
$result = 0;
} else {
$is = $this->get(['phone'=>$phone,'agents_id'=>$id,'status'=>0]);//去重
if (!$is){
$result = $this->save(['phone'=>$phone,'agents_id'=>$id]);
if (is_array($phone)) {
$insert_data = [];
$phone = array_unique($phone);
foreach ($phone as $k=>$v) {
$is = $this->get(['phone'=>$v,'agents_id'=>$id,'status'=>0]);//去重
if (empty($is->id)) {
$insert_data[$k]['agents_id'] = $id;
$insert_data[$k]['phone'] = $v;
}
}
$result = $this->saveAll($insert_data);
} else {
$result = 0;
$is = $this->get(['phone'=>$phone,'agents_id'=>$id,'status'=>0]);//去重
if (!$is){
$result = $this->save(['phone'=>$phone,'agents_id'=>$id]);
} else {
$result = 0;
}
}
}
return $result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment