UserServiceController.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. public array $notNeedLogin = ['getUserServiceData'];
  32. /**
  33. * @notes 获取服务列表
  34. * @return \think\response\Json
  35. * @throws \think\db\exception\DataNotFoundException
  36. * @throws \think\db\exception\DbException
  37. * @throws \think\db\exception\ModelNotFoundException
  38. * @author 段誉
  39. * @date 2022/10/13 10:54
  40. */
  41. public function getUserServiceList()
  42. {
  43. $params = (new UserServiceValidate())->get()->goCheck('userService');
  44. return $this->dataLists(new UserServiceLists());
  45. }
  46. /**
  47. * @notes 添加服务商信息
  48. * @return \think\response\Json
  49. * @author heshihu
  50. * @date 2022/2/21 17:31
  51. */
  52. public function addUserService()
  53. {
  54. if($this->request->isPost()) {
  55. $params = (new UserServiceValidate())->post()->goCheck('add');
  56. // $userId = $this->userId;
  57. // $params['user_id'] = $userId;
  58. switch ($params['type']){
  59. case 1 :
  60. $type_name = '农机手';
  61. break;
  62. case 2 :
  63. $type_name = '烘干服务';
  64. break ;
  65. case 3 :
  66. $type_name = '飞防服务';
  67. break;
  68. default :
  69. $type_name = '';
  70. break;
  71. }
  72. $result = UserServiceLogic::add($params,$type_name);
  73. if (1 === $result['code']) {
  74. return $this->success($type_name.'入驻信息添加成功', $result['data'], 1, 1);
  75. }else{
  76. return $this->fail(UserServiceLogic::getError());
  77. }
  78. }else{
  79. return $this->fail('请求方式错误');
  80. }
  81. //
  82. //
  83. // $params = (new UserServiceValidate())->post()->goCheck('add');
  84. // UserServiceLogic::add($params);
  85. // return $this->success('添加成功', [], 1, 1);
  86. }
  87. /**
  88. * @notes 删除服务商
  89. * @return \think\response\Json
  90. * @author heshihu
  91. * @date 2022/2/21 17:52
  92. */
  93. public function delete()
  94. {
  95. $params = (new UserServiceValidate())->post()->goCheck('delete');
  96. UserServiceLogic::delete($params);
  97. return $this->success('删除成功', [], 1, 1);
  98. }
  99. /**
  100. * @notes 服务详情
  101. * @return \think\response\Json
  102. * @author heshihu
  103. * @date 2022/2/21 17:54
  104. */
  105. public function detail()
  106. {
  107. $params = (new UserServiceValidate())->goCheck('detail');
  108. $result = UserServiceLogic::detail($params);
  109. return $this->data($result);
  110. }
  111. /**
  112. * @notes 更改服务商状态
  113. * @return \think\response\Json
  114. * @author heshihu
  115. * @date 2022/2/21 10:15
  116. */
  117. public function updateStatus()
  118. {
  119. $params = (new UserServiceValidate())->post()->goCheck('status');
  120. $result = UserServiceLogic::updateStatus($params);
  121. if (true === $result) {
  122. return $this->success('修改成功', [], 1, 1);
  123. }
  124. return $this->fail(UserServiceLogic::getError());
  125. }
  126. /**
  127. * @notes 服务商审核
  128. * @return \think\response\Json
  129. * @author heshihu
  130. * @date 2022/2/21 10:15
  131. */
  132. public function auditUserService()
  133. {
  134. $params = (new UserServiceValidate())->post()->goCheck('audit');
  135. $params['user_id'] = $this->adminId;
  136. $result = UserServiceLogic::auditUserService($params);
  137. if (true === $result) {
  138. return $this->success('操作成功', [], 1, 1);
  139. }
  140. return $this->fail(UserServiceLogic::getError());
  141. }
  142. /**
  143. * @notes 获取会员列表
  144. * @return \think\response\Json
  145. * @throws \think\db\exception\DataNotFoundException
  146. * @throws \think\db\exception\DbException
  147. * @throws \think\db\exception\ModelNotFoundException
  148. * @author 段誉
  149. * @date 2022/10/13 10:54
  150. */
  151. public function getUserList()
  152. {
  153. $result = UserServiceLogic::getValidUserData();
  154. return $this->data($result);
  155. }
  156. /**
  157. * @notes 获取W服务信息
  158. * @return \think\response\Json
  159. * @throws \think\db\exception\DataNotFoundException
  160. * @throws \think\db\exception\DbException
  161. * @throws \think\db\exception\ModelNotFoundException
  162. * @author 段誉
  163. * @date 2022/10/13 10:54
  164. */
  165. public function getServiceContent()
  166. {
  167. $result = UserServiceLogic::getServiceContent();
  168. return $this->data($result);
  169. }
  170. public function editServiceContent()
  171. {
  172. $params = (new UserServiceValidate())->post()->goCheck('editContent');
  173. $result = UserServiceLogic::saveServiceContent($params);
  174. if (true === $result) {
  175. return $this->success('保存成功', [], 1, 1);
  176. }
  177. return $this->fail(UserServiceLogic::getError());
  178. }
  179. public function getUserServiceData(){
  180. $result = UserServiceLogic::getServiceList();
  181. return $this->success('查询成功', $result, 1, 1);
  182. }
  183. public function getServiceDisclaimer()
  184. {
  185. $result = UserServiceLogic::getServiceDisclaimer();
  186. return $this->data($result);
  187. }
  188. public function editServiceDisclaimer()
  189. {
  190. $params = (new UserServiceValidate())->post()->goCheck('disclaimer');
  191. $result = UserServiceLogic::saveServiceDisclaimer($params);
  192. if (true === $result) {
  193. return $this->success('保存成功', [], 1, 1);
  194. }
  195. return $this->fail(UserServiceLogic::getError());
  196. }
  197. }