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