| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- <?php
- // +----------------------------------------------------------------------
- // | likeadmin快速开发前后端分离管理后台(PHP版)
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | 开源版本可自由商用,可去除界面版权logo
- // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
- // | github下载:https://github.com/likeshop-github/likeadmin
- // | 访问官网:https://www.likeadmin.cn
- // | likeadmin团队 版权所有 拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: likeadminTeam
- // +----------------------------------------------------------------------
- namespace app\api\controller;
- use app\api\logic\UserGoodsLogic;
- use app\common\logic\PaymentLogic;
- use app\common\service\ConfigService;
- use app\api\validate\{PayValidate, ServiceValidate, UserGoodsValidate};
- use app\api\logic\ServiceLogic;
- use app\api\lists\service\ServiceLists;
- /**
- * 服务商管理
- * Class LoginController
- * @package app\api\controller
- */
- class ServiceController extends BaseApiController
- {
- public array $notNeedLogin = ['getServiceList','getAreaList','getCateList','getServiceInfo','autoUpdateStatus','getServiceContent','getServiceDisclaimer','addScanLog'];
- /**
- * @notes 服务商入住
- * @return \think\response\Json
- * @author 段誉
- * @date 2022/9/7 15:38
- */
- public function serviceProviderSettled()
- {
- if($this->request->isPost()) {
- $params = (new ServiceValidate())->post()->goCheck('agricultural_machinery_operator');
- $userId = $this->userId;
- $params['user_id'] = $userId;
- $result = ServiceLogic::Settled($params);
- if (1 === $result['code']) {
- switch ($params['type']){
- case 1 :
- $type_name = '农机手';
- break;
- case 2 :
- $type_name = '烘干服务';
- break ;
- case 3 :
- $type_name = '飞防服务';
- break;
- default :
- $type_name = '';
- break;
- }
- return $this->success($type_name.'入驻信息添加成功', $result['data'], 1, 1);
- }
- }else{
- return $this->fail('请求方式错误');
- }
- }
- public function getAreaList(){
- $get = $this->request->get();
- $result = ServiceLogic::getsAreaLists($get);
- return $this->data($result);
- }
- public function getCateList(){
- $params = (new ServiceValidate())->get()->goCheck('cate');
- $result = ServiceLogic::getsCateLists($params);
- return $this->data($result);
- }
- /**
- * @notes 服务商列表
- * @return \think\response\Json
- * @author 段誉
- * @date 2022/9/7 15:38
- */
- public function getServiceList()
- {
- return $this->dataLists(new ServiceLists());
- }
- /**
- * @notes 查询服务商信息
- * @return \think\response\Json
- * @author 段誉
- * @date 2022/9/7 15:38
- */
- public function getServiceInfo()
- {
- $params = (new ServiceValidate())->get()->goCheck('info');
- $result = ServiceLogic::getInfo($params,$this->userId);
- if ($result === false) {
- return $this->fail(ServiceLogic::getError());
- }
- return $this->data($result);
- }
- /*
- * 服务商续费
- * */
- public function serviceRenew(){
- if($this->request->isPost()) {
- $params = (new ServiceValidate())->post()->goCheck('serviceRenew');
- $userId = $this->userId;
- $params['user_id'] = $userId;
- $result = ServiceLogic::Renew($params);
- if (1 === $result['code']) {
- switch ($params['type']){
- case 1 :
- $type_name = '农机手';
- break;
- case 2 :
- $type_name = '烘干服务';
- break ;
- case 3 :
- $type_name = '飞防服务';
- break;
- default :
- $type_name = '';
- break;
- }
- return $this->success($type_name.'续费信息生成成功', $result['data'], 1, 1);
- }
- return $this->fail(ServiceLogic::getError());
- }else{
- return $this->fail('请求方式错误');
- }
- }
- public function autoUpdateStatus(){
- $result = ServiceLogic::updateServiceStatus();
- return $this->success($result, [], 1, 1);
- }
- public function getServiceContent()
- {
- $result = ServiceLogic::getServiceContentInfo();
- if ($result === false) {
- return $this->fail(ServiceLogic::getError());
- }
- return $this->data($result);
- }
- public function getUserServiceInfo(){
- $userId = $this->userId;
- $result = ServiceLogic::getUserServiceInfo($userId);
- if ($result === false) {
- return $this->fail(ServiceLogic::getError());
- }
- return $this->data($result);
- }
- public function getServiceDisclaimer()
- {
- $result = ServiceLogic::getServiceDisclaimer();
- return $this->data($result);
- }
- public function addScanLog(){
- if($this->request->isPost()) {
- $params = (new ServiceValidate())->post()->goCheck('log');
- $userId = $this->userId;
- $params['user_id'] = $userId;
- $result = ServiceLogic::addLog($params);
- if (true === $result) {
- return $this->success('日志插入成功', [], 1, 1);
- }
- return $this->fail(ServiceLogic::getError());
- }else{
- return $this->fail('请求方式错误');
- }
- }
- }
|