提交代码
This commit is contained in:
97
app/Admin/Actions/AllotCard.php
Normal file
97
app/Admin/Actions/AllotCard.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
namespace App\Admin\Actions;
|
||||
|
||||
use App\Models\Card;
|
||||
use App\Models\CardOrder;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Actions\Action;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AllotCard extends Action
|
||||
{
|
||||
protected $selector = '.report-posts';
|
||||
|
||||
public function handle(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'startNum' => 'required|integer|min:1|lte:endNum',
|
||||
'endNum' => 'required|integer|min:1',
|
||||
], [
|
||||
'startNum.required' => '开始号码必须填写',
|
||||
'startNum.integer' => '开始号码必须是整数',
|
||||
'startNum.min' => '开始号码最小为1',
|
||||
'startNum.lte' => '开始号码要小于结束号码',
|
||||
'endNum.required' => '结束号码必须填写',
|
||||
'endNum.integer' => '结束号码必须是整数',
|
||||
'endNum.min' => '结束号码最小为1',
|
||||
]);
|
||||
$response = $this->response();
|
||||
$startNum = $request->startNum ?: 0;
|
||||
$endNum = $request->endNum ?: 0;
|
||||
$order_id = $request->order_id ?: 0;
|
||||
$company = $request->company;
|
||||
$number = $request->number;
|
||||
|
||||
$order = CardOrder::where('status', 1)->find($order_id);
|
||||
if (!$order) {
|
||||
$response->status = false;
|
||||
return $response->error('订单不存在或状态不正确');
|
||||
}
|
||||
|
||||
$startNum = sprintf("%'.08d", $startNum);
|
||||
$endNum = sprintf("%'.08d", $endNum);
|
||||
|
||||
$count = Card::whereBetween('code', [$startNum, $endNum])->count();
|
||||
|
||||
if ($order->num != $count) {
|
||||
$response->status = false;
|
||||
return $response->error('调拨数量与订单数量不匹配');
|
||||
}
|
||||
$isActive = Card::whereBetween('code', [$startNum, $endNum])->where('status', '!=', 1)->value('code');
|
||||
if ($isActive) {
|
||||
$response->status = false;
|
||||
return $response->error($isActive . '卡号状态不正确');
|
||||
}
|
||||
|
||||
if (!$order->user) {
|
||||
$response->status = false;
|
||||
return $response->error('用户不存在');
|
||||
} elseif ($order->user->identity->identity_id < 2) {
|
||||
$response->status = false;
|
||||
return $response->error($order->user->username . '用户不是代理');
|
||||
}
|
||||
$order->status = 2;
|
||||
$order->save();
|
||||
$order->deliver($company, $number);
|
||||
|
||||
Card::whereBetween('code', [$startNum, $endNum])->update([
|
||||
'user_id' => $order->user_id,
|
||||
'order_id' => $order->id,
|
||||
'status' => 3,
|
||||
]);
|
||||
|
||||
return $response->success('卡分配完毕')->refresh();
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
$orders = CardOrder::where('status', 1)->get();
|
||||
$orderData = array();
|
||||
foreach ($orders as $key => $order) {
|
||||
$orderData[$order->id] = '单号:' . $order->order_id . '(用户账号:' . $order->user->username . ',数量:' . $order->num . ')';
|
||||
}
|
||||
|
||||
$options = deliver_list();
|
||||
|
||||
$this->select('order_id', '订单号')->options($orderData)->rules('required');
|
||||
$this->text('startNum', '开始')->rules('required|integer|min:1');
|
||||
$this->text('endNum', '结束')->rules('required|integer|min:1');
|
||||
$this->select('company', '物流名称')->options($options)->required();
|
||||
$this->text('number', '物流单号')->required();
|
||||
}
|
||||
|
||||
public function html()
|
||||
{
|
||||
return "<a class='report-posts btn btn-sm btn-danger'><i class='fa fa-info-circle'></i>分配卡</a>";
|
||||
}
|
||||
}
|
||||
38
app/Admin/Actions/AreaSetManage.php
Normal file
38
app/Admin/Actions/AreaSetManage.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions;
|
||||
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Encore\Admin\Form;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AreaSetManage extends RowAction
|
||||
{
|
||||
public $name = '设置管理人';
|
||||
|
||||
public function handle(Model $model, Request $request)
|
||||
{
|
||||
$user = User::find($request->user_id);
|
||||
$model->user_id = $user->id;
|
||||
$model->save();
|
||||
return $this->response()->success('操作成功')->refresh();
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
$this->text('user_id', '用户序号')->rules(['required', 'numeric', function ($attribute, $value, $fail) {
|
||||
$user = User::find($value);
|
||||
if (!$user) {
|
||||
return $fail('未找到账号');
|
||||
}
|
||||
if (!in_array($user->identity->identity_id, [4])) {
|
||||
return $fail('账号等级不够');
|
||||
}
|
||||
}], [
|
||||
'required' => '用户序号不能为空',
|
||||
'numeric' => '用户序号必须为整数',
|
||||
], '2');
|
||||
}
|
||||
}
|
||||
40
app/Admin/Actions/CardOrder/OrderDeliver.php
Normal file
40
app/Admin/Actions/CardOrder/OrderDeliver.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions\CardOrder;
|
||||
|
||||
use Config;
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Encore\Admin\Form;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class OrderDeliver extends RowAction
|
||||
{
|
||||
public $name = '提货卡发货';
|
||||
|
||||
public function handle(Model $model, Request $request)
|
||||
{
|
||||
$company = $request->company;
|
||||
$number = $request->number;
|
||||
$model->deliver($company, $number);
|
||||
return $this->response()->success('发货成功')->refresh();
|
||||
}
|
||||
|
||||
public function form(Model $model)
|
||||
{
|
||||
$deliver_list = Config::get('deliver_list');
|
||||
$array = preg_split('/[\r\n]+/', trim($deliver_list, "\r\n"));
|
||||
if (strpos($deliver_list, ':')) {
|
||||
$options = [];
|
||||
foreach ($array as $val) {
|
||||
[$k, $v] = explode(':', $val, 2);
|
||||
$options[$k] = $v;
|
||||
}
|
||||
} else {
|
||||
$options = $array;
|
||||
}
|
||||
$this->select('company','物流名称')->options($options)->required();
|
||||
$this->text('number','物流单号')->required();
|
||||
}
|
||||
|
||||
}
|
||||
42
app/Admin/Actions/Cashout/Audit.php
Normal file
42
app/Admin/Actions/Cashout/Audit.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions\Cashout;
|
||||
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Encore\Admin\Form;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Storage;
|
||||
|
||||
class Audit extends RowAction
|
||||
{
|
||||
public $name = '审核提现';
|
||||
|
||||
public function handle(Model $model, Request $request)
|
||||
{
|
||||
$status = $request->status;
|
||||
if (!$status) {
|
||||
return $this->response()->error('请选择审核状态')->refresh();
|
||||
}
|
||||
|
||||
if ($status == 'pass') {
|
||||
$model->pass();
|
||||
return $this->response()->success('操作成功')->refresh();
|
||||
} else {
|
||||
$reason = $request->get('reason');
|
||||
$model->reject();
|
||||
$model->user->rule('cashoutreject', $model->variable);
|
||||
return $this->response()->success('驳回成功')->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public function form(Model $model)
|
||||
{
|
||||
$this->image('支付宝二维')->value(Storage::disk('admin')->url($model->user->cashAccount->alipay_account_code))->readonly();
|
||||
$this->text('用户账号')->value($model->user->username)->readonly();
|
||||
$this->text('用户名称')->value($model->user->info->nickname)->readonly();
|
||||
$this->text('提现金额')->value($model->variable)->readonly();
|
||||
$this->text('当前状态')->value($model->state_text)->readonly();
|
||||
$this->select('status', '审核')->options(['pass' => '通过', 'reject' => '驳回']);
|
||||
}
|
||||
}
|
||||
33
app/Admin/Actions/MobileImport.php
Normal file
33
app/Admin/Actions/MobileImport.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace App\Admin\Actions;
|
||||
|
||||
use App\Admin\Imports\Mobile;
|
||||
use Encore\Admin\Actions\Action;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class MobileImport extends Action
|
||||
{
|
||||
public $name = '导入手机号';
|
||||
|
||||
protected $selector = '.import-post';
|
||||
public $modelName = '';
|
||||
|
||||
public function handle(Request $request)
|
||||
{
|
||||
$res = Excel::import(new Mobile, $request->file('file'), 'excel');
|
||||
return $this->response()->success('导入完成!')->refresh();
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
$this->file('file', '请选择文件');
|
||||
}
|
||||
|
||||
public function html()
|
||||
{
|
||||
return <<<HTML
|
||||
<a class="btn btn-sm btn-default import-post"><i class="fa fa-upload"></i>导入数据</a>
|
||||
HTML;
|
||||
}
|
||||
}
|
||||
40
app/Admin/Actions/Order/OrderDeliver.php
Normal file
40
app/Admin/Actions/Order/OrderDeliver.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions\Order;
|
||||
|
||||
use Config;
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Encore\Admin\Form;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class OrderDeliver extends RowAction
|
||||
{
|
||||
public $name = '发货';
|
||||
|
||||
public function handle(Model $model, Request $request)
|
||||
{
|
||||
$company = $request->company;
|
||||
$number = $request->number;
|
||||
$res = $model->deliver($company, $number);
|
||||
return $this->response()->success('发货成功')->refresh();
|
||||
}
|
||||
|
||||
public function form(Model $model)
|
||||
{
|
||||
$deliver_list = Config::get('deliver_list');
|
||||
$array = preg_split('/[\r\n]+/', trim($deliver_list, "\r\n"));
|
||||
if (strpos($deliver_list, ':')) {
|
||||
$options = [];
|
||||
foreach ($array as $val) {
|
||||
[$k, $v] = explode(':', $val, 2);
|
||||
$options[$k] = $v;
|
||||
}
|
||||
} else {
|
||||
$options = $array;
|
||||
}
|
||||
$this->select('company','物流名称')->options($options)->required();
|
||||
$this->text('number','物流单号')->required();
|
||||
}
|
||||
|
||||
}
|
||||
74
app/Admin/Actions/OrderRefundAgree.php
Normal file
74
app/Admin/Actions/OrderRefundAgree.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Extensions\Actions;
|
||||
|
||||
use Encore\Admin\Admin;
|
||||
|
||||
class OrderRefundAgree
|
||||
{
|
||||
|
||||
protected $row;
|
||||
protected $resource;
|
||||
|
||||
public function __construct($row)
|
||||
{
|
||||
$this->row = $row;
|
||||
$this->resource = url()->current();
|
||||
}
|
||||
|
||||
protected function script()
|
||||
{
|
||||
return <<<SCRIPT
|
||||
$('.grid-deliver-row').unbind('click').click(function() {
|
||||
var id = $(this).data('id');
|
||||
swal({
|
||||
title: "确认要同意退款吗?",
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#DD6B55",
|
||||
confirmButtonText: "确认",
|
||||
showLoaderOnConfirm: true,
|
||||
cancelButtonText: "取消",
|
||||
preConfirm: function() {
|
||||
return new Promise(function(resolve) {
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '{$this->resource}/' + id + '/agree',
|
||||
data: {
|
||||
_token:LA.token,
|
||||
},
|
||||
success: function (data) {
|
||||
$.pjax.reload('#pjax-container');
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}).then(function(result) {
|
||||
var data = result.value;
|
||||
console.log(data);
|
||||
if (typeof data === 'object') {
|
||||
if (data.status) {
|
||||
swal(data.message, '', 'success');
|
||||
} else {
|
||||
swal(data.message, '', 'error');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
SCRIPT;
|
||||
}
|
||||
|
||||
protected function render()
|
||||
{
|
||||
Admin::script($this->script());
|
||||
|
||||
return "<button type='button' class='btn btn-xs btn-success grid-deliver-row' data-id='{$this->row->orderid}'>确认退款</button>";
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->render();
|
||||
}
|
||||
}
|
||||
30
app/Admin/Actions/ProfitStart.php
Normal file
30
app/Admin/Actions/ProfitStart.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions;
|
||||
|
||||
use Admin;
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Encore\Admin\Form;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ProfitStart extends RowAction
|
||||
{
|
||||
public $name = '执行全球分红';
|
||||
|
||||
public function handle(Model $model, Request $request)
|
||||
{
|
||||
$admin_pass = $request->admin_pass;
|
||||
if (!Admin::guard()->attempt(['username' => Admin::user()->username, 'password' => $admin_pass])) {
|
||||
return $this->response()->error('验证密码失败')->refresh();
|
||||
}
|
||||
\App\Bonus\ProfitStart::settlement($this->row);
|
||||
|
||||
return $this->response()->success('操作成功')->refresh();
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
$this->text('admin_pass', '当前管理员密码')->rules('required');
|
||||
}
|
||||
}
|
||||
38
app/Admin/Actions/SetParent.php
Normal file
38
app/Admin/Actions/SetParent.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions;
|
||||
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Encore\Admin\Form;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SetParent extends RowAction
|
||||
{
|
||||
public $name = '设置推荐人';
|
||||
|
||||
public function handle(Model $model, Request $request)
|
||||
{
|
||||
$parent = User::find($request->parent_id);
|
||||
$this->row->UpdateRelation($parent);
|
||||
|
||||
return $this->response()->success('操作成功')->refresh();
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
$this->text('parent_id', '用户序号')->rules(['required', 'numeric', function ($attribute, $value, $fail) {
|
||||
$parent = User::find($value);
|
||||
if (!$parent) {
|
||||
return $fail('未找到账号');
|
||||
}
|
||||
if (!in_array($parent->identity->identity_id, [2, 3, 4])) {
|
||||
return $fail('账号等级不够');
|
||||
}
|
||||
}], [
|
||||
'required' => '用户序号不能为空',
|
||||
'numeric' => '用户序号必须为整数',
|
||||
], '2');
|
||||
}
|
||||
}
|
||||
69
app/Admin/Actions/UserUpgrade.php
Normal file
69
app/Admin/Actions/UserUpgrade.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions;
|
||||
|
||||
use App\Models\UpgradePayment;
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Encore\Admin\Form;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use RuLong\Identity\Models\Identity;
|
||||
|
||||
class UserUpgrade extends RowAction
|
||||
{
|
||||
public $name = '空升';
|
||||
|
||||
public function handle(Model $model, Request $request)
|
||||
{
|
||||
$identity_id = $request->identity_id;
|
||||
$model->identityUpdate($identity_id, 'EmptyUp');
|
||||
if ($identity_id > 1 && !$model->activationd_at) {
|
||||
$model->activationd_at = now();
|
||||
$model->save();
|
||||
}
|
||||
$amount = $model->getIdentityPrice($identity_id);
|
||||
if ($amount) {
|
||||
$upgrade_payment = UpgradePayment::create([
|
||||
'user_id' => $model->id,
|
||||
'type' => 'agent',
|
||||
'pay_type' => 'ADMIN',
|
||||
'amount' => $amount,
|
||||
'total' => 0,
|
||||
'state' => 'SUCCESS',
|
||||
]);
|
||||
|
||||
if ($identity_id == 1) {
|
||||
\App\Bonus\DirectVip::settlement($upgrade_payment);
|
||||
|
||||
$source = [
|
||||
'user_id' => $upgrade_payment->user->id,
|
||||
'type' => 'UpgradeVip',
|
||||
'payment_id' => $upgrade_payment->id,
|
||||
];
|
||||
\App\Bonus\AddPerf::settlement($upgrade_payment->user, $upgrade_payment->amount, $source);
|
||||
} elseif ($identity_id > 1) {
|
||||
\App\Bonus\DirectAgency::settlement($upgrade_payment);
|
||||
|
||||
$source = [
|
||||
'user_id' => $upgrade_payment->user->id,
|
||||
'type' => 'UpgradeAgency',
|
||||
'payment_id' => $upgrade_payment->id,
|
||||
];
|
||||
\App\Bonus\AddPerf::settlement($upgrade_payment->user, $upgrade_payment->amount, $source);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response()->success('升级成功')->refresh();
|
||||
}
|
||||
|
||||
public function form(Model $model)
|
||||
{
|
||||
$identitys = Identity::where('id', '!=', $model->identity_id)->orderBy('id', 'asc')->pluck('title', 'id')->toArray();
|
||||
$identitys[0] = '普通用户';
|
||||
ksort($identitys);
|
||||
$this->text('用户名称')->value($model->info->nickname);
|
||||
$this->text('当前等级')->value($model->identity_text);
|
||||
$this->select('identity_id', '目标等级')->options($identitys);
|
||||
}
|
||||
|
||||
}
|
||||
64
app/Admin/Controllers/AccountController.php
Normal file
64
app/Admin/Controllers/AccountController.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
use RuLong\Identity\Models\Identity;
|
||||
use RuLong\UserAccount\Models\UserAccount;
|
||||
|
||||
class AccountController extends AdminController
|
||||
{
|
||||
protected $title = '账户管理';
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new UserAccount);
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableRowSelector();
|
||||
$grid->disableActions();
|
||||
$grid->disableColumnSelector();
|
||||
$grid->disableExport();
|
||||
$grid->model()->orderBy('cash', 'desc');
|
||||
|
||||
$grid->column('user_id', '用户序号')->sortable();
|
||||
$grid->column('用户名称')->display(function () {
|
||||
return $this->user->info->nickname;
|
||||
});
|
||||
$grid->column('级别')->display(function () {
|
||||
return $this->user->identity_text;
|
||||
});
|
||||
|
||||
$grid->column('cash', '余额')->display(function ($cash) {
|
||||
return "<span class='label label-warning'>" . number_format($cash, 1) . "</span>";
|
||||
})->sortable();
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(4, function ($filter) {
|
||||
$filter->equal('user_id', '用户序号');
|
||||
});
|
||||
$filter->column(4, function ($filter) {
|
||||
$filter->like('user.username', '用户账号');
|
||||
});
|
||||
|
||||
$filter->column(4, function ($filter) {
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user.info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
}, '用户名称');
|
||||
});
|
||||
|
||||
$filter->column(4, function ($filter) {
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user', function ($query) {
|
||||
$query->whereHas('identity', function ($query) {
|
||||
$query->where('identity_id', $this->input);
|
||||
});
|
||||
});
|
||||
}, '级别')->select(Identity::pluck('title', 'id'));
|
||||
});
|
||||
});
|
||||
return $grid;
|
||||
}
|
||||
}
|
||||
90
app/Admin/Controllers/AccountlogController.php
Normal file
90
app/Admin/Controllers/AccountlogController.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Exporters\AccountLog;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Illuminate\Http\Request;
|
||||
use RuLong\UserAccount\Models\UserAccountLog;
|
||||
|
||||
class AccountlogController extends AdminController
|
||||
{
|
||||
protected $title = '佣金明细管理';
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new UserAccountLog);
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableRowSelector();
|
||||
$grid->disableActions();
|
||||
$grid->disableColumnSelector();
|
||||
|
||||
$grid->model()->orderBy('id', 'desc');
|
||||
|
||||
$grid->column('id', '排序')->sortable();
|
||||
$grid->column('user_id', '用户序号');
|
||||
$grid->column('user.username', '用户账号');
|
||||
$grid->column('userinfo.nickname', '用户名称');
|
||||
$grid->column('rule.title', '佣金名称');
|
||||
$grid->column('variable', '佣金金额')->display(function ($variable) {
|
||||
return number_format($variable, 2);
|
||||
})->label('success');
|
||||
$grid->column('rule.remark', '规则描述');
|
||||
$grid->column('created_at', '产生时间');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(4, function ($filter) {
|
||||
$filter->equal('user.id', '用户序号');
|
||||
});
|
||||
$filter->column(4, function ($filter) {
|
||||
$filter->like('user.username', '用户账号');
|
||||
});
|
||||
$filter->column(4, function ($filter) {
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user.info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
}, '用户名称');
|
||||
});
|
||||
});
|
||||
$grid->exporter(new AccountLog());
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
//某人收益详情
|
||||
public function logs(Content $content, Request $request)
|
||||
{
|
||||
$grid = new Grid(new UserAccountLog);
|
||||
|
||||
$grid->disableCreateButton();
|
||||
$user = User::find($request->user_id);
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableRowSelector();
|
||||
$grid->disableActions();
|
||||
$grid->disableColumnSelector();
|
||||
|
||||
$grid->model()->where('user_id', $request->user_id)->orderBy('id', 'desc');
|
||||
|
||||
$grid->column('id', '排序')->sortable();
|
||||
$grid->column('user_id', '用户序号');
|
||||
$grid->column('user.username', '用户账号');
|
||||
$grid->column('userinfo.nickname', '用户名称');
|
||||
$grid->column('rule.title', '佣金名称');
|
||||
$grid->column('variable', '佣金金额')->display(function ($variable) {
|
||||
return number_format($variable, 2);
|
||||
})->label('success');
|
||||
$grid->column('rule.remark', '规则描述');
|
||||
$grid->column('created_at', '产生时间');
|
||||
|
||||
$grid->exporter(new AccountLog());
|
||||
|
||||
return $content
|
||||
->header($user->info->nickname . '的收益详情')
|
||||
->description('列表')
|
||||
->body($grid);
|
||||
}
|
||||
}
|
||||
104
app/Admin/Controllers/AdvertController.php
Normal file
104
app/Admin/Controllers/AdvertController.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\Advert;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
|
||||
class AdvertController extends AdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('轮播图管理')
|
||||
->description('列表')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function edit($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('轮播图管理')
|
||||
->description('编辑')
|
||||
->body($this->form()->edit($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function create(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('轮播图管理')
|
||||
->description('创建')
|
||||
->body($this->form());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$channel_type = (new Advert)->channel_type;
|
||||
|
||||
$grid = new Grid(new Advert);
|
||||
|
||||
$grid->id('ID');
|
||||
$grid->column('频道')->display(function () {
|
||||
return $this->channel_text;
|
||||
});
|
||||
|
||||
$grid->cover('图片')->image('', 60, 60);
|
||||
$grid->url('地址');
|
||||
$grid->sort('排序');
|
||||
|
||||
$grid->filter(function ($filter) use ($channel_type) {
|
||||
// 去掉默认的id过滤器
|
||||
$filter->disableIdFilter();
|
||||
// 在这里添加字段过滤器
|
||||
$filter->equal('channel', '渠道')->select($channel_type);
|
||||
});
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$channel_type = (new Advert)->channel_type;
|
||||
$form = new Form(new Advert);
|
||||
|
||||
$form->select('channel', '频道')->options($channel_type)->rules('required', ['required' => '必须选择频道']);
|
||||
$form->text('url', '地址')->rules('required');
|
||||
$form->image('cover', '图片')->rules('required')->uniqueName();
|
||||
$form->number('sort', '排序')->default(1);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
85
app/Admin/Controllers/AreaController.php
Normal file
85
app/Admin/Controllers/AreaController.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\AreaSetManage;
|
||||
use App\Admin\Exporters\ProvinceExporter;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use RuLong\Area\Models\Area;
|
||||
|
||||
class AreaController extends AdminController
|
||||
{
|
||||
protected $title = '省市管理';
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Area);
|
||||
$grid->disableCreateButton();
|
||||
// $grid->disableActions();
|
||||
$grid->exporter(new ProvinceExporter());
|
||||
$grid->model()->where('depth', '<', 3);
|
||||
|
||||
$grid->actions(function ($actions) {
|
||||
if ($this->row->type == '地级') {
|
||||
$actions->add(new AreaSetManage);
|
||||
}
|
||||
$actions->disableView();
|
||||
$actions->disableEdit();
|
||||
$actions->disableDelete();
|
||||
});
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->like('name', '省市全称');
|
||||
$filter->equal('hot', '是否热门')->select([
|
||||
' ' => '全部',
|
||||
'1' => '是',
|
||||
'0' => '否',
|
||||
]);
|
||||
});
|
||||
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->equal('type', '等级')->select([
|
||||
' ' => '全部',
|
||||
'省级' => '省级',
|
||||
'地级' => '地级',
|
||||
]);
|
||||
});
|
||||
});
|
||||
$grid->column('sn', '排序')->sortable();
|
||||
$states = [
|
||||
'on' => ['value' => 1, 'text' => '是', 'color' => 'primary'],
|
||||
'off' => ['value' => 0, 'text' => '否', 'color' => 'default'],
|
||||
];
|
||||
$grid->column('name', '省市全称');
|
||||
$grid->column('type', '等级');
|
||||
$grid->column('管理人')->display(function ($title, $column) use ($grid) {
|
||||
if ($this->user) {
|
||||
return $this->user->info->nickname;
|
||||
} else {
|
||||
return '---';
|
||||
}
|
||||
});
|
||||
$grid->column('shortname', '简称');
|
||||
// $grid->column('cnname', '拼音');
|
||||
// $grid->column('enname', '英文');
|
||||
$grid->column('hot', '是否热门')->switch($states);
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$form = new Form(new Area);
|
||||
$form->switch('hot', '是否热门')->default(1);
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
146
app/Admin/Controllers/ArticleController.php
Normal file
146
app/Admin/Controllers/ArticleController.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Models\Category;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Show;
|
||||
|
||||
class ArticleController extends AdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('资讯管理')
|
||||
->description('列表')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function edit($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('资讯管理')
|
||||
->description('编辑')
|
||||
->body($this->form()->edit($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function create(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('资讯管理')
|
||||
->description('创建')
|
||||
->body($this->form());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Article);
|
||||
|
||||
$grid->id('ID');
|
||||
$grid->title('标题');
|
||||
$grid->column('category.title', '所属分类');
|
||||
$grid->description('简介')->display(function ($text) {
|
||||
return str_limit($text, 100, '...');
|
||||
});
|
||||
$grid->cover('标题图')->image('', 60, 60);
|
||||
$grid->status('状态')->switch([
|
||||
'on' => ['value' => 1, 'text' => '正常', 'color' => 'primary'],
|
||||
'off' => ['value' => 0, 'text' => '关闭', 'color' => 'danger'],
|
||||
]);
|
||||
|
||||
$grid->hot('推荐')->switch([
|
||||
'on' => ['value' => 1, 'text' => '是', 'color' => 'primary'],
|
||||
'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
|
||||
]);
|
||||
$grid->order('排序');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
// 去掉默认的id过滤器
|
||||
$filter->disableIdFilter();
|
||||
// 在这里添加字段过滤器
|
||||
$filter->like('title', '标题');
|
||||
$filter->equal('category.id', '所属分类')->select(Category::selectOptions(function ($model) {
|
||||
return $model->where('status', 1)->where('type', 'article');
|
||||
}, '所有分类'));
|
||||
});
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
$show = new Show(Article::findOrFail($id));
|
||||
|
||||
$show->id('ID');
|
||||
$show->title('标题');
|
||||
$show->description('简介');
|
||||
$show->cover('标题图')->image('', 60, 60)->uniqueName();
|
||||
$show->content('详情');
|
||||
$show->status('状态')->using(['1' => '正常', '0' => '关闭']);
|
||||
$show->order('排序');
|
||||
$show->clicks('浏览量');
|
||||
|
||||
return $show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$form = new Form(new Article);
|
||||
|
||||
$form->text('title', '标题')->rules('required');
|
||||
|
||||
$form->select('category_id', '所属分类')->options(Category::selectOptions(function ($model) {
|
||||
return $model->where('status', 1)->where('type', 'article');
|
||||
}, '选择分类'))->rules('required', ['required' => '必须选择分类']);
|
||||
|
||||
$form->textarea('description', '简介')->rules('max:255', ['max' => '简介最多255字']);
|
||||
$form->image('cover', '标题图');
|
||||
$form->editor('content', '详情')->rules('required', ['required' => '详情不能为空']);
|
||||
$form->switch('status', '状态')->default(1);
|
||||
$form->switch('hot', '推荐')->default(0);
|
||||
$form->number('order', '排序')->default(0);
|
||||
$form->number('clicks', '浏览量')->default(0);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
10
app/Admin/Controllers/AuthController.php
Normal file
10
app/Admin/Controllers/AuthController.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Encore\Admin\Controllers\AuthController as BaseAuthController;
|
||||
|
||||
class AuthController extends BaseAuthController
|
||||
{
|
||||
|
||||
}
|
||||
189
app/Admin/Controllers/CardController.php
Normal file
189
app/Admin/Controllers/CardController.php
Normal file
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\AllotCard;
|
||||
use App\Admin\Exporters\CardExporters;
|
||||
use App\Models\Card;
|
||||
use App\Models\Goods;
|
||||
use App\Models\GoodsParams;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Widgets\Box;
|
||||
use Encore\Admin\Widgets\Form;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CardController extends AdminController
|
||||
{
|
||||
protected $title = '卡管理';
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Card);
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableRowSelector();
|
||||
$grid->disableActions();
|
||||
$grid->disableColumnSelector();
|
||||
$grid->tools(function (Grid\Tools $tools) {
|
||||
$tools->append(new AllotCard());
|
||||
});
|
||||
|
||||
$grid->header(function ($query) {
|
||||
$form = new Form();
|
||||
$form->action('card/createCard');
|
||||
$form->hidden('_token')->default(csrf_token());
|
||||
$form->disableReset();
|
||||
$form->text('num', '生成数量')->rules('required|integer|min:1');
|
||||
$form->select('type', '类型')->options([
|
||||
'L' => '联【L】',
|
||||
'K' => '卡【K】',
|
||||
'F' => '蝠【F】',
|
||||
])->load('goods', 'card/getGoods')->rules('required');
|
||||
$form->select('goods', '专属商品')->load('param', 'card/getParam');
|
||||
$form->select('param', '专属规格');
|
||||
|
||||
$box = new Box();
|
||||
$box = new Box('生成卡', $form->render());
|
||||
$box->collapsable();
|
||||
$box->style('success');
|
||||
$box->solid();
|
||||
return $box->render();
|
||||
});
|
||||
|
||||
$grid->model()->orderBy('id', 'desc');
|
||||
|
||||
$grid->column('id', '卡序号')->sortable();
|
||||
$grid->column('归属')->display(function () {
|
||||
return ($this->user->username ?? '---') . "<br>" . ($this->user->info->nickname ?? '---');
|
||||
});
|
||||
$grid->column('code', '卡号')->sortable();
|
||||
$grid->column('打印卡号')->display(function () {
|
||||
return $this->type . $this->code;
|
||||
});
|
||||
$grid->column('pass', '卡密');
|
||||
$grid->column('type', '类型')->using([
|
||||
'L' => '联【L】',
|
||||
'K' => '卡【K】',
|
||||
'F' => '蝠【F】',
|
||||
]);
|
||||
$grid->column('专项')->display(function () {
|
||||
if ($this->type == 'K') {
|
||||
return '商品ID:' . $this->source['goods'] . ';规格ID:' . $this->source['param'];
|
||||
} else {
|
||||
return '非专项';
|
||||
}
|
||||
});
|
||||
|
||||
$grid->column('status', '状态')->display(function () {
|
||||
return $this->status_text;
|
||||
})->label([
|
||||
0 => 'warning',
|
||||
1 => 'success',
|
||||
2 => 'success',
|
||||
3 => 'success',
|
||||
4 => 'success',
|
||||
5 => 'info',
|
||||
]);
|
||||
$grid->column('激活用户')->display(function () {
|
||||
return $this->activeUser->username ?? '无';
|
||||
});
|
||||
$grid->column('actived_at', '激活时间');
|
||||
$grid->column('created_at', '创建时间');
|
||||
$grid->column('updated_at', '更改时间');
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->disableIdFilter();
|
||||
$filter->column(4, function ($filter) {
|
||||
$filter->equal('code', '卡号');
|
||||
});
|
||||
$filter->column(4, function ($filter) {
|
||||
$filter->equal('type', '类型')->select([
|
||||
'L' => '联【L】',
|
||||
'K' => '卡【K】',
|
||||
'F' => '蝠【F】',
|
||||
]);
|
||||
});
|
||||
|
||||
$filter->column(4, function ($filter) {
|
||||
|
||||
});
|
||||
|
||||
$filter->column(4, function ($filter) {
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
$grid->disableExport(false);
|
||||
$grid->exporter(new CardExporters());
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
public function createCard(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'num' => 'required|integer|min:1',
|
||||
'type' => 'required',
|
||||
], [
|
||||
'num.required' => '数量必须填写',
|
||||
'num.integer' => '数量必须是整数',
|
||||
'num.min' => '数量最小为1',
|
||||
'type.required' => '类型必须填写',
|
||||
]);
|
||||
|
||||
$num = $request->num;
|
||||
$type = $request->type;
|
||||
$source = [
|
||||
'goods' => $request->goods ?: 0,
|
||||
'param' => $request->param ?: 0,
|
||||
];
|
||||
$data = [];
|
||||
$codeStart = (Card::max('id') ?? 0) + 1;
|
||||
$source = json_encode($source);
|
||||
while ($num > 0) {
|
||||
$data[] = [
|
||||
'code' => sprintf("%'.08d", $codeStart++),
|
||||
'pass' => sprintf("%'.04d", mt_rand(0, 9999)) . '-' . sprintf("%'.04d", mt_rand(0, 9999)) . '-' . sprintf("%'.04d", mt_rand(0, 9999)) . '-' . sprintf("%'.04d", mt_rand(0, 9999)),
|
||||
'type' => $type,
|
||||
'status' => 1,
|
||||
'source' => $source,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
--$num;
|
||||
}
|
||||
Card::insert($data);
|
||||
admin_success('成功生成', $request->num . '个码已经生成。');
|
||||
return back();
|
||||
}
|
||||
|
||||
public function getGoods()
|
||||
{
|
||||
$type = request('q');
|
||||
$data = [];
|
||||
if ($type == 'K') {
|
||||
$plucks = Goods::where('status', 1)->get(['id', 'title as text']);
|
||||
return $plucks;
|
||||
} else {
|
||||
$data[] = [
|
||||
'id' => 0,
|
||||
'text' => '非专属卡',
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getParam()
|
||||
{
|
||||
$goods_id = request('q');
|
||||
if ($goods_id) {
|
||||
$plucks = GoodsParams::where('goods_id', $goods_id)->where('status', 1)->get(['id', 'value as text']);
|
||||
return $plucks;
|
||||
} else {
|
||||
$data[] = [
|
||||
'id' => 0,
|
||||
'text' => '非专属卡',
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
111
app/Admin/Controllers/CardOrderController.php
Normal file
111
app/Admin/Controllers/CardOrderController.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\CardOrder;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
|
||||
class CardOrderController extends AdminController
|
||||
{
|
||||
protected $title = '购卡管理';
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new CardOrder);
|
||||
$grid->disableRowSelector();
|
||||
$grid->disableColumnSelector();
|
||||
$grid->disableExport();
|
||||
$grid->disableActions();
|
||||
$grid->model()->orderBy('created_at', 'desc');
|
||||
|
||||
$grid->column('order_id', '订单号');
|
||||
$grid->column('user_id', '用户编号');
|
||||
$grid->column('用户账号')->display(function () {
|
||||
return $this->user->username;
|
||||
});
|
||||
$grid->column('用户名称')->display(function () {
|
||||
return $this->user->info->nickname;
|
||||
});
|
||||
$grid->column('num', '购卡数量');
|
||||
$grid->column('price', '购卡金额');
|
||||
|
||||
$grid->column('status', '状态')->display(function () {
|
||||
return $this->status_text;
|
||||
})->label([
|
||||
0 => 'warning',
|
||||
1 => 'success',
|
||||
2 => 'success',
|
||||
3 => 'success',
|
||||
4 => 'info',
|
||||
]);
|
||||
|
||||
$grid->column('收货地址')->display(function () {
|
||||
if ($this->express) {
|
||||
$res = $this->express->name . "<br>";
|
||||
$res .= $this->express->mobile . "<br>";
|
||||
$res .= $this->express->address . "<br>";
|
||||
return $res;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
});
|
||||
|
||||
$grid->column('物流')->display(function () {
|
||||
if ($this->express) {
|
||||
$res = get_deliver_name($this->express->company) . "<br>";
|
||||
$res .= $this->express->number . "<br>";
|
||||
return $res;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
});
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->disableIdFilter();
|
||||
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->like('order_id', '订单编号');
|
||||
$filter->equal('status', '订单状态')->select([
|
||||
0 => '待支付',
|
||||
1 => '已支付',
|
||||
2 => '已发货',
|
||||
3 => '已收货',
|
||||
]);
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user', function ($query) {
|
||||
$query->whereHas('info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
});
|
||||
}, '下单用户');
|
||||
$filter->equal('type', '订单类型')->select(['L' => '拉', 'K' => '卡', 'F' => '蝠']);
|
||||
|
||||
});
|
||||
// $filter->column(1 / 3, function ($filter) {
|
||||
// $filter->between('created_at', '下单时间')->datetime();
|
||||
// });
|
||||
});
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$form = new Form(new CardOrder);
|
||||
|
||||
$form->text('user_id', '购卡用户ID')->rules('required');
|
||||
$form->number('num', '购卡数量')->rules('required');
|
||||
$form->currency('price', '购卡金额')->symbol('¥')->rules('required');
|
||||
$form->textarea('remark', '备注')->rules('max:255', ['max' => '简介最多255字']);
|
||||
$form->hidden('status')->default(1);
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
226
app/Admin/Controllers/CashOutController.php
Normal file
226
app/Admin/Controllers/CashOutController.php
Normal file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\Cashout\Audit;
|
||||
use App\Admin\Exporters\CashOutExport;
|
||||
use App\Models\Cashout;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Grid\Displayers\Modal;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Illuminate\Http\Request;
|
||||
use Storage;
|
||||
|
||||
class CashOutController extends AdminController
|
||||
{
|
||||
protected $title = '用户提现管理';
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Cashout);
|
||||
$grid->disableCreateButton();
|
||||
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableDelete();
|
||||
$actions->disableEdit();
|
||||
$actions->disableView();
|
||||
if ($actions->row->state == "INIT") {
|
||||
$actions->add(new Audit);
|
||||
}
|
||||
});
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user', function ($query) {
|
||||
$query->where('id', $this->input);
|
||||
});
|
||||
}, '用户序号');
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user.identity', function ($query) {
|
||||
$query->where('identity_id', $this->input);
|
||||
});
|
||||
}, '级别')->select([
|
||||
' ' => '全部',
|
||||
'5' => '一级',
|
||||
'4' => '二级',
|
||||
'3' => '三级',
|
||||
'1' => '员工',
|
||||
'2' => '商户',
|
||||
]);
|
||||
});
|
||||
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user', function ($query) {
|
||||
$query->where('username', $this->input);
|
||||
});
|
||||
}, '手机号');
|
||||
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user.info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
}, '用户名称');
|
||||
});
|
||||
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->equal('state', '状态')->select([
|
||||
' ' => '全部',
|
||||
'INIT' => '审核中',
|
||||
'PASS' => '通过',
|
||||
'REJECT' => '驳回',
|
||||
]);
|
||||
$filter->equal('created_at', '提交时间')->date();
|
||||
});
|
||||
});
|
||||
|
||||
$grid->model()->orderBy('id', 'desc');
|
||||
|
||||
$grid->column('id', '排序')->sortable();
|
||||
$grid->column('用户序号')->display(function () {
|
||||
return $this->user->id;
|
||||
});
|
||||
$grid->column('手机号')->display(function () {
|
||||
return $this->user->username;
|
||||
});
|
||||
|
||||
$grid->column('用户名称')->display(function () {
|
||||
return $this->user->info->nickname;
|
||||
});
|
||||
$grid->column('级别')->display(function () {
|
||||
return $this->user->identity_text;
|
||||
});
|
||||
$grid->column('支付宝账户')->display(function () {
|
||||
if ($this->cash_account_no) {
|
||||
return $this->cash_account_no;
|
||||
} else {
|
||||
return $this->user->cashAccount->alipay_account;
|
||||
}
|
||||
});
|
||||
$grid->column('支付宝商户二维码')->display(function ($title, $column) use ($grid) {
|
||||
if ($this->user->cashAccount->alipay_account_code) {
|
||||
$modal = new Modal('点击查看', $grid, $column, $this);
|
||||
$str = $modal->display('支付宝商户二维码', function ($modal) {
|
||||
return '<div style="width:100%;text-align:center;"><img style="max-height:50vh;margin:auto;" src="' . Storage::disk('admin')->url($modal->user->cashAccount->alipay_account_code) . '"></div>';
|
||||
});
|
||||
return $str;
|
||||
} else {
|
||||
return '无';
|
||||
}
|
||||
});
|
||||
|
||||
$grid->column('variable', '提现金额');
|
||||
$grid->column('审核状态')->display(function ($state) {
|
||||
switch ($this->state) {
|
||||
case 'INIT':
|
||||
return "<span style='color:red'>审核中</span>";
|
||||
break;
|
||||
case 'PASS':
|
||||
return "<span style='color:blue'>通过</span>";
|
||||
break;
|
||||
case 'REJECT':
|
||||
return "<span style='color:grey'>驳回</span>";
|
||||
break;
|
||||
}
|
||||
});
|
||||
$grid->column('created_at', '创建时间');
|
||||
$grid->column('updated_at', '修改时间');
|
||||
|
||||
$grid->footer(function ($query) {
|
||||
$all = number_format(Cashout::sum('variable'), 2) ?? 0;
|
||||
$init = number_format(Cashout::where('state', 'INIT')->sum('variable'), 2) ?? 0;
|
||||
$pass = number_format(Cashout::where('state', 'PASS')->sum('variable'), 2) ?? 0;
|
||||
$reject = number_format(Cashout::where('state', 'REJECT')->sum('variable'), 2) ?? 0;
|
||||
return '<label class="label label-success">总提现额:' . $all . '</label> <label class="label label-success">审核中:' . $init . '</label> <label class="label label-success">通过:' . $pass . '</label> <label class="label label-success">驳回:' . $reject . '</label>';
|
||||
});
|
||||
|
||||
$grid->exporter(new CashOutExport());
|
||||
return $grid;
|
||||
}
|
||||
|
||||
//某人收益详情
|
||||
public function logs(Content $content, Request $request)
|
||||
{
|
||||
$grid = new Grid(new Cashout);
|
||||
$user = User::find($request->user_id);
|
||||
|
||||
$grid->disableCreateButton();
|
||||
|
||||
$grid->disableActions();
|
||||
$grid->filter(function ($filter) {
|
||||
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->equal('state', '状态')->select([
|
||||
' ' => '全部',
|
||||
'INIT' => '审核中',
|
||||
'PASS' => '通过',
|
||||
'REJECT' => '驳回',
|
||||
]);
|
||||
$filter->equal('created_at', '提交时间')->date();
|
||||
});
|
||||
});
|
||||
|
||||
$grid->model()->where('user_id', $user->id)->orderBy('id', 'desc');
|
||||
|
||||
$grid->column('id', '排序')->sortable();
|
||||
$grid->column('用户序号')->display(function () {
|
||||
return $this->user->id;
|
||||
});
|
||||
$grid->column('用户账号')->display(function () {
|
||||
return $this->user->username;
|
||||
});
|
||||
|
||||
$grid->column('用户名称')->display(function () {
|
||||
return $this->user->info->nickname;
|
||||
});
|
||||
$grid->column('级别')->display(function () {
|
||||
return $this->user->identity_text;
|
||||
});
|
||||
$grid->column('支付宝账户')->display(function () {
|
||||
if ($this->cash_account_no) {
|
||||
return $this->cash_account_no;
|
||||
} else {
|
||||
return $this->user->cashAccount->alipay_account;
|
||||
}
|
||||
});
|
||||
$grid->column('支付宝商户二维码')->display(function ($title, $column) use ($grid) {
|
||||
if ($this->user->cashAccount->alipay_account_code) {
|
||||
$modal = new Modal('点击查看', $grid, $column, $this);
|
||||
$str = $modal->display('支付宝商户二维码', function ($modal) {
|
||||
return '<div style="width:100%;text-align:center;"><img style="max-height:50vh;margin:auto;" src="' . Storage::disk('admin')->url($modal->user->cashAccount->alipay_account_code) . '"></div>';
|
||||
});
|
||||
return $str;
|
||||
} else {
|
||||
return '无';
|
||||
}
|
||||
});
|
||||
|
||||
$grid->column('variable', '提现金额');
|
||||
$grid->column('审核状态')->display(function ($state) {
|
||||
switch ($this->state) {
|
||||
case 'INIT':
|
||||
return "<span style='color:red'>审核中</span>";
|
||||
break;
|
||||
case 'PASS':
|
||||
return "<span style='color:blue'>通过</span>";
|
||||
break;
|
||||
case 'REJECT':
|
||||
return "<span style='color:grey'>驳回</span>";
|
||||
break;
|
||||
}
|
||||
});
|
||||
$grid->column('created_at', '创建时间');
|
||||
$grid->column('updated_at', '修改时间');
|
||||
$grid->exporter(new CashOutExport());
|
||||
|
||||
return $content
|
||||
->header($user->info->nickname . '的提现详情')
|
||||
->description('列表')
|
||||
->body($grid);
|
||||
}
|
||||
|
||||
}
|
||||
180
app/Admin/Controllers/CategoryController.php
Normal file
180
app/Admin/Controllers/CategoryController.php
Normal file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\Category;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Column;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Layout\Row;
|
||||
use Encore\Admin\Show;
|
||||
use Encore\Admin\Tree;
|
||||
use Encore\Admin\Widgets\Box;
|
||||
use Encore\Admin\Widgets\Form as WidgetsForm;
|
||||
|
||||
class CategoryController extends AdminController
|
||||
{
|
||||
use HasResourceActions;
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('分类')
|
||||
->row(function (Row $row) {
|
||||
$row->column(6, $this->treeView());
|
||||
|
||||
$row->column(6, function (Column $column) {
|
||||
$form = new WidgetsForm();
|
||||
|
||||
$form->select('parent_id', '上级分类')->options(Category::selectOptions(function ($model) {
|
||||
return $model->where('status', 1);
|
||||
}, '一级分类'));
|
||||
$form->select('type', '分类类型')->options(['goods' => '商品', 'article' => '文章']);
|
||||
$form->text('title', '分类名称')->rules('required');
|
||||
$form->textarea('description', '分类简介')->rows(4)->rules('nullable');
|
||||
$form->image('cover', 'Logo');
|
||||
$form->number('order', '排序')->default(0);
|
||||
$form->switch('status', '显示')->states()->default(1);
|
||||
|
||||
$form->action('/admin/categories');
|
||||
|
||||
$column->append((new Box('新增分类', $form))->style('success'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Encore\Admin\Tree
|
||||
*/
|
||||
protected function treeView()
|
||||
{
|
||||
return Category::tree(function (Tree $tree) {
|
||||
$tree->disableCreate();
|
||||
|
||||
$tree->branch(function ($branch) {
|
||||
if ($branch['status'] == 1) {
|
||||
$payload = "<i class='fa fa-eye text-primary'></i> ";
|
||||
} else {
|
||||
$payload = "<i class='fa fa-eye text-gray'></i> ";
|
||||
}
|
||||
$payload .= " [ID:{$branch['id']}] - ";
|
||||
$payload .= " <strong>{$branch['title']}</strong> ";
|
||||
$payload .= " <small style='color:#999'>{$branch['description']}</small>";
|
||||
|
||||
return $payload;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function show($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('Detail')
|
||||
->description('description')
|
||||
->body($this->detail($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function edit($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('Edit')
|
||||
->description('description')
|
||||
->body($this->form()->edit($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function create(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('Create')
|
||||
->description('description')
|
||||
->body($this->form());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Category);
|
||||
|
||||
$grid->id('Id');
|
||||
$grid->title('分类名称');
|
||||
$grid->description('分类简介');
|
||||
$grid->order('排序');
|
||||
$grid->status('显示')->switch();
|
||||
$grid->created_at('创建时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
$show = new Show(Category::findOrFail($id));
|
||||
|
||||
$show->id('Id');
|
||||
$show->created_at('Created at');
|
||||
$show->updated_at('Updated at');
|
||||
|
||||
return $show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$form = new Form(new Category);
|
||||
|
||||
$form->select('parent_id', '上级分类')->options(Category::selectOptions(function ($model) {
|
||||
return $model->where('status', 1);
|
||||
}, '一级分类'));
|
||||
$form->select('type', '分类类型')->options(['goods' => '商品', 'article' => '文章'])->rules('required');
|
||||
$form->text('title', '分类名称')->rules('required');
|
||||
$form->textarea('description', '分类简介')->rows(4)->rules('nullable');
|
||||
$form->image('cover', 'Logo');
|
||||
$form->number('order', '排序')->default(0);
|
||||
$form->switch('status', '显示')->states()->default(1);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
14
app/Admin/Controllers/Controller.php
Normal file
14
app/Admin/Controllers/Controller.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use HasResourceActions, AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
235
app/Admin/Controllers/GoodsController.php
Normal file
235
app/Admin/Controllers/GoodsController.php
Normal file
@@ -0,0 +1,235 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\Goods;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Show;
|
||||
use Illuminate\Support\MessageBag;
|
||||
|
||||
class GoodsController extends AdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
|
||||
return $content
|
||||
->header('商品管理')
|
||||
->description('description')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function edit($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('编辑商品')
|
||||
->body($this->form()->edit($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function create(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('新增商品')
|
||||
->body($this->form());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Goods);
|
||||
|
||||
$grid->model()->orderBy('id', 'desc');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->like('title', '商品名称');
|
||||
$filter->like('category.id', '所属分类')->select(Category::selectOptions(function ($model) {
|
||||
return $model->where('status', 1)->where('type', 'goods');
|
||||
}, '所有分类'));
|
||||
});
|
||||
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->equal('status', '商品状态')->select([
|
||||
1 => '正常',
|
||||
0 => '禁用',
|
||||
]);
|
||||
$filter->equal('type', '商品类型')->select([
|
||||
'member' => '会员商品',
|
||||
'pick' => '提货商品',
|
||||
]);
|
||||
|
||||
});
|
||||
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->equal('is_hot_sell', '热销推荐')->select([
|
||||
1 => '是',
|
||||
0 => '否',
|
||||
]);
|
||||
$filter->equal('is_recommend', '最新推荐')->select([
|
||||
1 => '是',
|
||||
0 => '否',
|
||||
]);
|
||||
});
|
||||
|
||||
$filter->disableIdFilter();
|
||||
|
||||
});
|
||||
|
||||
$grid->id('序号');
|
||||
$grid->cover('封面')->image('', 60, 60);
|
||||
$grid->title('商品名称');
|
||||
$grid->column('所属分类')->display(function () {
|
||||
return $this->category->title;
|
||||
});
|
||||
$grid->description('简介');
|
||||
$grid->column('类型')->display(function () {
|
||||
return $this->type_text;
|
||||
});
|
||||
$grid->status('状态')->switch([
|
||||
'on' => ['value' => 1, 'text' => '正常', 'color' => 'primary'],
|
||||
'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
|
||||
]);
|
||||
$grid->is_hot_sell('热销推荐')->switch([
|
||||
'on' => ['value' => 1, 'text' => '是', 'color' => 'primary'],
|
||||
'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
|
||||
]);
|
||||
|
||||
$grid->is_recommend('最新推荐')->switch([
|
||||
'on' => ['value' => 1, 'text' => '是', 'color' => 'primary'],
|
||||
'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
|
||||
]);
|
||||
|
||||
$grid->created_at('创建时间');
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
if ($this->row->type == 'pick') {
|
||||
$actions->disableDelete();
|
||||
}
|
||||
$actions->disableView();
|
||||
});
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
$show = new Show(Goods::findOrFail($id));
|
||||
|
||||
$show->id('编号');
|
||||
$show->name('商品名称');
|
||||
$show->created_at('创建时间');
|
||||
|
||||
return $show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$form = new Form(new Goods);
|
||||
|
||||
$form->text('title', '商品名称')->rules('required');
|
||||
$form->select('category_id', '所属分类')->options(Category::selectOptions(function ($model) {
|
||||
return $model->where('status', 1)->where('type', 'goods');
|
||||
}, '选择分类'))->rules('required');
|
||||
|
||||
$form->textarea('description', '简介')->rules('required|max:255', [
|
||||
'required' => '简介不能为空',
|
||||
'max' => '简介不能超过255字',
|
||||
]);
|
||||
|
||||
$form->image('cover', '封面')->rules('required')->uniqueName();
|
||||
$form->radio('type', '类型')->options(['member' => '会员产品', 'pick' => '提货商品'])->default('member');
|
||||
$form->editor('content', '详情')->rules('required', ['required' => '详情不能为空']);
|
||||
$form->switch('status', '状态')->default(1);
|
||||
$form->switch('is_recommend', '最新推荐')->default(0);
|
||||
$form->switch('is_hot_sell', '热销推荐')->default(0);
|
||||
|
||||
$form->hasMany('params', '产品属性', function (Form\NestedForm $form) {
|
||||
$form->text('value', '名称')->rules('required');
|
||||
$form->text('original', '原价')->rules('required');
|
||||
$form->text('price', '会员价')->rules('required');
|
||||
$form->text('stock', '库存')->rules('required');
|
||||
$form->text('one', '一级佣金')->rules('required');
|
||||
$form->text('two', '二及佣金')->rules('required');
|
||||
})->rules('required');
|
||||
|
||||
$form->saving(function (Form $form) {
|
||||
if (request()->has('title')) {
|
||||
$params = request()->params;
|
||||
$params_count = empty($params) ? 0 : count($params);
|
||||
if (!$params_count) {
|
||||
$error = new MessageBag([
|
||||
'title' => '错误',
|
||||
'message' => '必须添加产品属性',
|
||||
]);
|
||||
return back()->with(compact('error'));
|
||||
}
|
||||
$remove = 0;
|
||||
|
||||
foreach ($params as $key => $param) {
|
||||
if ($param['_remove_'] == 1) {
|
||||
$remove++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($remove == $params_count) {
|
||||
$error = new MessageBag([
|
||||
'title' => '错误',
|
||||
'message' => '必须添加产品属性',
|
||||
]);
|
||||
return back()->with(compact('error'));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$form->saved(function (Form $form) {
|
||||
$goods_id = $form->model()->id;
|
||||
$goods = Goods::find($goods_id);
|
||||
$price = $goods->params()->orderBy('price', 'asc')->value('price');
|
||||
if ($price) {
|
||||
$goods->price = $price;
|
||||
$goods->save();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
71
app/Admin/Controllers/HomeController.php
Normal file
71
app/Admin/Controllers/HomeController.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Layout\Column;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Layout\Row;
|
||||
use Encore\Admin\Widgets\InfoBox;
|
||||
use RuLong\Order\Models\Order;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->title('控制台')
|
||||
->description('数据中心')
|
||||
->row(function (Row $row) {
|
||||
$row->column(2, function (Column $column) {
|
||||
$column->append(new InfoBox('总用户数', 'user', 'yellow', '/admin/users', User::count()));
|
||||
});
|
||||
$row->column(2, function (Column $column) {
|
||||
$column->append(new InfoBox('会员', 'users', 'yellow', '/admin/users?identity[identity_id]=1', User::whereHas('identity', function ($q) {$q->where('identity_id', 1);})->count()));
|
||||
});
|
||||
|
||||
$row->column(2, function (Column $column) {
|
||||
$column->append(new InfoBox('金牌', 'users', 'yellow', '/admin/users?identity[identity_id]=2', User::whereHas('identity', function ($q) {$q->where('identity_id', 2);})->count()));
|
||||
});
|
||||
$row->column(2, function (Column $column) {
|
||||
$column->append(new InfoBox('城市', 'users', 'yellow', '/admin/users?identity[identity_id]=3', User::whereHas('identity', function ($q) {$q->where('identity_id', 3);})->count()));
|
||||
});
|
||||
$row->column(2, function (Column $column) {
|
||||
$column->append(new InfoBox('股东', 'users', 'yellow', '/admin/users?identity[identity_id]=4', User::whereHas('identity', function ($q) {$q->where('identity_id', 4);})->count()));
|
||||
});
|
||||
})
|
||||
->row(function (Row $row) {
|
||||
$row->column(3, function (Column $column) {
|
||||
$column->append(new InfoBox('总订单数', 'print', 'orange', 'admin/orders', Order::count()));
|
||||
});
|
||||
$row->column(3, function (Column $column) {
|
||||
$column->append(new InfoBox('已支付', 'dollar', 'orange', 'admin/orders?state=PAID', Order::UnDeliver()->count()));
|
||||
});
|
||||
$row->column(3, function (Column $column) {
|
||||
$column->append(new InfoBox('已发货', 'dollar', 'orange', 'admin/orders?state=DELIVERED', Order::Delivered()->count()));
|
||||
});
|
||||
$row->column(3, function (Column $column) {
|
||||
$column->append(new InfoBox('已签收', 'dollar', 'orange', 'admin/orders?state=SIGNED', Order::Signed()->count()));
|
||||
});
|
||||
});
|
||||
// return $content
|
||||
// ->title('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::extensions());
|
||||
// });
|
||||
|
||||
// $row->column(4, function (Column $column) {
|
||||
// $column->append(Dashboard::dependencies());
|
||||
// });
|
||||
// });
|
||||
}
|
||||
}
|
||||
111
app/Admin/Controllers/IdentityController.php
Normal file
111
app/Admin/Controllers/IdentityController.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use RuLong\Identity\Models\Identity;
|
||||
|
||||
class IdentityController extends AdminController
|
||||
{
|
||||
protected $title = '用户身份配置';
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Identity);
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableFilter();
|
||||
$grid->disableExport();
|
||||
$grid->disableRowSelector();
|
||||
$grid->tools(function ($tools) {
|
||||
$tools->batch(function ($batch) {
|
||||
$batch->disableDelete();
|
||||
});
|
||||
});
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableDelete();
|
||||
$actions->disableView();
|
||||
});
|
||||
$grid->fixColumns(0, 0);
|
||||
|
||||
$grid->model()->orderBy('id', 'asc');
|
||||
$grid->column('id', '身份编号')->sortable();
|
||||
$grid->column('title', '级别');
|
||||
$grid->column('name', '等级');
|
||||
$grid->column('直推会员(奇)')->display(function () {
|
||||
return ($this->configs['direct_odd'] ?? 0) . '%';
|
||||
});
|
||||
$grid->column('直推会员(偶)')->display(function () {
|
||||
return ($this->configs['direct_even'] ?? 0) . '%';
|
||||
});
|
||||
$grid->column('一级卡酬')->display(function () {
|
||||
return '¥ ' . ($this->configs['direct_card'] ?? 0) . ' 元';
|
||||
});
|
||||
$grid->column('二级卡酬')->display(function () {
|
||||
return '¥ ' . ($this->configs['indirect_card'] ?? 0) . ' 元';
|
||||
});
|
||||
$grid->column('团队卡酬')->display(function () {
|
||||
return '¥ ' . ($this->configs['team_card'] ?? 0) . ' 元';
|
||||
});
|
||||
$grid->column('直推代理')->display(function () {
|
||||
return ($this->configs['direct_agency'] ?? 0) . '%';
|
||||
});
|
||||
$grid->column('间推代理')->display(function () {
|
||||
return ($this->configs['indirect_agency'] ?? 0) . '%';
|
||||
});
|
||||
$grid->column('100万业绩奖')->display(function () {
|
||||
return ($this->configs['perf_100'] ?? 0) . '%';
|
||||
});
|
||||
$grid->column('500万业绩奖')->display(function () {
|
||||
return ($this->configs['perf_500'] ?? 0) . '%';
|
||||
});
|
||||
$grid->column('1000万业绩奖')->display(function () {
|
||||
return ($this->configs['perf_1000'] ?? 0) . '%';
|
||||
});
|
||||
$grid->column('城市分红')->display(function () {
|
||||
return ($this->configs['orderPerf'] ?? 0) . '%';
|
||||
});
|
||||
|
||||
$grid->column('remark', '说明');
|
||||
$grid->column('updated_at', '修改时间');
|
||||
return $grid;
|
||||
}
|
||||
|
||||
protected function form()
|
||||
{
|
||||
$form = new Form(new Identity);
|
||||
$form->display('id', 'ID');
|
||||
$form->text('title', '级别')->rules('required');
|
||||
$form->text('name', '等级')->rules('required');
|
||||
$form->embeds('configs', '佣金设定', function ($form) {
|
||||
$form->rate('direct_odd', '直推会员(奇)')->value($this->configs['direct_odd'] ?? 0)->required()->setWidth(1, 3)->default(0);
|
||||
$form->rate('direct_even', '直推会员(偶)')->value($this->configs['direct_even'] ?? 0)->required()->setWidth(1, 3)->default(0);
|
||||
$form->currency('direct_card', '一级卡酬')->symbol('¥')->value($this->configs['direct_card'] ?? 0)->required()->setWidth(1, 3)->default(0);
|
||||
$form->currency('indirect_card', '二级卡酬')->symbol('¥')->value($this->configs['indirect_card'] ?? 0)->required()->setWidth(1, 3)->default(0);
|
||||
$form->currency('team_card', '团队卡酬')->symbol('¥')->value($this->configs['team_card'] ?? 0)->required()->setWidth(1, 3)->default(0);
|
||||
$form->rate('direct_agency', '直推代理')->value($this->configs['direct_agency'] ?? 0)->required()->setWidth(1, 3)->default(0);
|
||||
$form->rate('indirect_agency', '间推代理')->value($this->configs['indirect_agency'] ?? 0)->required()->setWidth(1, 3)->default(0);
|
||||
$form->rate('perf_100', '100万业绩奖')->value($this->configs['perf_100'] ?? 0)->required()->setWidth(1, 3)->default(0);
|
||||
$form->rate('perf_500', '500万业绩奖')->value($this->configs['perf_500'] ?? 0)->required()->setWidth(1, 3)->default(0);
|
||||
$form->rate('perf_1000', '1000万业绩奖')->value($this->configs['perf_1000'] ?? 0)->required()->setWidth(1, 3)->default(0);
|
||||
$form->rate('orderPerf', '城市分红')->value($this->configs['orderPerf'] ?? 0)->required()->setWidth(1, 3)->default(0);
|
||||
|
||||
});
|
||||
$form->textarea('remark', '说明')->rules('required');
|
||||
|
||||
$form->tools(function (Form\Tools $tools) {
|
||||
$tools->disableDelete();
|
||||
$tools->disableView();
|
||||
});
|
||||
|
||||
$form->footer(function ($footer) {
|
||||
$footer->disableReset();
|
||||
$footer->disableViewCheck();
|
||||
$footer->disableCreatingCheck();
|
||||
});
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
150
app/Admin/Controllers/MobileController.php
Normal file
150
app/Admin/Controllers/MobileController.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\MobileImport;
|
||||
use App\Models\Mobile;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Show;
|
||||
|
||||
class MobileController extends AdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
|
||||
return $content
|
||||
->header('手机号管理')
|
||||
->description('description')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit interface.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function edit($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('编辑手机号')
|
||||
->body($this->form()->edit($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function create(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('新增手机号')
|
||||
->body($this->form());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Mobile);
|
||||
$grid->model()->orderBy('id', 'desc');
|
||||
|
||||
$grid->tools(function (Grid\Tools $tools) {
|
||||
$tools->append(new MobileImport);
|
||||
});
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->like('number', '手机号');
|
||||
$filter->equal('status', '状态')->select([
|
||||
1 => '正常',
|
||||
0 => '禁用',
|
||||
]);
|
||||
});
|
||||
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->equal('operator', '运营商')->select(config('pick.operators'));
|
||||
$filter->like('city_name', '所属(市)');
|
||||
});
|
||||
|
||||
$filter->disableIdFilter();
|
||||
|
||||
});
|
||||
|
||||
$grid->id('ID');
|
||||
$grid->number('手机号');
|
||||
$grid->charge('服务费');
|
||||
$grid->price('低消费');
|
||||
$grid->type('靓号类型');
|
||||
$grid->column('运营商')->display(function () {
|
||||
return $this->operator_text;
|
||||
});
|
||||
|
||||
$grid->column('所属地区')->display(function () {
|
||||
return $this->city_name;
|
||||
});
|
||||
$grid->column('所属用户')->display(function () {
|
||||
return $this->user ? $this->user->info->nickname : '---';
|
||||
});
|
||||
|
||||
$grid->column('状态')->display(function () {
|
||||
return $this->status_text;
|
||||
});
|
||||
|
||||
$grid->created_at('创建时间');
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
$show = new Show(Mobile::findOrFail($id));
|
||||
|
||||
$show->id('编号');
|
||||
$show->name('手机号名称');
|
||||
$show->created_at('创建时间');
|
||||
|
||||
return $show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$operators = (new Mobile)->operators;
|
||||
|
||||
$form = new Form(new Mobile);
|
||||
|
||||
$form->text('number', '手机号')->rules('required');
|
||||
$form->text('type', '靓号类型')->rules('required');
|
||||
$form->text('charge', '服务费')->rules('required');
|
||||
$form->text('price', '低消')->rules('required');
|
||||
$form->select('operator', '运营商')->options($operators)->rules('required');
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
149
app/Admin/Controllers/OrderController.php
Normal file
149
app/Admin/Controllers/OrderController.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\Order\OrderDeliver;
|
||||
use App\Admin\Exporters\OrderExporter;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Facades\Admin;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Show;
|
||||
use RuLong\Order\Models\Order;
|
||||
|
||||
class OrderController extends AdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('订单列表')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Show interface.
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function detail(Order $order, Content $content)
|
||||
{
|
||||
return Admin::content(function (Content $content) use ($order) {
|
||||
$content->header('订单详情');
|
||||
|
||||
$content->body(view("admin.order.detail", compact('order')));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Order);
|
||||
$grid->disableCreateButton();
|
||||
|
||||
$grid->model()->orderBy('id', 'desc')->with(['details.item', 'user.info', 'payment']);
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableDelete();
|
||||
$actions->disableEdit();
|
||||
$actions->disableView();
|
||||
|
||||
if ($actions->row->canDeliver() && $actions->row->state == Order::ORDER_PAID) {
|
||||
$actions->add(new OrderDeliver);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->disableIdFilter();
|
||||
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->like('orderid', '订单编号');
|
||||
$filter->equal('state', '订单状态')->select([
|
||||
Order::ORDER_UNPAID => '待支付',
|
||||
Order::ORDER_PAID => '已支付',
|
||||
Order::ORDER_DELIVERED => '已发货',
|
||||
Order::ORDER_SIGNED => '已签收',
|
||||
Order::ORDER_CANCEL => '已取消',
|
||||
]);
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user', function ($query) {
|
||||
$query->whereHas('info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
});
|
||||
}, '下单用户');
|
||||
$filter->equal('type', '订单类型')->select(['MEMBER' => '会员商城', 'PICK' => '提货商城']);
|
||||
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->between('created_at', '下单时间')->datetime();
|
||||
$filter->between('paid_at', '付款时间')->datetime();
|
||||
});
|
||||
// $filter->expand();
|
||||
});
|
||||
|
||||
$grid->orderid('订单编号')->display(function ($model) {
|
||||
$ret = "<a href='orders/{$this->id}/detail' style='font-size:18px'>{$this->orderid}</a>";
|
||||
$ret .= '<br/><span style="color:#999">商品数量:' . $this->details()->sum('number') . '</span>';
|
||||
return $ret;
|
||||
});
|
||||
|
||||
$grid->column('订单类型')->display(function () {
|
||||
return $this->type_text;
|
||||
});
|
||||
|
||||
$grid->column('商品信息')->display(function () {
|
||||
$ret = '';
|
||||
foreach ($this->details as $detail) {
|
||||
$ret .= '<p style="font-size: 12px;line-height: 18px;margin: 0px;padding: 0px">' . $detail->item->getTitle() . ' <span style="color:red">' . number_format($detail['price'], 2) . '</span> * ' . $detail['number'] . '</p>';
|
||||
}
|
||||
return $ret;
|
||||
});
|
||||
$grid->column('下单用户')->display(function () {
|
||||
$ret = '<img src="' . $this->user->info->headimgurl . '" alt="" class="img img-thumbnail" style="max-width:40px;max-height:40px;vertical-align:top">';
|
||||
$ret .= '<div style="display:inline-block;margin-left:5px">' . $this->user->info->nickname;
|
||||
$ret .= '<br/>' . $this->user->info->mobile . '</div>';
|
||||
return $ret;
|
||||
});
|
||||
|
||||
$grid->column('价格')->display(function () {
|
||||
$ret = '商品小计:' . number_format($this->amount, 2);
|
||||
$ret .= '<br/>应收总额:' . number_format($this->total, 2);
|
||||
return $ret;
|
||||
});
|
||||
|
||||
$grid->column('状态')->display(function () {
|
||||
$ret = $this->state_text . '<br>';
|
||||
// $ret .= $this->status . '<br>';
|
||||
if ($this->payment) {
|
||||
$ret .= $this->payment->type_text . '<br>';
|
||||
$ret .= $this->payment->trade_no . '<br>';
|
||||
$ret .= $this->payment->transaction_id;
|
||||
}
|
||||
return $ret;
|
||||
});
|
||||
|
||||
$grid->column('下单时间/付款时间')->display(function ($gd) {
|
||||
$ret = $this->created_at . '<br/>';
|
||||
$ret .= $this->paid_at;
|
||||
return $ret;
|
||||
});
|
||||
|
||||
$grid->disableExport(false);
|
||||
$grid->exporter(new OrderExporter());
|
||||
|
||||
return $grid->render();
|
||||
}
|
||||
|
||||
}
|
||||
117
app/Admin/Controllers/ProfitController.php
Normal file
117
app/Admin/Controllers/ProfitController.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\ProfitStart;
|
||||
use App\Models\Profit;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Widgets\Table;
|
||||
use RuLong\Identity\Models\Identity;
|
||||
|
||||
class ProfitController extends AdminController
|
||||
{
|
||||
protected $title = '大盘分红管理';
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Profit);
|
||||
$grid->disableFilter();
|
||||
$grid->disableExport();
|
||||
$grid->disableRowSelector();
|
||||
$grid->tools(function ($tools) {
|
||||
$tools->batch(function ($batch) {
|
||||
$batch->disableDelete();
|
||||
});
|
||||
});
|
||||
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableDelete();
|
||||
$actions->disableView();
|
||||
if ($this->row->sett === 0) {
|
||||
$actions->add(new ProfitStart);
|
||||
}
|
||||
});
|
||||
$grid->fixColumns(0, 0);
|
||||
|
||||
$grid->model()->orderBy('id', 'asc');
|
||||
$grid->column('id', '序号')->sortable();
|
||||
$grid->column('分配级别')->display(function () {
|
||||
return $this->identity->title ?? '';
|
||||
});
|
||||
$grid->column('price', '分配额度');
|
||||
$grid->column('num', '分配人数');
|
||||
$grid->column('single', '单人分红金额');
|
||||
$grid->column('realPrice', '实发总金额');
|
||||
$grid->column('sett', '是否结算')->using([
|
||||
0 => '否',
|
||||
1 => '是',
|
||||
])->label([
|
||||
0 => 'warning',
|
||||
1 => 'success',
|
||||
]);
|
||||
$grid->column('created_at', '添加时间');
|
||||
$grid->column('updated_at', '修改时间');
|
||||
$grid->column('setted_at', '结算时间');
|
||||
$grid->column('分红记录')->display(function () {
|
||||
return '点击查看详情';
|
||||
})->modal('分红记录', function ($model) {
|
||||
$comments = $model->logs->map(function ($comment) {
|
||||
return [
|
||||
$comment->profit->id,
|
||||
$comment->profit->price,
|
||||
$comment->user_id,
|
||||
$comment->user->username ?? '---',
|
||||
$comment->user->info->nickname ?? '---',
|
||||
$comment->price,
|
||||
$comment->created_at->format('Y-m-d H:i:s'),
|
||||
];
|
||||
});
|
||||
return new Table(['分红ID', '分红总金额', '用户ID', '用户账号', '用户昵称', '分红金额', '产生时间'], $comments->toArray());
|
||||
});
|
||||
return $grid;
|
||||
}
|
||||
|
||||
protected function form()
|
||||
{
|
||||
$form = new Form(new Profit);
|
||||
$form->display('id', 'ID');
|
||||
|
||||
$form->tools(function (Form\Tools $tools) {
|
||||
$tools->disableDelete();
|
||||
$tools->disableView();
|
||||
});
|
||||
|
||||
$identitys = Identity::orderBy('id', 'desc')->pluck('title', 'id')->toArray();
|
||||
$form->select('identity_id', '分红身份')->options($identitys)->required();
|
||||
$form->currency('price', '分红总额度')->symbol('¥')->rules('required|min:0')->required();
|
||||
$states = [
|
||||
'on' => ['value' => 1, 'text' => '是', 'color' => 'success'],
|
||||
'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
|
||||
];
|
||||
|
||||
$form->switch('sett', '是否立即结算')->states($states)->default('off');
|
||||
$form->footer(function ($footer) {
|
||||
$footer->disableReset();
|
||||
$footer->disableViewCheck();
|
||||
$footer->disableCreatingCheck();
|
||||
});
|
||||
$form->saved(function (Form $form) {
|
||||
$log = $form->model();
|
||||
if (!empty($log->setted_at) && $log->sett == 0) {
|
||||
$log->sett = 1;
|
||||
$log->save();
|
||||
}
|
||||
if ($log->sett == 1 && empty($log->setted_at)) {
|
||||
//默认结算,并且结算时间为空,开始结算
|
||||
$log->sett = 0;
|
||||
$log->save();
|
||||
\App\Bonus\ProfitStart::settlement($log);
|
||||
}
|
||||
|
||||
});
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
44
app/Admin/Controllers/TestController.php
Normal file
44
app/Admin/Controllers/TestController.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TestController extends Controller
|
||||
{
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$users = \App\Models\User::whereHas('identity.info', function ($query) {
|
||||
$query->where('configs->perf_100', '>', 0)
|
||||
->orWhere('configs->perf_500', '>', 0)
|
||||
->orWhere('configs->perf_1000', '>', 0);
|
||||
})->get();
|
||||
foreach ($users as $key => $user) {
|
||||
\App\Jobs\Perf::dispatch($user, true);
|
||||
dump($user->id);
|
||||
}
|
||||
dd(1);
|
||||
$UpgradePayment = \App\Models\UpgradePayment::find(7);
|
||||
// $source = [
|
||||
// 'user_id' => $UpgradePayment->user->id,
|
||||
// 'type' => 'UpgradeVip',
|
||||
// 'payment_id' => $UpgradePayment->id,
|
||||
// ];
|
||||
// \App\Bonus\AddPerf::settlement($UpgradePayment->user, $UpgradePayment->amount, $source);
|
||||
event(new \App\Events\UpgradePaid($UpgradePayment));
|
||||
dd();
|
||||
//购卡订单
|
||||
//
|
||||
$info = \App\Models\CardPayment::find(2);
|
||||
\App\Bonus\BuyCard::settlement($info);
|
||||
|
||||
//推荐代理示例
|
||||
// $info = \App\Models\UpgradePayment::find(5);
|
||||
// \App\Bonus\DirectAgency::settlement($info);
|
||||
//推荐会员示例
|
||||
// $info = \App\Models\UpgradePayment::find(2);
|
||||
// \App\Bonus\DirectVip::settlement($info);
|
||||
}
|
||||
}
|
||||
144
app/Admin/Controllers/UpgradeController.php
Normal file
144
app/Admin/Controllers/UpgradeController.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\UpgradePayment;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use RuLong\Identity\Models\IdentityLog;
|
||||
|
||||
class UpgradeController extends AdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('升级订单')
|
||||
->description('description')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new UpgradePayment);
|
||||
$grid->model()->orderBy('id', 'desc');
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableActions();
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->like('id', '序号');
|
||||
|
||||
$filter->equal('type', '类型')->select([
|
||||
'vip' => '升级会员',
|
||||
'agent' => '升级代理商',
|
||||
]);
|
||||
});
|
||||
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('user', function ($query) {
|
||||
$query->whereHas('info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
});
|
||||
}, '用户名称');
|
||||
});
|
||||
|
||||
$filter->disableIdFilter();
|
||||
|
||||
});
|
||||
|
||||
$grid->column('id', '序号');
|
||||
$grid->column('手机号')->display(function () {
|
||||
return $this->user->username;
|
||||
});
|
||||
$grid->column('用户名称')->display(function () {
|
||||
return $this->user->info->nickname;
|
||||
});
|
||||
$grid->column('trade_no', '流水号');
|
||||
$grid->column('amount', '金额');
|
||||
$grid->column('total', '实付');
|
||||
$grid->column('type', '类型')->display(function () {
|
||||
return $this->type_text;
|
||||
});
|
||||
$grid->column('pay_type', '支付方式')->display(function () {
|
||||
return $this->pay_type_text;
|
||||
});
|
||||
$grid->column('状态')->display(function () {
|
||||
return $this->state_text;
|
||||
});
|
||||
$grid->column('created_at', '创建时间');
|
||||
$grid->column('paid_at', '支付时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function logs(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('升降记录')
|
||||
->description('description')
|
||||
->body($this->logsgrid());
|
||||
}
|
||||
|
||||
public function logsgrid()
|
||||
{
|
||||
$grid = new Grid(new IdentityLog);
|
||||
$grid->model()->orderBy('id', 'desc');
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableActions();
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->like('id', '序号');
|
||||
|
||||
$filter->equal('channel', '渠道')->select([
|
||||
'AutoUp' => '自动升级',
|
||||
'EmptyUp' => '后台升级',
|
||||
]);
|
||||
});
|
||||
|
||||
$filter->disableIdFilter();
|
||||
});
|
||||
|
||||
$grid->column('id', '序号');
|
||||
$grid->column('用户')->display(function () {
|
||||
return $this->user->info->nickname;
|
||||
});
|
||||
$grid->column('升级前')->display(function () {
|
||||
return $this->before_identity_title;
|
||||
});
|
||||
$grid->column('升级后')->display(function () {
|
||||
return $this->identity_title ?: '普通用户';
|
||||
});
|
||||
|
||||
$grid->column('渠道')->display(function () {
|
||||
return $this->channel_text;
|
||||
});
|
||||
$grid->created_at('升级时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
31
app/Admin/Controllers/UploadController.php
Normal file
31
app/Admin/Controllers/UploadController.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class UploadController extends AdminController
|
||||
{
|
||||
|
||||
public function editor(Request $request)
|
||||
{
|
||||
$files = $request->file("image");
|
||||
|
||||
if (empty($files)) {
|
||||
return response()->json(['errno' => 5, 'msg' => '请选择文件']);
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
$path = $file->store(
|
||||
'editor/' . date('Y/m/d'),
|
||||
config('admin.upload.disk')
|
||||
);
|
||||
|
||||
$data[] = Storage::disk(config('admin.upload.disk'))->url($path);
|
||||
}
|
||||
|
||||
return ['errno' => 0, 'data' => $data];
|
||||
}
|
||||
}
|
||||
133
app/Admin/Controllers/UserController.php
Normal file
133
app/Admin/Controllers/UserController.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\SetParent;
|
||||
use App\Admin\Actions\UserUpgrade;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Facades\Admin;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
|
||||
class UserController extends AdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('会员管理')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
|
||||
$grid = new Grid(new User);
|
||||
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableRowSelector();
|
||||
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableDelete();
|
||||
$actions->disableEdit();
|
||||
$actions->disableView();
|
||||
$actions->add(new UserUpgrade);
|
||||
if (!$this->row->parent) {
|
||||
$actions->add(new SetParent);
|
||||
}
|
||||
});
|
||||
|
||||
$grid->model()->orderBy('id', 'desc')->with(['info', 'account', 'orders']);
|
||||
|
||||
$grid->id('序号')->sortable();
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->disableIdFilter();
|
||||
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->like('id', '序号');
|
||||
$filter->like('info.nickname', '会员昵称');
|
||||
});
|
||||
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->like('username', '会员手机号');
|
||||
$filter->equal('identity.identity_id', '级别')->select([
|
||||
' ' => '全部',
|
||||
'1' => '会员',
|
||||
'2' => '金牌',
|
||||
'3' => '城市',
|
||||
'4' => '股东',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
$grid->column('头像 昵称')->display(function () {
|
||||
$avatar = '<img src="' . $this->info->headimgurl . '" alt="" style="width:40px;height:40px;border-radius:50%" />';
|
||||
return $avatar . ' ' . $this->info->nickname;
|
||||
});
|
||||
|
||||
$grid->column('手机号')->display(function () {
|
||||
return $this->username;
|
||||
});
|
||||
|
||||
$states = [
|
||||
'on' => ['value' => 1, 'text' => '是', 'color' => 'primary'],
|
||||
'off' => ['value' => 0, 'text' => '否', 'color' => 'default'],
|
||||
];
|
||||
$grid->column('is_contract', '签订合同')->switch($states);
|
||||
$grid->column('activationd_at', '升级代理时间');
|
||||
|
||||
$grid->column('推荐人')->display(function () {
|
||||
return $this->parent ? $this->parent->info->nickname . '(' . $this->parent->id . ')' : '';
|
||||
});
|
||||
|
||||
$grid->column('账户')->display(function () {
|
||||
$ret = '余额:' . $this->account->cash;
|
||||
return $ret;
|
||||
});
|
||||
|
||||
$grid->column('等级')->display(function () {
|
||||
return $this->identity_text;
|
||||
});
|
||||
|
||||
$grid->created_at('注册时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$form = new Form(new User);
|
||||
$form->switch('is_contract', '签订合同')->default(1);
|
||||
$form->saving(function (Form $form) {
|
||||
|
||||
if (request()->has('is_contract') && $form->model()->identity_id < 2) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => '当前账号不可设置合同状态。',
|
||||
]);
|
||||
}
|
||||
|
||||
});
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
44
app/Admin/Exporters/AccountLog.php
Normal file
44
app/Admin/Exporters/AccountLog.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Exporters;
|
||||
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Grid\Exporters\ExcelExporter;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class AccountLog extends ExcelExporter implements WithMapping
|
||||
{
|
||||
protected $fileName = '佣金明细.xlsx';
|
||||
protected $headings = [
|
||||
'序号',
|
||||
'用户编号',
|
||||
'用户账号',
|
||||
'用户名称',
|
||||
'佣金名称',
|
||||
'佣金金额',
|
||||
'佣金描述',
|
||||
'产生时间',
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->fileName = '佣金明细' . date('YmdHis') . '.xlsx';
|
||||
}
|
||||
|
||||
public function map($info): array
|
||||
{
|
||||
$data = [
|
||||
'id' => (string) $info->id,
|
||||
'user_id' => (string) $info->user_id,
|
||||
'username' => '`' . $info->user->username,
|
||||
'nickname' => (string) $info->userinfo->nickname,
|
||||
'title' => (string) $info->rule->title,
|
||||
'variable' => (string) $info->variable,
|
||||
'remark' => (string) $info->rule->remark,
|
||||
'created_at' => (string) $info->created_at,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
43
app/Admin/Exporters/CardExporters.php
Normal file
43
app/Admin/Exporters/CardExporters.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Exporters;
|
||||
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Grid\Exporters\CsvExporter;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
|
||||
class CardExporters extends CsvExporter implements WithMapping, WithStrictNullComparison
|
||||
{
|
||||
protected $fileName = '联卡蝠激活卡.csv';
|
||||
protected $mapTrue = true;
|
||||
protected $users = [];
|
||||
public function __construct()
|
||||
{
|
||||
$this->fileName = '联卡蝠激活卡' . date('YmdHis') . '.csv';
|
||||
$this->users = User::pluck('username', 'id')->toArray();
|
||||
}
|
||||
|
||||
protected $headings = ['卡序号', '归属', '卡号', '打印卡号', '卡密', '类型', '专项', '状态', '激活用户', '激活时间', '创建时间', '更改时间'];
|
||||
|
||||
public function map($info): array
|
||||
{
|
||||
$data = [
|
||||
$info->id,
|
||||
$this->users[$info->user_id] ?? '无',
|
||||
'`' . $info->code,
|
||||
$info->type . $info->code,
|
||||
$info->pass,
|
||||
$info->type,
|
||||
$info->type == 'K' ? '商品ID:' . $info->source['goods'] . ';规格ID:' . $info->source['param'] : '非专项',
|
||||
$info->status_text,
|
||||
$this->users[$info->active_id] ?? '无',
|
||||
$info->actived_at,
|
||||
$info->created_at,
|
||||
$info->updated_at,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
39
app/Admin/Exporters/CashOutExport.php
Normal file
39
app/Admin/Exporters/CashOutExport.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Exporters;
|
||||
|
||||
use Encore\Admin\Grid\Exporters\ExcelExporter;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class CashOutExport extends ExcelExporter implements WithMapping
|
||||
{
|
||||
protected $fileName = '提现用户.xlsx';
|
||||
|
||||
protected $columns = [
|
||||
'id' => '序号',
|
||||
'user_id' => '用户ID',
|
||||
'user.username' => '用户账号',
|
||||
'user.info.nickname' => '用户昵称',
|
||||
'cash_account_no' => '支付宝账户',
|
||||
'variable' => '提现金额',
|
||||
'state' => '提现状态',
|
||||
'created_at' => '提现时间',
|
||||
];
|
||||
|
||||
public function map($info): array
|
||||
{
|
||||
$data = [
|
||||
'id' => $info->id,
|
||||
'user_id' => $info->user_id,
|
||||
'user.username' => ' ' . $info->user->username,
|
||||
'user.info.nickname' => ' ' . $info->user->info->nickname,
|
||||
'cash_account_no' => ' ' . $info->cash_account_no,
|
||||
'variable' => ' ' . $info->variable,
|
||||
'state' => $info->state_text,
|
||||
'created_at' => $info->created_at,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
66
app/Admin/Exporters/GoodsExporter.php
Normal file
66
app/Admin/Exporters/GoodsExporter.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: 朝霞
|
||||
* Date: 2019/5/14
|
||||
* Time: 1:51 PM
|
||||
*/
|
||||
|
||||
namespace App\Admin\Exporters;
|
||||
|
||||
use Encore\Admin\Grid\Exporters\AbstractExporter;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class GoodsExporter extends AbstractExporter
|
||||
{
|
||||
/**
|
||||
* @Notes 商品导出
|
||||
* @Author 朝霞
|
||||
* @DateTime 2019/5/14 2:09 PM
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
Excel::create('商品导出', function ($excel) {
|
||||
$excel->sheet('Sheetname', function ($sheet) {
|
||||
$head = ['商品ID','商品名称','成本价','销售价','市场价','销量','库存','销售分公司','状态','开团时间','截团时间','创建时间', '最后更新时间'];
|
||||
$body = ['id','name','cost_price','price','original_price','sales','stock','companies','status','activity_begined_at','activity_ended_at','created_at', 'updated_at'];
|
||||
$bodyRows = collect($this->getData())->map(function ($item)use($body) {
|
||||
foreach ($body as $keyName){
|
||||
switch ($keyName) {
|
||||
case 'status' :
|
||||
switch (array_get($item, $keyName)) {
|
||||
case 0:
|
||||
$arr[] = '审核中';
|
||||
break;
|
||||
case 1:
|
||||
$arr[] = '上架';
|
||||
break;
|
||||
case -1:
|
||||
$arr[] = '下架';
|
||||
break;
|
||||
default:
|
||||
$arr[] = '未知状态';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'companies' :
|
||||
$companies = array_get($item, 'companies');
|
||||
$arr[] = count($companies) > 0 ? implode('/', array_column($companies,'name')) : '';
|
||||
break;
|
||||
default:
|
||||
$arr[] = array_get($item, $keyName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $arr;
|
||||
});
|
||||
|
||||
$rows = collect([$head])->merge($bodyRows);
|
||||
$sheet->rows($rows);
|
||||
|
||||
});
|
||||
})->export('xlsx');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
59
app/Admin/Exporters/OrderExporter.php
Normal file
59
app/Admin/Exporters/OrderExporter.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Exporters;
|
||||
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Grid\Exporters\CsvExporter;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
|
||||
class OrderExporter extends CsvExporter implements WithMapping, WithStrictNullComparison
|
||||
{
|
||||
protected $mapTrue = true;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->fileName = '订单导出' . date('YmdHis') . '.csv';
|
||||
}
|
||||
|
||||
protected $headings = ['订单编号', '商品总数', '订单类型', '商品信息', '下单用户', '价格', '状态', '下单时间', '付款时间'];
|
||||
|
||||
public function map($info): array
|
||||
{
|
||||
$data = [
|
||||
'`' . $info->orderid,
|
||||
$info->details()->sum('number'),
|
||||
$info->type_text,
|
||||
self::getGoodsValue($info->details),
|
||||
$info->user->info->nickname . "\r\n" . $info->user->username,
|
||||
"商品小计:" . number_format($info->amount, 2) . "\r\n" . "应收总额:" . number_format($info->total, 2),
|
||||
self::getOrderStatus($info),
|
||||
$info->created_at,
|
||||
$info->paid_at,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getGoodsValue($details)
|
||||
{
|
||||
$ret = '';
|
||||
foreach ($details as $detail) {
|
||||
$ret .= $detail['item']['name'] . number_format($detail['price'], 2) . "\r\n";
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
protected function getOrderStatus($order)
|
||||
{
|
||||
$ret = $order->state_text . "\r\n";
|
||||
if ($order->payment) {
|
||||
$ret .= $order->payment->type_text . "\r\n";
|
||||
$ret .= $order->payment->trade_no . "\r\n";
|
||||
$ret .= $order->payment->transaction_id;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
||||
22
app/Admin/Exporters/ProvinceExporter.php
Normal file
22
app/Admin/Exporters/ProvinceExporter.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Exporters;
|
||||
|
||||
use Encore\Admin\Grid\Exporters\ExcelExporter;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class ProvinceExporter extends ExcelExporter implements WithMapping
|
||||
{
|
||||
protected $fileName = '省市管理.xlsx';
|
||||
|
||||
protected $columns = [
|
||||
'shortname' => '省市区名称',
|
||||
];
|
||||
|
||||
public function map($area): array
|
||||
{
|
||||
return [
|
||||
$area->shortname,
|
||||
];
|
||||
}
|
||||
}
|
||||
43
app/Admin/Extensions/WangEditor.php
Normal file
43
app/Admin/Extensions/WangEditor.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Extensions;
|
||||
|
||||
use Encore\Admin\Form\Field;
|
||||
|
||||
class WangEditor extends Field
|
||||
{
|
||||
protected $view = 'admin.wang-editor';
|
||||
|
||||
protected static $css = [
|
||||
'/vendor/wangEditor-3.1.1/release/wangEditor.min.css',
|
||||
];
|
||||
|
||||
protected static $js = [
|
||||
'/vendor/wangEditor-3.1.1/release/wangEditor.min.js',
|
||||
];
|
||||
|
||||
public function render()
|
||||
{
|
||||
$_token = csrf_token();
|
||||
$name = $this->formatName($this->column);
|
||||
|
||||
$this->script = <<<EOT
|
||||
|
||||
var E = window.wangEditor
|
||||
var editor = new E('#{$this->id}');
|
||||
editor.customConfig.zIndex = 0
|
||||
editor.customConfig.uploadImgServer = '/admin/uploads/editor'
|
||||
editor.customConfig.uploadImgMaxSize = 2 * 1024 * 1024
|
||||
editor.customConfig.uploadFileName = 'image[]'
|
||||
editor.customConfig.uploadImgParams = {
|
||||
_token: '{$_token}'
|
||||
}
|
||||
editor.customConfig.onchange = function (html) {
|
||||
$('input[name=\'$name\']').val(html);
|
||||
}
|
||||
editor.create()
|
||||
|
||||
EOT;
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
36
app/Admin/Extensions/mobile.php
Normal file
36
app/Admin/Extensions/mobile.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace App\Admin\Extensions;
|
||||
|
||||
/**
|
||||
* 校验手机号
|
||||
*/
|
||||
class mobile
|
||||
{
|
||||
|
||||
public function phoneOperator()
|
||||
{
|
||||
$isPhone = "/^1[3-9]\d{9}$/"; //先判断正确手机号格式
|
||||
|
||||
if (preg_match($isPhone, $phone)) {
|
||||
|
||||
$isChinaMobile = "/^134[0-9]\d{7}$|^1703\d{7}$|^170[5-6]\d{7}$|^(?:13[5-9]|147|148|15[0-27-9]|178|18[2-478]|198)\d{8}$/"; //
|
||||
$isChinaUnion = "/^1704\d{7}$|^170[7-9]\d{7}$|^171[0-9]\d{7}$|^(?:13[0-2]|145|15[56]|166|140|175|176|18[56])\d{8}$/"; //
|
||||
$isChinaTelcom = "/^(?:133|153|169|177|173|174|170|179|18[019]|199)\d{8}$|^170[0-2]\d{7}$/"; //
|
||||
|
||||
if (preg_match($isChinaMobile, $phone)) {
|
||||
return 'mobile'; //中国移动
|
||||
} else if (preg_match($isChinaUnion, $phone)) {
|
||||
return 'unicom'; //中国联通
|
||||
} else if (preg_match($isChinaTelcom, $phone)) {
|
||||
return 'telecom'; //中国电信
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
50
app/Admin/Imports/Mobile.php
Normal file
50
app/Admin/Imports/Mobile.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Imports;
|
||||
|
||||
use App\Models\Mobile as MobileModel;
|
||||
use Illuminate\Support\Collection;
|
||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||
use RuLong\Area\Models\Area;
|
||||
|
||||
class Mobile implements ToCollection
|
||||
{
|
||||
|
||||
public function collection(Collection $rows)
|
||||
{
|
||||
$operators = [
|
||||
'移动号码' => 'mobile',
|
||||
'联通号码' => 'unicom',
|
||||
'电信号码' => 'telecom',
|
||||
];
|
||||
unset($rows[0]);
|
||||
$lists = [];
|
||||
foreach ($rows as $row) {
|
||||
$area = Area::where('name', $row['5'])->first();
|
||||
$data = [
|
||||
'number' => (string) $row[0] ?: '', //手机号
|
||||
'begin' => substr($row[1], 0, 3), //号段
|
||||
'type' => $row[2], //靓号类型
|
||||
'charge' => $row[3] ?: 0, //服务费
|
||||
'price' => $row[4] ?: 0, //低消
|
||||
'province_sn' => $area->psn ?: null,
|
||||
'city_sn' => $area->sn ?: null,
|
||||
'operator' => $operators[$row[6]] ?: null, //运营商
|
||||
'city_name' => $row[5],
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
|
||||
$info = MobileModel::where('number', $data['number'])->first();
|
||||
if ($info) {
|
||||
$info->update($data);
|
||||
} else {
|
||||
$lists[] = $data;
|
||||
}
|
||||
}
|
||||
if (count($lists) > 0) {
|
||||
MobileModel::insert($lists);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
28
app/Admin/bootstrap.php
Normal file
28
app/Admin/bootstrap.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use App\Admin\Extensions\WangEditor;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
|
||||
Form::forget(['map']);
|
||||
Form::extend('editor', WangEditor::class);
|
||||
|
||||
Form::init(function (Form $form) {
|
||||
$form->disableEditingCheck();
|
||||
$form->disableCreatingCheck();
|
||||
$form->disableViewCheck();
|
||||
|
||||
$form->tools(function (Form\Tools $tools) {
|
||||
$tools->disableDelete();
|
||||
$tools->disableView();
|
||||
$tools->disableList();
|
||||
});
|
||||
});
|
||||
|
||||
Grid::init(function (Grid $grid) {
|
||||
$grid->disableExport();
|
||||
$grid->disableRowSelector();
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
$actions->disableView();
|
||||
});
|
||||
});
|
||||
68
app/Admin/routes.php
Normal file
68
app/Admin/routes.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
|
||||
Admin::routes();
|
||||
|
||||
Route::group([
|
||||
'prefix' => config('admin.route.prefix'),
|
||||
'namespace' => config('admin.route.namespace'),
|
||||
'middleware' => config('admin.route.middleware'),
|
||||
], function (Router $router) {
|
||||
|
||||
$router->get('/', 'HomeController@index')->name('admin.home');
|
||||
|
||||
$router->post('uploads/editor', 'UploadController@editor')->name('uploads.editor');
|
||||
|
||||
// 分类
|
||||
$router->resource('categories', 'CategoryController');
|
||||
//文章
|
||||
$router->resource('articles', 'ArticleController');
|
||||
// 轮播图管理
|
||||
$router->resource('adverts', 'AdvertController');
|
||||
//商品管理
|
||||
$router->resource('goods', 'GoodsController');
|
||||
//手机号管理
|
||||
$router->resource('mobiles', 'MobileController');
|
||||
//大盘分红
|
||||
$router->resource('profit', 'ProfitController');
|
||||
|
||||
//卡管理管理
|
||||
$router->get('card/getGoods', 'CardController@getGoods');
|
||||
$router->get('card/getParam', 'CardController@getParam');
|
||||
$router->post('card/createCard', 'CardController@createCard');
|
||||
$router->resource('card', 'CardController');
|
||||
$router->resource('cardorder', 'CardOrderController');
|
||||
//用户管理
|
||||
$router->get('users/{user}/empty', 'UserController@emptys')->name('admin.users.empty');
|
||||
$router->post('users/{user}/empty', 'UserController@DoEmpty');
|
||||
$router->any('users/{user}/remark', 'UserController@remark')->name('admin.users.remark');
|
||||
$router->resource('users', 'UserController');
|
||||
|
||||
// 订单管理
|
||||
$router->post('orders/{order}/deliver', 'OrderController@deliver');
|
||||
$router->get('orders/{order}/detail', 'OrderController@detail')->name('admin.orders.detail');
|
||||
$router->resource('orders', 'OrderController');
|
||||
|
||||
//账户管理
|
||||
$router->resource('account', 'AccountController');
|
||||
|
||||
//账变明细
|
||||
$router->get('accountlog/logs', 'AccountlogController@logs')->name('admin.accountlog.logs');
|
||||
$router->resource('accountlog', 'AccountlogController');
|
||||
|
||||
//身份管理
|
||||
$router->resource('identity', 'IdentityController');
|
||||
|
||||
//区域列表
|
||||
$router->post('areas/setManage', 'AreaController@setManage');
|
||||
$router->resource('areas', 'AreaController');
|
||||
//升级订单
|
||||
$router->get('upgrades', 'UpgradeController@index')->name('admin.upgrades.index');
|
||||
$router->get('upgrades/logs', 'UpgradeController@logs')->name('admin.upgrades.logs');
|
||||
|
||||
//用户提现管理
|
||||
$router->get('cashout/logs', 'CashOutController@logs')->name('admin.cashout.logs');
|
||||
$router->resource('cashout', 'CashOutController');
|
||||
$router->get('test', 'TestController@index');
|
||||
});
|
||||
Reference in New Issue
Block a user