Jelajahi Sumber

Merge branch '1104-m'

liugc 1 tahun lalu
induk
melakukan
bfffe37ced

+ 3 - 1
app/adminapi/logic/works/ServiceWorkLogic.php

@@ -381,7 +381,9 @@ class ServiceWorkLogic extends BaseLogic
         ])->append(['id','work_status_text','service_status_text'])
             ->where($work_where)
             ->findOrEmpty()->toArray();
-
+        if(isset($params['user_id']) && $params['user_id'] && ($params['user_id'] != $result['master_worker_id'])){
+            throw new \Exception('您没有权限操作该工单');
+        }
         //工程师工单按钮状态
         $work_service_status = 0;
         $work_service_status_text = '待派单';

+ 4 - 3
app/api/logic/PerformanceLogic.php

@@ -45,16 +45,16 @@ class PerformanceLogic extends BaseLogic
             $coupon_price = RechargeOrder::where('work_id',$work->id)->sum('coupon_price');
             switch ($rule['type']){
                 case 0://按照总金额结算
-                    $settlement_amount = bcmul($worker_price, $rule['rate']);
+                    $settlement_amount = bcmul($work->work_total, $rule['rate'],2);
                     break;
                 case 1://按照结算金额结算
                     $worker_price = $work->work_amount;
-                    $settlement_amount = bcmul($worker_price, $rule['rate']);
+                    $settlement_amount = bcmul($worker_price, $rule['rate'],2);
                     break;
                 case 2://按照服务总费用结算
                     //搜索所有优惠券
                     $worker_price = $work->service_fee-$coupon_price;
-                    $settlement_amount = bcmul($worker_price, $rule['rate']);
+                    $settlement_amount = bcmul($worker_price, $rule['rate'],2);
                     break;
                 default://按照固定金额结算
                     $worker_price = $work->service_fee-$coupon_price;
@@ -64,6 +64,7 @@ class PerformanceLogic extends BaseLogic
 
             // 缴纳质保金
             $masterWorkerInfo = MasterWorker::where('id', $work->master_worker_id)->where('retention_money_status', 1)->findOrEmpty()->toArray();
+            Log::info('缴纳质保金工程师信息:'.json_encode($masterWorkerInfo));
             if(!empty($masterWorkerInfo) && $masterWorkerInfo['retention_pay_status'] == 2 && ($masterWorkerInfo['earnest_money'] > $masterWorkerInfo['earnest_money_usable'])){
                 $retentionData['action'] = WorkerAccountLogEnum::INC;
                 $retentionData['worker_id'] = $work->master_worker_id;

+ 15 - 10
app/workerapi/controller/WorksController.php

@@ -15,6 +15,7 @@ use app\workerapi\lists\ServiceWorkSparePartLists;
 use app\workerapi\lists\SparePartLists;
 use app\workerapi\validate\ServiceWorkValidate;
 use app\workerapi\validate\GoodsFeeStandardsValidate;
+use Exception;
 
 /**
  * 工单系统
@@ -95,17 +96,21 @@ class WorksController extends BaseApiController
      */
     public function detail()
     {
-        $params = (new ServiceWorkValidate())->goCheck('detail',[
-            'user_id' => $this->userId,
-        ]);
-        if(empty($params['id']) && empty($params['work_sn'])){
-            $this->fail('参数错误');
+        try {
+            $params = (new ServiceWorkValidate())->goCheck('detail',[
+                'user_id' => $this->userId,
+            ]);
+            if(empty($params['id']) && empty($params['work_sn'])){
+                $this->fail('参数错误');
+            }
+            $result = ServiceWorkLogic::detail($params);
+            if (false === $result) {
+                return $this->fail(ServiceWorkLogic::getError());
+            }
+            return $this->data($result);
+        } catch (Exception $e) {
+            return $this->fail($e->getMessage());
         }
-        $result = ServiceWorkLogic::detail($params);
-        if (false === $result) {
-            return $this->fail(ServiceWorkLogic::getError());
-        }
-        return $this->data($result);
     }
 
     /**

+ 10 - 1
app/workerapi/lists/GoodsCategoryLists.php

@@ -3,6 +3,7 @@ namespace app\workerapi\lists;
 
 use app\common\lists\ListsSearchInterface;
 use app\common\model\goods_category\GoodsCategory;
+use app\common\model\master_worker\MasterWorker;
 
 /**
  * GoodsCategory列表
@@ -26,7 +27,14 @@ class GoodsCategoryLists extends BaseWorkerDataLists implements ListsSearchInter
 
         ];
     }
-
+    public function queryWhere(){
+        $where = [];
+        if(!empty($this->userId)){
+            $ids = explode(',', MasterWorker::where('id', $this->userId)->value('category_ids'));
+            $ids && $where[] = ['id', 'in', $ids];
+        }
+        return $where;
+    }
 
     /**
      * @notes 获取列表
@@ -40,6 +48,7 @@ class GoodsCategoryLists extends BaseWorkerDataLists implements ListsSearchInter
     public function lists(): array
     {
         $lists = GoodsCategory::where($this->searchWhere)
+            //->where($this->queryWhere())
             ->field(['id', 'pid' ,'picture', 'name'])
             ->order(['weigh' => 'desc'])
             ->select()