Parcourir la source

Merge branch 'customer-m' into tmp-master

liugc il y a 1 an
Parent
commit
2d5071d0ec

+ 5 - 1
app/adminapi/controller/notice/NoticeController.php

@@ -78,7 +78,11 @@ class NoticeController extends BaseAdminController
     public function getInformation()
     {
         $params = $this->request->post();
-        $result = NoticeLogic::getInformation($params);
+        if(isset($params['business_codes']) && !empty($params['business_codes'])){
+            $result = NoticeLogic::getInformationBatch($params);
+        }else{
+            $result = NoticeLogic::getInformation($params);
+        }
         if ($result) {
             return $this->success('获取成功', $result);
         }

+ 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())

+ 19 - 0
app/adminapi/logic/notice/NoticeLogic.php

@@ -321,5 +321,24 @@ class NoticeLogic extends BaseLogic
             return false;
         }
     }
+    public static function getInformationBatch($params)
+    {
+        try {
+            $res = [];
+            $params['business_codes'] = explode(',',$params['business_codes']);
+            foreach ($params['business_codes'] as $business_code) {
+                $noticeInfo = self::getInformation(['business_code'=>$business_code]);
+                if($noticeInfo['confirm_code'] == 101){
+                    $res[$business_code] = $noticeInfo['count'];
+                }else{
+                    $res[$business_code] = 0;
+                }
+            }
+            return $res;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
 
 }

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

@@ -35,6 +35,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;
@@ -847,4 +848,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

@@ -65,6 +65,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';
+
+}