| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370 |
- <?php
- namespace app\api\controller;
- use app\adminapi\logic\master_worker\MasterWorkerLogic;
- use app\adminapi\logic\works\ServiceWorkLogic;
- use app\api\lists\recharge\ServiceOrderLists;
- use app\api\logic\ActivityLogic;
- use app\api\logic\ServiceOrderLogic;
- use app\api\validate\ServiceOrderValidate;
- use app\common\model\works\ServiceWorkAppointmentLog;
- use Exception;
- use think\facade\Log;
- /**
- * 订单类
- */
- class ServiceOrderController extends BaseApiController
- {
- /**
- * 订单列表
- * @return \think\response\Json
- */
- public function lists()
- {
- return $this->dataLists(new ServiceOrderLists());
- }
- /**
- * 订单详情
- * @return \think\response\Json
- */
- public function detail()
- {
- $params = (new ServiceOrderValidate())->goCheck('detail',[
- 'user_id' => $this->userId,
- 'user_info' => $this->userInfo,
- 'domain'=>$this->request->domain()
- ]);
- $result = ServiceOrderLogic::detail($params);
- if (false === $result) {
- return $this->fail(ServiceOrderLogic::getError());
- }
- return $this->data($result);
- }
- public function getDetailStatus()
- {
- $params = (new ServiceOrderValidate())->goCheck('detail',[
- 'user_id' => $this->userId,
- ]);
- $result = ServiceOrderLogic::getDetailStatus($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());
- }
- ActivityLogic::createPropertyOrder($params,$result);
- 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());
- }
- 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());
- }
- // 订单完成通知【给用户】 - 全款 -通知
- ServiceOrderLogic::serviceFinishNotice($params);
- // 工程师完单的时候设置该规则关闭,以及短信通知工程师
- ServiceOrderLogic::orderQuantityRule($params);
- 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());
- }
- return $this->success('已提交改约', [], 1, 1);
- }
- /**
- * 提交退款申请
- * @return \think\response\Json
- */
- public function approvalRefund()
- {
- $params = (new ServiceOrderValidate())->post()->goCheck('changePrice', [
- 'user_id' => $this->userId,
- 'user_info' => $this->userInfo
- ]);
- $result = ServiceOrderLogic::approvalRefund($params);
- if (false === $result) {
- return $this->fail(ServiceOrderLogic::getError());
- }
- return $this->success('已提交申请,等待客服确认中', [], 1, 1);
- }
- public function firmOrderLists()
- {
- return $this->dataLists(new ServiceOrderLists());
- }
- public function firmOrderSave()
- {
- $params = (new ServiceOrderValidate())->post()->goCheck('firmOrderSave', [
- 'user_id' => $this->userId,
- 'terminal' => $this->userInfo['terminal'],
- 'user_info' => $this->userInfo
- ]);
- Log::write(json_encode($params,JSON_UNESCAPED_UNICODE));
- if(count($params['order_goods']) == 0){
- return $this->fail('请选择商品');
- }else{
- $params['goods_id'] = $params['order_goods'][0]['id'];
- }
- $result = ServiceOrderLogic::firmSubmitOrder($params);
- if (false === $result) {
- return $this->fail(ServiceOrderLogic::getError());
- }
- return $this->data($result);
- }
- /**
- * 绑定工程师-设置为加单
- * @return \think\response\Json
- */
- public function bindWorkerAndWork()
- {
- $params = (new ServiceOrderValidate())->post()->goCheck('bindWorkerAndWork', [
- 'user_id' => $this->userId,
- 'user_info' => $this->userInfo
- ]);
- $result = ServiceOrderLogic::bindWorkerAndWork($params);
- if (false === $result) {
- return $this->fail(ServiceOrderLogic::getError());
- }
- return $this->success('绑定成功', [], 1, 1);
- }
- /**
- * 终止结束服务 - 上门费直接给工程师
- * @return \think\response\Json
- * @author liugc <466014217@qq.com>
- * @date 2025/5/5 19:03
- */
- public function terminateService()
- {
- $params = (new ServiceOrderValidate())->post()->goCheck('terminateService', [
- 'user_id' => $this->userId,
- 'user_info' => $this->userInfo
- ]);
- $params['isearnest'] = 0;
- $result = ServiceWorkLogic::terminateService($params);
- if (false === $result) {
- return $this->fail(ServiceWorkLogic::getError());
- }
- return $this->success('终止服务成功', [], 1, 1);
- }
- /**
- * 获取工单需支付信息
- * @return \think\response\Json
- * @author liugc <466014217@qq.com>
- * @date 2025/5/7 15:08
- */
- public function shareFixedAmountToNative()
- {
- try {
- $params = request()->post();
- $result = ServiceWorkLogic::shareFixedAmountToNative($params);
- if (false === $result) {
- return $this->fail(ServiceWorkLogic::getError());
- }
- return $this->success('', $result, 1, 1);
- } catch (Exception $e) {
- return $this->fail($e->getMessage());
- }
- }
- /**
- * 扫码分享的工单 - 获取工单信息
- * @return \think\response\Json
- * @author liugc <466014217@qq.com>
- * @date 2025/5/7 15:08
- */
- public function shareServiceWorkDetail()
- {
- try {
- $params = request()->post();
- $result = ServiceWorkLogic::shareServiceWorkDetail($params);
- return $this->data($result);
- } catch (Exception $e) {
- return $this->fail($e->getMessage());
- }
- }
- }
|