request->get(); $amount = $get['amount'] ?? 0; $password = $get['password'] ?? ''; $shopId = $get['shopId'] ?? 0; if (empty($amount) || is_numeric($amount) == false) { util::fail('请填写充值金额'); } $staff = $this->staff; if (password_verify($password, $staff->password) == false) { util::fail('密码错误'); } if (empty($shopId)) { util::fail('请先择门店'); } $shop = ShopClass::getLockById($shopId); if (empty($shop)) { util::fail('请先择门店!'); } if (getenv('YII_ENV', 'local') == 'production') { if ($staff->mobile != '15280215347') { util::fail('线上只有超管才能发起充值'); } } $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { $wxPay = dict::getDict('payWay', 'unknown'); $data = [ 'amount' => $amount, 'payWay' => $wxPay, 'sjId' => $shop->sjId, 'sjStyle' => $shop->ptStyle, 'shopId' => $shopId, 'modPrice' => 0, 'remark' => '', ]; $order = RechargeClass::addOrder($data, true); $tx = dict::getDict('yeTx', 'canNot'); $capitalType = dict::getDict('capitalType', 'xhRecharge'); ShopClass::rechargeAddBalance($shop, $amount, $order, $tx, $capitalType); $transaction->commit(); util::complete(); } catch (\Exception $exception) { Yii::info("shopId:{$shopId}充值{$amount}元,系统操作失败:" . $exception->getMessage()); util::fail('操作失败'); } } }