UserServiceController.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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\adminapi\controller\agricultural_machinery;
  15. use app\adminapi\controller\BaseAdminController;
  16. use app\adminapi\lists\agricultural_machinery\AgriculturalMachineryCategoryLists;
  17. use app\adminapi\lists\agricultural_machinery\UserServiceLists;
  18. use app\adminapi\logic\agricultural_machinery\AgriculturalMachineryServiceCategoryLogic;
  19. use app\adminapi\validate\agricultural_machinery\AgriculturalMachineryServiceCategoryValidate;
  20. use app\adminapi\validate\agricultural_machinery\UserServiceValidate;
  21. use app\adminapi\logic\agricultural_machinery\UserServiceLogic;
  22. use app\api\logic\ServiceLogic;
  23. use app\api\validate\ServiceValidate;
  24. /**
  25. * 社会服务管理控制器
  26. * Class ArticleCateController
  27. * @package app\adminapi\controller\article
  28. */
  29. class UserServiceController extends BaseAdminController
  30. {
  31. /**
  32. * @notes 获取服务列表
  33. * @return \think\response\Json
  34. * @throws \think\db\exception\DataNotFoundException
  35. * @throws \think\db\exception\DbException
  36. * @throws \think\db\exception\ModelNotFoundException
  37. * @author 段誉
  38. * @date 2022/10/13 10:54
  39. */
  40. public function getUserServiceList()
  41. {
  42. $params = (new UserServiceValidate())->get()->goCheck('userService');
  43. return $this->dataLists(new UserServiceLists());
  44. }
  45. /**
  46. * @notes 添加服务商信息
  47. * @return \think\response\Json
  48. * @author heshihu
  49. * @date 2022/2/21 17:31
  50. */
  51. public function addUserService()
  52. {
  53. if($this->request->isPost()) {
  54. $params = (new UserServiceValidate())->post()->goCheck('add');
  55. // $userId = $this->userId;
  56. // $params['user_id'] = $userId;
  57. switch ($params['type']){
  58. case 1 :
  59. $type_name = '农机手';
  60. break;
  61. case 2 :
  62. $type_name = '烘干服务';
  63. break ;
  64. case 3 :
  65. $type_name = '飞防服务';
  66. break;
  67. default :
  68. $type_name = '';
  69. break;
  70. }
  71. $result = UserServiceLogic::add($params,$type_name);
  72. if (1 === $result['code']) {
  73. return $this->success($type_name.'入驻信息添加成功', $result['data'], 1, 1);
  74. }else{
  75. return $this->fail(UserServiceLogic::getError());
  76. }
  77. }else{
  78. return $this->fail('请求方式错误');
  79. }
  80. //
  81. //
  82. // $params = (new UserServiceValidate())->post()->goCheck('add');
  83. // UserServiceLogic::add($params);
  84. // return $this->success('添加成功', [], 1, 1);
  85. }
  86. /**
  87. * @notes 删除服务商
  88. * @return \think\response\Json
  89. * @author heshihu
  90. * @date 2022/2/21 17:52
  91. */
  92. public function delete()
  93. {
  94. $params = (new UserServiceValidate())->post()->goCheck('delete');
  95. UserServiceLogic::delete($params);
  96. return $this->success('删除成功', [], 1, 1);
  97. }
  98. /**
  99. * @notes 服务详情
  100. * @return \think\response\Json
  101. * @author heshihu
  102. * @date 2022/2/21 17:54
  103. */
  104. public function detail()
  105. {
  106. $params = (new UserServiceValidate())->goCheck('detail');
  107. $result = UserServiceLogic::detail($params);
  108. return $this->data($result);
  109. }
  110. /**
  111. * @notes 更改服务商状态
  112. * @return \think\response\Json
  113. * @author heshihu
  114. * @date 2022/2/21 10:15
  115. */
  116. public function updateStatus()
  117. {
  118. $params = (new UserServiceValidate())->post()->goCheck('status');
  119. $result = UserServiceLogic::updateStatus($params);
  120. if (true === $result) {
  121. return $this->success('修改成功', [], 1, 1);
  122. }
  123. return $this->fail(UserServiceLogic::getError());
  124. }
  125. /**
  126. * @notes 获取会员列表
  127. * @return \think\response\Json
  128. * @throws \think\db\exception\DataNotFoundException
  129. * @throws \think\db\exception\DbException
  130. * @throws \think\db\exception\ModelNotFoundException
  131. * @author 段誉
  132. * @date 2022/10/13 10:54
  133. */
  134. public function getUserList()
  135. {
  136. $result = UserServiceLogic::getValidUserData();
  137. return $this->data($result);
  138. }
  139. /**
  140. * @notes 获取W服务信息
  141. * @return \think\response\Json
  142. * @throws \think\db\exception\DataNotFoundException
  143. * @throws \think\db\exception\DbException
  144. * @throws \think\db\exception\ModelNotFoundException
  145. * @author 段誉
  146. * @date 2022/10/13 10:54
  147. */
  148. public function getServiceContent()
  149. {
  150. $result = UserServiceLogic::getServiceContent();
  151. return $this->data($result);
  152. }
  153. public function editServiceContent()
  154. {
  155. $params = (new UserServiceValidate())->post()->goCheck('editContent');
  156. $result = UserServiceLogic::saveServiceContent($params);
  157. if (true === $result) {
  158. return $this->success('保存成功', [], 1, 1);
  159. }
  160. return $this->fail(UserServiceLogic::getError());
  161. }
  162. }