Преглед на файлове

add - 独立活动管理:活动商品、活动券、商品标签、活动配置

liugc преди 1 година
родител
ревизия
d3306ad6e4

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

+ 0 - 1
app/adminapi/lists/coupon/CouponRulesLists.php

@@ -85,7 +85,6 @@ class CouponRulesLists extends BaseAdminDataLists implements ListsSearchInterfac
         }
         if (isset($this->params['property_activity_id']) && !empty($this->params['property_activity_id'])) {
             // 筛选已选过的
-
             $where[] = ['id','>' ,0];//100000
         }
         return $where;

+ 11 - 1
app/adminapi/lists/goods/GoodsLists.php

@@ -21,6 +21,7 @@ use app\common\lists\ListsSearchInterface;
 use app\common\model\goods_category\GoodsCategory;
 use app\common\service\FileService;
 use think\db\Query;
+use think\facade\Log;
 
 
 /**
@@ -41,7 +42,7 @@ class GoodsLists extends BaseAdminDataLists implements ListsSearchInterface
     public function setSearch(): array
     {
         return [
-            '=' => ['goods_status','is_agent'],
+            '=' => ['goods_status','is_agent','is_activity'],
             '%like%' => ['goods_name','goods_brand'],
             'between' => ['service_total', 'service_fee'],
         ];
@@ -63,6 +64,15 @@ class GoodsLists extends BaseAdminDataLists implements ListsSearchInterface
         } else {
             $where[] = ['user_id','=' ,$this->params['user_id']];
         }
+        if (isset($this->params['labels']) && !empty($this->params['labels'])) {
+            $sqls = [];
+            foreach ($this->params['labels'] as $item) {
+                $sqls[] = "FIND_IN_SET({$item}, labels) > 0";
+            }
+            $query_sql = implode(' OR ', $sqls);
+            $period_ids = Goods::where('labels','<>', '')->whereRaw($query_sql)->column('id');
+            $where[] = [ 'id','IN',$period_ids?:[0]];
+        }
         if (isset($this->params['property_activity_id']) && !empty($this->params['property_activity_id'])) {
             // 筛选已选过的
             $where[] = ['is_activity','=' ,1];//100000

+ 78 - 0
app/adminapi/lists/labels/LabelsLists.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\labels;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\labels\Labels;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * Labels列表
+ * Class LabelsLists
+ * @package app\adminapi\lists
+ */
+class LabelsLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/12/12 17:15
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['label_type'],
+            '%like%' => ['label_name'],
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/12/12 17:15
+     */
+    public function lists(): array
+    {
+        return Labels::where($this->searchWhere)
+            ->field(['id', 'label_type', 'label_name'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/12/12 17:15
+     */
+    public function count(): int
+    {
+        return Labels::where($this->searchWhere)->count();
+    }
+
+}

+ 9 - 1
app/adminapi/logic/ConfigLogic.php

@@ -21,6 +21,7 @@ use app\adminapi\logic\dept\DeptLogic;
 use app\adminapi\logic\dept\JobsLogic;
 use app\adminapi\logic\setting\dict\DictTypeLogic;
 use app\common\enum\YesNoEnum;
+use app\common\logic\TableDataLogic;
 use app\common\model\article\ArticleCate;
 use app\common\model\auth\SystemMenu;
 use app\common\model\auth\SystemRole;
@@ -83,7 +84,14 @@ class ConfigLogic
         
         $type = explode(',', $type);
         $lists = DictData::whereIn('type_value', $type)->select()->toArray();
-
+        foreach ($type as $item) {
+            if (strpos($item, 'data_table_') !== false) {
+                $table = str_replace('data_table_', '', $item);
+                if (method_exists(TableDataLogic::class, $table)) {
+                    $lists = array_merge($lists, TableDataLogic::$table());
+                }
+            }
+        }
         if (empty($lists)) {
             return [];
         }

+ 4 - 2
app/adminapi/logic/goods/GoodsLogic.php

@@ -84,7 +84,8 @@ class GoodsLogic extends BaseLogic
                 'hot_weight' => $params['hot_weight'] ?:0,
                 'is_agent' => $params['is_agent'] ?:0,
                 'is_activity' => $params['is_activity'] ??0,
-                'property_activity_id' => $params['property_activity_id'] ??0
+                'property_activity_id' => $params['property_activity_id'] ??0,
+                'labels' => (isset($params['labels']) && $params['labels'])?implode(',',$params['labels']):'',
             ]);
 
             Db::commit();
@@ -154,7 +155,8 @@ class GoodsLogic extends BaseLogic
                 'hot_weight' => $params['hot_weight'] ?:0,
                 'is_agent' => $params['is_agent'] ?:0,
                 'is_activity' => $params['is_activity'] ??0,
-                'property_activity_id' => $params['property_activity_id'] ??0
+                'property_activity_id' => $params['property_activity_id'] ??0,
+                'labels' => (isset($params['labels']) && $params['labels'])?implode(',',$params['labels']):'',
             ]);
 
             //更新绩效规则

+ 108 - 0
app/adminapi/logic/labels/LabelsLogic.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\logic\labels;
+
+
+use app\common\model\labels\Labels;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * Labels逻辑
+ * Class LabelsLogic
+ * @package app\adminapi\logic
+ */
+class LabelsLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/12/12 17:15
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            Labels::create([
+                'label_type' => $params['label_type'],
+                'label_name' => $params['label_name'],
+            ]);
+
+            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/12/12 17:15
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            Labels::where('id', $params['id'])->update([
+                'label_type' => $params['label_type'],
+                'label_name' => $params['label_name'],
+            ]);
+
+            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/12/12 17:15
+     */
+    public static function delete(array $params): bool
+    {
+        return Labels::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/12/12 17:15
+     */
+    public static function detail($params): array
+    {
+        return Labels::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 100 - 0
app/adminapi/validate/labels/LabelsValidate.php

@@ -0,0 +1,100 @@
+<?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\labels;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * Labels验证器
+ * Class LabelsValidate
+ * @package app\adminapi\validate
+ */
+class LabelsValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'label_type' => 'require',
+        'label_name' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'label_type' => '标签分类',
+        'label_name' => '标签名称',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return LabelsValidate
+     * @author likeadmin
+     * @date 2024/12/12 17:15
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['label_type','label_name']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return LabelsValidate
+     * @author likeadmin
+     * @date 2024/12/12 17:15
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','label_type','label_name']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return LabelsValidate
+     * @author likeadmin
+     * @date 2024/12/12 17:15
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return LabelsValidate
+     * @author likeadmin
+     * @date 2024/12/12 17:15
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 48 - 0
app/common/logic/TableDataLogic.php

@@ -0,0 +1,48 @@
+<?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\logic;
+
+
+use app\common\enum\PayEnum;
+use app\common\enum\RefundEnum;
+use app\common\model\labels\Labels;
+use app\common\model\recharge\RechargeOrder;
+use app\common\model\refund\RefundLog;
+use app\common\model\refund\RefundRecord;
+use app\common\service\pay\AliPayService;
+use app\common\service\pay\WeChatPayService;
+
+
+/**
+ * 查询选项类数据
+ * Class TableDataLogic
+ * @package app\common\logic
+ */
+class TableDataLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 标签列表
+     */
+    public static function labels()
+    {
+        return Labels::where('id','>',0)->field('id,label_name as name,id as value,"data_table_labels" as type_value')->select()->toArray();
+    }
+
+
+
+}

+ 4 - 0
app/common/model/goods/Goods.php

@@ -59,5 +59,9 @@ class Goods extends BaseModel
             return 0;
         }
     }
+    public function getLabelsAttr($value)
+    {
+        return $value?array_map(function($item){ return (int)$item; },explode(',',$value)):[];
+    }
 
 }

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