[fix] VipPrivilege

This commit is contained in:
Lkeme 2022-09-01 15:30:27 +08:00
parent 0c32ce0256
commit 5b814434a8
6 changed files with 27 additions and 10 deletions

View File

@ -17,7 +17,7 @@
<p align="center"> <p align="center">
<img src="https://img.shields.io/badge/Version-2.0.0.220822-orange.svg?longCache=true&style=for-the-badge"> <img src="https://img.shields.io/badge/Version-2.0.0.220822-orange.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/PHP-8.0+-green.svg?longCache=true&style=for-the-badge"> <img src="https://img.shields.io/badge/PHP-8.1+-green.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/Composer-latest-blueviolet.svg?longCache=true&style=for-the-badge"> <img src="https://img.shields.io/badge/Composer-latest-blueviolet.svg?longCache=true&style=for-the-badge">
<img src="https://img.shields.io/badge/License-mit-blue.svg?longCache=true&style=for-the-badge"> <img src="https://img.shields.io/badge/License-mit-blue.svg?longCache=true&style=for-the-badge">

View File

@ -42,7 +42,7 @@
} }
], ],
"require": { "require": {
"php": ">=8.0", "php": ">=8.1",
"ext-curl": "*", "ext-curl": "*",
"ext-openssl": "*", "ext-openssl": "*",
"ext-sockets": "*", "ext-sockets": "*",

View File

@ -72,6 +72,7 @@ class MainSite extends BasePlugin
/** /**
* 投币任务 * 投币任务
* @return bool * @return bool
* @throws NoLoginException
*/ */
protected function coinTask(): bool protected function coinTask(): bool
{ {

View File

@ -21,6 +21,7 @@ use Bhp\Plugin\BasePlugin;
use Bhp\Plugin\Plugin; use Bhp\Plugin\Plugin;
use Bhp\TimeLock\TimeLock; use Bhp\TimeLock\TimeLock;
use Bhp\User\User; use Bhp\User\User;
use Bhp\Util\Exceptions\NoLoginException;
class VipPrivilege extends BasePlugin class VipPrivilege extends BasePlugin
{ {
@ -43,8 +44,11 @@ class VipPrivilege extends BasePlugin
*/ */
protected array $privilege = [ protected array $privilege = [
0 => '未知奖励', 0 => '未知奖励',
1 => 'B币劵', 1 => '年度专享B币赠送',
2 => '会员购优惠券' 2 => '年度专享会员购优惠券',
3 => '年度专享漫画礼包',
4 => '大会员专享会员购包邮券',
5 => '年度专享漫画礼包',
]; ];
/** /**
@ -61,6 +65,7 @@ class VipPrivilege extends BasePlugin
/** /**
* 执行 * 执行
* @return void * @return void
* @throws NoLoginException
*/ */
public function execute(): void public function execute(): void
{ {
@ -75,6 +80,7 @@ class VipPrivilege extends BasePlugin
/** /**
* 领取 * 领取
* @return void * @return void
* @throws NoLoginException
*/ */
protected function receiveTask(): void protected function receiveTask(): void
{ {
@ -114,16 +120,23 @@ class VipPrivilege extends BasePlugin
/** /**
* 领取我的大会员权益 * 领取我的大会员权益
* @param int $type * @param int $type
* @throws NoLoginException
*/ */
protected function myVipPrivilegeReceive(int $type): void protected function myVipPrivilegeReceive(int $type): void
{ {
// {"code":0,"message":"0","ttl":1} // {"code":0,"message":"0","ttl":1}
// {-101: "账号未登录", -111: "csrf 校验失败", -400: "请求错误", 69800: "网络繁忙 请稍后重试", 69801: "你已领取过该权益"}
$response = ApiPrivilege::receive($type); $response = ApiPrivilege::receive($type);
// //
if ($response['code']) { switch ($response['code']) {
Log::warning("大会员权益: 领取权益 {$this->privilege[$type]} 失败 {$response['code']} -> {$response['message']}"); case -101:
} else { throw new NoLoginException($response['message']);
Log::warning("大会员权益: 领取权益 {$this->privilege[$type]} 成功"); case 0:
Log::warning("大会员权益: 领取权益 {$this->privilege[$type]} 成功");
break;
default:
Log::warning("大会员权益: 领取权益 {$this->privilege[$type]} 失败 {$response['code']} -> {$response['message']}");
break;
} }
} }

View File

@ -95,8 +95,8 @@ class Env extends BaseResource
if (PHP_SAPI != 'cli') { if (PHP_SAPI != 'cli') {
failExit('Please run this script from command line .'); failExit('Please run this script from command line .');
} }
if (version_compare(PHP_VERSION, '8.0.0', '<')) { if (version_compare(PHP_VERSION, '8.1.0', '<')) {
failExit('Please upgrade PHP version < 8.0.0 .'); failExit('Please upgrade PHP version > 8.1.0 .');
} }
return $this; return $this;
} }

View File

@ -138,6 +138,9 @@ function getAppHomePage(): string
if (Env::isDocker()) { if (Env::isDocker()) {
// 暂停两分钟后自动退出 // 暂停两分钟后自动退出
sleep($delay); sleep($delay);
} else {
// 其他环境暂停
sleep($delay / 4);
} }
die(); die();
} }