moonsflyer 8 mesiacov pred
rodič
commit
460d464b66

+ 18 - 4
app/adminapi/controller/agricultural_machinery/AgriculturalMachineryCategoryController.php

@@ -15,12 +15,10 @@
 namespace app\adminapi\controller\agricultural_machinery;
 
 use app\adminapi\controller\BaseAdminController;
-use app\adminapi\lists\article\ArticleCateLists;
 use app\adminapi\lists\agricultural_machinery\AgriculturalMachineryCategoryLists;
 use app\adminapi\logic\agricultural_machinery\AgriculturalMachineryServiceCategoryLogic;
 use app\adminapi\validate\agricultural_machinery\AgriculturalMachineryServiceCategoryValidate;
-use app\adminapi\logic\article\ArticleCateLogic;
-use app\adminapi\validate\article\ArticleCateValidate;
+use app\adminapi\validate\agricultural_machinery\UserServiceValidate;
 
 /**
  * 农机服务分类管理控制器
@@ -120,7 +118,7 @@ class AgriculturalMachineryCategoryController extends BaseAdminController
 
 
     /**
-     * @notes 获取农耕分类
+     * @notes 获取有效农耕分类
      * @return \think\response\Json
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
@@ -136,4 +134,20 @@ class AgriculturalMachineryCategoryController extends BaseAdminController
     }
 
 
+    /**
+     * @notes 获取服务列表
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/10/13 10:54
+     */
+    public function getUserServiceList()
+    {
+        $params = (new UserServiceValidate())->get()->goCheck('user_service');
+        $result = AgriculturalMachineryServiceCategoryLogic::getValidCateData($params);
+        return $this->data($result);
+    }
+
 }

+ 143 - 0
app/adminapi/controller/agricultural_machinery/UserServiceController.php

@@ -0,0 +1,143 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\controller\agricultural_machinery;
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\agricultural_machinery\AgriculturalMachineryCategoryLists;
+use app\adminapi\lists\agricultural_machinery\UserServiceLists;
+use app\adminapi\logic\agricultural_machinery\AgriculturalMachineryServiceCategoryLogic;
+use app\adminapi\validate\agricultural_machinery\AgriculturalMachineryServiceCategoryValidate;
+use app\adminapi\validate\agricultural_machinery\UserServiceValidate;
+
+/**
+ * 社会服务管理控制器
+ * Class ArticleCateController
+ * @package app\adminapi\controller\article
+ */
+class UserServiceController extends BaseAdminController
+{
+
+    /**
+     * @notes 获取服务列表
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/10/13 10:54
+     */
+    public function getUserServiceList()
+    {
+        $params = (new UserServiceValidate())->get()->goCheck('userService');
+        return $this->dataLists(new UserServiceLists());
+    }
+
+
+    /**
+     * @notes  添加资讯分类
+     * @return \think\response\Json
+     * @author heshihu
+     * @date 2022/2/21 17:31
+     */
+    public function add()
+    {
+        $params = (new AgriculturalMachineryServiceCategoryValidate())->post()->goCheck('add');
+        AgriculturalMachineryServiceCategoryLogic::add($params);
+        return $this->success('添加成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes  编辑农耕分类
+     * @return \think\response\Json
+     * @author heshihu
+     * @date 2022/2/21 17:49
+     */
+    public function edit()
+    {
+        $params = (new AgriculturalMachineryServiceCategoryValidate())->post()->goCheck('edit');
+        $result = AgriculturalMachineryServiceCategoryLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(AgriculturalMachineryServiceCategoryLogic::getError());
+    }
+
+
+    /**
+     * @notes  删除农耕分类
+     * @return \think\response\Json
+     * @author heshihu
+     * @date 2022/2/21 17:52
+     */
+    public function delete()
+    {
+        $params = (new AgriculturalMachineryServiceCategoryValidate())->post()->goCheck('delete');
+        AgriculturalMachineryServiceCategoryLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes  农耕分类详情
+     * @return \think\response\Json
+     * @author heshihu
+     * @date 2022/2/21 17:54
+     */
+    public function detail()
+    {
+        $params = (new AgriculturalMachineryServiceCategoryValidate())->goCheck('detail');
+        $result = AgriculturalMachineryServiceCategoryLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes  更改农耕分类状态
+     * @return \think\response\Json
+     * @author heshihu
+     * @date 2022/2/21 10:15
+     */
+    public function updateStatus()
+    {
+        $params = (new AgriculturalMachineryServiceCategoryValidate())->post()->goCheck('status');
+        $result = AgriculturalMachineryServiceCategoryLogic::updateStatus($params);
+        if (true === $result) {
+            return $this->success('修改成功', [], 1, 1);
+        }
+        return $this->fail(AgriculturalMachineryServiceCategoryLogic::getError());
+    }
+
+
+    /**
+     * @notes 获取有效农耕分类
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/10/13 10:54
+     */
+    public function getValidCate()
+    {
+        $params = (new AgriculturalMachineryServiceCategoryValidate())->get()->goCheck('list');
+        $result = AgriculturalMachineryServiceCategoryLogic::getValidCateData($params);
+        return $this->data($result);
+    }
+
+
+
+
+}

+ 0 - 99
app/adminapi/lists/agricultural_machinery/ArticleLists.php

@@ -1,99 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeadmin快速开发前后端分离管理后台(PHP版)
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
-// | github下载:https://github.com/likeshop-github/likeadmin
-// | 访问官网:https://www.likeadmin.cn
-// | likeadmin团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeadminTeam
-// +----------------------------------------------------------------------
-
-namespace app\adminapi\lists\article;
-
-use app\adminapi\lists\BaseAdminDataLists;
-use app\common\lists\ListsSearchInterface;
-use app\common\lists\ListsSortInterface;
-use app\common\model\article\Article;
-
-/**
- * 资讯列表
- * Class ArticleLists
- * @package app\adminapi\lists\article
- */
-class ArticleLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface
-{
-
-    /**
-     * @notes  设置搜索条件
-     * @return array
-     * @author heshihu
-     * @date 2022/2/8 18:39
-     */
-    public function setSearch(): array
-    {
-        return [
-            '%like%' => ['title'],
-            '=' => ['cid', 'is_show']
-        ];
-    }
-
-    /**
-     * @notes  设置支持排序字段
-     * @return array
-     * @author heshihu
-     * @date 2022/2/9 15:11
-     */
-    public function setSortFields(): array
-    {
-        return ['create_time' => 'create_time', 'id' => 'id'];
-    }
-
-    /**
-     * @notes  设置默认排序
-     * @return array
-     * @author heshihu
-     * @date 2022/2/9 15:08
-     */
-    public function setDefaultOrder(): array
-    {
-        return ['sort' => 'desc', 'id' => 'desc'];
-    }
-
-    /**
-     * @notes  获取管理列表
-     * @return array
-     * @author heshihu
-     * @date 2022/2/21 17:11
-     */
-    public function lists(): array
-    {
-        $ArticleLists = Article::where($this->searchWhere)
-            ->append(['cate_name', 'click'])
-            ->limit($this->limitOffset, $this->limitLength)
-            ->order($this->sortOrder)
-            ->select()
-            ->toArray();
-
-        return $ArticleLists;
-    }
-
-    /**
-     * @notes  获取数量
-     * @return int
-     * @author heshihu
-     * @date 2022/2/9 15:12
-     */
-    public function count(): int
-    {
-        return Article::where($this->searchWhere)->count();
-    }
-
-    public function extend()
-    {
-        return [];
-    }
-}

+ 130 - 0
app/adminapi/lists/agricultural_machinery/UserServiceLists.php

@@ -0,0 +1,130 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\lists\agricultural_machinery;
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\lists\ListsSearchInterface;
+use app\common\lists\ListsSortInterface;
+use app\common\model\agricultural_machinery\ServiceCategory as AgriculturalMachineryServiceCategory;
+use app\common\model\agricultural_machinery\UserService;
+
+/**
+ * 资讯分类列表
+ * Class ArticleCateLists
+ * @package app\adminapi\lists\article
+ */
+class UserServiceLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface
+{
+
+
+    /**
+     * @notes  设置搜索条件
+     * @return array
+     * @author heshihu
+     * @date 2022/2/8 18:39
+     */
+    public function setSearch(): array
+    {
+        return [
+            '%like%' => ['us.name','us.mobile'],
+            '=' => ['us.type']
+        ];
+    }
+    /**
+     * @notes 自定查询条件
+     * @return array
+     * @author 段誉
+     * @date 2022/10/25 16:53
+     */
+    public function queryWhere()
+    {
+        $where  = [];
+        if (isset($this->params['pay_status']) && !empty($this->params['pay_status'])) {
+            $pay_status =  $this->params['pay_status'];
+            if($pay_status == -1){
+                $pay_status = 0;
+            }
+            $where[] = ['ro.pay_status', '=', $pay_status];
+        }
+        if (isset($this->params['area_id'])) {
+            $where[] = ['us.area_id', 'like','%'. ',' . $this->params['area_id']. ',' .'%'];
+        }
+        if (isset($this->params['cate_id'])) {
+            $where[] = ['us.cate_id', 'like','%'. ',' . $this->params['cate_id']. ',' .'%'];
+        }
+        return $where;
+    }
+    /**
+     * @notes  设置支持排序字段
+     * @return array
+     * @author heshihu
+     * @date 2022/2/9 15:11
+     */
+    public function setSortFields(): array
+    {
+        return [ 'id' => 'id'];
+    }
+
+    /**
+     * @notes  设置默认排序
+     * @return array
+     * @author heshihu
+     * @date 2022/2/9 15:08
+     */
+    public function setDefaultOrder(): array
+    {
+        return ['us.id' => 'desc'];
+    }
+
+    /**
+     * @notes  获取管理列表
+     * @return array
+     * @author heshihu
+     * @date 2022/2/21 17:11
+     */
+    public function lists(): array
+    {
+
+        $ServerCateLists = UserService::alias('us')
+            ->leftJoin('recharge_order ro','ro.id=us.order_id')
+            ->field('us.id,us.user_id,us.type,us.name,us.mobile,us.agricultural_machinery_model,us.images,us.cate_id,us.area_id,us.money,us.content,us.status,us.expiration_time
+                    ,us.order_id,us.create_time,ro.sn,ro.pay_way,ro.pay_status,ro.pay_time')
+            ->where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order($this->sortOrder)
+            ->append(['status_desc','pay_status_desc','type_desc','cate_desc','area_desc','user'])
+            ->select()
+            ->toArray();
+
+        return $ServerCateLists;
+    }
+
+    /**
+     * @notes  获取数量
+     * @return int
+     * @author heshihu
+     * @date 2022/2/9 15:12
+     */
+    public function count(): int
+    {
+        return UserService::alias('us')->leftJoin('recharge_order ro','ro.id=us.order_id')->where($this->searchWhere)->where($this->queryWhere())->count();
+    }
+
+    public function extend()
+    {
+        return [];
+    }
+}

+ 0 - 121
app/adminapi/logic/agricultural_machinery/ArticleLogic.php

@@ -1,121 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeadmin快速开发前后端分离管理后台(PHP版)
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
-// | github下载:https://github.com/likeshop-github/likeadmin
-// | 访问官网:https://www.likeadmin.cn
-// | likeadmin团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeadminTeam
-// +----------------------------------------------------------------------
-
-namespace app\adminapi\logic\article;
-
-use app\common\logic\BaseLogic;
-use app\common\model\article\Article;
-use app\common\service\FileService;
-
-/**
- * 资讯管理逻辑
- * Class ArticleLogic
- * @package app\adminapi\logic\article
- */
-class ArticleLogic extends BaseLogic
-{
-
-    /**
-     * @notes  添加资讯
-     * @param array $params
-     * @author heshihu
-     * @date 2022/2/22 9:57
-     */
-    public static function add(array $params)
-    {
-        Article::create([
-            'title' => $params['title'],
-            'desc' => $params['desc'] ?? '',
-            'author' => $params['author'] ?? '', //作者
-            'sort' => $params['sort'] ?? 0, // 排序
-            'abstract' => $params['abstract'], // 文章摘要
-            'click_virtual' => $params['click_virtual'] ?? 0,
-            'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '',
-            'cid' => $params['cid'],
-            'is_show' => $params['is_show'],
-            'content' => $params['content'] ?? '',
-        ]);
-    }
-
-
-    /**
-     * @notes  编辑资讯
-     * @param array $params
-     * @return bool
-     * @author heshihu
-     * @date 2022/2/22 10:12
-     */
-    public static function edit(array $params) : bool
-    {
-        try {
-            Article::update([
-                'id' => $params['id'],
-                'title' => $params['title'],
-                'desc' => $params['desc'] ?? '', // 简介
-                'author' => $params['author'] ?? '', //作者
-                'sort' => $params['sort'] ?? 0, // 排序
-                'abstract' => $params['abstract'], // 文章摘要
-                'click_virtual' => $params['click_virtual'] ?? 0,
-                'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '',
-                'cid' => $params['cid'],
-                'is_show' => $params['is_show'],
-                'content' => $params['content'] ?? '',
-            ]);
-            return true;
-        } catch (\Exception $e) {
-            self::setError($e->getMessage());
-            return false;
-        }
-    }
-
-
-    /**
-     * @notes  删除资讯
-     * @param array $params
-     * @author heshihu
-     * @date 2022/2/22 10:17
-     */
-    public static function delete(array $params)
-    {
-        Article::destroy($params['id']);
-    }
-
-    /**
-     * @notes  查看资讯详情
-     * @param $params
-     * @return array
-     * @author heshihu
-     * @date 2022/2/22 10:15
-     */
-    public static function detail($params) : array
-    {
-        return Article::findOrEmpty($params['id'])->toArray();
-    }
-
-    /**
-     * @notes  更改资讯状态
-     * @param array $params
-     * @return bool
-     * @author heshihu
-     * @date 2022/2/22 10:18
-     */
-    public static function updateStatus(array $params)
-    {
-        Article::update([
-            'id' => $params['id'],
-            'is_show' => $params['is_show']
-        ]);
-        return true;
-    }
-}

+ 132 - 0
app/adminapi/logic/agricultural_machinery/UserServiceLogic.php

@@ -0,0 +1,132 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\logic\agricultural_machinery;
+
+use app\common\enum\YesNoEnum;
+use app\common\logic\BaseLogic;
+use app\common\model\article\ArticleCate;
+use app\common\model\agricultural_machinery\ServiceCategory as AgriculturalMachineryServiceCategory;
+
+/**
+ * 服务管理逻辑
+ * Class ArticleCateLogic
+ * @package app\adminapi\logic\article
+ */
+class UserServiceLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes  添加农耕分类
+     * @param array $params
+     * @author heshihu
+     * @date 2022/2/18 10:17
+     */
+    public static function add(array $params)
+    {
+        AgriculturalMachineryServiceCategory::create([
+            'name' => $params['name'],
+            'type' => $params['type'],
+            'status' => $params['status'] ?? 1,
+            'sort' => $params['sort'] ?? 0
+        ]);
+    }
+
+
+    /**
+     * @notes  编辑农耕分类
+     * @param array $params
+     * @return bool
+     * @author heshihu
+     * @date 2022/2/21 17:50
+     */
+    public static function edit(array $params) : bool
+    {
+        try {
+            AgriculturalMachineryServiceCategory::update([
+                'id' => $params['id'],
+                'name' => $params['name'],
+                'status' => $params['status'] ?? 1,
+                'sort' => $params['sort'] ?? 0
+            ]);
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes  删除农耕分类
+     * @param array $params
+     * @author heshihu
+     * @date 2022/2/21 17:52
+     */
+    public static function delete(array $params)
+    {
+        AgriculturalMachineryServiceCategory::destroy($params['id']);
+    }
+
+    /**
+     * @notes  查看农耕分类详情
+     * @param $params
+     * @return array
+     * @author heshihu
+     * @date 2022/2/21 17:54
+     */
+    public static function detail($params) : array
+    {
+        return AgriculturalMachineryServiceCategory::findOrEmpty($params['id'])->toArray();
+    }
+
+    /**
+     * @notes  更改农耕分类状态
+     * @param array $params
+     * @return bool
+     * @author heshihu
+     * @date 2022/2/21 18:04
+     */
+    public static function updateStatus(array $params)
+    {
+        AgriculturalMachineryServiceCategory::update([
+            'id' => $params['id'],
+            'status' => $params['status']
+        ]);
+        return true;
+    }
+
+
+    /**
+     * @notes 有效农耕分类数据
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/10/13 10:53
+     */
+    public static function getValidCateData($get)
+    {
+
+        $list =  AgriculturalMachineryServiceCategory::where(['status' => YesNoEnum::YES,'type'=>$get['type']])
+            ->field('id,name')
+            ->order(['sort' => 'desc', 'id' => 'desc'])
+            ->select()
+            ->toArray();
+        return $list;
+    }
+
+}

+ 0 - 108
app/adminapi/validate/agricultural_machinery/ArticleValidate.php

@@ -1,108 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | likeadmin快速开发前后端分离管理后台(PHP版)
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
-// | github下载:https://github.com/likeshop-github/likeadmin
-// | 访问官网:https://www.likeadmin.cn
-// | likeadmin团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeadminTeam
-// +----------------------------------------------------------------------
-
-namespace app\adminapi\validate\article;
-
-use app\common\validate\BaseValidate;
-use app\common\model\article\Article;
-
-/**
- * 资讯管理验证
- * Class ArticleValidate
- * @package app\adminapi\validate\article
- */
-class ArticleValidate extends BaseValidate
-{
-    protected $rule = [
-        'id' => 'require|checkArticle',
-        'title' => 'require|length:1,255',
-//        'image' => 'require',
-        'cid' => 'require',
-        'is_show' => 'require|in:0,1',
-    ];
-
-    protected $message = [
-        'id.require' => '资讯id不能为空',
-        'title.require' => '标题不能为空',
-        'title.length' => '标题长度须在1-255位字符',
-//        'image.require' => '封面图必须存在',
-        'cid.require' => '所属栏目必须存在',
-    ];
-
-    /**
-     * @notes  添加场景
-     * @return ArticleValidate
-     * @author heshihu
-     * @date 2022/2/22 9:57
-     */
-    public function sceneAdd()
-    {
-        return $this->remove(['id'])
-            ->remove('id','require|checkArticle');
-    }
-
-    /**
-     * @notes  详情场景
-     * @return ArticleValidate
-     * @author heshihu
-     * @date 2022/2/22 10:15
-     */
-    public function sceneDetail()
-    {
-        return $this->only(['id']);
-    }
-
-    /**
-     * @notes  更改状态场景
-     * @return ArticleValidate
-     * @author heshihu
-     * @date 2022/2/22 10:18
-     */
-    public function sceneStatus()
-    {
-        return $this->only(['id', 'is_show']);
-    }
-
-    public function sceneEdit()
-    {
-    }
-
-    /**
-     * @notes  删除场景
-     * @return ArticleValidate
-     * @author heshihu
-     * @date 2022/2/22 10:17
-     */
-    public function sceneDelete()
-    {
-        return $this->only(['id']);
-    }
-
-    /**
-     * @notes  检查指定资讯是否存在
-     * @param $value
-     * @return bool|string
-     * @author heshihu
-     * @date 2022/2/22 10:11
-     */
-    public function checkArticle($value)
-    {
-        $article = Article::findOrEmpty($value);
-        if ($article->isEmpty()) {
-            return '资讯不存在';
-        }
-        return true;
-    }
-
-}

+ 154 - 0
app/adminapi/validate/agricultural_machinery/UserServiceValidate.php

@@ -0,0 +1,154 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\validate\agricultural_machinery;
+
+use app\common\validate\BaseValidate;
+use app\common\model\agricultural_machinery\ServiceCategory as AgriculturalMachineryServiceCategory;
+
+/**
+ * 服务管理验证
+ * Class ArticleCateValidate
+ * @package app\adminapi\validate\article
+ */
+class UserServiceValidate extends BaseValidate
+{
+    protected $rule = [
+        'id' => 'require|checkMachineryCate',
+        'name' => 'require|length:1,60',
+        'status' => 'require|in:0,1',
+        'sort' => 'egt:0',
+        'type' =>'require|in:1,2,3',
+        'pay_status' => 'requireIf:pay_status,true|in:1,-1',
+    ];
+
+    protected $message = [
+        'id.require' => ' 分类id不能为空1',
+        'name.require' => '分类名称不能为空',
+        'name.length' => '分类长度须在1-60位字符',
+        'sort.egt' => '排序值不正确',
+        'type.require' => '类型不能为空',
+        'type.in' => '类型值type参数规则错误',
+        'pay_status.requireIf' => '请选择支付状态',
+        'pay_status.in' => '支付状态值错误',
+    ];
+
+    /**
+     * @notes  列表
+     * @return ArticleCateValidate
+     * @author heshihu
+     * @date 2022/2/10 15:11
+     */
+    public function sceneUserService()
+    {
+        return $this->only(['type','pay_status']);
+    }
+
+    /**
+     * @notes  添加场景
+     * @return ArticleCateValidate
+     * @author heshihu
+     * @date 2022/2/10 15:11
+     */
+    public function sceneAdd()
+    {
+        return $this->remove(['id'])
+            ->remove('id', 'require|checkMachineryCate');
+    }
+
+    /**
+     * @notes  详情场景
+     * @return ArticleCateValidate
+     * @author heshihu
+     * @date 2022/2/21 17:55
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+    /**
+     * @notes  更改状态场景
+     * @return ArticleCateValidate
+     * @author heshihu
+     * @date 2022/2/21 18:02
+     */
+    public function sceneStatus()
+    {
+        return $this->only(['id', 'status']);
+    }
+
+    public function sceneEdit()
+    {
+        return $this
+        ->remove('type', 'require');
+    }
+
+    /**
+     * @notes  获取所有农耕分类场景
+     * @return ArticleCateValidate
+     * @author heshihu
+     * @date 2022/2/15 10:05
+     */
+    public function sceneSelect()
+    {
+//        return $this->only(['type']);
+    }
+
+
+    /**
+     * @notes  删除场景
+     * @return ArticleCateValidate
+     * @author heshihu
+     * @date 2022/2/21 17:52
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id'])
+            ->append('id', 'checkDeleteArticleCate');
+    }
+
+    /**
+     * @notes  检查指定农耕分类是否存在
+     * @param $value
+     * @return bool|string
+     * @author heshihu
+     * @date 2022/2/10 15:10
+     */
+    public function checkMachineryCate($value)
+    {
+        $category = AgriculturalMachineryServiceCategory::findOrEmpty($value);
+        if ($category->isEmpty()) {
+            return '农耕分类不存在';
+        }
+        return true;
+    }
+
+    /**
+     * @notes  删除时验证农耕分类是否已使用
+     * @param $value
+     * @return bool|string
+     * @author heshihu
+     * @date 2022/2/22 14:45
+     */
+    public function checkDeleteArticleCate($value)
+    {
+//        $article = Article::where('cid', $value)->findOrEmpty();
+//        if (!$article->isEmpty()) {
+//            return '农耕分类已使用,请先删除绑定该农耕分类的农耕服务';
+//        }
+        return true;
+    }
+
+}

+ 18 - 2
app/common/model/agricultural_machinery/UserService.php

@@ -54,15 +54,31 @@ class UserService extends BaseModel
      * @param $value
      * @param $data
      * @return string
-     * @author 段誉
+     * @author 段誉 状态  0 新增  1 有效  2 已过期
      * @date 2022/9/15 11:25
      */
     public function getStatusDescAttr($value, $data)
     {
-        return $data['status'] ? '启用' : '停用';
+        $status = $data['status'];
+        $desc = [
+            0 => '新增',
+            1 => '已支付',
+            2 => '已过期',
+        ];
+
+        return $desc[$status] ?? '';
     }
 
+    public function getPayStatusDescAttr($value, $data)
+    {
+        $status = $data['pay_status'];
+        $desc = [
+            0 => '未支付',
+            1 => '已支付',
+        ];
 
+        return $desc[$status] ?? '';
+    }
     /**
      * @notes
      * @param $value