SystemServiceSetup.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. declare(strict_types=1);
  3. namespace app\miniapi\service;
  4. final class SystemServiceSetup
  5. {
  6. public static function build(array $capabilities): array
  7. {
  8. $messages = [];
  9. if (!($capabilities['wechat_login'] ?? false)) {
  10. $messages['wechat_login'] = [
  11. 'action' => 'configure',
  12. 'summary' => 'WeChat login is not configured.',
  13. 'steps' => [
  14. 'Set the mini program AppID in water-mini/src/manifest.json.',
  15. 'Set MINI_WECHAT_APPID and MINI_WECHAT_SECRET in server/.env; keep the secret on the server.',
  16. 'Configure the HTTPS API domain in the WeChat mini program console and water-mini/.env.local.',
  17. 'Restart the Webman service after saving configuration.',
  18. 'Verify capabilities.wechat_login from GET /api/mini/v1/config.',
  19. 'Use wx.login and bind the new mini user to a business identity in the admin panel.',
  20. ],
  21. ];
  22. }
  23. if (!($capabilities['test_phone_login'] ?? false)) {
  24. $messages['test_phone_login'] = ['action' => 'optional', 'summary' => 'Local test phone login is disabled.', 'steps' => ['Use APP_ENV=local and MINI_TEST_PHONE_LOGIN=true only for local testing.', 'Restart Webman after changing the setting.']];
  25. }
  26. if (($capabilities['sms_login'] ?? false) === false && config('mini_api.sms_login', false) === true) {
  27. $messages['sms_login'] = [
  28. 'action' => 'configure',
  29. 'summary' => 'SMS login is enabled but the provider account is incomplete.',
  30. 'steps' => [
  31. 'Set MINI_SMS_USER and MINI_SMS_PASSWORD in server/.env.',
  32. 'Confirm the provider account has remaining balance.',
  33. 'Bind the phone to a mini user in the admin panel before sending codes to it.',
  34. ],
  35. ];
  36. }
  37. return $messages;
  38. }
  39. }