liugc 1 рік тому
батько
коміт
f193daa5e4

+ 14 - 2
app/adminapi/lists/effective/OrderEffectiveLogLists.php

@@ -16,8 +16,10 @@ namespace app\adminapi\lists\effective;
 
 
 use app\adminapi\lists\BaseAdminDataLists;
-use app\common\model\effective\OrderEffectiveLog;
+use app\adminapi\logic\effective\OrderEffectiveLogLogic;
+use app\common\model\orders\OrderEffectiveLog;
 use app\common\lists\ListsSearchInterface;
+use app\common\model\works\ServiceWork;
 
 
 /**
@@ -55,12 +57,22 @@ class OrderEffectiveLogLists extends BaseAdminDataLists implements ListsSearchIn
      */
     public function lists(): array
     {
-        return OrderEffectiveLog::where($this->searchWhere)
+        $list = OrderEffectiveLog::with(['goods'=>function ($query) {
+                $query->with(['goodsCategory'=>function ($query1) {
+                    $query1->field(['name','picture']);
+                }]);
+            },'serviceWork','originalServiceWork'])->where('effective_status','>',0)->where($this->searchWhere)
             ->field(['*'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
             ->select()
             ->toArray();
+
+        foreach ($list as &$value) {
+            $value['income_fee'] = 0;
+            if($value['originalServiceWork']) $value['income_fee'] = OrderEffectiveLogLogic::commissionAndAssuranceDeposit($value['originalServiceWork']);
+        }
+        return $list;
     }
 
 

+ 2 - 2
app/adminapi/logic/effective/OrderEffectiveLogLogic.php

@@ -20,7 +20,7 @@ use app\common\enum\GoodsEnum;
 use app\common\enum\PayEnum;
 use app\common\enum\WorkEnum;
 use app\common\enum\worker\WorkerAccountLogEnum;
-use app\common\model\effective\OrderEffectiveLog;
+use app\common\model\orders\OrderEffectiveLog;
 use app\common\logic\BaseLogic;
 use app\common\model\goods\Goods;
 use app\common\model\master_worker\MasterWorkerAccountLog;
@@ -140,7 +140,7 @@ class OrderEffectiveLogLogic extends BaseLogic
             'action'=>WorkerAccountLogEnum::INC,'worker_id'=>$serviceWork['master_worker_id'],
             'work_sn'=>$serviceWork['work_sn']])->value('change_amount');
         $retentionAmount = MasterWorkerRetentionMoneyLog::where(['action'=>WorkerAccountLogEnum::INC,'source'=>2,'worker_id'=>$serviceWork['master_worker_id'],'work_id'=>$serviceWork['id']])->value('amount');
-        return $change_amount + $retentionAmount;
+        return bcadd((string)$change_amount,(string)$retentionAmount,2);
     }
 
 

+ 1 - 1
app/api/logic/OrderEffectiveLogLogic.php

@@ -15,7 +15,7 @@
 namespace app\api\logic;
 
 
-use app\common\model\effective\OrderEffectiveLog;
+use app\common\model\orders\OrderEffectiveLog;
 use app\common\logic\BaseLogic;
 use think\facade\Db;
 

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

@@ -7,7 +7,7 @@ use app\common\logic\BaseLogic;
 use app\common\logic\EffectiveLogic;
 use app\common\logic\WorkAddMoneyLogic;
 use app\common\logic\WorkerAccountLogLogic;
-use app\common\model\effective\OrderEffectiveLog;
+use app\common\model\orders\OrderEffectiveLog;
 use app\common\model\master_commission\MasterWorkerCommissionConfig;
 use app\common\model\master_commission\MasterWorkerCommissionRatio;
 use app\common\model\master_worker\MasterWorker;
@@ -193,7 +193,7 @@ class PerformanceLogic extends BaseLogic
     /**
      * @notes 保修单结算
      * @param $work
-     * @return false|void
+     * @return bool|mixed
      */
     public static function effectivePerformance($work)
     {
@@ -220,6 +220,11 @@ class PerformanceLogic extends BaseLogic
 
             $remark = '保修单结算-工单号:'.$work->work_sn.',收益金额:'.$new_amount.',原因:保修工单新工程师收益';
             WorkerAccountLogLogic::addAccountLog($work,$new_amount,WorkerAccountLogEnum::UM_INC_ADMIN,WorkerAccountLogEnum::INC,$remark);
+
+            Log::info('effectivePerformance:'.$remark);
         }
+        $orderEffectiveLog->effective_status = 3;
+        $orderEffectiveLog->save();
+        return true;
     }
 }

+ 10 - 1
app/common/model/orders/OrderEffectiveLog.php

@@ -11,11 +11,20 @@ use app\common\model\works\ServiceWork;
 class OrderEffectiveLog extends BaseModel
 {
     protected $name = 'order_effective_log';
-
+    protected $type = [
+        'effective_images' => 'array',
+    ];
     public function goods()
     {
         return $this->hasOne(Goods::class, 'id', 'goods_id');
     }
+
+    public function originalServiceWork()
+    {
+        return $this->hasOne(ServiceWork::class, 'id', 'work_id');
+    }
+
+
     public function serviceWork()
     {
         return $this->hasOne(ServiceWork::class, 'order_effective_id', 'id');