ソースを参照

Merge remote-tracking branch 'origin/master'

cqp 2 ヶ月 前
コミット
c37e86fd78
1 ファイル変更9 行追加5 行削除
  1. 9 5
      app/Service/AuxiliaryAccountService.php

+ 9 - 5
app/Service/AuxiliaryAccountService.php

@@ -128,6 +128,10 @@ class AuxiliaryAccountService extends Service
         $model = new ExpenseClaimsDetails();
         //总金额
         $list = $model->where('expense_claims_id',$month_ps_order_id)->where('del_time',0)->select("fee_id","amount as total_amount","remark","entrust_type","item_id")->get()->toArray();
+        foreach ($list as &$v){
+            $v['entrust1_amount'] = $v['entrust_type'] == 1 ?  $v['total_amount'] : 0;
+            $v['entrust2_amount'] = $v['entrust_type'] == 2 ?  $v['total_amount'] : 0;
+        }
         ///分组
         $fee_type_list = Fee::Clear($user,$data)->where('del_time',0)->select("title","id","parent_id")->get()->toArray();
 
@@ -205,18 +209,18 @@ class AuxiliaryAccountService extends Service
             $model->crt_id = $user['id'];
             $model->top_depart_id = $user['top_depart_id'];
             $model->save();
-            $this->saveDetail($model->id, time(), $data,$user['id']);
+            $this->saveDetail($model->id, time(), $data,$user['id'],$user);
 
             DB::commit();
         }catch (\Exception $exception){
             DB::rollBack();
-            return [false,$exception->getMessage()];
+            return [false,$exception->getLine().':'.$exception->getMessage()];
         }
 
         return [true, ''];
     }
 
-    private function saveDetail($id, $time, $data,$crt_id){
+    private function saveDetail($id, $time, $data,$crt_id,$user){
         if(! empty($data['details'])){
             $unit = [];
             foreach ($data['details'] as $value){
@@ -235,7 +239,7 @@ class AuxiliaryAccountService extends Service
                     'entrust2_amount' => $value['entrust2_amount']??0,
                     'aggregation_amount' => $value['aggregation_amount']??00,
                     'total_amount' => $value['total_amount'],
-                    'top_depart_id' => $data['top_depart_id'],
+                    'top_depart_id' => $user['top_depart_id'],
                     'item_id' => $value['item_id'],
                     'crt_time' => $time,
                     'crt_id' => $crt_id,
@@ -282,7 +286,7 @@ class AuxiliaryAccountService extends Service
             if ($claimTime < $monthStart || $claimTime > $monthEnd) return [false, "第" . ($index + 1) . "凭证日期必须早于当前结算月份(" . date("Y-m", $data['month']) . ")"];
         }
 
-        $query = AuxiliaryAccount::where('top_depart_id', $data['top_depart_id'])
+        $query = AuxiliaryAccount::where('top_depart_id', $user['top_depart_id'])
             ->where('month', $monthStart)
             ->where('del_time', 0);