Commit 1e108f91 by 庄钊鑫

初始化

parents

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

FROM registry.cn-shenzhen.aliyuncs.com/dankal/php-nginx:7.1
ENV VIRTUAL_HOST api-zhifu-alliance.dankal.cn
ENV LETSENCRYPT_HOST api-zhifu-alliance.dankal.cn
ENV LETSENCRYPT_EMAIL bingo@dankal.cn
COPY . /app
#RUN chmod -R 777 /app/runtime
#RUN chmod -R 777 /app/public/qrcode
RUN chmod -R 777 /app
This diff is collapsed. Click to expand it.
智服联盟
---------
\ No newline at end of file
Folder
*.zip
*.rar
*.via
*.tmp
*.err
*.log
/runtime/
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
# =========================
# Operating System Files
# =========================
# OSX
# =========================
.DS_Store
.AppleDouble
.LSOverride
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
deny from all
\ No newline at end of file
<?php
/**
* 授权基类,包含请求方式过滤 请求参数处理 请求资源限制等
*/
namespace app\api\controller;
use think\Controller;
use think\exception\HttpResponseException;
use think\Request;
class Api extends Controller
{
use Send;
protected $param = [];
protected $userId;
protected $pageIndex;
protected $pageSize;
/**
* 对应操作
* @var array
*/
public $methodToAction = [
'get' => 'read',
'post' => 'save',
'put' => 'update',
'delete' => 'delete',
'patch' => 'patch',
'head' => 'head',
'options' => 'options',
];
/**
* 允许访问的请求类型
* @var string
*/
public $restMethodList = 'get|post|put|delete|patch|head|options';
/**
* 默认不验证
* @var bool
*/
public $apiAuth = true;
protected $request;
/**
* 当前请求类型
* @var string
*/
protected $method;
/**
* 当前资源类型
* @var string
*/
protected $type;
public static $app;
/**
* 返回的资源类的
* @var string
*/
protected $restTypeList = 'json';
/**
* REST允许输出的资源类型列表
* @var array
*/
protected $restOutputType = [
'json' => 'application/json',
];
/**
* 客户端信息
*/
protected $clientInfo;
/**
* 控制器初始化操作
*/
public function _initialize()
{
$request = Request::instance();
$this->request = $request;
$this->init(); //检查资源类型
}
public function __construct(Request $request = null)
{
parent::__construct();
$this->param = $request->param();
$this->getPageIndexAndSize();
}
/**
* 初始化方法
* 检测请求类型,数据格式等操作
*/
public function init()
{
$request = Request::instance();
$ext = $request->ext();
if ('' == $ext) {
// 自动检测资源类型
$this->type = $request->type();
} elseif (!preg_match('/\(' . $this->restTypeList . '\)$/i', $ext)) {
// 资源类型非法 则用默认资源类型访问
$this->type = $this->restDefaultType;
} else {
$this->type = $ext;
}
$this->setType();
// 请求方式检测
$method = strtolower($request->method());
$this->method = $method;
if (false === stripos($this->restMethodList, $method)) {
throw new HttpResponseException(json((object)array('error'=>405,'message'=>'No routing path can be found for the request.'),200));
}
}
/**
* 空操作
* @return \think\Response|\think\response\Json|\think\response\Jsonp|\think\response\Xml
*/
public function _empty()
{
return $this->render(200);
}
/**
* 单个参数验证
*
* @param $value
* @param $key
* @param $validate
*/
protected function checkSingle($value, $key, $validate)
{
$this->check([$key => $value], $validate);
}
/**
* 验证参数
* @access protected
* @param array $data 数据
* @param string|array $validate 验证器名或者验证规则数组
* @param array $message 提示信息
*/
protected function check($data, $validate, $message = [])
{
$validateResult = $this->validate($data, $validate, $message);
if ($validateResult !== true) {
self::returnmsg(400, [], [], "", "param error", $validateResult);
}
}
/**
* 获取页码和每页数量
* @param int $defaultIndex
* @param int $defaultSize
* @param int $sizeLimit
*/
protected function getPageIndexAndSize($defaultIndex = 1, $defaultSize = 20, $sizeLimit = 1000)
{
$this->pageIndex = isset($this->param['page_index']) ? $this->param['page_index'] : null;
$this->pageSize = isset($this->param['page_size']) ? $this->param['page_size'] : null;
$this->pageIndex = $this->pageIndex ?: $defaultIndex;
$this->pageSize = $this->pageSize ?: $defaultSize;
$this->checkSingle($this->pageIndex, 'page_index', 'Base.page_index');
$this->checkSingle($this->pageSize, 'page_size', 'Base.page_size');
if ($this->pageSize > $sizeLimit) {
self::returnmsg(400, [], [], "", "param error", "参数不合法");
}
}
/**
* 获取指定参数
*
* @param string $key
* @param mixed|null $defaultValue
* @return mixed|null
*/
protected function getParam($key, $defaultValue = null)
{
return isset($this->param[$key])
? (is_string($this->param[$key]) ? trim($this->param[$key]) : $this->param[$key])
: $defaultValue;
}
/**
* 获取多个参数,keysArray为空时获得全部参数
* 注意键名不能为数字
*
* @param array|null $keysArray
* @return array
*/
protected function selectParam($keysArray = null)
{
if ($keysArray) {
$paramResult = [];
foreach ($keysArray as $key => $value) {
if (is_int($key)) {
// 没有 key , 用数字作为key
$paramResult[$value] = $this->getParam($value);
} else {
// 有 key 和 value , value为参数默认值
$paramResult[$key] = $this->getParam($key, $value);
}
}
return $paramResult;
} else {
return $this->param;
}
}
}
\ No newline at end of file
<?php
/**
*
*/
namespace app\api\controller;
class Factory
{
private static $Factory;
private function __construct()
{
}
public static function getInstance($className, $options = null)
{
if (!isset(self::$Factory[$className]) || !self::$Factory[$className]) {
self::$Factory[$className] = new $className($options);
}
return self::$Factory[$className];
}
}
\ No newline at end of file
<?php
namespace app\api\controller;
use app\api\controller\UnauthorizedException;
use app\api\controller\Send;
use think\Exception;
use think\Request;
use think\Db;
use think\Cache;
class Oauth
{
use Send;
/**
* accessToken存储前缀
*
* @var string
*/
public static $accessTokenPrefix = 'accessToken_';
/**
* accessTokenAndClientPrefix存储前缀
*
* @var string
*/
public static $accessTokenAndClientPrefix = 'accessTokenAndClient_';
/**
* 过期时间秒数
*
* @var int
*/
public static $expires = 72000;
/**
* 客户端信息
*
* @var
*/
public $clientInfo;
/**
* 认证授权 通过用户信息和路由
* @param Request $request
* @return \Exception|UnauthorizedException|mixed|Exception
* @throws UnauthorizedException
*/
final function authenticate()
{
$request = Request::instance();
// var_dump($request);die;
try {
//验证授权
$clientInfo = $this->getClient();
// var_dump($clientInfo);die;
$checkclient = $this->certification($clientInfo);
if($checkclient){
return $clientInfo;
}
} catch (Exception $e) {
// return $this->returnmsg(402,'Invalid1 authentication credentials.');
$this->returnmsg('402',[],[],'service_message','Invalid1 authentication credentials.','验证码错误');
}
}
/**
* 获取用户信息
* @param Request $request
* @return $this
* @throws UnauthorizedException
*/
public function getClient()
{
$request = Request::instance();
//获取头部信息
try {
//========关键信息在头部传入例如key,用户信息,token等,==============
$authorization = $request->header('token');
// var_dump($authorization);die;
// $authorization = explode(" ", base64_decode($authorization));
// $authorization = explode(':', $authorization[1]);
// $app_key = $authorization[0];
$access_token = $authorization;
// $user_id = $authorization[2];//$_SERVER['PHP_AUTH_USER']
// $clientInfo['user_id'] = $user_id;
// $clientInfo['app_key'] = $app_key;
$clientInfo['token'] = $access_token;
// $clientInfo = $request->param();
} catch (Exception $e) {
return $this->returnmsg(402,$e.'Invalid authentication credentials');
}
return $clientInfo;
}
/**
* 获取用户信息后 验证权限
* @return mixed
*/
public function certification($data = []){
// ======下面注释部分是缓存验证access_token是否有效,这次使用数据库验证======
$time = date("Y-m-d H:i:s",time());
$checkclient = Db::name('token')->field('end_time')->where('uuid',$data['uuid'])->where('access_token',$data['access_token'])->find();
if(empty($checkclient)){
$this->returnmsg(401);
}
if($checkclient <= $time){
$this->returnmsg('402',[],[],'service_message','Token time out','token已过期');
}
return true;
// $getCacheAccessToken = Cache::get(self::$accessTokenPrefix . $data['access_token']); //获取缓存access_token
// if(!$getCacheAccessToken){
// return $this->returnmsg(402,'Access_token expired or error!');
// }
// if($getCacheAccessToken['client']['app_key'] != $data['app_key']){
//
// return $this->returnmsg(402,'App_token does not match app_key'); //app_key与缓存中的appkey不匹配
// }
//
// return true;
}
/**
* 生成签名
* _字符开头的变量不参与签名
*/
public function makeSign ($data = [],$app_secret = '')
{
unset($data['version']);
unset($data['signature']);
foreach ($data as $k => $v) {
if(substr($data[$k],0,1) == '_'){
unset($data[$k]);
}
}
dump($data);
return $this->_getOrderMd5($data,$app_secret);
}
/**
* 计算ORDER的MD5签名
*/
private function _getOrderMd5($params = [] , $app_secret = '') {
ksort($params);
$params['key'] = $app_secret;
return strtolower(md5(urldecode(http_build_query($params))));
}
}
\ No newline at end of file
<?php
/**
* 向客户端发送相应基类
*/
namespace app\api\controller;
use think\exception\HttpResponseException;
use think\Response;
use think\response\Redirect;
trait Send
{
/**
* 默认返回资源类型
* @var string
*/
protected $restDefaultType = 'json';
/**
* 设置响应类型
* @param null $type
* @return $this
*/
public function setType($type = null)
{
$this->type = (string)(!empty($type)) ? $type : $this->restDefaultType;
return $this;
}
/**
* 失败响应
* @param int $error
* @param string $message
* @param int $code
* @param array $data
* @param array $headers
* @param array $options
* @return Response|\think\response\Json|\think\response\Jsonp|\think\response\Xml
*/
public function sendError($error = 400, $message = 'error', $code = 400, $data = [], $headers = [], $options = [])
{
$responseData['error'] = (int)$error;
$responseData['message'] = (string)$message;
if (!empty($data)) $responseData['data'] = $data;
$responseData = array_merge($responseData, $options);
return $this->response($responseData, $code, $headers);
}
/**
* 成功响应
* @param int $code
* @param array|string $result
* @return Response|\think\response\Json|\think\response\Jsonp|Redirect|\think\response\Xml
*/
public function render($result = 'SUCCESS', $code = 200)
{
throw new HttpResponseException(json((object)$result, $code));
}
/**
* 重定向
* @param $url
* @param array $params
* @param int $code
* @param array $with
* @return Redirect
*/
public function sendRedirect($url, $params = [], $code = 302, $with = [])
{
$response = new Redirect($url);
if (is_integer($params)) {
$code = $params;
$params = [];
}
$response->code($code)->params($params)->with($with);
return $response;
}
/**
* 响应
* @param $responseData
* @param $code
* @param $headers
* @return Response|\think\response\Json|\think\response\Jsonp|Redirect|\think\response\View|\think\response\Xml
*/
public function response($responseData, $code, $headers)
{
if (!isset($this->type) || empty($this->type)) $this->setType();
return Response::create($responseData, $this->type, $code, $headers);
}
/**
* 如果需要允许跨域请求,请在记录处理跨域options请求问题,并且返回200,以便后续请求,这里需要返回几个头部。。
* @param string|int $code 状态码
* @param string $message 返回信息
* @param array $data 返回信息
* @param array $header 返回头部信息
* @param string $reason
* @param string $type
*
*/
public function returnmsg($code = '400', $data = [], $header = [], $type = "", $reason = "", $message = "")
{
switch ($code) {
case 200:
$error = "SUCCESS";
break;
case 400:
$error['error']['code'] = "400";
$error['error']['reason'] = empty($reason) ? "param missing" : $reason;
$error['error']['message'] = empty($message) ? "请求参数格式不正确" : $message;
break;
case 401:
$error['error']['code'] = "401";
$error['error']['reason'] = empty($reason) ? "token error." : $reason;;
$error['error']['message'] = empty($message) ? "鉴权失败" : $message;
break;
case 500:
$error['error']['code'] = "500";
$error['error']['reason'] = $reason;
$error['error']['message'] = empty($message) ? "服务器内部错误" : $message;
break;
case 404:
default:
$error['error']['code'] = "Not Found";
$error['error']['reason'] = "url error.";
$error['error']['message'] = "请求资源不存在";
break;
}
if (!empty($data)) $error['error']['data'] = $data;
// 发送头部信息
foreach ($header as $name => $val) {
is_null($val) ? header($name) : header($name . ':' . $val);
}
throw new HttpResponseException(json((object)$error, $code));
}
}
\ No newline at end of file
<?php
/**
* 授权失败
*/
namespace app\api\controller;
use think\Exception;
class UnauthorizedException extends Exception
{
public $authenticate;
public function __construct($challenge = 'Basic', $message = 'authentication Failed')
{
$this->authenticate = $challenge;
$this->message = $message;
}
/**
* 获取验证错误信息
* @access public
* @return array|string
*/
public function getError()
{
return $this->error;
}
/**
* WWW-Authenticate challenge string
* @return array
*/
public function getHeaders()
{
return array('WWW-Authenticate' => $this->authenticate);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: xiezhixian
* Date: 2018/7/17
* Time: 上午11:04
*/
namespace app\api\controller\v1\app;
use app\api\controller\Api;
use app\api\logic\app\UserLogic;
use app\api\model\EngineerToken;
class Base extends Api
{
protected function validateToken(){
$token = getToken();
$bool = EngineerToken::build()->validateToken($token);
if (!$bool) {
self::returnmsg(401, [], [], "", "AUTH ERROR", "鉴权失败");
}
return $bool;
}
/**
* @author: zhaoxin
* @time: 2019年3月
* description 判断当前短信的类型
*/
protected function validateSmsType($requestData){
//必须是未注册的
if($requestData['sms_type'] == 'empty') {
$bool = \app\api\model\Engineer::build()->checkUser($requestData['mobile']);
if(!empty($bool)){
ResponseDirect(13000);
}
}
//必须是注册的
elseif($requestData['sms_type'] == 'must') {
$bool = \app\api\model\Engineer::build()->checkUser($requestData['mobile']);
if(empty($bool)){
ResponseDirect(13008);
}
}
//验证
elseif($requestData['sms_type'] == 'validate'){
return true;
}
else{
ResponseDirect(11005);
}
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: xiezhixian
* Date: 2019/3/14
* Time: 下午4:01
*/
namespace app\api\controller\v1\app;
use app\api\logic\app\ConfigLogic;
use app\api\model\AboutUs;
class Config extends Base
{
public $restMethodList = 'get|post|put';
/**
* User: zhaoxin
* Date: 2019-09-19
* Time: 10:39
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index(){
$requsetData = $this->selectParam(['key']);
$this->check($requsetData,'Base.config');
$data = ConfigLogic::index($requsetData['key']);
$data !== false ? $this->render($data) : ResponseDirect(10003);
}
/**
* User: zhaoxin
* Date: 2019-09-19
* Time: 10:38
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function about_us(){
$data= AboutUs::build()->where('id',1)->find();
$this->render($data);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-09-19
* Time: 14:35
*/
namespace app\api\controller\v1\app;
use app\api\model\EngineeringRegisters;
class Engineering extends Base
{
public $restMethodList = 'get|post|put';
/**
* User: zhaoxin
* Date: 2019-09-19
* Time: 15:06
* description
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function registers(){
$requestData = $this->selectParam(['type' => '1']);
$this->check($requestData,['type' => 'require|number|in:1,2,3']);
$data = EngineeringRegisters::build()->AllRegisters($requestData);
if ($data) {
$this->render($data,200);
} else {
ResponseDirect(14000);//查询工程注册失败
}
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: xiezhixian
* Date: 2019/3/14
* Time: 下午4:01
*/
namespace app\api\controller\v1\app;
use app\api\logic\app\HelpCenterLogic;
class HelpCenter extends Base
{
public $restMethodList = 'get|post|put';
/**
* User: zhaoxin
* Date: 2019-09-19
* Time: 10:00
*/
public function index(){
$request = $this->selectParam(['question']);
$data = HelpCenterLogic::index($request['question'],$this->pageIndex,$this->pageSize);
$this->render(['list'=>$data]);
}
/**
* User: zhaoxin
* Date: 2019-09-19
* Time: 10:00
* @param $id
*/
public function read($id){
$requestData['uuid'] = $id;
$this->check($requestData, 'Base.uuid');
$data = HelpCenterLogic::read($id);
$data !== false ? $this->render($data) : ResponseDirect(10003);
}
/**
* User: zhaoxin
* Date: 2019-09-19
* Time: 10:00
*/
public function feedback(){
$user_info = $this->validateToken();
$requestData = $this->selectParam(['content','img_src']);
$this->check($requestData, 'User.feedback');
$data = HelpCenterLogic::feedback($user_info['uuid'],$requestData);
$data !== false ? $this->render('反馈成功') : ResponseDirect(12016);//反馈失败
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/25
* Time: 19:22
*/
namespace app\api\controller\v1\app;
use app\api\logic\cms\BannerLogic;
use app\api\logic\cms\CooperatorLogic;
use app\api\logic\cms\EngineeringLogic;
use app\api\logic\cms\AdvantageLogic;
use app\api\logic\cms\HelpCenterLogic;
use app\api\logic\cms\AboutLogic;
use app\api\logic\cms\NewsLogic;
use app\api\logic\cms\MessageLogic;
use think\Collection;
class Index extends Base
{
public $restMethodList = 'get|put|post';
public function _initialize()
{
parent::_initialize();
//$this->hasPermission();
//$this->validateToken();
}
public function banner() {
$data = BannerLogic::index($this->pageIndex,$this->pageSize);
$data !== false ? $this->render($data) : $this->returnmsg(16130);
}
/**
* 企业新闻
*/
public function news() {
$data = NewsLogic::index($this->pageIndex,$this->pageSize);
$data !== false ? $this->render($data) : $this->returnmsg(16260);
}
/**
* 企业新闻详情
*/
public function news_detail() {
$requestData = $this->selectParam(['uuid']);
$data = NewsLogic::read($requestData['uuid']);
$data !== false ? $this->render($data) : $this->returnmsg(16261);
}
/**
* 加入智服联盟说明
*/
public function message() {
$data = MessageLogic::index($this->pageIndex,$this->pageSize);
$data !== false ? $this->render($data) : $this->returnmsg(16310);
}
/**
* 消息详情
*/
public function message_detail() {
$requestData = $this->selectParam(['uuid']);
$data = MessageLogic::read($requestData['uuid']);
$data !== false ? $this->render($data) : $this->returnmsg(16311);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: xiezhixian
* Date: 2019/3/14
* Time: 下午4:01
*/
namespace app\api\controller\v1\app;
use app\api\model\MessageUser;
use app\api\logic\app\MessageLogic;
class Message extends Base
{
public $restMethodList = 'get|post';
/**
* User: zhaoxin
* Date: 2019-09-19
* Time: 10:01
*/
public function index(){
$token = getToken();
if(!$token){
$this->render(['list'=>[]]);
}
$user= $this->validateToken();
$data = MessageLogic::index($user,$this->pageIndex,$this->pageSize);
$data !==false ? $this->render(['list'=>$data]) : ResponseDirect(10007);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-09-24
* Time: 16:55
*/
namespace app\api\controller\v1\app;
use app\api\logic\app\OrderLogic;
class Order extends Base
{
public $restMethodList = 'get|post|put';
public function index(){
$user = $this->validateToken();
$request = $this->selectParam([
'keyword' => '','order_status' => '2','engineering_type' => '1','start_time','end_time'
]);
$this->check($request,'Search.app_order_engineer');
$data = OrderLogic::index($request,$user,$this->pageIndex,$this->pageSize);
if ($data === false) {
ResponseDirect(14016);
}
$this->render($data);
}
public function read($id){
$user = $this->validateToken();
$this->check(['uuid' => $id], 'Base.uuid');
$order = new OrderLogic();
$data = $order->read($id);
if ($data === false) {
ResponseDirect(14018);
}
$this->render($data);
}
/**
* User: zhaoxin
* Date: 2019-09-23
* Time: 17:21
* description 上传表单
*/
public function uploadExcel(){
$user = $this->validateToken();
$request = $this->selectParam([
'uuid','excel_list' => []
]);
$this->check(['uuid' => $request['uuid']], 'Base.uuid');
//验证excel
foreach ($request['excel_list'] as $k => $v) {
$this->check($v,'Engineering.order_excel');
}
$data = OrderLogic::uploadExcel($request);
if ($data === false) {
ResponseDirect(14022);
}
$this->render('上传成功');
}
/**
* User: zhaoxin
* Date: 2019-10-10
* Time: 15:15
* description 维保订单上传合同图片
*/
public function uploadContractImg(){
$this->validateToken();
$request = $this->selectParam([
'uuid','img' => []
]);
$this->check(['uuid' => $request['uuid']], 'Base.uuid');
$data = OrderLogic::uploadContractImg($request);
if ($data === false) {
ResponseDirect(14022);
}
$this->render('上传成功');
}
/**
* User: zhaoxin
* Date: 2019-10-10
* Time: 15:22
* description 维保订单上传合同金额
*/
public function setMoney(){
$this->validateToken();
$request = $this->selectParam([
'uuid','money'
]);
$this->check($request, 'Engineering.money');
$data = OrderLogic::setMoney($request);
if ($data === false) {
ResponseDirect(14051);
}
$this->render('输入金额成功');
}
/**
* User: zhaoxin
* Date: 2019-10-11
* Time: 15:05
* description 下一步
*/
public function next(){
$this->validateToken();
$request = $this->selectParam([
'uuid'
]);
$this->check($request, 'Base.uuid');
$data = OrderLogic::next($request['uuid']);
if ($data === false) {
ResponseDirect(14055);
}
$this->render('操作成功');
}
/**
* User: zhaoxin
* Date: 2019-09-25
* Time: 16:08
* description 节点列表
*/
public function nodes(){
$user = $this->validateToken();
$request = $this->selectParam([
'uuid'
]);
$this->check(['uuid' => $request['uuid']], 'Base.uuid');
$data = OrderLogic::nodes($request['uuid']);
if ($data === false) {
ResponseDirect(14031);
}
$this->render($data);
}
/**
* User: zhaoxin
* Date: 2019-09-25
* Time: 16:08
* description 节点列表
*/
public function nodeDetails(){
$user = $this->validateToken();
$request = $this->selectParam([
'uuid','type' => '1'
]);
$this->check(['uuid' => $request['uuid']], 'Base.uuid');
$data = OrderLogic::nodeDetails($request['uuid'],$request['type']);
if ($data === false) {
ResponseDirect(14031);
}
$this->render($data);
}
/**
* User: zhaoxin
* Date: 2019-09-25
* Time: 16:22
* description 节点添加
*/
public function addNode(){
$user = $this->validateToken();
$request = $this->selectParam([
'uuid','node_name','node_time','node_type'
]);
$this->check($request, 'Engineering.add_node');
$data = OrderLogic::addNode($request);
if ($data === false) {
ResponseDirect(14032);
}
$this->render('添加节点成功');
}
/**
* User: zhaoxin
* Date: 2019-09-25
* Time: 16:22
* description 节点添加
*/
public function addNodeDetail(){
$user = $this->validateToken();
$request = $this->selectParam([
'uuid','node_uuid','node_remark','node_img' => []
]);
$this->check($request, 'Engineering.add_node_detail');
$data = OrderLogic::addNodeDetail($request);
if ($data === false) {
ResponseDirect(14032);
}
$this->render('添加节点进度成功');
}
/**
* User: zhaoxin
* Date: 2019-09-26
* Time: 14:43
* description 申请验收
*/
public function applyCheck(){
$user = $this->validateToken();
$request = $this->selectParam([
'uuid'
]);
$this->check(['uuid' => $request['uuid']], 'Base.uuid');
$data = OrderLogic::applyCheck($request['uuid'], $user);
if ($data === false) {
ResponseDirect(14039);
}
$this->render('申请验收成功');
}
public function datas(){
$user = $this->validateToken();
$request = $this->selectParam([
'year'
]);
$this->check($request, ['year' => 'require']);
$data = OrderLogic::datas($request['year'],$user['uuid']);
if ($data === false) {
ResponseDirect(14046);
}
$this->render($data);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: xiezhixian
* Date: 2018/7/17
* Time: 上午11:04
*/
namespace app\api\controller\v1\app;
use app\common\tools\Qiniu as QiniuTool;
class Qiniu extends Base
{
public function index(){
$Qiniu = new QiniuTool();
$bucket = $Qiniu->getBucketDomain();
$token = $Qiniu->getToken();
$config['bucket_domain'] = $bucket;
$config['token'] = $token;
$this->render($config);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: xiezhixian
* Date: 2018/5/4
* Time: 上午11:05
*/
namespace app\api\controller\v1\app;
use app\api\model\UserSms;
use app\api\controller\Api;
use think\Controller;
use app\api\logic\app\SendLogic;
use app\api\logic\app\UserLogic;
class Send extends Base
{
/**
* 允许访问的方式列表,资源数组如果没有对应的方式列表,请不要把该方法写上,如user这个资源,客户端没有delete操作
*/
public $restMethodList = 'get|post|put|';
/**
* @author: zhaoxin
* @time: 2019年4月
* description 发送验证码
*/
public function code()
{
$request = $this->selectParam(['mobile','sms_type']);
$this->check($request, 'Base.send_sms');
$this->validateSmsType($request);
$info = SendLogic::SendSms($request['mobile'], $request['sms_type']);
if ($info === false) {
ResponseDirect(11000);//验证码错误
}
$this->render('发送验证码成功',200);
}
}
<?php
/**
* Created by PhpStorm.
* User: xiezhixian
* Date: 2019/3/14
* Time: 下午4:01
*/
namespace app\api\controller\v1\app;
use app\api\logic\app\WithdrawalLogic;
class Withdrawal extends Base
{
public $restMethodList = 'get|post|put';
public function _initialize()
{
parent::_initialize();
//$this->validateToken();
}
/**
* @author: star
* @time: 2019年9月
* description 设置提现密码
*/
public function index(){
$user_info = $this->validateToken();
$request = $this->selectParam(['start_time'=>'','end_time'=>'','type','status'=>'']);
$this->check($request,"EnginnerWithdrawal.type");
$result = WithdrawalLogic::index($request,$user_info,$this->pageIndex,$this->pageSize);
$result != false ? $this->render($result) :ResponseDirect(18003);
}
/**
* @author: star
* @time: 2019年9月
* description 设置提现密码
*/
public function set_password(){
$user_info = $this->validateToken();
$request = $this->selectParam(['password']);
$this->check($request,"EnginnerWithdrawal.password");
$result = WithdrawalLogic::set_password($request,$user_info);
$result != false ? $this->render('提现密码设置成功') :ResponseDirect(16400);
}
/**
* @author: star
* @time: 2019年9月
* description 银行卡列表
*/
public function bank_list(){
$user_info = $this->validateToken();
$result = WithdrawalLogic::bank_list($user_info,$this->pageIndex,$this->pageSize);
$result != false ? $this->render($result) :ResponseDirect(16401);
}
/**
* @author: star
* @time: 2019年9月
* description 添加银行卡
*/
public function add_bank(){
$user_info = $this->validateToken();
$request = $this->selectParam(['bank_card','name','identity_card','mobile','code']);
$this->check($request,"EnginnerWithdrawal.add_bank");
$request['uuid'] = uuid();
$request['engineer_uuid'] = $user_info['uuid'];
$request['create_time'] = timeToDate();
$request['sms_type']='empty';
$result = WithdrawalLogic::add_bank($request);
$result != false ? $this->render('添加成功') :ResponseDirect(16402);
}
/**
* @author: star
* @time: 2019年9月
* description 提现
*/
public function submit(){
$user_info = $this->validateToken();
$request = $this->selectParam(['bank_uuid','money','password']);
$result = WithdrawalLogic::submit($request,$user_info);
$result != false ? $this->render('提现成功,等待后台审核') :ResponseDirect(18003);
}
/**
* @author: star
* @time: 2019年9月
* description 提现详情
*/
public function read($id){
$this->check(['uuid'=>$id],"ServiceWithdrawal.uuid");
$result = WithdrawalLogic::read($id);
$result != false ? $this->render($result) : ResponseDirect(18004);
}
//提现审核
public function update($id){
$request = $this->selectParam(['status','reason']);
$request['uuid'] = $id;
$this->check($request,"ServiceWithdrawal.update");
$result = WithdrawalLogic::cash_audit($request);
$result != false ? $this->render("操作成功") : ResponseDirect(18005);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/23
* Time: 14:15
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\AboutLogic;
use app\api\controller\v1\cms\Base;
class About extends Base
{
public $restMethodList = 'get|post|delete|put';
public function _initialize()
{
parent::_initialize();
//$this->hasPermission();
$this->validateToken();
}
/*
* 列表
*/
public function index()
{
$data = AboutLogic::index($this->pageIndex,$this->pageSize);
$data !== false ? $this->render($data) : $this->returnmsg(16180);
}
/*
* 详情
*/
public function read($id)
{
$this->check(['uuid' => $id], 'About.uuid');
$data = AboutLogic::read($id);
$data !== false ? $this->render($data) : $this->returnmsg(16181);
}
/*
* 新增
*/
public function save()
{
$requestData = $this->selectParam(['title','content']);
$requestData['uuid'] = uuid();
$requestData['create_time'] = timeToDate();
$requestData['update_time'] = timeToDate();
$this->check($requestData, 'About.save');
$bool = AboutLogic::save($requestData);
$bool !== false ? $this->render('新增成功'): $this->returnmsg(16181);
}
/*
* 编辑
*/
public function update($id)
{
$data = $this->selectParam(['title','content']);
$data['uuid'] = $id;
$data['update_time'] = timeToDate();
$this->check($data, 'About.update');
$bool = AboutLogic::update($data);
$bool !== false ? $this->render('编辑成功'): $this->returnmsg(16182);
}
/*
* 删除
*/
public function delete($id)
{
$this->check(['uuid' => $id], 'About.uuid');
$bool = AboutLogic::delete($id);
$bool !== false ? $this->render('删除成功'): $this->returnmsg(16183);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/8/21
* Time: 15:45
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\AdminLogLogic;
class AdminLogs extends Base
{
public $restMethodList = 'get';
public function _initialize()
{
parent::_initialize();
//$this->hasPermission();
$this->validateToken();
}
/**
* @author: Airon
* @time: 2019年4月
* description
* @throws \think\exception\DbException
*/
public function index() {
$requestData = $this->selectParam([
'start_time' => '',
'end_time' => '',
'admin_uuid' => '',
'keyword' => ''
]);
$this->check($requestData, [
'start_time' => 'date',
'end_time' => 'date',
'admin_uuid' => 'max:32',
], [
'start_time' => '起始时间 ',
'end_time' => '结束时间 ',
'admin_uuid' => '管理员ID ',
]);
$data = AdminLogLogic::index($requestData, $this->pageIndex, $this->pageSize);
$data !== false ? $this->render($data) : ResponseDirect(10003);//内容不存在
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/20
* Time: 15:12
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\AdminLogic;
class Admins extends Base
{
public $restMethodList = 'get|post|put|delete';
/**
* @author: Airon
* @time: 2019年4月
* description 登录
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function login() {
$requestData = $this->selectParam([
'account' => '',
'password' => ''
]);
$this->check($requestData, 'Admin.login');
$data = AdminLogic::login($requestData['account'], $requestData['password']);
if ($data === false) {
ResponseDirect(12002);//账号密码错误
}
$this->render($data);
}
/**
* @author: Airon
* @time: 2019年4月
* description
* @throws \think\exception\DbException
*/
public function index() {
$this->validateToken();
$requestData = $this->selectParam(['keyword' => '']);
$this->check($requestData, ['keyword'=>"max:30"]);
$data = AdminLogic::index($requestData['keyword'],$this->pageIndex, $this->pageSize);
$data !== false ? $this->render($data) :ResponseDirect(10003);//内容不存在
}
/**
* @author: Airon
* @time: 2019年4月
* description
* @param $id
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function read($id) {
$this->validateToken();
$this->check(['uuid' => $id], 'Base.uuid');
$data = AdminLogic::read($id);
$data !== false ? $this->render($data) : ResponseDirect(10003);//内容不存在
}
/**
* @author: Airon
* @time: 2019年4月
* description 新增
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function save(){
$this->validateToken();
$requestData = $this->selectParam([
'account' => '',
'name' => '',
'mobile' => '',
'password' => '',
'group_uuid' => ''
]);
$this->check($requestData, 'Admin.cms_save');
$bool = AdminLogic::save($requestData);
$bool !== false ? $this->render(200) : ResponseDirect(12017);//添加失败
}
/**
* @author: Airon
* @time: 2019年4月
* description
* @param $id
*/
public function update($id){
$this->validateToken();
$requestData = $this->selectParam([
'uuid' => $id,
'account' => '',
'name' => '',
'password' => '',
'mobile' => '',
'group_uuid' => ''
]);
$this->check($requestData, 'Admin.cms_update');
$bool = AdminLogic::update($requestData);
$bool !== false ? $this->render(200) : ResponseDirect(12011);//修改失败
}
/**
* @author: Airon
* @time: 2019年4月
* description
* @param $id
*/
public function delete($id){
$this->validateToken();
$this->check(['uuid' => $id], 'Base.uuid');
$bool = AdminLogic::delete($id);
$bool !== false ? $this->render(200) : ResponseDirect(12018);//删除失败
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/23
* Time: 14:15
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\AdvantageLogic;
use app\api\controller\v1\cms\Base;
class Advantage extends Base
{
public $restMethodList = 'get|post|delete|put';
public function _initialize()
{
parent::_initialize();
//$this->hasPermission();
$this->validateToken();
}
/*
* 宣传片列表
*/
public function index()
{
$data = AdvantageLogic::index($this->pageIndex,$this->pageSize);
$data !== false ? $this->render($data) : $this->returnmsg(16160);
}
/*
* 详情
*/
public function read($id)
{
$this->check(['uuid' => $id], 'Advantage.uuid');
$data = AdvantageLogic::read($id);
$data !== false ? $this->render($data) : $this->returnmsg(16161);
}
/*
* 新增
*/
public function save()
{
$requestData = $this->selectParam(['img_src','title','content']);
$requestData['uuid'] = uuid();
$requestData['create_time'] = timeToDate();
$requestData['update_time'] = timeToDate();
$this->check($requestData, 'Advantage.save');
$bool = AdvantageLogic::save($requestData);
$bool !== false ? $this->render('新增成功'): $this->returnmsg(16162);
}
/*
* 编辑
*/
public function update($id)
{
$data = $this->selectParam(['img_src','title','content']);
$data['uuid'] = $id;
$data['update_time'] = timeToDate();
$this->check($data, 'Advantage.update');
$bool = AdvantageLogic::update($data);
$bool !== false ? $this->render('编辑成功'): $this->returnmsg(16163);
}
/*
* 删除
*/
public function delete($id)
{
$this->check(['uuid' => $id], 'Advantage.uuid');
$bool = AdvantageLogic::delete($id);
$bool !== false ? $this->render('删除成功'): $this->returnmsg(16164);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/23
* Time: 14:15
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\BannerLogic;
class Banner extends Base
{
public $restMethodList = 'get|post|delete|put';
public function _initialize()
{
parent::_initialize();
// $this->hasPermission();
//$this->validateToken();
}
/*
* 查看轮播图
*/
public function index()
{
$data = BannerLogic::index($this->pageIndex,$this->pageSize);
$data !== false ? $this->render($data) : ResponseDirect(16130);
}
/*
* 查看轮播图
*/
public function read($id)
{
$this->check(['uuid' => $id], 'Banner.uuid');
$data = BannerLogic::read($id);
$data !== false ? $this->render($data) : ResponseDirect(16131);
}
/*
* 创建轮播图
*/
public function save()
{
$requestData = $this->selectParam(['url', 'img_src']);
$requestData['uuid'] = uuid();
$requestData['create_time'] = timeToDate();
$requestData['update_time'] = timeToDate();
$this->check($requestData, 'Banner.save');
$bool = BannerLogic::save($requestData);
$bool !== false ? $this->render('新增成功'): ResponseDirect(16132);
}
/*
* 编辑轮播图
*/
public function update($id)
{
$data = $this->selectParam(['img_src','url','uuid'=>$id]);
$this->check($data, 'Banner.update');
$bool = BannerLogic::update($data);
$bool !== false ? $this->render('编辑成功'): ResponseDirect(16133);
}
/*
* 删除轮播图
*/
public function delete($id)
{
$this->check(['uuid' => $id], 'Banner.uuid');
$bool = BannerLogic::delete($id);
$bool !== false ? $this->render('删除成功'): ResponseDirect(16134);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-04-10
* Time: 10:38
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\AdminTokenLogic;
use app\api\logic\cms\GroupLogic;
use app\api\controller\Api;
use think\Request;
use think\Hook;
use think\Session;
class Base extends Api
{
public function __construct(Request $request = null)
{
Hook::add('response_end', 'app\common\behavior\Log', true);
parent::__construct($request);
}
protected function validateToken() {
$token = getToken();
$user_info = AdminTokenLogic::validateToken($token);
if (!$user_info) {
self::returnmsg(401, [], [], "", "AUTH ERROR", "鉴权失败");
}
Session::set('admin_info', $user_info);
return $user_info;
}
protected function hasPermission() {
$controller = $this->request->controller();
$controller_path = explode('.', $controller);
$controller = strtolower(end($controller_path));
$action = strtolower($this->request->action());
$token_info = $this->validateToken();
$admin_uuid = $token_info['uuid'];
$bool = GroupLogic::hasPermission($admin_uuid, $controller, $action);
if (!$bool) {
self::returnmsg(401, [], [], "", "AUTH ERROR", "您没有权限,请联系超级管理员");
}
}
/**
* @author: ChiaHsiang
* @time: 2018/8/10
* @description: 从前端获取文件,存入public/excel目录下,返回文件全路径
* @return string
*/
public function getFile() {
if (empty($_FILES['file'])) {
ResponseDirect(10001);//缺少必要参数
}
$file = request()->file('file');
$info = $file->rule('uniqid')->move(ROOT_PATH.'public' . DS . 'excel');
if (!$info) {
ResponseDirect(10001);//缺少必要参数
}
$file = $info->getFilename();
$save_path = ROOT_PATH . 'public' . DS . 'excel' . DS;
$file_name = $save_path . $file;
return $file_name;
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/25
* Time: 19:22
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\ConfigLogic;
use think\Collection;
class Config extends Base
{
public $restMethodList = 'get|put|post';
public function _initialize()
{
parent::_initialize();
//$this->hasPermission();
//$this->validateToken();
}
public function read($id) {
$requestData = $this->selectParam([
'key' => $id,
]);
$this->check($requestData, [
'key' => 'require|in:register_agreement_engineer ,register_agreement_personal ,register_agreement_team,engineer_withdrawal_rate,network_withdrawal_rate,engineer_order_rate,network_order_rate,repair_excel,engineer_excel'
], [
'key' => '资源类型 ',
]);
$data = ConfigLogic::read($requestData['key']);
$data !== false ? $this->render($data) : $this->returnmsg(16052);
}
public function index() {
$data = ConfigLogic::lists();
$data !== false ? $this->render($data) : $this->returnmsg(16052);
}
public function excel() {
$data = ConfigLogic::excel();
$data !== false ? $this->render($data) : $this->returnmsg(16302);
}
public function excel_edit() {
$requestData = $this->selectParam(['value','type']);
$this->check($requestData, [
'type' => 'require|in:1,2',
'value' => 'require'
], [
'value' => '资源 ',
'type' => '资源类型 ',
]);
$requestData['update_time'] = timeToDate();
$data = ConfigLogic::excel_edit($requestData);
$data !== false ? $this->render('上传成功') : $this->returnmsg(16302);
}
public function update($id) {
$requestData = $this->selectParam([
'key' => $id,
'value' => '',
]);
$this->check($requestData, [
'key' => 'require|in:register_agreement_engineer,register_agreement_personal,register_agreement_team,engineer_withdrawal_rate,network_withdrawal_rate,engineer_order_rate,network_order_rate,repair_excel,engineer_excel',
'value' => 'require',
], [
'key' => '资源类型',
'value' => '资源值',
]);
$requestData['update_time'] = timeToDate();
$bool = ConfigLogic::update($requestData);
$bool !== false ? $this->render('编辑成功') : $this->returnmsg(16051);
}
public function poster(){
$data = \app\api\model\Config::build()->where('key','poster')->value('value');
$this->render($data);
}
public function update_poster(){
$request = $this->selectParam(['poster']);
$data = \app\api\model\Config::build()->where('key','poster')->update(['value'=>$request['poster']]);
$data !== false ? $this->render(200) : $this->returnmsg(403);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/23
* Time: 14:15
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\CooperatorLogic;
use app\api\controller\v1\cms\Base;
class Cooperator extends Base
{
public $restMethodList = 'get|post|delete|put';
public function _initialize()
{
parent::_initialize();
//$this->hasPermission();
$this->validateToken();
}
/*
* 宣传片列表
*/
public function index()
{
$data = CooperatorLogic::index($this->pageIndex,$this->pageSize);
$data !== false ? $this->render($data) : $this->returnmsg(16110);
}
/*
* 详情
*/
public function read($id)
{
$this->check(['uuid' => $id], 'Cooperator.uuid');
$data = CooperatorLogic::read($id);
$data !== false ? $this->render($data) : $this->returnmsg(16111);
}
/*
* 新增
*/
public function save()
{
$requestData = $this->selectParam(['name','url','img_src','content','type']);
$requestData['uuid'] = uuid();
$requestData['create_time'] = timeToDate();
$this->check($requestData, 'Cooperator.save');
$bool = CooperatorLogic::save($requestData);
$bool !== false ? $this->render('新增成功'): $this->returnmsg(16112);
}
/*
* 编辑
*/
public function update($id)
{
$data = $this->selectParam(['name','url','img_src','content','type']);
$data['uuid'] = $id;
$data['update_time'] = timeToDate();
$this->check($data, 'Cooperator.update');
$bool = CooperatorLogic::update($data);
$bool !== false ? $this->render('编辑成功'): $this->returnmsg(16113);
}
/*
* 删除
*/
public function delete($id)
{
$this->check(['uuid' => $id], 'Cooperator.uuid');
$bool = CooperatorLogic::delete($id);
$bool !== false ? $this->render('删除成功'): $this->returnmsg(16114);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-09-20
* Time: 14:40
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\EngineerLogic;
use app\api\model\ServiceNetwork;
class Engineer extends Base
{
public $restMethodList = 'get|put|post|delete';
public function _initialize()
{
parent::_initialize();
$this->validateToken();
}
/**
* User: zhaoxin
* Date: 2019-09-20
* Time: 15:07
* description 工程师列表
*/
public function index(){
$request = $this->selectParam([
'keyword' => '','service_type' => '','is_authentication' => '','province' => '',
'city' => '','county' => '','user_type' => '','is_export' => ''
]);
$this->check($request,'Search.engineer_search');
$data = EngineerLogic::index($request, $this->pageIndex, $this->pageSize);
if($request['is_export'] == '1'){
$header = ['序号','姓名','联系方式','地区','工程师类型','所属服务网点','添加时间','是否认证'];
excelExport('工程师列表',$header,$data);
}
$data !== false ? $this->render($data) : ResponseDirect(13011);
}
/**
* User: zhaoxin
* Date: 2019-09-29
* Time: 11:13
* description 导入
*/
public function import(){
$file_name = $this->getFile();
$service_uuid = ServiceNetwork::build()->where(['type' => '0'])->value('uuid');
$bool = \app\api\model\Engineer::import('Xlsx',$file_name,$service_uuid,'3');
if($bool['status'] == '1'){
$this->render(['message' => $bool['message']]);
}
elseif($bool['status'] == '2'){
$this->render(['message' => $bool['message'],'info'=>$bool['info']],403);
}
else{
ResponseDirect(13021);
}
}
/**
* User: zhaoxin
* Date: 2019-09-29
* Time: 11:16
* description
*/
public function downTemplate()
{
$name = '用户导入模版下载';
$header = [
'姓名','联系方式','省','市','区','工程师类型',
];
$data[] = [
'某某某','13302516724','广东省','深圳市','龙岗区','工程师'
];
excelExport($name,$header,$data);
}
/**
* User: zhaoxin
* Date: 2019-09-20
* Time: 15:13
* description 工程师详情
* @param $id
*/
public function read($id){
$this->check(['uuid' => $id],'Base.uuid');
$data = EngineerLogic::read($id);
$data !== false ? $this->render($data) : ResponseDirect(13012);
}
/**
* User: zhaoxin
* Date: 2019-09-20
* Time: 15:16
* description 删除
* @param $id
*/
public function delete($id){
$this->check(['uuid' => $id],'Base.uuid');
$data = EngineerLogic::delete($id);
$data !== false ? $this->render('删除成功') : ResponseDirect(13013);
}
/**
* User: zhaoxin
* Date: 2019-09-20
* Time: 15:20
* description 新增
*/
public function save(){
$requestData = $this->selectParam([
'mobile', 'password',
'service_type','name','province','city','county','service_day' => [],'service_time' => [],'service_skill' => [],
'id_img_one','id_img_two','other_img' => [],'number' => ''
]);
$this->check($requestData, 'Engineer.cms_register');
$data = \app\api\model\Engineer::build()->register($requestData,'3');
if ($data){
$this->render('新增成功',200);
}else{
ResponseDirect(13001);
}
}
/**
* User: zhaoxin
* Date: 2019-09-26
* Time: 17:47
* description 认证
*/
public function authentication(){
$requestData = $this->selectParam(['engineer_uuid','is_authentication']);
$this->check($requestData, 'Engineer.authentication');
$data = \app\api\model\Engineer::build()->authentication($requestData);
if ($data){
$this->render('操作成功',200);
}else{
ResponseDirect(13017);
}
}
public function info(){
$request = $this->selectParam([
'uuid'
]);
$this->check($request,'Base.uuid');
$data = EngineerLogic::info($request['uuid']);
$data !== false ? $this->render($data) : ResponseDirect(15008);
}
public function lists(){
$request = $this->selectParam([
'keyword','service_type','is_authentication','status'
]);
$this->check($request,'Search.engineer_list_search');
$data = EngineerLogic::lists($request,$this->pageIndex,$this->pageSize);
$data !== false ? $this->render($data) : ResponseDirect(15000);
}
public function handle(){
$request = $this->selectParam([
'uuid','engineer_status','reason'
]);
$this->check($request,'engineer.engineer_handle');
$data = EngineerLogic::handle($request);
$data !== false ? $this->render('审核成功') : ResponseDirect(15009);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: xiezhixian
* Date: 2019/3/14
* Time: 下午4:01
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\EngineerWithdrawalLogic;
class EngineerWithdrawal extends Base
{
public $restMethodList = 'get|post|put';
public function _initialize()
{
parent::_initialize();
$this->validateToken();
}
/**
* @author: star
* @time: 2019年9月
* description 提现列表
*/
public function index(){
$request = $this->selectParam(['status'=>'','service_type'=>'']);
$result = EngineerWithdrawalLogic::index($request,$this->pageIndex,$this->pageSize);
$result != false ? $this->render($result) :ResponseDirect(18003);
}
/**
* @author: star
* @time: 2019年9月
* description 提现详情
*/
public function read($id){
$this->check(['uuid'=>$id],"ServiceWithdrawal.uuid");
$result = EngineerWithdrawalLogic::read($id);
$result != false ? $this->render($result) : ResponseDirect(18004);
}
//提现审核
public function update($id){
$request = $this->selectParam(['status','reason']);
$request['uuid'] = $id;
$this->check($request,"ServiceWithdrawal.update");
$result = EngineerWithdrawalLogic::cash_audit($request);
$result != false ? $this->render("操作成功") : ResponseDirect(18005);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-09-21
* Time: 17:30
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\EngineeringLogic;
class Engineering extends Base
{
public $restMethodList = 'get|put|post|delete';
public function _initialize()
{
parent::_initialize();
$this->validateToken();
}
/**
* User: zhaoxin
* Date: 2019-09-21
* Time: 18:04
* description 新增
*/
public function save(){
$requestData = $this->selectParam([
'type','name','title','img','content'
]);
$this->check($requestData, 'Engineering.save');
$data = EngineeringLogic::save($requestData);
if ($data){
$this->render('新增成功',200);
}else{
ResponseDirect(14001);
}
}
public function read($id){
$this->check(['uuid' => $id], 'Base.uuid');
$data = EngineeringLogic::read($id);
if ($data){
$this->render($data,200);
}else{
ResponseDirect(14004);
}
}
/**
* User: zhaoxin
* Date: 2019-09-21
* Time: 18:14
* description
* @param $id
*/
public function update($id){
$requestData = $this->selectParam([
'type','name','title','img','content'
]);
$this->check($requestData, 'Engineering.save');
$data = EngineeringLogic::update($requestData,$id);
if ($data){
$this->render('编辑成功',200);
}else{
ResponseDirect(14002);
}
}
/**
* User: zhaoxin
* Date: 2019-09-21
* Time: 18:18
* description
*/
public function index(){
$request = $this->selectParam([
'keyword','engineering_type' => '1'
]);
$this->check($request, 'Search.engineering_search');
$data = EngineeringLogic::index($request,$this->pageIndex,$this->pageSize);
if ($data){
$this->render($data,200);
}else{
ResponseDirect(14003);
}
}
/**
* User: zhaoxin
* Date: 2019-09-21
* Time: 18:24
* description
* @param $id
*/
public function delete($id){
$this->check(['uuid' => $id], 'Base.uuid');
$data = EngineeringLogic::delete($id);
if ($data){
$this->render('删除成功',200);
}else{
ResponseDirect(14004);
}
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-09-23
* Time: 09:46
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\EngineeringLogic;
class EngineeringGrade extends Base
{
public $restMethodList = 'get|put|post|delete';
public function _initialize()
{
parent::_initialize();
$this->validateToken();
}
public function index(){
$data = \app\api\model\EngineeringGrade::build()
->field(['uuid','title','praise','order'])
->order(['create_time' => 'desc'])
->paginate(['list_rows' => $this->pageSize, 'page' => $this->pageIndex]);
if ($data){
$this->render($data,200);
}else{
ResponseDirect(14008);
}
}
public function save(){
$requestData = $this->selectParam([
'title','praise','order'
]);
$this->check($requestData, 'Engineering.grade_save');
$requestData['uuid'] = uuid();
$requestData['create_time'] = timeToDate();
$data = \app\api\model\EngineeringGrade::build()
->insert($requestData);
if ($data){
$this->render('新增成功',200);
}else{
ResponseDirect(14005);
}
}
public function update($id){
$requestData = $this->selectParam([
'title','praise','order'
]);
$this->check($requestData, 'Engineering.target_save');
$requestData['update_time'] = timeToDate();
$data = \app\api\model\EngineeringGrade::build()
->where(['uuid' => $id])
->update($requestData);
if ($data){
$this->render('编辑成功',200);
}else{
ResponseDirect(14006);
}
}
public function delete($id){
$this->check(['uuid' => $id], 'Base.uuid');
$data = \app\api\model\EngineeringGrade::build()
->where(['uuid' => $id])
->delete();
if ($data){
$this->render('删除成功',200);
}else{
ResponseDirect(14007);
}
}
public function read($id){
$this->check(['uuid' => $id], 'Base.uuid');
$data = \app\api\model\EngineeringGrade::build()
->where(['uuid' => $id])
->find();
if ($data){
$this->render($data,200);
}else{
ResponseDirect(14007);
}
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-09-23
* Time: 09:46
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\EngineeringLogic;
class EngineeringRegisters extends Base
{
public $restMethodList = 'get|put|post|delete';
public function _initialize()
{
parent::_initialize();
$this->validateToken();
}
public function index(){
$requestData = $this->selectParam([
'registers_type'
]);
$data = \app\api\model\EngineeringRegisters::build()
->where(['is_delete' => '0','type' =>$requestData['registers_type']])
->order(['create_time' => 'desc'])
->paginate(['list_rows' => $this->pageSize, 'page' => $this->pageIndex]);
if ($data){
$this->render($data,200);
}else{
ResponseDirect(14009);
}
}
public function save(){
$requestData = $this->selectParam([
'registers_type','content'
]);
$this->check($requestData, 'Engineering.registers_save');
$data = \app\api\model\EngineeringRegisters::build()
->insert([
'uuid' => uuid(),
'type' => $requestData['registers_type'],
'content' => $requestData['content'],
'create_time' => timeToDate(),
]);
if ($data){
$this->render('新增成功',200);
}else{
ResponseDirect(14010);
}
}
public function update($id){
$requestData = $this->selectParam([
'content','registers_type'
]);
$this->check($requestData, 'Engineering.registers_save');
$data = \app\api\model\EngineeringRegisters::build()
->where(['uuid' => $id])
->update([
'update_time' => timeToDate(),
'content' => $requestData['content']
]);
if ($data){
$this->render('编辑成功',200);
}else{
ResponseDirect(14011);
}
}
public function delete($id){
$this->check(['uuid' => $id], 'Base.uuid');
$data = \app\api\model\EngineeringRegisters::build()
->where(['uuid' => $id])
->update([
'update_time' => timeToDate(),
'is_delete' => '1'
]);
if ($data){
$this->render('删除成功',200);
}else{
ResponseDirect(14012);
}
}
public function read($id){
$this->check(['uuid' => $id], 'Base.uuid');
$data = \app\api\model\EngineeringRegisters::build()
->where(['uuid' => $id])
->find();
if ($data){
$this->render($data,200);
}else{
ResponseDirect(14012);
}
}
public function lists(){
$data = \app\api\model\EngineeringTarget::build()
->where(['is_delete' => '0'])
->field(['uuid','content title'])
->order(['create_time' => timeToDate()])
->select();
if ($data){
$this->render(['list' => $data],200);
}else{
ResponseDirect(14009);
}
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-09-23
* Time: 09:46
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\EngineeringLogic;
class EngineeringTarget extends Base
{
public $restMethodList = 'get|put|post|delete';
public function _initialize()
{
parent::_initialize();
$this->validateToken();
}
public function index(){
$data = \app\api\model\EngineeringTarget::build()
->where(['is_delete' => '0'])
->field(['uuid','title','create_time'])
->order(['create_time' => 'DESC'])
->paginate(['list_rows' => $this->pageSize, 'page' => $this->pageIndex]);
if ($data){
$this->render($data,200);
}else{
ResponseDirect(14009);
}
}
public function save(){
$requestData = $this->selectParam([
'title'
]);
$this->check($requestData, 'Engineering.target_save1');
$data = \app\api\model\EngineeringTarget::build()
->insert([
'uuid' => uuid(),
'create_time' => timeToDate(),
'title' => $requestData['title']
]);
if ($data){
$this->render('新增成功',200);
}else{
ResponseDirect(14010);
}
}
public function update($id){
$requestData = $this->selectParam([
'title'
]);
$this->check($requestData, 'Engineering.target_save1');
$data = \app\api\model\EngineeringTarget::build()
->where(['uuid' => $id])
->update([
'update_time' => timeToDate(),
'title' => $requestData['title']
]);
if ($data){
$this->render('编辑成功',200);
}else{
ResponseDirect(14011);
}
}
public function delete($id){
$this->check(['uuid' => $id], 'Base.uuid');
$data = \app\api\model\EngineeringTarget::build()
->where(['uuid' => $id])
->update([
'update_time' => timeToDate(),
'is_delete' => '1'
]);
if ($data){
$this->render('删除成功',200);
}else{
ResponseDirect(14012);
}
}
public function read($id){
$this->check(['uuid' => $id], 'Base.uuid');
$data = \app\api\model\EngineeringTarget::build()
->where(['uuid' => $id])
->find();
if ($data){
$this->render($data,200);
}else{
ResponseDirect(14012);
}
}
public function lists(){
$data = \app\api\model\EngineeringTarget::build()
->where(['is_delete' => '0'])
->field(['uuid','title'])
->order(['create_time' => timeToDate()])
->select();
if ($data){
$this->render(['list' => $data],200);
}else{
ResponseDirect(14009);
}
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/23
* Time: 14:15
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\ExampleLogic;
use app\api\controller\v1\cms\Base;
class Example extends Base
{
public $restMethodList = 'get|post|delete|put';
public function _initialize()
{
parent::_initialize();
//$this->hasPermission();
$this->validateToken();
}
/*
* 列表
*/
public function index()
{
$data = ExampleLogic::index($this->pageIndex,$this->pageSize);
$data !== false ? $this->render($data) : $this->returnmsg(16081);
}
/*
* 详情
*/
public function read($id)
{
$this->check(['uuid' => $id], 'Example.uuid');
$data = ExampleLogic::read($id);
$data !== false ? $this->render($data) : $this->returnmsg(16082);
}
/*
* 新增
*/
public function save()
{
$requestData = $this->selectParam(['name','profile','img_src','content']);
$requestData['uuid'] = uuid();
$requestData['create_time'] = timeToDate();
$this->check($requestData, 'Example.save');
$bool = ExampleLogic::save($requestData);
$bool !== false ? $this->render('新增成功'): $this->returnmsg(16083);
}
/*
* 编辑
*/
public function update($id)
{
$data = $this->selectParam(['name','profile','img_src','content']);
$data['uuid'] = $id;
$data['update_time'] = timeToDate();
$this->check($data, 'Example.update');
$bool = ExampleLogic::update($data);
$bool !== false ? $this->render('编辑成功'): $this->returnmsg(16084);
}
/*
* 删除
*/
public function delete($id)
{
$this->check(['uuid' => $id], 'Example.uuid');
$bool = ExampleLogic::delete($id);
$bool !== false ? $this->render('删除成功'): $this->returnmsg(16085);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-04-11
* Time: 10:05
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\FinanceLogic;
use app\api\model\ServiceNetwork;
class Finance extends Base
{
/**
* 允许访问的方式列表,资源数组如果没有对应的方式列表,请不要把该方法写上,如user这个资源,客户端没有delete操作
*/
public $restMethodList = 'get|post|put';
public function _initialize()
{
parent::_initialize();
//$this->hasPermission();
$this->validateToken();
}
public function index(){
$requestData = $this->selectParam([
'engineering_type','start_time','end_time','is_export'
]);
$this->check($requestData,'Search.finances');
$requestData['service_uuid'] = ServiceNetwork::build()->where(['type' => '0'])->value('uuid');
$data = \app\api\model\Order::finances($requestData,$this->pageIndex,$this->pageSize,'3');
if ($requestData['is_export']==1) {
$name='财务订单信息';
$header=['订单编号','联系人','联系方式','省','市','服务类型','提交时间','工程类型'];
excelExport($name,$header,$data);
}
$data !== false ? $this->render($data): ResponseDirect(16371);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/20
* Time: 17:12
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\GroupLogic;
class Groups extends Base
{
public $restMethodList = 'get|post|put|delete';
public function _initialize()
{
parent::_initialize();
$this->validateToken();
}
/**
* @author: Airon
* @time: 2019年4月
* description
* @throws \think\exception\DbException
*/
public function index() {
$data = GroupLogic::index($this->pageIndex, $this->pageSize);
$data !== false ? $this->render($data) :ResponseDirect(10003);//内容不存在
}
/**
* @author: Airon
* @time: 2019年4月
* description 获取组相关权限
* @param $id
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function read($id) {
$this->check(['uuid' => $id], 'Base.uuid');
$data = GroupLogic::read($id);
$data !== false ? $this->render($data) : ResponseDirect(10003);//内容不存在
}
/*
* 新增
*/
public function save(){
$requestData = $this->selectParam([
'name' => '',
'menu_uuid' => []
]);
$this->check($requestData, 'Groups.cms_save');
$bool = GroupLogic::save($requestData);
$bool !== false ? $this->render(200) : ResponseDirect(12017);//添加失败
}
/*
* 编辑
*/
public function update($id){
$requestData = $this->selectParam([
'uuid' => $id,
'name' => '',
'menu_uuid' => []
]);
$this->check($requestData, 'Groups.cms_update');
$bool = GroupLogic::update($requestData);
$bool !== false ? $this->render(200) : ResponseDirect(12011);//修改失败
}
/*
* 删除
*/
public function delete($id){
$this->check([
'uuid' => $id,
], 'Base.uuid');
$bool = GroupLogic::delete($id);
$bool !== false ? $this->render(200) :ResponseDirect(12018);//删除失败
}
/*
* 节点获取
*/
public function getMenuList($id){
$this->check(['uuid' => $id],'Base.uuid');
$data = GroupLogic::getMenuList($id);
$data !== false ? $this->render($data) : ResponseDirect(10004);//操作失败
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/23
* Time: 14:15
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\HelpCenterLogic;
class HelpCenter extends Base
{
public $restMethodList = 'get|post|delete|put';
public function _initialize()
{
parent::_initialize();
// $this->hasPermission();
$this->validateToken();
}
/**
* @author: jkl
* @time: 2019年3月
* description 帮助中心列表
*/
public function index(){
$requestData = $this->selectParam(['type']);
$this->check($requestData, 'HelpCenter.type');
$data = HelpCenterLogic::index($requestData,$this->pageIndex,$this->pageSize);
$this->render($data);
}
/**
* @author: jkl
* @time: 2019年3月
* description 帮助中心詳情
*/
public function read($id){
$requestData['uuid'] = $id;
$this->check($requestData, 'HelpCenter.uuid');
$data = HelpCenterLogic::read($id);
$data !== false ? $this->render($data) : ResponseDirect(16201);
}
/*
* 添加问题
*/
public function save()
{
$requestData = $this->selectParam(['title','content','type']);
$requestData['uuid'] = uuid();
$requestData['create_time'] = timeToDate();
$requestData['update_time'] = timeToDate();
$this->check($requestData, 'HelpCenter.save');
$bool = HelpCenterLogic::save($requestData);
$bool !== false ? $this->render('新增成功'): ResponseDirect(16202);
}
/*
* 编辑问题
*/
public function update($id)
{
$data = $this->selectParam(['title','content','type','uuid'=>$id]);
$this->check($data, 'HelpCenter.update');
$bool = HelpCenterLogic::update($data);
$bool !== false ? $this->render('编辑成功'): ResponseDirect(16203);
}
/*
* 删除问题
*/
public function delete($id)
{
$this->check(['uuid' => $id], 'HelpCenter.uuid');
$bool = HelpCenterLogic::delete($id);
$bool !== false ? $this->render('删除成功'): ResponseDirect(16204);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/23
* Time: 14:15
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\HelpCenterTypeLogic;
class HelpCenterType extends Base
{
public $restMethodList = 'get|post|delete|put';
public function _initialize()
{
parent::_initialize();
// $this->hasPermission();
$this->validateToken();
}
/**
* @author: jkl
* @time: 2019年3月
* description 帮助中心列表
*/
public function index(){
$data = HelpCenterTypeLogic::index($condition='',$this->pageIndex,$this->pageSize);
$this->render($data);
}
/**
* @author: jkl
* @time: 2019年3月
* description 帮助中心詳情
*/
public function read($id){
$requestData['uuid'] = $id;
$this->check($requestData, 'HelpCenter.uuid');
$data = HelpCenterTypeLogic::read($id);
$data !== false ? $this->render($data) : ResponseDirect(16201);
}
/*
* 添加问题
*/
public function save()
{
$requestData = $this->selectParam(['title']);
$requestData['uuid'] = uuid();
$requestData['create_time'] = timeToDate();
$requestData['update_time'] = timeToDate();
$this->check($requestData, 'HelpCenter.save_type');
$bool = HelpCenterTypeLogic::save($requestData);
$bool !== false ? $this->render('新增成功'): ResponseDirect(16202);
}
/*
* 编辑问题
*/
public function update($id)
{
$data = $this->selectParam(['title','type','uuid'=>$id]);
$this->check($data, 'HelpCenter.update_type');
$bool = HelpCenterTypeLogic::update($data);
$bool !== false ? $this->render('编辑成功'): ResponseDirect(16203);
}
/*
* 删除问题
*/
public function delete($id)
{
$this->check(['uuid' => $id], 'HelpCenter.uuid');
$bool = HelpCenterTypeLogic::delete($id);
$bool !== false ? $this->render('删除成功'): ResponseDirect(16204);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/31
* Time: 14:27
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\MenuBarLogic;
class Menus extends Base
{
public $restMethodList = 'get|post|put|delete';
public function _initialize()
{
parent::_initialize();
//$this->hasPermission();
$this->validateToken();
}
/**
* @author: Airon
* @time: 2019年4月
* description
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index()
{
$data = MenuBarLogic::index();
$data !== false ? $this->render($data) : ResponseDirect(10003);//内容不存在
}
public function save()
{
$requestData = $this->selectParam([
'sort' => 0,
'name',
'url' => '',
'classes' => '',
'parent_uuid' => '0'
]);
$requestData['parent_uuid'] = empty($requestData['parent_uuid'])?0:$requestData['parent_uuid'];
$this->check($requestData, 'MenuBars.cms_save');
$bool = MenuBarLogic::save($requestData);
$bool !== false ? $this->render(200) : ResponseDirect(12017);//添加失败
}
public function update($id)
{
$requestData = $this->selectParam([
'uuid' => $id,
'sort' => 0,
'name',
'url' => '',
'classes' => '',
'parent_uuid' => '0'
]);
$requestData['parent_uuid'] = empty($requestData['parent_uuid'])?0:$requestData['parent_uuid'];
$this->check($requestData, 'MenuBars.cms_update');
$bool = MenuBarLogic::update($requestData);
$bool !== false ? $this->render(200) : ResponseDirect(12011);//修改失败
}
public function delete($id)
{
$this->check(['uuid' => $id], 'Base.uuid');
$bool = MenuBarLogic::delete($id);
$bool !== false ? $this->render(200) : ResponseDirect(12018);//删除失败
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/23
* Time: 14:15
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\MessageLogic;
class Message extends Base
{
public $restMethodList = 'get|post|delete|put';
public function _initialize()
{
parent::_initialize();
// $this->hasPermission();
$this->validateToken();
}
/*
* 列表
*/
public function index()
{
//$request = $this->selectParam(['keyword','status','start_time','end_time','release_start_time','release_end_time']);
$data = MessageLogic::index($this->pageIndex,$this->pageSize);
$data !== false ? $this->render($data) : ResponseDirect(16310);
}
/*
* 详情
*/
public function read($id)
{
$this->check(['uuid' => $id], 'Message.uuid');
$data = MessageLogic::read($id);
$data !== false ? $this->render($data) : ResponseDirect(16311);
}
/*
* 创建
*/
public function save()
{
$requestData = $this->selectParam(['title','content']);
$requestData['uuid'] = uuid();
$requestData['create_time'] = timeToDate();
$this->check($requestData, 'Message.save');
$bool = MessageLogic::save($requestData);
$bool !== false ? $this->render('新增成功'): ResponseDirect(16312);
}
/*
* 创建
*/
public function update()
{
$requestData = $this->selectParam(['title','content','img_src']);
$requestData['uuid'] = uuid();
$requestData['create_time'] = timeToDate();
$this->check($requestData, 'Message.update');
$bool = MessageLogic::save($requestData);
$bool !== false ? $this->render('编辑成功'): ResponseDirect(16313);
}
/*
* 删除
*/
public function delete($id)
{
$this->check(['uuid' => $id], 'Message.uuid');
$bool = MessageLogic::delete($id);
$bool !== false ? $this->render('删除成功'): ResponseDirect(16314);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-09-20
* Time: 17:30
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\NetworkLogic;
use app\api\model\ServiceNetwork;
class Network extends Base
{
public $restMethodList = 'get|post|delete|put';
public function _initialize()
{
parent::_initialize();
// $this->hasPermission();
$this->validateToken();
}
/**
* User: zhaoxin
* Date: 2019-09-20
* Time: 17:53
* description 服务网点列表
* @throws \think\exception\DbException
*/
public function index(){
$request = $this->selectParam([
'keyword' => '','is_export'
]);
$this->check($request,'Search.keyword');
$data = NetworkLogic::index($request,$this->pageIndex,$this->pageSize);
if($request['is_export'] == '1'){
$header = ['序号','服务网点名称','联系人','联系方式','地区','添加时间','工程师人数'];
excelExport('服务网点列表',$header,$data);
}
$data !== false ? $this->render($data) : ResponseDirect(15000);
}
/**
* User: zhaoxin
* Date: 2019-09-20
* Time: 18:00
* description 新增
*/
public function save(){
$request = $this->selectParam([
'name' => '','contact_mobile'=> '','contact_name' => '','province','city','county',
'address','introduce','password'
]);
$this->check($request,'network.save');
$data = NetworkLogic::save($request);
$data !== false ? $this->render('新增成功') : ResponseDirect(15001);
}
/**
* User: zhaoxin
* Date: 2019-09-21
* Time: 11:51
* description 详情
* @param $id
*/
public function read($id){
$this->check(['uuid' => $id],'Base.uuid');
$data = NetworkLogic::read($id);
$data !== false ? $this->render($data) : ResponseDirect(15008);
}
/**
* User: zhaoxin
* Date: 2019-09-20
* Time: 18:23
* description
* @param $id
*/
public function update($id){
$request = $this->selectParam([
'name' => '','contact_mobile'=> '','contact_name' => '','province','city','county',
'address','introduce'
]);
$this->check($request,'network.update');
$data =ServiceNetwork::build()->updateInfo($request,$id);
$data !== false ? $this->render('编辑成功') : ResponseDirect(15003);
}
/**
* User: zhaoxin
* Date: 2019-09-21
* Time: 09:56
* description
* @param $id
*/
public function delete($id){
$this->check(['uuid' => $id],'Base.uuid');
$data = NetworkLogic::delete($id);
$data !== false ? $this->render('删除成功') : ResponseDirect(15004);
}
/**
* User: zhaoxin
* Date: 2019-09-21
* Time: 14:29
* description 审核
*/
public function checks(){
$request = $this->selectParam([
'keyword' => '','network_status' => '0'
]);
$this->check($request,'Search.search_network');
$data = NetworkLogic::checks($request,$this->pageIndex,$this->pageSize);
$data !== false ? $this->render($data) : ResponseDirect(15000);
}
/**
* User: zhaoxin
* Date: 2019-09-21
* Time: 11:39
* description 审核
*/
public function handle(){
$request = $this->selectParam([
'uuid','network_status'
]);
$this->check($request,'network.network_handle');
$data = NetworkLogic::handle($request);
$data !== false ? $this->render('审核成功') : ResponseDirect(15009);
}
/**
* User: zhaoxin
* Date: 2019-09-21
* Time: 15:17
* description 审核信息
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function info(){
$request = $this->selectParam([
'uuid'
]);
$this->check($request,'Base.uuid');
$data = NetworkLogic::info($request['uuid']);
$data !== false ? $this->render($data) : ResponseDirect(15008);
}
public function lists(){
$request = $this->selectParam([
'keyword' => '',
]);
$this->check($request,'Search.keyword');
$data = NetworkLogic::lists($request);
$data !== false ? $this->render($data) : ResponseDirect(15000);
}
}
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/23
* Time: 14:15
*/
namespace app\api\controller\v1\cms;
use app\api\controller\v1\cms\Base;
use app\api\logic\cms\NewsLogic;
class News extends Base
{
public $restMethodList = 'get|post|put|delete';
public function _initialize()
{
parent::_initialize();
//$this->hasPermission();
$this->validateToken();
}
/*
* 列表
*/
public function index()
{
$data = NewsLogic::index($this->pageIndex,$this->pageSize);
$data !== false ? $this->render($data): $this->returnmsg(16260);
}
/*
* 详情
*/
public function read($id)
{
$this->check(['uuid' => $id], 'News.uuid');
$data = NewsLogic::read($id);
$data !== false ? $this->render($data) : $this->returnmsg(16261);
}
//新增
public function save(){
$request = $this->selectParam(['title','img_src','content','profile']);
$this->check($request,'News.save');
$request['create_time'] = timeToDate();
$request['update_time'] = timeToDate();
$data = NewsLogic::save($request);
$data !== false ? $this->render("新增成功") : ResponseDirect(16262);
}
//更新
public function update($id){
$request = $this->selectParam(['uuid'=>$id,'title','img_src','content','profile']);
$this->check($request,'News.update');
$request['update_time'] = timeToDate();
$data = NewsLogic::update($id,$request);
$data !== false ? $this->render('更新成功') : ResponseDirect(16263);
}
//删除
public function delete($id){
$this->check(['uuid' => $id], 'News.uuid');
$data = NewsLogic::delete($id);
$data !== false ? $this->render('删除成功') : ResponseDirect(16264);
}
public function getList(){
$data = NewsLogic::getList();
$data !== false ? $this->render($data): $this->returnmsg(20001);
}
public function add(){
$request = $this->selectParam(['news_uuid']);
$this->check(['uuid'=>$request['news_uuid']],'News.uuid');
$request['uuid'] = uuid();
$request['create_time'] = timeToDate();
$data = NewsLogic::add($request);
$data !== false ? $this->render('新增成功'): $this->returnmsg(20003);
}
public function delete_news(){
$request = $this->selectParam(['uuid']);
$this->check(['uuid'=>$request['uuid']],'News.uuid');
$data = NewsLogic::delete_news($request);
$data !== false ? $this->render($data): $this->returnmsg(20005);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-05-06
* Time: 12:03
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\EngineerLogic;
use app\api\logic\cms\OrderLogic;
use app\api\model\LogisticsCompany;
class Order extends Base
{
public $restMethodList = 'get|post|put|delete';
public function _initialize()
{
parent::_initialize();
// $this->hasPermission();
$this->validateToken();
}
/**
* User: zhaoxin
* Date: 2019-09-23
* Time: 18:09
* description
*/
public function index(){
$request = $this->selectParam([
'keyword' => '','province','city','county','order_status' => '1',
'is_export','engineering_type' => '1'
]);
$this->check($request,'Search.order_cms');
$data = OrderLogic::index($request,$this->pageIndex,$this->pageSize);
if ($data === false) {
ResponseDirect(14016);
}
if($request['is_export'] == '1'){
$header = ['序号','订单编号','联系人','联系方式','地区','服务类型','提交时间','是否需要勘测'];
excelExport('订单列表',$header,$data);
}
$this->render($data);
}
/**
* User: zhaoxin
* Date: 2019-09-23
* Time: 18:20
* description
* @param $id
*/
public function read($id){
$this->check(['uuid' => $id], 'Base.uuid');
$data = OrderLogic::read($id);
if ($data === false) {
ResponseDirect(14018);
}
$this->render($data);
}
public function EngineerList(){
$request = $this->selectParam([
'keyword' => '','service_type' => '','is_authentication' => '','province' => '',
'city' => '','county' => '','user_type' => '1','is_export' => '','engineer_uuid' => [],
'is_page' => '1'
]);
$this->check($request,'Search.engineer_search');
$data = EngineerLogic::index($request, $this->pageIndex, $this->pageSize);
if($request['is_export'] == '1'){
$header = ['序号','姓名','联系方式','地区','工程师类型','所属服务网点','添加时间','是否认证'];
excelExport('工程师列表',$header,$data);
}
$data !== false ? $this->render($data) : ResponseDirect(13011);
}
/**
* User: zhaoxin
* Date: 2019-09-24
* Time: 14:53
* description 指派
*/
public function appoint(){
$request = $this->selectParam([
'order_uuid', 'appoint_uuid', 'appoint_type', 'captain_info', 'member_info' => []
]);
$this->check($request,'Engineering.order_appoint');
//指派给工程师或多个工程师
if ($request['appoint_type'] == '1') {
$this->check($request['captain_info'],'Engineering.order_member_info');
if (count($request['member_info']) >= 1) {
$ratio = $request['captain_info']['engineer_ratio'];
foreach ($request['member_info'] as $k => $v) {
$this->check($v,'Engineering.order_member_info');
$ratio = $ratio + $v['engineer_ratio'];
}
if ($ratio > 100) {
ResponseDirect(14060);
}
} else {
ResponseDirect(14062);
}
}
$data = OrderLogic::appoint($request);
if ($data === false) {
ResponseDirect(14018);
}
$this->render('指派成功');
}
/**
* User: zhaoxin
* Date: 2019-09-24
* Time: 14:58
* description 取消订单
*/
public function cancel(){
$request = $this->selectParam([
'uuid'
]);
$this->check($request, 'Base.uuid');
$data = \app\api\logic\web\OrderLogic::cancel($request['uuid']);
if ($data === false) {
ResponseDirect(14021);
}
$this->render('取消成功');
}
/**
* User: zhaoxin
* Date: 2019-09-25
* Time: 14:37
* description 确认指派
*/
public function confirmAppoint(){
$request = $this->selectParam([
'order_uuid', 'type', 'new_engineer_moneys', 'old_engineer_moneys', 'contract_img', 'contract_money'
]);
$this->check($request,'Engineering.order_confirm');
if ($request['type'] == '1') {
$this->check($request['new_engineer_moneys'], 'Engineering.new_engineer_money');
}
if ($request['type'] == '2') {
foreach ($request['old_engineer_moneys'] as $k => $v){
$this->check($v, 'Engineering.old_engineer_money');
}
}
$data = OrderLogic::confirmAppoint($request);
if ($data === false) {
ResponseDirect(14025);
}
$this->render('确认指派成功');
}
/**
* User: zhaoxin
* Date: 2019-09-25
* Time: 14:31
* description 上传支付凭证
*/
public function updateCertificate(){
$user = $this->validateToken();
$request = $this->selectParam([
'order_uuid','money'
]);
$this->check($request,'Engineering.order_cms_pay');
$data = \app\api\model\Order::updateCertificate($request);
if ($data === false) {
ResponseDirect(14029);
}
$this->render('上传成功');
}
/**
* User: zhaoxin
* Date: 2019-09-25
* Time: 15:04
* description 支付确认
*/
public function confirmPay(){
$request = $this->selectParam([
'order_uuid'
]);
$this->check($request,'Engineering.order_uuid');
$data = \app\api\model\Order::confirmPay($request['order_uuid'],'1');
if ($data === false) {
ResponseDirect(14025);
}
$this->render('确认支付成功');
}
/**
* User: zhaoxin
* Date: 2019-10-11
* Time: 16:42
* description
*/
public function nodeDetails(){
$request = $this->selectParam([
'uuid','type' => '1'
]);
$this->check(['uuid' => $request['uuid']], 'Base.uuid');
$data = \app\api\logic\app\OrderLogic::nodeDetails($request['uuid'],$request['type']);
if ($data === false) {
ResponseDirect(14031);
}
$this->render($data);
}
/**
* User: zhaoxin
* Date: 2019-10-19
* Time: 10:48
* description 新增订单
*/
public function save(){
$request = $this->selectParam([
'user_uuid','type','engineering_uuid','describe','contact_name','contact_mobile',
'province','city','county','address','excel_list' => []
]);
$this->check($request, 'Engineering.order_cms_save');
//验证excel
foreach ($request['excel_list'] as $k => $v) {
$this->check($v,'Engineering.order_excel');
}
$user = ['uuid' => $request['user_uuid']];
unset($request['user_uuid']);
$data = \app\api\logic\web\OrderLogic::save($request,$user);
if ($data === false) {
ResponseDirect(14013);
}
$this->render('提交成功');
}
/**
* User: zhaoxin
* Date: 2019-09-25
* Time: 15:04
* description 验收确认
*/
public function confirmCheck(){
$request = $this->selectParam([
'order_uuid'
]);
$this->check($request,'Engineering.order_uuid');
$data = \app\api\model\Order::confirmCheck($request['order_uuid'],'1');
if ($data === false) {
ResponseDirect(14025);
}
$this->render('确认支付成功');
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-09-27
* Time: 18:07
*/
namespace app\api\controller\v1\cms;
use app\api\model\Target as TargetModel;
class Target extends Base
{
public $restMethodList = 'get|post|put|delete';
public function _initialize()
{
parent::_initialize();
// $this->hasPermission();
$this->validateToken();
}
public function index(){
$request = $this->selectParam([
'service_uuid','keyword','target_uuid','start_time','end_time'
]);
$this->check($request,'Search.target');
$data = TargetModel::build()->index($request,$this->pageIndex,$this->pageSize);
if ($data === false) {
ResponseDirect(17000);
}
$this->render($data);
}
public function save(){
$request = $this->selectParam([
'service_uuid','target_uuid','title','start_time','end_time','content'
]);
$this->check($request,'engineering.target_save');
$data = TargetModel::build()->saveInfo($request);
if ($data === false) {
ResponseDirect(17001);
}
$this->render('新增成功');
}
public function update($id){
$request = $this->selectParam([
'service_uuid','target_uuid','title','start_time','end_time','content'
]);
$this->check($request,'engineering.target_save');
$data = TargetModel::build()->updateInfo($request,$id);
if ($data === false) {
ResponseDirect(17002);
}
$this->render('编辑成功');
}
public function delete($id){
$data = TargetModel::build()->where(['uuid' => $id])->delete();
if ($data === false) {
ResponseDirect(17003);
}
$this->render('删除成功');
}
public function read($id){
$data = TargetModel::build()->where(['uuid' => $id])->find();
if ($data === false) {
ResponseDirect(17003);
}
$this->render($data);
}
public function achievements(){
$request = $this->selectParam([
'service_uuid','target_uuid','keyword'
]);
$this->check($request,'engineering.achievements');
$data = TargetModel::build()->achievements($request,$this->pageIndex,$this->pageSize);
if ($data === false) {
ResponseDirect(17000);
}
$this->render($data);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/23
* Time: 14:15
*/
namespace app\api\controller\v1\cms;
use app\api\model\Jpush;
use app\api\model\Message;
use app\api\model\MessageUser;
use app\api\model\User;
use think\Db;
use think\Exception;
class Timer extends Base
{
public $restMethodList = 'get|post';
//定时发布消息
public function push_message(){
$data = Message::build()
->where(['status' => '0','push_time' => ['<=',timeToDate()],'is_delete'=>0])
->select();
if(empty($data)){
ResponseDirect(80000);//无定时任务需要执行
}
$data = collection($data)->toArray();
$uuid = array_column($data,'uuid');
if(count($uuid) < 1){
$this->render(false);
}
$time = timeToDate();
try{
Db::startTrans();
foreach ($data as $v){
if($v['type'] == 1){ //普通用户
$where['is_merchant'] = 0;
}
if($v['type'] == 2){ //认证用户
$where['is_merchant'] = ['in',[1,2]];
}
$where['is_banned'] = 0;
$user_uuid = User::build()->where($where)->column('uuid');
if(!empty($user_uuid)){
$message['title'] =$v['title'] ;
$message['content'] = $v['content'];
$message['create_time'] = $time;
$message['message_uuid'] = $v['uuid'];
$message['message_type'] = 0;
$jpush['alert'] = $v['content'];
$jpush['create_time'] = $time;
foreach ($user_uuid as $u_v){
$message['uuid'] = uuid();
$message['user_uuid'] = $u_v;
$jpush['uuid'] = uuid();
$jpush['user_uuid'] = $u_v;
$result[] = $message;
$jpush_result[] = $jpush;
//极光推送
jpush($v['content'],$u_v,'','no',0);
}
}
}
Message::build()->where(['uuid'=>['in',$uuid]])->update(['status'=>1]);
Jpush::build()->insertAll($jpush_result);
MessageUser::build()->insertAll($result);
// exit;
Db::commit();
}catch (Exception $e){
Db::rollback();
logFile($uuid, 'message fail', 'message');
ResponseDirect(80001);//定时任务执行错误
}
$this->render(true);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/23
* Time: 14:15
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\UserLogic;
class User extends Base
{
public $restMethodList = 'get|post|delete|put';
public function _initialize()
{
parent::_initialize();
//$this->hasPermission();
$this->validateToken();
}
/*
* 用户列表
*/
public function index()
{
$request = $this->selectParam(['keyword','type','is_export'=>0]);
//$this->check($request, 'User.type');
$data = UserLogic::index($request,$this->pageIndex,$this->pageSize);
if ($request['is_export']==1) {
$name='用户列表';
$header=['姓名','联系方式','地址','注册时间'];
excelExport($name,$header,$data);
exit;
}
$message = $request['type']==1 ? 12041 : 12042;
$data !== false ? $this->render($data) : ResponseDirect($message);
}
/*
* 用户详情
*/
public function read($id)
{
$request = $this->selectParam(['type','uuid'=>$id]);
$this->check($request, 'User.web_detail');
$data = UserLogic::read($request);
$message = $request['type']==1 ? 12043 : 12044;
$data !== false ? $this->render($data) : ResponseDirect($message);
}
/*
* 新增用户
*/
public function save()
{
$request = $this->selectParam(['name','mobile','email','province','city','county','detail','company_name','company_contact','company_mobile','type']);
$this->check($request, 'User.web_save');
$request['uuid'] = uuid();
$request['password'] = md5(md5('123456'));
if($request['type']==2){
$request['account_grade'] = 1;
}
$request['create_time'] = timeToDate();
$request['update_time'] = timeToDate();
$data = UserLogic::save($request);
$message = $request['type']==1 ? 12045 : 12046;
$data !== false ? $this->render('新增成功') : ResponseDirect($message);
}
/*
* 是否禁用
*/
public function update($id)
{
$request = $this->selectParam(['is_banned','uuid'=>$id]);
$this->check($request,['is_banned'=>'require|in:0,1','uuid'=>'require|length:32']);
$data = UserLogic::update($id,$request['is_banned']);
$message = $request['is_banned']==1? "已禁用":"已解禁";
$send = $request['is_banned']==1? 12047:12048;
$data !== false ? $this->render($message) : ResponseDirect($send);
}
public function lists(){
$request = $this->selectParam(['keyword','user_type' => '1']);
$this->check($request, 'Search.user_lists');
$data = UserLogic::lists($request);
$data !== false ? $this->render($data) : ResponseDirect(12041);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/23
* Time: 14:15
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\UserFeedBackLogic;
use app\api\controller\v1\cms\Base;
class UserFeedBack extends Base
{
public $restMethodList = 'get|post|delete|put';
public function _initialize()
{
parent::_initialize();
//$this->hasPermission();
}
/*
* 查看意见反馈
*/
public function read($id)
{
$this->validateToken();
$this->check(['uuid'=>$id], 'UserFeedBack.uuid');
$data = UserFeedBackLogic::read($id);
$data !== false ? $this->render($data) : $this->returnmsg(200082);
}
/*
* 修改阅读状态
*/
public function update($id)
{
$this->validateToken();
$data['uuid'] = $id;
$data['update_time'] = timeToDate();
$this->check($data, 'UserFeedBack.uuid');
$bool = UserFeedBackLogic::update($data);
$bool !== false ? $this->render(200): $this->returnmsg(403);
}
/*
* 删除意见反馈
*/
public function delete($id)
{
$this->validateToken();
$this->check(['uuid' => $id], 'UserFeedBack.uuid');
$bool = UserFeedBackLogic::delete($id);
$bool !== false ? $this->render('删除成功'): $this->returnmsg(200085);
}
/*
* 意见反馈搜索
*/
public function index()
{
$this->validateToken();
$requestData = $this->selectParam(['keyword']);
$data = UserFeedBackLogic::index($requestData,$this->pageIndex, $this->pageSize);
$data !== false ? $this->render($data) : $this->returnmsg(200081);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: xiezhixian
* Date: 2019/3/14
* Time: 下午4:01
*/
namespace app\api\controller\v1\cms;
use app\api\logic\cms\WithdrawalLogic;
class Withdrawal extends Base
{
public $restMethodList = 'get|post|put';
public function _initialize()
{
parent::_initialize();
$this->validateToken();
}
/**
* @author: star
* @time: 2019年9月
* description 提现列表
*/
public function index(){
$request = $this->selectParam(['status'=>'']);
$result = WithdrawalLogic::index($request,$this->pageIndex,$this->pageSize);
$result != false ? $this->render($result) :ResponseDirect(18003);
}
/**
* @author: star
* @time: 2019年9月
* description 提现详情
*/
public function read($id){
$this->check(['uuid'=>$id],"ServiceWithdrawal.uuid");
$result = WithdrawalLogic::read($id);
$result != false ? $this->render($result) : ResponseDirect(18004);
}
//提现审核
public function update($id){
$request = $this->selectParam(['status','reason']);
$request['uuid'] = $id;
$this->check($request,"ServiceWithdrawal.update");
$result = WithdrawalLogic::cash_audit($request);
$result != false ? $this->render("操作成功") : ResponseDirect(18005);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-04-11
* Time: 17:35
*/
namespace app\api\controller\v1\network;
use app\api\logic\network\NetworkLogic;
use think\Session;
class Admin extends Base
{
public $restMethodList = 'get|post|put|delete';
public function _initialize()
{
parent::_initialize();
}
/**
* User: zhaoxin
* Date: 2019-09-21
* Time: 10:21
* description 登陆
*/
public function login()
{
$requestData = $this->selectParam(['account', 'password']);
$this->check($requestData, 'admin.login');
$data = NetworkLogic::login($requestData['account'], $requestData['password']);
if ($data) {
$this->render($data,200);
} else {
ResponseDirect(15007);//账号密码错误
}
}
/**
* User: zhaoxin
* Date: 2019-09-21
* Time: 10:22
* description
*/
public function save(){
// $this->validateToken();
$requestData = $this->selectParam([
'account' => '',
'name' => '',
'mobile' => '',
'password' => '',
'group_uuid' => ''
]);
$this->check($requestData, 'Admin.cms_save');
$bool = SellerLogic::save($requestData);
$bool !== false ? $this->render(200) : $this->returnmsg(403);
}
/**
* User: zhaoxin
* Date: 2019-09-21
* Time: 10:22
* description 查看权限
*/
public function menuInfo(){
$requestData = $this->selectParam([
'uuid' => '',
]);
$this->check($requestData, 'Base.uuid');
$list = SellerLogic::menuInfo($requestData['uuid']);
if($list){
$this->render($list);
}else{
ResponseDirect('查看管理员权限失败',403);
}
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-04-11
* Time: 17:37
*/
namespace app\api\controller\v1\network;
use app\api\logic\network\GroupLogic;
use app\api\controller\Api;
use app\api\model\ServiceNetworkToken;
use think\Request;
use think\Hook;
use think\Session;
class Base extends Api
{
public function __construct(Request $request = null)
{
// Hook::add('response_end', 'app\common\behavior\sellerLog', true);
parent::__construct($request);
}
protected function validateToken() {
$token = getToken();
$user_info = ServiceNetworkToken::validateToken($token);
if (!$user_info) {
self::returnmsg(401, [], [], "", "AUTH ERROR", "鉴权失败");
}
Session::set('network_info', $user_info);
// //记录用户访问记录
// $count = SellerActive::build()->where(['seller_uuid' => $user_info['uuid']])->whereTime('create_time','today')->count();
// //今天第一次活跃
// if($count < 1){
// SellerActive::build()->insert([
// 'uuid' => uuid(),
// 'create_time' => timeToDate(),
// 'seller_uuid' => $user_info['uuid']
// ]);
// }
return $user_info;
}
protected function hasPermission() {
$controller = $this->request->controller();
$controller_path = explode('.', $controller);
$controller = strtolower(end($controller_path));
$action = strtolower($this->request->action());
$seller_info = Session::get('seller_info');
$bool = GroupLogic::hasPermission($seller_info['seller_admin_uuid'], $controller, $action);
if (!$bool) {
self::returnmsg(401, [], [], "", "AUTH ERROR", "您没有权限,请联系超级管理员");
}
}
/**
* @author: ChiaHsiang
* @time: 2018/8/10
* @description: 从前端获取文件,存入public/excel目录下,返回文件全路径
* @return string
*/
public function getFile() {
if (empty($_FILES['file'])) {
$this->render(403);
}
$file = request()->file('file');
$info = $file->rule('uniqid')->move(ROOT_PATH.'public' . DS . 'excel');
if (!$info) {
$this->render(403);
}
$file = $info->getFilename();
$save_path = ROOT_PATH . 'public' . DS . 'excel' . DS;
$file_name = $save_path . $file;
return $file_name;
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-09-20
* Time: 14:40
*/
namespace app\api\controller\v1\network;
use app\api\logic\network\EngineerLogic;
use think\Session;
class Engineer extends Base
{
public $restMethodList = 'get|put|post|delete';
public function _initialize()
{
parent::_initialize();
$this->validateToken();
}
/**
* User: zhaoxin
* Date: 2019-09-20
* Time: 15:07
* description 工程师列表
*/
public function index(){
$request = $this->selectParam([
'keyword' => '','service_type' => '','is_authentication' => '','province' => '',
'city' => '','county' => '','user_type' => '','is_export'
]);
$this->check($request,'Search.engineer_search');
$EngineerLogic = new EngineerLogic();
$data = $EngineerLogic->index($request,$this->pageIndex,$this->pageSize);
if($request['is_export'] == '1'){
$header = ['序号','姓名','联系方式','地区','工程师类型','添加时间','是否认证'];
excelExport('工程师列表',$header,$data);
}
$data !== false ? $this->render($data) : ResponseDirect(13011);
}
/**
* User: zhaoxin
* Date: 2019-09-20
* Time: 15:13
* description 工程师详情
* @param $id
*/
public function read($id){
$this->check(['uuid' => $id],'Base.uuid');
$EngineerLogic = new EngineerLogic();
$data = $EngineerLogic->read($id);
$data !== false ? $this->render($data) : ResponseDirect(13012);
}
/**
* User: zhaoxin
* Date: 2019-09-20
* Time: 15:16
* description 删除
* @param $id
*/
public function delete($id){
$this->check(['uuid' => $id],'Base.uuid');
$data = EngineerLogic::delete($id);
$data !== false ? $this->render('删除成功') : ResponseDirect(13013);
}
/**
* User: zhaoxin
* Date: 2019-09-20
* Time: 15:20
* description 新增
*/
public function save(){
$user = $this->validateToken();
$requestData = $this->selectParam([
'mobile', 'password',
'service_type','name','province','city','county','service_day' => [],'service_time' => [],'service_skill' => [],
'id_img_one','id_img_two','other_img' => [],'number' => ''
]);
$this->check($requestData, 'Engineer.cms_register');
$data = \app\api\model\Engineer::build()->register($requestData,'2',$user);
if ($data){
$this->render('新增成功',200);
}else{
ResponseDirect(13001);
}
}
/**
* User: zhaoxin
* Date: 2019-09-26
* Time: 17:47
* description 认证
*/
public function authentication(){
$requestData = $this->selectParam(['engineer_uuid','is_authentication']);
$this->check($requestData, 'Engineer.authentication');
$data = \app\api\model\Engineer::build()->authentication($requestData);
if ($data){
$this->render('操作成功',200);
}else{
ResponseDirect(13017);
}
}
/**
* User: zhaoxin
* Date: 2019-09-29
* Time: 11:13
* description 导入
*/
public function import(){
$file_name = $this->getFile();
$info = Session::get('network_info');
$service_uuid = $info['uuid'];
$bool = \app\api\model\Engineer::import('Xlsx',$file_name,$service_uuid,'2');
if($bool['status'] == '1'){
$this->render(['message' => $bool['message']]);
}
elseif($bool['status'] == '2'){
$this->render(['message' => $bool['message'],'info'=>$bool['info']],403);
}
else{
ResponseDirect(13021);
}
}
/**
* User: zhaoxin
* Date: 2019-09-29
* Time: 11:16
* description
*/
public function downTemplate()
{
$name = '用户导入模版下载';
$header = [
'姓名','联系方式','省','市','区','工程师类型',
];
$data[] = [
'某某某','13302516724','广东省','深圳市','龙岗区','工程师'
];
excelExport($name,$header,$data);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-04-11
* Time: 10:05
*/
namespace app\api\controller\v1\network;
use app\api\logic\cms\FinanceLogic;
use app\api\model\ServiceNetwork;
use think\Session;
class Finance extends Base
{
/**
* 允许访问的方式列表,资源数组如果没有对应的方式列表,请不要把该方法写上,如user这个资源,客户端没有delete操作
*/
public $restMethodList = 'get|post|put';
public function _initialize()
{
parent::_initialize();
//$this->hasPermission();
$this->validateToken();
}
public function index(){
$requestData = $this->selectParam([
'engineering_type','start_time','end_time','is_export'
]);
$this->check($requestData,'Search.finances');
$info = Session::get('network_info');
$requestData['service_uuid'] = $info['uuid'];
$data = \app\api\model\Order::finances($requestData,$this->pageIndex,$this->pageSize,'2');
if ($requestData['is_export']==1) {
$name='财务订单信息';
$header=['订单编号','联系人','联系方式','省','市','服务类型','提交时间','工程类型'];
excelExport($name,$header,$data);
}
$data !== false ? $this->render($data): ResponseDirect(16371);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-04-13
* Time: 11:02
*/
namespace app\api\controller\v1\network;
use app\api\logic\network\GroupLogic;
use app\api\model\Operation;
use app\common\tools\wechatUtil;
class Groups extends Base
{
public $restMethodList = 'get|post|put|delete';
public function _initialize()
{
parent::_initialize();
}
/**
* @author: Airon
* @time: 2019年4月
* description
* @throws \think\exception\DbException
*/
public function adminList() {
// $this->validateToken();
$this->hasPermission();
$requestData = $this->selectParam(['keyword']);
$this->check($requestData, 'Base.keyword');
$GroupLogic = new GroupLogic();
$data = $GroupLogic->index($requestData,$this->pageIndex, $this->pageSize);
$data !== false ? $this->render($data) : $this->returnmsg(403);
}
/**
* @author: Airon
* @time: 2019年4月
* description 获取组相关权限
* @param $id
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function read($id) {
// $this->validateToken();
$this->check(['uuid' => $id], 'Base.uuid');
$data = GroupLogic::read($id);
$data !== false ? $this->render($data) : $this->returnmsg(403);
}
/*
* 新增
*/
public function save(){
// $this->validateToken();
$requestData = $this->selectParam([
'uuid' => '',
'menu_uuid' => []
]);
$this->check($requestData, 'Groups.menu_save');
$bool = GroupLogic::save($requestData);
$bool !== false ? $this->render('分配权限成功') : $this->returnmsg(403);
}
/*
* 添加商家后台管理员
*/
public function addSellerAdmin(){
// $this->validateToken();
$requestData = $this->selectParam([
'account' => '',
'password' => '',
'name' => '',
'mobile' => ''
]);
$this->check($requestData, 'Groups.seller_save');
$GroupLogic = new GroupLogic();
$bool = $GroupLogic->addSellerAdmin($requestData);
if($bool){
$this->render('添加成功');
}else{
ResponseDirect('添加管理员失败',403);
}
}
/*
* 编辑
*/
public function update(){
// $this->validateToken();
$requestData = $this->selectParam([
'uuid' => '',
'account' => '',
'password' => '',
'name' => '',
'mobile' => ''
]);
$this->check($requestData, 'Groups.seller_update');
$bool = GroupLogic::update($requestData);
$bool !== false ? $this->render('编辑成功') : $this->returnmsg(403);
}
/*
* 查看当前管理员的权限
*/
public function menuInfo(){
// $this->validateToken();
$requestData = $this->selectParam([
'uuid' => '',
]);
$this->check($requestData, 'Base.uuid');
$list = GroupLogic::menuInfo($requestData['uuid']);
if($list){
$this->render($list);
}else{
ResponseDirect('查看管理员权限失败',403);
}
}
/*
* 删除
*/
public function delete($id){
// $this->validateToken();
$this->check([
'uuid' => $id,
], 'Base.uuid');
$bool = GroupLogic::delete($id);
$bool !== false ? $this->render('删除成功') : $this->returnmsg(403);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-09-21
* Time: 10:37
*/
namespace app\api\controller\v1\network;
use app\api\logic\network\NetworkLogic;
use app\api\model\ServiceNetwork;
class Info extends Base
{
public $restMethodList = 'get|post|put|delete';
public function _initialize()
{
parent::_initialize();
$this->validateToken();
}
/**
* User: zhaoxin
* Date: 2019-09-21
* Time: 11:07
* description 基本信息
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function index(){
$logic = new NetworkLogic();
$data = $logic->info();
if($data == false){
ResponseDirect(15008);
}
$this->render($data);
}
/**
* User: zhaoxin
* Date: 2019-09-21
* Time: 15:07
* description 查看审核信息
* @param $id
*/
public function read($id){
$this->check(['uuid' => $id],'Base.uuid');
$data = NetworkLogic::read($id);
$data !== false ? $this->render($data) : ResponseDirect(15008);
}
/**
* User: zhaoxin
* Date: 2019-09-21
* Time: 11:08
* description 编辑
* @param $id
*/
public function update($id){
$request = $this->selectParam([
'name' => '','contact_mobile'=> '','contact_name' => '','province','city','county',
'address','introduce'
]);
$this->check($request,'network.update');
$data =ServiceNetwork::build()->updateInfo2($request,$id);
$data !== false ? $this->render('编辑成功') : ResponseDirect(15003);
}
}
\ No newline at end of file
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
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