Commit 2da89808 authored by hujun's avatar hujun

新增拨打号码界面接口修改

parent b7ec01f0
...@@ -155,13 +155,20 @@ class CellPhone extends Basic ...@@ -155,13 +155,20 @@ class CellPhone extends Basic
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function agentsPhone() { public function agentsPhone() {
header('Access-Control-Allow-Origin:*');
if ($this->params['agents_id']) { if ($this->params['agents_id']) {
$agents_phone = new AAgentsPhone(); $agents_phone = new AAgentsPhone();
if ($this->request->isGet()) { if ($this->request->isGet()) {
$this->data = $agents_phone->getList(1,15,'id asc','id,phone','status = 0'); $where['agents_id'] = $this->params['agents_id'];
$where['status'] = 0;
$this->data = $agents_phone->getList(1,3,'id asc','id,phone',$where);
} else {
if ($this->params['type'] == 'delete') {
$this->data = $agents_phone->delPhone($this->params['agents_id'],$this->params['phone']);
} else { } else {
$this->data = $agents_phone->add($this->params['agents_id'],$this->params['phone']); $this->data = $agents_phone->add($this->params['agents_id'],$this->params['phone']);
} }
}
} else { } else {
$this->code = 101; $this->code = 101;
$this->msg = 'agents_id is null'; $this->msg = 'agents_id is null';
......
...@@ -22,13 +22,18 @@ class AAgentsPhone extends BaseModel ...@@ -22,13 +22,18 @@ class AAgentsPhone extends BaseModel
public function add($id, $phone) { public function add($id, $phone) {
if (is_array($phone)) { if (is_array($phone)) {
$insert_data = []; $insert_data = [];
$phone = array_unique($phone);
foreach ($phone as $k=>$v) { 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]['agents_id'] = $id;
$insert_data[$k]['phone'] = $phone; $insert_data[$k]['phone'] = $v;
} }
$result = $this->saveAll(array_unique($insert_data)); }
$result = $this->saveAll($insert_data);
} else { } else {
$is = $this->get(['phone'=>$phone,'agents_id'=>$id]); $is = $this->get(['phone'=>$phone,'agents_id'=>$id,'status'=>0]);//去重
if (!$is){ if (!$is){
$result = $this->save(['phone'=>$phone,'agents_id'=>$id]); $result = $this->save(['phone'=>$phone,'agents_id'=>$id]);
} else { } else {
......
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