Explorar o código

商品banner图处理,及保修卡处理

林海涛 hai 1 ano
pai
achega
5f56ca6052

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

+ 87 - 0
app/adminapi/lists/effective/EffectiveRulesLists.php

@@ -0,0 +1,87 @@
+<?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\effective;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\effective\EffectiveRules;
+use app\common\lists\ListsSearchInterface;
+use think\db\Query;
+
+
+/**
+ * EffectiveRules列表
+ * Class EffectiveRulesLists
+ * @package app\adminapi\listseffective
+ */
+class EffectiveRulesLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/17 11:49
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['effective_num', 'effective_unit', 'remark'],
+
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/17 11:49
+     */
+    public function lists(): array
+    {
+       $data =  EffectiveRules::with(['effectiveWithCategory'=>function(Query $query){
+            $query->field('id,name');
+        }])
+            ->where($this->searchWhere)
+            ->field(['id', 'effective_num', 'effective_unit', 'remark'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+       foreach($data as $k => $v){
+           $v['goods_category_ids'] = array_column($v['effectiveWithCategory'],'id');
+           $data[$k] = $v;
+       }
+       return $data;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/17 11:49
+     */
+    public function count(): int
+    {
+        return EffectiveRules::where($this->searchWhere)->count();
+    }
+
+}

+ 140 - 0
app/adminapi/logic/effective/EffectiveRulesLogic.php

@@ -0,0 +1,140 @@
+<?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\effective;
+
+
+use app\common\model\effective\EffectiveCategory;
+use app\common\model\effective\EffectiveRules;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * EffectiveRules逻辑
+ * Class EffectiveRulesLogic
+ * @package app\adminapi\logic\effective
+ */
+class EffectiveRulesLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/17 11:49
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            $effectiveRules = EffectiveRules::create([
+                'effective_num' => $params['effective_num'],
+                'effective_unit' => $params['effective_unit'],
+                'remark' => $params['remark'],
+            ]);
+            if(!empty($params['goods_category_ids'])){
+                $effectiveCategoryArr = [];
+                $ruleId = $effectiveRules->id;
+                foreach($params['goods_category_ids'] as $v){
+                    $effectiveCategoryArr[] = end($v);
+                }
+                $categoryIds = EffectiveCategory::where([['goods_category_id','in',$effectiveCategoryArr],['effective_id','<>',$ruleId]])->column('goods_category_id');
+                if(!empty($categoryIds)){
+                    throw new \Exception('存在已分配的分类:'.implode(',',$categoryIds));
+                }
+                $effectiveRules->effectiveWithCategory()->saveAll($effectiveCategoryArr);
+            }
+            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/07/17 11:49
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            EffectiveRules::where('id', $params['id'])->update([
+                'effective_num' => $params['effective_num'],
+                'effective_unit' => $params['effective_unit'],
+                'remark' => $params['remark'],
+            ]);
+            EffectiveCategory::where('effective_id',$params['id'])->delete();
+            $effectiveCategoryArr = [];
+            if(!empty($params['goods_category_ids'])){
+                foreach($params['goods_category_ids'] as $v){
+                    $effectiveCategoryArr[] =end($v);
+                }
+                $categoryIds = EffectiveCategory::where([['goods_category_id','in',$effectiveCategoryArr],['effective_id','<>', $params['id']]])->column('goods_category_id');
+                if(!empty($categoryIds)){
+                    throw new \Exception('存在已分配的分类:'.implode(',',$categoryIds));
+                }
+                $effectiveRules = EffectiveRules::find($params['id']);
+                $effectiveRules->effectiveWithCategory()->saveAll($effectiveCategoryArr);
+            }
+            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/07/17 11:49
+     */
+    public static function delete(array $params): bool
+    {
+        EffectiveCategory::where('effective_id',$params['id'])->delete();
+        return EffectiveRules::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/07/17 11:49
+     */
+    public static function detail($params): array
+    {
+
+       $rules = EffectiveRules::findOrEmpty($params['id'])->toArray();
+       if(!empty($rules)){
+           $rules['goods_category_ids'] =  EffectiveCategory::where('effective_id',$params['id'])->column('goods_category_id');
+       }
+       return $rules;
+    }
+}

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

@@ -49,6 +49,7 @@ class GoodsLogic extends BaseLogic
                 'goods_name' => $params['goods_name'],
                 'goods_image' => $params['goods_image'],
                 'goods_video' => $params['goods_video'],
+                'goods_banners' => $params['goods_banners'],
                 'goods_number' => $params['goods_number'],
                 'good_unit' => $params['good_unit'],
                 'goods_size' => $params['goods_size'],
@@ -100,6 +101,7 @@ class GoodsLogic extends BaseLogic
                 'goods_name' => $params['goods_name'],
                 'goods_image' => $params['goods_image'],
                 'goods_video' => $params['goods_video'],
+                'goods_banners' => !empty($params['goods_banners']) ? json_encode($params['goods_banners'],true) : null,
                 'goods_number' => $params['goods_number'],
                 'good_unit' => $params['good_unit'],
                 'goods_size' => $params['goods_size'],

+ 98 - 0
app/adminapi/validate/effective/EffectiveRulesValidate.php

@@ -0,0 +1,98 @@
+<?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\effective;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * EffectiveRules验证器
+ * Class EffectiveRulesValidate
+ * @package app\adminapi\validate\effective
+ */
+class EffectiveRulesValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'effective_num' => 'require',
+        'effective_unit' => 'require',

+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'effective_num' => '保修值',
+        'effective_unit' => '单位',

+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return EffectiveRulesValidate
+     * @author likeadmin
+     * @date 2024/07/17 11:49
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['effective_num','effective_unit']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return EffectiveRulesValidate
+     * @author likeadmin
+     * @date 2024/07/17 11:49
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','effective_num','effective_unit']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return EffectiveRulesValidate
+     * @author likeadmin
+     * @date 2024/07/17 11:49
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return EffectiveRulesValidate
+     * @author likeadmin
+     * @date 2024/07/17 11:49
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 13 - 0
app/api/controller/ServiceOrderController.php

@@ -104,4 +104,17 @@ class ServiceOrderController extends BaseApiController
         }
         return $this->success('已确认服务完成', [], 1, 1);
     }
+
+    public function queryEffective()
+    {
+        $params = (new ServiceOrderValidate())->post()->goCheck('queryEffective', [
+            'user_id' => $this->userId,
+            'user_info' => $this->userInfo
+        ]);
+        $result = ServiceOrderLogic::queryEffective($params);
+        if (false === $result) {
+            return $this->fail(ServiceOrderLogic::getError());
+        }
+        return $this->success('已确认服务完成', [], 1, 1);
+    }
 }

+ 21 - 0
app/api/logic/ServiceOrderLogic.php

@@ -314,4 +314,25 @@ class ServiceOrderLogic extends BaseLogic
             return false;
         }
     }
+
+
+    public static function queryEffective($params)
+    {
+        Db::startTrans();
+        try {
+            $work_id = \app\common\model\recharge\RechargeOrder::where([
+                'order_type' => 0,
+                'user_id' => $params['user_id'],
+                'sn'=>$params['sn']
+            ])->value('work_id');
+            if(empty($work_id)){
+                throw new Exception('订单不存在');
+            }
+            return true;
+        }catch(\Exception $e){
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
 }

+ 4 - 1
app/api/validate/ServiceOrderValidate.php

@@ -58,5 +58,8 @@ class ServiceOrderValidate extends BaseValidate
     }
 
 
-
+    public function sceneQueryEffective()
+    {
+        return $this->only(['sn']);
+    }
 }

+ 15 - 0
app/common/model/effective/EffectiveCategory.php

@@ -0,0 +1,15 @@
+<?php
+/**
+ * @author 林海涛
+ * @date 2024/7/17 下午1:59
+ */
+namespace app\common\model\effective;
+
+use app\common\model\BaseModel;
+use think\model\Pivot;
+
+class EffectiveCategory extends Pivot
+{
+    protected $name = 'effective_category';
+    protected $autoWriteTimestamp = true;
+}

+ 37 - 0
app/common/model/effective/EffectiveRules.php

@@ -0,0 +1,37 @@
+<?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\effective;
+
+
+use app\common\model\BaseModel;
+use app\common\model\goods_category\GoodsCategory;
+
+
+/**
+ * EffectiveRules模型
+ * Class EffectiveRules
+ * @package app\common\model\effective
+ */
+class EffectiveRules extends BaseModel
+{
+    
+    protected $name = 'effective_rules';
+
+
+    public function effectiveWithCategory()
+    {
+        return $this->belongsToMany(GoodsCategory::class,EffectiveCategory::class,'goods_category_id','effective_id');
+    }
+}

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

@@ -32,6 +32,7 @@ class Goods extends BaseModel
 
     protected $type = [
         'goods_category_ids' =>  'array',
+        'goods_banners' => 'array'
     ];
 
     public function goodsCategory()