| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace app\api\controller\notify;
- use app\adminapi\logic\works\ServiceWorkLogic;
- use app\api\controller\BaseApiController;
- use app\api\validate\UserConfirmValidate;
- use app\common\model\master_worker\MasterWorker;
- use app\common\model\works\ServiceWork;
- use think\Exception;
- /**
- *
- * Class UserConfirmController
- * @package app\api\controller\notify
- */
- class UserConfirmController extends BaseApiController
- {
- public array $notNeedLogin = ['confirmDoor'];
- public function confirmDoor()
- {
- $params = (new UserConfirmValidate())->post()->goCheck('confirmDoor');
- try {
- $work_sn = decrypt($params['code'], \think\facade\Config::get('project.work_sn_key'));
- $work = ServiceWork::where(['work_sn'=>$work_sn,'mobile'=>$params['phone']])->findOrEmpty();
- if($work->isEmpty()){
- throw new Exception('工单不存在');
- }
- $params['user_id'] = $work['master_worker_id'];//工程师信息
- $params['user_info'] = MasterWorker::where('id',$work['master_worker_id'])->field('worker_number,real_name')->findOrEmpty();//工程师信息
- $params['work_sn'] = $work_sn;
- $result = ServiceWorkLogic::confirmDoor($params);
- if (false === $result) {
- throw new Exception(ServiceWorkLogic::getError());
- }
- }catch (\Exception $e){
- return $this->fail($e->getMessage());
- }
- return $this->success('已确认上门');
- }
- }
|