Commit e32bc6d4 authored by clone's avatar clone

个推id绑定

parent 85cf3004
...@@ -108,6 +108,7 @@ class Broker extends Basic ...@@ -108,6 +108,7 @@ class Broker extends Basic
/*$params = array( /*$params = array(
"phone" => "15002102357", "phone" => "15002102357",
"pwd" => "123456", "pwd" => "123456",
"push_id" => "123123",
"device_id" => "qweqweqweqweqw123123", "device_id" => "qweqweqweqweqw123123",
"model" => "iphone7",//手机型号 "model" => "iphone7",//手机型号
);*/ );*/
...@@ -179,7 +180,7 @@ class Broker extends Basic ...@@ -179,7 +180,7 @@ class Broker extends Basic
return $this->response("101", $checkResult); return $this->response("101", $checkResult);
} }
$is_visit = $this->judgeBand($params["device_id"], $params["agent_id"], "", 1); $is_visit = $this->judgeBand($params["device_id"], $params["agent_id"], "", 1, "");
if ($is_visit) { if ($is_visit) {
return $this->response("200", "success", []); return $this->response("200", "success", []);
} else { } else {
...@@ -193,33 +194,46 @@ class Broker extends Basic ...@@ -193,33 +194,46 @@ class Broker extends Basic
* @param int $agent_id * @param int $agent_id
* @param string $model * @param string $model
* @param int $type 0提交记录到后台, 1仅仅判断 * @param int $type 0提交记录到后台, 1仅仅判断
* @param int $push_id
* @return bool * @return bool
*/ */
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, int $push_id): bool
{ {
$params["agent_id"] = $agent_id; $params["agent_id"] = $agent_id;
$result = $this->aBD->getDeviceByAgentId($params); $result = $this->aBD->getDeviceByAgentId($params);
if (count($result) <= 0) { if (count($result) <= 0) {
//新增设备绑定关系 //新增设备绑定关系 默认直接登陆
if ($type == 0) if ($type == 0)
$this->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,
"push_id" => $push_id,
"is_forbidden" => 0 ]);
return true; return true;
} }
$is_exits = false; $is_exits = false;
foreach ($result as $item) { foreach ($result as $item) {
if ($device_id == $item["device_id"] && $item["is_forbidden"] == 0) { if ($device_id == $item["device_id"]) {
return true; if ($item["is_forbidden"] == 0) {
} return true;
if ($device_id == $item["device_id"] && $item["is_forbidden"] == 1) { } elseif ($item["is_forbidden"] == 1) { //已存在申请关系
$is_exits = true; $is_exits = true;
} }
//当个推返回的id改变时则更新记录
if ($push_id && $push_id != $item["push_id"])
$this->aBD->updateDevice([ "id" => $item["id"], "push_id" => $push_id ]);
}
} }
if (!$is_exits && $type == 0) { if (!$is_exits && $type == 0)
//新增申请绑定关系 //新增申请绑定关系,需要后台同意登陆
$this->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,
"push_id" => $push_id,
"is_forbidden" => 1 ]);
return false; return false;
} }
...@@ -228,7 +242,8 @@ class Broker extends Basic ...@@ -228,7 +242,8 @@ class Broker extends Basic
* 绑定或者解绑 * 绑定或者解绑
* @return \think\Response * @return \think\Response
*/ */
public function updateDevice() public
function updateDevice()
{ {
$params = $this->params; $params = $this->params;
/* $params = array( /* $params = array(
...@@ -264,7 +279,8 @@ class Broker extends Basic ...@@ -264,7 +279,8 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getBroker() public
function getBroker()
{ {
$data['status'] = 200; $data['status'] = 200;
$data['data'] = ''; $data['data'] = '';
...@@ -297,7 +313,8 @@ class Broker extends Basic ...@@ -297,7 +313,8 @@ class Broker extends Basic
* *
* @return \think\Response * @return \think\Response
*/ */
public function add_phone_follow_up() public
function add_phone_follow_up()
{ {
header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Origin:*');
$params = $this->params; $params = $this->params;
...@@ -346,7 +363,8 @@ class Broker extends Basic ...@@ -346,7 +363,8 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function user_search() public
function user_search()
{ {
$Two_days_ago = date("Y-m-d h:i:s", strtotime("-2 day")); $Two_days_ago = date("Y-m-d h:i:s", strtotime("-2 day"));
//dump($Two_days_ago); //dump($Two_days_ago);
...@@ -408,7 +426,8 @@ class Broker extends Basic ...@@ -408,7 +426,8 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function useraction_search() public
function useraction_search()
{ {
header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Origin:*');
$params = $this->params; $params = $this->params;
...@@ -468,7 +487,8 @@ class Broker extends Basic ...@@ -468,7 +487,8 @@ class Broker extends Basic
* 搜索动态 * 搜索动态
* @return \think\Response * @return \think\Response
*/ */
public function userStateSearch() public
function userStateSearch()
{ {
$params = $this->params; $params = $this->params;
/* $params = array( /* $params = array(
...@@ -487,7 +507,8 @@ class Broker extends Basic ...@@ -487,7 +507,8 @@ class Broker extends Basic
/** /**
* 编辑密码 * 编辑密码
*/ */
public function editAgent() public
function editAgent()
{ {
$data['code'] = 200; $data['code'] = 200;
$data['msg'] = ""; $data['msg'] = "";
...@@ -515,7 +536,8 @@ class Broker extends Basic ...@@ -515,7 +536,8 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function forgetPwd() public
function forgetPwd()
{ {
$data['code'] = 101; $data['code'] = 101;
$data['msg'] = ""; $data['msg'] = "";
...@@ -565,7 +587,8 @@ class Broker extends Basic ...@@ -565,7 +587,8 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function uploadHeadImg() public
function uploadHeadImg()
{ {
$data['status'] = 101; $data['status'] = 101;
$data['msg'] = ''; $data['msg'] = '';
...@@ -608,7 +631,8 @@ class Broker extends Basic ...@@ -608,7 +631,8 @@ class Broker extends Basic
* *
* @return \think\Response * @return \think\Response
*/ */
public function token() public
function token()
{ {
header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Origin:*');
$jwt = new JwtUntils(); $jwt = new JwtUntils();
...@@ -625,7 +649,8 @@ class Broker extends Basic ...@@ -625,7 +649,8 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getAgentsByPhone() public
function getAgentsByPhone()
{ {
header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Origin:*');
$agents = new AAgents(); $agents = new AAgents();
...@@ -643,7 +668,8 @@ class Broker extends Basic ...@@ -643,7 +668,8 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function sendSms() public
function sendSms()
{ {
$data['data'] = []; $data['data'] = [];
$data['status'] = 101; $data['status'] = 101;
...@@ -705,7 +731,8 @@ class Broker extends Basic ...@@ -705,7 +731,8 @@ class Broker extends Basic
* @throws \Endroid\QrCode\Exception\InvalidPathException * @throws \Endroid\QrCode\Exception\InvalidPathException
* @throws \Endroid\QrCode\Exception\InvalidWriterException * @throws \Endroid\QrCode\Exception\InvalidWriterException
*/ */
public function qrCode() public
function qrCode()
{ {
$parms = $this->params; $parms = $this->params;
......
...@@ -35,7 +35,7 @@ class UploadImg extends Basic ...@@ -35,7 +35,7 @@ class UploadImg extends Basic
set_time_limit(0); set_time_limit(0);
$file = $_FILES['image']; $file = $_FILES['image'];
$type = request()->param('type'); $type = request()->param('type');
// Log::record("upload img info :" . json_encode($file) ); Log::record("upload img info :" . json_encode($file) );
$uploadResult = $this->uFService->upload($file, $type); $uploadResult = $this->uFService->upload($file, $type);
......
...@@ -345,6 +345,7 @@ class OrderLogService ...@@ -345,6 +345,7 @@ class OrderLogService
$trees[$i]["create_time"] = $v[0]["create_time"]; $trees[$i]["create_time"] = $v[0]["create_time"];
} }
unset($tree);
sort($trees); sort($trees);
return $trees; return $trees;
} }
......
...@@ -19,6 +19,7 @@ class PerformanceValidate extends Validate ...@@ -19,6 +19,7 @@ class PerformanceValidate extends Validate
'phone' => 'require|number', 'phone' => 'require|number',
'pwd' => 'require|min:6', 'pwd' => 'require|min:6',
'device_id' => 'require', 'device_id' => 'require',
'push_id' => 'require',
'is_forbidden' => 'require|in:0,1', 'is_forbidden' => 'require|in:0,1',
'operator_id' => 'require|number', 'operator_id' => 'require|number',
]; ];
...@@ -33,6 +34,7 @@ class PerformanceValidate extends Validate ...@@ -33,6 +34,7 @@ class PerformanceValidate extends Validate
'pwd.require' => '密码不能为空', 'pwd.require' => '密码不能为空',
'pwd.min' => '密码小于6位', 'pwd.min' => '密码小于6位',
'device_id.require' => '设备号获取失败,请联系管理员', 'device_id.require' => '设备号获取失败,请联系管理员',
'push_id.require' => '个推帐号获取失败,请联系管理员',
'is_forbidden.require' => '是否绑定字段必填', 'is_forbidden.require' => '是否绑定字段必填',
'is_forbidden.in' => '是否绑定字段值只能为0或1', 'is_forbidden.in' => '是否绑定字段值只能为0或1',
'operator_id.require' => '操作人为必填字段', 'operator_id.require' => '操作人为必填字段',
...@@ -42,7 +44,7 @@ class PerformanceValidate extends Validate ...@@ -42,7 +44,7 @@ class PerformanceValidate extends Validate
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', "push_id" ],
'verifyStatus' => [ 'agent_id', 'device_id' ], 'verifyStatus' => [ 'agent_id', 'device_id' ],
'verifyIsForbidden' => [ 'phone', 'device_id', 'is_forbidden', 'operator_id' ], 'verifyIsForbidden' => [ 'phone', 'device_id', 'is_forbidden', 'operator_id' ],
]; ];
......
...@@ -65,16 +65,16 @@ class ABindingDevice extends BaseModel ...@@ -65,16 +65,16 @@ class ABindingDevice extends BaseModel
* @param string $field * @param string $field
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
*/ */
public function getDeviceByAgentId(array $params, string $field = "id,agent_id,device_id,is_forbidden") public function getDeviceByAgentId(array $params, string $field = "id,agent_id,device_id,is_forbidden,push_id")
{ {
$where_ = []; $where_ = [];
if(isset($params["agent_id"])){ if (isset($params["agent_id"])) {
$where_["agent_id"] = $params["agent_id"]; $where_["agent_id"] = $params["agent_id"];
} }
if(isset($params["device_id"])){ if (isset($params["device_id"])) {
$where_["device_id"] = $params["device_id"]; $where_["device_id"] = $params["device_id"];
} }
if(isset($params["is_forbidden"])){ if (isset($params["is_forbidden"])) {
$where_["is_forbidden"] = $params["is_forbidden"]; $where_["is_forbidden"] = $params["is_forbidden"];
} }
return $this return $this
...@@ -103,6 +103,9 @@ class ABindingDevice extends BaseModel ...@@ -103,6 +103,9 @@ class ABindingDevice extends BaseModel
if (isset($params["device_id"])) { if (isset($params["device_id"])) {
$arr["device_id"] = $params["device_id"]; $arr["device_id"] = $params["device_id"];
} }
if (isset($params["push_id"])) {
$arr["push_id"] = $params["push_id"];
}
if (isset($params["model"])) { if (isset($params["model"])) {
$arr["model"] = $params["model"]; $arr["model"] = $params["model"];
} }
......
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