UserConfirmController.php 1.8 KB

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