ServiceController.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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\common\service\ConfigService;
  18. use app\api\validate\{PayValidate, ServiceValidate, UserGoodsValidate};
  19. use app\api\logic\ServiceLogic;
  20. use app\api\lists\service\ServiceLists;
  21. /**
  22. * 服务商管理
  23. * Class LoginController
  24. * @package app\api\controller
  25. */
  26. class ServiceController extends BaseApiController
  27. {
  28. public array $notNeedLogin = ['getServiceList','getAreaList','getCateList','getServiceInfo','autoUpdateStatus','getServiceContent','getServiceDisclaimer','addScanLog','getMechanicalCateList'];
  29. /**
  30. * @notes 服务商入住
  31. * @return \think\response\Json
  32. * @author 段誉
  33. * @date 2022/9/7 15:38
  34. */
  35. public function serviceProviderSettled()
  36. {
  37. if($this->request->isPost()) {
  38. $params = (new ServiceValidate())->post()->goCheck('agricultural_machinery_operator');
  39. $userId = $this->userId;
  40. $params['user_id'] = $userId;
  41. $result = ServiceLogic::Settled($params);
  42. if (1 === $result['code']) {
  43. switch ($params['type']){
  44. case 1 :
  45. $type_name = '农机手';
  46. break;
  47. case 2 :
  48. $type_name = '烘干服务';
  49. break ;
  50. case 3 :
  51. $type_name = '飞防服务';
  52. break;
  53. default :
  54. $type_name = '';
  55. break;
  56. }
  57. return $this->success($type_name.'入驻信息添加成功', $result['data'], 1, 1);
  58. }
  59. }else{
  60. return $this->fail('请求方式错误');
  61. }
  62. }
  63. public function getAreaList(){
  64. $get = $this->request->get();
  65. $result = ServiceLogic::getsAreaLists($get);
  66. return $this->data($result);
  67. }
  68. public function getCateList(){
  69. $params = (new ServiceValidate())->get()->goCheck('cate');
  70. $result = ServiceLogic::getsCateLists($params);
  71. return $this->data($result);
  72. }
  73. /**
  74. * @notes 服务商列表
  75. * @return \think\response\Json
  76. * @author 段誉
  77. * @date 2022/9/7 15:38
  78. */
  79. public function getServiceList()
  80. {
  81. return $this->dataLists(new ServiceLists());
  82. }
  83. /**
  84. * @notes 查询服务商信息
  85. * @return \think\response\Json
  86. * @author 段誉
  87. * @date 2022/9/7 15:38
  88. */
  89. public function getServiceInfo()
  90. {
  91. $params = (new ServiceValidate())->get()->goCheck('info');
  92. $result = ServiceLogic::getInfo($params,$this->userId);
  93. if ($result === false) {
  94. return $this->fail(ServiceLogic::getError());
  95. }
  96. return $this->data($result);
  97. }
  98. /*
  99. * 服务商续费
  100. * */
  101. public function serviceRenew(){
  102. if($this->request->isPost()) {
  103. $params = (new ServiceValidate())->post()->goCheck('serviceRenew');
  104. $userId = $this->userId;
  105. $params['user_id'] = $userId;
  106. $result = ServiceLogic::Renew($params);
  107. if (1 === $result['code']) {
  108. switch ($params['type']){
  109. case 1 :
  110. $type_name = '农机手';
  111. break;
  112. case 2 :
  113. $type_name = '烘干服务';
  114. break ;
  115. case 3 :
  116. $type_name = '飞防服务';
  117. break;
  118. default :
  119. $type_name = '';
  120. break;
  121. }
  122. return $this->success($type_name.'续费信息生成成功', $result['data'], 1, 1);
  123. }
  124. return $this->fail(ServiceLogic::getError());
  125. }else{
  126. return $this->fail('请求方式错误');
  127. }
  128. }
  129. public function autoUpdateStatus(){
  130. $result = ServiceLogic::updateServiceStatus();
  131. return $this->success($result, [], 1, 1);
  132. }
  133. public function getServiceContent()
  134. {
  135. $result = ServiceLogic::getServiceContentInfo();
  136. if ($result === false) {
  137. return $this->fail(ServiceLogic::getError());
  138. }
  139. return $this->data($result);
  140. }
  141. public function getUserServiceInfo(){
  142. $userId = $this->userId;
  143. $result = ServiceLogic::getUserServiceInfo($userId);
  144. if ($result === false) {
  145. return $this->fail(ServiceLogic::getError());
  146. }
  147. return $this->data($result);
  148. }
  149. public function getServiceDisclaimer()
  150. {
  151. $result = ServiceLogic::getServiceDisclaimer();
  152. return $this->data($result);
  153. }
  154. public function addScanLog(){
  155. if($this->request->isPost()) {
  156. $params = (new ServiceValidate())->post()->goCheck('log');
  157. $userId = $this->userId;
  158. $params['user_id'] = $userId;
  159. $result = ServiceLogic::addLog($params);
  160. if (true === $result) {
  161. return $this->success('日志插入成功', [], 1, 1);
  162. }
  163. return $this->fail(ServiceLogic::getError());
  164. }else{
  165. return $this->fail('请求方式错误');
  166. }
  167. }
  168. public function getMechanicalCateList(){
  169. $params = (new ServiceValidate())->get()->goCheck('mechanical');
  170. $result = ServiceLogic::getsMechanicalCateLists($params);
  171. return $this->data($result);
  172. }
  173. }