diff --git a/app/Cache/Redis/Common/ConfigCache.php b/app/Cache/Redis/Common/ConfigCache.php index 7f3b1b2..645e041 100644 --- a/app/Cache/Redis/Common/ConfigCache.php +++ b/app/Cache/Redis/Common/ConfigCache.php @@ -7,6 +7,7 @@ use App\Constants\ConfigCode; use App\Constants\RedisCode; use App\Model\Config; use App\Model\Cycle; +use App\Service\ServiceTrait\Common\OssTrait; use Hyperf\Di\Annotation\Inject; use Hyperf\Tappable\HigherOrderTapProxy; use Psr\Container\ContainerExceptionInterface; @@ -14,6 +15,7 @@ use Psr\Container\NotFoundExceptionInterface; class ConfigCache { + use OssTrait; /** * @var RedisCache @@ -62,21 +64,29 @@ class ConfigCache /** * @param $key - * @param int $isRedis + * @param int $isRedis //默认走缓存 可以关闭 * @param int $expire * @return false|HigherOrderTapProxy|mixed|\Redis|string * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function getConfigValueByKey($key, int $isRedis = 0,int $expire = 600): mixed + public function getConfigValueByKey($key, int $isRedis = 1,int $expire = 600): mixed { $redisKey = CommonRedisKey::getConfigKey($key); if (!$this->redis->exists($redisKey,RedisCode::SYSTEM_DB)) { $value = $this->configModel->where('key',$key)->value('value'); + + // 做转换 + $value = match ($key) { + ConfigCode::APP_LOGO => $this->getOssObjectById($value), + default => $value, + }; + if ($isRedis == 1) { $this->redis->setEx($redisKey, $value, $expire,RedisCode::SYSTEM_DB); } + return $value ?? ConfigCode::DEFAULT_VALUE[$key]; } diff --git a/app/Constants/ConfigCode.php b/app/Constants/ConfigCode.php index c927413..90eb109 100644 --- a/app/Constants/ConfigCode.php +++ b/app/Constants/ConfigCode.php @@ -14,6 +14,12 @@ class ConfigCode const string NUMBER_OF_USER_ADDRESS_POOLS = 'NumberOfUserAddressPools'; // 用户可以设置的送达地址的数量 const string MAXIMUM_VALUE_IN_FULL_BOX = 'MaximumValueInFullBox'; //运输箱最大可装自选盒数 const string MAXIMUM_WHOLE_CASE_SPLIT = 'MaximumWholeCaseSplit'; //运输箱分割列数最大值 + const string ABOUT_US_SYNOPSIS = 'AboutUsSynopsis'; // 关于我们 - 简介 + const string BUSINESS_LICENSE = 'BusinessLicense'; // 营业执照 + const string USER_AGREEMENT = 'UserAgreement'; // 用户使用协议 + const string USER_PRIVACY_AGREEMENT = 'UserPrivacyAgreement'; // 用户隐私协议 + const string APP_LOGO = 'AppLogo'; // app 图标 + /** * @var string CouponConfiguration|优惠券配置 @@ -34,6 +40,11 @@ class ConfigCode self::NUMBER_OF_USER_ADDRESS_POOLS => 10, self::MAXIMUM_VALUE_IN_FULL_BOX => 32, self::MAXIMUM_WHOLE_CASE_SPLIT => 4, + self::ABOUT_US_SYNOPSIS => '关于我们-xxxx', + self::BUSINESS_LICENSE => 'https://www.baidu.com', + self::USER_AGREEMENT => 'https://www.baidu.com', + self::USER_PRIVACY_AGREEMENT => 'https://www.baidu.com', + self::APP_LOGO => 'https://www.baidu.com', //CouponConfiguration self::COUPONS_FOR_NEWCOMERS => '0', self::NEWBIE_COUPON_VALIDITY => '0', diff --git a/app/Controller/Api/SystemController.php b/app/Controller/Api/SystemController.php index d25fdb1..80c27db 100644 --- a/app/Controller/Api/SystemController.php +++ b/app/Controller/Api/SystemController.php @@ -7,6 +7,7 @@ namespace App\Controller\Api; use App\Controller\AbstractController; use App\Middleware\Api\JwtAuthMiddleware; use App\Service\Api\System\CityListService; +use App\Service\Api\System\MiniWxConfigService; use App\Service\Api\System\SiteListService; use Hyperf\HttpServer\Annotation\Controller; use Hyperf\HttpServer\Annotation\Middlewares; @@ -30,4 +31,11 @@ class SystemController extends AbstractController { return (new CityListService)->handle(); } + + #[RequestMapping(path: 'mini_wx/config',methods: 'GET')] + #[Scene(scene: 'mini_wx_config')] + public function getMiniWxConfig() + { + return (new MiniWxConfigService)->handle(); + } } diff --git a/app/Service/Api/System/MiniWxConfigService.php b/app/Service/Api/System/MiniWxConfigService.php new file mode 100644 index 0000000..11a84c1 --- /dev/null +++ b/app/Service/Api/System/MiniWxConfigService.php @@ -0,0 +1,58 @@ + $this->configCache->getConfigValueByKey(ConfigCode::APP_LOGO), + 'about_us' => [ + 'synopsis' => $this->configCache->getConfigValueByKey(ConfigCode::ABOUT_US_SYNOPSIS), + 'jump_page' => [ + [ + 'title' => '营业执照', + 'url' => $this->configCache->getConfigValueByKey(ConfigCode::BUSINESS_LICENSE) + ], + [ + 'title' => '用户使用协议', + 'url' => $this->configCache->getConfigValueByKey(ConfigCode::USER_AGREEMENT) + ], + [ + 'title' => '用户隐私协议', + 'url' => $this->configCache->getConfigValueByKey(ConfigCode::USER_PRIVACY_AGREEMENT) + ], + ] + ] + ]; + + return $this->return->success('success', $res); + } +} \ No newline at end of file