[新增] first commit
This commit is contained in:
60
app/Admin/Actions/Coupon/Batch.php
Normal file
60
app/Admin/Actions/Coupon/Batch.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions\Coupon;
|
||||
|
||||
use App\Models\Coupon;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Actions\Action;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Batch extends Action
|
||||
{
|
||||
|
||||
public $name = '批量打款';
|
||||
|
||||
protected $selector = '.import-post';
|
||||
|
||||
public function handle(Request $request)
|
||||
{
|
||||
$user_id = $request->user_id;
|
||||
$date = $request->date;
|
||||
$list = Coupon::where('user_id', $user_id)->whereDate('created_at', $date)->where('status', 2)->get();
|
||||
if ($list->isEmpty()) {
|
||||
return $this->response()->error('打款失败!没有可处理的数据')->refresh();
|
||||
}
|
||||
|
||||
$success = $error = 0;
|
||||
foreach ($list as $key => $coupon) {
|
||||
$res = $coupon->sendMoney();
|
||||
if ($res === true) {
|
||||
$success++;
|
||||
} else {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response()->success("处理完成,成功:{$success}条,失败:{$error}条")->refresh();
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
$users = User::query()
|
||||
->whereHas('identity', function ($query) {
|
||||
$query->where('identity_id', 1);
|
||||
})
|
||||
->get()
|
||||
->pluck('nickname', 'id');
|
||||
|
||||
$this->select('user_id', '渠道')->options($users)->required();
|
||||
// 时间日期选择
|
||||
$this->date('date', '核销日期')->required();
|
||||
}
|
||||
|
||||
public function html()
|
||||
{
|
||||
return <<<HTML
|
||||
<a class="btn btn-sm btn-default import-post"><i class="fa fa-Yuan"></i>批量打款</a>
|
||||
HTML;
|
||||
}
|
||||
|
||||
}
|
||||
33
app/Admin/Actions/Coupon/BatchProfit.php
Normal file
33
app/Admin/Actions/Coupon/BatchProfit.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions\Coupon;
|
||||
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BatchProfit extends RowAction
|
||||
{
|
||||
public $name = '打款';
|
||||
|
||||
public function handle(Model $model)
|
||||
{
|
||||
if ($model->canProfit()) {
|
||||
$res = $model->sendMoney();
|
||||
if ($res === true) {
|
||||
return $this->response()->success('操作成功')->refresh();
|
||||
|
||||
} else {
|
||||
return $this->response()->success($res)->refresh();
|
||||
}
|
||||
|
||||
} else {
|
||||
return $this->response()->success('操作失败')->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public function dialog()
|
||||
{
|
||||
$this->confirm('确定分润?');
|
||||
}
|
||||
|
||||
}
|
||||
33
app/Admin/Actions/Coupon/BatchProfits.php
Normal file
33
app/Admin/Actions/Coupon/BatchProfits.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions\Coupon;
|
||||
|
||||
use Encore\Admin\Actions\BatchAction;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class BatchProfits extends BatchAction
|
||||
{
|
||||
public $name = '批量打款';
|
||||
|
||||
public function handle(Collection $collection)
|
||||
{
|
||||
$success = $error = 0;
|
||||
|
||||
foreach ($collection as $model) {
|
||||
$res = $model->sendMoney();
|
||||
if ($res === true) {
|
||||
$success++;
|
||||
} else {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response()->success('成功' . $success . '条,失败' . $error . '条')->refresh();
|
||||
}
|
||||
|
||||
public function dialog()
|
||||
{
|
||||
$this->confirm('确定打款?');
|
||||
}
|
||||
|
||||
}
|
||||
42
app/Admin/Actions/User/Callback.php
Normal file
42
app/Admin/Actions/User/Callback.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions\User;
|
||||
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Callback extends RowAction
|
||||
{
|
||||
|
||||
public $name = '设置回调地址';
|
||||
|
||||
public function handle(Model $model, Request $request)
|
||||
{
|
||||
$validator = \Validator::make($request->all(), [
|
||||
'callback' => 'required|url',
|
||||
], [
|
||||
'callback.required' => '缺少回调地址',
|
||||
'callback.url' => '回调地址不正确,不是有效的url地址',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return $this->response()->error($validator->errors()->first());
|
||||
}
|
||||
|
||||
$model->callback = $request->callback;
|
||||
|
||||
if ($model->save()) {
|
||||
return $this->response()->success('设置成功')->refresh();
|
||||
}
|
||||
|
||||
return $this->response()->error('设置失败')->refresh();
|
||||
|
||||
}
|
||||
|
||||
public function form(Model $model)
|
||||
{
|
||||
$this->text('callback', '回调地址')->default($model->callback)->required();
|
||||
}
|
||||
|
||||
}
|
||||
33
app/Admin/Actions/User/Profit.php
Normal file
33
app/Admin/Actions/User/Profit.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions\User;
|
||||
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Profit extends RowAction
|
||||
{
|
||||
public $name = '设置分润';
|
||||
|
||||
public function handle(Model $model, Request $request)
|
||||
{
|
||||
$datas = $request->code;
|
||||
|
||||
$codes = $model->code;
|
||||
foreach ($codes as $key => $code) {
|
||||
$code->profit = round($datas[$code->id], 2);
|
||||
$code->save();
|
||||
}
|
||||
return $this->response()->success('操作成功')->refresh();
|
||||
}
|
||||
|
||||
public function form(Model $model)
|
||||
{
|
||||
$codes = $model->code;
|
||||
foreach ($codes as $key => $code) {
|
||||
$this->text("code[{$code->id}]", $code->name)->value($code->profit)->required();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
45
app/Admin/Actions/User/ReCode.php
Normal file
45
app/Admin/Actions/User/ReCode.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions\User;
|
||||
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use RuLong\Identity\Models\Identity;
|
||||
|
||||
class ReCode extends RowAction
|
||||
{
|
||||
|
||||
public $name = '重置规则';
|
||||
|
||||
public function handle(Model $model)
|
||||
{
|
||||
if ($model->identity_id != 1) {
|
||||
return $this->response()->error('只有渠道才能刷新');
|
||||
}
|
||||
|
||||
$all_codes = Identity::find(1)->codes;
|
||||
$user_codes = $model->code;
|
||||
|
||||
if ($all_codes->count() == $user_codes->count()) {
|
||||
return $this->response()->success('操作成功')->refresh();
|
||||
}
|
||||
|
||||
foreach ($all_codes as $key => $code) {
|
||||
$model->code()->updateOrCreate([
|
||||
'code' => $code->code,
|
||||
], [
|
||||
'name' => $code->name,
|
||||
'code' => $code->code,
|
||||
'profit' => $code->profit,
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->response()->success('操作成功')->refresh();
|
||||
}
|
||||
|
||||
public function dialog()
|
||||
{
|
||||
$this->confirm('确定要重置卡券规则吗?刷新后将重置此渠道卡券规则');
|
||||
}
|
||||
|
||||
}
|
||||
24
app/Admin/Actions/User/RefD3Key.php
Normal file
24
app/Admin/Actions/User/RefD3Key.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions\User;
|
||||
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class RefD3Key extends RowAction
|
||||
{
|
||||
public $name = '刷新D3key';
|
||||
|
||||
public function handle(Model $model)
|
||||
{
|
||||
$model->des3key = Str::random(24);
|
||||
$model->save();
|
||||
return $this->response()->success('操作成功')->refresh();
|
||||
}
|
||||
|
||||
public function dialog()
|
||||
{
|
||||
$this->confirm('确定要刷新D3key吗?');
|
||||
}
|
||||
}
|
||||
37
app/Admin/Actions/User/UserImport.php
Normal file
37
app/Admin/Actions/User/UserImport.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace App\Admin\Actions\User;
|
||||
|
||||
use App\Admin\Imports\User;
|
||||
use Encore\Admin\Actions\Action;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class UserImport extends Action
|
||||
{
|
||||
public $name = '导入网点编号';
|
||||
|
||||
protected $selector = '.import-post';
|
||||
public $modelName = '';
|
||||
|
||||
public function handle(Request $request)
|
||||
{
|
||||
$res = Excel::import(new User, $request->file('file'), 'excel');
|
||||
if ($res === true) {
|
||||
return $this->response()->success('导入完成!')->refresh();
|
||||
} else {
|
||||
return $this->response()->error('失败' . $res)->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;
|
||||
}
|
||||
}
|
||||
31
app/Admin/Actions/User/UserUpgrade.php
Normal file
31
app/Admin/Actions/User/UserUpgrade.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions\User;
|
||||
|
||||
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');
|
||||
|
||||
return $this->response()->success('升级成功')->refresh();
|
||||
}
|
||||
|
||||
public function form(Model $model)
|
||||
{
|
||||
$identitys = Identity::where('id', '!=', $model->identity_id)->orderBy('id', 'asc')->pluck('title', 'id')->toArray();
|
||||
$this->text('用户名称')->disable()->value($model->info->nickname);
|
||||
$this->text('当前等级')->disable()->value($model->identity_text);
|
||||
$this->select('identity_id', '目标等级')->options($identitys);
|
||||
}
|
||||
|
||||
}
|
||||
55
app/Admin/Actions/Wo/Unsubscribe.php
Normal file
55
app/Admin/Actions/Wo/Unsubscribe.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Actions\Wo;
|
||||
|
||||
use Encore\Admin\Actions\RowAction;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Wo;
|
||||
|
||||
class Unsubscribe extends RowAction
|
||||
{
|
||||
public $name = '退订';
|
||||
|
||||
public function handle(Model $model)
|
||||
{
|
||||
$postData = [
|
||||
'logNo' => $model->logNo,
|
||||
];
|
||||
//查询状态
|
||||
$res = Wo::ticketQuery($postData, $model->user_id);
|
||||
if (is_string($res)) {
|
||||
return $this->response()->error($res)->refresh();
|
||||
}
|
||||
|
||||
$ConfigTicketState = config('wo.ticketState');
|
||||
$ConfigTicketStateText = config('wo.ticketStateText');
|
||||
$ticketState = $res['ticketState'];
|
||||
|
||||
if (!in_array($ticketState, ['A', 'U'])) {
|
||||
$msg = (array_key_exists($ticketState, $ConfigTicketStateText)) ? $ConfigTicketStateText[$ticketState] : '未知状态';
|
||||
return $this->response()->error($msg)->refresh();
|
||||
}
|
||||
|
||||
//判断数组中是否存在下标
|
||||
if (!array_key_exists($ticketState, $ConfigTicketState)) {
|
||||
return $this->response()->error('未知状态')->refresh();
|
||||
}
|
||||
|
||||
$postData['service'] = $ConfigTicketState[$ticketState];
|
||||
$postData['ologNo'] = $postData['logNo'];
|
||||
|
||||
//退业务
|
||||
$res = Wo::ticketBack($postData, $model->user);
|
||||
|
||||
if (is_string($res)) {
|
||||
return $this->response()->error($res)->refresh();
|
||||
}
|
||||
|
||||
return $this->response()->success($res)->refresh();
|
||||
}
|
||||
|
||||
public function dialog()
|
||||
{
|
||||
$this->confirm('确定要退订吗?');
|
||||
}
|
||||
}
|
||||
47
app/Admin/Controllers/Account/IndexController.php
Normal file
47
app/Admin/Controllers/Account/IndexController.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Account;
|
||||
|
||||
use App\Models\Account;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
|
||||
class IndexController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = '账户管理';
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Account);
|
||||
|
||||
$grid->model()->whereHasMorph(
|
||||
'accountable',
|
||||
User::class,
|
||||
function ($query) {
|
||||
$query->whereHas('identity', function ($q) {
|
||||
$q->where('identity_id', 1);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
$grid->disableActions();
|
||||
$grid->disableCreateButton();
|
||||
// $grid->column('所属项目')->display(function () {
|
||||
// return $this->accountable->type_text;
|
||||
// });
|
||||
$grid->column('渠道名称')->display(function () {
|
||||
return $this->accountable->name ?? $this->accountable->nickname;
|
||||
});
|
||||
$grid->column('balance', '总分润');
|
||||
$grid->column('score', '已打款');
|
||||
// $grid->column('updated_at', '更新时间');
|
||||
$grid->column('日志')->display(function () {
|
||||
return '<a href="' . admin_url('accounts/logs?id=' . $this->id) . '">账户日志</a>';
|
||||
});
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
75
app/Admin/Controllers/Account/LogController.php
Normal file
75
app/Admin/Controllers/Account/LogController.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Account;
|
||||
|
||||
use App\Models\AccountLog;
|
||||
use App\Models\User;
|
||||
use App\Models\AccountRule;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
|
||||
class LogController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = '账户日志';
|
||||
|
||||
function grid()
|
||||
{
|
||||
$grid = new Grid(new AccountLog);
|
||||
$grid->model()->with(['account'])->latest();
|
||||
$userId = request()->user_id;
|
||||
$grid->model()->when($userId, function ($query, $userId) {
|
||||
$query->where('user_id', $userId);
|
||||
});
|
||||
|
||||
$grid->disableActions();
|
||||
$grid->disableCreateButton();
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->equal('rule_id', '触发规则')->select(AccountRule::pluck('title', 'id'));
|
||||
$filter->equal('type', '账户类型')->select(config('account.account_type'));
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('account', function ($query) {
|
||||
$query->whereHasMorph('accountable', 'App\Models\User', function ($query) {
|
||||
$query->where('id', $this->input);
|
||||
});
|
||||
});
|
||||
}, '会员账号', 'id')->select(User::whereHas('identity', function ($q) {
|
||||
$q->where('identity_id', 1);
|
||||
})->get()->pluck('info.nickname', 'id'));
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->equal('frozen', '冻结')->select([
|
||||
0 => '否',
|
||||
1 => '是',
|
||||
]);
|
||||
$filter->between('created_at', '创建时间')->datetime();
|
||||
});
|
||||
});
|
||||
|
||||
$grid->column('会员账号')->display(function () {
|
||||
return $this->account->accountable->username;
|
||||
});
|
||||
$grid->column('会员昵称')->display(function () {
|
||||
return $this->account->accountable->info->nickname;
|
||||
});
|
||||
$grid->column('rule.title', '触发规则');
|
||||
$grid->column('type', '类型')
|
||||
->using(config('account.account_type'));
|
||||
$grid->column('variable', '变量');
|
||||
$grid->column('balance', '余额');
|
||||
$grid->column('frozen', '冻结')
|
||||
->using([0 => '否', 1 => '是'])
|
||||
->label([
|
||||
0 => 'success',
|
||||
1 => 'warning',
|
||||
]);
|
||||
$grid->column('created_at', '获取时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
107
app/Admin/Controllers/Account/RuleController.php
Normal file
107
app/Admin/Controllers/Account/RuleController.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Account;
|
||||
|
||||
use App\Models\AccountRule;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class RuleController extends AdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* Title for current resource.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $title = '账户规则';
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new AccountRule);
|
||||
$grid->tools(function (Grid\Tools $tools) {
|
||||
$tools->batch(function ($batch) {
|
||||
$batch->disableDelete();
|
||||
});
|
||||
});
|
||||
$grid->quickSearch('title')->placeholder('规则名称');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->like('title', '规则名称');
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->like('name', '调用标记');
|
||||
});
|
||||
$filter->column(1 / 3, function ($filter) {
|
||||
$filter->equal('type', '账户类型')->select([
|
||||
'cash' => '现金账户',
|
||||
'score' => '积分账户',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
$grid->column('id', '编号');
|
||||
$grid->column('title', '规则名称');
|
||||
$grid->column('name', '调用标记');
|
||||
$grid->column('type', '账户类型')->using(config('account.account_type'));
|
||||
$grid->column('variable', '增减变量');
|
||||
$grid->column('trigger', '频率')->display(function () {
|
||||
return $this->trigger_text;
|
||||
});
|
||||
$grid->column('deductions', '立即处理')->bool();
|
||||
$grid->column('remark', '备注');
|
||||
$grid->column('created_at', '创建时间');
|
||||
$grid->column('updated_at', '更新时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
|
||||
$form = new Form(new AccountRule);
|
||||
$form->text('title', '规则名称')
|
||||
->rules('required|between:2,50');
|
||||
|
||||
$form->text('name', '调用标记')
|
||||
->creationRules('required|alpha_dash|between:2,50|unique:account_rules')
|
||||
->updateRules('required|alpha_dash|between:2,50|unique:account_rules,name,{{id}}');
|
||||
|
||||
$form->select('type', '账户类型')
|
||||
->options(config('account.account_type'))
|
||||
->rules(['required', Rule::in(array_keys(config('account.account_type')))]);
|
||||
|
||||
$form->number('variable', '增减变量')
|
||||
->value(0)
|
||||
->rules('required|numeric');
|
||||
|
||||
$form->number('trigger', '次数限制')->value(0)
|
||||
->help('执行次数限制,小于0则终身一次,等于0不限制,大于0每日N次')
|
||||
->rules('required|integer');
|
||||
|
||||
$states = [
|
||||
'on' => ['value' => 1, 'text' => '打开'],
|
||||
'off' => ['value' => 0, 'text' => '关闭'],
|
||||
];
|
||||
|
||||
$form->switch('deductions', '立即处理')->value(1)->states($states);
|
||||
|
||||
$form->textarea('remark', '备注信息')->rules('nullable|max:255');
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
108
app/Admin/Controllers/Activity/CouponController.php
Normal file
108
app/Admin/Controllers/Activity/CouponController.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Activity;
|
||||
|
||||
use App\Models\ActivityCoupon;
|
||||
use App\Models\ActivityRule;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
|
||||
class CouponController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = '卡券列表管理';
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new ActivityCoupon);
|
||||
$grid->model()->with(['outlet'])->latest();
|
||||
$grid->disableActions();
|
||||
$grid->disableCreateButton();
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->equal('status', '状态')->select(ActivityCoupon::STATUS);
|
||||
$filter->between('used_at', '核销时间')->datetime();
|
||||
|
||||
$users = User::whereHas('identity', function ($query) {
|
||||
$query->where('identity_id', 1);
|
||||
})->get()->pluck('nickname', 'id');
|
||||
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('outlet', function ($query) {
|
||||
$query->whereHas('info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
});
|
||||
}, '网点名称', 'outlet_name');
|
||||
|
||||
});
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->like('code', '卡券编号');
|
||||
$filter->like('mobile', '手机号');
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('activity', function ($query) {
|
||||
$query->whereHas('rule', function ($query) {
|
||||
$query->where('code', $this->input);
|
||||
});
|
||||
});
|
||||
}, '优惠政策', 'rule_code')->select(ActivityRule::where('status', 1)->pluck('title', 'code'));
|
||||
|
||||
$users = User::query()
|
||||
->whereHas('identity', function ($query) {
|
||||
$query->where('identity_id', 1);
|
||||
})
|
||||
->get()
|
||||
->pluck('nickname', 'id');
|
||||
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('outlet', function ($query) {
|
||||
$query->whereHas('parent', function ($query) {
|
||||
$query->where('id', $this->input);
|
||||
});
|
||||
});
|
||||
}, '渠道', 'parent_id')->select($users);;
|
||||
});
|
||||
});
|
||||
|
||||
$grid->column('id', '#ID#');
|
||||
$grid->column('activity.title', '卡券名称');
|
||||
$grid->column('mobile', '手机号');
|
||||
$grid->column('优惠政策')->display(function () {
|
||||
return $this->activity->rule->title;
|
||||
});
|
||||
|
||||
$grid->column('网点名称/编号')->display(function () {
|
||||
return $this->outlet ? $this->outlet->nickname : $this->outletId;
|
||||
});
|
||||
|
||||
$grid->column('code', '卡券编号');
|
||||
$grid->column('status', '状态')
|
||||
->using(ActivityCoupon::STATUS)
|
||||
->label([
|
||||
1 => 'default',
|
||||
2 => 'warning',
|
||||
3 => 'info',
|
||||
]);
|
||||
|
||||
$grid->column('used_at', '核销时间');
|
||||
$grid->column('created_at', '创建时间');
|
||||
|
||||
$grid->disableExport(false);
|
||||
|
||||
$grid->export(function ($export) {
|
||||
$export->column('status', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->column('mobile', function ($value, $original) {
|
||||
return $value . "\t";
|
||||
});
|
||||
|
||||
$export->filename($this->title . date("YmdHis"));
|
||||
});
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
282
app/Admin/Controllers/Activity/IndexController.php
Normal file
282
app/Admin/Controllers/Activity/IndexController.php
Normal file
@@ -0,0 +1,282 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Activity;
|
||||
|
||||
use App\Admin\Renderable\Activity\Grants;
|
||||
use App\Models\Activity;
|
||||
use App\Models\ActivityGrant;
|
||||
use App\Models\ActivityRule;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Illuminate\Routing\Controller as AdminController;
|
||||
|
||||
class IndexController extends AdminController
|
||||
{
|
||||
|
||||
use HasResourceActions;
|
||||
|
||||
protected $title = '活动管理';
|
||||
|
||||
/**
|
||||
* Get content title.
|
||||
* @return string
|
||||
*/
|
||||
protected function title()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->title($this->title())
|
||||
->description($this->description['index'] ?? trans('admin.list'))
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit interface.
|
||||
* @param mixed $id
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function edit($id, Content $content)
|
||||
{
|
||||
return $content
|
||||
->title($this->title())
|
||||
->description($this->description['edit'] ?? trans('admin.edit'))
|
||||
->body($this->form($id)->edit($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create interface.
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function create(Content $content)
|
||||
{
|
||||
return $content
|
||||
->title($this->title())
|
||||
->description($this->description['create'] ?? trans('admin.create'))
|
||||
->body($this->form());
|
||||
}
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Activity);
|
||||
$grid->model()->withCount('coupons');
|
||||
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableView();
|
||||
});
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->equal('status', '状态')->select(Activity::STATUS);
|
||||
$filter->equal('type', '类型')->select(Activity::TYPES);
|
||||
|
||||
$users = User::whereHas('identity', function ($query) {
|
||||
$query->where('identity_id', 1);
|
||||
})->get()->pluck('nickname', 'id');
|
||||
|
||||
});
|
||||
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->between('start_at', '开始时间')->datetime();
|
||||
$filter->between('end_at', '结束时间')->datetime();
|
||||
$filter->equal('channel', '核销途径')->select(Activity::CHANNELS);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$grid->column('id', '#ID#');
|
||||
$grid->column('title', '活动名称');
|
||||
$grid->column('code', '活动编号');
|
||||
$grid->column('total', '可发券总数');
|
||||
$grid->column('coupons_count', '已发券总数');
|
||||
$grid->column('rule.code', '卡券规则');
|
||||
$grid->column('类型')->display(function () {
|
||||
return $this->type_text;
|
||||
});
|
||||
|
||||
$grid->column('channel', '核销途径')
|
||||
->using(Activity::CHANNELS)
|
||||
->label([
|
||||
Activity::CHANNEL_YSD => 'info',
|
||||
Activity::CHANNEL_UNION => 'success',
|
||||
]);
|
||||
|
||||
$grid->column('days', '延期(天)');
|
||||
$grid->column('rule.full', '满足金额');
|
||||
$grid->column('rule.take', '扣除金额');
|
||||
$grid->column('发券')
|
||||
->display(function () {
|
||||
return $this->grants->pluck('user_nickname');
|
||||
})
|
||||
->label()
|
||||
->hide();
|
||||
|
||||
$grid->column('核券')
|
||||
->display(function () {
|
||||
return $this->verifications->pluck('user_nickname');
|
||||
})
|
||||
->label()
|
||||
->hide();
|
||||
|
||||
$grid->column('开始时间')->display(function () {
|
||||
return $this->type == Activity::TYPE_SCOPE ? $this->start_at->format('Y-m-d') : '---';
|
||||
});
|
||||
$grid->column('结束时间')->display(function () {
|
||||
return $this->type == Activity::TYPE_SCOPE ? $this->end_at->format('Y-m-d') : '---';
|
||||
});
|
||||
|
||||
$grid->status('状态')->switch([
|
||||
'on' => ['value' => 1, 'text' => '正常', 'color' => 'primary'],
|
||||
'off' => ['value' => 0, 'text' => '关闭', 'color' => 'danger'],
|
||||
]);
|
||||
|
||||
$grid->column('created_at', '创建时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
* @return Form
|
||||
*/
|
||||
protected function form($id = '')
|
||||
{
|
||||
$form = new Form(new Activity);
|
||||
|
||||
$form->text('title', '活动名称')->required();
|
||||
$form->textarea('description', '活动说明')->required();
|
||||
|
||||
$form->select('activity_rule_id', '所属规则')
|
||||
->options(function ($option, $info) {
|
||||
return ActivityRule::where('status', 1)->pluck('title', 'id');
|
||||
})
|
||||
->required();
|
||||
|
||||
$form->number('total', '总数')
|
||||
->help('可发券总数,0为不限制')
|
||||
->default(10000)
|
||||
->required();
|
||||
|
||||
$form->radio('type', '类型')
|
||||
->options(Activity::TYPES)
|
||||
->when(Activity::TYPE_EXTEND, function (Form $form) {
|
||||
$form->number('days', '延期天数')->default(60)->help('到期日期=发券日期+延期天数');
|
||||
})
|
||||
->when(Activity::TYPE_SCOPE, function (Form $form) {
|
||||
$form->dateRange('start_at', 'end_at', '有效时间');
|
||||
})
|
||||
->required();
|
||||
|
||||
$form->radio('channel', '核销途径')
|
||||
->options(Activity::CHANNELS)
|
||||
->default(Activity::CHANNEL_YSD)
|
||||
->help('券码核销的途径:亿时代是自己核销,银联是银联pos核销')
|
||||
->required();
|
||||
|
||||
$form->switch('status', '状态')->default(1);
|
||||
$form->switch('need_check', '多次校验')
|
||||
->default(1)
|
||||
->help('同一订单,多次核销时校验,订单每满100元可核销一笔。');
|
||||
|
||||
$grantdef = $verificationsdef = '';
|
||||
if ($id) {
|
||||
$grantdef = Activity::find($id)->grants()->pluck('user_id')->toArray();
|
||||
$verificationsdef = Activity::find($id)->verifications()->pluck('user_id')->toArray();
|
||||
}
|
||||
|
||||
$users = User::with('info')->whereHas('identity', function ($q) {
|
||||
$q->where('identity_id', 1);
|
||||
})->orderBy('id', 'desc')->get()->pluck('nickname', 'id');
|
||||
|
||||
$form->listbox('grants.user_id', '可发券渠道')
|
||||
->options($users)
|
||||
->default($grantdef)
|
||||
->required();
|
||||
|
||||
$form->listbox('verifications.user_id', '可核券渠道')
|
||||
->options($users)
|
||||
->default($verificationsdef)
|
||||
->required();
|
||||
|
||||
$form->saving(function (Form $form) {
|
||||
$request = request();
|
||||
|
||||
if ($request->total < 0) {
|
||||
$error = new MessageBag([
|
||||
'title' => '错误',
|
||||
'message' => '可发券总数必须大于0',
|
||||
]);
|
||||
|
||||
return back()->withInput()->with(compact('error'));
|
||||
}
|
||||
|
||||
if ($request->type == Activity::TYPE_EXTEND && empty($request->days)) {
|
||||
$error = new MessageBag([
|
||||
'title' => '错误',
|
||||
'message' => '必须添加延期天数',
|
||||
]);
|
||||
|
||||
return back()->withInput()->with(compact('error'));
|
||||
}
|
||||
|
||||
if ($request->type == Activity::TYPE_SCOPE && (empty($request->start_at) || empty($request->end_at))) {
|
||||
$error = new MessageBag([
|
||||
'title' => '错误',
|
||||
'message' => '必须添加延期天数',
|
||||
]);
|
||||
|
||||
return back()->withInput()->with(compact('error'));
|
||||
}
|
||||
|
||||
if (request()->start) {
|
||||
$form->start_at = $form->start_at . ' 00:00:01';
|
||||
}
|
||||
|
||||
if (request()->end_at) {
|
||||
$form->end_at = $form->end_at . ' 23:59:59';
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$form->saved(function (Form $form) {
|
||||
$users = [];
|
||||
foreach ($form->grants['user_id'] as $key => $user_id) {
|
||||
if ($user_id) {
|
||||
$form->model()->grants()->updateOrCreate([
|
||||
'user_id' => $user_id,
|
||||
]);
|
||||
$users[] = $user_id;
|
||||
}
|
||||
}
|
||||
$form->model()->grants()->whereNotIn('user_id', $users)->delete();
|
||||
$users = [];
|
||||
foreach ($form->verifications['user_id'] as $key => $user_id) {
|
||||
if ($user_id) {
|
||||
$form->model()->verifications()->updateOrCreate([
|
||||
'user_id' => $user_id,
|
||||
]);
|
||||
$users[] = $user_id;
|
||||
}
|
||||
}
|
||||
$form->model()->verifications()->whereNotIn('user_id', $users)->delete();
|
||||
});
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
94
app/Admin/Controllers/Activity/LogController.php
Normal file
94
app/Admin/Controllers/Activity/LogController.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Activity;
|
||||
|
||||
use App\Admin\Renderable\Activity\Grants;
|
||||
use App\Models\Activity;
|
||||
use App\Models\ActivityCouponLog;
|
||||
use App\Models\ActivityGrant;
|
||||
use App\Models\ActivityRule;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Illuminate\Routing\Controller as AdminController;
|
||||
|
||||
class LogController extends AdminController
|
||||
{
|
||||
|
||||
use HasResourceActions;
|
||||
|
||||
protected $title = '回调记录';
|
||||
|
||||
/**
|
||||
* Get content title.
|
||||
* @return string
|
||||
*/
|
||||
protected function title()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->title($this->title())
|
||||
->description($this->description['index'] ?? trans('admin.list'))
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new ActivityCouponLog);
|
||||
|
||||
$grid->model()->latest();
|
||||
$grid->disableActions();
|
||||
$grid->disableCreateButton();
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->equal('code', '卡券编号');
|
||||
$filter->equal('type', '分类')->select(ActivityCouponLog::TYPES);
|
||||
});
|
||||
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->equal('status', '状态')->select(ActivityCouponLog::STATUS);
|
||||
|
||||
$filter->between('created_at', '开始时间')->datetime();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$grid->column('id', '#ID#');
|
||||
$grid->column('code', '卡券编号');
|
||||
$grid->column('type', '分类')
|
||||
->using(ActivityCouponLog::TYPES)
|
||||
->label([
|
||||
1 => 'default',
|
||||
2 => 'warning',
|
||||
3 => 'info',
|
||||
]);
|
||||
|
||||
$grid->column('status', '状态')
|
||||
->using(ActivityCouponLog::STATUS)
|
||||
->label([
|
||||
1 => 'default',
|
||||
2 => 'warning',
|
||||
3 => 'info',
|
||||
]);
|
||||
|
||||
$grid->column('remark', '处理结果');
|
||||
|
||||
$grid->column('created_at', '操作时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
83
app/Admin/Controllers/Activity/RuleController.php
Normal file
83
app/Admin/Controllers/Activity/RuleController.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Activity;
|
||||
|
||||
use App\Models\ActivityRule;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use RuLong\Identity\Models\Identity;
|
||||
|
||||
class RuleController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = '规则管理';
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new ActivityRule);
|
||||
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableView();
|
||||
});
|
||||
|
||||
$grid->column('id', '#ID#');
|
||||
$grid->column('title', '规则名称');
|
||||
$grid->column('code', '规则编号');
|
||||
$grid->column('full', '满足金额');
|
||||
$grid->column('take', '扣除金额');
|
||||
$grid->status('状态')->switch([
|
||||
'on' => ['value' => 1, 'text' => '正常', 'color' => 'primary'],
|
||||
'off' => ['value' => 0, 'text' => '关闭', 'color' => 'danger'],
|
||||
]);
|
||||
|
||||
$grid->column('created_at', '创建时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$form = new Form(new ActivityRule);
|
||||
|
||||
$form->text('title', '规则名称')->required();
|
||||
$form->text('code', '规则编号')->required()->help('列:YSD-full100-15');
|
||||
|
||||
$form->hidden('full', '满足金额')->required()->default(0);
|
||||
$form->hidden('take', '抵扣金额')->required()->default(0);
|
||||
|
||||
$form->switch('status', '状态')->default(1);
|
||||
$form->saving(function (Form $form) {
|
||||
if ($form->code) {
|
||||
$code = $form->code;
|
||||
|
||||
$ticket = explode('-', $code);
|
||||
if (!is_array($ticket) || count($ticket) != 3) {
|
||||
$error = new MessageBag([
|
||||
'title' => '错误',
|
||||
'message' => '规则编号格式错误',
|
||||
]);
|
||||
|
||||
return back()->withInput()->with(compact('error'));
|
||||
}
|
||||
|
||||
$full = $ticket[1]; //full100
|
||||
$price = $ticket[2];
|
||||
preg_match('/\d+/', $full, $match);
|
||||
|
||||
$form->full = $match[0];
|
||||
$form->take = $price;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
21
app/Admin/Controllers/Ajax/AreaController.php
Normal file
21
app/Admin/Controllers/Ajax/AreaController.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Ajax;
|
||||
|
||||
use App\Models\Area;
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AreaController
|
||||
{
|
||||
|
||||
public function children(Request $request)
|
||||
{
|
||||
$code = $request->get('q');
|
||||
|
||||
return Area::whereHas('parent', function ($q) use ($code) {
|
||||
$q->where('code', $code);
|
||||
})->get(['code as id', DB::raw('name as text')]);
|
||||
}
|
||||
|
||||
}
|
||||
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
|
||||
{
|
||||
|
||||
}
|
||||
160
app/Admin/Controllers/Coupon/IndexController.php
Normal file
160
app/Admin/Controllers/Coupon/IndexController.php
Normal file
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Coupon;
|
||||
|
||||
use App\Models\ActivityRule;
|
||||
use App\Models\Coupon;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
|
||||
class IndexController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = '卡券列表';
|
||||
|
||||
/**
|
||||
* Notes:
|
||||
* @Author: <C.Jason>
|
||||
* @Date : 2019/9/18 14:50
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Coupon);
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableBatchActions();
|
||||
$grid->disableActions();
|
||||
|
||||
$grid->model()
|
||||
->with(['outlet.province', 'outlet.city', 'outlet.district', 'user', 'user.info'])
|
||||
->whereIn('status', [2, 3])
|
||||
->orderBy('id', 'desc');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->equal('status', '状态')->select([
|
||||
'2' => '核销成功',
|
||||
'3' => '核销失败',
|
||||
]);
|
||||
$filter->between('created_at', '核销时间')->datetime();
|
||||
$users = User::whereHas('identity', function ($query) {
|
||||
$query->where('identity_id', 1);
|
||||
})->get()->pluck('nickname', 'id');
|
||||
|
||||
$filter->equal('user_id', '渠道')->select($users);
|
||||
$filter->equal('thirdPartyGoodsId', '优惠政策')->select(ActivityRule::pluck('title', 'code'));
|
||||
});
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->like('redemptionCode', '卡券编号');
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('outlet', function ($query) {
|
||||
$query->whereHas('info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
});
|
||||
}, '网点名称');
|
||||
|
||||
$filter->equal('type', '类型')->select(Coupon::TYPES);
|
||||
});
|
||||
});
|
||||
|
||||
$grid->column('id', '#ID#');
|
||||
$grid->column('渠道')->display(function () {
|
||||
return $this->user->nickname;
|
||||
});
|
||||
$grid->column('type', '类型')
|
||||
->using(Coupon::TYPES)
|
||||
->label([
|
||||
'1' => 'info',
|
||||
'2' => 'success',
|
||||
]);
|
||||
|
||||
$grid->column('网点名称/编号')->display(function () {
|
||||
return $this->outlet ? $this->outlet->nickname : $this->outletId;
|
||||
});
|
||||
|
||||
$grid->column('redemptionCode', '卡券编号');
|
||||
$grid->column('couponName', '优惠政策');
|
||||
$grid->column('price', '核销金额');
|
||||
$grid->column('total', '订单金额');
|
||||
|
||||
$grid->column('资金通道结算')->display(function () {
|
||||
$profit = $this->status == 2 ? $this->profit : '0.00';
|
||||
|
||||
return '<span style="color:red">' . $profit . '</span>';
|
||||
});
|
||||
$grid->column('状态')->display(function () {
|
||||
switch ($this->status) {
|
||||
case 2:
|
||||
return '<span style="color:green">' . $this->status_text . '</span>';
|
||||
break;
|
||||
case 3:
|
||||
return '<span style="color:red">' . $this->status_text . '</span>';
|
||||
break;
|
||||
default:
|
||||
return $this->status_text;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$grid->column('remark', '处理结果');
|
||||
$grid->column('startTime', '起始时间');
|
||||
$grid->column('endTime', '到期时间');
|
||||
$grid->column('created_at', '核销时间');
|
||||
$grid->column('省')->display(function () {
|
||||
return ($this->outlet && $this->outlet->province) ? $this->outlet->province->name : '';
|
||||
});
|
||||
|
||||
$grid->column('市')->display(function () {
|
||||
return ($this->outlet && $this->outlet->province) ? $this->outlet->city->name : '';
|
||||
});
|
||||
|
||||
$grid->column('区')->display(function () {
|
||||
return ($this->outlet && $this->outlet->province) ? $this->outlet->district->name : '';
|
||||
});
|
||||
|
||||
$grid->footer(function ($query) {
|
||||
// $all = $query->get();
|
||||
// $pass = $all->where('status', 2)->all();
|
||||
// $pass = collect($pass);
|
||||
$total = $query->count();
|
||||
$success = $query->where('status', 2)->count();
|
||||
$faield = $total - $success;
|
||||
|
||||
return '<label class="label label-success">全部:' . $total . '张</label> '
|
||||
. '<label class="label label-success">成功:' . $success . '张</label> '
|
||||
. '<label class="label label-success">失败:' . $faield . '张</label> '
|
||||
. '<label class="label label-success">核销金额:' . $query->sum('price') . '元</label> '
|
||||
. '<label class="label label-success">资金通道结算:' . $query->sum('profit') . '元</label> '
|
||||
. '<label class="label label-success">打款金额:' . $query->where('is_profit', 1)
|
||||
->sum('profit') . '元</label> ';
|
||||
});
|
||||
$grid->disableExport(false);
|
||||
|
||||
$grid->export(function ($export) {
|
||||
$export->column('状态', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->column('type', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->column('redemptionCode', function ($value, $original) {
|
||||
return $value . "\t";
|
||||
});
|
||||
// $export->column('price', function ($value, $original) {
|
||||
// return $value . "\t";
|
||||
// });
|
||||
// $export->column('total', function ($value, $original) {
|
||||
// return $value . "\t";
|
||||
// });
|
||||
$export->column('资金通道结算', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->filename('卡券列表' . date("YmdHis"));
|
||||
});
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
99
app/Admin/Controllers/Finance/CensusController.php
Normal file
99
app/Admin/Controllers/Finance/CensusController.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Finance;
|
||||
|
||||
use App\Models\AccountRule;
|
||||
use App\Models\ActivityRule;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Facades\Admin;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Layout\Content;
|
||||
|
||||
class CensusController extends AdminController
|
||||
{
|
||||
|
||||
protected $today = false;
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header('核销总数据')
|
||||
->description('description')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
/**
|
||||
* 今日核销数据
|
||||
* @param Content $content [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function today(Content $content)
|
||||
{
|
||||
$this->today = true;
|
||||
|
||||
return $content
|
||||
->header('核销今日数据')
|
||||
->description('description')
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new User);
|
||||
|
||||
$grid->model()
|
||||
->whereHas('identity', function ($q) {
|
||||
$q->where('identity_id', 1);
|
||||
});
|
||||
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableBatchActions();
|
||||
$grid->disableActions();
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
}, '渠道名称');
|
||||
});
|
||||
});
|
||||
|
||||
$grid->column('渠道')->display(function () {
|
||||
return $this->info->nickname;
|
||||
});
|
||||
|
||||
$today = $this->today;
|
||||
$rules = ActivityRule::get();
|
||||
|
||||
foreach ($rules as $rule) {
|
||||
$grid->column($rule->title)->display(function () use ($today, $rule) {
|
||||
return $this->getCouponCount($rule->code, $today);
|
||||
});
|
||||
}
|
||||
// $grid->column('100元减10元优惠券')->display(function () use ($today) {
|
||||
// return $this->getCouponCount('YSD-full100-10', $today);
|
||||
// });
|
||||
//
|
||||
// $grid->column('100元减25元优惠券')->display(function () use ($today) {
|
||||
// return $this->getCouponCount('YSD-full100-25', $today);
|
||||
// });
|
||||
// $grid->column('100元减50元优惠券')->display(function () use ($today) {
|
||||
// return $this->getCouponCount('YSD-full100-50', $today);
|
||||
// });
|
||||
//
|
||||
// $grid->column(' 200元减100元优惠券')->display(function () use ($today) {
|
||||
// return $this->getCouponCount('YSD-full200-100', $today);
|
||||
// });
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
160
app/Admin/Controllers/Finance/IndexController.php
Normal file
160
app/Admin/Controllers/Finance/IndexController.php
Normal file
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Finance;
|
||||
|
||||
use App\Admin\Actions\Coupon\Batch;
|
||||
use App\Admin\Actions\Coupon\BatchProfit;
|
||||
use App\Admin\Actions\Coupon\BatchProfits;
|
||||
use App\Models\Coupon;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
|
||||
class IndexController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = '平安渠道打款处理';
|
||||
|
||||
/**
|
||||
* Notes:
|
||||
* @Author: <C.Jason>
|
||||
* @Date : 2019/9/18 14:50
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Coupon);
|
||||
$grid->model()->with(['outlet', 'user', 'user.info'])->where('profit', '>', 0);
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableBatchActions(false);
|
||||
|
||||
$grid->tools(function (Grid\Tools $tools) {
|
||||
$tools->append(new Batch);
|
||||
$tools->batch(function ($batch) {
|
||||
$batch->disableDelete();
|
||||
$batch->add(new BatchProfits);
|
||||
});
|
||||
});
|
||||
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
$actions->disableView();
|
||||
$actions->disableEdit();
|
||||
$actions->disableDelete();
|
||||
if ($actions->row->canProfit()) {
|
||||
$actions->add(new BatchProfit);
|
||||
}
|
||||
});
|
||||
|
||||
$grid->model()->where('status', 2)->orderBy('id', 'desc');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->equal('is_profit', '打款')->select([
|
||||
'0' => '未打款',
|
||||
'1' => '已打款',
|
||||
]);
|
||||
$filter->between('created_at', '核销时间')->datetime();
|
||||
$filter->between('paid_at', '打款时间')->datetime();
|
||||
$users = User::query()
|
||||
->whereHas('identity', function ($query) {
|
||||
$query->where('identity_id', 1);
|
||||
})
|
||||
->get()
|
||||
->pluck('nickname', 'id');
|
||||
|
||||
$filter->equal('user_id', '渠道')->select($users);
|
||||
});
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->like('redemptionCode', '平安券编号');
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('outlet', function ($query) {
|
||||
$query->whereHas('info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
});
|
||||
}, '渠道名称');
|
||||
});
|
||||
});
|
||||
|
||||
$grid->column('id', '#ID#');
|
||||
$grid->column('渠道')->display(function () {
|
||||
return $this->user->nickname;
|
||||
});
|
||||
|
||||
$grid->column('网点名称/编号')->display(function () {
|
||||
return $this->outlet ? $this->outlet->nickname : $this->outletId;
|
||||
});
|
||||
|
||||
$grid->column('redemptionCode', '平安券编号');
|
||||
$grid->column('couponName', '优惠政策');
|
||||
$grid->column('price', '核销金额');
|
||||
$grid->column('profit', '资金通道结算');
|
||||
|
||||
$grid->column('状态')->display(function () {
|
||||
switch ($this->status) {
|
||||
case 2:
|
||||
return '<span style="color:green">' . $this->status_text . '</span>';
|
||||
break;
|
||||
case 3:
|
||||
return '<span style="color:red">' . $this->status_text . '</span>';
|
||||
break;
|
||||
default:
|
||||
return $this->status_text;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$grid->column('打款')->display(function () {
|
||||
switch ($this->is_profit) {
|
||||
case 0:
|
||||
return '<span style="color:green">未打款</span>';
|
||||
break;
|
||||
case 1:
|
||||
return '<span style="color:red">已打款</span>';
|
||||
break;
|
||||
default:
|
||||
return '未知';
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$grid->column('paid_at', '打款时间');
|
||||
$grid->column('created_at', '核销时间');
|
||||
|
||||
$grid->footer(function ($query) {
|
||||
$total = $query->count();
|
||||
$success = $query->where('status', 2)->count();
|
||||
$faield = $total - $success;
|
||||
|
||||
return '<label class="label label-success">全部:' . $total . '张</label> '
|
||||
. '<label class="label label-success">核销金额:' . $query->sum('price') . '元</label> '
|
||||
. '<label class="label label-success">资金通道结算:' . $query->sum('profit') . '元</label> '
|
||||
. '<label class="label label-success">打款金额:' . $query->where('is_profit', 1)
|
||||
->sum('profit') . '元</label> ';
|
||||
});
|
||||
|
||||
$grid->disableExport(false);
|
||||
|
||||
$grid->export(function ($export) {
|
||||
$export->column('状态', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->column('打款', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->column('redemptionCode', function ($value, $original) {
|
||||
return $value . "\t";
|
||||
});
|
||||
$export->column('price', function ($value, $original) {
|
||||
return $value . "\t";
|
||||
});
|
||||
$export->column('profit', function ($value, $original) {
|
||||
return strip_tags($value) . "\t";
|
||||
});
|
||||
$export->filename('平安渠道打款处理' . date("YmdHis"));
|
||||
});
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
110
app/Admin/Controllers/Finance/LogController.php
Normal file
110
app/Admin/Controllers/Finance/LogController.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Finance;
|
||||
|
||||
use App\Admin\Exporters\CouponProfitExport;
|
||||
use App\Models\Coupon;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
|
||||
class LogController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = '已打款记录';
|
||||
|
||||
/**
|
||||
* Notes:
|
||||
* @Author: <C.Jason>
|
||||
* @Date : 2019/9/18 14:50
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Coupon);
|
||||
$grid->model()->where('profit', '>', 0);
|
||||
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableBatchActions();
|
||||
$grid->disableActions();
|
||||
|
||||
$grid->model()->where('is_profit', 1)->orderBy('id', 'desc');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->between('paid_at', '打款时间')->datetime();
|
||||
$users = User::query()
|
||||
->whereHas('identity', function ($query) {
|
||||
$query->where('identity_id', 1);
|
||||
})
|
||||
->get()
|
||||
->pluck('nickname', 'id');
|
||||
$filter->equal('user_id', '渠道')->select($users);
|
||||
});
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->like('redemptionCode', '平安券编号');
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('outlet', function ($query) {
|
||||
$query->whereHas('info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
});
|
||||
}, '网点名称');
|
||||
});
|
||||
});
|
||||
|
||||
$grid->column('id', '#ID#');
|
||||
$grid->column('渠道')->display(function () {
|
||||
return $this->user->nickname;
|
||||
});
|
||||
|
||||
$grid->column('网点名称/编号')->display(function () {
|
||||
return $this->outlet ? $this->outlet->nickname : $this->outletId;
|
||||
});
|
||||
|
||||
$grid->column('redemptionCode', '平安券编号');
|
||||
$grid->column('couponName', '优惠政策');
|
||||
$grid->column('price', '核销金额');
|
||||
$grid->column('profit', '资金通道结算');
|
||||
|
||||
$grid->column('paid_at', '打款时间');
|
||||
|
||||
$grid->footer(function ($query) {
|
||||
$all = $query->get();
|
||||
$pass = $query->where('status', 2)->get();
|
||||
$reject = $query->where('status', 3)->get();
|
||||
|
||||
return '<label class="label label-success">全部:' . $all->count() . '张</label> '
|
||||
. '<label class="label label-success">核销金额:' . $pass->sum('price') . '元</label> '
|
||||
. '<label class="label label-success">资金通道结算:' . $pass->sum('profit') . '元</label> '
|
||||
. '<label class="label label-success">打款金额:' . $pass->where('is_profit', 1)
|
||||
->sum('profit') . '元</label> ';
|
||||
});
|
||||
$grid->disableExport(false);
|
||||
|
||||
$grid->export(function ($export) {
|
||||
$export->column('状态', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->column('打款', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->column('redemptionCode', function ($value, $original) {
|
||||
return $value . "\t";
|
||||
});
|
||||
$export->column('网点名称/编号', function ($value, $original) {
|
||||
return $value . "\t";
|
||||
});
|
||||
$export->column('price', function ($value, $original) {
|
||||
return $value . "\t";
|
||||
});
|
||||
$export->column('profit', function ($value, $original) {
|
||||
return strip_tags($value) . "\t";
|
||||
});
|
||||
$export->filename('已打款记录' . date("YmdHis"));
|
||||
});
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
204
app/Admin/Controllers/HomeController.php
Normal file
204
app/Admin/Controllers/HomeController.php
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Coupon;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Layout\Column;
|
||||
use Encore\Admin\Layout\Content;
|
||||
use Encore\Admin\Layout\Row;
|
||||
use Encore\Admin\Widgets\InfoBox;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
|
||||
public function index(Content $content)
|
||||
{
|
||||
|
||||
return $content
|
||||
->title('数据看版3')
|
||||
->row(function (Row $row) {
|
||||
$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(function (Row $row) {
|
||||
$row->column(2, function (Column $column) {
|
||||
$column->append(new InfoBox(
|
||||
'核销卡券总数',
|
||||
'',
|
||||
'blue',
|
||||
'/admin/coupons',
|
||||
Coupon::whereIn('status', [2, 3])->count()
|
||||
));
|
||||
});
|
||||
$row->column(2, function (Column $column) {
|
||||
$column->append(new InfoBox(
|
||||
'核销成功',
|
||||
'',
|
||||
'blue',
|
||||
'/admin/coupons',
|
||||
Coupon::where('status', 2)->count()
|
||||
));
|
||||
});
|
||||
$row->column(2, function (Column $column) {
|
||||
$column->append(new InfoBox(
|
||||
'核销失败',
|
||||
'',
|
||||
'black',
|
||||
'/admin/coupons',
|
||||
Coupon::where('status', 3)->count()
|
||||
));
|
||||
});
|
||||
$row->column(2, function (Column $column) {
|
||||
$column->append(new InfoBox(
|
||||
'资金通道结算',
|
||||
'',
|
||||
'red',
|
||||
'/admin/coupons',
|
||||
Coupon::where('status', 2)->sum('price')
|
||||
));
|
||||
});
|
||||
$row->column(2, function (Column $column) {
|
||||
$column->append(new InfoBox(
|
||||
'应打款金额',
|
||||
'',
|
||||
'green',
|
||||
'/admin/coupons',
|
||||
Coupon::where('status', 2)->sum('profit')
|
||||
));
|
||||
});
|
||||
$row->column(2, function (Column $column) {
|
||||
$column->append(new InfoBox(
|
||||
'已打款金额',
|
||||
'',
|
||||
'green',
|
||||
'/admin/coupons',
|
||||
Coupon::where('status', 2)
|
||||
->where('is_profit', 1)
|
||||
->sum('profit')
|
||||
));
|
||||
});
|
||||
})
|
||||
->row(function (Row $row) {
|
||||
|
||||
$lists = [
|
||||
'ysd10' => Coupon::where('status', 2)
|
||||
->whereDate('created_at', now()->format('Y-m-d'))
|
||||
->where('thirdPartyGoodsId', 'YSD-full100-10')
|
||||
->count(),
|
||||
'ysd25' => Coupon::where('status', 2)
|
||||
->whereDate('created_at', now()->format('Y-m-d'))
|
||||
->where('thirdPartyGoodsId', 'YSD-full100-25')
|
||||
->count(),
|
||||
'ysd50' => Coupon::where('status', 2)
|
||||
->whereDate('created_at', now()->format('Y-m-d'))
|
||||
->where('thirdPartyGoodsId', 'YSD-full100-50')
|
||||
->count(),
|
||||
'ysd100' => Coupon::where('status', 2)
|
||||
->whereDate('created_at', now()->format('Y-m-d'))
|
||||
->where('thirdPartyGoodsId', 'YSD-full200-100')
|
||||
->count(),
|
||||
];
|
||||
|
||||
$row->column(2, function (Column $column) use ($lists) {
|
||||
$column->append(new InfoBox(
|
||||
'100元减10元成功今日总数',
|
||||
'',
|
||||
'blue',
|
||||
'/admin/coupons',
|
||||
$lists['ysd10']
|
||||
));
|
||||
});
|
||||
|
||||
$row->column(2, function (Column $column) use ($lists) {
|
||||
$column->append(new InfoBox(
|
||||
'100元减25元成功今日总数',
|
||||
'',
|
||||
'blue',
|
||||
'/admin/coupons',
|
||||
$lists['ysd25']
|
||||
));
|
||||
});
|
||||
|
||||
$row->column(2, function (Column $column) use ($lists) {
|
||||
$column->append(new InfoBox(
|
||||
'100元减50元成功今日总数',
|
||||
'',
|
||||
'blue',
|
||||
'/admin/coupons',
|
||||
$lists['ysd50']
|
||||
));
|
||||
});
|
||||
|
||||
$row->column(2, function (Column $column) use ($lists) {
|
||||
$column->append(new InfoBox(
|
||||
'200元减100元成功今日总数',
|
||||
'',
|
||||
'blue',
|
||||
'/admin/coupons',
|
||||
$lists['ysd100']
|
||||
));
|
||||
});
|
||||
})
|
||||
->row(function (Row $row) {
|
||||
|
||||
$lists = [
|
||||
'ysd10' => Coupon::where('status', 2)->where('thirdPartyGoodsId', 'YSD-full100-10')->count(),
|
||||
'ysd25' => Coupon::where('status', 2)->where('thirdPartyGoodsId', 'YSD-full100-25')->count(),
|
||||
'ysd50' => Coupon::where('status', 2)->where('thirdPartyGoodsId', 'YSD-full100-50')->count(),
|
||||
'ysd100' => Coupon::where('status', 2)->where('thirdPartyGoodsId', 'YSD-full200-100')->count(),
|
||||
];
|
||||
|
||||
$row->column(2, function (Column $column) use ($lists) {
|
||||
$column->append(new InfoBox(
|
||||
'100元减10元成功总数',
|
||||
'',
|
||||
'blue',
|
||||
'/admin/coupons',
|
||||
$lists['ysd10']
|
||||
));
|
||||
});
|
||||
|
||||
$row->column(2, function (Column $column) use ($lists) {
|
||||
$column->append(new InfoBox(
|
||||
'100元减25元成功总数',
|
||||
'',
|
||||
'blue',
|
||||
'/admin/coupons',
|
||||
$lists['ysd25']
|
||||
));
|
||||
});
|
||||
|
||||
$row->column(2, function (Column $column) use ($lists) {
|
||||
$column->append(new InfoBox(
|
||||
'100元减50元成功总数',
|
||||
'',
|
||||
'blue',
|
||||
'/admin/coupons',
|
||||
$lists['ysd50']
|
||||
));
|
||||
});
|
||||
|
||||
$row->column(2, function (Column $column) use ($lists) {
|
||||
$column->append(new InfoBox(
|
||||
'200元减100元成功总数',
|
||||
'',
|
||||
'blue',
|
||||
'/admin/coupons',
|
||||
$lists['ysd100']
|
||||
));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
84
app/Admin/Controllers/IdentityController.php
Normal file
84
app/Admin/Controllers/IdentityController.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Widgets\Table;
|
||||
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 ($title, $column) {
|
||||
return '点击查看';
|
||||
})->modal(function ($model) {
|
||||
$codes = $model->codes->map(function ($code) {
|
||||
return $code->only(['name', 'code', 'profit']);
|
||||
});
|
||||
|
||||
return new Table(['名称', '规则项', '分润金额(元)'], $codes->toArray());
|
||||
});
|
||||
|
||||
$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->hasMany('codes', '分润项目', function (Form\NestedForm $form) {
|
||||
$form->text('name', '标题');
|
||||
$form->text('code', '分润的项目');
|
||||
$form->text('profit', '分润金额');
|
||||
});
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
}
|
||||
106
app/Admin/Controllers/Log/IndexController.php
Normal file
106
app/Admin/Controllers/Log/IndexController.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Log;
|
||||
|
||||
use App\Admin\Renderable\Log\InData;
|
||||
use App\Admin\Renderable\Log\OutData;
|
||||
use App\Models\Log;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Widgets\Table;
|
||||
|
||||
class IndexController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = 'api接口日志';
|
||||
|
||||
/**
|
||||
* Notes:
|
||||
* @Author: <C.Jason>
|
||||
* @Date : 2019/9/18 14:50
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new Log);
|
||||
$grid->model()->orderBy('id', 'desc');
|
||||
|
||||
$grid->disableActions();
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->equal('type', '接口类型')->select(Log::TYPES);
|
||||
$filter->where(function ($query) {
|
||||
$query->where("out_source->data->profitOfferItemVersion", $this->input);
|
||||
}, '券类型')->select([
|
||||
1 => '新版',
|
||||
0 => '老版',
|
||||
]);
|
||||
$filter->where(function ($query) {
|
||||
$query->where("in_source->query->redemptionCode", $this->input)
|
||||
->orWhere("in_source->jiemi->redemptionCode", $this->input);
|
||||
}, '券码');
|
||||
$filter->where(function ($query) {
|
||||
$query->Where("in_source->jiemi->outletId", $this->input);
|
||||
}, '网点编号');
|
||||
|
||||
$filter->between('created_at', '提交时间')->datetime();
|
||||
|
||||
// $filter->equal('created_at', '提交时间')->date();
|
||||
});
|
||||
|
||||
$grid->column('id', '#ID#');
|
||||
|
||||
// $grid->column('path', '请求地址');
|
||||
$grid->column('请求地址')->display(function ($title, $column) {
|
||||
return '展开';
|
||||
})->expand(function ($model) {
|
||||
$header = ['请求地址'];
|
||||
$array = [[$model->path]];
|
||||
|
||||
return new Table($header, $array);
|
||||
});
|
||||
$grid->column('created_at', '提交时间');
|
||||
|
||||
$grid->column('method', '模式');
|
||||
// $grid->column('in_source', '请求参数')
|
||||
// ->display(function ($title, $column) {
|
||||
// return '点击展开';
|
||||
// })->modal(InData::class);
|
||||
//
|
||||
// $grid->column('out_source', '返回参数')
|
||||
// ->display(function ($title, $column) {
|
||||
// return '点击展开';
|
||||
// })->modal(OutData::class);
|
||||
$grid->column('请求参数')->display(function () {
|
||||
$in_source = $this->in_source;
|
||||
unset($in_source['merchantSign']);
|
||||
unset($in_source['merchantCert']);
|
||||
unset($in_source['sign']);
|
||||
unset($in_source['data']);
|
||||
unset($in_source['json']);
|
||||
unset($in_source['query']['merchantSign']);
|
||||
unset($in_source['query']['merchantCert']);
|
||||
|
||||
return $in_source;
|
||||
});
|
||||
$grid->column('返回信息')->display(function () {
|
||||
$out_source = $this->out_source;
|
||||
|
||||
if (!is_array($out_source)) {
|
||||
return $out_source;
|
||||
}
|
||||
unset($out_source['merchantSign']);
|
||||
unset($out_source['merchantCert']);
|
||||
unset($out_source['serverCert']);
|
||||
unset($out_source['serverSign']);
|
||||
if (isset($out_source['data']) && is_string($out_source['data'])) {
|
||||
unset($out_source['data']);
|
||||
}
|
||||
|
||||
return $out_source;
|
||||
});
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
72
app/Admin/Controllers/TestController.php
Normal file
72
app/Admin/Controllers/TestController.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\Coupon;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class TestController
|
||||
{
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$date = $request->date ?? date('Y-m-d');
|
||||
$time = Carbon::parse($date);
|
||||
|
||||
$all = Coupon::where('status', 2)
|
||||
->whereBetween('created_at', [
|
||||
$time->startOfDay()->toDateTimeString(),
|
||||
$time->endOfDay()->toDateTimeString(),
|
||||
])
|
||||
->count();
|
||||
$self = Coupon::where('status', 2)
|
||||
->where('type', Coupon::TYPE_YSD)
|
||||
->whereBetween('created_at', [
|
||||
$time->startOfDay()->toDateTimeString(),
|
||||
$time->endOfDay()->toDateTimeString(),
|
||||
])
|
||||
->count();
|
||||
$pingan = Coupon::where('status', 2)
|
||||
->where('type', Coupon::TYPE_PINGAN)
|
||||
->whereBetween('created_at', [
|
||||
$time->startOfDay()->toDateTimeString(),
|
||||
$time->endOfDay()->toDateTimeString(),
|
||||
])
|
||||
->count();
|
||||
|
||||
$error = Coupon::where('status', 3)
|
||||
->whereBetween('created_at', [
|
||||
$time->startOfDay()->toDateTimeString(),
|
||||
$time->endOfDay()->toDateTimeString(),
|
||||
])
|
||||
->count();
|
||||
|
||||
$lists = DB::table('coupons')
|
||||
->where('status', 2)
|
||||
->whereBetween('created_at', [
|
||||
$time->startOfDay()->toDateTimeString(),
|
||||
$time->endOfDay()->toDateTimeString(),
|
||||
])
|
||||
->select('redemptionCode', DB::raw('COUNT(*) as code_count'))
|
||||
->groupBy('redemptionCode')
|
||||
->having('code_count', '>', 1)
|
||||
->get();
|
||||
|
||||
$data = [
|
||||
' 日期为:' . $time->format('Y-m-d'),
|
||||
' 核销总数为:' . $all,
|
||||
' 自有卡券总数为:' . $self,
|
||||
' 平安卡券总数为:' . $pingan,
|
||||
' 核销错误总数为:' . $error,
|
||||
' 核销重复数据数为:' . $lists->count(),
|
||||
];
|
||||
|
||||
foreach ($data as $info) {
|
||||
dump($info);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
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];
|
||||
}
|
||||
}
|
||||
279
app/Admin/Controllers/User/IndexController.php
Normal file
279
app/Admin/Controllers/User/IndexController.php
Normal file
@@ -0,0 +1,279 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\User;
|
||||
|
||||
use App\Admin\Actions\User\Callback;
|
||||
use App\Admin\Actions\User\Profit;
|
||||
use App\Admin\Actions\User\ReCode;
|
||||
use App\Admin\Actions\User\RefD3Key;
|
||||
use App\Admin\Renderable\User\Rule;
|
||||
use App\Admin\Renderable\User\ServerKey;
|
||||
use App\Models\Area;
|
||||
use App\Models\User;
|
||||
use Auth;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Widgets\Table;
|
||||
use Illuminate\Http\Request;
|
||||
use RuLong\Identity\Models\Identity;
|
||||
|
||||
class IndexController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = '用户管理';
|
||||
|
||||
/**
|
||||
* Notes:
|
||||
* @Author: <C.Jason>
|
||||
* @Date : 2019/9/18 14:50
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$user = Auth::guard('admin')->user();
|
||||
$grid = new Grid(new User);
|
||||
$grid->model()->with(['parent']);
|
||||
$grid->actions(function ($actions) use ($user) {
|
||||
$actions->disableDelete();
|
||||
$actions->disableView();
|
||||
|
||||
if ($actions->row->identity_id == 1) {
|
||||
$actions->add(new RefD3Key);
|
||||
$actions->add(new ReCode);
|
||||
$actions->add(new Callback);
|
||||
}
|
||||
|
||||
if ($actions->row->identity_id == 1 && $user->id == 1) {
|
||||
$actions->add(new Profit);
|
||||
}
|
||||
});
|
||||
|
||||
$grid->tools(function (Grid\Tools $tools) {
|
||||
// $tools->append(new UserImport);
|
||||
});
|
||||
|
||||
$grid->model()->orderBy('id', 'desc');
|
||||
|
||||
$grid->quickSearch('username')->placeholder('登录账户');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->like('username', '登录账户');
|
||||
$filter->like('server_id', '渠道编号');
|
||||
$filter->like('outlet_id', '网点编号');
|
||||
$filter->like('PaOutletId', '平安网点id');
|
||||
$filter->between('created_at', '注册时间')->datetime();
|
||||
});
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->like('info.nickname', '渠道/网点');
|
||||
$filter->like('server_key', '服务秘钥');
|
||||
$filter->equal('identity.identity_id', '用户身份')->select([
|
||||
' ' => '全部',
|
||||
'1' => '渠道商',
|
||||
'2' => '网点',
|
||||
]);
|
||||
$filter->equal('type', '所属项目')->select([
|
||||
' ' => '全部',
|
||||
'pingan' => '平安券',
|
||||
'wo' => '沃支付',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
$grid->column('id', '#ID#');
|
||||
$grid->column('username', '登录账户');
|
||||
$grid->column('渠道编号')->display(function () {
|
||||
return $this->server_id;
|
||||
});
|
||||
$grid->column('网点编号')->display(function () {
|
||||
return $this->outlet_id ?? '---';
|
||||
});
|
||||
|
||||
$grid->column('平安网点id')->display(function () {
|
||||
return $this->PaOutletId ?? '---';
|
||||
});
|
||||
|
||||
$grid->column('所属项目')->display(function () {
|
||||
return $this->type_text;
|
||||
});
|
||||
|
||||
$grid->column('回调地址')->display(function ($title, $column) {
|
||||
return '点击查看';
|
||||
})->modal(function ($model) {
|
||||
$data = [
|
||||
[
|
||||
$this->callback,
|
||||
],
|
||||
];
|
||||
|
||||
return new Table(['url'], $data);
|
||||
|
||||
});
|
||||
|
||||
$grid->column('密钥')->display(function ($title, $column) {
|
||||
return '点击查看';
|
||||
})->modal(ServerKey::class);
|
||||
|
||||
$grid->column('nickname', '渠道/网点');
|
||||
$grid->column('用户身份')->display(function () {
|
||||
if ($this->identity_id == 1) {
|
||||
return "<p style='color:green'>" . $this->identity_text . "</p>";
|
||||
} else {
|
||||
return $this->identity_text;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$grid->column('隶属渠道')->display(function () {
|
||||
return $this->parent ? $this->parent->nickname : '---';
|
||||
});
|
||||
|
||||
$grid->column('分润规则')->display(function ($title, $column) {
|
||||
return '点击展开';
|
||||
})->modal(Rule::class);
|
||||
|
||||
$grid->column('created_at', '注册时间');
|
||||
$grid->disableExport(false);
|
||||
|
||||
$grid->export(function ($export) {
|
||||
$export->except(['密钥', '分润规则', '回调地址']);
|
||||
$export->column('用户身份', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->column('渠道编号', function ($value, $original) {
|
||||
return $value . "\t";
|
||||
});
|
||||
$export->column('网点编号', function ($value, $original) {
|
||||
return $value . "\t";
|
||||
});
|
||||
$export->filename($this->title . date("YmdHis"));
|
||||
});
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:
|
||||
* @Author: <C.Jason>
|
||||
* @Date : 2019/9/18 14:50
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
$province = Area::where('parent_id', 1)->pluck('name', 'code');
|
||||
|
||||
$form = new Form(new User);
|
||||
$identity = Identity::find(1);
|
||||
|
||||
$form->text('username', '登录账户')
|
||||
->creationRules(['required', "unique:users", 'max:11'], ['max' => '小于11个字符'])
|
||||
->updateRules(['required', "unique:users,username,{{id}}"])->required();
|
||||
|
||||
$form->password('password', '登录密码')
|
||||
->creationRules('required|min:6', [
|
||||
'required' => '必填',
|
||||
'min' => '密码不能少于6个字符',
|
||||
]);
|
||||
|
||||
$form->text('PaOutletId', '平安网点id');
|
||||
|
||||
$form->select('type', '项目')
|
||||
->options(['pingan' => '平安券和自有券', 'wo' => '沃支付'])
|
||||
->load('parent_id', '/admin/user/parent')
|
||||
->required();
|
||||
|
||||
$form->select('parent_id', '隶属渠道')
|
||||
->options(function ($option, $info) {
|
||||
$user = $this;
|
||||
if (!$option || ($user && $user->identity_id == 2)) {
|
||||
return User::with('info')->whereHas('identity', function ($q) {
|
||||
$q->where('identity_id', 1);
|
||||
})->when(isset($user->id), function ($q) use ($user) {
|
||||
$q->where('type', $user->type);
|
||||
})->orderBy('id', 'desc')->get()->pluck('nickname', 'id');
|
||||
} else {
|
||||
return [0 => '没有隶属渠道'];
|
||||
}
|
||||
})
|
||||
->default(function ($info) {
|
||||
if ($info->model() && $info->model()->parent) {
|
||||
return $info->model()->parent_id;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
})
|
||||
->help('未选择隶属渠道创建渠道账号,选择隶属渠道创建网点账号');
|
||||
|
||||
$form->select('province_id', '行政省份')
|
||||
->options($province)
|
||||
->load('city_id', '/admin/ajax/areas/children')
|
||||
->required();
|
||||
|
||||
$form->select('city_id', '行政城市')->options(function ($option, $info) {
|
||||
if ($option) {
|
||||
return Area::whereHas('parent', function ($q) use ($info) {
|
||||
$q->where('code', $this->province_id);
|
||||
})->pluck('name', 'code');
|
||||
}
|
||||
})->load('district_id', '/admin/ajax/areas/children')->required();
|
||||
|
||||
$form->select('district_id', '行政区域')->options(function ($option, $info) {
|
||||
if ($option) {
|
||||
return Area::whereHas('parent', function ($q) use ($info) {
|
||||
$q->where('code', $this->city_id);
|
||||
})->pluck('name', 'code');
|
||||
}
|
||||
})->required();
|
||||
|
||||
$form->divider('用户资料');
|
||||
$form->text('info.nickname', '渠道/网点')->placeholder('请输入渠道/网点名称')->required();
|
||||
|
||||
$form->saved(function (Form $form) {
|
||||
$user_id = $form->model()->id;
|
||||
$user = User::find($user_id);
|
||||
if ($user->identity_id == 1 && $user->code()->count() === 0) {
|
||||
$userCodes = Identity::find(1)->codes->map(function ($code) {
|
||||
return $code->only(['name', 'code', 'profit']);
|
||||
});
|
||||
$user->code()->createMany($userCodes);
|
||||
}
|
||||
|
||||
if ($user->parent_id) {
|
||||
if ($user->server_id != $user->parent->server_id) {
|
||||
$user->server_id = $user->parent->server_id;
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取隶属
|
||||
* @author 玄尘 2020-03-12
|
||||
* @param Request $request [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getParent(Request $request)
|
||||
{
|
||||
$type = $request->get('q');
|
||||
|
||||
$users = User::whereHas('identity', function ($query) {
|
||||
$query->where('identity_id', 1);
|
||||
})->get();
|
||||
|
||||
$userRet = $users->map(function ($code) {
|
||||
return [
|
||||
'id' => $code->id,
|
||||
'text' => $code->info->nickname,
|
||||
];
|
||||
});
|
||||
$userRet->prepend(['id' => '', 'text' => '']);
|
||||
|
||||
return $userRet;
|
||||
}
|
||||
|
||||
}
|
||||
151
app/Admin/Controllers/Wo/IndexController.php
Normal file
151
app/Admin/Controllers/Wo/IndexController.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Wo;
|
||||
|
||||
use App\Admin\Actions\Wo\Unsubscribe;
|
||||
use App\Admin\Exporters\WoCouponExport;
|
||||
use App\Models\User;
|
||||
use App\Models\WoCoupon;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
use Encore\Admin\Widgets\Table;
|
||||
|
||||
class IndexController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = '沃钱包业务';
|
||||
|
||||
/**
|
||||
* Notes:
|
||||
* @Author: <C.Jason>
|
||||
* @Date : 2019/9/18 14:50
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$grid = new Grid(new WoCoupon);
|
||||
$grid->model()->with(['user']);
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableBatchActions();
|
||||
// $grid->disableActions();
|
||||
|
||||
$grid->model()->whereIn('status', [1, 2, 3])->orderBy('id', 'desc');
|
||||
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableDelete();
|
||||
$actions->disableView();
|
||||
$actions->disableEdit();
|
||||
|
||||
if ($actions->row->status == 1 && $actions->row->service == 'ticketGrant') {
|
||||
$actions->add(new Unsubscribe);
|
||||
}
|
||||
});
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->equal('status', '状态')->select([
|
||||
'1' => '成功',
|
||||
'2' => '失败',
|
||||
'3' => '退订',
|
||||
]);
|
||||
$filter->equal('service', '业务')->select([
|
||||
'ticketGrant' => '发券请求',
|
||||
'ticketBuyback' => '返销请求',
|
||||
'ticketInvalid' => '作废请求',
|
||||
]);
|
||||
$filter->like('mobile', '手机号');
|
||||
$filter->like('logNo', '发券流水号');
|
||||
});
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->like('number', '工号');
|
||||
$users = User::query()
|
||||
->whereHas('identity', function ($query) {
|
||||
$query->where('identity_id', 1);
|
||||
})
|
||||
->where('type', 'wo')
|
||||
->get()
|
||||
->pluck('nickname', 'id');
|
||||
$filter->equal('user_id', '渠道')->select($users);
|
||||
$filter->equal('activityId', '活动')->select([
|
||||
'97LJ202025' => '25元兑换券',
|
||||
'97LJ202010' => '100元兑换券',
|
||||
'97LJ202018' => '180元话费券',
|
||||
]);
|
||||
$filter->between('created_at', '处理时间')->datetime();
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
$grid->column('id', '#ID#');
|
||||
$grid->column('渠道')->display(function () {
|
||||
return $this->user->nickname;
|
||||
});
|
||||
|
||||
$grid->column('number', '工号');
|
||||
|
||||
$grid->column('业务')->display(function () {
|
||||
return $this->service_text;
|
||||
});
|
||||
|
||||
$grid->column('活动')->display(function () {
|
||||
return $this->activity_text;
|
||||
});
|
||||
$grid->column('mobile', '手机号')->display(function ($title, $column) {
|
||||
return $this->mobile;
|
||||
})->modal(function ($model) {
|
||||
$datas = $model->logs->map(function ($data) {
|
||||
return [
|
||||
'mobile' => $data->mobile,
|
||||
'service_text' => $data->coupon->service_text ?? '---',
|
||||
'activity_text' => $data->coupon->activity_text ?? '---',
|
||||
'status_text' => $data->coupon->status_text ?? '---',
|
||||
'created_at' => $data->created_at,
|
||||
];
|
||||
});
|
||||
|
||||
return new Table(['手机号', '业务', '活动', '结果', '时间'], $datas->toArray());
|
||||
|
||||
});
|
||||
$grid->column('ticketAmt', '电子券面值');
|
||||
$grid->column('status', '状态')->display(function () {
|
||||
switch ($this->status) {
|
||||
case 1:
|
||||
return "<span class='label label-success' >" . $this->status_text . "</span>";
|
||||
break;
|
||||
case 2:
|
||||
return "<span class='label label-warning' >" . $this->status_text . "</span>";
|
||||
break;
|
||||
case 3:
|
||||
return "<span class='label label-primary' >" . $this->status_text . "</span>";
|
||||
break;
|
||||
default:
|
||||
return $this->status_text;
|
||||
break;
|
||||
}
|
||||
});
|
||||
$grid->column('remark', '处理结果');
|
||||
$grid->column('原发放流水')->display(function () {
|
||||
return $this->ologNo ?? '---';
|
||||
});
|
||||
$grid->column('logNo', '发券流水号');
|
||||
$grid->column('created_at', '处理时间');
|
||||
$grid->disableExport(false);
|
||||
|
||||
$grid->export(function ($export) {
|
||||
$export->column('status', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->column('mobile', function ($value, $original) {
|
||||
return $original . "\t";
|
||||
});
|
||||
$export->column('ticketAmt', function ($value, $original) {
|
||||
return $value . "\t";
|
||||
});
|
||||
|
||||
$export->filename('沃钱包业务' . date("YmdHis"));
|
||||
});
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
40
app/Admin/Exporters/CouponExport.php
Normal file
40
app/Admin/Exporters/CouponExport.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Exporters;
|
||||
|
||||
use Encore\Admin\Grid\Exporters\ExcelExporter;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class CouponExport extends ExcelExporter implements WithMapping
|
||||
{
|
||||
|
||||
protected $headings = ['渠道', '网点名称/编号', '订单号', '平安券编号', '优惠政策', '核销金额', '资金通道结算', '状态', '处理结果', '起始时间', '到期时间', '核销时间', '省', '市', '区'];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->fileName = '卡券记录' . date('YmdHis') . '.xlsx';
|
||||
}
|
||||
|
||||
public function map($info): array
|
||||
{
|
||||
$data = [
|
||||
$info->user->nickname,
|
||||
$info->outlet ? $info->outlet->nickname : $info->outletId,
|
||||
' ' . $info->redemptionCode,
|
||||
$info->couponName,
|
||||
$info->price,
|
||||
$info->profit,
|
||||
$info->status_text,
|
||||
$info->remark,
|
||||
$info->startTime,
|
||||
$info->endTime,
|
||||
$info->created_at,
|
||||
($info->outlet && $info->outlet->province) ? $info->outlet->province->name : '',
|
||||
($info->outlet && $info->outlet->province) ? $info->outlet->city->name : '',
|
||||
($info->outlet && $info->outlet->province) ? $info->outlet->district->name : '',
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
40
app/Admin/Exporters/CouponPassExport.php
Normal file
40
app/Admin/Exporters/CouponPassExport.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Exporters;
|
||||
|
||||
use Encore\Admin\Grid\Exporters\ExcelExporter;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class CouponPassExport extends ExcelExporter implements WithMapping
|
||||
{
|
||||
|
||||
protected $headings = ['渠道', '网点名称/编号', '订单号', '平安券编号', '优惠政策', '核销金额', '资金通道结算', '状态', '打款', '打款时间', '核销时间', '省', '市', '区'];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->fileName = '平安渠道打款处理' . date('YmdHis') . '.xlsx';
|
||||
}
|
||||
|
||||
public function map($info): array
|
||||
{
|
||||
$data = [
|
||||
$info->user->nickname,
|
||||
$info->outlet ? $info->outlet->nickname : $info->outletId,
|
||||
' ' . $info->redemptionCode,
|
||||
$info->couponName,
|
||||
$info->price,
|
||||
$info->profit,
|
||||
$info->status_text,
|
||||
$info->profit_text,
|
||||
$info->paid_at,
|
||||
$info->created_at,
|
||||
($info->outlet && $info->outlet->province) ? $info->outlet->province->name : '',
|
||||
($info->outlet && $info->outlet->province) ? $info->outlet->city->name : '',
|
||||
($info->outlet && $info->outlet->province) ? $info->outlet->district->name : '',
|
||||
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
33
app/Admin/Exporters/CouponProfitExport.php
Normal file
33
app/Admin/Exporters/CouponProfitExport.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Exporters;
|
||||
|
||||
use Encore\Admin\Grid\Exporters\ExcelExporter;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class CouponProfitExport extends ExcelExporter implements WithMapping
|
||||
{
|
||||
|
||||
protected $headings = ['渠道', '网点名称/编号', '订单号', '平安券编号', '优惠政策', '核销金额', '分润金额', '打款时间'];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->fileName = '已打款记录 ' . date('YmdHis') . '.xlsx';
|
||||
}
|
||||
|
||||
public function map($info): array
|
||||
{
|
||||
$data = [
|
||||
$info->user->nickname,
|
||||
$info->outlet ? $info->outlet->nickname : $info->outletId,
|
||||
' ' . $info->redemptionCode,
|
||||
$info->couponName,
|
||||
$info->price,
|
||||
$info->profit,
|
||||
$info->paid_at,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
36
app/Admin/Exporters/UsersExport.php
Normal file
36
app/Admin/Exporters/UsersExport.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Exporters;
|
||||
|
||||
use Encore\Admin\Grid\Exporters\ExcelExporter;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class UsersExport extends ExcelExporter implements WithMapping
|
||||
{
|
||||
protected $headings = ['登录账户', '渠道编号', '网点编号', '平安网点id', '所属项目', '服务秘钥', 'DES3秘钥', '渠道/网点', '用户身份', '隶属渠道', '注册时间'];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->fileName = '用户列表' . date('YmdHis') . '.xlsx';
|
||||
}
|
||||
|
||||
public function map($info): array
|
||||
{
|
||||
$data = [
|
||||
$info->username,
|
||||
' ' . $info->server_id ?? $info->parent->server_id,
|
||||
' ' . $info->outlet_id ?? '---',
|
||||
' ' . $info->PaOutletId ?? '---',
|
||||
$info->type_text,
|
||||
$info->server_key ?? '---',
|
||||
$info->des3key ?? '---',
|
||||
$info->nickname,
|
||||
$info->identity_text,
|
||||
$info->parent ? $info->parent->nickname : '---',
|
||||
$info->created_at,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
37
app/Admin/Exporters/WoCouponExport.php
Normal file
37
app/Admin/Exporters/WoCouponExport.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Exporters;
|
||||
|
||||
use Encore\Admin\Grid\Exporters\ExcelExporter;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class WoCouponExport extends ExcelExporter implements WithMapping
|
||||
{
|
||||
protected $headings = ['渠道', '网点', '工号', '业务', '活动编号', '手机号', '电子券面值', '状态', '处理结果', '原发放流水', '发券流水号', '处理时间'];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->fileName = '沃支付业务记录' . date('YmdHis') . '.xlsx';
|
||||
}
|
||||
|
||||
public function map($info): array
|
||||
{
|
||||
$data = [
|
||||
$info->user->nickname,
|
||||
$info->outlet ? $info->outlet->nickname : $info->outletId,
|
||||
' ' . $info->number,
|
||||
' ' . $info->service_text,
|
||||
$info->activityId,
|
||||
' ' . $info->mobile,
|
||||
$info->ticketAmt,
|
||||
$info->status_text,
|
||||
$info->remark,
|
||||
' ' . $info->ologNo,
|
||||
' ' . $info->logNo,
|
||||
$info->created_at,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
39
app/Admin/Imports/User.php
Normal file
39
app/Admin/Imports/User.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Imports;
|
||||
|
||||
use App\Models\User as UserModel;
|
||||
use Illuminate\Support\Collection;
|
||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||
|
||||
class User implements ToCollection
|
||||
{
|
||||
|
||||
public function collection(Collection $rows)
|
||||
{
|
||||
|
||||
$error = [];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$user = UserModel::whereHas('info', function ($q) use ($row) {
|
||||
$q->where('nickname', $row[1]);
|
||||
})->whereNull('PaOutletId')->first();
|
||||
|
||||
if ($user) {
|
||||
$user->PaOutletId = $row[2];
|
||||
$user->save();
|
||||
} else {
|
||||
$error[] = $row['1'];
|
||||
}
|
||||
}
|
||||
|
||||
if (count($error) > 0) {
|
||||
dd($error);
|
||||
|
||||
return implode(' ,', $error);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
26
app/Admin/Renderable/Activity/Grants.php
Normal file
26
app/Admin/Renderable/Activity/Grants.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Renderable\Activity;
|
||||
|
||||
use App\Models\Activity;
|
||||
use Encore\Admin\Widgets\Table;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
|
||||
class Grants implements Renderable
|
||||
{
|
||||
|
||||
public function render($key = null)
|
||||
{
|
||||
$activity = Activity::find($key);
|
||||
$items = $activity->grants->map(function ($info) {
|
||||
return [
|
||||
'id' => $info->id,
|
||||
'nickname' => $info->user_nickname,
|
||||
];
|
||||
});
|
||||
dd($items->toArray());
|
||||
|
||||
return new Table(['Id', '渠道'], $items->toArray());
|
||||
}
|
||||
|
||||
}
|
||||
32
app/Admin/Renderable/Log/InData.php
Normal file
32
app/Admin/Renderable/Log/InData.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Renderable\Log;
|
||||
|
||||
use App\Models\Log;
|
||||
use Encore\Admin\Widgets\Table;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
|
||||
class InData implements Renderable
|
||||
{
|
||||
|
||||
public function render($key = null)
|
||||
{
|
||||
$log = Log::find($key);
|
||||
$in_source = $log->in_source;
|
||||
foreach ($in_source as $key => $item) {
|
||||
if (!in_array($key, [])) {
|
||||
|
||||
}
|
||||
if (is_array($item)) {
|
||||
$in_source[$key] = json_encode($item);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($in_source) && count($in_source) > 1) {
|
||||
$table = new Table(['名称', '值'], $in_source, ['panel', ' panel-default']);
|
||||
|
||||
return $table->render();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
25
app/Admin/Renderable/Log/OutData.php
Normal file
25
app/Admin/Renderable/Log/OutData.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Renderable\Log;
|
||||
|
||||
use App\Models\Log;
|
||||
use Encore\Admin\Widgets\Table;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
|
||||
class OutData implements Renderable
|
||||
{
|
||||
|
||||
public function render($key = null)
|
||||
{
|
||||
$log = Log::find($key);
|
||||
$out_source = $log->out_source;
|
||||
|
||||
if (is_array($out_source) && count($out_source) > 1) {
|
||||
unset($out_source['sign']);
|
||||
$table = new Table(['名称', '值'], $out_source, ['panel ', 'panel-success']);
|
||||
|
||||
return $table->render();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
23
app/Admin/Renderable/User/Rule.php
Normal file
23
app/Admin/Renderable/User/Rule.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Renderable\User;
|
||||
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Widgets\Table;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
|
||||
class Rule implements Renderable
|
||||
{
|
||||
|
||||
public function render($key = null)
|
||||
{
|
||||
$user = User::find($key);
|
||||
$codes = $user->code->map(function ($code) {
|
||||
return $code->only(['name', 'code', 'profit']);
|
||||
});
|
||||
$table = new Table(['名称', '规则项', '分润金额(元)'], $codes->toArray());
|
||||
|
||||
return $table->render();
|
||||
}
|
||||
|
||||
}
|
||||
30
app/Admin/Renderable/User/ServerKey.php
Normal file
30
app/Admin/Renderable/User/ServerKey.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Renderable\User;
|
||||
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Widgets\Table;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
|
||||
class ServerKey implements Renderable
|
||||
{
|
||||
|
||||
public function render($key = null)
|
||||
{
|
||||
$user = User::find($key);
|
||||
|
||||
$data = [
|
||||
[
|
||||
'服务秘钥', $user->server_key ?? '---',
|
||||
],
|
||||
[
|
||||
'DES3秘钥', $user->des3key ?? '---',
|
||||
],
|
||||
];
|
||||
|
||||
$table = new Table(['名称', '参数'], $data);
|
||||
|
||||
return $table->render();
|
||||
}
|
||||
|
||||
}
|
||||
32
app/Admin/bootstrap.php
Normal file
32
app/Admin/bootstrap.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use App\Admin\Extensions\WangEditor;
|
||||
use Encore\Admin\Form;
|
||||
use Encore\Admin\Grid;
|
||||
|
||||
//Form::forget(['map', 'editor']);
|
||||
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->actions(function (Grid\Displayers\Actions $actions) {
|
||||
$actions->disableView();
|
||||
});
|
||||
$grid->disableBatchActions();
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->disableIdFilter();
|
||||
});
|
||||
// $grid->expandFilter();
|
||||
});
|
||||
58
app/Admin/routes.php
Normal file
58
app/Admin/routes.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?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->get('test', 'TestController@index')->name('test.index');
|
||||
|
||||
$router->post('uploads/editor', 'UploadController@editor')->name('uploads.editor');
|
||||
|
||||
/**
|
||||
* 账户管理
|
||||
*/
|
||||
$router->get('accounts', 'Account\IndexController@index');
|
||||
$router->get('accounts/logs', 'Account\LogController@index');
|
||||
$router->resource('accounts/rules', 'Account\RuleController');
|
||||
/**
|
||||
* 用户管理
|
||||
*/
|
||||
$router->get('user/parent', 'User\IndexController@getParent');
|
||||
$router->resource('users', 'User\IndexController');
|
||||
|
||||
//身份管理
|
||||
$router->resource('identity', 'IdentityController');
|
||||
|
||||
/**
|
||||
* api 日志
|
||||
*/
|
||||
$router->resource('logs', 'Log\IndexController');
|
||||
$router->resource('coupons', 'Coupon\IndexController'); //平安卡券
|
||||
$router->resource('wos', 'Wo\IndexController'); //沃钱包业务
|
||||
|
||||
/**
|
||||
* 财务管理
|
||||
*/
|
||||
$router->resource('finances', 'Finance\IndexController');
|
||||
$router->resource('financelogs', 'Finance\LogController');
|
||||
|
||||
$router->get('census/today', 'Finance\CensusController@today');
|
||||
$router->resource('census', 'Finance\CensusController');
|
||||
|
||||
//省份地址
|
||||
$router->get('ajax/areas/children', 'Ajax\AreaController@children')->name('areas.children');
|
||||
|
||||
//活动列表
|
||||
$router->resource('activities', 'Activity\IndexController');
|
||||
$router->resource('rules', 'Activity\RuleController');
|
||||
$router->resource('activitycoupons', 'Activity\CouponController');
|
||||
$router->resource('activitycouponlogs', 'Activity\LogController');
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user