ShipYard.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. namespace app\admin\controller;
  3. use app\data\model\DataShipyard;
  4. use app\data\model\DataShipyard as Model;
  5. use app\data\model\DataUser;
  6. use Carbon\Carbon;
  7. use think\admin\Controller;
  8. use app\data\model\SystemUser;
  9. use think\admin\service\AdminService;
  10. use think\facade\Db;
  11. /**
  12. * 船厂管理
  13. * Class Xw
  14. * @package app\admin\controller\ShipYard
  15. * http://www.zjnk.com/fileserver/News/04b7854f-bb0a-458b-b359-ce948acfea09.JPG
  16. */
  17. class ShipYard extends Controller
  18. {
  19. /**
  20. * 船厂审核管理
  21. * @auth true
  22. * @menu true
  23. */
  24. public function index(){
  25. $this->title='船厂管理';
  26. if(AdminService::getUserId()==10000){
  27. $admin_id = [];
  28. }
  29. else{
  30. $admin_id['id']=SystemUser::mk()->where('id',AdminService::getUserId())->value('link_id');
  31. }
  32. $this->assign('status',Model::getStatus());
  33. Model::mQuery()
  34. ->like('name')
  35. ->equal('audit')
  36. ->where($admin_id)
  37. ->dateBetween('create_at')
  38. ->layTable();
  39. }
  40. /**
  41. * 船厂审核详情
  42. * @auth true
  43. * @menu true
  44. */
  45. public function audit_detail($id){
  46. $row=Model::with(['user'])->find($id);
  47. $this->assign('row',$row);
  48. $this->fetch('form');
  49. }
  50. /**
  51. * 船厂审核
  52. * @auth true
  53. * @menu true
  54. */
  55. public function audit($id){
  56. $data=$this->_vali([
  57. 'audit.require'=>'结果必须',
  58. 'audit.in:2,3'=>'审核结果有误',
  59. 'why.requireIf:audit,3'=>'原因必须',
  60. ]);
  61. $row=Model::find($id);
  62. $row->startTrans();
  63. if($row['audit']!=1){
  64. $this->error('该信息已审核');
  65. }
  66. $row['audit']=$data['audit'];
  67. $row['why']=$data['why'];
  68. $row['audit_at']=Carbon::now()->toDateTimeString();
  69. $row->save();
  70. if($row['audit']==2){
  71. #创建账号
  72. SystemUser::createShipYard($row);
  73. DataUser::mk()->where('id',$row['uuid'])->update(['is_shipyard'=>1]);
  74. //极光推送
  75. $content = '您申请加入船厂信息已通过申请,请及时查看';
  76. }elseif ($data['audit']==3){
  77. //极光推送
  78. $content = '您申请加入船厂信息未通过申请,请及时查看';
  79. }
  80. $alias = DataUser::mk()->where('id',$row['uuid'])->value('jgalias');
  81. if(!empty(getAliasDevices($alias)['body']['registration_ids'])){
  82. $alias ? jgpush($content,$alias) : '';
  83. }
  84. setusermessage($row['uuid'],'审核通知',$content);
  85. $row->commit();
  86. $this->success('审核成功');
  87. }
  88. /**
  89. * 维护船厂
  90. */
  91. public function edit(){
  92. DataShipyard::mForm('edit');
  93. }
  94. public function _form_filter($vo){
  95. if ($this->request->isGet()) {
  96. if (isset($vo['id'])){
  97. $this->assign('vo',$vo);
  98. $this->fetch('edit');
  99. }
  100. }elseif ($this->request->isPost()){
  101. // $vo['environment_imgs'] = implode(',',explode('|',$vo['environment_imgs']));
  102. // $vo['audit'] =2;
  103. // print_r($vo);
  104. $vo['create_at']=Carbon::now()->toDateTimeString();
  105. $vo['update_at'] = date('Y-m-d H:i:s');
  106. unset($vo['pos']);
  107. isset($vo['id']) ? DataShipyard::mk()->where('id',$vo['id'])->update($vo) : '';
  108. $this->success('数据更新成功',$vo);
  109. }
  110. }
  111. }