Commit 9e25e2f4 by 庄钊鑫

用户授权记录

parent 1e108f91
<?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: 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
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 User extends Base
{
/**
* 允许访问的方式列表,资源数组如果没有对应的方式列表,请不要把该方法写上,如user这个资源,客户端没有delete操作
*/
public $restMethodList = 'get|post|put|';
public function login()
{
$requestData = $this->selectParam(['openid','avatar','unionid'=>'','wechat_name']);
$this->check($requestData, [
'openid'=>'require',
'avatar'=>"require",
'wechat_name'=>"require",
]);
$result = \app\api\model\User::build()->login($requestData);
if ($result) {
$this->render($result);
} else {
ResponseDirect(12003);
}
}
}
\ 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
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-04-12
* Time: 18:14
*/
namespace app\api\controller\v1\network;
use app\api\logic\network\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) : $this->returnmsg(403);
}
public function save()
{
$requestData = $this->selectParam([
'sort' => 0,
'name',
'url' => '',
'classes' => '',
'parent_uuid' => '0',
'authority_url' => '',
]);
$requestData['parent_uuid'] = empty($requestData['parent_uuid'])?0:$requestData['parent_uuid'];
$this->check($requestData, 'MenuBars.seller_save');
$bool = MenuBarLogic::save($requestData);
$bool !== false ? $this->render(200) : $this->returnmsg(403);
}
public function update($id)
{
$requestData = $this->selectParam([
'uuid' => $id,
'sort' => 0,
'name',
'url' => '',
'classes' => '',
'parent_uuid' => '0',
'authority_url' => ''
]);
$requestData['parent_uuid'] = empty($requestData['parent_uuid'])?0:$requestData['parent_uuid'];
$this->check($requestData, 'MenuBars.selller_update');
$bool = MenuBarLogic::update($requestData);
$bool !== false ? $this->render(200) : $this->returnmsg(403);
}
public function delete($id)
{
$this->check(['uuid' => $id], 'Base.uuid');
$bool = MenuBarLogic::delete($id);
$bool !== false ? $this->render(200) : $this->returnmsg(403);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-09-24
* Time: 15:03
*/
namespace app\api\controller\v1\network;
use app\api\logic\network\OrderLogic;
class Order extends Base
{
public $restMethodList = 'get|post|put|delete';
public function _initialize()
{
parent::_initialize();
$this->validateToken();
}
public function index(){
$request = $this->selectParam([
'keyword' => '','province','city','county','order_status' => '1',
'is_export','engineering_type' => '1'
]);
$this->check($request,'Search.order_cms');
$order = new OrderLogic();
$data = $order->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');
$order = new OrderLogic();
$data = $order->read($id);
if ($data === false) {
ResponseDirect(14018);
}
$this->render($data);
}
/**
* User: zhaoxin
* Date: 2019-09-24
* Time: 15:31
* description 指派
*/
public function appoint(){
$request = $this->selectParam([
'order_uuid','appoint_uuid'
]);
$this->check($request,'Engineering.network_order_appoint');
$order = new OrderLogic();
$data = $order->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'
]);
$this->check($request,'Engineering.order_uuid');
$data = OrderLogic::confirmAppoint($request['order_uuid']);
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'],'2');
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/23
* Time: 11:07 上午
* description
* @throws \think\Exception
*/
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('提交成功');
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-09-27
* Time: 18:21
*/
namespace app\api\controller\v1\network;
use app\api\model\Target as TargetModel;
use think\Session;
class Target extends Base
{
public $restMethodList = 'get|post|put|delete';
public function _initialize()
{
parent::_initialize();
$this->validateToken();
}
public function index(){
$request = $this->selectParam([
'keyword','target_uuid','start_time','end_time'
]);
$network = Session::get('network_info');
$request['service_uuid'] = $network['uuid'];
$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([
'target_uuid','title','start_time','end_time','content'
]);
$network = Session::get('network_info');
$request['service_uuid'] = $network['uuid'];
$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([
'target_uuid','title','start_time','end_time','content'
]);
$network = Session::get('network_info');
$request['service_uuid'] = $network['uuid'];
$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([
'target_uuid','keyword'
]);
$network = Session::get('network_info');
$request['service_uuid'] = $network['uuid'];
$this->check($request,'engineering.achievements');
$data = TargetModel::build()->achievements($request,$this->pageIndex,$this->pageSize);
if ($data === false) {
ResponseDirect(17000);
}
$this->render($data);
}
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: xiezhixian
* Date: 2019/3/14
* Time: 下午4:01
*/
namespace app\api\controller\v1\network;
use app\api\logic\network\WithdrawalLogic;
class Withdrawal extends Base
{
public $restMethodList = 'get|post|put';
public function _initialize()
{
parent::_initialize();
//$this->validateToken();
}
/**
* @author: jkl
* @time: 2019年5月
* description 用户提现列表
*/
public function index(){
$user = $this->validateToken();
$request = $this->selectParam(['start_time','end_time','status'=>'','is_export'=>0]);
$result = WithdrawalLogic::index($user,$request,$this->pageIndex,$this->pageSize);
if ($request['is_export']==1) {
$name='网点提现信息';
$header=['服务网点','联系人','联系方式','省','市','提现时间','提现状态','提现金额'];
excelExport($name,$header,$result);
}
$result != false ? $this->render($result) :ResponseDirect(18003);
}
/**
* @author: jkl
* @time: 2019年5月
* description 用户提现详情
*/
public function read($id){
$user = $this->validateToken();
$this->check(['uuid'=>$id],"ServiceWithdrawal.uuid");
$result = WithdrawalLogic::read($id);
$result != false ? $this->render($result) : ResponseDirect(18004);
}
//发起提现
public function submit(){
$user = $this->validateToken();
$request = $this->selectParam(['money','account','card','payee','mobile','password']);
$this->check($request,"ServiceWithdrawal.submit");
$request['uuid'] = uuid();
$request['service_uuid'] = $user['uuid'];
$request['create_time'] = timeToDate();
$result = WithdrawalLogic::submit($user,$request);
$result != false ? $this->render("操作成功") : ResponseDirect(18000);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: xiezhixian
* Date: 2018/7/17
* Time: 上午11:04
*/
namespace app\api\controller\v1\web;
use app\api\controller\Api;
use app\api\model\UserToken;
use app\api\logic\web\UserLogic;
class Base extends Api
{
protected function validateToken(){
$token = getToken();
$bool = UserToken::build()->validateToken($token);
if (!$bool) {
self::returnmsg(401, [], [], "", "AUTH ERROR", "鉴权失败");
}
return $bool;
}
/**
* @author: zhaoxin
* @time: 2019年3月
* description 判断当前短信的类型
*/
protected function validateSmsType($requestData,$type = 'user'){
$method = 'check'.ucfirst($type);
//注册
if($requestData['sms_type'] == 'pass') {
$bool = UserLogic::$method($requestData['mobile']);
if(!empty($bool)){
self::returnmsg(403, [], [],"", "", "该手机号已注册");
}
}
//忘记密码
elseif(in_array($requestData['sms_type'],['getback','reset'])) {
$bool = UserLogic::$method($requestData['mobile']);
if(empty($bool)){
self::returnmsg(403, [], [],"", "", "该手机号未注册");
}
}
//修改密码
elseif($requestData['sms_type'] == 'bind'){
return true;
}
//授权
elseif($requestData['sms_type'] == 'oauth'){
return true;
}else{
self::returnmsg(403, [], [],"", "", "短信类型错误");
}
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/25
* Time: 19:22
*/
namespace app\api\controller\v1\web;
use app\api\logic\web\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'
], [
'key' => '资源类型 ',
]);
$data = ConfigLogic::read($requestData['key']);
$data !== false ? $this->render($data) : $this->returnmsg(16052);
}
public function update($id) {
$requestData = $this->selectParam([
'key' => $id,
'value' => '',
]);
$this->check($requestData, [
'key' => 'require|in:register_agreement',
'value' => 'require',
], [
'key' => '资源类型 ',
'value' => '资源值 ',
]);
$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/25
* Time: 19:22
*/
namespace app\api\controller\v1\web;
use app\api\logic\cms\ExampleLogic;
use app\api\logic\cms\CooperatorLogic;
use app\api\logic\cms\BannerLogic;
use app\api\logic\cms\EngineeringLogic;
use app\api\logic\cms\AdvantageLogic;
use app\api\logic\cms\HelpCenterLogic;
use app\api\logic\cms\HelpCenterTypeLogic;
use app\api\logic\cms\AboutLogic;
use app\api\logic\cms\NewsLogic;
use think\Collection;
class Index extends Base
{
public $restMethodList = 'get|put|post';
public function _initialize()
{
parent::_initialize();
//$this->hasPermission();
//$this->validateToken();
}
public function cooperator() {
$data = CooperatorLogic::index($this->pageIndex,$this->pageSize);
$data !== false ? $this->render($data) : $this->returnmsg(16110);
}
public function banner() {
$data = BannerLogic::index($this->pageIndex,$this->pageSize);
$data !== false ? $this->render($data) : $this->returnmsg(200041);
}
public function example() {
$data = ExampleLogic::index($this->pageIndex,$this->pageSize);
$data !== false ? $this->render($data) : $this->returnmsg(16081);
}
public function example_detail() {
$request = $this->selectParam(['uuid']);
$data = ExampleLogic::read($request['uuid']);
$data !== false ? $this->render($data) : $this->returnmsg(16082);
}
public function project() {
$request = $this->selectParam(['engineering_type']);
$data = EngineeringLogic::index($request,$this->pageIndex,$this->pageSize);
$data !== false ? $this->render($data) : $this->returnmsg(14003);
}
public function advantage() {
$data = AdvantageLogic::index($this->pageIndex,$this->pageSize);
$data !== false ? $this->render($data) : $this->returnmsg(16160);
}
public function help() {
$requestData = $this->selectParam(['type']);
$data = HelpCenterLogic::index($requestData,$this->pageIndex,$this->pageSize);
$this->render($data);
}
public function type_lists() {
$data = HelpCenterTypeLogic::index($condition=1);
$this->render($data);
}
public function help_detail() {
$requestData = $this->selectParam(['uuid']);
$this->check($requestData, 'HelpCenter.uuid');
$data = HelpCenterLogic::read($requestData['uuid']);
$this->render($data);
}
/**
* 关于我们
*/
public function about() {
$data = AboutLogic::index($this->pageIndex,$this->pageSize);
$data !== false ? $this->render($data) : $this->returnmsg(16180);
}
/**
* 关于我们详情
*/
public function about_detail() {
$requestData = $this->selectParam(['uuid']);
$data = AboutLogic::read($requestData['uuid']);
$data !== false ? $this->render($data) : $this->returnmsg(16181);
}
/**
* 企业新闻
*/
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 map() {
$data = \app\api\logic\cms\NetworkLogic::map();
$data !== false ? $this->render($data) : $this->returnmsg(15012);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/23
* Time: 14:15
*/
namespace app\api\controller\v1\web;
use app\api\logic\web\MessageLogic;
class Message extends Base
{
public $restMethodList = 'get|post|delete|put';
public function _initialize()
{
parent::_initialize();
// $this->hasPermission();
//$this->validateToken();
}
/*
* 列表
*/
public function index()
{
$user = $this->validateToken();
$request = $this->selectParam(['uuid'=>[]]);
$data = MessageLogic::index($user,$request,$this->pageIndex,$this->pageSize);
if(!empty($request['uuid'])){
$data !== false ? $this->render('标记成功') : ResponseDirect(16315);
}
$data !== false ? $this->render($data) : ResponseDirect(16310);
}
/*
* 详情
*/
public function read($id)
{
$user = $this->validateToken();
$this->check(['uuid' => $id], 'Message.uuid');
$data = MessageLogic::read($user,$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']);
$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-23
* Time: 11:02
*/
namespace app\api\controller\v1\web;
use think\Collection;
use app\api\logic\web\OrderLogic;
class Order extends Base
{
public $restMethodList = 'get|put|post|delete';
public function _initialize()
{
parent::_initialize();
}
/**
* User: zhaoxin
* Date: 2019-09-24
* Time: 17:09
* description
*/
public function engineerings(){
$request = $this->selectParam(['type']);
$this->check($request, 'Engineering.type');
$data = OrderLogic::engineerings($request);
if ($data === false) {
ResponseDirect(14003);
}
$this->render($data);
}
/**
* User: zhaoxin
* Date: 2019-09-24
* Time: 17:09
* description
*/
public function save(){
$user = $this->validateToken();
$request = $this->selectParam([
'type','engineering_uuid','describe','contact_name','contact_mobile',
'province','city','county','address','excel_list' => []
]);
$this->check($request, 'Engineering.order_save');
//验证excel
foreach ($request['excel_list'] as $k => $v) {
$this->check($v,'Engineering.order_excel');
}
$data = OrderLogic::save($request,$user);
if ($data === false) {
ResponseDirect(14013);
}
$this->render('提交成功');
}
/**
* User: zhaoxin
* Date: 2019-09-23
* Time: 16:41
* description
*/
public function index(){
$user = $this->validateToken();
$request = $this->selectParam([
'keyword','start_time','end_time','order_status' => '1','engineering_type' => '1'
]);
$this->check($request, 'search.order');
$data = OrderLogic::index($request,$user,$this->pageIndex,$this->pageSize);
if ($data === false) {
ResponseDirect(14016);
}
$this->render($data);
}
/**
* User: zhaoxin
* Date: 2019-09-24
* Time: 17:30
* description
* @param $id
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function read($id){
$user = $this->validateToken();
$this->check(['uuid' => $id], 'Base.uuid');
$data = OrderLogic::read($id);
if ($data === false) {
ResponseDirect(14018);
}
$this->render($data);
}
public function update($id){
$user = $this->validateToken();
$this->check(['uuid' => $id], 'Base.uuid');
$request = $this->selectParam([
'contact_name','contact_mobile','province','city','county','address',
]);
$this->check($request, 'Engineering.order_update');
$data = OrderLogic::update($request,$id);
if ($data === false) {
ResponseDirect(14019);
}
$this->render('编辑成功');
}
/**
* User: zhaoxin
* Date: 2019-09-23
* Time: 17:12
* description 取消订单
*/
public function cancel(){
$user = $this->validateToken();
$request = $this->selectParam([
'uuid'
]);
$this->check($request, 'Base.uuid');
$data = OrderLogic::cancel($request['uuid']);
if ($data === false) {
ResponseDirect(14021);
}
$this->render('取消成功');
}
/**
* 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-09-23
* Time: 17:25
* description excel删除
*/
public function deleteExcel(){
$user = $this->validateToken();
$request = $this->selectParam([
'excel_uuid'
]);
$this->check($request,'Engineering.order_excel_delete');
$data = OrderLogic::deleteExcel($request);
if ($data === false) {
ResponseDirect(14022);
}
$this->render('删除成功');
}
/**
* User: zhaoxin
* Date: 2019-09-25
* Time: 14:31
* description 上传支付凭证
*/
public function updateCertificate(){
$user = $this->validateToken();
$request = $this->selectParam([
'order_uuid','money','pay_img','pay_type'
]);
$this->check($request,'Engineering.order_pay');
$data = \app\api\model\Order::updateCertificate($request);
if ($data === false) {
ResponseDirect(14029);
}
$this->render('上传成功');
}
/**
* User: zhaoxin
* Date: 2019-09-25
* Time: 15:43
* description 进度查看
*/
public function progresses(){
$user = $this->validateToken();
$request = $this->selectParam([
'order_uuid'
]);
$this->check($request,'Engineering.order_uuid');
$data = OrderLogic::progresses($request);
if ($data === false) {
ResponseDirect(14031);
}
$this->render($data);
}
/**
* User: zhaoxin
* Date: 2019-09-26
* Time: 15:31
* description 确认验收
*/
public function confirmCheck(){
$user = $this->validateToken();
$request = $this->selectParam([
'order_uuid','money','pay_img','pay_type'
]);
$pay_type = \app\api\model\Order::build()
->where(['uuid' => $request['order_uuid']])
->field(['pay_type','type'])
->find();
if ($pay_type == '1' && $pay_type['type'] == '1') {
$this->check($request,'Engineering.order_pay');
}
$data = OrderLogic::comfirmCheck($request);
if ($data === false) {
ResponseDirect(14040);
}
$this->render('确认验收成功');
}
/**
* User: zhaoxin
* Date: 2019-09-26
* Time: 15:48
* description 评价信息
*/
public function messagees(){
$user = $this->validateToken();
$request = $this->selectParam([
'order_uuid'
]);
$this->check($request,'Engineering.order_uuid');
$data = OrderLogic::messagees($request['order_uuid']);
if ($data === false) {
ResponseDirect(14040);
}
$this->render($data);
}
/**
* User: zhaoxin
* Date: 2019-09-26
* Time: 16:35
* description 订单评论
*/
public function message(){
$user = $this->validateToken();
$request = $this->selectParam([
'order_uuid','message_type','message_content'
]);
$this->check($request,'Engineering.order_message');
$data = OrderLogic::message($request,$user);
if ($data === false) {
ResponseDirect(14040);
}
$this->render('评论成功');
}
/**
* User: zhaoxin
* Date: 2019/11/7
* Time: 5:33 下午
* description 节点评价
*/
public function nodeMessage(){
$user = $this->validateToken();
$request = $this->selectParam([
'node_uuid','message_type','message_content'
]);
$this->check($request,'Engineering.node_message');
$data = OrderLogic::nodeMessage($request,$user);
if ($data === false) {
ResponseDirect(14040);
}
$this->render('评论成功');
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: xiezhixian
* Date: 2018/5/4
* Time: 上午11:05
*/
namespace app\api\controller\v1\web;
use app\api\logic\web\SendLogic;
use app\api\logic\web\UserLogic;
/**
* 所有资源类接都必须继承基类控制器
* 基类控制器提供了基础的验证,包含app_token,请求时间,请求是否合法的一系列的验证
* 在所有子类中可以调用$this->clientInfo对象访问请求客户端信息,返回为一个数组
* 在具体资源方法中,不需要再依赖注入,直接调用$this->request返回为请具体信息的一个对象
* date:2017-07-25
*/
class Send extends Base
{
/**
* 允许访问的方式列表,资源数组如果没有对应的方式列表,请不要把该方法写上,如user这个资源,客户端没有delete操作
*/
public $restMethodList = 'get|post|put|';
/*
* 发送验证码
*/
public function index()
{
$request = $this->selectParam(['mobile', 'sms_type']);
$request['define_sms_type'] = $request['sms_type'];
$this->check($request, 'Base.sendCompanySms');
$bool = UserLogic::checkUser($request['mobile']);
if(!empty($bool) and $request['sms_type']==='register'){
ResponseDirect(12062);//该手机已注册
}
if ($request['sms_type'] === 'bind' or $request['sms_type'] === 'pass' or $request['sms_type'] === 'reset' or $request['sms_type'] === 'getback') {
$bool = UserLogic::checkUser($request['mobile']);
if(empty($bool)){
ResponseDirect(12063);//该手机未注册
}
}
$info = SendLogic::SendSms($request['mobile'], $request['sms_type']);
if ($info === false) {
ResponseDirect(12064);//信息发送出现了一点小问题哟
}
//发送成功
$this->render(200);
}
/*
* 验证验证码
*/
public function validateTemp()
{
$request = $this->selectParam(['sms_type' => 'reset','code']);
$this->check($request, 'Base.validateCode');
//修改密码
$user_info = $this->validateToken();
$request['mobile'] = $user_info['mobile'];
$info = SendLogic::validateCode($request);
if ($info === false) {
ResponseDirect(11003);//验证码错误
}
$this->render("验证成功",200);
}
/*
* 验证验证码
*/
public function validateCode()
{
$request = $this->selectParam(['sms_type' => 'reset','code','mobile']);
$this->check($request, 'Base.validateWebCode');
$info = SendLogic::validateCode($request);
if ($info === false) {
ResponseDirect(11003);//验证码错误
}
$this->render("验证成功",200);
}
/**
* @author: zhaoxin
* @time: 2019年3月
* description 发送验证码
*/
public function sendCode()
{
$request = $this->selectParam(['mobile', 'sms_type' => 'pass']);
$request['sendPartnerSms'] = $request['sms_type'];
$this->check($request, 'Base.send_sms');
if($request['sms_type'] == 'reset'){
$user_info = $this->validateToken();
if($user_info['mobile'] != $request['mobile']){
$this->returnmsg(403, [], [],"", "", "手机号不一致");
}
}
$this->validateSmsType($request);
$info = SendLogic::SendSms($request['mobile'], $request['sms_type']);
if ($info === false) {
$this->returnmsg(403, [], [],"", "", "信息发送出现了一点小问题哟~");
}
$this->render('发送验证码成功',200);
}
}
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/23
* Time: 14:15
*/
namespace app\api\controller\v1\web;
use app\api\controller\v1\web\Base;
use app\api\logic\web\SubaccountLogic;
class Subaccount extends Base
{
public $restMethodList = 'get|post|put|delete';
public function _initialize()
{
parent::_initialize();
//$this->hasPermission();
}
/*
* 列表
*/
public function index()
{
$user = $this->validateToken();
$data = SubaccountLogic::index($user);
$data !== false ? $this->render($data): $this->returnmsg(16290);
}
/*
* 详情
*/
public function read($id)
{
$this->validateToken();
$this->check(['uuid' => $id], 'Subaccount.uuid');
$data = SubaccountLogic::read($id);
$data !== false ? $this->render($data) : $this->returnmsg(16291);
}
//新增
public function save(){
$user = $this->validateToken();
//判断是否是主账号
if($user['account_grade']!==1){
ResponseDirect(16297);
}
$request = $this->selectParam(['name','mobile','position','password','order_uuid']);
$this->check($request,'Subaccount.save');
$request['parent_uuid'] = $user['uuid'];
$request['order_uuid'] = json_encode($request['order_uuid']);
$request['create_time'] = timeToDate();
$request['update_time'] = timeToDate();
$data = SubaccountLogic::save($request);
$data !== false ? $this->render("新增成功") : ResponseDirect(16292);
}
//更新
public function update($id){
$user = $this->validateToken();
//判断是否是主账号
if($user['account_grade']!==1){
ResponseDirect(16297);
}
$request = $this->selectParam(['uuid'=>$id,'name','mobile','position','password','order_uuid']);
$this->check($request,'Subaccount.update');
unset($request['uuid']);
$request['parent_uuid'] = $user['uuid'];
$request['order_uuid'] = json_encode($request['order_uuid']);
$request['update_time'] = timeToDate();
$data = SubaccountLogic::update($id,$request);
$data !== false ? $this->render('更新成功') : ResponseDirect(16293);
}
//删除
public function delete($id){
$this->validateToken();
$this->check(['uuid' => $id], 'Subaccount.uuid');
$data = SubaccountLogic::delete($id);
$data !== false ? $this->render('删除成功') : ResponseDirect(16294);
}
//订单列表
public function order_list(){
$user = $this->validateToken();
$data = SubaccountLogic::order_list($user,$this->pageIndex, $this->pageSize);
$data !== false ? $this->render($data) : ResponseDirect(16295);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/23
* Time: 14:15
*/
namespace app\api\controller\v1\web;
use app\api\logic\web\UserFeedBackLogic;
use app\api\controller\v1\web\Base;
class UserFeedBack extends Base
{
public $restMethodList = 'get|post|delete|put';
public function _initialize()
{
parent::_initialize();
//$this->hasPermission();
}
/*
* 新增
*/
public function save()
{
$user = $this->validateToken();
$requestData = $this->selectParam(['title','content']);
$this->check($requestData, 'Example.feed_back');
$requestData['uuid'] = uuid();
$requestData['user_uuid'] = $user['uuid'];
$requestData['create_time'] = timeToDate();
$requestData['update_time'] = timeToDate();
$bool = UserFeedBackLogic::save($requestData);
$bool !== false ? $this->render('提交成功'): $this->returnmsg(16230);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-09-19
* Time: 11:34
*/
namespace app\api\logic\app;
use app\api\model\Engineer;
use app\api\model\EngineerForm;
use app\api\model\EngineeringGrade;
use app\api\model\EngineeringRegisters;
use app\api\model\EngineerOauth;
use app\api\model\EngineerToken;
use app\api\model\ServiceNetwork;
use app\api\model\Target;
use app\common\tools\wechatUtil;
use app\common\tools\WXBizDataCrypt;
class EngineerLogic{
/**
* User: zhaoxin
* Date: 2019-09-20
* Time: 14:46
* description
* @param $user_info
* @return mixed
*/
public static function index($user_info){
$service_name = ServiceNetwork::build()->where(['uuid' => $user_info['service_uuid']])->value('name');
$user_info['service_name'] = empty($service_name) ? '暂无' : $service_name;
$grade_name = EngineeringGrade::build()
->where(['praise' => ['<=',$user_info['praise_number'],'order' => ['<=',$user_info['order_number']]]])
->order(['praise' => 'desc','order' => 'desc'])
->value('title');
// ->field(['title'])
// ->limit(1,1)
// ->select();
$user_info['grade_name'] = empty($grade_name) ? '暂无' : $grade_name;
$user_info['service_day'] = json_decode($user_info['service_day']);
foreach ($user_info['service_day'] as $k => &$v){
$v = [
'name' => EngineeringRegisters::build()->where(['uuid' => $v])->value('content'),
'uuid' => $v
];
}
$user_info['service_time'] = json_decode($user_info['service_time']);
foreach ($user_info['service_time'] as $k => &$v){
$v = [
'name' => EngineeringRegisters::build()->where(['uuid' => $v])->value('content'),
'uuid' => $v
];
}
$user_info['service_skill'] = json_decode($user_info['service_skill']);
foreach ($user_info['service_skill'] as $k => &$v){
$v = [
'name' => EngineeringRegisters::build()->where(['uuid' => $v])->value('content'),
'uuid' => $v
];
}
$user_info['other_img'] = json_decode($user_info['other_img']);
unset($user_info['password']);
unset($user_info['is_delete']);
return $user_info;
}
/**
* User: zhaoxin
* Date: 2019-09-19
* Time: 17:47
* description 小程序授权
* @param $requestData
* @return array|int
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function oauth($requestData){
$config = config('wechat');
$openIdInfo = self::getOpenId($config['XcxAppID'], $config['XcxAppSecret'],$requestData['jscode']);
$openIdInfo = json_decode($openIdInfo, true);
if (!empty($openIdInfo['errcode'])) {
ResponseDirect(13002);
}
$pc = new WXBizDataCrypt($config['XcxAppID'], $openIdInfo['session_key']);
$errCode = $pc->decryptData($requestData['encryptedData'], $requestData['vi'], $result);
if ($errCode != 0) {
return $errCode;
}
$result = json_decode($result, true);
$oauth_info = EngineerOauth::build()
->where(['oauth_id' => $openIdInfo['openid']])
->find();
//已授权并绑定用户直接登陆
if(!empty($oauth_info['engineer_uuid'])){
$engineer_info = Engineer::build()
->where(['uuid' => $oauth_info['engineer_uuid']])
->find();
if ($engineer_info['is_banned']) {
ResponseDirect(12021);
}
$token = EngineerToken::storeToken($oauth_info['engineer_uuid']);
$users['token'] = $token;
$users['login'] = 1;//直接登陆
return $users;
}
//已授权并绑定了手机号,但未填写直接登陆
if(!empty($oauth_info['mobile'])){
$users['login'] = 2;//进行添加信息操作
$users['oauth_uuid'] = $oauth_info['uuid'];//进行添加信息操作
return $users;
}
//第一次进行授权
if(empty($oauth_info)){
$data = [];
$data['uuid'] = uuid();
$data['oauth_type'] = "xcx";
$data['oauth_id'] = $openIdInfo['openid'];
$data['nickname'] = $result['nickName'];
$data['avatar'] = $result['avatarUrl'];
$data['sex'] = $result['gender'];
$data['union_id'] = $result['unionId'];
$data['create_time'] = timeToDate();
$bool = EngineerOauth::build()
->insert($data);
if($bool == false){
ResponseDirect(13003);
}
$oauth_info['uuid'] = $data['uuid'];
}
return ['login' => 3,'oauth_uuid' => $oauth_info['uuid']];//需要进行绑定授权步骤
}
/**
* User: zhaoxin
* Date: 2019-09-19
* Time: 17:06
* description 小程序获取openid
* @param $appId
* @param $appSecret
* @param $js_code
* @return bool
*/
public static function getOpenId($appId, $appSecret,$js_code)
{
if (empty($appId) || empty($appSecret)) {
return false;
}
$url = "https://api.weixin.qq.com/sns/jscode2session?"
. "?grant_type=authorization_code&appid={$appId}&secret={$appSecret}&js_code={$js_code}";
$result = wechatUtil::getCurl($url);
return $result;
}
/**
* User: zhaoxin
* Date: 2019-09-20
* Time: 09:59
* description
* @param $requestData
* @return array
* @throws \think\Exception
*/
public static function bandMobile($requestData)
{
$config = config('wechat');
$openIdInfo = self::getOpenId($config['XcxAppID'], $config['XcxAppSecret'],$requestData['jscode']);
$openIdInfo = json_decode($openIdInfo, true);
if (!empty($openIdInfo['errcode'])) {
ResponseDirect(13002);
}
$pc = new WXBizDataCrypt($config['XcxAppID'], $openIdInfo['session_key']);
$errCode = $pc->decryptData($requestData['encryptedData'], $requestData['vi'], $result);
if ($errCode != 0) {
return $errCode;
}
$result = json_decode($result, true);
$count = Engineer::build()->checkUser($result['phoneNumber']);
if($count > 0){
ResponseDirect(13000);
}
$bool = EngineerOauth::build()
->where(['oauth_id'=>$openIdInfo['openid']])
->update(['mobile' => $result['phoneNumber'],'update_time' => timeToDate()]);
if($bool == false){
ResponseDirect(13004);
}
return ['login' => 2,'oauth_uuid' => $requestData['oauth_uuid']];
}
/**
* User: zhaoxin
* Date: 2019-09-20
* Time: 11:17
* description
* @param $requestData
* @return Engineer
* @throws \think\Exception
*/
public static function resetPassword($requestData){
$count = Engineer::build()->checkUser($requestData['mobile']);
if($count <= 0){
ResponseDirect(13008);
}
return Engineer::build()
->where(['mobile' => $requestData['mobile']])
->update(['password' => md5(md5($requestData['password'])),'update_time' => timeToDate()]);
}
public static function plans($requestData,$user,$page_index,$page_size){
$where = ['service_uuid' => $user['service_uuid']];
if (!empty($requestData['start_time']) && !empty($requestData['end_time'])) {
$start_time = date('Y-m-01 00:00:00',strtotime($requestData['start_time']));
$end_time = date('Y-m-31 23:59:59',strtotime($requestData['end_time']));
$where['t.start_time|t.end_time'] = ['between time',[$start_time,$end_time]];
}
$list = Target::build()
->alias('t')
->join('engineering_target e_t','e_t.uuid = t.target_uuid')
->where($where)
->field([
't.uuid','t.start_time','t.end_time','t.title','e_t.title target_time',
])
->paginate(['list_rows' => $page_size, 'page' => $page_index]);
return $list;
}
public static function planInfo($uuid){
return Target::build()
->where(['uuid' => $uuid])
->field(['title','content'])
->find();
}
public static function saveFormId($requestData,$userInfo){
if (empty($requestData['form_id'])){
return false;
}
return EngineerForm::build()
->insert([
'uuid' => uuid(),
'engineer_uuid' => $userInfo['uuid'],
'form_id' => $requestData['form_id'],
'expire_time' => timeToDate(time() + 604800)
]);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-09-20
* Time: 14:52
*/
namespace app\api\logic\network;
use app\api\model\Engineer;
use app\api\model\EngineeringRegisters;
use app\api\model\EngineerOauth;
use think\Session;
class EngineerLogic
{
private $network_info;
public function __construct()
{
$this->network_info = Session::get('network_info');
}
public function index($request,$page_index,$page_size){
$where = ['e.is_delete' => '0','service_uuid' => $this->network_info['uuid']];
if (!empty($request['keyword'])){
$where['e.name|e.mobile'] = ['like',"%".$request['keyword']."%"];
}
if (!empty($request['province'])){
$where['e.province'] = ['like',"%".$request['province']."%"];
}
if (!empty($request['city'])){
$where['e.city'] = ['like',"%".$request['city']."%"];
}
if (!empty($request['county'])){
$where['e.county'] = ['like',"%".$request['county']."%"];
}
if (!empty($request['service_type'])){
$where['e.service_type'] = $request['service_type'];
}
if (in_array($request['is_authentication'],['0','1'])){
$where['e.is_authentication'] = $request['is_authentication'];
}
if($request['user_type'] == '1'){
$where['e.is_authentication'] = '1';
$where['e.is_banned'] = '0';
$where['e.type'] = ['in',['1','3']];
}
$data = Engineer::build()
->alias('e')
->where($where)
->field([
'e.name','e.mobile','e.province','e.city','e.county','e.service_type','e.service_uuid service_name',
'e.create_time', 'e.is_authentication','e.uuid'
])
->order(['e.create_time' => 'desc']);
if($request['is_export'] == '1'){
$data = collection($data->select())->toArray();
$exports = [];
foreach ($data as $k => $v){
$export = [
'id' => $k+1,
'name' => $v['name'],
'mobile' => $v['mobile'].' ',
'address' => $v['province'].$v['city'].$v['county'],
'service_type' => ($v['service_type'] == '1') ? '工程师' : '工程队',
'create_time' => $v['create_time'],
'is_authentication' => ($v['is_authentication'] == '1') ? '是':'否'
];
$exports[] = array_values($export);
}
return $exports;
}
$data = $data->paginate(['list_rows' => $page_size, 'page' => $page_index]);
return $data;
return $data;
}
public function read($uuid){
$user_info = Engineer::build()->where(['uuid' => $uuid,'service_uuid' => $this->network_info['uuid']])->find();
$user_info = $user_info->toArray();
foreach ($user_info['service_day'] as $k => &$v){
$v = [
'name' => EngineeringRegisters::build()->where(['uuid' => $v])->value('content'),
'uuid' => $v
];
}
foreach ($user_info['service_time'] as $k => &$v){
$v = [
'name' => EngineeringRegisters::build()->where(['uuid' => $v])->value('content'),
'uuid' => $v
];
}
foreach ($user_info['service_skill'] as $k => &$v){
$v = [
'name' => EngineeringRegisters::build()->where(['uuid' => $v])->value('content'),
'uuid' => $v
];
}
$user_info['oauth_info'] = EngineerOauth::build()
->where(['engineer_uuid' => $uuid])
->field(['nickname','mobile','avatar'])
->find();
return $user_info;
}
public static function delete($uuid){
return Engineer::build()->where(['uuid' => $uuid])->update(['is_delete' => '1','update_time' => timeToDate()]);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-04-12
* Time: 18:19
*/
namespace app\api\logic\network;
use app\api\model\ServiceNetworkGroupMenus;
use app\api\model\ServiceNetworkMenus;
class MenuBarLogic
{
private static function showCat($cats, $root)
{
$tree = [];
if (isset($cats[$root])) {
foreach ($cats[$root] as $k => $cat) {
$tree[$k] = $cat;
$children = self::showCat($cats, $cat['uuid']);
$tree[$k]['children'] = $children;
}
}
return $tree;
}
/**
* @author: Airon
* @time: 2019年4月
* description
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function index()
{
$result = ServiceNetworkMenus::build()
->order(['sort' => 'DESC'])
->select();
$result = collection($result)->toArray();
$cats = [];
foreach ($result as $cat) {
$cats[$cat['parent_uuid']][] = $cat;
}
return ['root' => self::showCat($cats, '0')];
}
public static function save($data)
{
$data['uuid'] = uuid();
$data['create_time'] = timeToDate();
if (empty($data['parent_uuid'])) {
$data['parent_uuid'] = '0';
}
return ServiceNetworkMenus::build()->insert($data);
}
public static function update($data)
{
return ServiceNetworkMenus::build()->where(['uuid' => $data['uuid']])->update($data);
}
public static function delete($id)
{
$bool_2 = ServiceNetworkGroupMenus::build()
->where([
'menu_uuid' => $id,
])->delete();
return ServiceNetworkMenus::build()
->where([
'uuid' => $id,
])->delete();
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-09-21
* Time: 10:14
*/
namespace app\api\logic\network;
use app\api\model\ServiceNetwork;
use app\api\model\ServiceNetworkAdmin;
use app\api\model\ServiceNetworkInfo;
use app\api\model\ServiceNetworkMenus;
use app\api\model\ServiceNetworkToken;
use think\Session;
class NetworkLogic
{
private $network_info;
public function __construct()
{
$this->network_info = Session::get('network_info');
}
/**
* User: zhaoxin
* Date: 2019-09-21
* Time: 11:07
* description
* @param string $account
* @param string $password
* @return array|bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function login($account = '', $password = ''){
$user = ServiceNetworkAdmin::build()
->alias('S_A')
->join('service_network S','S.uuid = S_A.network_uuid')
->where(['S_A.account' => $account, 'S_A.password' => md5(md5($password))])
->field(['S_A.uuid','S_A.network_uuid','S.name','S_A.type'])
->find();
if (!empty($user)) {
$token = ServiceNetworkToken::storeToken($user['network_uuid'],$user['uuid']);
$menu = ServiceNetworkAdmin::build()
->alias('S_A')
->join('service_network_group_menus S_G_M', 'S_G_M.group_uuid = S_A.uuid')
->join('service_network_menus M_B', 'M_B.uuid = S_G_M.menu_uuid')
->where(['S_A.uuid' => $user['uuid']])
->field([
'M_B.uuid',
'M_B.parent_uuid',
'M_B.name',
'M_B.url',
'M_B.classes'
])
->order(['M_B.sort' => 'DESC'])
->select();
if(empty($menu)){
return [
'user_info' => $user,
'token' => $token,
'menu_bar' => '',
];
}
$menu = collection($menu)->toArray();
$parent = ServiceNetworkMenus::build()
->where(['parent_uuid' => 0])
->field(['uuid', 'name', 'parent_uuid', 'url', 'classes'])
->select();
$parent = collection($parent)->toArray();
$data = [];
foreach ($parent as $item) {
$data[$item['uuid']] = $item;//目录字典
}
$parent_array = array_column($parent, 'uuid');
$lists = [];
foreach ($menu as $item) {
$lists[$item['parent_uuid']][] = $item;
}
$result = $lists[0];//设置一级菜单
foreach ($lists as $k => $v) {
if ($k !== 0) {//判断是否为一级
$temp = $v;
foreach ($temp as $key => $value) {//进行二级菜单子集判断
if (array_key_exists($value['uuid'], $lists)) {
$temp[$key]['children'] = $lists[$value['uuid']];
}
}
foreach ($result as $key=>$value){
if($value['uuid'] == $k){
$result[$key]['children'] = $temp;
}
}
continue;
}
}
return [
'user_info' => $user,
'token' => $token,
'menu_bar' => $result,
];
}
return false;
}
/**
* User: zhaoxin
* Date: 2019-09-21
* Time: 11:07
* description
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function info(){
$data = ServiceNetwork::build()
->where(['uuid' => $this->network_info['uuid']])
->field([
'name','province','city','county','address','contact_name','contact_mobile',
'introduce','uuid','status'
])
->find();
return $data;
}
public static function read($uuid){
$data = ServiceNetworkInfo::build()
->where(['network_uuid' => $uuid])
->field([
'name','province','city','county','address','contact_name','contact_mobile',
'introduce'
])
->find();
return $data;
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: mac
* Date: 2019-09-23
* Time: 18:01
*/
namespace app\api\logic\network;
use app\api\model\Engineer;
use app\api\model\MessageUser;
use app\api\model\Order;
use app\api\model\OrderExcel;
use app\api\model\Orderhistory;
use app\api\model\OrderNode;
use app\api\model\ServiceNetwork;
use think\Db;
use think\Session;
class OrderLogic
{
private $network_info;
public function __construct()
{
$this->network_info = Session::get('network_info');
}
public function index($request,$page_index,$page_size){
$where = ['service_uuid' => $this->network_info['uuid']];
if (!empty($request['keyword'])) {
$where['o.contact_name|o.code|contact_mobile'] = ['like',"%{$request['keyword']}%"];
}
if(!empty($request['engineering_type'])) {
$where['o.type'] = $request['engineering_type'];
}
switch ($request['order_status']){
case '1'://已下单
$where['o.pay_status'] = '0';
// $where['o.is_assgin'] = '2';
$where['o.status'] = '0';
break;
case '2'://已指派
$where['o.pay_status'] = '0';
// $where['o.is_assgin'] = '2';
$where['o.status'] = '1';
break;
case '3'://待确定
// $where['o.is_assgin'] = '2';
$where['o.pay_status'] = ['in',['1','2']];
$where['o.status'] = '1';
break;
case '4'://实施中
$where['o.pay_status'] = '2';
$where['o.status'] = '2';
$where['o.is_check'] = '0';
break;
case '5'://
$where['o.pay_status'] = '2';
$where['o.status'] = '2';
$where['o.is_check'] = '1';
break;
case '6'://已完成
$where['o.pay_status'] = '2';
$where['o.status'] = '3';
break;
case '7'://已取消
$where['o.pay_status'] = '3';
break;
default:
ResponseDirect(14017);
break;
}
$data = Order::build()
->alias('o')
->join('engineering e','e.uuid = o.engineering_uuid')
->where($where)
->field([
'o.uuid','o.code','e.name','o.contact_name','o.contact_mobile','o.type',
'o.update_time','o.province','o.city','o.county','o.address','o.uuid is_need'
])
->order(['o.update_time' => 'desc']);
if($request['is_export'] == '1'){
$data = collection($data->select())->toArray();
$exports = [];
foreach ($data as $k => $v){
$export = [
'id' => $k+1,
'code' => $v['code'].' ',
'contact_name' => $v['contact_name'],
'contact_mobile' => $v['contact_mobile'].' ',
'address' => $v['province'].$v['city'].$v['county'],
'name' => $v['name'],
'create_time' => $v['update_time'],
'is_need' => ($v['is_need'] == '1') ? '是':'否'
];
$exports[] = array_values($export);
}
return $exports;
}
$data = $data->paginate(['list_rows' => $page_size, 'page' => $page_index]);
return $data;
}
public function read($id){
$count = Order::build()
->where(['uuid' => $id,'service_uuid' => $this->network_info['uuid']])
->count();
if($count <= 0){
ResponseDirect(14024);
}
$info['user_info'] = Order::build()
->alias('o')
->join('user u','u.uuid = o.user_uuid')
->where(['o.uuid' => $id])
->field([
'u.type','u.name','u.mobile','u.email','u.province','u.county','u.city',
'u.detail','u.company_name','u.company_contact','u.company_mobile','u.business_licence',
'o.engineer_uuid'
])
->find();
$info['order_info'] = Order::build()
->alias('o')
->join('engineering e','e.uuid = o.engineering_uuid')
->where(['o.uuid' => $id])
->field([
'o.type','e.name','o.contact_name','o.contact_mobile','o.province','o.city','o.county',
'o.describe','o.pay_status','o.status service_order_status','o.uuid','o.is_message',
'o.is_check','o.contract_money','o.contract_img'
])
->find();
$info['excel_info'] = OrderExcel::build()
->where(['order_uuid' => $id])
->field(['uuid','name','url','create_time'])
->order(['create_time' => 'DESC'])
->select();
$info['node_info'] = OrderNode::build()
->where(['order_uuid' => $id])
->field(['name','time','uuid'])
->order(['time' => 'ASC'])
->select();
$info['assgin_info'] = Engineer::build()
->where(['uuid' => $info['user_info']['engineer_uuid']])
->field([
'service_type','uuid service_name','name','mobile','province','city','county'
])
->find();
if($info['order_info']['type'] == '2'){
$info['contract_info']['money'] = $info['order_info']['contract_money'];
$info['contract_info']['img'] = $info['order_info']['contract_img'];
}
unset($info['order_info']['contract_money']);
unset($info['order_info']['contract_img']);
return $info;
}
public function appoint($request){
//直接指派给工程师
$user_info = Engineer::build()
->where(['uuid' => $request['appoint_uuid']])
->field(['uuid','is_authentication','type','service_uuid','name','mobile'])
->find();
if(empty($user_info)){
ResponseDirect(13014);
}
$data['service_uuid'] = $this->network_info['uuid'];
$data['engineer_uuid'] = $request['appoint_uuid'];
$data['status'] = '1';
$data['update_time'] = timeToDate();
//指派信息
$order_history = [
'uuid' => uuid(),
'order_uuid' => $request['order_uuid'],
'pay_status' => '0',
'status' => '1',
'is_check' => '0',
'name' => $user_info['name'],
'mobile' => $user_info['mobile'],
'create_time' => timeToDate(),
];
Db::startTrans();
$bool = Order::build()
->where(['uuid' => $request['order_uuid']])
->update($data);
if($bool == false){
ResponseDirect(14023);
}
$bool = Orderhistory::build()
->insert($order_history);
if($bool == false){
Db::rollback();
ResponseDirect(14015);
}
$bool = MessageUser::build()
->insert([
'uuid' => uuid(),
'user_uuid' => $user_info['uuid'],
'title' => '订单通知',
'content' => '您的订单已指派,请保持电话通畅,方便工作人员联系您!',
'other_uuid' => $request['order_uuid'],
'message_type' => '1',
'create_time' => timeToDate(),
]);
if($bool == false){
Db::rollback();
ResponseDirect(14059);
}
Db::commit();
return true;
}
public static function confirmAppoint($uuid){
$order_info = Order::build()
->where(['uuid' => $uuid])
->field(['engineer_uuid','contact_name','contact_mobile'])
->find();
if(empty($order_info)){
ResponseDirect(14027);
}
if(empty($order_info['engineer_uuid'])){
ResponseDirect(14026);
}
$count = OrderExcel::build()
->where(['order_uuid' => $uuid])
->count();
if($count <= 0){
ResponseDirect(14028);
}
Db::startTrans();
$bool = Order::build()
->where(['uuid' => $uuid])
->update([
'pay_status' => '1',
'update_time' => timeToDate()
]);
if($bool == false){
ResponseDirect(14019);
}
$bool = Orderhistory::build()
->insert([
'uuid' => uuid(),
'order_uuid' => $uuid,
'pay_status' => '1',
'status' => '1',
'is_check' => '0',
'name' => $order_info['contact_name'],
'mobile' => $order_info['contact_mobile'],
'create_time' => timeToDate()
]);
if($bool == false){
DB::rollback();
ResponseDirect(14015);
}
Db::commit();
return true;
}
}
\ No newline at end of file
<?php
/**
*
* Created by PhpStorm.
* User: fenggaoyuan
* Email: 253869997@qq.com
* Date: 2018/7/26
* Time: 11:35
*/
namespace app\api\logic\network;
use app\api\model\MessageUser;
use app\api\model\User;
use app\api\model\UserMoney;
use app\api\model\UserRecharge;
use app\api\model\ServiceWithdrawal;
use app\api\model\Withdrawal;
use app\api\model\Config;
use app\api\model\ServiceNetwork;
use think\Db;
use think\Exception;
class WithdrawalLogic
{
public static function index($user,$request,$page,$size){
$where['sw.service_uuid'] =['eq',$user['uuid']];
if (!empty($data['start_time']) and !empty('end_time')) {
$start_time = date('Y-m-d 00:00::00',strtotime($data['start_time']));
$end_time = date('Y-m-d 23:59::59',strtotime($data['end_time']));
$where['create_time'] = ['between', [$start_time,$end_time]];
}
if ($request['status'] !== '') {
$where['status'] =$request['status'];
}
$field = "sw.uuid,sn.name network_name,sn.contact_name,sn.contact_mobile as mobile,sn.province,sn.city,sw.create_time,sw.status,sw.money";
$result = ServiceWithdrawal::build()
->alias('sw')
->join('service_network sn','sw.service_uuid=sn.uuid')
//->join('engineer e','sn.uuid=e.service_uuid','left')
->field($field)
->where($where)
->order('create_time desc');
if ($request['is_export']==1) {
$arr = $result->select();
$arr = collection($arr)->toArray();
$result = [];
foreach ($arr as $first) {
unset($first['uuid']);
$result[] = array_values($first);
}
return $result;
}
return $result->paginate(['list_rows'=>$size, 'page'=>$page]);
}
public static function read($uuid){
return ServiceWithdrawal::build()->where(['uuid'=> $uuid])->find();
}
public static function submit($user,$request){
$password = ServiceNetwork::build()->where('uuid',$user['uuid'])->value('withdrawal_password');
if($password!=md5(md5($request['password']))){
ResponseDirect(18001);
}
//余额是否足够
$network_withdrawal_rate = Config::build()->where('key','network_withdrawal_rate')->value('value');
$network_withdrawal_rate = json_decode($network_withdrawal_rate,true);
$withdrawal_money = round((float)$request['money']*(1+(float)$network_withdrawal_rate['content']/100),2);
$remain = ServiceNetwork::build()->where(['uuid'=>$user['uuid']])->value('money');
if ($remain<$withdrawal_money) {
ResponseDirect(18002);
}
try{
Db::startTrans();
unset($request['password']);
$request['deduct_money'] = $withdrawal_money;
//提现表
ServiceWithdrawal::build()->insert($request);
//网点余额表
ServiceNetwork::build()->where(['uuid'=>$user['uuid']])->setDec('money',$withdrawal_money);
Db::commit();
return true;
}catch (Exception $e){
Db::rollback();
return false;
}
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/8/3
* Time: 14:19
*/
namespace app\api\logic\web;
use app\api\model\Config;
use think\config as extra_config;
class ConfigLogic
{
public static function read($id) {
return Config::build()->where(['key' => $id])->field(['value'])->find();
}
public static function update($data) {
$bool = Config::build()
->where([
'key' => $data['key']
])->field([
'value'
])->find();
if (!empty($bool)) {
if($data['key'] =="advertise_img_src" || $data['key'] =="broker_template"){
$domain= extra_config::get('qiniu.BucketDomain');
$data['value']['content'] = $domain.'/'.$data['value']['content'];
}
return Config::build()->save($data, ['key' => $data['key']]);
}
return Config::build()
->save($data);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/26
* Time: 10:44
*/
namespace app\api\logic\web;
use app\api\model\Jpush as JpushModel;
use app\api\model\Message;
use app\api\model\MessageUser;
use app\api\model\User;
use think\Db;
use think\Exception;
class MessageLogic
{
public static function index($user,$request,$page_index,$page_size)
{
if(!empty($request['uuid'])){
return MessageUser::build()->where('uuid','in',$request['uuid'])->update(['is_read'=>1]);
}
return MessageUser::build()
->where(['user_uuid'=>$user['uuid']])
->field('uuid,type,title,content,is_read,create_time')
->order('create_time desc')
->paginate(['page'=>$page_index,'list_rows'=>$page_size]);
}
public static function read($user,$id)
{
MessageUser::build()->where(['uuid'=>$id])->update(['is_read'=>1]);
return MessageUser::build()->field('uuid,type,title,content,create_time')->where(['uuid' => $id])->find();
}
public static function update($data)
{
$uuid = $data['uuid'];
unset($data['uuid']);
$data['update_time'] = timeToDate();
$data['type'] = 1;
return Message::build()->where(['uuid'=>$uuid])->update($data);
}
public static function save($data)
{
$user_uuid = User::build()->field('uuid')->where(['is_banned'=>0])->select();
$user_uuid = array_column($user_uuid,'uuid');
try{
Db::startTrans();
foreach ($user_uuid as $v){
$message['uuid'] = uuid();
$message['user_uuid'] = $v;
$message['title'] = $data['title'];
$message['content'] = $data['content'];
$message['message_uuid'] = $data['uuid'];
$result[] = $message;
}
//普通推送
MessageUser::build()->insertAll($result);
Message::build()->save($data);
}catch (\Exception $e){
Db::rollback();
return false;
}
return true;
}
public static function delete($id)
{
return Message::build()->where(['uuid' => $id])->update(['is_delete'=>1]);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Airon
* Date: 2017/7/11
* Time: 14:56
*/
namespace app\api\logic\web;
use app\api\model\UserSms as SmsModel;
class SendLogic
{
public static function SendSms($mobile, $sms_type)
{
//todo 为了测试方便 默认123456
// $code = '123456';
// $bool = SmsModel::build()->insert([
// 'uuid' => uuid(),
// 'mobile' => $mobile,
// 'sms_type' => $sms_type,
// 'sms_code' => $code,
// 'send_result' => 'ok',
// 'create_time' => timeToDate(time()),
// 'update_time' => timeToDate(time()),
// ]);
// return $bool;
return SmsModel::sendSms($mobile, randString(6), $sms_type);
}
public static function validateCode($requestData)
{
return SmsModel::validateCode(
$requestData['mobile'],
$requestData['code'],
$requestData['sms_type']
);
}
}
\ No newline at end of file
<?php
/**
*
* Created by PhpStorm.
* User: fenggaoyuan
* Email: 253869997@qq.com
* Date: 2018/7/26
* Time: 11:35
*/
namespace app\api\logic\web;
use app\api\model\Subaccount;
use app\api\model\Order;
use app\api\model\User;
use think\Db;
use think\Exception;
class SubaccountLogic
{
/**
* @author: star
* @time: 2019年9月
* 列表
*/
public static function index($user)
{
return User::build()
->alias('u')
->join('user_subaccount us','us.parent_uuid=u.uuid')
->field('us.uuid,us.position,us.name,us.mobile,us.create_time')
->where(['u.uuid'=>$user['uuid']])
->order('us.create_time desc')
->paginate(['page'=>1,'list_rows'=>3]);
}
/**
* @author: star
* @time: 2019年9月
* 详情
*/
public static function read($uuid)
{
$where['uuid'] = $uuid;
return Subaccount::build()->where($where)->find();
}
/**
* @author: star
* @time: 2019年9月
* 新增
*/
public static function save($request)
{
$number = Subaccount::build()->where(['parent_uuid'=>$request['parent_uuid']])->count();
if($number>3){
ResponseDirect(16296);//最多三个子账号
}
$request['uuid'] = uuid();
try{
Db::startTrans();
//添加子账号
Subaccount::build()->insert($request);
//写入用户表
$company_info = User::build()
->where(['uuid'=>$request['parent_uuid']])
->field('company_name,company_mobile,company_contact,business_licence,province,city,county,detail')
->find();
//企业子账号用户信息
$company_user['uuid'] = $request['uuid'];
$company_user['name'] = $request['name'];
$company_user['account'] = $request['mobile'];
$company_user['mobile'] = $request['mobile'];
$company_user['type'] = 2;
$company_user['account_grade'] = 2;
$company_user['password'] = md5(md5($request['password']));
$company_user['company_name'] = $company_info['company_name'];
$company_user['company_mobile'] = $company_info['company_mobile'];
$company_user['company_contact'] = $company_info['company_contact'];
if(!empty($company_info['business_licence'])){
$company_user['business_licence'] = json_encode($company_info['business_licence']);
}
$company_user['province'] = $company_info['province'];
$company_user['city'] = $company_info['city'];
$company_user['county'] = $company_info['county'];
$company_user['detail'] = $company_info['county'];
$company_user['create_time'] = timeToDate();
$company_user['update_time'] = timeToDate();
User::build()->insert($company_user);
Db::commit();
return true;
}catch(\Exception $e){
Db::rollback();
return false;
}
}
/**
* @author: star
* @time: 2019年9月
* 更新
*/
public static function update($id,$request)
{
try{
Db::startTrans();
Db::commit();
//编辑子账号表
Subaccount::build()->where(['uuid'=>$id])->update($request);
//用户表
$data['account'] = $request['mobile'];
$data['name'] = $request['name'];
//电话是否改动
$mobile = User::build()->where(['uuid'=>$id])->value('mobile');
if($mobile!=$request['mobile']){
$data['mobile'] = $request['mobile'];
}
$data['password'] = md5(md5($request['password']));
$data['update_time'] = timeToDate();
User::build()->where(['uuid'=>$id])->update($data);
return true;
}catch(\Exception $e){
Db::rollback();
return false;
}
}
/**
* @author: star
* @time: 2019年9月
* 更新
*/
public static function delete($id)
{
try{
Db::startTrans();
Db::commit();
Subaccount::build()->where(['uuid'=>$id])->delete();
User::build()->where(['uuid'=>$id])->delete();
return true;
}catch(\Exception $e){
Db::rollback();
return false;
}
}
/**
* @author: star
* @time: 2019年9月
* 订单列表
*/
public static function order_list($user,$page_index,$page_size)
{
return Order::build()
->alias('o')
->join('engineering e','e.uuid=o.engineering_uuid')
->join('user u','u.uuid=o.user_uuid')
->field('o.uuid,e.type,e.name,o.contact_name,o.contact_mobile,o.status')
->where(['o.user_uuid'=>$user['uuid'],'o.pay_status'=>2])
->order('o.create_time desc')
->paginate(['page'=>$page_index,'list_rows'=>$page_size]);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: ChiaHsiang
* Date: 2018/7/26
* Time: 10:44
*/
namespace app\api\logic\web;
use app\api\model\UserFeedback;
class UserFeedBackLogic
{
public static function save($data)
{
return UserFeedback::build()->save($data);
}
}
\ No newline at end of file
<?php
/**
*
* Created by PhpStorm.
* User: fenggaoyuan
* Email: 253869997@qq.com
* Date: 2018/7/26
* Time: 11:35
*/
namespace app\api\logic\web;
use app\api\logic\app\ConfigLogic;
use app\api\model\Config;
use app\api\model\SmsModel;
use app\api\model\MessageUser;
use app\api\model\Subaccount;
use app\api\model\User;
use app\api\model\UserOauth;
use app\api\model\UserToken;
use app\common\tools\wechatUtil;
use think\Db;
use think\Exception;
class UserLogic
{
public static function checkUser($mobile)
{
$bool = User::build()->where(['account' => $mobile])->find();
return empty($bool) ? false : true;
}
/**
* @author: star
* @time: 2019年9月
* description 检查邮箱是否绑定账号
*/
public static function checkEmail($email)
{
$bool = User::build()->where(['email' => $email])->find();
return empty($bool) ? false : true;
}
/**
* @author: star
* @time: 2019年9月
* description 退出登录
*/
public static function loginOut($uuid){
$bool = UserToken::build()->where(['user_uuid' => $uuid])->update([
'expiry_time' => timeToDate(time())
]);
if($bool){
return true;
}
return false;
}
public static function unbind($request){
$bool = User::build()
->where([
'uuid'=>$request['uuid']
])
->update([
'openid'=>null,'unionid'=>null,'update_time'=>timeToDate(),
'nickname'=>null,'avatar'=>null
]);
if($bool){
return true;
}
return false;
}
/**
* @author: star
* @time: 2019年9月
* description 绑定账户
*/
public static function bandWeChat($request){
$user = User::build()->where(['account'=>$request['mobile']])->find();
if($user['is_banned']==1){
ResponseDirect(12021);//账户被禁用
}
$bool = User::build()
->where([
'account'=>$request['mobile']
])
->update([
'openid'=>$request['openid'],'unionid'=>$request['unionid'],'update_time'=>timeToDate(),
'nickname'=>$request['nickname'],'avatar'=>$request['avatar']
]);
if($bool){
return true;
}
return false;
}
/**
* @author: Airon
* @time: 2019年5月
* description 获取微信用户信息
* @param $data
* @return array|bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function getWechatInfo($data)
{
$config = config('wechat');
$result = wechatUtil::getAccessToken($config['PublicAppID'], $config['PublicAppSecret'], $data['jscode']);
$result = json_decode($result, true);
if (!empty($result['errcode'])) {
(new self())->returnmsg(403, [], [], 'jsCode Error', "", $result['errmsg']);
}
$user_info = wechatUtil::getUserInfo($result['access_token'], $result['openid']);
if (empty($user_info)) {
(new self())->returnmsg(403, [], [], 'login Error', "", "获取失败");
}
$user_info = json_decode($user_info, true);
$user_info['nickname'] = $result['nickname'];
$user_info['avatar'] = $result['headimgurl'];
$user_info['openid'] = $result['openid'];
$user_info['unionid'] = empty($result['unionid']) ? "" : $result['unionid'];
return $user_info;
}
public static function save($data)
{
//根据ouath_uuid获取授权信息
$result = UserOauth::build()->where(['uuid'=>$data['oauth_uuid']])->find();
$data['openid'] = $result['pc_oauth_id'];
$data['unionid'] = $result['union_id'];
$data['avatar'] = $result['avatar'];
$data['nickname'] = $result['nickname'];
unset($data['oauth_uuid']);
return User::build()->insert($data);
}
public static function edit_email($data,$user)
{
return User::build()->where(['uuid'=>$user['uuid']])->update(['email'=>$data['email'],'update_time'=>timeToDate()]);
}
public static function edit_info($data)
{
//更新
$info = [];
if($data['type']==1){//普通用户
$info['name'] = $data['name'];
$info['mobile'] = $data['mobile'];
//$info['email'] = $data['email'];
$info['province'] = $data['province'];
$info['city'] = $data['city'];
$info['county'] = $data['county'];
$info['detail'] = $data['detail'];
$info['update_time'] = timeToDate();
}
if($data['type']==2){//企业用户
$info['company_name'] = $data['company_name'];
//$info['email'] = $data['email'];
$info['company_mobile'] = $data['company_mobile'];
$info['company_contact'] = $data['company_contact'];
// if(!empty($data['business_licence'])){
// $info['business_licence'] = json_encode($data['business_licence']);
// }
$info['province'] = $data['province'];
$info['city'] = $data['city'];
$info['county'] = $data['county'];
$info['detail'] = $data['detail'];
$info['update_time'] = timeToDate();
}
if($data['type']==3){//企业子账号用户
$info['name'] = $data['name'];
$info['mobile'] = $data['mobile'];
$info['position'] = $data['position'];
$info['update_time'] = timeToDate();
$result = Subaccount::build()->where(['uuid'=>$data['uuid']])->update($info);
if(!$result){
ResponseDirect(11006);
}
unset($info['position']);
$info['account'] = $data['mobile'];
}
return User::build()->where(['uuid'=>$data['uuid']])->update($info);
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@
namespace app\api\model;
use think\Collection;
use think\Db;
use think\Model;
class User extends Model
......@@ -20,56 +21,37 @@ class User extends Model
* @time: 2019年3月
* description 验证码登录
*/
public function login($requestData,$oauth_uuid = "")
public function login($requestData)
{
if($requestData['login_type']==1){//账号密码登录
$password = self::build()->where(['account' => $requestData['mobile']])
->field(['password'],false)->find();
$md5Password = md5(md5($requestData['password']));
if($password){
if($md5Password != $password['password']){
ResponseDirect(12022);
}
}else{
ResponseDirect(12013);
}
unset($password);
$user = self::build()->where(['oauth_id' => $requestData['openid']])->find();
$user = self::build()->where(['account' => $requestData['mobile'],'password' => $md5Password])
->field(['password'],true)->find();
}
if($requestData['login_type']==2){//验证码登录
$user = self::build()->where(['account' => $requestData['mobile']])->field(['password'],true)->find();
if(empty($user)){
ResponseDirect(12063);
}
}
if($requestData['login_type']==3){//微信登录
$user = self::build()->where(['openid' => $requestData['openid']])->field(['password'],true)->find();
if(empty($user)){
ResponseDirect(12061);
}
Db::startTrans();
if ($user) {
if(!empty($requestData['openid']) && !empty($requestData['avatar']) && isset($requestData['unionid']) && isset($requestData['wechat_name'])){
self::build()->where(['oauth_id' => $requestData['openid']])
->update(['avatar'=>$requestData['avatar'],'unionid'=>$requestData['unionid'],'wechat_name'=>$requestData['wechat_name']]);
}
if ($user['is_banned'] == '1') {
ResponseDirect(12021);
}
$token = UserToken::storeToken($user['uuid']);
$companys['info']['token'] = $token;
$companys['info']['user_info'] = self::build()
->where(['uuid'=>$user['uuid']])
->field(['password','is_banned'],true)
->find();
if($companys['info']['user_info']['type']==2 and $companys['info']['user_info']['account_grade']==1){
$companys['info']['user_info']['type']=2;
}
if($companys['info']['user_info']['type']==2 and $companys['info']['user_info']['account_grade']==2){
$companys['info']['user_info']['type']=3;
$companys['info']['user_info']['position'] = \app\api\model\Subaccount::build()->where(['uuid'=>$companys['info']['user_info']['uuid']])->value('position');
}else{
$uuid = uuid();
$bool = self::build()
->insert([
'uuid' => $uuid,
'oauth_id' => $requestData['openid'],
'avatar' => $requestData['avatar'],
'unionid' => $requestData['unionid'],
'wechat_name' => $requestData['wechat_name'],
'create_time' => timeToDate()
]);
$token = UserToken::storeToken($uuid);
$user = self::build()->where(['oauth_id' => $requestData['openid']])->find();
}
return $companys;
Db::commit();
$users['token'] = $token;
$users['user_info'] = $user;
return $users;
}
......
......@@ -15,7 +15,7 @@ return [
// 服务器地址
'hostname' => 'rm-wz9z40fs394wti63aio.mysql.rds.aliyuncs.com',
// 数据库名
'database' => 'zf_union',
'database' => 'hh',
// 用户名
'username' => 'dankal_master',//
// 密码
......
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