|
|
@@ -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('操作失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|