Commit 05b37966 authored by zhuwei's avatar zhuwei

C端 设置站点

parent b44d6639
<?php
namespace app\api\controller;
/**
* Created by PhpStorm.
* User: zhuwei
* Date:2018-10-18
* Time:10:50:55
*/
use app\api\extend\Basic;
use app\index\service\UserService;
use app\model\ASite;
use think\Request;
class Site extends Basic
{
protected $aSite;
public function __construct($request = null)
{
parent::__construct($request);
$this->aSite = new ASite();
}
/**
* 设置站点
* User: 朱伟
* Date:2018-10-18
* Time:10:50:55
*/
public function setUserSite()
{
header('Access-Control-Allow-Origin:*');
$params = $this->params;
/*$params = array(
"user_id" => 1,
"site_id" =>'1,1'
);*/
$checkResult = $this->validate($params, "Site.setUserSite");
if (true !== $checkResult) {
return $this->response("101", $checkResult);
}
$user_service = new UserService();
$user_id =$params['user_id'];
$site_id =$params['site_id'];
$res = $user_service->setUserSites($user_id, $site_id);
if ($res) {
return $this->response("200", "成功");
} else {
return $this->response("101", "失败");
}
}
/**
* 获取站点列表
* User: 朱伟
* Date:2018-10-18
* Time:10:50:55
*/
public function getSiteList()
{
$params = $this->params;
/*$params = array(
"id" => 5740
);*/
$field = 'id,name,city,is_del';
$get_params['is_del'] = 0;
$res = $this->aSite->getSite($field, $params);
return $this->response("200", "成功", $res);
}
/**
* 关闭或开启站点
* @return \think\Response
*/
// public function delImageDepot(){
// $params = $this->params;
// $checkResult = $this->validate($params, "Site.delImageDepot");
// if (true !== $checkResult) {
// return $this->response("101", $checkResult);
// }
// $params_['id'] = $params['id'];
// $params_['is_del'] = $params['is_del'];
// $res = $this->aSite->updateSite($params_);//int(1)
// if($res == 1){
// return $this->response("200", "成功",['data'=>$res]);
// }else{
// return $this->response("300", "失败");
// }
// }
//
// public function siteLogList()
// {
// if (!$this->request->isAjax()) {
// return view('site/siteLogList');
// }
// }
}
\ No newline at end of file
<?php
namespace app\api\validate;
use think\Validate;
class Site extends Validate {
protected $rule = [
'site_id' => 'require',
'user_id' => 'require|number|gt:0'
];
protected $message = [
'site_id.require' => '站点不能为空',
'user_id.require' => '用户id不能为空',
'user_id.number' => '用户id只能为数字',
'user_id.gt' => '用户id必须大于0',
];
protected $scene = [
'setUserSite' => [ 'user_id', 'site_id' ],
];
}
\ No newline at end of file
......@@ -83,14 +83,6 @@ class UserService
}
$id = $this->user->edit($data, $id, $operation_id); //新增或编辑
$this->setUserSites($id, $data['site_id']);//设置站点
//操作完成之后判断下是什么动作
if($type == 'add'){
//$type等于'add'说明是新增客户,需要设置保护期截止日期
$this->setUserProtectTime($id);
}
if ($id <= 0) {
$msg = $this->getCodeMsg($id);
$result['status'] = 'fail';
......@@ -101,6 +93,16 @@ class UserService
$result['msg'] = '';
}
$this->setUserSites($id, $data['site_id']);//设置站点
//操作完成之后判断下是什么动作
if($type == 'add'){
//$type等于'add'说明是新增客户,需要设置保护期截止日期
$this->setUserProtectTime($id);
}
//记录修改客方
if (!empty($data['agents_id'])) {
$this->recordGuest((int)$data['agents_id'], (int)$agent_id_old, $id, $user_name, $type);
......
......@@ -294,23 +294,23 @@ class Users extends Model
}
}
if (empty($data['province'])) {
return -5;
} else {
$insert_data['province'] = $data['province'];
}
if (empty($data['city'])) {
return -5;
} else {
$insert_data['city'] = $data['city'];
}
if (empty($data['disc'])) {
return -5;
} else {
$insert_data['disc'] = $data['disc'];
}
// if (empty($data['province'])) {
// return -5;
// } else {
// $insert_data['province'] = $data['province'];
// }
//
// if (empty($data['city'])) {
// return -5;
// } else {
// $insert_data['city'] = $data['city'];
// }
//
// if (empty($data['disc'])) {
// return -5;
// } else {
// $insert_data['disc'] = $data['disc'];
// }
//0普通用户1是租客也是房东 2纯房东
if (!empty($data['user_label'])) {
$insert_data['user_label'] = $data['user_label'];
......
......@@ -418,6 +418,8 @@ Route::group('api', [
'saveSiteCity' => [ 'api/Location/saveSiteCity', [ 'method' => 'POST|GET' ] ], //保存默认城市选择 c端
'setUserSite' => [ 'api/Site/setUserSite', [ 'method' => 'POST|GET' ] ],//设置站点
]);
......
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