Explorar el Código

add - 商品收费标准

liugc hace 1 año
padre
commit
261dbd0cfc

+ 108 - 0
app/adminapi/controller/goods_fee_standards/GoodsFeeStandardsController.php

@@ -0,0 +1,108 @@
+<?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\goods_fee_standards;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\goods_fee_standards\GoodsFeeStandardsLists;
+use app\adminapi\logic\goods_fee_standards\GoodsFeeStandardsLogic;
+use app\adminapi\validate\goods_fee_standards\GoodsFeeStandardsValidate;
+
+
+/**
+ * GoodsFeeStandards控制器
+ * Class GoodsFeeStandardsController
+ * @package app\adminapi\controller
+ */
+class GoodsFeeStandardsController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/10/14 15:59
+     */
+    public function lists()
+    {
+        return $this->dataLists(new GoodsFeeStandardsLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/10/14 15:59
+     */
+    public function add()
+    {
+        $params = (new GoodsFeeStandardsValidate())->post()->goCheck('add');
+        $result = GoodsFeeStandardsLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(GoodsFeeStandardsLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/10/14 15:59
+     */
+    public function edit()
+    {
+        $params = (new GoodsFeeStandardsValidate())->post()->goCheck('edit');
+        $result = GoodsFeeStandardsLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(GoodsFeeStandardsLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/10/14 15:59
+     */
+    public function delete()
+    {
+        $params = (new GoodsFeeStandardsValidate())->post()->goCheck('delete');
+        GoodsFeeStandardsLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/10/14 15:59
+     */
+    public function detail()
+    {
+        $params = (new GoodsFeeStandardsValidate())->goCheck('detail');
+        $result = GoodsFeeStandardsLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 78 - 0
app/adminapi/lists/goods_fee_standards/GoodsFeeStandardsLists.php

@@ -0,0 +1,78 @@
+<?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\goods_fee_standards;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\goods_fee_standards\GoodsFeeStandards;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * GoodsFeeStandards列表
+ * Class GoodsFeeStandardsLists
+ * @package app\adminapi\lists
+ */
+class GoodsFeeStandardsLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/10/14 15:59
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['type', 'name', 'min_fee', 'max_fee', 'unit', 'details', 'status','goods_id'],
+
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/10/14 15:59
+     */
+    public function lists(): array
+    {
+        return GoodsFeeStandards::where($this->searchWhere)
+            ->field(['id', 'type', 'name', 'min_fee', 'max_fee', 'unit', 'details', 'status','goods_id'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/10/14 15:59
+     */
+    public function count(): int
+    {
+        return GoodsFeeStandards::where($this->searchWhere)->count();
+    }
+
+}

+ 120 - 0
app/adminapi/logic/goods_fee_standards/GoodsFeeStandardsLogic.php

@@ -0,0 +1,120 @@
+<?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\goods_fee_standards;
+
+
+use app\common\model\goods_fee_standards\GoodsFeeStandards;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * GoodsFeeStandards逻辑
+ * Class GoodsFeeStandardsLogic
+ * @package app\adminapi\logic
+ */
+class GoodsFeeStandardsLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/10/14 15:59
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            GoodsFeeStandards::create([
+                'type' => $params['type'],
+                'name' => $params['name'],
+                'min_fee' => $params['min_fee'],
+                'max_fee' => $params['max_fee'],
+                'unit' => $params['unit'],
+                'details' => $params['details'],
+                'status' => $params['status'],
+                'goods_id' => $params['goods_id'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/10/14 15:59
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            GoodsFeeStandards::where('id', $params['id'])->update([
+                'type' => $params['type'],
+                'name' => $params['name'],
+                'min_fee' => $params['min_fee'],
+                'max_fee' => $params['max_fee'],
+                'unit' => $params['unit'],
+                'details' => $params['details'],
+                'status' => $params['status'],
+                'goods_id' => $params['goods_id'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/10/14 15:59
+     */
+    public static function delete(array $params): bool
+    {
+        return GoodsFeeStandards::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/10/14 15:59
+     */
+    public static function detail($params): array
+    {
+        return GoodsFeeStandards::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 106 - 0
app/adminapi/validate/goods_fee_standards/GoodsFeeStandardsValidate.php

@@ -0,0 +1,106 @@
+<?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\goods_fee_standards;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * GoodsFeeStandards验证器
+ * Class GoodsFeeStandardsValidate
+ * @package app\adminapi\validate
+ */
+class GoodsFeeStandardsValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'type' => 'require',
+        'name' => 'require',
+        'min_fee' => 'require',
+        'max_fee' => 'require',
+        'status' => 'require',
+        'goods_id' => 'require',
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'type' => '类型',
+        'name' => '名称',
+        'min_fee' => '最低价格',
+        'max_fee' => '最高价格(为0时即最低价为固定价)',
+        'status' => '状态',
+        'goods_id' => '商品ID必须',
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return GoodsFeeStandardsValidate
+     * @author likeadmin
+     * @date 2024/10/14 15:59
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['type','name','min_fee','max_fee','status','goods_id']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return GoodsFeeStandardsValidate
+     * @author likeadmin
+     * @date 2024/10/14 15:59
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','type','name','min_fee','max_fee','status','goods_id']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return GoodsFeeStandardsValidate
+     * @author likeadmin
+     * @date 2024/10/14 15:59
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return GoodsFeeStandardsValidate
+     * @author likeadmin
+     * @date 2024/10/14 15:59
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 34 - 0
app/common/model/goods_fee_standards/GoodsFeeStandards.php

@@ -0,0 +1,34 @@
+<?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\common\model\goods_fee_standards;
+
+
+use app\common\model\BaseModel;
+
+
+
+/**
+ * GoodsFeeStandards模型
+ * Class GoodsFeeStandards
+ * @package app\common\model
+ */
+class GoodsFeeStandards extends BaseModel
+{
+    
+    protected $name = 'goods_fee_standards';
+    
+
+    
+}