From 746d75cf895fa5f3501d9957a5b91fcd61dc2523 Mon Sep 17 00:00:00 2001 From: Lkeme <19500576+lkeme@users.noreply.github.com> Date: Fri, 26 Jun 2020 20:52:46 +0800 Subject: [PATCH] [fix] Statistics --- src/plugin/Statistics.php | 18 ++++++++++++++++-- src/plugin/StormRaffle.php | 6 +++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/plugin/Statistics.php b/src/plugin/Statistics.php index 478275c..da60bdb 100644 --- a/src/plugin/Statistics.php +++ b/src/plugin/Statistics.php @@ -169,7 +169,10 @@ class Statistics $results = 0; is_null($second_key) ? self::initKeyValue($target, $key) : self::initKeyValue($target, $key, 0, $second_key); foreach ($target as $item) { - is_null($second_key) ? $results += intval($item[$key]) : $results += intval($item[$key][$second_key]); + $skip = is_null($second_key) ? isset($item[$key]) : $item[$key][$second_key]; + if ($skip) { + is_null($second_key) ? $results += intval($item[$key]) : $results += intval($item[$key][$second_key]); + } } return $results; } @@ -236,7 +239,18 @@ class Statistics array_push($tr_list_profit, $td); } } - return [$tr_list_count, $tr_list_profit]; + return [self::unique_arr($tr_list_count), self::unique_arr($tr_list_profit)]; + } + + + /** + * @use 二维数组去重 + * @param $result + * @return array + */ + private static function unique_arr(array $result): array + { + return array_unique($result, SORT_REGULAR); } /** diff --git a/src/plugin/StormRaffle.php b/src/plugin/StormRaffle.php index 2baa3a5..cd3cf5b 100644 --- a/src/plugin/StormRaffle.php +++ b/src/plugin/StormRaffle.php @@ -109,10 +109,14 @@ class StormRaffle extends BaseRaffle for ($i = 1; $i < $num; $i++) { $raw = Curl::post('app', $url, Sign::common($payload)); if (strpos((string)$raw, 'html') !== false) { - Log::notice(self::formatInfo($raffle['raffle_id'], $num, '由于触发哔哩哔哩安全风控策略,该次访问请求被拒绝')); + Log::notice(self::formatInfo($raffle['raffle_id'], $num, '触发哔哩哔哩安全风控策略(412)')); break; } $de_raw = json_decode($raw, true); + // {"code":-412,"message":"请求被拦截","ttl":1,"data":null} + if ($de_raw['code'] == -412) { + Log::notice(self::formatInfo($raffle['raffle_id'], $num, '触发哔哩哔哩安全风控策略(-412)')); + } if ($de_raw['code'] == 429 || $de_raw['code'] == -429) { Log::notice(self::formatInfo($raffle['raffle_id'], $num, '节奏风暴未实名或异常验证码')); break;