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;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Slowlyo\OwlAdmin\Renderers\Card;
|
||||
use Slowlyo\OwlAdmin\Renderers\Flex;
|
||||
|
|
@ -14,19 +15,20 @@ use Slowlyo\OwlAdmin\Renderers\Custom;
|
|||
use Slowlyo\OwlAdmin\Renderers\Wrapper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||
use App\Models\User;
|
||||
|
||||
class HomeController extends AdminController
|
||||
{
|
||||
public function index(): JsonResponse|JsonResource
|
||||
{
|
||||
$page = $this->basePage()->css($this->css())->body([
|
||||
Grid::make()->columns([
|
||||
$this->frameworkInfo()->md(5),
|
||||
Flex::make()->items([
|
||||
$this->pieChart(),
|
||||
$this->cube(),
|
||||
]),
|
||||
]),
|
||||
// Grid::make()->columns([
|
||||
// $this->frameworkInfo()->md(5),
|
||||
// Flex::make()->items([
|
||||
// $this->pieChart(),
|
||||
// $this->cube(),
|
||||
// ]),
|
||||
// ]),
|
||||
Grid::make()->columns([
|
||||
$this->lineChart()->md(8),
|
||||
Flex::make()->className('h-full')->items([
|
||||
|
|
@ -171,28 +173,43 @@ JS
|
|||
|
||||
public function lineChart(): Card
|
||||
{
|
||||
$randArr = function () {
|
||||
$_arr = [];
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$_arr[] = random_int(10, 200);
|
||||
}
|
||||
return '[' . implode(',', $_arr) . ']';
|
||||
};
|
||||
$days = [];
|
||||
for($i=0; $i<7; $i++){
|
||||
$days[] = now()->subDays($i)->format('Y-m-d');
|
||||
}
|
||||
$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();
|
||||
$random2 = $randArr();
|
||||
$bindUser = User::selectRaw('DATE(`bind_phone_at`) as day, count(id) as num')
|
||||
->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("{
|
||||
backgroundColor:'',
|
||||
title:{ text: '会员增长情况', },
|
||||
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' },
|
||||
grid:{ left: '7%', right:'3%', top: 60, bottom: 30, },
|
||||
legend: { data: ['访问量','注册量'] },
|
||||
series: [
|
||||
{ name: '访问量', data: {$random1}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', },
|
||||
{ name:'注册量', data: {$random2}, type: 'line', areaStyle: {}, smooth: true, symbol: 'none', },
|
||||
{ name: '访问量', data: {$createUser}, 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);
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ class UserController extends AdminController
|
|||
amis()->TableColumn('last_login_at', __('admin.users.last_login_at')),
|
||||
amis()->TableColumn('last_ip', __('admin.users.last_login_ip')),
|
||||
|
||||
Operation::make()->label(__('admin.actions'))->buttons([
|
||||
$this->rowShowTypeButton('drawer', 'xl'),
|
||||
])
|
||||
// Operation::make()->label(__('admin.actions'))->buttons([
|
||||
// $this->rowShowTypeButton('drawer', 'xl'),
|
||||
// ])
|
||||
]);
|
||||
|
||||
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\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\UserGiftService;
|
||||
use App\Admin\Components;
|
||||
use App\Models\UserGift;
|
||||
use App\Models\Activity;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UserGiftController extends AdminController
|
||||
{
|
||||
|
|
@ -22,13 +26,23 @@ class UserGiftController extends AdminController
|
|||
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()),
|
||||
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([
|
||||
amis()->TableColumn('activity.name', __('admin.activities.name')),
|
||||
amis()->TableColumn('gift.name', __('admin.activity_gifts.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([
|
||||
"0"=>"<span class='label label-default'>未领取</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('phone', __('admin.user_gifts.phone')),
|
||||
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);
|
||||
|
|
@ -74,4 +100,14 @@ class UserGiftController extends AdminController
|
|||
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('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']);
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ class ActivityGameController extends ApiController
|
|||
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']){
|
||||
return $this->success(null, '竞猜成功');
|
||||
|
|
|
|||
|
|
@ -71,14 +71,15 @@ class UserController extends ApiController
|
|||
|
||||
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));
|
||||
|
||||
return $this->success(['activities' => UserGiftResource::collection($userGifts)->resolve()]);
|
||||
return $this->success(['gifts' => UserGiftResource::collection($userGifts)->resolve()]);
|
||||
}
|
||||
|
||||
public function userGift(UserGift $userGift, Request $request)
|
||||
{
|
||||
$userGift->load(['gift', 'activity']);
|
||||
return UserGiftResource::make($userGift);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class UserGiftResource extends JsonResource
|
|||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'gift_name'=>$this->whenLoaded('gift', function () {
|
||||
return $this->gift->name;
|
||||
}, ''),
|
||||
|
|
@ -28,8 +29,8 @@ class UserGiftResource extends JsonResource
|
|||
'gift_explain'=> $this->whenLoaded('gift', function () {
|
||||
return $this->gift->explain;
|
||||
}, ''),
|
||||
'activity_name' => $this->whenLoaded('gift.activity', function () {
|
||||
return $this->gift->activity->name;
|
||||
'activity_name' => $this->whenLoaded('activity', function () {
|
||||
return $this->activity->name;
|
||||
}, ''),
|
||||
|
||||
'consignee' => $this->consignee ?? '',
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@ class Activity extends Model
|
|||
{
|
||||
use HasFactory,Filterable;
|
||||
|
||||
protected $fillable = [
|
||||
'state'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'start_at' => 'datetime',
|
||||
'end_at' => 'datetime'
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class AdFilter extends ModelFilter
|
|||
{
|
||||
return $this->where('address', $address);
|
||||
}
|
||||
|
||||
public function publishedAt($publishedAt){
|
||||
$publishedAt = explode(',',$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
|
||||
{
|
||||
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\Model;
|
||||
use EloquentFilter\Filterable;
|
||||
|
||||
class UserGame extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasFactory, Filterable;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
|
|
@ -16,4 +17,19 @@ class UserGame extends Model
|
|||
'score',
|
||||
'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;
|
||||
|
||||
protected $fillable = [
|
||||
'consignee',
|
||||
'address',
|
||||
'phone',
|
||||
'shipping_company',
|
||||
'shipping_number',
|
||||
'state',
|
||||
];
|
||||
|
||||
public function scopeSort($q)
|
||||
{
|
||||
$q->orderBy('created_at', 'desc');
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Services\Admin;
|
||||
|
||||
use DB;
|
||||
use App\Models\Activity;
|
||||
use App\Models\Filters\ActivityFilter;
|
||||
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 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;
|
||||
}
|
||||
|
||||
// public function receiveGift(UserGift $userGift, $params)
|
||||
// {
|
||||
// $userGift->update([
|
||||
// 'consignee' => $params['consignee'],
|
||||
// 'phone' => $params['phone'],
|
||||
// 'address' => $params['address'],
|
||||
// 'state' => 1
|
||||
// ]);
|
||||
// }
|
||||
public function receiveGift(UserGift $userGift, $params)
|
||||
{
|
||||
$userGift->update([
|
||||
'consignee' => $params['consignee'],
|
||||
'phone' => $params['phone'],
|
||||
'address' => $params['address'],
|
||||
'state' => 1
|
||||
]);
|
||||
}
|
||||
|
||||
// protected function saveFile($path, $file = null)
|
||||
// {
|
||||
// if (gettype($file) == 'object') {
|
||||
// //获取文件大小
|
||||
// if($size = $file->getSize() > 2*1024*1024){//大于2M
|
||||
// return false;
|
||||
// }
|
||||
// $type = $file->getClientOriginalExtension();
|
||||
// if (in_array($type, array('jpeg', 'jpg', 'bmp', 'png'))) {
|
||||
// $file = Storage::disk(Admin::config('admin.upload.disk'))->putFile($path, $file);
|
||||
// }else{
|
||||
// return false;
|
||||
// }
|
||||
// } else if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $file, $result)) {
|
||||
// $type = $result[2];
|
||||
// if (in_array($type, array('jpeg', 'jpg', 'bmp', 'png'))) {
|
||||
// $savePath = $path . '/' . uniqid() . '.' . $type;
|
||||
// Storage::disk(Admin::config('admin.upload.disk'))->put($savePath, base64_decode(str_replace($result[1], '', $file)));
|
||||
// $file = $savePath;
|
||||
// }else{
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// return $file;
|
||||
// }
|
||||
protected function saveFile($path, $file = null)
|
||||
{
|
||||
if (gettype($file) == 'object') {
|
||||
//获取文件大小
|
||||
if($size = $file->getSize() > 2*1024*1024){//大于2M
|
||||
return false;
|
||||
}
|
||||
$type = $file->getClientOriginalExtension();
|
||||
if (in_array($type, array('jpeg', 'jpg', 'bmp', 'png'))) {
|
||||
$file = Storage::disk(Admin::config('admin.upload.disk'))->putFile($path, $file);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
} else if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $file, $result)) {
|
||||
$type = $result[2];
|
||||
if (in_array($type, array('jpeg', 'jpg', 'bmp', 'png'))) {
|
||||
$savePath = $path . '/' . uniqid() . '.' . $type;
|
||||
Storage::disk(Admin::config('admin.upload.disk'))->put($savePath, base64_decode(str_replace($result[1], '', $file)));
|
||||
$file = $savePath;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $file;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
return [
|
||||
// 应用名称
|
||||
'name' => 'Owl Admin',
|
||||
'name' => '竞猜小程序',
|
||||
|
||||
// 应用 logo
|
||||
'logo' => '/admin-assets/logo.png',
|
||||
|
|
@ -86,7 +86,7 @@ return [
|
|||
|
||||
'layout' => [
|
||||
// 浏览器标题, 功能名称使用 %title% 代替
|
||||
'title' => '%title% | OwlAdmin',
|
||||
'title' => '%title% | 竞猜小程序',
|
||||
'header' => [
|
||||
// 是否显示 [刷新] 按钮
|
||||
'refresh' => true,
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ class AdminMenuSeeder extends Seeder
|
|||
['title' => 'activity', 'icon' => 'akar-icons:star', 'url' => '/activity', 'order' => 3,
|
||||
'children' => [
|
||||
['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,
|
||||
|
|
|
|||
|
|
@ -362,5 +362,9 @@ return [
|
|||
'shipping_company' => '快递公司',
|
||||
'shipping_number' => '快递号码',
|
||||
'state' => '状态',
|
||||
],
|
||||
'user_games' => [
|
||||
'score' => '竞猜比分',
|
||||
'is_right' => '状态',
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ return [
|
|||
'ads' => '广告管理',
|
||||
'activity' => '活动中心',
|
||||
'activites'=> '足彩竞猜',
|
||||
'user_games' => '竞猜记录',
|
||||
'user_gifts' => '获奖列表',
|
||||
'users' => '会员管理'
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in New Issue