123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- namespace app\admin\controller;
- use app\data\model\DataShipyard;
- use app\data\model\DataShipyard as Model;
- use app\data\model\DataUser;
- use Carbon\Carbon;
- use think\admin\Controller;
- use app\data\model\SystemUser;
- use think\admin\service\AdminService;
- use think\facade\Db;
- /**
- * 船厂管理
- * Class Xw
- * @package app\admin\controller\ShipYard
- * http://www.zjnk.com/fileserver/News/04b7854f-bb0a-458b-b359-ce948acfea09.JPG
- */
- class ShipYard extends Controller
- {
- /**
- * 船厂审核管理
- * @auth true
- * @menu true
- */
- public function index(){
- $this->title='船厂管理';
- if(AdminService::getUserId()==10000){
- $admin_id = [];
- }
- else{
- $admin_id['id']=SystemUser::mk()->where('id',AdminService::getUserId())->value('link_id');
- }
- $this->assign('status',Model::getStatus());
- Model::mQuery()
- ->like('name')
- ->equal('audit')
- ->where($admin_id)
- ->dateBetween('create_at')
- ->layTable();
- }
- /**
- * 船厂审核详情
- * @auth true
- * @menu true
- */
- public function audit_detail($id){
- $row=Model::with(['user'])->find($id);
- $this->assign('row',$row);
- $this->fetch('form');
- }
- /**
- * 船厂审核
- * @auth true
- * @menu true
- */
- public function audit($id){
- $data=$this->_vali([
- 'audit.require'=>'结果必须',
- 'audit.in:2,3'=>'审核结果有误',
- 'why.requireIf:audit,3'=>'原因必须',
- ]);
- $row=Model::find($id);
- $row->startTrans();
- if($row['audit']!=1){
- $this->error('该信息已审核');
- }
- $row['audit']=$data['audit'];
- $row['why']=$data['why'];
- $row['audit_at']=Carbon::now()->toDateTimeString();
- $row->save();
- if($row['audit']==2){
- #创建账号
- SystemUser::createShipYard($row);
- DataUser::mk()->where('id',$row['uuid'])->update(['is_shipyard'=>1]);
- //极光推送
- $content = '您申请加入船厂信息已通过申请,请及时查看';
- }elseif ($data['audit']==3){
- //极光推送
- $content = '您申请加入船厂信息未通过申请,请及时查看';
- }
- $alias = DataUser::mk()->where('id',$row['uuid'])->value('jgalias');
- if(!empty(getAliasDevices($alias)['body']['registration_ids'])){
- $alias ? jgpush($content,$alias) : '';
- }
- setusermessage($row['uuid'],'审核通知',$content);
- $row->commit();
- $this->success('审核成功');
- }
- /**
- * 维护船厂
- */
- public function edit(){
- DataShipyard::mForm('edit');
- }
- public function _form_filter($vo){
- if ($this->request->isGet()) {
- if (isset($vo['id'])){
- $this->assign('vo',$vo);
- $this->fetch('edit');
- }
- }elseif ($this->request->isPost()){
- // $vo['environment_imgs'] = implode(',',explode('|',$vo['environment_imgs']));
- // $vo['audit'] =2;
- // print_r($vo);
- $vo['create_at']=Carbon::now()->toDateTimeString();
- $vo['update_at'] = date('Y-m-d H:i:s');
- unset($vo['pos']);
- isset($vo['id']) ? DataShipyard::mk()->where('id',$vo['id'])->update($vo) : '';
- $this->success('数据更新成功',$vo);
- }
- }
- }
|