Skip to content

Commit

Permalink
产品修改
Browse files Browse the repository at this point in the history
  • Loading branch information
imnpc committed May 28, 2021
1 parent 9b50961 commit fcae01c
Show file tree
Hide file tree
Showing 11 changed files with 586 additions and 183 deletions.
202 changes: 202 additions & 0 deletions app/Admin/Controllers/Pro2Controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
<?php

namespace App\Admin\Controllers;

use App\Models\Product;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class Pro2Controller extends AdminController
{
/**
* Title for current resource.
*
* @var string
*/
protected $title = 'Product';

/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
$grid = new Grid(new Product());

$grid->column('id', __('Id'));
$grid->column('name', __('Name'));
$grid->column('tag', __('Tag'));
$grid->column('price', __('Price'));
$grid->column('price_usdt', __('Price usdt'));
$grid->column('price_coin', __('Price coin'));
$grid->column('coin_wallet_address', __('Coin wallet address'));
$grid->column('coin_wallet_qrcode', __('Coin wallet qrcode'));
$grid->column('wallet_type_id', __('Wallet type id'));
$grid->column('wait_days', __('Wait days'));
$grid->column('valid_days', __('Valid days'));
$grid->column('valid_days_text', __('Valid days text'));
$grid->column('choose_reason', __('Choose reason'));
$grid->column('choose_reason_text', __('Choose reason text'));
$grid->column('service_rate', __('Service rate'));
$grid->column('pay_user_rate', __('Pay user rate'));
$grid->column('now_rate', __('Now rate'));
$grid->column('freed_rate', __('Freed rate'));
$grid->column('freed_days', __('Freed days'));
$grid->column('parent1_rate', __('Parent1 rate'));
$grid->column('parent2_rate', __('Parent2 rate'));
$grid->column('invite_rate', __('Invite rate'));
$grid->column('bonus_team_a', __('Bonus team a'));
$grid->column('bonus_team_b', __('Bonus team b'));
$grid->column('bonus_team_c', __('Bonus team c'));
$grid->column('upgrade_team_a', __('Upgrade team a'));
$grid->column('upgrade_team_b', __('Upgrade team b'));
$grid->column('upgrade_team_c', __('Upgrade team c'));
$grid->column('risk_rate', __('Risk rate'));
$grid->column('gas_fee', __('Gas fee'));
$grid->column('pledge_fee', __('Pledge fee'));
$grid->column('pledge_days', __('Pledge days'));
$grid->column('valid_rate', __('Valid rate'));
$grid->column('package_rate', __('Package rate'));
$grid->column('thumb', __('Thumb'));
$grid->column('desc', __('Desc'));
$grid->column('content', __('Content'));
$grid->column('status', __('Status'));
$grid->column('created_at', __('Created at'));
$grid->column('updated_at', __('Updated at'));
$grid->column('deleted_at', __('Deleted at'));
$grid->column('total_revenue', __('Total revenue'));
$grid->column('yesterday_revenue', __('Yesterday revenue'));
$grid->column('yesterday_gas', __('Yesterday gas'));
$grid->column('yesterday_efficiency', __('Yesterday efficiency'));
$grid->column('total_revenue_text', __('Total revenue text'));
$grid->column('yesterday_revenue_text', __('Yesterday revenue text'));
$grid->column('yesterday_gas_text', __('Yesterday gas text'));
$grid->column('yesterday_efficiency_text', __('Yesterday efficiency text'));

return $grid;
}

/**
* Make a show builder.
*
* @param mixed $id
* @return Show
*/
protected function detail($id)
{
$show = new Show(Product::findOrFail($id));

$show->field('id', __('Id'));
$show->field('name', __('Name'));
$show->field('tag', __('Tag'));
$show->field('price', __('Price'));
$show->field('price_usdt', __('Price usdt'));
$show->field('price_coin', __('Price coin'));
$show->field('coin_wallet_address', __('Coin wallet address'));
$show->field('coin_wallet_qrcode', __('Coin wallet qrcode'));
$show->field('wallet_type_id', __('Wallet type id'));
$show->field('wait_days', __('Wait days'));
$show->field('valid_days', __('Valid days'));
$show->field('valid_days_text', __('Valid days text'));
$show->field('choose_reason', __('Choose reason'));
$show->field('choose_reason_text', __('Choose reason text'));
$show->field('service_rate', __('Service rate'));
$show->field('pay_user_rate', __('Pay user rate'));
$show->field('now_rate', __('Now rate'));
$show->field('freed_rate', __('Freed rate'));
$show->field('freed_days', __('Freed days'));
$show->field('parent1_rate', __('Parent1 rate'));
$show->field('parent2_rate', __('Parent2 rate'));
$show->field('invite_rate', __('Invite rate'));
$show->field('bonus_team_a', __('Bonus team a'));
$show->field('bonus_team_b', __('Bonus team b'));
$show->field('bonus_team_c', __('Bonus team c'));
$show->field('upgrade_team_a', __('Upgrade team a'));
$show->field('upgrade_team_b', __('Upgrade team b'));
$show->field('upgrade_team_c', __('Upgrade team c'));
$show->field('risk_rate', __('Risk rate'));
$show->field('gas_fee', __('Gas fee'));
$show->field('pledge_fee', __('Pledge fee'));
$show->field('pledge_days', __('Pledge days'));
$show->field('valid_rate', __('Valid rate'));
$show->field('package_rate', __('Package rate'));
$show->field('thumb', __('Thumb'));
$show->field('desc', __('Desc'));
$show->field('content', __('Content'));
$show->field('status', __('Status'));
$show->field('created_at', __('Created at'));
$show->field('updated_at', __('Updated at'));
$show->field('deleted_at', __('Deleted at'));
$show->field('total_revenue', __('Total revenue'));
$show->field('yesterday_revenue', __('Yesterday revenue'));
$show->field('yesterday_gas', __('Yesterday gas'));
$show->field('yesterday_efficiency', __('Yesterday efficiency'));
$show->field('total_revenue_text', __('Total revenue text'));
$show->field('yesterday_revenue_text', __('Yesterday revenue text'));
$show->field('yesterday_gas_text', __('Yesterday gas text'));
$show->field('yesterday_efficiency_text', __('Yesterday efficiency text'));

return $show;
}

/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
$form = new Form(new Product());

$form->text('name', __('Name'));
$form->text('tag', __('Tag'));
$form->decimal('price', __('Price'))->default(0.00);
$form->decimal('price_usdt', __('Price usdt'))->default(0.00);
$form->decimal('price_coin', __('Price coin'))->default(0.00);
$form->text('coin_wallet_address', __('Coin wallet address'));
$form->text('coin_wallet_qrcode', __('Coin wallet qrcode'));
$form->number('wallet_type_id', __('Wallet type id'));
$form->number('wait_days', __('Wait days'));
$form->number('valid_days', __('Valid days'));
$form->text('valid_days_text', __('Valid days text'));
$form->text('choose_reason', __('Choose reason'));
$form->text('choose_reason_text', __('Choose reason text'));
$form->decimal('service_rate', __('Service rate'))->default(0.00);
$form->decimal('pay_user_rate', __('Pay user rate'))->default(0.00);
$form->decimal('now_rate', __('Now rate'))->default(0.00);
$form->decimal('freed_rate', __('Freed rate'))->default(0.00);
$form->number('freed_days', __('Freed days'));
$form->decimal('parent1_rate', __('Parent1 rate'))->default(0.00);
$form->decimal('parent2_rate', __('Parent2 rate'))->default(0.00);
$form->decimal('invite_rate', __('Invite rate'))->default(0.00);
$form->decimal('bonus_team_a', __('Bonus team a'))->default(0.00);
$form->decimal('bonus_team_b', __('Bonus team b'))->default(0.00);
$form->decimal('bonus_team_c', __('Bonus team c'))->default(0.00);
$form->number('upgrade_team_a', __('Upgrade team a'));
$form->number('upgrade_team_b', __('Upgrade team b'));
$form->number('upgrade_team_c', __('Upgrade team c'));
$form->decimal('risk_rate', __('Risk rate'))->default(0.00);
$form->decimal('gas_fee', __('Gas fee'))->default(0.00000);
$form->decimal('pledge_fee', __('Pledge fee'))->default(0.00000);
$form->number('pledge_days', __('Pledge days'))->default(1);
$form->decimal('valid_rate', __('Valid rate'))->default(0.00);
$form->decimal('package_rate', __('Package rate'))->default(0.00);
$form->text('thumb', __('Thumb'));
$form->text('desc', __('Desc'));
$form->textarea('content', __('Content'));
$form->switch('status', __('Status'))->default(1);
$form->decimal('total_revenue', __('Total revenue'))->default(0.00000);
$form->decimal('yesterday_revenue', __('Yesterday revenue'))->default(0.00000);
$form->decimal('yesterday_gas', __('Yesterday gas'))->default(0.00000);
$form->decimal('yesterday_efficiency', __('Yesterday efficiency'))->default(0.00000);
$form->text('total_revenue_text', __('Total revenue text'))->default('矿池总产量');
$form->text('yesterday_revenue_text', __('Yesterday revenue text'))->default('昨日产量');
$form->text('yesterday_gas_text', __('Yesterday gas text'))->default('昨日消耗GAS');
$form->text('yesterday_efficiency_text', __('Yesterday efficiency text'))->default('昨日挖矿效率');

return $form;
}
}
10 changes: 10 additions & 0 deletions app/Admin/Controllers/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,16 @@ protected function form()
$form->number('pledge_days', __('Pledge days'))->default(1)->required();
$form->decimal('valid_rate', __('Valid rate'))->default(0.00)->required();
$form->decimal('package_rate', __('Package rate'))->default(0.00)->required();

$form->decimal('total_revenue', __('Total revenue'))->default(0.00000);
$form->decimal('yesterday_revenue', __('Yesterday revenue'))->default(0.00000);
$form->decimal('yesterday_gas', __('Yesterday gas'))->default(0.00000);
$form->decimal('yesterday_efficiency', __('Yesterday efficiency'))->default(0.00000);
$form->text('total_revenue_text', __('Total revenue text'))->default('矿池总产量');
$form->text('yesterday_revenue_text', __('Yesterday revenue text'))->default('昨日产量');
$form->text('yesterday_gas_text', __('Yesterday gas text'))->default('昨日消耗GAS');
$form->text('yesterday_efficiency_text', __('Yesterday efficiency text'))->default('昨日挖矿效率');

$form->image('thumb', __('Thumb'))->required();
// $form->textarea('desc', __('Desc'));
$form->editor('content', __('Content'))->required();
Expand Down
9 changes: 5 additions & 4 deletions app/Admin/Controllers/WithdrawController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Models\UserWalletLog;
use App\Models\Withdraw;
use App\Services\LogService;
use App\Services\UserWalletService;
use Carbon\Carbon;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
Expand Down Expand Up @@ -180,11 +181,11 @@ protected function form()
$order->canceled_time = Carbon::now(); // 标记订单确认时间
$order->save();
// 给用户账户增加对应金额
$logService = app()->make(LogService::class);
$UserWalletService = app()->make(UserWalletService::class);
if ($form->model()->status == 2) {
// 充值账户转入 TODO
$remark2 = "取消提币退回 " . $form->model()->coin . ',理由-' . $form->model()->reason . '#' . $form->model()->id;
$logService->userLog(User::BALANCE_FILECOIN, $form->model()->user_id, $form->model()->coin, 0, $day, UserWalletLog::FROM_CANCEL_WITHDRAW, $remark2, 0, 0, 0, UserWalletLog::TYPE_MINER);
$meta['add'] = $form->model()->coin;
$meta['remark'] = "取消提币退回 " . $form->model()->coin . ',理由-' . $form->model()->reason . '#' . $form->model()->id;
$UserWalletService->store($form->model()->user_id, $form->model()->wallet_type_id, $form->model()->coin, $meta);
}
}
});
Expand Down
85 changes: 85 additions & 0 deletions app/Http/Controllers/Api/IndexController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Announcement;
use App\Models\ArticleCategory;
use App\Models\Product;
use Illuminate\Http\Request;
use Storage;

class IndexController extends Controller
{
public function index(Request $request)
{
$data = [];
// Banner 图片
$banner = [];
$banner[] = config('app.banner1');
$banner[] = config('app.banner2');
$banner[] = config('app.banner3');
$banner_list = [];
foreach ($banner as $ban) {
if ($ban) {
$banner_list[] = Storage::disk('oss')->url($ban);
} else {
return '';
}
}
$data['banner'] = array_values($banner_list);

// 获取公告
$announcement = Announcement::where('is_recommand', '=', 1)
->where('status', '=', 1)
->select('id', 'title')
->get();
$data['announcement'] = $announcement;

// 导航栏
$nav = ArticleCategory::where('status', '=', 1)
->orderBy('order', 'asc')
->select('id', 'title', 'icon')
->get();
$data['nav'] = $nav;

// 抢购算力 切换
// 矿池运营数据 TODO
$list = Product::where('status', '=', 0)
->orderBy('id', 'asc')
->get();
//print_r($list->toArray());
foreach ($list as $k => $v) {
//
$data['coinlist'][$k]['name'] = $v->wallet_slug;
$data['coinlist'][$k]['total_revenue'] = $v->total_revenue;
$data['coinlist'][$k]['yesterday_revenue'] = $v->yesterday_revenue;
$data['coinlist'][$k]['yesterday_gas'] = $v->yesterday_gas;
$data['coinlist'][$k]['yesterday_efficiency'] = $v->yesterday_efficiency;
$data['coinlist'][$k]['total_revenue_text'] = $v->total_revenue_text;
$data['coinlist'][$k]['yesterday_revenue_text'] = $v->yesterday_revenue_text;
$data['coinlist'][$k]['yesterday_gas_text'] = $v->yesterday_gas_text;
$data['coinlist'][$k]['yesterday_efficiency_text'] = $v->yesterday_efficiency_text;
}

// 矿池总产量 total_revenue 昨日产量 yesterday_revenue 昨日消耗GAS yesterday_gas 挖矿效率 yesterday_efficiency
// $data['filpool']['progress'] = config('filpool.progress'); // 矿池填充进度
// $data['filpool']['node_power'] = config('filpool.node_power'); // 节点总有效算力
// $data['filpool']['community_power'] = config('filpool.community_power'); // 社区总有效算力
// $data['filpool']['community_torage_space'] = config('filpool.community_torage_space'); // 社区总存储空间
// $data['filpool']['total_revenue'] = config('filpool.total_revenue'); // 矿池总收益
// $data['filpool']['yesterday_revenue'] = config('filpool.yesterday_revenue'); // 昨日收益
// $data['filpool']['yesterday_gas'] = config('filpool.yesterday_gas'); // 昨日消耗GAS
// $data['filpool']['single_revenue'] = config('filpool.single_revenue'); // 有效算力单T收益

// 产品列表
$product = Product::where('status', '=', 0)
->orderBy('id', 'desc')
->select('id', 'name', 'thumb', 'choose_reason')
->get();

$data['product'] = $product;

return $data;
}
}
5 changes: 2 additions & 3 deletions app/Services/UserWalletService.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function store($uid, $wallet_type_id, $money, $remark)
{
$decimal = 0;
$user = User::find($uid);
$this->checkWallet($uid); // 检测用户是否创建过钱包
$wallet_type = WalletType::find($wallet_type_id);
$name = $wallet_type->slug;
$wallet = $user->getWallet($name);
Expand All @@ -27,9 +28,7 @@ public function store($uid, $wallet_type_id, $money, $remark)
$wallet->depositFloat($money, $remark); // 增加
} elseif ($money > 0 && $decimal == 0) {
$wallet->deposit($money, $remark); // 增加
}

if ($money < 0 && $decimal == 1) {
} elseif ($money < 0 && $decimal == 1) {
$wallet->withdrawFloat($money, $remark); // 减少
} elseif ($money < 0 && $decimal == 0) {
$wallet->withdraw($money, $remark); // 减少
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"ghost/google-authenticator": "^1.0",
"guzzlehttp/guzzle": "^7.0.1",
"ichynul/configx": "^1.4",
"ichynul/row-table": "^1.1",
"kra8/laravel-snowflake": "^2.0",
"laminas/laminas-diactoros": "^2.5",
"laravel-admin-ext/config": "^1.1",
Expand Down
Loading

0 comments on commit fcae01c

Please sign in to comment.