shish před 4 roky
rodič
revize
6b7961ef50

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

@@ -0,0 +1,29 @@
+<?php
+
+namespace ghs\controllers;
+
+use bizGhs\expend\classes\ExpendClass;
+use common\components\dict;
+use common\components\util;
+use Yii;
+
+class ExpendController extends BaseController
+{
+
+    //新增支出 ssh 20220710
+    public function actionAddExpend()
+    {
+        $post = Yii::$app->request->post();
+        $type = $post['type'] ?? dict::getDict('expendType', 'hs');
+        $amount = $post['amount'] ?? 0;
+        if (is_numeric($amount) == false || $amount <= 0) {
+            util::fail('请输入正确的金额');
+        }
+        $remark = $post['remark'] ?? '';
+        $staffName = $this->shopAdmin->name ?? '';
+        $data = ['type' => $type, 'amount' => $amount, 'remark' => $remark, 'mainId' => $this->mainId, 'staffId' => $this->shopAdminId, 'staffName' => $staffName];
+        ExpendClass::add($data);
+        util::complete();
+    }
+
+}

+ 8 - 0
common/components/dict.php

@@ -328,6 +328,14 @@ class dict
             4 => '美团',
             5 => '饿了么',
         ],
+        'expendType' => [
+            'dz' => 0,//店租
+            'sd' => 1,//水电
+            'wy' => 2,//物业
+            'hs' => 3,//伙食
+            'fz' => 4,//房租
+            'qt' => 5,//其它
+        ],
     ];
 
     //取配置文件的值