瀏覽代碼

订单投诉工程师

whitefang 1 年之前
父節點
當前提交
0d90b6911f

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

+ 78 - 0
app/adminapi/lists/orders/OrderReportLists.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\orders;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\orders\OrderReport;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * OrderReport列表
+ * Class OrderReportLists
+ * @package app\adminapi\listsorders
+ */
+class OrderReportLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2025/01/17 13:50
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['work_id','worker_id','user_id', 'report', 'audit_state', 'event_status', 'remark'],
+
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2025/01/17 13:50
+     */
+    public function lists(): array
+    {
+        return OrderReport::where($this->searchWhere)
+            ->field(['id', 'work_id','worker_id','user_id', 'report', 'audit_state', 'event_status', 'remark'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2025/01/17 13:50
+     */
+    public function count(): int
+    {
+        return OrderReport::where($this->searchWhere)->count();
+    }
+
+}

+ 113 - 0
app/adminapi/logic/orders/OrderReportLogic.php

@@ -0,0 +1,113 @@
+<?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\orders;
+
+
+use app\common\model\orders\OrderReport;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * OrderReport逻辑
+ * Class OrderReportLogic
+ * @package app\adminapi\logic\orders
+ */
+class OrderReportLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2025/01/17 13:50
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            OrderReport::create([
+                'work_id' => $params['work_id'],
+                'report' => $params['report'],
+                'audit_state' => $params['audit_state'],
+                'event_status' => $params['event_status'],
+                'remark' => $params['remark'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2025/01/17 13:50
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            OrderReport::where('id', $params['id'])->update([
+                'report' => $params['report'],
+                'audit_state' => $params['audit_state'],
+                'event_status' => $params['event_status'],
+                'remark' => $params['remark'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2025/01/17 13:50
+     */
+    public static function delete(array $params): bool
+    {
+        return OrderReport::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2025/01/17 13:50
+     */
+    public static function detail($params): array
+    {
+        return OrderReport::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 98 - 0
app/adminapi/validate/orders/OrderReportValidate.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\orders;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * OrderReport验证器
+ * Class OrderReportValidate
+ * @package app\adminapi\validate\orders
+ */
+class OrderReportValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'report' => 'require',
+        'event_status' => 'require',

+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'report' => '投诉类别',
+        'event_status' => '支付处理',

+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return OrderReportValidate
+     * @author likeadmin
+     * @date 2025/01/17 13:50
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['report','event_status']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return OrderReportValidate
+     * @author likeadmin
+     * @date 2025/01/17 13:50
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','report','event_status']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return OrderReportValidate
+     * @author likeadmin
+     * @date 2025/01/17 13:50
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return OrderReportValidate
+     * @author likeadmin
+     * @date 2025/01/17 13:50
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 27 - 0
app/api/controller/OrderReportController.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace app\api\controller;
+
+use app\api\validate\OrderReportValidate;
+use app\api\logic\OrderReportLogic;
+use app\common\model\dict\DictData;
+
+class OrderReportController extends BaseApiController
+{
+    public function ReportList()
+    {
+        return $this->data(DictData::where(['type_value'=>'order_report','status'=>1])->field('value,name')->select()->toArray());
+    }
+
+    public function add()
+    {
+        $params = (new OrderReportValidate())->post()->goCheck('add',[
+            'user_id' => $this->userId,
+        ]);
+        $result = OrderReportLogic::add($params);
+        if (true === $result) {
+            return $this->success('已提交投诉审核', [], 1, 1);
+        }
+        return $this->fail(OrderReportLogic::getError());
+    }
+}

+ 58 - 0
app/api/logic/OrderReportLogic.php

@@ -0,0 +1,58 @@
+<?php
+
+namespace app\api\logic;
+
+
+use app\common\logic\BaseLogic;
+use app\common\model\orders\OrderReport;
+use app\common\model\works\ServiceWork;
+use think\facade\Db;
+
+
+/**
+ * OrderReport
+ * Class OrderReportLogic
+ * @package app\api\logic
+ */
+class OrderReportLogic extends BaseLogic
+{
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            $work = ServiceWork::where(['id'=>$params['work_id'],'user_id'=>$params['user_id']])->findOrEmpty();
+            if($work->isEmpty()){
+                self::setError('工单不存在');
+                return false;
+            }
+
+            if(empty($work->master_worker_id)){
+                self::setError('工单未分配');
+                return false;
+            }
+
+            $is_report = OrderReport::where(['user_id'=>$params['user_id'],'work_id'=>$params['work_id']])->findOrEmpty();
+            if(!$is_report->isEmpty()){
+                self::setError('您已提交过投诉');
+                return false;
+            }
+
+            OrderReport::create([
+                'user_id'=>$params['user_id'],
+                'work_id' => $params['work_id'],
+                'worker_id'=> $work->master_worker_id,
+                'report' => $params['report'],
+                'audit_state' => 0,
+                'event_status' => 0,
+                'remark' => !empty($params['remark'])?$params['remark']:'',
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+}

+ 102 - 0
app/api/validate/OrderReportValidate.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\api\validate;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * OrderReport验证器
+ * Class OrderReportValidate
+ * @package app\api\validate
+ */
+class OrderReportValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'work_id'=>'require',
+        'report' => 'require',
+        'event_status' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'work_id' => '工单',
+        'report' => '投诉类别',
+        'event_status' => '支付处理',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return OrderReportValidate
+     * @author likeadmin
+     * @date 2025/01/17 13:50
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['work_id','report']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return OrderReportValidate
+     * @author likeadmin
+     * @date 2025/01/17 13:50
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','report','event_status']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return OrderReportValidate
+     * @author likeadmin
+     * @date 2025/01/17 13:50
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return OrderReportValidate
+     * @author likeadmin
+     * @date 2025/01/17 13:50
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 45 - 0
app/common/model/orders/OrderReport.php

@@ -0,0 +1,45 @@
+<?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\orders;
+
+
+use app\common\model\BaseModel;
+
+
+
+/**
+ * OrderReport模型
+ * Class OrderReport
+ * @package app\common\model\orders
+ */
+class OrderReport extends BaseModel
+{
+    
+    protected $name = 'order_report';
+    
+
+    
+    /**
+     * @notes 关联serviceWork
+     * @return \think\model\relation\HasOne
+     * @author likeadmin
+     * @date 2025/01/17 13:50
+     */
+    public function serviceWork()
+    {
+        return $this->hasOne(\app\common\model\works\ServiceWork::class, 'id', 'work_id');
+    }
+
+}