Ver Fonte

Merge branch 'mt' of git.huaml.com:zhh/huahuibao into mt

shizhongqi há 4 anos atrás
pai
commit
82b45e2ec6

+ 1 - 1
app-ghs/controllers/ConsoleController.php

@@ -165,7 +165,7 @@ class ConsoleController extends BaseController
             ["name" => "出库记录", "img" => "ghs/home/dbck.png", "url" => "/pagesStorehouse/allot/allotEx"],
             ["name" => "入库记录", "img" => "ghs/home/dbrk.png", "url" => "/pagesStorehouse/allot/allotPut"],
             ["name" => "销售结账单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/clear/customList"],
-            ["name" => "采购结账单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/clear/list"],
+            ["name" => "支出登记", "img" => "ghs/home/kcyjs.png", "url" => "/admin/expend/addExpend"],
         ];
 
         util::success(['asset' => $this->main, 'notice' => $notice, 'todayData' => $todayData, 'incomeStat' => $incomeStat, 'menu' => $menu,]);

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

@@ -0,0 +1,37 @@
+<?php
+
+namespace ghs\controllers;
+
+use bizGhs\expend\classes\ExpendClass;
+use common\components\dict;
+use common\components\util;
+use Yii;
+
+class ExpendController extends BaseController
+{
+
+    public function actionList()
+    {
+        $where = [];
+        $where['mainId'] = $this->mainId;
+        $list = ExpendClass::getExpendList($where);
+        util::success($list);
+    }
+
+    //新增支出 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();
+    }
+
+}

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

@@ -0,0 +1,77 @@
+<?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()
+    {
+
+        $staff = $this->shopAdmin;
+        $mobile = $staff->mobile ?? 0;
+        if (in_array($mobile, ['15280215347', '13531700113', '18030262314']) == false) {
+            util::fail('没有权限');
+        }
+
+        $where = [];
+        $where['mainId'] = $this->mainId;
+        $list = SalaryClass::getSalaryList($where);
+        util::success($list);
+    }
+
+    //发工资 ssh 2022710
+    public function actionAddSalary()
+    {
+
+        $staff = $this->shopAdmin;
+        $mobile = $staff->mobile ?? 0;
+        if (in_array($mobile, ['15280215347', '13531700113', '18030262314']) == false) {
+            util::fail('没有权限');
+        }
+
+        $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('操作失败');
+        }
+    }
+
+}

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

@@ -0,0 +1,18 @@
+<?php
+
+namespace bizGhs\expend\classes;
+
+use bizHd\base\classes\BaseClass;
+
+class ExpendClass extends BaseClass
+{
+
+    public static $baseFile = '\bizGhs\expend\models\Expend';
+
+    public static function getExpendList($where)
+    {
+        $data = self::getList('*', $where, 'addTime DESC,id DESC');
+        return $data;
+    }
+
+}

+ 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';
+
+}

+ 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,//其它
+        ],
     ];
 
     //取配置文件的值