mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 10:38:14 -05:00
Compare commits
9 Commits
1f6980355c
...
97e9f7297d
Author | SHA1 | Date | |
---|---|---|---|
|
97e9f7297d | ||
|
3a05281a9f | ||
|
74d93691b9 | ||
|
d743296392 | ||
|
024a9dfb54 | ||
|
a550fd1436 | ||
|
43bac89d3a | ||
|
e2262f1435 | ||
|
fc6bb8cf34 |
@ -51,15 +51,16 @@ class MigrateFromV2b extends Command
|
||||
],
|
||||
'1.7.3' => [
|
||||
'ALTER TABLE `v2_stat_order` RENAME TO `v2_stat`;',
|
||||
"ALTER TABLE `v2_stat` CHANGE COLUMN order_amount order_total INT COMMENT '订单合计';",
|
||||
"ALTER TABLE `v2_stat` CHANGE COLUMN order_amount paid_total INT COMMENT '订单合计';",
|
||||
"ALTER TABLE `v2_stat` CHANGE COLUMN order_count paid_count INT COMMENT '邀请佣金';",
|
||||
"ALTER TABLE `v2_stat` CHANGE COLUMN commission_amount commission_total INT COMMENT '佣金合计';",
|
||||
"ALTER TABLE `v2_stat`
|
||||
ADD COLUMN paid_count INT NULL,
|
||||
ADD COLUMN paid_total INT NULL,
|
||||
ADD COLUMN order_count INT NULL,
|
||||
ADD COLUMN order_total INT NULL,
|
||||
ADD COLUMN register_count INT NULL,
|
||||
ADD COLUMN invite_count INT NULL,
|
||||
ADD COLUMN transfer_used_total VARCHAR(32) NULL;
|
||||
",
|
||||
",
|
||||
"CREATE TABLE `v2_log` (
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`title` TEXT NOT NULL,
|
||||
|
97
app/Payments/EpusdtPay.php
Normal file
97
app/Payments/EpusdtPay.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
//author by GoodGoodStudy
|
||||
namespace App\Payments;
|
||||
|
||||
use \Curl\Curl;
|
||||
|
||||
class EpusdtPay {
|
||||
public function __construct($config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
return [
|
||||
'epusdt_pay_url' => [
|
||||
'label' => 'API 地址',
|
||||
'description' => '您的 EpusdtPay API 接口地址(例如: https://epusdt-pay.xxx.com)',
|
||||
'type' => 'input',
|
||||
],
|
||||
'epusdt_pay_apitoken' => [
|
||||
'label' => 'API Token',
|
||||
'description' => '您的 EpusdtPay API Token',
|
||||
'type' => 'input',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function pay($order)
|
||||
{
|
||||
$params = [
|
||||
"amount" => round($order['total_amount']/100,2),
|
||||
"order_id" => $order['trade_no'],
|
||||
'redirect_url' => $order['return_url'],
|
||||
'notify_url' => $order['notify_url'],
|
||||
];
|
||||
$params['signature'] = $this->sign($params);
|
||||
|
||||
$curl = new Curl();
|
||||
$curl->setUserAgent('EpusdtPay');
|
||||
$curl->setOpt(CURLOPT_SSL_VERIFYPEER, 0);
|
||||
$curl->setOpt(CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
|
||||
$curl->post($this->config['epusdt_pay_url'] . '/api/v1/order/create-transaction', json_encode($params));
|
||||
$result = $curl->response;
|
||||
$curl->close();
|
||||
if (!isset($result->status_code) || $result->status_code != 200) {
|
||||
abort(500, "Failed to create order. Error: {$result->message}");
|
||||
}
|
||||
return [
|
||||
'type' => 1, // 0:qrcode 1:url
|
||||
'data' => $result->data->payment_url
|
||||
];
|
||||
}
|
||||
|
||||
public function notify($params)
|
||||
{
|
||||
$status = $params['status'];
|
||||
// 1:等待支付,2:支付成功,3:已过期
|
||||
if ($status != 2) {
|
||||
die('failed');
|
||||
}
|
||||
//不合法的数据
|
||||
if (!$this->verify($params)) {
|
||||
die('cannot pass verification');
|
||||
}
|
||||
return [
|
||||
'trade_no' => $params['order_id'],
|
||||
'callback_no' => $params['trade_id'],
|
||||
'custom_result' => 'ok'
|
||||
];
|
||||
}
|
||||
|
||||
public function verify($params) {
|
||||
return $params['signature'] === $this->sign($params);
|
||||
}
|
||||
|
||||
protected function sign(array $params)
|
||||
{
|
||||
ksort($params);
|
||||
reset($params); //内部指针指向数组中的第一个元素
|
||||
$sign = '';
|
||||
$urls = '';
|
||||
foreach ($params as $key => $val) {
|
||||
if ($val == '') continue;
|
||||
if ($key != 'signature') {
|
||||
if ($sign != '') {
|
||||
$sign .= "&";
|
||||
$urls .= "&";
|
||||
}
|
||||
$sign .= "$key=$val"; //拼接为url参数形式
|
||||
$urls .= "$key=" . urlencode($val); //拼接为url参数形式
|
||||
}
|
||||
}
|
||||
$sign = md5($sign . $this->config['epusdt_pay_apitoken']);//密码追加进入开始MD5签名
|
||||
return $sign;
|
||||
}
|
||||
}
|
@ -12,11 +12,17 @@ class UnBind extends Telegram {
|
||||
|
||||
public function handle($message, $match = []) {
|
||||
if (!$message->is_private) return;
|
||||
$user = User::where('telegram_id', $message->chat_id)->first();
|
||||
$telegramService = $this->telegramService;
|
||||
if (!$user) {
|
||||
$telegramService->sendMessage($message->chat_id, '没有查询到您的用户信息,请先绑定账号', 'markdown');
|
||||
return;
|
||||
if (!isset($message->args[0])) {
|
||||
$user = User::where('telegram_id', $message->chat_id)->first();
|
||||
} else {
|
||||
$chat = User::where('telegram_id', $message->chat_id)->first();
|
||||
if (!$chat) return;
|
||||
if (!($chat->is_admin || $chat->is_staff)) return;
|
||||
if (strpos($message->args[0], '@') !== true) {
|
||||
$user = User::where('email', $message->args[0])->first();
|
||||
} else {
|
||||
$user = User::where('telegram_id', $message->args[0])->first();
|
||||
}
|
||||
}
|
||||
$user->telegram_id = NULL;
|
||||
if (!$user->save()) {
|
||||
|
@ -110,11 +110,20 @@ class Helper
|
||||
|
||||
public static function getSubscribeUrl(string $token, $subscribeUrl = null)
|
||||
{
|
||||
$strs = 'QWERTYUIOPASDFGHJKLZXCVBNM1234567890qwertyuiopasdfghjklzxcvbnm';
|
||||
$randstr = substr(str_shuffle($strs), 0, rand(4,8));
|
||||
|
||||
$path = route('client.subscribe', ['token' => $token], false);
|
||||
if(!$subscribeUrl){
|
||||
$subscribeUrls = explode(',', admin_setting('subscribe_url'));
|
||||
$subscribeUrl = \Arr::random($subscribeUrls);
|
||||
$subscribeUrl = self::replaceByPattern($subscribeUrl);
|
||||
if (strpos($subscribeUrl, "*") !== false) {
|
||||
$subscribeUrl = str_replace("*", $randstr, $subscribeUrl);
|
||||
} elseif (strpos($subscribeUrl, '{uuid}') !== false) {
|
||||
$user = User::where('token', $token)->first();
|
||||
$subscribeUrl = str_replace('{uuid}', $user->uuid, $subscribeUrl);
|
||||
}
|
||||
}
|
||||
return $subscribeUrl ? rtrim($subscribeUrl, '/') . $path : url($path);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ if ! command -v git &> /dev/null; then
|
||||
fi
|
||||
|
||||
git config --global --add safe.directory $(pwd)
|
||||
git fetch --all && git reset --hard origin/dev && git pull origin dev
|
||||
git fetch --all && git reset --hard origin/legacy && git pull origin legacy
|
||||
rm -rf composer.lock composer.phar
|
||||
wget https://github.com/composer/composer/releases/latest/download/composer.phar -O composer.phar
|
||||
php composer.phar update -vvv
|
||||
|
Loading…
Reference in New Issue
Block a user