generated from liutk/owl-admin-base
Compare commits
3 Commits
54faeb2ca7
...
3c19d5e4e5
| Author | SHA1 | Date |
|---|---|---|
|
|
3c19d5e4e5 | |
|
|
1788620e8f | |
|
|
831af90170 |
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Admin\Controllers;
|
namespace App\Admin\Controllers;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Card;
|
use Slowlyo\OwlAdmin\Renderers\Card;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Flex;
|
use Slowlyo\OwlAdmin\Renderers\Flex;
|
||||||
|
|
@ -14,19 +15,20 @@ use Slowlyo\OwlAdmin\Renderers\Custom;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Wrapper;
|
use Slowlyo\OwlAdmin\Renderers\Wrapper;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
class HomeController extends AdminController
|
class HomeController extends AdminController
|
||||||
{
|
{
|
||||||
public function index(): JsonResponse|JsonResource
|
public function index(): JsonResponse|JsonResource
|
||||||
{
|
{
|
||||||
$page = $this->basePage()->css($this->css())->body([
|
$page = $this->basePage()->css($this->css())->body([
|
||||||
Grid::make()->columns([
|
// Grid::make()->columns([
|
||||||
$this->frameworkInfo()->md(5),
|
// $this->frameworkInfo()->md(5),
|
||||||
Flex::make()->items([
|
// Flex::make()->items([
|
||||||
$this->pieChart(),
|
// $this->pieChart(),
|
||||||
$this->cube(),
|
// $this->cube(),
|
||||||
]),
|
// ]),
|
||||||
]),
|
// ]),
|
||||||
Grid::make()->columns([
|
Grid::make()->columns([
|
||||||
$this->lineChart()->md(8),
|
$this->lineChart()->md(8),
|
||||||
Flex::make()->className('h-full')->items([
|
Flex::make()->className('h-full')->items([
|
||||||
|
|
@ -171,28 +173,43 @@ JS
|
||||||
|
|
||||||
public function lineChart(): Card
|
public function lineChart(): Card
|
||||||
{
|
{
|
||||||
$randArr = function () {
|
$days = [];
|
||||||
$_arr = [];
|
|
||||||
for($i=0; $i<7; $i++){
|
for($i=0; $i<7; $i++){
|
||||||
$_arr[] = random_int(10, 200);
|
$days[] = now()->subDays($i)->format('Y-m-d');
|
||||||
}
|
}
|
||||||
return '[' . implode(',', $_arr) . ']';
|
$createUser = User::selectRaw('DATE(`created_at`) as day, count(id) as num')
|
||||||
};
|
->whereBetween('created_at', [now()->subDays(6)->startOfDay(), now()])
|
||||||
|
->groupBy('day')
|
||||||
|
->get()->pluck('num', 'day')->toArray();
|
||||||
|
|
||||||
$random1 = $randArr();
|
$bindUser = User::selectRaw('DATE(`bind_phone_at`) as day, count(id) as num')
|
||||||
$random2 = $randArr();
|
->whereBetween('bind_phone_at', [now()->subDays(6)->startOfDay(), now()])
|
||||||
|
->groupBy('day')
|
||||||
|
->get()->pluck('num', 'day')->toArray();
|
||||||
|
|
||||||
|
foreach($days as $day){
|
||||||
|
if(!isset($createUser[$day])){
|
||||||
|
$createUser[$day] = 0;
|
||||||
|
}
|
||||||
|
if(!isset($bindUser[$day])){
|
||||||
|
$bindUser[$day] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
asort($createUser);asort($bindUser);
|
||||||
|
$createUser = '['.implode(',', $createUser).']';
|
||||||
|
$bindUser = '['.implode(',', $bindUser).']';
|
||||||
|
|
||||||
$chart = Chart::make()->height(380)->className('h-96')->config("{
|
$chart = Chart::make()->height(380)->className('h-96')->config("{
|
||||||
backgroundColor:'',
|
backgroundColor:'',
|
||||||
title:{ text: '会员增长情况', },
|
title:{ text: '会员增长情况', },
|
||||||
tooltip: { trigger: 'axis' },
|
tooltip: { trigger: 'axis' },
|
||||||
xAxis: { type: 'category', boundaryGap: false, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] },
|
xAxis: { type: 'category', boundaryGap: false, data: ['".implode("','", $days)."']},
|
||||||
yAxis: { type: 'value' },
|
yAxis: { type: 'value' },
|
||||||
grid:{ left: '7%', right:'3%', top: 60, bottom: 30, },
|
grid:{ left: '7%', right:'3%', top: 60, bottom: 30, },
|
||||||
legend: { data: ['访问量','注册量'] },
|
legend: { data: ['访问量','注册量'] },
|
||||||
series: [
|
series: [
|
||||||
{ name: '访问量', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', },
|
{ name: '访问量', data: {$createUser}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', },
|
||||||
{ name:'注册量', data: {$random2}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', },
|
{ name:'注册量', data: {$bindUser}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', },
|
||||||
]}");
|
]}");
|
||||||
|
|
||||||
return Card::make()->className('clear-card-mb')->body($chart);
|
return Card::make()->className('clear-card-mb')->body($chart);
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,9 @@ class UserController extends AdminController
|
||||||
amis()->TableColumn('last_login_at', __('admin.users.last_login_at')),
|
amis()->TableColumn('last_login_at', __('admin.users.last_login_at')),
|
||||||
amis()->TableColumn('last_ip', __('admin.users.last_login_ip')),
|
amis()->TableColumn('last_ip', __('admin.users.last_login_ip')),
|
||||||
|
|
||||||
Operation::make()->label(__('admin.actions'))->buttons([
|
// Operation::make()->label(__('admin.actions'))->buttons([
|
||||||
$this->rowShowTypeButton('drawer', 'xl'),
|
// $this->rowShowTypeButton('drawer', 'xl'),
|
||||||
])
|
// ])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->baseList($crud);
|
return $this->baseList($crud);
|
||||||
|
|
@ -57,10 +57,47 @@ class UserController extends AdminController
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function detail(): Form
|
public function detail()
|
||||||
{
|
{
|
||||||
return $this->baseDetail()->body([
|
$form = amisMake()->form()->title('')->panelClassName('border-r border-t-0 border-b-0 border-l-0')->mode('horizontal')
|
||||||
|
->static(true)->actions([])
|
||||||
|
->body([
|
||||||
|
amis()->FieldSetControl()->title('用户信息')->body([
|
||||||
|
amis()->TextControl('nick_name', __('admin.users.nick_name'))->required(true),
|
||||||
|
amis()->Image()->type('static-image')->name('avatar')->label( __('admin.users.avatar'))->height('80px')->width('80px')->thumbMode('cover')->enlargeAble(true)->required(true),
|
||||||
|
amis()->TextControl('phone', __('admin.users.phone'))->required(true),
|
||||||
|
amis()->DateTimeControl('created_at', __('admin.users.created_at'))->format('YYYY-MM-DD HH:mm:ss')->required(true),
|
||||||
|
amis()->DateTimeControl('bind_phone_at', __('admin.users.bind_phone_at'))->format('YYYY-MM-DD HH:mm:ss')->required(true),
|
||||||
|
|
||||||
|
amis()->TextControl('last_ip', __('admin.users.last_login_ip'))->required(true),
|
||||||
|
amis()->DateTimeControl('last_login_at', __('admin.users.last_login_at'))->format('YYYY-MM-DD HH:mm:ss')->required(true),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return amisMake()->Grid()->columns([
|
||||||
|
amis()->Column()->body($form)->md(4),
|
||||||
|
amis()->Column()->body([
|
||||||
|
amisMake()->form()->title('')->panelClassName('border-0')->mode('horizontal')
|
||||||
|
->static(true)->actions([])
|
||||||
|
->body([
|
||||||
|
amis()->FieldSetControl()->title('竞猜场次')->body([
|
||||||
|
amisMake()->CRUDTable()->affixHeader(false)->perPage(10)->loadDataOnce(true)
|
||||||
|
->title('')
|
||||||
|
->api()
|
||||||
|
->columns([
|
||||||
|
|
||||||
|
]),
|
||||||
|
])
|
||||||
|
])
|
||||||
|
])->md(8),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function detailActions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//返回
|
||||||
|
amis()->Button()->actionType('cancel')->label(__('admin.back'))->primary()
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers;
|
||||||
|
|
||||||
|
use Slowlyo\OwlAdmin\Admin;
|
||||||
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||||
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||||
|
use Slowlyo\OwlAdmin\Renderers\Operation;
|
||||||
|
use Slowlyo\OwlAdmin\Renderers\Dialog;
|
||||||
|
use Slowlyo\OwlAdmin\Renderers\DialogAction;
|
||||||
|
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||||
|
use App\Services\Admin\UserGameService;
|
||||||
|
use App\Models\Activity;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class UserGameController extends AdminController
|
||||||
|
{
|
||||||
|
protected string $serviceName = UserGameService::class;
|
||||||
|
|
||||||
|
public function list(): Page
|
||||||
|
{
|
||||||
|
$crud = $this->baseCRUD()->tableLayout('fixed')
|
||||||
|
->headerToolbar([
|
||||||
|
amis('reload')->align('right'),
|
||||||
|
amis('filter-toggler')->align('right'),
|
||||||
|
])
|
||||||
|
->filter($this->baseFilter()->labelWidth('80px')->body([
|
||||||
|
amis()->GroupControl()->mode('horizontal')->body([
|
||||||
|
amis()->SelectControl('activity', __('admin.activities.name'))->options(Activity::sort()->pluck('name', 'id')->toArray())
|
||||||
|
->columnRatio(3),
|
||||||
|
amis()->TextControl('user_name', __('admin.users.nick_name'))
|
||||||
|
->columnRatio(3)
|
||||||
|
->placeholder(__('admin.users.nick_name')),
|
||||||
|
amis()->TextControl('user_phone', __('admin.users.phone'))
|
||||||
|
->columnRatio(3)
|
||||||
|
->placeholder(__('admin.users.phone')),
|
||||||
|
])
|
||||||
|
]))
|
||||||
|
->columns([
|
||||||
|
amis()->TableColumn('activity.name', __('admin.activities.name')),
|
||||||
|
amis()->TableColumn('game.name', __('admin.activity_games.name')),
|
||||||
|
amis()->TableColumn('user.nick_name', __('admin.users.nick_name')),
|
||||||
|
amis()->TableColumn('user.phone', __('admin.users.phone'))->copyable(),
|
||||||
|
amis()->TableColumn('score', __('admin.user_games.score')),
|
||||||
|
amis()->TableColumn('is_right', __('admin.user_games.is_right'))->type('mapping')->map([
|
||||||
|
"0"=>"-",
|
||||||
|
"1"=>"<span class='label label-danger'>正确</span>",
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->baseList($crud);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function form($isEdit = false): Form
|
||||||
|
{
|
||||||
|
return $this->baseForm()->body([
|
||||||
|
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function detail()
|
||||||
|
{
|
||||||
|
$form = amisMake()->form()->title('')->panelClassName('border-r border-t-0 border-b-0 border-l-0')->mode('horizontal')
|
||||||
|
->static(true)->actions([])
|
||||||
|
->body([
|
||||||
|
|
||||||
|
]);
|
||||||
|
|
||||||
|
return amisMake()->Grid()->columns([
|
||||||
|
amis()->Column()->body($form)->md(4),
|
||||||
|
amis()->Column()->body([
|
||||||
|
])->md(8),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function detailActions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//返回
|
||||||
|
amis()->Button()->actionType('cancel')->label(__('admin.back'))->primary()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发货
|
||||||
|
*/
|
||||||
|
public function shipping(UserGift $userGift, Request $request)
|
||||||
|
{
|
||||||
|
$res = $this->service->shippingGift($userGift, $request->input());
|
||||||
|
|
||||||
|
return $this->autoResponse($res, '发货');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,9 +6,13 @@ use Slowlyo\OwlAdmin\Admin;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Page;
|
use Slowlyo\OwlAdmin\Renderers\Page;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Form;
|
use Slowlyo\OwlAdmin\Renderers\Form;
|
||||||
use Slowlyo\OwlAdmin\Renderers\Operation;
|
use Slowlyo\OwlAdmin\Renderers\Operation;
|
||||||
|
use Slowlyo\OwlAdmin\Renderers\Dialog;
|
||||||
|
use Slowlyo\OwlAdmin\Renderers\DialogAction;
|
||||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||||
use App\Services\Admin\UserGiftService;
|
use App\Services\Admin\UserGiftService;
|
||||||
use App\Admin\Components;
|
use App\Models\UserGift;
|
||||||
|
use App\Models\Activity;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class UserGiftController extends AdminController
|
class UserGiftController extends AdminController
|
||||||
{
|
{
|
||||||
|
|
@ -22,13 +26,23 @@ class UserGiftController extends AdminController
|
||||||
amis('filter-toggler')->align('right'),
|
amis('filter-toggler')->align('right'),
|
||||||
])
|
])
|
||||||
->filter($this->baseFilter()->labelWidth('80px')->body([
|
->filter($this->baseFilter()->labelWidth('80px')->body([
|
||||||
|
amis()->GroupControl()->mode('horizontal')->body([
|
||||||
|
amis()->SelectControl('activity', __('admin.activities.name'))->options(Activity::sort()->pluck('name', 'id')->toArray()),
|
||||||
|
amis()->TextControl('user_name', __('admin.users.nick_name'))
|
||||||
|
->placeholder(__('admin.users.nick_name')),
|
||||||
|
amis()->TextControl('user_phone', __('admin.users.phone'))
|
||||||
|
->placeholder(__('admin.users.phone')),
|
||||||
|
amis()->SelectControl('state', __('admin.user_gifts.state'))
|
||||||
|
->options([
|
||||||
|
1=>'未发货',2=>'已发货',0=>'未领取'
|
||||||
|
]),
|
||||||
|
])
|
||||||
]))
|
]))
|
||||||
->columns([
|
->columns([
|
||||||
amis()->TableColumn('activity.name', __('admin.activities.name')),
|
amis()->TableColumn('activity.name', __('admin.activities.name')),
|
||||||
amis()->TableColumn('gift.name', __('admin.activity_gifts.name')),
|
amis()->TableColumn('gift.name', __('admin.activity_gifts.name')),
|
||||||
amis()->TableColumn('user.nick_name', __('admin.users.nick_name')),
|
amis()->TableColumn('user.nick_name', __('admin.users.nick_name')),
|
||||||
amis()->TableColumn('user.phone', __('admin.users.phone')),
|
amis()->TableColumn('user.phone', __('admin.users.phone'))->copyable(),
|
||||||
amis()->TableColumn('state', __('admin.user_gifts.state'))->type('mapping')->map([
|
amis()->TableColumn('state', __('admin.user_gifts.state'))->type('mapping')->map([
|
||||||
"0"=>"<span class='label label-default'>未领取</span>",
|
"0"=>"<span class='label label-default'>未领取</span>",
|
||||||
"1"=>"<span class='label label-danger'>未发货</span>",
|
"1"=>"<span class='label label-danger'>未发货</span>",
|
||||||
|
|
@ -39,7 +53,19 @@ class UserGiftController extends AdminController
|
||||||
amis()->TableColumn('address', __('admin.user_gifts.address')),
|
amis()->TableColumn('address', __('admin.user_gifts.address')),
|
||||||
amis()->TableColumn('phone', __('admin.user_gifts.phone')),
|
amis()->TableColumn('phone', __('admin.user_gifts.phone')),
|
||||||
amis()->TableColumn('shipping_company', __('admin.user_gifts.shipping_company')),
|
amis()->TableColumn('shipping_company', __('admin.user_gifts.shipping_company')),
|
||||||
amis()->TableColumn('shipping_number', __('admin.user_gifts.shipping_number')),
|
amis()->TableColumn('shipping_number', __('admin.user_gifts.shipping_number'))->copyable(),
|
||||||
|
Operation::make()->label(__('admin.actions'))->buttons([
|
||||||
|
amisMake()->DialogAction()->label('发货')
|
||||||
|
->level('link')
|
||||||
|
->dialog(Dialog::make()->title('填写发货信息')->body([
|
||||||
|
amisMake()->form()->title('')
|
||||||
|
->api('post:' .admin_url('user_gifts/${id}/shipping'))
|
||||||
|
->body([
|
||||||
|
amis()->TextControl('shipping_company', __('admin.user_gifts.shipping_company'))->required(),
|
||||||
|
amis()->TextControl('shipping_number', __('admin.user_gifts.shipping_number'))->required(),
|
||||||
|
])
|
||||||
|
]))->visibleOn('${state == 1}'),
|
||||||
|
])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->baseList($crud);
|
return $this->baseList($crud);
|
||||||
|
|
@ -74,4 +100,14 @@ class UserGiftController extends AdminController
|
||||||
amis()->Button()->actionType('cancel')->label(__('admin.back'))->primary()
|
amis()->Button()->actionType('cancel')->label(__('admin.back'))->primary()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发货
|
||||||
|
*/
|
||||||
|
public function shipping(UserGift $userGift, Request $request)
|
||||||
|
{
|
||||||
|
$res = $this->service->shippingGift($userGift, $request->input());
|
||||||
|
|
||||||
|
return $this->autoResponse($res, '发货');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -42,7 +42,10 @@ Route::group([
|
||||||
|
|
||||||
$router->resource('activity_gifts', \App\Admin\Controllers\ActivityGiftController::class);
|
$router->resource('activity_gifts', \App\Admin\Controllers\ActivityGiftController::class);
|
||||||
|
|
||||||
$router->resource('user_gifts', \App\Admin\Controllers\UserGiftController::class);
|
$router->post('user_gifts/{user_gift}/shipping', [\App\Admin\Controllers\UserGiftController::class, 'shipping']);
|
||||||
|
$router->resource('user_gifts', \App\Admin\Controllers\UserGiftController::class)->only(['index']);
|
||||||
|
|
||||||
|
$router->resource('user_games', \App\Admin\Controllers\UserGameController::class)->only(['index']);
|
||||||
|
|
||||||
//修改上传
|
//修改上传
|
||||||
$router->post('upload_file', [\App\Admin\Controllers\IndexController::class, 'uploadFile']);
|
$router->post('upload_file', [\App\Admin\Controllers\IndexController::class, 'uploadFile']);
|
||||||
|
|
|
||||||
|
|
@ -57,9 +57,9 @@ class ActivityGameController extends ApiController
|
||||||
return $this->success();
|
return $this->success();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function joinGame(ActivityGame $activityGame, JoinGameRequest $request)
|
public function joinGame(ActivityGame $game, JoinGameRequest $request)
|
||||||
{
|
{
|
||||||
$res = $this->service->join($activityGame, $request->user(), $request->input('score'));
|
$res = $this->service->join($game, $request->user(), $request->input('score'));
|
||||||
|
|
||||||
if($res['status']){
|
if($res['status']){
|
||||||
return $this->success(null, '竞猜成功');
|
return $this->success(null, '竞猜成功');
|
||||||
|
|
|
||||||
|
|
@ -71,14 +71,15 @@ class UserController extends ApiController
|
||||||
|
|
||||||
public function giftList(Request $request)
|
public function giftList(Request $request)
|
||||||
{
|
{
|
||||||
$userGifts = $request->user()->gifts()->with(['gift', 'gift.activity'])->sort()
|
$userGifts = $request->user()->gifts()->with(['gift', 'activity'])->sort()
|
||||||
->simplePaginate($request->query('per_page', 20));
|
->simplePaginate($request->query('per_page', 20));
|
||||||
|
|
||||||
return $this->success(['activities' => UserGiftResource::collection($userGifts)->resolve()]);
|
return $this->success(['gifts' => UserGiftResource::collection($userGifts)->resolve()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function userGift(UserGift $userGift, Request $request)
|
public function userGift(UserGift $userGift, Request $request)
|
||||||
{
|
{
|
||||||
|
$userGift->load(['gift', 'activity']);
|
||||||
return UserGiftResource::make($userGift);
|
return UserGiftResource::make($userGift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ class UserGiftResource extends JsonResource
|
||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
'gift_name'=>$this->whenLoaded('gift', function () {
|
'gift_name'=>$this->whenLoaded('gift', function () {
|
||||||
return $this->gift->name;
|
return $this->gift->name;
|
||||||
}, ''),
|
}, ''),
|
||||||
|
|
@ -28,8 +29,8 @@ class UserGiftResource extends JsonResource
|
||||||
'gift_explain'=> $this->whenLoaded('gift', function () {
|
'gift_explain'=> $this->whenLoaded('gift', function () {
|
||||||
return $this->gift->explain;
|
return $this->gift->explain;
|
||||||
}, ''),
|
}, ''),
|
||||||
'activity_name' => $this->whenLoaded('gift.activity', function () {
|
'activity_name' => $this->whenLoaded('activity', function () {
|
||||||
return $this->gift->activity->name;
|
return $this->activity->name;
|
||||||
}, ''),
|
}, ''),
|
||||||
|
|
||||||
'consignee' => $this->consignee ?? '',
|
'consignee' => $this->consignee ?? '',
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,10 @@ class Activity extends Model
|
||||||
{
|
{
|
||||||
use HasFactory,Filterable;
|
use HasFactory,Filterable;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'state'
|
||||||
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'start_at' => 'datetime',
|
'start_at' => 'datetime',
|
||||||
'end_at' => 'datetime'
|
'end_at' => 'datetime'
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ class AdFilter extends ModelFilter
|
||||||
{
|
{
|
||||||
return $this->where('address', $address);
|
return $this->where('address', $address);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function publishedAt($publishedAt){
|
public function publishedAt($publishedAt){
|
||||||
$publishedAt = explode(',',$publishedAt);
|
$publishedAt = explode(',',$publishedAt);
|
||||||
return $this->where(function($q) use ($publishedAt) {
|
return $this->where(function($q) use ($publishedAt) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Filters;
|
||||||
|
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
use EloquentFilter\ModelFilter;
|
||||||
|
|
||||||
|
class UserGameFilter extends ModelFilter
|
||||||
|
{
|
||||||
|
public function activityId($activity)
|
||||||
|
{
|
||||||
|
return $this->where('activity_id', $activityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function userName($userName)
|
||||||
|
{
|
||||||
|
return $this->whereHas('user', function($q) use ($userName) {
|
||||||
|
return $q->where('nick_name', 'like', '%'.$userName.'%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function userPhone($userPhone)
|
||||||
|
{
|
||||||
|
return $this->whereHas('user', function($q) use ($userPhone) {
|
||||||
|
return $q->where('phone', 'like', $userPhone.'%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,5 +7,22 @@ use EloquentFilter\ModelFilter;
|
||||||
|
|
||||||
class UserGiftFilter extends ModelFilter
|
class UserGiftFilter extends ModelFilter
|
||||||
{
|
{
|
||||||
|
public function activityId($activity)
|
||||||
|
{
|
||||||
|
return $this->where('activity_id', $activityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function userName($userName)
|
||||||
|
{
|
||||||
|
return $this->whereHas('user', function($q) use ($userName) {
|
||||||
|
return $q->where('nick_name', 'like', '%'.$userName.'%');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function userPhone($userPhone)
|
||||||
|
{
|
||||||
|
return $this->whereHas('user', function($q) use ($userPhone) {
|
||||||
|
return $q->where('phone', 'like', $userPhone.'%');
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,11 @@ namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use EloquentFilter\Filterable;
|
||||||
|
|
||||||
class UserGame extends Model
|
class UserGame extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory, Filterable;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'user_id',
|
'user_id',
|
||||||
|
|
@ -16,4 +17,19 @@ class UserGame extends Model
|
||||||
'score',
|
'score',
|
||||||
'is_right'
|
'is_right'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'user_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function activity()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Activity::class, 'activity_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function game()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(ActivityGame::class, 'game_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,15 @@ class UserGift extends Model
|
||||||
{
|
{
|
||||||
use HasFactory,Filterable;
|
use HasFactory,Filterable;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'consignee',
|
||||||
|
'address',
|
||||||
|
'phone',
|
||||||
|
'shipping_company',
|
||||||
|
'shipping_number',
|
||||||
|
'state',
|
||||||
|
];
|
||||||
|
|
||||||
public function scopeSort($q)
|
public function scopeSort($q)
|
||||||
{
|
{
|
||||||
$q->orderBy('created_at', 'desc');
|
$q->orderBy('created_at', 'desc');
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Services\Admin;
|
namespace App\Services\Admin;
|
||||||
|
|
||||||
|
use DB;
|
||||||
use App\Models\Activity;
|
use App\Models\Activity;
|
||||||
use App\Models\Filters\ActivityFilter;
|
use App\Models\Filters\ActivityFilter;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Admin;
|
||||||
|
|
||||||
|
use App\Models\UserGame;
|
||||||
|
use App\Models\Filters\UserGameFilter;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method UserGame getModel()
|
||||||
|
* @method UserGame|\Illuminate\Database\Query\Builder query()
|
||||||
|
*/
|
||||||
|
class UserGameService extends BaseService
|
||||||
|
{
|
||||||
|
protected string $modelName = UserGame::class;
|
||||||
|
|
||||||
|
protected string $modelFilterName = UserGameFilter::class;
|
||||||
|
|
||||||
|
protected array $withRelationships = ['user', 'game', 'activity'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -21,4 +21,16 @@ class UserGiftService extends BaseService
|
||||||
protected string $modelFilterName = UserGiftFilter::class;
|
protected string $modelFilterName = UserGiftFilter::class;
|
||||||
|
|
||||||
protected array $withRelationships = ['user', 'gift', 'activity'];
|
protected array $withRelationships = ['user', 'gift', 'activity'];
|
||||||
|
|
||||||
|
public function shippingGift(UserGift $userGift, $params)
|
||||||
|
{
|
||||||
|
//更新状态,结果
|
||||||
|
$userGift->update([
|
||||||
|
'shipping_company' => $params['shipping_company'],
|
||||||
|
'shipping_number' => $params['shipping_number'],
|
||||||
|
'state' => 2,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -65,40 +65,40 @@ class UserService
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function receiveGift(UserGift $userGift, $params)
|
public function receiveGift(UserGift $userGift, $params)
|
||||||
// {
|
{
|
||||||
// $userGift->update([
|
$userGift->update([
|
||||||
// 'consignee' => $params['consignee'],
|
'consignee' => $params['consignee'],
|
||||||
// 'phone' => $params['phone'],
|
'phone' => $params['phone'],
|
||||||
// 'address' => $params['address'],
|
'address' => $params['address'],
|
||||||
// 'state' => 1
|
'state' => 1
|
||||||
// ]);
|
]);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// protected function saveFile($path, $file = null)
|
protected function saveFile($path, $file = null)
|
||||||
// {
|
{
|
||||||
// if (gettype($file) == 'object') {
|
if (gettype($file) == 'object') {
|
||||||
// //获取文件大小
|
//获取文件大小
|
||||||
// if($size = $file->getSize() > 2*1024*1024){//大于2M
|
if($size = $file->getSize() > 2*1024*1024){//大于2M
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
||||||
// $type = $file->getClientOriginalExtension();
|
$type = $file->getClientOriginalExtension();
|
||||||
// if (in_array($type, array('jpeg', 'jpg', 'bmp', 'png'))) {
|
if (in_array($type, array('jpeg', 'jpg', 'bmp', 'png'))) {
|
||||||
// $file = Storage::disk(Admin::config('admin.upload.disk'))->putFile($path, $file);
|
$file = Storage::disk(Admin::config('admin.upload.disk'))->putFile($path, $file);
|
||||||
// }else{
|
}else{
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
||||||
// } else if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $file, $result)) {
|
} else if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $file, $result)) {
|
||||||
// $type = $result[2];
|
$type = $result[2];
|
||||||
// if (in_array($type, array('jpeg', 'jpg', 'bmp', 'png'))) {
|
if (in_array($type, array('jpeg', 'jpg', 'bmp', 'png'))) {
|
||||||
// $savePath = $path . '/' . uniqid() . '.' . $type;
|
$savePath = $path . '/' . uniqid() . '.' . $type;
|
||||||
// Storage::disk(Admin::config('admin.upload.disk'))->put($savePath, base64_decode(str_replace($result[1], '', $file)));
|
Storage::disk(Admin::config('admin.upload.disk'))->put($savePath, base64_decode(str_replace($result[1], '', $file)));
|
||||||
// $file = $savePath;
|
$file = $savePath;
|
||||||
// }else{
|
}else{
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// return $file;
|
return $file;
|
||||||
// }
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
return [
|
return [
|
||||||
// 应用名称
|
// 应用名称
|
||||||
'name' => 'Owl Admin',
|
'name' => '竞猜小程序',
|
||||||
|
|
||||||
// 应用 logo
|
// 应用 logo
|
||||||
'logo' => '/admin-assets/logo.png',
|
'logo' => '/admin-assets/logo.png',
|
||||||
|
|
@ -86,7 +86,7 @@ return [
|
||||||
|
|
||||||
'layout' => [
|
'layout' => [
|
||||||
// 浏览器标题, 功能名称使用 %title% 代替
|
// 浏览器标题, 功能名称使用 %title% 代替
|
||||||
'title' => '%title% | OwlAdmin',
|
'title' => '%title% | 竞猜小程序',
|
||||||
'header' => [
|
'header' => [
|
||||||
// 是否显示 [刷新] 按钮
|
// 是否显示 [刷新] 按钮
|
||||||
'refresh' => true,
|
'refresh' => true,
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ class AdminMenuSeeder extends Seeder
|
||||||
['title' => 'activity', 'icon' => 'akar-icons:star', 'url' => '/activity', 'order' => 3,
|
['title' => 'activity', 'icon' => 'akar-icons:star', 'url' => '/activity', 'order' => 3,
|
||||||
'children' => [
|
'children' => [
|
||||||
['title'=> 'activites', 'icon'=> 'bx:football', 'url' => '/activities', 'order'=>1],
|
['title'=> 'activites', 'icon'=> 'bx:football', 'url' => '/activities', 'order'=>1],
|
||||||
['title'=> 'user_gifts', 'icon'=> 'akar-icons:gift', 'url' => '/user_gifts', 'order'=>1],
|
['title'=> 'user_games', 'icon'=> 'material-symbols:list-alt-outline', 'url' => '/user_games', 'order'=>2],
|
||||||
|
['title'=> 'user_gifts', 'icon'=> 'akar-icons:gift', 'url' => '/user_gifts', 'order'=>3],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
['title' => 'web_content', 'icon' => 'ic:outline-collections-bookmark', 'url' => '', 'order'=>4,
|
['title' => 'web_content', 'icon' => 'ic:outline-collections-bookmark', 'url' => '', 'order'=>4,
|
||||||
|
|
|
||||||
|
|
@ -362,5 +362,9 @@ return [
|
||||||
'shipping_company' => '快递公司',
|
'shipping_company' => '快递公司',
|
||||||
'shipping_number' => '快递号码',
|
'shipping_number' => '快递号码',
|
||||||
'state' => '状态',
|
'state' => '状态',
|
||||||
|
],
|
||||||
|
'user_games' => [
|
||||||
|
'score' => '竞猜比分',
|
||||||
|
'is_right' => '状态',
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ return [
|
||||||
'ads' => '广告管理',
|
'ads' => '广告管理',
|
||||||
'activity' => '活动中心',
|
'activity' => '活动中心',
|
||||||
'activites'=> '足彩竞猜',
|
'activites'=> '足彩竞猜',
|
||||||
|
'user_games' => '竞猜记录',
|
||||||
'user_gifts' => '获奖列表',
|
'user_gifts' => '获奖列表',
|
||||||
'users' => '会员管理'
|
'users' => '会员管理'
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue