UserServiceController.php 7.5 KB

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