request->get(); $customId = $get['customId'] ?? 0; $custom = CustomClass::getById($customId); CustomClass::valid($custom, $this->shopId); $where = []; $where['customId'] = $customId; $list = CustomRechargeClass::getRechargeList($where); util::success($list); } /** * 充值退款:财务权限;线上原路退,线下扣减余额并记变动明细。 */ public function actionRefund() { $staff = $this->shopAdmin; if (!isset($staff->finance) || intval($staff->finance) === 0) { util::fail('请有财务权限的人操作'); } $post = Yii::$app->request->post(); $id = intval($post['id'] ?? 0); if ($id <= 0) { util::fail('参数错误'); } $cacheKey = 'ghs_custom_recharge_refund_' . $id; $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]); if (!empty($has)) { util::fail('请5秒之后再提交'); } Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 5, 'has']); $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { CustomRechargeClass::refundPaidRecharge($id, $this->shop, $staff); $transaction->commit(); util::complete('退款成功'); } catch (\Exception $e) { $transaction->rollBack(); Yii::info('充值退款失败:' . $e->getMessage()); util::fail($e->getMessage() ?: '退款失败'); } } }