dataLists(new ServiceOrderLists()); } /** * 订单详情 * @return \think\response\Json */ public function detail() { $params = (new ServiceOrderValidate())->goCheck('detail',[ 'user_id' => $this->userId, ]); $result = ServiceOrderLogic::detail($params); if (false === $result) { return $this->fail(ServiceOrderLogic::getError()); } return $this->data($result); } /** * 订单支付详情 * @return \think\response\Json */ public function orderPayInfo() { $params = (new ServiceOrderValidate())->goCheck('detail',[ 'user_id' => $this->userId, ]); $result = ServiceOrderLogic::orderPayInfo($params); if (false === $result) { return $this->fail(ServiceOrderLogic::getError()); } return $this->data($result); } public function getMasterWorker() { $params = (new ServiceOrderValidate())->goCheck('worker',[ 'user_id' => $this->userId, ]); $result = ServiceOrderLogic::getMasterWorker($params); if (false === $result) { return $this->fail(ServiceOrderLogic::getError()); } return $this->data($result); } /** * 提交订单 * @return \think\response\Json */ public function submitOrder() { $params = (new ServiceOrderValidate())->post()->goCheck('add', [ 'user_id' => $this->userId, 'terminal' => $this->userInfo['terminal'], 'user_info' => $this->userInfo ]); Log::write(json_encode($params,JSON_UNESCAPED_UNICODE)); $result = ServiceOrderLogic::submitOrder($params); if (false === $result) { return $this->fail(ServiceOrderLogic::getError()); } // 用户下单后,给订单运营专员(配置固定ID)发送公众号提醒(订单信息) $workDetail = ServiceWorkLogic::detail(['id'=>$result['work_id']]); $res = event('Notice', [ 'scene_id' => 100, 'params' => [ 'user_id' => 0, 'thing3' => $workDetail['title'], 'time6' => $workDetail['appointment_time'], 'phone_number8' => $workDetail['mobile'], ] ]); return $this->data($result); } /** * 取消订单 * @return \think\response\Json */ public function cancelOrder() { $params = (new ServiceOrderValidate())->post()->goCheck('cancel', [ 'user_id' => $this->userId, 'terminal' => $this->userInfo['terminal'], 'user_info' => $this->userInfo ]); $result = ServiceOrderLogic::cancelOrder($params); if (false === $result) { return $this->fail(ServiceOrderLogic::getError()); } // 订单取消通知【给用户】 $res = event('Notice', [ 'scene_id' => 122, 'params' => [ 'user_id' => $params['user_id'] ] ]); return $this->success('取消成功', [], 1, 1); } /** * 确认报价订单 * @return \think\response\Json */ public function confirmOrder() { $params = (new ServiceOrderValidate())->post()->goCheck('price', [ 'user_id' => $this->userId, 'user_info' => $this->userInfo ]); $result = ServiceOrderLogic::confirmOrder($params); if (false === $result) { return $this->fail(ServiceOrderLogic::getError()); } return $this->success('已确认报价,工程师即将开始服务', [], 1, 1); } /** * 用户确认服务完成 * @return \think\response\Json */ public function confirmServiceFinish() { $params = (new ServiceOrderValidate())->post()->goCheck('finished', [ 'user_id' => $this->userId, 'user_info' => $this->userInfo ]); $result = ServiceOrderLogic::confirmServiceFinish($params); if (false === $result) { return $this->fail(ServiceOrderLogic::getError()); } // 订单完成通知【给用户】 $res = event('Notice', [ 'scene_id' => 120, 'params' => [ 'user_id' => $params['user_id'] ] ]); return $this->success('已确认服务完成', [], 1, 1); } /** * 提交尾款订单 * @return \think\response\Json */ public function submitFinalOrder() { $params = (new ServiceOrderValidate())->post()->goCheck('final', [ 'user_id' => $this->userId, 'terminal' => $this->userInfo['terminal'], 'user_info' => $this->userInfo ]); Log::write(json_encode($params,JSON_UNESCAPED_UNICODE)); $result = ServiceOrderLogic::submitFinalOrder($params); if (false === $result) { return $this->fail(ServiceOrderLogic::getError()); } return $this->data($result); } /** * 重置订单优惠券 * @return \think\response\Json */ public function cancelOrderCoupon() { $params = (new ServiceOrderValidate())->post()->goCheck('cancelOrderCoupon', [ 'user_id' => $this->userId, 'user_info' => $this->userInfo ]); $result = ServiceOrderLogic::cancelOrderCoupon($params); if (false === $result) { return $this->fail(ServiceOrderLogic::getError()); } return $this->success('保存成功', [], 1, 1); } /** * 查询是否在服务区内 * @return \think\response\Json */ public function isServiceWithin() { $params = (new ServiceOrderValidate())->get()->goCheck('LonLat', [ 'user_id' => $this->userId, 'user_info' => $this->userInfo ]); $result = ServiceOrderLogic::isService($params); if (false === $result) { return $this->fail(ServiceOrderLogic::getError(),['is_service'=>0]); } return $this->success('服务区域内', ['is_service'=>1], 1, 1); } /** * 申请改价 * @return \think\response\Json */ public function approvalChangePrice() { $params = (new ServiceOrderValidate())->post()->goCheck('changePrice', [ 'user_id' => $this->userId, 'user_info' => $this->userInfo ]); $result = ServiceOrderLogic::approvalChangePrice($params); if (false === $result) { return $this->fail(ServiceOrderLogic::getError()); } return $this->success('已提交改价申请,等待工程师确认', [], 1, 1); } /** * 申请改约 * @return \think\response\Json */ public function approvalChangeAppointment() { $params = (new ServiceOrderValidate())->post()->goCheck('changeAppointment', [ 'user_id' => $this->userId, 'user_info' => $this->userInfo ]); $result = ServiceOrderLogic::approvalChangeAppointment($params); if (false === $result) { return $this->fail(ServiceOrderLogic::getError()); } $order = ServiceOrderLogic::orderPayInfo($params); $workDetail = ServiceWorkLogic::detail(['id'=>$order['work_id']]); $masterDetail = MasterWorkerLogic::detail(['id'=>$workDetail['master_worker_id']]); // 修改预约时间通知【给用户的通知】 $res = event('Notice', [ 'scene_id' => 117, 'params' => [ 'user_id' => $workDetail['user_id'], 'date' => $params['appointment_time'], 'tel' => $masterDetail['mobile'], ] ]); // 修改预约时间通知【给工程师的通知,仅限公众号】 $res = event('Notice', [ 'scene_id' => 118, 'params' => [ 'user_id' => $workDetail['master_worker_id'], 'thing4' => $workDetail['title'], 'time5' => $workDetail['appointment_time'], 'time6' => $params['appointment_time'], 'thing11' => $workDetail['address'], 'phone_number8' => $workDetail['mobile'], ] ]); return $this->success('已提交改约', [], 1, 1); } }