shish 2 ani în urmă
părinte
comite
a44271bb4a

+ 12 - 0
app-ghs/controllers/ExpendController.php

@@ -2,6 +2,7 @@
 
 namespace ghs\controllers;
 
+use bizGhs\expend\classes\ExpendBxClass;
 use bizGhs\expend\classes\ExpendClass;
 use bizGhs\shop\classes\MainClass;
 use bizGhs\shop\classes\ShopAdminClass;
@@ -53,12 +54,23 @@ class ExpendController extends BaseController
         try {
             $list = ExpendClass::getAllByCondition(['mainId' => $this->mainId, 'bx' => 0, 'staffId' => $staffId], null, '*', null, true);
             $total = 0;
+            $staff = $this->shopAdmin;
+            $bxData = [
+                'mainId' => $this->mainId,
+                'staffId' => $staff->id ?? 0,
+                'staffName' => $staff->name ?? '',
+            ];
+            $bx = ExpendBxClass::add($bxData, true);
+            $bxId = $bx->id ?? 0;
             foreach ($list as $it) {
                 $amount = $it->amount ?? 0;
                 $total = bcadd($total, $amount, 2);
                 $it->bx = 1;
+                $it->bxId = $bxId;
                 $it->save();
             }
+            $bx->amount = $total;
+            $bx->save();
             if (floatval($amount) != floatval($total)) {
                 util::fail('金额有问题,返回上页再进来');
             }

+ 12 - 0
biz-ghs/expend/classes/ExpendBxClass.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace bizGhs\expend\classes;
+
+use bizHd\base\classes\BaseClass;
+
+class ExpendBxClass extends BaseClass
+{
+
+    public static $baseFile = '\bizGhs\expend\models\ExpendBx';
+
+}

+ 15 - 0
biz-ghs/expend/models/ExpendBx.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace bizGhs\expend\models;
+
+use bizHd\base\models\Base;
+
+class ExpendBx extends Base
+{
+
+    public static function tableName()
+    {
+        return 'xhExpendBx';
+    }
+
+}