UserServiceController.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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 17:31
  117. */
  118. public function editUserService()
  119. {
  120. if($this->request->isPost()) {
  121. $params = (new UserServiceValidate())->post()->goCheck('editUserService');
  122. // $userId = $this->userId;
  123. // $params['user_id'] = $userId;
  124. switch ($params['type']){
  125. case 1 :
  126. $type_name = '农机手';
  127. break;
  128. case 2 :
  129. $type_name = '烘干服务';
  130. break ;
  131. case 3 :
  132. $type_name = '飞防服务';
  133. break;
  134. default :
  135. $type_name = '';
  136. break;
  137. }
  138. $result = UserServiceLogic::edit($params,$type_name);
  139. if (1 === $result['code']) {
  140. return $this->success($type_name.'入驻信息修改成功成功', $result, 1, 1);
  141. }else{
  142. return $this->fail(UserServiceLogic::getError());
  143. }
  144. }else{
  145. return $this->fail('请求方式错误');
  146. }
  147. //
  148. //
  149. // $params = (new UserServiceValidate())->post()->goCheck('add');
  150. // UserServiceLogic::add($params);
  151. // return $this->success('添加成功', [], 1, 1);
  152. }
  153. /**
  154. * @notes 更改服务商状态
  155. * @return \think\response\Json
  156. * @author heshihu
  157. * @date 2022/2/21 10:15
  158. */
  159. public function updateStatus()
  160. {
  161. $params = (new UserServiceValidate())->post()->goCheck('status');
  162. $result = UserServiceLogic::updateStatus($params);
  163. if (true === $result) {
  164. return $this->success('修改成功', [], 1, 1);
  165. }
  166. return $this->fail(UserServiceLogic::getError());
  167. }
  168. /**
  169. * @notes 服务商审核
  170. * @return \think\response\Json
  171. * @author heshihu
  172. * @date 2022/2/21 10:15
  173. */
  174. public function auditUserService()
  175. {
  176. $params = (new UserServiceValidate())->post()->goCheck('audit');
  177. $params['user_id'] = $this->adminId;
  178. $result = UserServiceLogic::auditUserService($params);
  179. if (true === $result) {
  180. return $this->success('操作成功', [], 1, 1);
  181. }
  182. return $this->fail(UserServiceLogic::getError());
  183. }
  184. /**
  185. * @notes 获取会员列表
  186. * @return \think\response\Json
  187. * @throws \think\db\exception\DataNotFoundException
  188. * @throws \think\db\exception\DbException
  189. * @throws \think\db\exception\ModelNotFoundException
  190. * @author 段誉
  191. * @date 2022/10/13 10:54
  192. */
  193. public function getUserList()
  194. {
  195. $result = UserServiceLogic::getValidUserData();
  196. return $this->data($result);
  197. }
  198. /**
  199. * @notes 获取W服务信息
  200. * @return \think\response\Json
  201. * @throws \think\db\exception\DataNotFoundException
  202. * @throws \think\db\exception\DbException
  203. * @throws \think\db\exception\ModelNotFoundException
  204. * @author 段誉
  205. * @date 2022/10/13 10:54
  206. */
  207. public function getServiceContent()
  208. {
  209. $result = UserServiceLogic::getServiceContent();
  210. return $this->data($result);
  211. }
  212. public function editServiceContent()
  213. {
  214. $params = (new UserServiceValidate())->post()->goCheck('editContent');
  215. $result = UserServiceLogic::saveServiceContent($params);
  216. if (true === $result) {
  217. return $this->success('保存成功', [], 1, 1);
  218. }
  219. return $this->fail(UserServiceLogic::getError());
  220. }
  221. public function getUserServiceData(){
  222. $result = UserServiceLogic::getServiceList();
  223. return $this->success('查询成功', $result, 1, 1);
  224. }
  225. public function getServiceDisclaimer()
  226. {
  227. $result = UserServiceLogic::getServiceDisclaimer();
  228. return $this->data($result);
  229. }
  230. public function editServiceDisclaimer()
  231. {
  232. $params = (new UserServiceValidate())->post()->goCheck('disclaimer');
  233. $result = UserServiceLogic::saveServiceDisclaimer($params);
  234. if (true === $result) {
  235. return $this->success('保存成功', [], 1, 1);
  236. }
  237. return $this->fail(UserServiceLogic::getError());
  238. }
  239. public function getMechanicalCateList()
  240. {
  241. $params = (new UserServiceValidate())->get()->goCheck('mechanical');
  242. return $this->dataLists(new MechanicalCateLists());
  243. }
  244. /**
  245. * @notes 添加机械分类
  246. * @return \think\response\Json
  247. * @author heshihu
  248. * @date 2022/2/21 17:31
  249. */
  250. public function addMechanicalCate()
  251. {
  252. $params = (new UserServiceValidate())->post()->goCheck('addMechanicalCate');
  253. UserServiceLogic::addMechanicalCate($params);
  254. return $this->success('添加成功', [], 1, 1);
  255. }
  256. /**
  257. * @notes 机械分类详情
  258. * @return \think\response\Json
  259. * @author heshihu
  260. * @date 2022/2/21 17:54
  261. */
  262. public function mechanicalCateDetail()
  263. {
  264. $params = (new UserServiceValidate())->goCheck('cateDetail');
  265. $result = UserServiceLogic::cate_detail($params);
  266. return $this->data($result);
  267. }
  268. public function editMechanicalCate()
  269. {
  270. $params = (new UserServiceValidate())->post()->goCheck('editCate');
  271. $result = UserServiceLogic::editCate($params);
  272. if (true === $result) {
  273. return $this->success('编辑成功', [], 1, 1);
  274. }
  275. return $this->fail(UserServiceLogic::getError());
  276. }
  277. /**
  278. * @notes 删除机械分类
  279. * @return \think\response\Json
  280. * @author heshihu
  281. * @date 2022/2/21 17:52
  282. */
  283. public function deleteCate()
  284. {
  285. $params = (new UserServiceValidate())->post()->goCheck('cateDetail');
  286. UserServiceLogic::deleteCate($params);
  287. return $this->success('删除成功', [], 1, 1);
  288. }
  289. }