阶段更新
This commit is contained in:
20
app/Admin/Actions/LinkCreateAddress.php
Normal file
20
app/Admin/Actions/LinkCreateAddress.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions;
|
||||
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
|
||||
class LinkCreateAddress extends RowAction
|
||||
{
|
||||
|
||||
public $name = '添加收货地址';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function href(): string
|
||||
{
|
||||
return admin_url("mall/addresses/create?user_id=".$this->row->id);
|
||||
}
|
||||
|
||||
}
|
||||
20
app/Admin/Actions/LinkStockOrderDeliver.php
Normal file
20
app/Admin/Actions/LinkStockOrderDeliver.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions;
|
||||
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
|
||||
class LinkStockOrderDeliver extends RowAction
|
||||
{
|
||||
|
||||
public $name = '发货';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function href(): string
|
||||
{
|
||||
return admin_url('mall/stock_orders?user_id='.$this->row->user->id);
|
||||
}
|
||||
|
||||
}
|
||||
20
app/Admin/Actions/LinkVipOrderRefund.php
Normal file
20
app/Admin/Actions/LinkVipOrderRefund.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions;
|
||||
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
|
||||
class LinkVipOrderRefund extends RowAction
|
||||
{
|
||||
|
||||
public $name = '体验官退款';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function href(): string
|
||||
{
|
||||
return admin_url("platform/vip_orders?user[username]=".$this->row->user->username);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,44 +3,244 @@
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Encore\Admin\Facades\Admin;
|
||||
use Encore\Admin\Layout\Column;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Layout\Row;
|
||||
use Encore\Admin\Widgets\InfoBox;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Modules\Mall\Models\Order;
|
||||
use Modules\Mall\Models\OrderItem;
|
||||
use Modules\User\Models\Identity;
|
||||
use Modules\User\Models\User;
|
||||
use Modules\User\Models\UserStock;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
public $content;
|
||||
|
||||
/**
|
||||
* Notes : 数据看板
|
||||
*
|
||||
* @Date : 2021/3/10 5:12 下午
|
||||
* @Author : <Jason.C>
|
||||
* @Author : < Jason.C >
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content): Content
|
||||
public function index(Content $content)
|
||||
{
|
||||
if (config('app.debug')) {
|
||||
return $content
|
||||
->title(__('admin.menu_titles.dashboard'))
|
||||
->description('Description...')
|
||||
->row(Dashboard::title())
|
||||
->row(function (Row $row) {
|
||||
$row->column(4, function (Column $column) {
|
||||
$column->append(Dashboard::environment());
|
||||
});
|
||||
|
||||
$row->column(4, function (Column $column) {
|
||||
$column->append(Dashboard::dependencies());
|
||||
});
|
||||
|
||||
$row->column(4, function (Column $column) {
|
||||
$column->append(Dashboard::extensions());
|
||||
});
|
||||
});
|
||||
} else {
|
||||
return $content
|
||||
->title(__('admin.menu_titles.dashboard'))
|
||||
->description('Description...');
|
||||
}
|
||||
$this->content = $content->title('数据看板')->description('Description...');
|
||||
$this->getUserData();
|
||||
$this->getUserStockData();
|
||||
$this->getUserStockOrderData();
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 获取用户数据
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/11/17 11:24
|
||||
*/
|
||||
public function getUserData()
|
||||
{
|
||||
$this->content->row($this->setDivider('用户统计'));
|
||||
|
||||
$users = [
|
||||
'all' => [
|
||||
'name' => '用户总数',
|
||||
'color' => 'blue',
|
||||
'count' => User::count()
|
||||
],
|
||||
'free_vip' => [
|
||||
'name' => '免费会员',
|
||||
'color' => 'green',
|
||||
'count' => User::query()
|
||||
->whereHas('identities', function ($q) {
|
||||
$q->FreeVip();
|
||||
})->count()
|
||||
],
|
||||
'yk' => [
|
||||
'name' => '月卡用户数',
|
||||
'color' => 'red',
|
||||
'count' => User::query()
|
||||
->whereHas('identities', function ($q) {
|
||||
$q->Yk();
|
||||
})->count()
|
||||
],
|
||||
'jk' => [
|
||||
'name' => '季卡用户数',
|
||||
'color' => 'red',
|
||||
'count' => User::query()
|
||||
->whereHas('identities', function ($q) {
|
||||
$q->Jk();
|
||||
})->count()
|
||||
],
|
||||
'nk' => [
|
||||
'name' => '年卡用户数',
|
||||
'color' => 'yellow',
|
||||
'count' => User::query()
|
||||
->whereHas('identities', function ($q) {
|
||||
$q->Nk();
|
||||
})->count(),
|
||||
],
|
||||
];
|
||||
|
||||
$this->content->row(function (Row $row) use ($users) {
|
||||
foreach ($users as $user) {
|
||||
$row->column(2, function (Column $column) use ($user) {
|
||||
$column->append(new InfoBox(
|
||||
$user['name'],
|
||||
'users',
|
||||
$user['color'],
|
||||
'/admin/users',
|
||||
$user['count'],
|
||||
));
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 用户水数量
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2022/9/1 13:35
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUserStockData()
|
||||
{
|
||||
$this->content->row($this->setDivider('会员水库存数'));
|
||||
|
||||
$all = UserStock::query()->sum('stock');
|
||||
$holds = UserStock::query()->sum('hold');
|
||||
$sy = bcsub($all, $holds);
|
||||
|
||||
$users = [
|
||||
'all' => [
|
||||
'name' => '总数',
|
||||
'color' => 'blue',
|
||||
'count' => UserStock::query()->sum('stock')
|
||||
],
|
||||
'stock' => [
|
||||
'name' => '已提货数',
|
||||
'color' => 'green',
|
||||
'count' => UserStock::query()->sum('hold')
|
||||
],
|
||||
'sy' => [
|
||||
'name' => '待提货数',
|
||||
'color' => 'green',
|
||||
'count' => $sy
|
||||
],
|
||||
];
|
||||
|
||||
$this->content->row(function (Row $row) use ($users) {
|
||||
foreach ($users as $user) {
|
||||
$row->column(2, function (Column $column) use ($user) {
|
||||
$column->append(new InfoBox(
|
||||
$user['name'],
|
||||
'goods',
|
||||
$user['color'],
|
||||
'/admin/stocks',
|
||||
$user['count'],
|
||||
));
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 提货订单数量
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2022/9/1 13:51
|
||||
*/
|
||||
public function getUserStockOrderData()
|
||||
{
|
||||
$this->content->row($this->setDivider('会员提货订单'));
|
||||
$users = [
|
||||
'all' => [
|
||||
'name' => '订单总数',
|
||||
'color' => 'blue',
|
||||
'count' => Order::query()->where('type', Order::TYPE_SAMPLE)->count()
|
||||
],
|
||||
'deliver' => [
|
||||
'name' => '待发货',
|
||||
'color' => 'green',
|
||||
'count' => Order::query()
|
||||
->where('type', Order::TYPE_SAMPLE)
|
||||
->paid()
|
||||
->count()
|
||||
],
|
||||
'deliverd' => [
|
||||
'name' => '已发货',
|
||||
'color' => 'green',
|
||||
'count' => Order::query()
|
||||
->where('type', Order::TYPE_SAMPLE)
|
||||
->whereIn('state', [
|
||||
Order::STATUS_DELIVERED,
|
||||
])
|
||||
->count(),
|
||||
],
|
||||
'signed' => [
|
||||
'name' => '已签收',
|
||||
'color' => 'green',
|
||||
'count' => Order::query()
|
||||
->where('type', Order::TYPE_SAMPLE)
|
||||
->whereIn('state', [
|
||||
Order::STATUS_SIGNED,
|
||||
])
|
||||
->count()
|
||||
],
|
||||
];
|
||||
|
||||
$this->content->row(function (Row $row) use ($users) {
|
||||
foreach ($users as $user) {
|
||||
$row->column(2, function (Column $column) use ($user) {
|
||||
$column->append(new InfoBox(
|
||||
$user['name'],
|
||||
'goods',
|
||||
$user['color'],
|
||||
'/admin/stocks',
|
||||
$user['count'],
|
||||
));
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes : 清理模型缓存
|
||||
*
|
||||
* @Date : 2021/6/8 10:51 上午
|
||||
* @Author : < Jason.C >
|
||||
* @return string
|
||||
*/
|
||||
public function cleanCache(): string
|
||||
{
|
||||
Artisan::call('modelCache:clear');
|
||||
|
||||
return '缓存清理成功';
|
||||
}
|
||||
|
||||
public function setDivider($title)
|
||||
{
|
||||
return <<<HTML
|
||||
<div style="height: 20px; border-bottom: 1px solid #eee; text-align: center;margin-top: 20px;margin-bottom: 20px;">
|
||||
<span style="font-size: 18px; padding: 0 10px;">
|
||||
{$title}
|
||||
</span>
|
||||
</div>
|
||||
HTML;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
56
app/Admin/Controllers/Material/IndexController.php
Normal file
56
app/Admin/Controllers/Material/IndexController.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Material;
|
||||
|
||||
use App\Models\Material;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
|
||||
class IndexController extends AdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* Title for current resource.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $title = '物料/素材';
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Material());
|
||||
|
||||
$grid->column('id', '编号');
|
||||
$grid->column('title', '名称');
|
||||
$grid->column('地址')->display(function () {
|
||||
return $this->cover_url;
|
||||
});
|
||||
$grid->column('created_at', '创建时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form(): Form
|
||||
{
|
||||
$form = new Form(new Material());
|
||||
$form->text('title', '名称');
|
||||
$form->image('cover', '图片')
|
||||
->move('materials/'.date('Y/m/d'))
|
||||
->removable()
|
||||
->required();
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
205
app/Admin/Controllers/Platform/DashboardController.php
Normal file
205
app/Admin/Controllers/Platform/DashboardController.php
Normal file
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Platform;
|
||||
|
||||
use Encore\Admin\Layout\Column;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Layout\Row;
|
||||
use Encore\Admin\Widgets\InfoBox;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Mall\Models\Order;
|
||||
use Modules\Mall\Models\OrderItem;
|
||||
use Modules\User\Models\User;
|
||||
use Modules\User\Models\UserStock;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function index(Content $content): Content
|
||||
{
|
||||
$this->content = $content->title('数据看板')->description('Description...');
|
||||
$this->getVipUserData();
|
||||
$this->getUserStockData();
|
||||
return $this->content;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 获取用户数据
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/11/17 11:24
|
||||
*/
|
||||
public function getVipUserData(): Content
|
||||
{
|
||||
$this->content->row($this->setDivider('会员统计'));
|
||||
$users = [
|
||||
'all' => [
|
||||
'name' => '总会员量',
|
||||
'color' => 'blue',
|
||||
'count' => User::query()
|
||||
->whereHas('identities', function ($q) {
|
||||
$q->where('id', '>', 1);
|
||||
})->count()
|
||||
],
|
||||
'free_vip' => [
|
||||
'name' => '免费会员',
|
||||
'color' => 'green',
|
||||
'count' => User::query()
|
||||
->whereHas('identities', function ($q) {
|
||||
$q->FreeVip();
|
||||
})->count()
|
||||
],
|
||||
'yk' => [
|
||||
'name' => '月卡用户数',
|
||||
'color' => 'red',
|
||||
'count' => User::query()
|
||||
->whereHas('identities', function ($q) {
|
||||
$q->Yk();
|
||||
})->count()
|
||||
],
|
||||
'jk' => [
|
||||
'name' => '季卡用户数',
|
||||
'color' => 'red',
|
||||
'count' => User::query()
|
||||
->whereHas('identities', function ($q) {
|
||||
$q->Jk();
|
||||
})->count()
|
||||
],
|
||||
'nk' => [
|
||||
'name' => '年卡用户数',
|
||||
'color' => 'yellow',
|
||||
'count' => User::query()
|
||||
->whereHas('identities', function ($q) {
|
||||
$q->Nk();
|
||||
})->count(),
|
||||
],
|
||||
'onlone' => [
|
||||
'name' => '在线会员数',
|
||||
'color' => 'red',
|
||||
'count' => User::query()
|
||||
->whereHas('identities', function ($q) {
|
||||
$q->where('id', '>', 2);
|
||||
})
|
||||
->where('status', User::STATUS_INIT)
|
||||
->count(),
|
||||
],
|
||||
'refund' => [
|
||||
'name' => '退费会员数',
|
||||
'color' => 'maroon',
|
||||
'count' => User::query()
|
||||
->whereHas('identities', function ($q) {
|
||||
$q->where('id', '>', 2);
|
||||
})
|
||||
->where('status', User::STATUS_REFUND)
|
||||
->count(),
|
||||
],
|
||||
];
|
||||
|
||||
$this->content->row(function (Row $row) use ($users) {
|
||||
foreach ($users as $user) {
|
||||
$row->column(2, function (Column $column) use ($user) {
|
||||
$column->append(new InfoBox(
|
||||
$user['name'],
|
||||
'users',
|
||||
$user['color'],
|
||||
'/admin/platform/vips',
|
||||
$user['count'],
|
||||
));
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 用户水数量
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2022/9/1 13:35
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUserStockData()
|
||||
{
|
||||
$this->content->row($this->setDivider('会员库存数'));
|
||||
|
||||
$all = UserStock::query()->sum('stock');
|
||||
$holds = UserStock::query()->sum('hold');
|
||||
$sy = bcsub($all, $holds);
|
||||
|
||||
$users = [
|
||||
'all' => [
|
||||
'name' => '累计总箱数',
|
||||
'color' => 'blue',
|
||||
'count' => $all
|
||||
],
|
||||
'stock' => [
|
||||
'name' => '累计提货数',
|
||||
'color' => 'green',
|
||||
'count' => $holds
|
||||
],
|
||||
'sy' => [
|
||||
'name' => '累计剩余',
|
||||
'color' => 'green',
|
||||
'count' => $sy
|
||||
],
|
||||
'online' => [
|
||||
'name' => '线上发货',
|
||||
'color' => 'green',
|
||||
'count' => OrderItem::query()
|
||||
->whereHas('order', function ($q) {
|
||||
$q->whereIn('state', [
|
||||
Order::STATUS_PAID,
|
||||
Order::STATUS_DELIVERED,
|
||||
Order::STATUS_SIGNED,
|
||||
])->where('channel', Order::CHANNEL_USER);
|
||||
})
|
||||
->sum('qty')
|
||||
],
|
||||
'offline' => [
|
||||
'name' => '线下发货',
|
||||
'color' => 'green',
|
||||
'count' => OrderItem::query()
|
||||
->whereHas('order', function ($q) {
|
||||
$q->whereIn('state', [
|
||||
Order::STATUS_PAID,
|
||||
Order::STATUS_DELIVERED,
|
||||
Order::STATUS_SIGNED,
|
||||
])->where('channel', Order::CHANNEL_SYSTEM);
|
||||
})
|
||||
->sum('qty')
|
||||
],
|
||||
];
|
||||
|
||||
$this->content->row(function (Row $row) use ($users) {
|
||||
foreach ($users as $user) {
|
||||
$row->column(2, function (Column $column) use ($user) {
|
||||
$column->append(new InfoBox(
|
||||
$user['name'],
|
||||
'goods',
|
||||
$user['color'],
|
||||
'/admin/users/stocks',
|
||||
$user['count'],
|
||||
));
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function setDivider($title)
|
||||
{
|
||||
return <<<HTML
|
||||
<div style="height: 20px; border-bottom: 1px solid #eee; text-align: center;margin-top: 20px;margin-bottom: 20px;">
|
||||
<span style="font-size: 18px; padding: 0 10px;">
|
||||
{$title}
|
||||
</span>
|
||||
</div>
|
||||
HTML;
|
||||
}
|
||||
|
||||
}
|
||||
255
app/Admin/Controllers/Platform/VipController.php
Normal file
255
app/Admin/Controllers/Platform/VipController.php
Normal file
@@ -0,0 +1,255 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Platform;
|
||||
|
||||
use App\Admin\Actions\LinkCreateAddress;
|
||||
use Carbon\Carbon;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Facades\Admin;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Modules\User\Http\Controllers\Admin\Actions\AddUserRemark;
|
||||
use Modules\User\Http\Controllers\Admin\Actions\JoinIdentity;
|
||||
use Modules\User\Http\Controllers\Admin\Actions\UserStatusInit;
|
||||
use Modules\User\Http\Controllers\Admin\Actions\UserStatusRefund;
|
||||
use Modules\User\Models\Identity;
|
||||
use Modules\User\Models\IdentityLog;
|
||||
use Modules\User\Models\IdentityMiddle;
|
||||
use Modules\User\Models\User;
|
||||
use Modules\User\Renderable\UserLog;
|
||||
|
||||
class VipController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = '会员管理';
|
||||
|
||||
/**
|
||||
* Notes : 用户管理列表
|
||||
*
|
||||
* @Date : 2021/3/11 1:59 下午
|
||||
* @Author : <Jason.C>
|
||||
* @return Grid
|
||||
*/
|
||||
public function grid(): Grid
|
||||
{
|
||||
$grid = new Grid(new User());
|
||||
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
$actions->disableEdit();
|
||||
$actions->disableDelete();
|
||||
$actions->disableView();
|
||||
if ($actions->row->status == User::STATUS_INIT) {
|
||||
$actions->add(new UserStatusRefund());
|
||||
}
|
||||
if ($actions->row->status == User::STATUS_REFUND) {
|
||||
$actions->add(new UserStatusInit());
|
||||
}
|
||||
|
||||
$actions->add(new JoinIdentity());
|
||||
$actions->add(new AddUserRemark());
|
||||
$actions->add(new LinkCreateAddress());
|
||||
|
||||
});
|
||||
|
||||
$grid->quickSearch('username')->placeholder('快速搜索用户名');
|
||||
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
$filter->column(1 / 3, function (Grid\Filter $filter) {
|
||||
$filter->like('username', '用户名');
|
||||
});
|
||||
|
||||
$filter->column(1 / 3, function (Grid\Filter $filter) {
|
||||
$filter->like('info.nickname', '用户昵称');
|
||||
});
|
||||
$filter->column(1 / 3, function (Grid\Filter $filter) {
|
||||
$filter->equal('identities.id', '身份')
|
||||
->select(Identity::query()->where('id', '>', 1)->pluck('name', 'id'));
|
||||
});
|
||||
});
|
||||
|
||||
$grid->model()
|
||||
->whereHas('identities', function ($q) {
|
||||
$q->where('id', '>', 1);
|
||||
})
|
||||
->withCount(['addresses', 'logs'])
|
||||
->with(['info', 'parent', 'identities', 'addresses', 'vipOrders', 'userStock', 'logs']);
|
||||
|
||||
//序号 姓名 手机号 会员类型 会员编号 缴费金额 加入时间 状态(正常,退费) 用箱数 提货箱数 剩余箱数
|
||||
$grid->column('id', '序号');
|
||||
$grid->column('username', '手机号');
|
||||
$grid->column('identities', '会员类型')
|
||||
->display(function () {
|
||||
$data = [];
|
||||
foreach ($this->identities as $identity) {
|
||||
$data[] = $identity->name;
|
||||
}
|
||||
return $data;
|
||||
})
|
||||
->label();
|
||||
$grid->column('serial', '会员编号')
|
||||
->display(function () {
|
||||
$data = [];
|
||||
foreach ($this->identities as $identity) {
|
||||
$data[] = $identity->serial_prefix.$identity->getOriginal('pivot_serial');
|
||||
}
|
||||
return $data;
|
||||
})
|
||||
->label();
|
||||
|
||||
$grid->column('price', '缴费金额')
|
||||
->display(function () {
|
||||
return $this->getOpenVipPrices();
|
||||
})
|
||||
->label();
|
||||
|
||||
$grid->column('created_at', '加入时间');
|
||||
$grid->column('status', '状态')
|
||||
->using(User::STATUS)
|
||||
->label();
|
||||
$grid->column('userStock.stock', '总箱数');
|
||||
$grid->column('userStock.hold', '提货箱数');
|
||||
$grid->column('userStock.residue', '剩余箱数');
|
||||
$grid->column('addresses_count', '收货地址')
|
||||
->link(function () {
|
||||
return route('admin.mall.addresses.index', ['user_id' => $this->id]);
|
||||
}, '_self');
|
||||
$grid->column('logs_count', '备注')
|
||||
->modal('备注信息', UserLog::class);
|
||||
|
||||
$grid->disableExport(false);
|
||||
$grid->export(function ($export) {
|
||||
$export->column('identities', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->column('serial', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->column('price', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->column('status', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
|
||||
// $export->column('use_way', function ($value, $original) {
|
||||
// return strip_tags($value);
|
||||
// });
|
||||
// $export->column('所属用户', function ($value, $original) {
|
||||
// return iconv('gb2312//ignore', 'utf-8',
|
||||
// iconv('utf-8', 'gb2312//ignore', strip_tags(str_replace(" ", " ", $value))));
|
||||
// });
|
||||
//
|
||||
// $export->column('couponGrant.code', function ($value, $original) {
|
||||
// return $value."\n";
|
||||
// });
|
||||
|
||||
$export->except(['addresses_count', 'logs_count']);
|
||||
|
||||
$export->filename($this->title.date("YmdHis"));
|
||||
});
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes : 编辑表单
|
||||
*
|
||||
* @Date : 2021/7/15 5:09 下午
|
||||
* @Author : <Jason.C>
|
||||
* @return Form
|
||||
* @throws Exception
|
||||
*/
|
||||
public function form(): Form
|
||||
{
|
||||
// if (! config('user.create_user_by_admin')) {
|
||||
// throw new Exception('不运允许操作用户');
|
||||
// }
|
||||
|
||||
Admin::script(" $(document.body).append(`<script src='/vendor/js/setStock.js'>`); ");
|
||||
$form = new Form(new User());
|
||||
|
||||
//姓名 手机号 身份 编号 (数字从1开始) 缴费金额 加入日期(当天) 总箱数
|
||||
$form->text('info.nickname', '姓名')->required();
|
||||
$form->text('username', '手机号')
|
||||
->required()
|
||||
->rules(['phone:CN,mobile', 'unique:users,username,{{id}}'], [
|
||||
'phone' => '手机号格式错误'
|
||||
]);
|
||||
$form->select('join_identity_id', '加入身份')
|
||||
->options(Identity::where('order', '>', 2)->pluck('name', 'id'))
|
||||
->required();
|
||||
$form->text('serial', '编号')->value($form->model()->getNewSerial(8))->required();
|
||||
$form->number('price', '缴费金额')
|
||||
->default(1)
|
||||
->required();
|
||||
|
||||
$form->date('join_at', '加入时间')->default(now())->required();
|
||||
$form->number('stock', '总箱数')
|
||||
->default(0)
|
||||
->setLabelClass(['identity_stock'])
|
||||
->required();
|
||||
|
||||
$form->ignore(['join_at', 'price', 'serial', 'stock', 'join_identity_id']);
|
||||
|
||||
$form->saving(function (Form $form) {
|
||||
$exists = IdentityMiddle::query()->where('serial', $form->serial)->first();
|
||||
if ($exists) {
|
||||
$error = new MessageBag([
|
||||
'title' => '错误',
|
||||
'message' => '编号已经存在',
|
||||
]);
|
||||
|
||||
return back()->withInput()->with(compact('error'));
|
||||
}
|
||||
});
|
||||
|
||||
$form->saved(function (Form $form) {
|
||||
$user = $form->model();
|
||||
$user->update([
|
||||
'created_at' => Carbon::parse(request()->jion_at)->startOfDay()
|
||||
]);
|
||||
$user->createOrder(request()->join_identity_id, 1, request()->price, request()->stock, [
|
||||
'serial' => request()->serial,
|
||||
'channel' => IdentityLog::CHANNEL_SYSTEM,
|
||||
]);//创建订单
|
||||
});
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes : User 列表选择, 这里没有判断,用户是否已经有店铺了,如果判断的情况,可能导致当前用户 无法被选中
|
||||
*
|
||||
* @Date : 2021/5/6 4:35 下午
|
||||
* @Author : <Jason.C>
|
||||
*/
|
||||
public function ajax(Request $request)
|
||||
{
|
||||
$q = $request->get('q');
|
||||
|
||||
return User::leftJoin('user_infos as info', 'users.id', '=', 'info.user_id')
|
||||
->where('username', 'like', "%$q%")
|
||||
->orWhere('info.nickname', 'like', "%$q%")
|
||||
->select('id', DB::raw('CONCAT(username, " [", info.nickname, "]") as text'))
|
||||
->paginate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 获取库存
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2022/9/7 15:23
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function stock(Request $request)
|
||||
{
|
||||
$q = $request->get('q');
|
||||
$identity = Identity::find($q);
|
||||
return ['status_code' => 200, 'value' => $identity->stock];
|
||||
}
|
||||
|
||||
}
|
||||
83
app/Admin/Controllers/Platform/VipOrderController.php
Normal file
83
app/Admin/Controllers/Platform/VipOrderController.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Platform;
|
||||
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Exception;
|
||||
use Modules\User\Http\Controllers\Admin\Actions\Refund;
|
||||
use Modules\User\Models\Order;
|
||||
|
||||
class VipOrderController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = '体验官退款';
|
||||
|
||||
/**
|
||||
* Notes: 升级订单
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date : 2021/6/7 15:19
|
||||
* @return Grid
|
||||
*/
|
||||
public function grid(): Grid
|
||||
{
|
||||
try {
|
||||
trait_exists('Modules\Payment\Traits\WithPayments');
|
||||
$grid = new Grid(new Order());
|
||||
$grid->model()
|
||||
->whereHas('identity', function ($q) {
|
||||
$q->ty();
|
||||
})
|
||||
->whereIn('state',[Order::STATE_SUCCESS,Order::STATE_REFUND])
|
||||
->latest();
|
||||
|
||||
$grid->disableCreateButton();
|
||||
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
$actions->disableEdit();
|
||||
$actions->disableDelete();
|
||||
$actions->disableView();
|
||||
if ($actions->row->canRefund()) {
|
||||
$actions->add(new Refund());
|
||||
}
|
||||
});
|
||||
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
$filter->column(1 / 2, function (Grid\Filter $filter) {
|
||||
$filter->like('user.username', '用户名');
|
||||
});
|
||||
|
||||
$filter->column(1 / 2, function (Grid\Filter $filter) {
|
||||
$filter->equal('state', '状态')->select(Order::STATES);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$grid->column('id', '用户ID');
|
||||
$grid->column('升级用户')->display(function () {
|
||||
return $this->user->username."({$this->user->info->nickname})";
|
||||
});
|
||||
$grid->column('identity.name', '身份');
|
||||
$grid->column('price', '金额');
|
||||
$grid->column('state', '状态')->using(Order::STATES)->label();
|
||||
$grid->column('type', '类型')->using(Order::TYPES)->label();
|
||||
$grid->column('created_at', '升级时间');
|
||||
|
||||
return $grid;
|
||||
} catch (Exception $exception) {
|
||||
dd('Payment 模块不存在,无法加载订单数据');
|
||||
}
|
||||
}
|
||||
|
||||
public function form(): Form
|
||||
{
|
||||
$form = new Form(new Order());
|
||||
|
||||
$form->decimal('price', '金额')->required();
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
135
app/Admin/Controllers/TestController.php
Normal file
135
app/Admin/Controllers/TestController.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Bonus\IdentityBonus;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Liuhelong\LaravelAdmin\Wechat\Models\WechatOffiaccountUser;
|
||||
use Modules\Coupon\Models\Coupon;
|
||||
use Modules\Coupon\Traits\WithCoupon;
|
||||
use Modules\User\Models\Identity;
|
||||
use Modules\User\Models\Order;
|
||||
use Modules\User\Models\UserInvite;
|
||||
use Modules\User\Models\UserStockLog;
|
||||
use Modules\User\Models\UserWechat;
|
||||
use Modules\User\Models\UserWechatOfficial;
|
||||
use Modules\User\Traits\WechatTrait;
|
||||
use Vinkla\Hashids\Facades\Hashids;
|
||||
|
||||
class TestController extends Controller
|
||||
{
|
||||
use WechatTrait;
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->getAllSubscribeUsers();
|
||||
|
||||
dd(1);
|
||||
$weChat = app('wechat.official_account');
|
||||
|
||||
$officialUsers = UserWechatOfficial::query()->get();
|
||||
foreach ($officialUsers as $officialUser) {
|
||||
if (! $officialUser->userWechat->unionid) {
|
||||
$info = $weChat->user->get($officialUser->openid);
|
||||
$officialUser->userWechat->update([
|
||||
'unionid' => $info->unionid
|
||||
]);
|
||||
}
|
||||
}
|
||||
dd(1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes: 清空数据表的操作,为了测试用的
|
||||
*
|
||||
* @Author: <C.Jason>
|
||||
* @Date : 2020/11/23 4:54 下午
|
||||
*/
|
||||
public function truncate(Request $request)
|
||||
{
|
||||
$name = $request->name;
|
||||
$is_test = config('app.is_test');
|
||||
dump('is_test'.$is_test);
|
||||
|
||||
if ($name != 'skyxu') {
|
||||
dd('name不对');
|
||||
}
|
||||
|
||||
if (! $is_test) {
|
||||
dd('不是测试环境');
|
||||
}
|
||||
dd(1);
|
||||
$tables = [
|
||||
'admin_operation_log',
|
||||
'bouns',
|
||||
'bouns_orders',
|
||||
'bouns_user_perves',
|
||||
'coupon_grants',
|
||||
'coupon_item_use_logs',
|
||||
'coupon_use_logs',
|
||||
'failed_jobs',
|
||||
'gout_case_log_symptoms',
|
||||
'gout_case_logs',
|
||||
'gout_case_timelines',
|
||||
'gout_case_symptom',
|
||||
'gout_cases',
|
||||
'gout_surveys',
|
||||
'gout_votes',
|
||||
'jobs',
|
||||
'linker_relations',
|
||||
'linkers',
|
||||
'mall_addresses',
|
||||
'mall_order_expresses',
|
||||
'mall_order_items',
|
||||
'mall_orders',
|
||||
'mall_carts',
|
||||
'mall_refund_items',
|
||||
'mall_refund_logs',
|
||||
'mall_refunds',
|
||||
'mall_refund_expresses',
|
||||
'notifications',
|
||||
'payment_refunds',
|
||||
'payments',
|
||||
'user_account_logs',
|
||||
'user_accounts',
|
||||
'user_identity',
|
||||
'user_identity_logs',
|
||||
'user_identity_coupons',
|
||||
'user_infos',
|
||||
'user_invites',
|
||||
'user_logs',
|
||||
'user_orders',
|
||||
'user_perves',
|
||||
'user_relations',
|
||||
'user_sign_logs',
|
||||
'user_signs',
|
||||
'user_sms',
|
||||
'user_stock_logs',
|
||||
'user_stocks',
|
||||
'user_wechat_apps',
|
||||
'user_wechat_minis',
|
||||
'user_wechat_officials',
|
||||
'user_wechats',
|
||||
'users',
|
||||
'versions',
|
||||
'wechat_offiaccount_event_logs',
|
||||
'withdraw_alipay_accounts',
|
||||
'withdraw_bank_accounts',
|
||||
'withdraw_logs',
|
||||
'withdraws',
|
||||
'personal_access_tokens',
|
||||
];
|
||||
foreach ($tables as $table) {
|
||||
DB::table($table)->truncate();
|
||||
}
|
||||
dd('清理成功');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
10
app/Admin/Routes/material.php
Normal file
10
app/Admin/Routes/material.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
|
||||
Route::group([
|
||||
'namespace' => 'Material',
|
||||
], function (Router $router) {
|
||||
$router->resource('materials', 'IndexController');
|
||||
|
||||
});
|
||||
15
app/Admin/Routes/platform.php
Normal file
15
app/Admin/Routes/platform.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
|
||||
Route::group([
|
||||
'namespace' => 'Platform',
|
||||
'prefix' => 'platform',
|
||||
], function (Router $router) {
|
||||
$router->resource('experiences', 'ExperienceController');//体验官审核
|
||||
$router->resource('vip_orders', 'VipOrderController');//体验官审核
|
||||
$router->resource('vips', 'VipController');//会员管理
|
||||
$router->get('identity_stock', 'VipController@stock')->name('platform.identity_stock');;//会员管理
|
||||
$router->get('dashboard', 'DashboardController@index');
|
||||
|
||||
});
|
||||
12
app/Admin/Routes/test.php
Normal file
12
app/Admin/Routes/test.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::group([
|
||||
'prefix' => 'test',
|
||||
], function (Router $router) {
|
||||
$router->get('', 'TestController@index');
|
||||
$router->get('truncate', 'TestController@truncate');
|
||||
$router->get('leady', 'LeadyController@index');
|
||||
});
|
||||
Reference in New Issue
Block a user