UserConfirmController.php 1.7 KB

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