Commit 50e59c8f authored by clone's avatar clone

解绑或者绑定经纪人

parent bdb06b82
...@@ -20,16 +20,19 @@ use app\model\GOperatingRecords; ...@@ -20,16 +20,19 @@ use app\model\GOperatingRecords;
use app\model\NoteLog; use app\model\NoteLog;
use app\model\UPhoneFollowPp; use app\model\UPhoneFollowPp;
use app\model\Users; use app\model\Users;
use think\Exception;
use think\Request; use think\Request;
class Broker extends Basic class Broker extends Basic
{ {
protected $a_agents; protected $a_agents;
protected $aBD;
public function __construct(Request $request = null) public function __construct(Request $request = null)
{ {
parent::__construct($request); parent::__construct($request);
$this->a_agents = new AAgents(); $this->a_agents = new AAgents();
$this->aBD = new ABindingDevice();
} }
/** /**
...@@ -194,15 +197,13 @@ class Broker extends Basic ...@@ -194,15 +197,13 @@ class Broker extends Basic
*/ */
private function judgeBand(string $device_id, int $agent_id, string $model, int $type): bool private function judgeBand(string $device_id, int $agent_id, string $model, int $type): bool
{ {
$aBD = new ABindingDevice();
$params["agent_id"] = $agent_id; $params["agent_id"] = $agent_id;
$result = $aBD->getDeviceByAgentId($params); $result = $this->aBD->getDeviceByAgentId($params);
if (count($result) <= 0) { if (count($result) <= 0) {
//新增设备绑定关系 //新增设备绑定关系
if ($type == 0) if ($type == 0)
$aBD->addDevice([ "device_id" => $device_id, "agent_id" => $agent_id, "model" => $model, "is_forbidden" => 0 ]); $this->aBD->addDevice([ "device_id" => $device_id, "agent_id" => $agent_id, "model" => $model, "is_forbidden" => 0 ]);
return true; return true;
} }
$is_exits = false; $is_exits = false;
...@@ -210,19 +211,50 @@ class Broker extends Basic ...@@ -210,19 +211,50 @@ class Broker extends Basic
if ($device_id == $item["device_id"] && $item["is_forbidden"] == 0) { if ($device_id == $item["device_id"] && $item["is_forbidden"] == 0) {
return true; return true;
} }
if($device_id == $item["device_id"] && $item["is_forbidden"] == 1){ if ($device_id == $item["device_id"] && $item["is_forbidden"] == 1) {
$is_exits = true; $is_exits = true;
} }
} }
if (!$is_exits && $type == 0) { if (!$is_exits && $type == 0) {
//新增申请绑定关系 //新增申请绑定关系
$aBD->addDevice([ "device_id" => $device_id, "agent_id" => $agent_id, "model" => $model, "is_forbidden" => 1 ]); $this->aBD->addDevice([ "device_id" => $device_id, "agent_id" => $agent_id, "model" => $model, "is_forbidden" => 1 ]);
} }
return false; return false;
} }
/**
* 绑定或者解绑
* @return \think\Response
*/
public function updateDevice()
{
$params = $this->params;
/* $params = array(
"agent_id" => 1,
"id" => 1,
"operator_id" => 12,
"is_forbidden" => 0,//0正常 1禁止
);*/
$checkResult = $this->validate($params, "PerformanceValidate.verifyIsForbidden");
if (true !== $checkResult) {
return $this->response("101", $checkResult);
}
try {
$id = $this->aBD->updateDevice($params);
if ($id > 0) {
return $this->response("200", "update success", [ "id" => $id ]);
} else {
return $this->response("101", "请求异常");
}
} catch (Exception $exception) {
return $this->response("101", "请求错误:" . $exception);
}
}
/** /**
* 获取经纪人列表 * 获取经纪人列表
......
...@@ -14,29 +14,36 @@ use think\Validate; ...@@ -14,29 +14,36 @@ use think\Validate;
class PerformanceValidate extends Validate class PerformanceValidate extends Validate
{ {
protected $rule = [ protected $rule = [
'type' => 'require|number', 'type' => 'require|number',
'agent_id' => 'require|number', 'agent_id' => 'require|number',
'phone' => 'require|number', 'phone' => 'require|number',
'pwd' => 'require|min:6', 'pwd' => 'require|min:6',
'device_id' => 'require', 'device_id' => 'require',
'is_forbidden' => 'require|in:0,1',
'operator_id' => 'require|number',
]; ];
protected $message = [ protected $message = [
'type.require' => 'type为必填字段', 'type.require' => 'type为必填字段',
'type.number' => 'type只能为数字', 'type.number' => 'type只能为数字',
'agent_id.require' => 'agent_id为必填字段', 'agent_id.require' => 'agent_id为必填字段',
'agent_id.number' => 'agent_id只能为数字', 'agent_id.number' => 'agent_id只能为数字',
'phone.require' => '手机号不能为空', 'phone.require' => '手机号不能为空',
'phone.number' => '手机号输入错误', 'phone.number' => '手机号输入错误',
'pwd.require' => '密码不能为空', 'pwd.require' => '密码不能为空',
'pwd.min' => '密码小于6位', 'pwd.min' => '密码小于6位',
'device_id.require' => '设备号获取失败,请联系管理员', 'device_id.require' => '设备号获取失败,请联系管理员',
'is_forbidden.require' => '是否绑定字段必填',
'is_forbidden.in' => '是否绑定字段值只能为0或1',
'operator_id.require' => '操作人为必填字段',
'operator_id.number' => '操作人编号只能为数字',
]; ];
protected $scene = [ protected $scene = [
'verify' => [ 'type', 'agent_id' ], 'verify' => [ 'type', 'agent_id' ],
'verifyOther' => [ 'agent_id' ], 'verifyOther' => [ 'agent_id' ],
'login' => [ 'phone', 'pwd', 'device_id' ], 'login' => [ 'phone', 'pwd', 'device_id' ],
'verifyStatus' => [ 'phone', 'device_id' ], 'verifyStatus' => [ 'phone', 'device_id' ],
'verifyIsForbidden' => [ 'phone', 'device_id', 'is_forbidden', 'operator_id' ],
]; ];
} }
\ No newline at end of file
...@@ -109,6 +109,9 @@ class ABindingDevice extends BaseModel ...@@ -109,6 +109,9 @@ class ABindingDevice extends BaseModel
if (isset($params["is_forbidden"])) { if (isset($params["is_forbidden"])) {
$arr["is_forbidden"] = $params["is_forbidden"]; $arr["is_forbidden"] = $params["is_forbidden"];
} }
if (isset($params["operator_id"])) {
$arr["operator_id"] = $params["operator_id"];
}
$arr["update_time"] = date("Y-m-d H:i:s", time()); $arr["update_time"] = date("Y-m-d H:i:s", time());
return $arr; return $arr;
} }
......
...@@ -376,6 +376,8 @@ Route::group('broker', [ ...@@ -376,6 +376,8 @@ Route::group('broker', [
'login' => [ 'api_broker/Broker/login', [ 'method' => 'post' ] ], //经纪人登陆 废弃 'login' => [ 'api_broker/Broker/login', [ 'method' => 'post' ] ], //经纪人登陆 废弃
'loginV2' => [ 'api_broker/Broker/loginV2', [ 'method' => 'post' ] ], //经纪人登陆 'loginV2' => [ 'api_broker/Broker/loginV2', [ 'method' => 'post' ] ], //经纪人登陆
'verifyAgentStatus' => [ 'api_broker/Broker/verifyAgentStatus', [ 'method' => 'post' ] ], //判断经纪人是否被解绑 'verifyAgentStatus' => [ 'api_broker/Broker/verifyAgentStatus', [ 'method' => 'post' ] ], //判断经纪人是否被解绑
'updateDevice' => [ 'api_broker/Broker/updateDevice', [ 'method' => 'post' ] ], //解绑或者绑定经纪人
'editAgent' => [ 'api_broker/Broker/editAgent', [ 'method' => 'post' ] ], //经纪人修改密码 'editAgent' => [ 'api_broker/Broker/editAgent', [ 'method' => 'post' ] ], //经纪人修改密码
'forgetPwd' => [ 'api_broker/Broker/forgetPwd', [ 'method' => 'post' ] ], //经纪人忘记密码 'forgetPwd' => [ 'api_broker/Broker/forgetPwd', [ 'method' => 'post' ] ], //经纪人忘记密码
'uploadHeadImg' => [ 'api_broker/Broker/uploadHeadImg', [ 'method' => 'post' ] ], //经纪人上传头像 'uploadHeadImg' => [ 'api_broker/Broker/uploadHeadImg', [ 'method' => 'post' ] ], //经纪人上传头像
......
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