Ver Fonte

发工资

shish há 4 anos atrás
pai
commit
fba7f6503d

+ 63 - 0
app-ghs/controllers/SalaryController.php

@@ -0,0 +1,63 @@
+<?php
+
+namespace ghs\controllers;
+
+use bizGhs\shop\classes\ShopAdminClass;
+use bizGhs\staff\classes\SalaryClass;
+use common\components\dict;
+use common\components\util;
+use Yii;
+
+class SalaryController extends BaseController
+{
+
+    public $guestAccess = [];
+
+    public function actionList()
+    {
+        $where = [];
+        $where['mainId'] = $this->mainId;
+        $list = SalaryClass::getSalaryList($where);
+        util::success($list);
+    }
+
+    //发工资 ssh 2022710
+    public function actionAddSalary()
+    {
+        $post = Yii::$app->request->post();
+        $data = $post['data'] ?? '';
+        if (empty($data)) {
+            util::fail('请填写工资');
+        }
+        $arr = json_decode($data, true);
+        if (is_array($arr) == false) {
+            util::fail('请填写工资哦');
+        }
+        $connection = Yii::$app->db;
+        $transaction = $connection->beginTransaction();
+        try {
+            $ids = array_column($arr, 'staffId');
+            $info = ShopAdminClass::getByIds($ids, null, 'id');
+            foreach ($arr as $item) {
+                $staffId = $item['staffId'] ?? 0;
+                if (isset($info[$staffId]) == false) {
+                    util::fail('员工有问题哦');
+                }
+                $current = $info[$staffId];
+                $name = $current['name'] ?? '';
+                $mobile = $current['mobile'] ?? '';
+                $adminId = $current['adminId'] ?? 0;
+                $amount = $item['amount'] ?? 0;
+                $data = ['name' => $name, 'mobile' => $mobile, 'adminId' => $adminId, 'amount' => $amount, 'mainId' => $this->mainId, 'sjId' => $this->sjId];
+                SalaryClass::addData($data);
+            }
+            $transaction->commit();
+            util::complete();
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            Yii::info("失败原因:" . $e->getMessage());
+            util::fail('操作失败');
+        }
+    }
+
+}

+ 11 - 0
biz-ghs/expend/classes/ExpendClass.php

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

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

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

+ 14 - 0
biz-ghs/expend/services/ExpendService.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace bizGhs\staff\services;
+
+use bizHd\base\services\BaseService;
+use common\components\util;
+use Yii;
+
+class ExpendService extends BaseService
+{
+
+    public static $baseFile = '\bizGhs\expend\classes\ExpendClass';
+
+}

+ 23 - 0
biz-ghs/staff/classes/SalaryClass.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace bizGhs\staff\classes;
+
+use bizHd\base\classes\BaseClass;
+
+class SalaryClass extends BaseClass
+{
+
+    public static $baseFile = '\bizGhs\staff\models\Salary';
+
+    public static function getSalaryList($where)
+    {
+        $data = self::getList('*', $where, 'addTime DESC,id DESC');
+        return $data;
+    }
+
+    public static function addData($data)
+    {
+        self::add($data);
+    }
+
+}

+ 15 - 0
biz-ghs/staff/models/Salary.php

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

+ 14 - 0
biz-ghs/staff/services/SalaryService.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace bizGhs\staff\services;
+
+use bizHd\base\services\BaseService;
+use common\components\util;
+use Yii;
+
+class SalaryService extends BaseService
+{
+
+    public static $baseFile = '\bizGhs\staff\classes\SalaryClass';
+
+}