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

+ 11 - 1
app/adminapi/controller/works/ServiceWorkController.php

@@ -179,5 +179,15 @@ class ServiceWorkController extends BaseAdminController
     }
 
 
-
+    public function addCustomerLog()
+    {
+        $params = (new ServiceWorkValidate())->post()->goCheck('detail',[
+            'admin_id' => $this->adminId,
+        ]);
+        $result = ServiceWorkLogic::addCustomerLog($params);
+        if (true === $result) {
+            return $this->success('操作成功!', [], 1, 1);
+        }
+        return $this->fail(ServiceWorkLogic::getError());
+    }
 }

+ 3 - 1
app/adminapi/lists/works/ServiceWorkLists.php

@@ -128,8 +128,10 @@ class ServiceWorkLists extends BaseAdminDataLists implements ListsSearchInterfac
             },
             'serviceWorkLog' =>function(Query $query){
                 $query->field('id,work_id,opera_log,create_time');
+            },
+            'serviceWorkCustomerLog' =>function(Query $query){
+                $query->field('id,work_id,content,create_time');
             }
-
         ])
             ->where($this->searchWhere)
             ->where($this->queryWhere())

+ 26 - 0
app/adminapi/logic/works/ServiceWorkLogic.php

@@ -33,6 +33,7 @@ use app\common\model\works\ServiceWork;
 use app\common\logic\BaseLogic;
 use app\common\model\works\ServiceWorkAllocateWorkerLog;
 use app\common\model\works\ServiceWorkAppointmentLog;
+use app\common\model\works\ServiceWorkCustomerLog;
 use app\common\model\works\ServiceWorkLog;
 use app\common\model\works\ServiceWorkSpare;
 use app\workerapi\logic\ServiceWorkerAllocateWorkerLogic;
@@ -837,4 +838,29 @@ class ServiceWorkLogic extends BaseLogic
         }
     }
 
+
+    public static function addCustomerLog($params)
+    {
+        Db::startTrans();
+        try {
+            $serviceWork = ServiceWork::where('id',$params['id'])->findOrEmpty();
+            if($serviceWork->isEmpty()){
+                throw new \Exception('工单不存在');
+            }
+            ServiceWorkCustomerLog::create([
+                'work_id'=>$serviceWork->id,
+                'content'=>$params['content']??'',
+                'admin_id'=>$params['admin_id']??0,
+                'create_time'=>time(),
+            ]);
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
 }

+ 4 - 0
app/common/model/works/ServiceWork.php

@@ -55,6 +55,10 @@ class ServiceWork extends BaseModel
     {
         return $this->hasMany(ServiceWorkLog::class,'work_id','id')->order(['id'=>'desc']);
     }
+    public function serviceWorkCustomerLog()
+    {
+        return $this->hasMany(ServiceWorkCustomerLog::class,'work_id','id')->order(['id'=>'desc']);
+    }
     public function rechargeOrder()
     {
         return $this->hasMany(RechargeOrder::class,'work_id','id');

+ 17 - 0
app/common/model/works/ServiceWorkCustomerLog.php

@@ -0,0 +1,17 @@
+<?php
+namespace app\common\model\works;
+
+
+use app\common\model\BaseModel;
+
+
+/**
+ * ServiceWorkLog模型
+ * Class ServiceWorkLog
+ * @package app\common\model\works
+ */
+class ServiceWorkCustomerLog extends BaseModel
+{
+    protected $name = 'service_work_customer_log';
+
+}