Browse Source

商品服务-相关修改

whitefang 1 year ago
parent
commit
6816af6d82

+ 0 - 4
app/adminapi/controller/goods/GoodsController.php

@@ -99,10 +99,6 @@ class GoodsController extends BaseAdminController
      */
     public function detail()
     {
-        $data = GoodsCategory::field('id,pid,name')
-            ->order(['weigh' => 'desc', 'id' => 'desc'])
-            ->select()
-            ->toArray();
         $params = (new GoodsValidate())->goCheck('detail');
         $result = GoodsLogic::detail($params);
         return $this->data($result);

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

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

@@ -97,7 +97,7 @@ class GoodsLists extends BaseAdminDataLists implements ListsSearchInterface
      */
     public function count(): int
     {
-        return Goods::where($this->searchWhere)->count();
+        return Goods::where($this->searchWhere)->where($this->queryWhere())->count();
     }
 
 }

+ 78 - 0
app/adminapi/lists/reviews/GoodsReviewsLists.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\reviews;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\reviews\GoodsReviews;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * GoodsReviews列表
+ * Class GoodsReviewsLists
+ * @package app\adminapi\listsreviews
+ */
+class GoodsReviewsLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author whitef
+     * @date 2024/07/09 17:11
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['goods_id', 'goods_category_id', 'user_id', 'rating', 'comment', 'review_image', 'review_status', 'create_time', 'update_time'],
+
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author whitef
+     * @date 2024/07/09 17:11
+     */
+    public function lists(): array
+    {
+        return GoodsReviews::where($this->searchWhere)
+            ->field(['id', 'goods_id', 'goods_category_id', 'user_id', 'rating', 'comment', 'review_image', 'review_status', 'create_time', 'update_time'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author whitef
+     * @date 2024/07/09 17:11
+     */
+    public function count(): int
+    {
+        return GoodsReviews::where($this->searchWhere)->count();
+    }
+
+}

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

@@ -53,10 +53,12 @@ class GoodsLogic extends BaseLogic
                 'goods_type' => $params['goods_type'],
                 'goods_brand' => $params['goods_brand'],
                 'install_guide' => $params['install_guide'],
+                'goods_payment_type'=>$params['goods_payment_type'],
                 'base_service_fee' => $params['base_service_fee'],
                 'service_total' => $params['service_total'],
                 'service_fee' => $params['service_fee'],
                 'service_image' => $params['service_image'],
+                'warranty_period'=>$params['warranty_period'],
                 'fee_schedule' => $params['fee_schedule'],
                 'goods_status' => $params['goods_status'],
                 'is_recommend' => $params['is_recommend'] ?:0,
@@ -101,10 +103,12 @@ class GoodsLogic extends BaseLogic
                 'goods_type' => $params['goods_type'],
                 'goods_brand' => $params['goods_brand'],
                 'install_guide' => $params['install_guide'],
+                'goods_payment_type'=>$params['goods_payment_type'],
                 'base_service_fee' => $params['base_service_fee'],
                 'service_total' => $params['service_total'],
                 'service_fee' => $params['service_fee'],
                 'service_image' => $params['service_image'],
+                'warranty_period'=>$params['warranty_period'],
                 'fee_schedule' => $params['fee_schedule'],
                 'goods_status' => $params['goods_status'],
                 'is_recommend' => $params['is_recommend'] ?:0,

+ 118 - 0
app/adminapi/logic/reviews/GoodsReviewsLogic.php

@@ -0,0 +1,118 @@
+<?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\reviews;
+
+
+use app\common\model\reviews\GoodsReviews;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * GoodsReviews逻辑
+ * Class GoodsReviewsLogic
+ * @package app\adminapi\logic\reviews
+ */
+class GoodsReviewsLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author whitef
+     * @date 2024/07/09 17:11
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            GoodsReviews::create([
+                'goods_id' => $params['goods_id'],
+                'goods_category_id' => $params['goods_category_id'],
+                'user_id' => $params['user_id'],
+                'rating' => $params['rating'],
+                'comment' => $params['comment'],
+                'review_image' => $params['review_image'],
+                'review_status' => $params['review_status'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author whitef
+     * @date 2024/07/09 17:11
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            GoodsReviews::where('id', $params['id'])->update([
+                'goods_id' => $params['goods_id'],
+                'goods_category_id' => $params['goods_category_id'],
+                'user_id' => $params['user_id'],
+                'rating' => $params['rating'],
+                'comment' => $params['comment'],
+                'review_image' => $params['review_image'],
+                'review_status' => $params['review_status'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author whitef
+     * @date 2024/07/09 17:11
+     */
+    public static function delete(array $params): bool
+    {
+        return GoodsReviews::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author whitef
+     * @date 2024/07/09 17:11
+     */
+    public static function detail($params): array
+    {
+        return GoodsReviews::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 102 - 0
app/adminapi/validate/reviews/GoodsReviewsValidate.php

@@ -0,0 +1,102 @@
+<?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\reviews;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * GoodsReviews验证器
+ * Class GoodsReviewsValidate
+ * @package app\adminapi\validate\reviews
+ */
+class GoodsReviewsValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'goods_id' => 'require',
+        'goods_category_id' => 'require',
+        'user_id' => 'require',
+        'rating' => 'require',

+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'goods_id' => 'goods_id',
+        'goods_category_id' => 'goods_category_id',
+        'user_id' => 'user_id',
+        'rating' => 'rating',

+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return GoodsReviewsValidate
+     * @author whitef
+     * @date 2024/07/09 17:11
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['goods_id','goods_category_id','user_id','rating']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return GoodsReviewsValidate
+     * @author whitef
+     * @date 2024/07/09 17:11
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','goods_id','goods_category_id','user_id','rating']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return GoodsReviewsValidate
+     * @author whitef
+     * @date 2024/07/09 17:11
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return GoodsReviewsValidate
+     * @author whitef
+     * @date 2024/07/09 17:11
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 2 - 18
app/api/controller/GoodsController.php

@@ -1,22 +1,6 @@
 <?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\api\controller;
 
-
-
-
-
 use app\api\lists\GoodsLists;
 use app\api\logic\GoodsLogic;
 
@@ -42,8 +26,8 @@ class GoodsController extends BaseApiController
 
     public function detail()
     {
-        $id = $this->request->get('id/d');
-        $result = GoodsLogic::detail($id, $this->userId);
+        $id = $this->request->get('category_id/d');
+        $result = GoodsLogic::detail($id);
         return $this->data($result);
     }
 }

+ 19 - 0
app/api/controller/GoodsReviewsController.php

@@ -0,0 +1,19 @@
+<?php
+namespace app\api\controller;
+
+use app\api\lists\GoodsReviewsLists;
+
+/**
+ * 商品评论控制器
+ * Class GoodsReviewsController
+ * @package app\api\controller
+ */
+class GoodsReviewsController extends BaseApiController
+{
+    public array $notNeedLogin = ['lists'];
+
+    public function lists()
+    {
+        return $this->dataLists(new GoodsReviewsLists());
+    }
+}

+ 1 - 1
app/api/lists/GoodsLists.php

@@ -96,7 +96,7 @@ class GoodsLists  extends BaseApiDataLists implements ListsSearchInterface
      */
     public function count(): int
     {
-        return Goods::where($this->searchWhere)->count();
+        return Goods::where($this->searchWhere)->where($this->queryWhere())->count();
     }
 
 }

+ 71 - 0
app/api/lists/GoodsReviewsLists.php

@@ -0,0 +1,71 @@
+<?php
+namespace app\api\lists;
+
+use app\common\model\goods_category\GoodsCategory;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\reviews\GoodsReviews;
+
+/**
+ * GoodsReviewsLists
+ * Class GoodsReviewsLists
+ * @package app\api\lists\GoodsReviewsLists
+ */
+class GoodsReviewsLists extends BaseApiDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @date 2024/07/07 18:23
+     */
+    public function setSearch(): array
+    {
+        return [
+            'goods_id','user_id','review_status','goods_category_id'
+        ];
+    }
+
+    public function queryWhere()
+    {
+        $where = [];
+        $where[] = ['goods_category_id','=',!empty($this->params['category_id'])?$this->params['category_id']:'9999999'];
+        $where[] = ['review_status','=',1];
+        return $where;
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author whitef
+     * @date 2024/07/07 18:23
+     */
+    public function lists(): array
+    {
+        $lists = GoodsReviews::where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->limit($this->limitOffset, $this->limitLength)
+            ->field(['id','rating','comment','review_image','create_time'])
+            ->order('create_time desc')
+            ->select()
+            ->toArray();
+        return $lists;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author whitef
+     * @date 2024/07/07 18:23
+     */
+    public function count(): int
+    {
+        return GoodsReviews::where($this->searchWhere)->where($this->queryWhere())->count();
+    }
+
+}

+ 7 - 2
app/api/logic/GoodsLogic.php

@@ -21,8 +21,13 @@ class GoodsLogic extends BaseLogic
      * @author whitef
      * @date 2022/9/20 17:09
      */
-    public static function detail($goods_id, $userId){
-        return Goods::findOrEmpty($goods_id)->visible(['id'])->toArray();
+    public static function detail($goods_category_id){
+        $goods = Goods::where('goods_category_id',$goods_category_id)->visible([
+            'id','goods_image','goods_video',
+            'goods_number','good_unit','base_service_fee',
+            'service_total','service_fee','service_image','fee_schedule','warranty_period'
+        ])->select()->toArray();
+        return $goods;
     }
 
     public static function getHotData()

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