FUND_TYPE::FUND1->value, // 金币账户 2 => FUND_TYPE::FUND2->value, // 钻石账户 ]; // 检查币种类型是否支持 if (!isset($map[$data['coinType']])) { $this->addError('coinType', '不支持的币种类型'); return false; } $fundId = $map[$data['coinType']]; $service = new FundService($data['userId'], $fundId); if ($service->balance() < $value ) { $this->addError('amount', '余额不足'); return false; } return true; } }