UserConfirmController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\api\controller\notify;
  3. use app\adminapi\logic\works\ServiceWorkLogic;
  4. use app\api\controller\BaseApiController;
  5. use app\api\validate\UserConfirmValidate;
  6. use app\common\model\master_worker\MasterWorker;
  7. use app\common\model\works\ServiceWork;
  8. use think\Exception;
  9. /**
  10. *
  11. * Class UserConfirmController
  12. * @package app\api\controller\notify
  13. */
  14. class UserConfirmController extends BaseApiController
  15. {
  16. public array $notNeedLogin = ['confirmDoor'];
  17. public function confirmDoor()
  18. {
  19. $params = (new UserConfirmValidate())->post()->goCheck('confirmDoor');
  20. try {
  21. $work_sn = decrypt($params['code'], \think\facade\Config::get('project.work_sn_key'));
  22. $work = ServiceWork::where(['work_sn'=>$work_sn,'mobile'=>$params['phone']])->findOrEmpty();
  23. if($work->isEmpty()){
  24. throw new Exception('工单不存在');
  25. }
  26. $params['user_id'] = $work['master_worker_id'];//工程师信息
  27. $params['user_info'] = MasterWorker::where('id',$work['master_worker_id'])->field('worker_number,real_name')->findOrEmpty();//工程师信息
  28. $params['work_sn'] = $work_sn;
  29. $result = ServiceWorkLogic::confirmDoor($params);
  30. if (false === $result) {
  31. throw new Exception(ServiceWorkLogic::getError());
  32. }
  33. }catch (\Exception $e){
  34. return $this->fail($e->getMessage());
  35. }
  36. return $this->success('已确认上门');
  37. }
  38. }