2
0

CreditPolicyController.php 880 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace App\Http\Controllers\V3;
  3. use App\Http\Controllers\Controller;
  4. use App\Http\Resources\V3\CreditPolicyResource;
  5. use App\Services\V3\CreditService;
  6. /**
  7. * AI 对话积分策略(单例资源,公开)。
  8. *
  9. * 新资源,没有 v2 前身。策略写在 `config('mint.credits.policy')`,只有当前生效的一版,历史看 git。
  10. */
  11. class CreditPolicyController extends Controller
  12. {
  13. public function __construct(private readonly CreditService $credits) {}
  14. /**
  15. * 查看当前的积分策略
  16. *
  17. * 每天赠送多少、每次提问多少钱、读经和编辑怎么换积分。`version` 是生效日(YYYYMMDD),
  18. * 也记在每笔积分流水里。「一天」按 UTC 算。
  19. *
  20. * @unauthenticated
  21. */
  22. public function __invoke()
  23. {
  24. return CreditPolicyResource::make($this->credits->policy());
  25. }
  26. }