Procházet zdrojové kódy

处理删除支出项,检测是否是否是已经报销的支出项,如果是则处理下xhExpendBx表

shizhongqi před 1 rokem
rodič
revize
792243d55f
1 změnil soubory, kde provedl 14 přidání a 1 odebrání
  1. 14 1
      app-ghs/controllers/ExpendController.php

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

@@ -149,7 +149,8 @@ class ExpendController extends BaseController
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
-            $list = ExpendClass::getAllByCondition(['mainId' => $this->mainId, 'bx' => 0, 'staffId' => $staffId], null, '*', null, true);
+            $condition = ['mainId' => $this->mainId, 'bx' => 0, 'staffId' => $staffId, 'delStatus' => 0];
+            $list = ExpendClass::getAllByCondition($condition, null, '*', null, true);
             $total = 0;
             $staff = $this->shopAdmin;
             $bxData = [
@@ -390,6 +391,18 @@ class ExpendController extends BaseController
         if ($expend->mainId != $this->mainId){
             util::fail('没有找到支出数据');
         }
+        if ($expend->delStatus == 1) {
+            util::fail('此支出数据已是删除状态');
+        }
+
+        // 处理报销表数据
+        if ($expend->bxId != 0) {
+            $expendBx = ExpendBxClass::getById($expend->bxId, true);
+            $expendBx->amount = $expendBx->amount - $expend->amount;
+            $expendBx->remark = $expendBx->remark . "| " . date("Y-m-d H:i") . " 删除支出:ID=" . $expend->id;
+            $expendBx->save();
+        }
+
         $expend->delStaffId = $staffId;
         $expend->delStaffName = $staff->name;
         $expend->delStatus = 1;