shish 1 rok temu
rodzic
commit
298a71e1c9
1 zmienionych plików z 9 dodań i 15 usunięć
  1. 9 15
      app-ghs/controllers/ExpendController.php

+ 9 - 15
app-ghs/controllers/ExpendController.php

@@ -104,7 +104,7 @@ class ExpendController extends BaseController
                 $currentAmount = $amount;
                 $unAmount = $amount;
                 if (isset($arr[$staffId])) {
-                    $arr[$staffId]['amount'] = bcadd($arr[$staffId]['amount'], $unAmount,2);
+                    $arr[$staffId]['amount'] = bcadd($arr[$staffId]['amount'], $unAmount, 2);
                     $arr[$staffId]['num'] = bcadd($arr[$staffId]['num'], 1);
                 } else {
                     $arr[$staffId]['totalAmount'] = $currentAmount;
@@ -170,7 +170,7 @@ class ExpendController extends BaseController
             $bx->amount = $total;
             $bx->save();
             if (floatval($postAmount) != floatval($total)) {
-                util::fail('金额错误,请刷新页面,实际:'.floatval($total));
+                util::fail('金额错误,请刷新页面,实际:' . floatval($total));
             }
             $transaction->commit();
             util::complete();
@@ -207,9 +207,7 @@ class ExpendController extends BaseController
         if ($bx != -1) {
             $where['bx'] = $bx;
         }
-        if (true) { //过滤掉已删除的
-            $where['delStatus'] = 0;
-        }
+        $where['delStatus'] = 0;
         $searchTime = isset($get['searchTime']) && !empty($get['searchTime']) ? $get['searchTime'] : 'thisYear';
         $startTime = $get['startTime'] ?? '';
         $endTime = $get['endTime'] ?? '';
@@ -261,7 +259,7 @@ class ExpendController extends BaseController
         $amount = $post['amount'] ?? 0;
         $remark = $post['remark'] ?? '';
         $bx = $post['bx'] ?? -1;
-        if (is_numeric($amount) == false || $amount <= 0) {
+        if (!is_numeric($amount) || $amount <= 0) {
             util::fail('请输入正确的金额');
         }
         if ($bx == -1) {
@@ -367,13 +365,9 @@ class ExpendController extends BaseController
     //删除支出
     public function actionDelExpend()
     {
-        $mainId = $this->mainId;
-        if (getenv('YII_ENV') == 'production') {
-            if (in_array($mainId, [23390])) {
-                if (!in_array($this->adminId, [24655])) {
-                    util::fail('请财务人员操作吧');
-                }
-            }
+        $staff = $this->shopAdmin;
+        if ($staff->finance == 0) {
+            util::fail('没有财务权限');
         }
 
         $post = Yii::$app->request->post();
@@ -388,7 +382,7 @@ class ExpendController extends BaseController
 
         $id = intval($post['id']);
         $expend = ExpendClass::getById($id, true);
-        if ($expend->mainId != $this->mainId){
+        if ($expend->mainId != $this->mainId) {
             util::fail('没有找到支出数据');
         }
         if ($expend->delStatus == 1) {
@@ -398,7 +392,7 @@ class ExpendController extends BaseController
         // 处理报销表数据
         if ($expend->bxId != 0) {
             $expendBx = ExpendBxClass::getById($expend->bxId, true);
-            $expendBx->amount = $expendBx->amount - $expend->amount;
+            $expendBx->amount = bcsub($expendBx->amount, $expend->amount, 2);
             $expendBx->remark = $expendBx->remark . " | " . date("Y-m-d H:i") . " 删除支出:ID=" . $expend->id;
             $expendBx->save();
         }