Jelajahi Sumber

登记报销

shish 2 tahun lalu
induk
melakukan
9035007632
1 mengubah file dengan 17 tambahan dan 14 penghapusan
  1. 17 14
      app-ghs/controllers/ExpendController.php

+ 17 - 14
app-ghs/controllers/ExpendController.php

@@ -190,17 +190,6 @@ class ExpendController extends BaseController
             }
             $staffName = $staff->name ?? '';
             $ptStyle = dict::getDict('ptStyle', 'ghs');
-            $bxId = 0;
-            if ($bx == 1) {
-                $bxData = [
-                    'mainId' => $this->mainId,
-                    'staffId' => $getStaffId,
-                    'staffName' => $staffName,
-                    'remark' => '登记时已报销',
-                ];
-                $bx = ExpendBxClass::add($bxData, true);
-                $bxId = $bx->id ?? 0;
-            }
             $expendData = [
                 'type' => $type,
                 'amount' => $amount,
@@ -213,9 +202,23 @@ class ExpendController extends BaseController
                 'bx' => $bx,
                 'bxId' => $bxId,
             ];
-            ExpendClass::add($expendData);
-            $bx->amount = $amount;
-            $bx->save();
+            $respond = ExpendClass::add($expendData, true);
+
+            if ($bx == 1) {
+                $bxData = [
+                    'mainId' => $this->mainId,
+                    'staffId' => $getStaffId,
+                    'staffName' => $staffName,
+                    'remark' => '登记时已报销',
+                ];
+                $bxInfo = ExpendBxClass::add($bxData, true);
+                $bxId = $bxInfo->id ?? 0;
+                $bxInfo->amount = $amount;
+                $bxInfo->save();
+                $respond->bxId = $bxId;
+                $respond->save();
+            }
+
             $transaction->commit();
             util::complete();
         } catch (\Exception $e) {