From 1c4f0ed2b28e7a1520f01b79bf8646a1b3d30843 Mon Sep 17 00:00:00 2001 From: ModStart Date: Tue, 29 Oct 2024 15:45:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=EF=BC=9A=E5=8F=91=E5=B8=839.?= =?UTF-8?q?0.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Constant/AppConstant.php | 2 +- .../Admin/Controller/MemberController.php | 1 + module/Member/Core/ModuleServiceProvider.php | 21 ++++++++++++-- module/Member/Docs/release.md | 1 + ...00_member_user_register_ip_name_modify.php | 29 +++++++++++++++++++ 5 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 module/Member/Migrate/2024_10_29_000000_member_user_register_ip_name_modify.php diff --git a/app/Constant/AppConstant.php b/app/Constant/AppConstant.php index 5874aff1..82d6c760 100644 --- a/app/Constant/AppConstant.php +++ b/app/Constant/AppConstant.php @@ -6,5 +6,5 @@ class AppConstant { const APP = 'cms'; const APP_NAME = 'ModStartCMS'; - const VERSION = '8.9.0'; + const VERSION = '9.0.0'; } diff --git a/module/Member/Admin/Controller/MemberController.php b/module/Member/Admin/Controller/MemberController.php index 5b16cf72..99588de6 100644 --- a/module/Member/Admin/Controller/MemberController.php +++ b/module/Member/Admin/Controller/MemberController.php @@ -146,6 +146,7 @@ protected function crud(AdminCRUDBuilder $builder) $builder->datetime('vipExpire', 'VIP过期'); } $builder->display('registerIp', '注册IP'); + $builder->display('registerIpName', '注册IP定位'); $builder->display('created_at', '注册时间'); $builder->canBatchSelect(true); $builder->batchOperatePrepend(''); diff --git a/module/Member/Core/ModuleServiceProvider.php b/module/Member/Core/ModuleServiceProvider.php index 32632af2..a62a699b 100644 --- a/module/Member/Core/ModuleServiceProvider.php +++ b/module/Member/Core/ModuleServiceProvider.php @@ -9,6 +9,7 @@ use ModStart\Admin\Widget\DashboardItem; use ModStart\Admin\Widget\DashboardItemA; use ModStart\Core\Util\ColorUtil; +use ModStart\Core\Util\StrUtil; use ModStart\Data\Event\DataDeletedEvent; use ModStart\Data\Event\DataUploadedEvent; use ModStart\Data\Event\DataUploadingEvent; @@ -33,6 +34,7 @@ use Module\Vendor\Admin\Widget\AdminWidgetDashboard; use Module\Vendor\Admin\Widget\AdminWidgetLink; use Module\Vendor\Job\MailSendJob; +use Module\Vendor\Provider\LBS\IpProvider; use Module\Vendor\Provider\Schedule\ScheduleBiz; use Module\Vendor\Provider\SmsTemplate\SmsTemplateProvider; use Module\Voucher\Biz\VoucherBiz; @@ -226,9 +228,9 @@ public function boot(Dispatcher $events) } Event::listen(MemberUserRegisteredEvent::class, function (MemberUserRegisteredEvent $e) { + $memberUser = MemberUtil::getCached($e->memberUserId); // VIP赠送积分 if (ModuleManager::getModuleConfig('Member', 'creditEnable', false)) { - $memberUser = MemberUtil::getCached($e->memberUserId); $vipSet = MemberVipUtil::get($memberUser['vipId']); if ($vipSet['creditPresentEnable']) { if ($vipSet['creditPresentValue']) { @@ -239,20 +241,33 @@ public function boot(Dispatcher $events) // 注册发送邮件 $message = modstart_config('Member_Registered_Message', ''); if ($message) { - $memberUser = MemberUtil::getCached($e->memberUserId); $message = MemberParamUtil::replaceParam($message, $memberUser); MemberMessageUtil::send($e->memberUserId, MemberParamUtil::replaceParam($message, $memberUser)); } $emailContent = modstart_config('Member_Registered_Email', ''); $emailTitle = modstart_config('Member_Registered_EmailTitle', ''); if ($emailTitle && $emailContent) { - $memberUser = MemberUtil::getCached($e->memberUserId); if (!empty($memberUser['email'])) { $emailTitle = MemberParamUtil::replaceParam($emailTitle, $memberUser); $emailContent = MemberParamUtil::replaceParam($emailContent, $memberUser); MailSendJob::createHtml($memberUser['email'], $emailTitle, $emailContent); } } + // 注册信息更新 + $registerIpNameRes = IpProvider::firstResponse($memberUser['registerIp']); + if (!empty($registerIpNameRes)) { + $name = join('', array_filter([ + $registerIpNameRes->country, + $registerIpNameRes->province, + $registerIpNameRes->city, + $registerIpNameRes->district, + ])); + if (!empty($name)) { + MemberUtil::update($memberUser['id'], [ + 'registerIpName' => StrUtil::mbLimit($name, 30), + ]); + } + } }); AdminMenu::register(function () { diff --git a/module/Member/Docs/release.md b/module/Member/Docs/release.md index 4a9879e1..b0c0b843 100644 --- a/module/Member/Docs/release.md +++ b/module/Member/Docs/release.md @@ -3,6 +3,7 @@ - 新增:VIP 优惠券功能集成,支持折扣券 - 新增:可完全自定义上传功能定制的特性 UploadScript Hook - 新增:用户登录传输用户密码加密 +- 新增:用户注册增加注册IP定位,支持用户注册地理位置记录 - 优化:VIP 开通页面交互形式优化 --- diff --git a/module/Member/Migrate/2024_10_29_000000_member_user_register_ip_name_modify.php b/module/Member/Migrate/2024_10_29_000000_member_user_register_ip_name_modify.php new file mode 100644 index 00000000..0d7fbab4 --- /dev/null +++ b/module/Member/Migrate/2024_10_29_000000_member_user_register_ip_name_modify.php @@ -0,0 +1,29 @@ +string('registerIpName', 30)->nullable()->comment('注册IP定位'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + + } +}