commit
b57f817475
@ -0,0 +1,19 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an new idea for this project
|
||||
title: "[Feature Request]"
|
||||
labels: enhancement
|
||||
|
||||
---
|
||||
|
||||
- [ ] I acknowledge if I don't follow the format below or I don't check these box, my issue could be closed without any notice.
|
||||
- [ ] I certify that I have read project Wiki and other issue may related to this one.
|
||||
|
||||
**Feature**
|
||||
The feature you want.
|
||||
|
||||
**Solution**
|
||||
If you have some solution about this issue, type it here.
|
||||
|
||||
**Addition**
|
||||
Additional context here.
|
||||
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Auth;
|
||||
|
||||
class File
|
||||
{
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Services\Auth;
|
||||
|
||||
use App\Services\Factory;
|
||||
|
||||
class Token extends Base
|
||||
{
|
||||
protected $storage;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->storage = Factory::createTokenStorage();
|
||||
}
|
||||
|
||||
public function login($uid, $time)
|
||||
{
|
||||
// TODO: Implement getUser() method.
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
// TODO: Implement logout() method.
|
||||
}
|
||||
|
||||
public function getUser()
|
||||
{
|
||||
$token = Cookie::get('token');
|
||||
}
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
class Cache
|
||||
{
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Token;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
abstract class Base
|
||||
{
|
||||
abstract public function store($token, User $user, $expireTime);
|
||||
|
||||
abstract public function delete($token);
|
||||
|
||||
abstract public function get($token);
|
||||
}
|
||||
@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Services\Token;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Token as TokenModel;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
|
||||
class DB extends Base
|
||||
{
|
||||
public function store($tokenStr, User $user, $expireTime)
|
||||
{
|
||||
$token = new TokenModel();
|
||||
$token->token = $tokenStr;
|
||||
$token->user_id = $user->id;
|
||||
$token->create_time = time();
|
||||
$token->expire_time = $expireTime;
|
||||
if ($token->save()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function delete($token)
|
||||
{
|
||||
$token = TokenModel::where('token', $token)->first();
|
||||
if ($token == null) {
|
||||
return false;
|
||||
}
|
||||
$token->delete();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function get($token)
|
||||
{
|
||||
try {
|
||||
$tokenModel = TokenModel::where('token', $token)->firstOrFail();
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return null;
|
||||
}
|
||||
$token = new Token();
|
||||
$token->token = $tokenModel->token;
|
||||
$token->userId = $tokenModel->user_id;
|
||||
$token->createTime = $tokenModel->create_time;
|
||||
$token->expireTime = $tokenModel->expire_time;
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Token;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Services\Aws\Factory;
|
||||
|
||||
class Dynamodb extends Base
|
||||
{
|
||||
protected $client;
|
||||
|
||||
protected $tableName = 'token';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->client = Factory::createDynamodb();
|
||||
$this->tableName = 'token';
|
||||
}
|
||||
|
||||
public function store($token, User $user, $expireTime)
|
||||
{
|
||||
$result = $this->client->putItem(array(
|
||||
'TableName' => $this->tableName,
|
||||
'Item' => array(
|
||||
'token' => array('S' => $token),
|
||||
'user_id' => array('N' => (string)$user->id),
|
||||
'create_time' => array('N' => (string)time()),
|
||||
'expire_time' => array('N' => (string)$expireTime)
|
||||
)
|
||||
));
|
||||
return true;
|
||||
}
|
||||
|
||||
public function delete($token)
|
||||
{
|
||||
$this->client->deleteItem(array(
|
||||
'TableName' => $this->tableName,
|
||||
'Key' => array(
|
||||
'token' => array('S' => $token),
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
public function get($token)
|
||||
{
|
||||
$result = $this->client->getItem(array(
|
||||
'ConsistentRead' => true,
|
||||
'TableName' => $this->tableName,
|
||||
'Key' => array(
|
||||
'token' => array('S' => $token),
|
||||
)
|
||||
));
|
||||
$token = new Token();
|
||||
$token->token = $result['Item']['token']['S'];
|
||||
$token->userId = $result['Item']['user_id']['N'];
|
||||
$token->createTime = $result['Item']['create_time']['N'];
|
||||
$token->expireTime = $result['Item']['expire_time']['N'];
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Services\Token;
|
||||
|
||||
class Token
|
||||
{
|
||||
public $token;
|
||||
public $userId;
|
||||
public $createTime;
|
||||
public $expireTime;
|
||||
}
|
||||
@ -1,88 +1,27 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Utils;
|
||||
|
||||
use App\Services\Config;
|
||||
use Zxing\QrReader;
|
||||
use ZBarCodeImage;
|
||||
use ZBarCodeScanner;
|
||||
|
||||
class QRcode
|
||||
{
|
||||
public static function decode($url)
|
||||
/**
|
||||
* Decode QR code
|
||||
*
|
||||
* @param string $source QR code source url/path
|
||||
*
|
||||
* @return string|null Decoded string, null for empty
|
||||
*/
|
||||
public static function decode(string $source)
|
||||
{
|
||||
switch (Config::get('qrcode')) {
|
||||
case 'phpzbar':
|
||||
return self::phpzbar_decode($url);
|
||||
case 'online':
|
||||
return self::online_decode($url);
|
||||
case 'zxing_local':
|
||||
return self::zxing_local_decode($url);
|
||||
default:
|
||||
return self::zxing_decode($url);
|
||||
}
|
||||
}
|
||||
|
||||
public static function online_decode($url)
|
||||
{
|
||||
$data = array();
|
||||
$data['fileurl'] = $url;
|
||||
$param = http_build_query($data, '', '&');
|
||||
|
||||
$sock = new HTTPSocket();
|
||||
$sock->connect('api.qrserver.com', 80);
|
||||
$sock->set_method('GET');
|
||||
$sock->query('/v1/read-qr-code/', $param);
|
||||
|
||||
$raw_text = $sock->fetch_body();
|
||||
$result_array = json_decode($raw_text, true);
|
||||
if (isset($result_array[0])) {
|
||||
return $result_array[0]['symbol'][0]['data'];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function phpzbar_decode($url)
|
||||
{
|
||||
$filepath = BASE_PATH . '/storage/' . time() . random_int(1, 100) . '.png';
|
||||
$img = file_get_contents($url);
|
||||
file_put_contents($filepath, $img);
|
||||
|
||||
/* Create new image object */
|
||||
$image = new ZBarCodeImage($filepath);
|
||||
|
||||
/* Create a barcode scanner */
|
||||
$scanner = new ZBarCodeScanner();
|
||||
|
||||
/* Scan the image */
|
||||
$barcode = $scanner->scan($image);
|
||||
|
||||
unlink($filepath);
|
||||
|
||||
return ($barcode[0]['data'] ?? null);
|
||||
}
|
||||
|
||||
public static function zxing_local_decode($url)
|
||||
{
|
||||
$filepath = BASE_PATH . '/storage/' . time() . random_int(1, 100) . '.png';
|
||||
$img = file_get_contents($url);
|
||||
file_put_contents($filepath, $img);
|
||||
|
||||
$qrcode = new QrReader($filepath);
|
||||
$text = $qrcode->text(); //return decoded text from QR Code
|
||||
|
||||
unlink($filepath);
|
||||
|
||||
if ($text == null || $text == '') {
|
||||
$img = file_get_contents($source);
|
||||
$qrcode = new QrReader($img, QrReader::SOURCE_TYPE_BLOB);
|
||||
$text = $qrcode->text();
|
||||
if ($text == false || $text == '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
public static function zxing_decode($url)
|
||||
{
|
||||
$raw_text = file_get_contents('https://zxing.org/w/decode?u=' . urlencode($url));
|
||||
return Tools::get_middle_text($raw_text, '<tr><td>Raw text</td><td><pre>', '</pre></td></tr><tr><td>Raw bytes</td><td><pre>');
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,100 +0,0 @@
|
||||
<div class="card-inner">
|
||||
<p class="card-heading">输入充值金额后,点击下方的图标进行充值</p>
|
||||
<div class="form-group form-group-label">
|
||||
<label class="floating-label" for="amount">金额</label>
|
||||
<input class="form-control" id="amount" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div id="qrarea">
|
||||
<button class="btn btn-flat waves-attach" id="btnSubmit" name="type" onclick="pay('Alipay')">
|
||||
<img src="data:image/svg+xml;base64,CjxzdmcgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDEwMDAgMTAwMCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMTAwMCAxMDAwIiB4bWw6c3BhY2U9InByZXNlcnZlIj4KPG1ldGFkYXRhPiDnn6Lph4/lm77moIfkuIvovb0gOiBodHRwOi8vd3d3LnNmb250LmNuLyA8L21ldGFkYXRhPjxnPjxwYXRoIGQ9Ik05OTAsNjgwLjlWMTk4LjVDOTkwLDk0LjQsOTA1LjcsMTAsODAxLjUsMTBIMTk4LjVDOTQuNCwxMCwxMCw5NC4zLDEwLDE5OC41djYwMy4xQzEwLDkwNS42LDk0LjMsOTkwLDE5OC41LDk5MGg2MDMuMWM5Mi44LDAsMTY5LjktNjcsMTg1LjUtMTU1LjNjLTUwLTIxLjUtMjY2LjctMTE1LjEtMzc5LjQtMTY5Yy04NS44LDEwNC0xNzUuOCwxNjYuNS0zMTEuMywxNjYuNXMtMjI2LTgzLjMtMjE1LjEtMTg1LjZjNy4xLTY3LjIsNTMuMi0xNzYuNiwyNTMtMTU3LjhjMTA1LjMsMTAsMTUzLjUsMjkuNSwyMzkuNCw1Ny45YzIyLjEtNDAuNyw0MC42LTg1LjUsNTQuNi0xMzMuMkgyNDcuNXYtMzcuN2gxODguM3YtNjcuOEgyMDZ2LTQxLjVoMjI5Ljh2LTk3LjhjMCwwLDIuMi0xNS4zLDE5LTE1LjNoOTQuM3YxMTMuMWgyNDV2NDEuNWgtMjQ1djY3LjhoMTk5LjdjLTE4LjMsNzQuOC00Ni4yLDE0My41LTgxLDIwMy41QzcyNS45LDYwMC4yLDk5MCw2ODAuOSw5OTAsNjgwLjlMOTkwLDY4MC45TDk5MCw2ODAuOXogTTI4MS40LDc2Ny42Yy0xNDMuMywwLTE2NS44LTkwLjUtMTU4LjMtMTI4LjJzNDktODYuNywxMjguNi04Ni43YzkxLjUsMCwxNzMuNSwyMy40LDI3MS44LDcxLjNDNDU0LjUsNzE0LDM2OS41LDc2Ny42LDI4MS40LDc2Ny42TDI4MS40LDc2Ny42eiIgc3R5bGU9ImZpbGw6IzU2YWJlNCI+PC9wYXRoPjwvZz48L3N2Zz4gIA=="
|
||||
width="64" height="64">
|
||||
</button>
|
||||
<button class="btn btn-flat waves-attach" id="btnSubmit" name="type" onclick="pay('WEPAY_JSAPI')">
|
||||
<!-- iCon by SFont.Cn -->
|
||||
<img src="data:image/svg+xml;base64,CjxzdmcgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDEwMDAgMTAwMCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMTAwMCAxMDAwIiB4bWw6c3BhY2U9InByZXNlcnZlIj4KPG1ldGFkYXRhPiDnn6Lph4/lm77moIfkuIvovb0gOiBodHRwOi8vd3d3LnNmb250LmNuLyA8L21ldGFkYXRhPjxnPjxwYXRoIGQ9Ik0zMTIuNiwzMTUuN2MtMT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DI1LjQtNzYuNGMtNjMuNi00NC41LTEwMS43LTEwMS44LTEwMS43LTE3MS41YzAtMTIwLjksMTE0LjQtMjE2LDI1NC4xLTIxNmMxMjQuOSwwLDIzNC4zLDc2LjEsMjU2LjMsMTc4LjRjLTguMi0wLjktMTYuNC0xLjUtMjQuNS0xLjVjLTEyMC43LDAtMjE1LjksOTAtMjE1LjksMjAxYzAsMTguNiwyLjksMzYuNCw3LjgsNTMuM0M0MTEsNjM5LjQsNDAzLjEsNjM5LjgsMzk1LjIsNjM5LjhMMzk1LjIsNjM5LjhMMzk1LjIsNjM5Ljh6IE03NjkuNyw3MjguOGwxOS4yLDYzLjVsLTY5LjctMzguM2MtMjUuNCw2LjQtNTAuOSwxMi43LTc2LjIsMTIuN2MtMTIwLjksMC0yMTYtODIuNS0yMTYtMTg0LjNjMC0xMDEuNiw5NS4xLTE4NC4zLDIxNi0xODQuM2MxMTQuMSwwLDIxNS44LDgyLjgsMjE1LjgsMTg0LjNDODU4LjgsNjM5LjgsODIwLjgsNjkwLjUsNzY5LjcsNzI4LjhMNzY5LjcsNzI4LjhMNzY5LjcsNzI4Ljh6IiBzdHlsZT0iZmlsbDojMTFjZDZlIj48L3BhdGg+PC9nPjwvc3ZnPiAg"
|
||||
width="64" height="64">
|
||||
</button>
|
||||
</div>
|
||||
<script>
|
||||
var pid = 0;
|
||||
|
||||
function pay(type) {
|
||||
if (type === 'Alipay') {
|
||||
if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
|
||||
type = 'ALIPAY_WAP';
|
||||
} else {
|
||||
type = 'ALIPAY_WEB';
|
||||
}
|
||||
}
|
||||
|
||||
var price = parseFloat($$getValue('amount'));
|
||||
|
||||
//console.log("将要使用 " + type + " 充值" + price + "元");
|
||||
if (isNaN(price)) {
|
||||
$("#readytopay").modal('hide');
|
||||
$("#result").modal();
|
||||
$$.getElementById('msg').innerHTML = '非法的金额!'
|
||||
return;
|
||||
}
|
||||
$('#readytopay').modal();
|
||||
$("#readytopay").on('shown.bs.modal', function () {
|
||||
$.ajax({
|
||||
url: "/user/payment/purchase",
|
||||
data: {
|
||||
price,
|
||||
type,
|
||||
},
|
||||
dataType: 'json',
|
||||
type: "POST",
|
||||
success: (data) => {
|
||||
if (data.code == 0) {
|
||||
//console.log(data);
|
||||
$("#readytopay").modal('hide');
|
||||
if (type === 'ALIPAY_WAP' || type === 'ALIPAY_WEB') {
|
||||
window.location.href = data.data;
|
||||
} else {
|
||||
pid = data.pid;
|
||||
$$.getElementById('qrarea').innerHTML = '<div class="text-center"><p>使用微信扫描二维码支付.</p><div align="center" id="qrcode" style="padding-top:10px;"></div><p>充值完毕后会自动跳转</p></div>';
|
||||
var qrcode = new QRCode("qrcode", {
|
||||
render: "canvas",
|
||||
width: 200,
|
||||
height: 200,
|
||||
text: encodeURI(data.data)
|
||||
});
|
||||
tid = setTimeout(f, 1000); //循环调用触发setTimeout
|
||||
}
|
||||
} else {
|
||||
$("#result").modal();
|
||||
$$.getElementById('msg').innerHTML = data.msg;
|
||||
//console.log(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function f() {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/payment/status",
|
||||
dataType: "json",
|
||||
{literal}
|
||||
data: { pid },
|
||||
{/literal}
|
||||
success: (data) => {
|
||||
if (data.result) {
|
||||
//console.log(data);
|
||||
$("#result").modal();
|
||||
$$.getElementById('msg').innerHTML = '充值成功!';
|
||||
window.setTimeout("location.href=window.location.href", {$config['jump_delay']});
|
||||
}
|
||||
},
|
||||
error: (jqXHR) => {
|
||||
//console.log(jqXHR);
|
||||
}
|
||||
});
|
||||
tid = setTimeout(f, 1000); //循环调用触发setTimeout
|
||||
}
|
||||
|
||||
</script>
|
||||
Loading…
Reference in New Issue