ServiceController.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\api\controller;
  15. use app\api\logic\UserGoodsLogic;
  16. use app\common\logic\PaymentLogic;
  17. use app\api\validate\{PayValidate, ServiceValidate, UserGoodsValidate};
  18. use app\api\logic\ServiceLogic;
  19. use app\api\lists\service\ServiceLists;
  20. /**
  21. * 服务商管理
  22. * Class LoginController
  23. * @package app\api\controller
  24. */
  25. class ServiceController extends BaseApiController
  26. {
  27. public array $notNeedLogin = ['getServiceList','getAreaList','getCateList','getServiceInfo','autoUpdateStatus'];
  28. /**
  29. * @notes 服务商入住
  30. * @return \think\response\Json
  31. * @author 段誉
  32. * @date 2022/9/7 15:38
  33. */
  34. public function serviceProviderSettled()
  35. {
  36. if($this->request->isPost()) {
  37. $params = (new ServiceValidate())->post()->goCheck('agricultural_machinery_operator');
  38. $userId = $this->userId;
  39. $params['user_id'] = $userId;
  40. $result = ServiceLogic::Settled($params);
  41. if (1 === $result['code']) {
  42. switch ($params['type']){
  43. case 1 :
  44. $type_name = '农机手';
  45. break;
  46. case 2 :
  47. $type_name = '烘干服务';
  48. break ;
  49. case 3 :
  50. $type_name = '飞防服务';
  51. break;
  52. default :
  53. $type_name = '';
  54. break;
  55. }
  56. return $this->success($type_name.'入驻信息添加成功', $result['data'], 1, 1);
  57. }
  58. }else{
  59. return $this->fail('请求方式错误');
  60. }
  61. }
  62. public function getAreaList(){
  63. $get = $this->request->get();
  64. $result = ServiceLogic::getsAreaLists($get);
  65. return $this->data($result);
  66. }
  67. public function getCateList(){
  68. $params = (new ServiceValidate())->get()->goCheck('cate');
  69. $result = ServiceLogic::getsCateLists($params);
  70. return $this->data($result);
  71. }
  72. /**
  73. * @notes 服务商列表
  74. * @return \think\response\Json
  75. * @author 段誉
  76. * @date 2022/9/7 15:38
  77. */
  78. public function getServiceList()
  79. {
  80. return $this->dataLists(new ServiceLists());
  81. }
  82. /**
  83. * @notes 查询服务商信息
  84. * @return \think\response\Json
  85. * @author 段誉
  86. * @date 2022/9/7 15:38
  87. */
  88. public function getServiceInfo()
  89. {
  90. $params = (new ServiceValidate())->get()->goCheck('info');
  91. $result = ServiceLogic::getInfo($params,$this->userId);
  92. if ($result === false) {
  93. return $this->fail(PaymentLogic::getError());
  94. }
  95. return $this->data($result);
  96. }
  97. /*
  98. * 服务商续费
  99. * */
  100. public function serviceRenew(){
  101. if($this->request->isPost()) {
  102. $params = (new ServiceValidate())->post()->goCheck('serviceRenew');
  103. $userId = $this->userId;
  104. $params['user_id'] = $userId;
  105. $result = ServiceLogic::Renew($params);
  106. if (1 === $result['code']) {
  107. switch ($params['type']){
  108. case 1 :
  109. $type_name = '农机手';
  110. break;
  111. case 2 :
  112. $type_name = '烘干服务';
  113. break ;
  114. case 3 :
  115. $type_name = '飞防服务';
  116. break;
  117. default :
  118. $type_name = '';
  119. break;
  120. }
  121. return $this->success($type_name.'续费信息生成成功', $result['data'], 1, 1);
  122. }
  123. return $this->fail(ServiceLogic::getError());
  124. }else{
  125. return $this->fail('请求方式错误');
  126. }
  127. }
  128. public function autoUpdateStatus(){
  129. $result = ServiceLogic::updateServiceStatus();
  130. return $this->success($result, [], 1, 1);
  131. }
  132. }