Commit 2da89808 authored by hujun's avatar hujun

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

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