first commit
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Dcat\Admin\Http\Controllers\AuthController as BaseAuthController;
|
||||
|
||||
class AuthController extends BaseAuthController
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\Post\BatchRestore;
|
||||
use App\Admin\Actions\Post\Restore;
|
||||
use App\Admin\Forms\ImportCarmis;
|
||||
use App\Admin\Repositories\Carmis;
|
||||
use App\Models\Goods;
|
||||
use Dcat\Admin\Form;
|
||||
use Dcat\Admin\Grid;
|
||||
use Dcat\Admin\Layout\Content;
|
||||
use Dcat\Admin\Show;
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
use App\Models\Carmis as CarmisModel;
|
||||
use Dcat\Admin\Widgets\Card;
|
||||
|
||||
class CarmisController extends AdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
return Grid::make(new Carmis(['goods']), function (Grid $grid) {
|
||||
$grid->model()->orderBy('id', 'DESC');
|
||||
$grid->column('id')->sortable();
|
||||
$grid->column('goods.gd_name', admin_trans('carmis.fields.goods_id'));
|
||||
$grid->column('status')->select(CarmisModel::getStatusMap());
|
||||
$grid->column('is_loop')->display(function($v){return $v==1?admin_trans('carmis.fields.yes'):"";});
|
||||
$grid->column('carmi')->limit(20);
|
||||
$grid->column('created_at');
|
||||
$grid->column('updated_at')->sortable();
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
$filter->equal('id');
|
||||
$filter->equal('goods_id')->select(
|
||||
Goods::query()->where('type', Goods::AUTOMATIC_DELIVERY)->pluck('gd_name', 'id')
|
||||
);
|
||||
$filter->equal('status')->select(CarmisModel::getStatusMap());
|
||||
$filter->scope(admin_trans('dujiaoka.trashed'))->onlyTrashed();
|
||||
});
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
if (request('_scope_') == admin_trans('dujiaoka.trashed')) {
|
||||
$actions->append(new Restore(CarmisModel::class));
|
||||
}
|
||||
});
|
||||
$grid->batchActions(function (Grid\Tools\BatchActions $batch) {
|
||||
if (request('_scope_') == admin_trans('dujiaoka.trashed')) {
|
||||
$batch->add(new BatchRestore(CarmisModel::class));
|
||||
}
|
||||
});
|
||||
$grid->export()->titles(['goods.gd_name' => admin_trans('carmis.fields.goods_id'), 'carmi' => admin_trans('carmis.fields.carmi'), 'created_at' => admin_trans('admin.created_at')]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
return Show::make($id, new Carmis(['goods']), function (Show $show) {
|
||||
$show->field('id');
|
||||
$show->field('goods.gd_name', admin_trans('carmis.fields.goods_id'));
|
||||
$show->field('status')->as(function ($type) {
|
||||
if ($type == CarmisModel::STATUS_UNSOLD) {
|
||||
return admin_trans('carmis.fields.status_unsold');
|
||||
} else {
|
||||
return admin_trans('carmis.fields.status_sold');
|
||||
}
|
||||
});
|
||||
$show->field('is_loop')->as(function ($v) {return $v==1?admin_trans('carmis.fields.yes'):"";});
|
||||
$show->field('carmi');
|
||||
$show->field('created_at');
|
||||
$show->field('updated_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
return Form::make(new Carmis(), function (Form $form) {
|
||||
$form->display('id');
|
||||
$form->select('goods_id')->options(
|
||||
Goods::query()->where('type', Goods::AUTOMATIC_DELIVERY)->pluck('gd_name', 'id')
|
||||
)->required();
|
||||
$form->radio('status')
|
||||
->options(CarmisModel::getStatusMap())
|
||||
->default(CarmisModel::STATUS_UNSOLD);
|
||||
$form->switch('is_loop')->default(false);
|
||||
$form->textarea('carmi')->required();
|
||||
$form->display('created_at');
|
||||
$form->display('updated_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入卡密
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public function importCarmis(Content $content)
|
||||
{
|
||||
return $content
|
||||
->title(admin_trans('carmis.fields.import_carmis'))
|
||||
->body(new Card(new ImportCarmis()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\Post\BatchRestore;
|
||||
use App\Admin\Actions\Post\Restore;
|
||||
use App\Admin\Repositories\Coupon;
|
||||
use App\Models\Goods;
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Form;
|
||||
use Dcat\Admin\Grid;
|
||||
use Dcat\Admin\Show;
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
use App\Models\Coupon as CouponModel;
|
||||
|
||||
class CouponController extends AdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
return Grid::make(new Coupon(['goods']), function (Grid $grid) {
|
||||
$grid->model()->orderBy('id', 'DESC');
|
||||
$grid->column('id')->sortable();
|
||||
$grid->column('discount');
|
||||
$grid->column('is_use')->select(CouponModel::getStatusUseMap());
|
||||
$grid->column('is_open')->switch();
|
||||
$grid->column('coupon')->copyable();
|
||||
$grid->column('ret');
|
||||
$grid->column('created_at');
|
||||
$grid->column('updated_at')->sortable();
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
if (request('_scope_') == admin_trans('dujiaoka.trashed')) {
|
||||
$actions->append(new Restore(CouponModel::class));
|
||||
}
|
||||
});
|
||||
$grid->batchActions(function (Grid\Tools\BatchActions $batch) {
|
||||
if (request('_scope_') == admin_trans('dujiaoka.trashed')) {
|
||||
$batch->add(new BatchRestore(CouponModel::class));
|
||||
}
|
||||
});
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
$filter->equal('id');
|
||||
$filter->equal('goods.goods_id', admin_trans('coupon.fields.goods_id'))->select(
|
||||
Goods::query()->pluck('gd_name', 'id')
|
||||
);
|
||||
$filter->scope(admin_trans('dujiaoka.trashed'))->onlyTrashed();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
return Show::make($id, new Coupon(), function (Show $show) {
|
||||
$show->field('id');
|
||||
$show->field('discount');
|
||||
$show->field('is_use')->as(function ($isUse) {
|
||||
if ($isUse == CouponModel::STATUS_UNUSED) {
|
||||
return admin_trans('coupon.fields.status_unused');
|
||||
} else {
|
||||
return admin_trans('coupon.fields.status_use');
|
||||
}
|
||||
});
|
||||
$show->field('is_open')->as(function ($isOPen) {
|
||||
if ($isOPen == CouponModel::STATUS_OPEN) {
|
||||
return admin_trans('dujiaoka.status_open');
|
||||
} else {
|
||||
return admin_trans('dujiaoka.status_close');
|
||||
}
|
||||
});
|
||||
$show->field('coupon');
|
||||
$show->field('ret');
|
||||
$show->field('created_at');
|
||||
$show->field('updated_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
return Form::make(Coupon::with('goods'), function (Form $form) {
|
||||
$form->display('id');
|
||||
$form->multipleSelect('goods', admin_trans('coupon.fields.goods_id'))
|
||||
->options(Goods::all()->pluck('gd_name', 'id'))
|
||||
->customFormat(function ($v) {
|
||||
if (! $v) {
|
||||
return [];
|
||||
}
|
||||
// 从数据库中查出的二维数组中转化成ID
|
||||
return array_column($v, 'id');
|
||||
});
|
||||
$form->currency('discount')->default(0)->required();
|
||||
$form->text('coupon')->required();
|
||||
$form->number('ret')->default(1);
|
||||
$form->radio('is_use')->options(CouponModel::getStatusUseMap())->default(CouponModel::STATUS_UNUSED);
|
||||
$form->switch('is_open')->default(CouponModel::STATUS_OPEN);
|
||||
$form->display('created_at');
|
||||
$form->display('updated_at');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* The file was created by Assimon.
|
||||
*
|
||||
* @author ZhangYiQiu<me@zhangyiqiu.net>
|
||||
* @copyright ZhangYiQiu<me@zhangyiqiu.net>
|
||||
* @link http://zhangyiqiu.net/
|
||||
*/
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
|
||||
use App\Admin\Forms\EmailTest;
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
use Dcat\Admin\Layout\Content;
|
||||
use Dcat\Admin\Widgets\Card;
|
||||
|
||||
class EmailTestController extends AdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* 系统设置
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public function emailTest(Content $content)
|
||||
{
|
||||
return $content
|
||||
->title(admin_trans('menu.titles.email_test'))
|
||||
->body(new Card(new EmailTest()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\Post\BatchRestore;
|
||||
use App\Admin\Actions\Post\Restore;
|
||||
use App\Admin\Repositories\Emailtpl;
|
||||
use Dcat\Admin\Form;
|
||||
use Dcat\Admin\Grid;
|
||||
use Dcat\Admin\Show;
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
use App\Models\Emailtpl as EmailTplModel;
|
||||
|
||||
class EmailtplController extends AdminController
|
||||
{
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
return Grid::make(new Emailtpl(), function (Grid $grid) {
|
||||
$grid->column('id')->sortable();
|
||||
$grid->column('tpl_name');
|
||||
$grid->column('tpl_token');
|
||||
$grid->column('created_at');
|
||||
$grid->column('updated_at')->sortable();
|
||||
$grid->disableViewButton();
|
||||
$grid->disableDeleteButton();
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
$filter->equal('id');
|
||||
$filter->like('tpl_name');
|
||||
$filter->like('tpl_token');
|
||||
});
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
if (request('_scope_') == admin_trans('dujiaoka.trashed')) {
|
||||
$actions->append(new Restore(EmailTplModel::class));
|
||||
}
|
||||
});
|
||||
$grid->batchActions(function (Grid\Tools\BatchActions $batch) {
|
||||
if (request('_scope_') == admin_trans('dujiaoka.trashed')) {
|
||||
$batch->add(new BatchRestore(EmailTplModel::class));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
return Show::make($id, new Emailtpl(), function (Show $show) {
|
||||
$show->field('id');
|
||||
$show->field('tpl_name');
|
||||
$show->field('tpl_content');
|
||||
$show->field('tpl_token');
|
||||
$show->field('created_at');
|
||||
$show->field('updated_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
return Form::make(new Emailtpl(), function (Form $form) {
|
||||
$form->display('id');
|
||||
$form->text('tpl_name')->required();
|
||||
$form->editor('tpl_content')->required();
|
||||
if ($form->isCreating()) {
|
||||
$form->text('tpl_token')->required();
|
||||
} else {
|
||||
$form->text('tpl_token')->disable();
|
||||
}
|
||||
$form->display('created_at');
|
||||
$form->display('updated_at');
|
||||
$form->disableViewButton();
|
||||
$form->disableDeleteButton();
|
||||
$form->footer(function ($footer) {
|
||||
// 去掉`查看`checkbox
|
||||
$footer->disableViewCheck();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\Post\BatchRestore;
|
||||
use App\Admin\Actions\Post\Restore;
|
||||
use App\Admin\Repositories\Goods;
|
||||
use App\Models\Carmis;
|
||||
use App\Models\Coupon;
|
||||
use App\Models\GoodsGroup as GoodsGroupModel;
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Form;
|
||||
use Dcat\Admin\Grid;
|
||||
use Dcat\Admin\Show;
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
use App\Models\Goods as GoodsModel;
|
||||
|
||||
class GoodsController extends AdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
return Grid::make(new Goods(['group', 'coupon']), function (Grid $grid) {
|
||||
$grid->model()->orderBy('id', 'DESC');
|
||||
$grid->column('id')->sortable();
|
||||
$grid->column('picture')->image('', 100, 100);
|
||||
$grid->column('gd_name');
|
||||
$grid->column('gd_description');
|
||||
$grid->column('gd_keywords');
|
||||
$grid->column('group.gp_name', admin_trans('goods.fields.group_id'));
|
||||
$grid->column('type')
|
||||
->using(GoodsModel::getGoodsTypeMap())
|
||||
->label([
|
||||
GoodsModel::AUTOMATIC_DELIVERY => Admin::color()->success(),
|
||||
GoodsModel::MANUAL_PROCESSING => Admin::color()->info(),
|
||||
]);
|
||||
$grid->column('retail_price');
|
||||
$grid->column('actual_price')->sortable();
|
||||
$grid->column('in_stock')->display(function () {
|
||||
// 如果为自动发货,则加载库存卡密
|
||||
if ($this->type == GoodsModel::AUTOMATIC_DELIVERY) {
|
||||
return Carmis::query()->where('goods_id', $this->id)
|
||||
->where('status', Carmis::STATUS_UNSOLD)
|
||||
->count();
|
||||
} else {
|
||||
return $this->in_stock;
|
||||
}
|
||||
});
|
||||
$grid->column('sales_volume');
|
||||
$grid->column('ord')->editable()->sortable();
|
||||
$grid->column('is_open')->switch();
|
||||
$grid->column('created_at')->sortable();
|
||||
$grid->column('updated_at');
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
$filter->equal('id');
|
||||
$filter->like('gd_name');
|
||||
$filter->equal('type')->select(GoodsModel::getGoodsTypeMap());
|
||||
$filter->equal('group_id')->select(GoodsGroupModel::query()->pluck('gp_name', 'id'));
|
||||
$filter->scope(admin_trans('dujiaoka.trashed'))->onlyTrashed();
|
||||
$filter->equal('coupon.coupons_id', admin_trans('goods.fields.coupon_id'))->select(
|
||||
Coupon::query()->pluck('coupon', 'id')
|
||||
);
|
||||
});
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
if (request('_scope_') == admin_trans('dujiaoka.trashed')) {
|
||||
$actions->append(new Restore(GoodsModel::class));
|
||||
}
|
||||
});
|
||||
$grid->batchActions(function (Grid\Tools\BatchActions $batch) {
|
||||
if (request('_scope_') == admin_trans('dujiaoka.trashed')) {
|
||||
$batch->add(new BatchRestore(GoodsModel::class));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
return Show::make($id, new Goods(), function (Show $show) {
|
||||
$show->id('id');
|
||||
$show->field('gd_name');
|
||||
$show->field('gd_description');
|
||||
$show->field('gd_keywords');
|
||||
$show->field('picture')->image();
|
||||
$show->field('retail_price');
|
||||
$show->field('actual_price');
|
||||
$show->field('in_stock');
|
||||
$show->field('ord');
|
||||
$show->field('sales_volume');
|
||||
$show->field('type')->as(function ($type) {
|
||||
if ($type == GoodsModel::AUTOMATIC_DELIVERY) {
|
||||
return admin_trans('goods.fields.automatic_delivery');
|
||||
} else {
|
||||
return admin_trans('goods.fields.manual_processing');
|
||||
}
|
||||
});
|
||||
$show->field('is_open')->as(function ($isOpen) {
|
||||
if ($isOpen == GoodsGroupModel::STATUS_OPEN) {
|
||||
return admin_trans('dujiaoka.status_open');
|
||||
} else {
|
||||
return admin_trans('dujiaoka.status_close');
|
||||
}
|
||||
});
|
||||
$show->wholesale_price_cnf()->unescape()->as(function ($wholesalePriceCnf) {
|
||||
return "<textarea class=\"form-control field_wholesale_price_cnf _normal_\" rows=\"10\" cols=\"30\">" . $wholesalePriceCnf . "</textarea>";
|
||||
});
|
||||
$show->other_ipu_cnf()->unescape()->as(function ($otherIpuCnf) {
|
||||
return "<textarea class=\"form-control field_wholesale_price_cnf _normal_\" rows=\"10\" cols=\"30\">" . $otherIpuCnf . "</textarea>";
|
||||
});
|
||||
$show->api_hook()->unescape()->as(function ($apiHook) {
|
||||
return "<textarea class=\"form-control field_wholesale_price_cnf _normal_\" rows=\"10\" cols=\"30\">" . $apiHook . "</textarea>";
|
||||
});;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
return Form::make(new Goods(), function (Form $form) {
|
||||
$form->display('id');
|
||||
$form->text('gd_name')->required();
|
||||
$form->text('gd_description')->required();
|
||||
$form->text('gd_keywords')->required();
|
||||
$form->select('group_id')->options(
|
||||
GoodsGroupModel::query()->pluck('gp_name', 'id')
|
||||
)->required();
|
||||
$form->image('picture')->autoUpload()->uniqueName()->help(admin_trans('goods.helps.picture'));
|
||||
$form->radio('type')->options(GoodsModel::getGoodsTypeMap())->default(GoodsModel::AUTOMATIC_DELIVERY)->required();
|
||||
$form->currency('retail_price')->default(0)->help(admin_trans('goods.helps.retail_price'));
|
||||
$form->currency('actual_price')->default(0)->required();
|
||||
$form->number('in_stock')->help(admin_trans('goods.helps.in_stock'));
|
||||
$form->number('sales_volume');
|
||||
$form->number('buy_limit_num')->help(admin_trans('goods.helps.buy_limit_num'));
|
||||
$form->editor('buy_prompt');
|
||||
$form->editor('description');
|
||||
$form->textarea('other_ipu_cnf')->help(admin_trans('goods.helps.other_ipu_cnf'));
|
||||
$form->textarea('wholesale_price_cnf')->help(admin_trans('goods.helps.wholesale_price_cnf'));
|
||||
$form->textarea('api_hook');
|
||||
$form->number('ord')->default(1)->help(admin_trans('dujiaoka.ord'));
|
||||
$form->switch('is_open')->default(GoodsModel::STATUS_OPEN);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\Post\BatchRestore;
|
||||
use App\Admin\Actions\Post\Restore;
|
||||
use App\Admin\Repositories\GoodsGroup;
|
||||
use Dcat\Admin\Form;
|
||||
use Dcat\Admin\Grid;
|
||||
use Dcat\Admin\Show;
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
use App\Models\GoodsGroup as GoodsGroupModel;
|
||||
|
||||
class GoodsGroupController extends AdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
return Grid::make(new GoodsGroup(), function (Grid $grid) {
|
||||
$grid->model()->orderBy('id', 'DESC');
|
||||
$grid->column('id')->sortable();
|
||||
$grid->column('gp_name')->editable();
|
||||
$grid->column('is_open')->switch();
|
||||
$grid->column('ord')->editable();
|
||||
$grid->column('created_at');
|
||||
$grid->column('updated_at')->sortable();
|
||||
$grid->disableViewButton();
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
$filter->equal('id');
|
||||
$filter->scope(admin_trans('dujiaoka.trashed'))->onlyTrashed();
|
||||
});
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
if (request('_scope_') == admin_trans('dujiaoka.trashed')) {
|
||||
$actions->append(new Restore(GoodsGroupModel::class));
|
||||
}
|
||||
});
|
||||
$grid->batchActions(function (Grid\Tools\BatchActions $batch) {
|
||||
if (request('_scope_') == admin_trans('dujiaoka.trashed')) {
|
||||
$batch->add(new BatchRestore(GoodsGroupModel::class));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
return Show::make($id, new GoodsGroup(), function (Show $show) {
|
||||
$show->field('id');
|
||||
$show->field('gp_name');
|
||||
$show->field('is_open')->as(function ($isOpen) {
|
||||
if ($isOpen == GoodsGroupModel::STATUS_OPEN) {
|
||||
return admin_trans('dujiaoka.status_open');
|
||||
} else {
|
||||
return admin_trans('dujiaoka.status_close');
|
||||
}
|
||||
});
|
||||
$show->field('ord');
|
||||
$show->field('created_at');
|
||||
$show->field('updated_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
return Form::make(new GoodsGroup(), function (Form $form) {
|
||||
$form->display('id');
|
||||
$form->text('gp_name');
|
||||
$form->switch('is_open')->default(GoodsGroupModel::STATUS_OPEN);
|
||||
$form->number('ord')->default(1)->help(admin_trans('dujiaoka.ord'));
|
||||
$form->display('created_at');
|
||||
$form->display('updated_at');
|
||||
$form->disableViewButton();
|
||||
$form->footer(function ($footer) {
|
||||
// 去掉`查看`checkbox
|
||||
$footer->disableViewCheck();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Charts\DashBoard;
|
||||
use App\Admin\Charts\PayoutRateCard;
|
||||
use App\Admin\Charts\PopularGoodsCard;
|
||||
use App\Admin\Charts\SalesCard;
|
||||
use App\Admin\Charts\SuccessOrderCard;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Dcat\Admin\Layout\Column;
|
||||
use Dcat\Admin\Layout\Content;
|
||||
use Dcat\Admin\Layout\Row;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
|
||||
public function index(Content $content)
|
||||
{
|
||||
return $content
|
||||
->header(admin_trans('dujiaoka.dashboard'))
|
||||
->description(admin_trans('dujiaoka.dashboard_description'))
|
||||
->body(function (Row $row) {
|
||||
$row->column(6, function (Column $column) {
|
||||
$column->row(self::title());
|
||||
$column->row(new DashBoard());
|
||||
});
|
||||
|
||||
$row->column(6, function (Column $column) {
|
||||
$column->row(function (Row $row) {
|
||||
$row->column(6, new SuccessOrderCard());
|
||||
$row->column(6, new PayoutRateCard());
|
||||
});
|
||||
|
||||
$column->row(new SalesCard());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static function title()
|
||||
{
|
||||
return view('admin.dashboard.title');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\Post\BatchRestore;
|
||||
use App\Admin\Actions\Post\Restore;
|
||||
use App\Admin\Repositories\Order;
|
||||
use App\Models\Coupon;
|
||||
use App\Models\Goods;
|
||||
use App\Models\Pay;
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Form;
|
||||
use Dcat\Admin\Grid;
|
||||
use Dcat\Admin\Show;
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
use App\Models\Order as OrderModel;
|
||||
|
||||
class OrderController extends AdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
return Grid::make(new Order(['goods', 'coupon', 'pay']), function (Grid $grid) {
|
||||
$grid->model()->orderBy('id', 'DESC');
|
||||
$grid->column('id')->sortable();
|
||||
$grid->column('order_sn')->copyable();
|
||||
$grid->column('title');
|
||||
$grid->column('type')->using(OrderModel::getTypeMap())
|
||||
->label([
|
||||
OrderModel::AUTOMATIC_DELIVERY => Admin::color()->success(),
|
||||
OrderModel::MANUAL_PROCESSING => Admin::color()->info(),
|
||||
]);
|
||||
$grid->column('email')->copyable();
|
||||
$grid->column('goods.gd_name', admin_trans('order.fields.goods_id'));
|
||||
$grid->column('goods_price');
|
||||
$grid->column('buy_amount');
|
||||
$grid->column('total_price');
|
||||
$grid->column('coupon.coupon', admin_trans('order.fields.coupon_id'));
|
||||
$grid->column('coupon_discount_price');
|
||||
$grid->column('wholesale_discount_price');
|
||||
$grid->column('actual_price');
|
||||
$grid->column('pay.pay_name', admin_trans('order.fields.pay_id'));
|
||||
$grid->column('buy_ip');
|
||||
$grid->column('search_pwd')->copyable();
|
||||
$grid->column('trade_no')->copyable();
|
||||
$grid->column('status')
|
||||
->select(OrderModel::getStatusMap());
|
||||
$grid->column('created_at');
|
||||
$grid->column('updated_at')->sortable();
|
||||
$grid->disableCreateButton();
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
$filter->equal('order_sn');
|
||||
$filter->like('title');
|
||||
$filter->equal('status')->select(OrderModel::getStatusMap());
|
||||
$filter->equal('email');
|
||||
$filter->equal('trade_no');
|
||||
$filter->equal('type')->select(OrderModel::getTypeMap());
|
||||
$filter->equal('goods_id')->select(Goods::query()->pluck('gd_name', 'id'));
|
||||
$filter->equal('coupon_id')->select(Coupon::query()->pluck('coupon', 'id'));
|
||||
$filter->equal('pay_id')->select(Pay::query()->pluck('pay_name', 'id'));
|
||||
$filter->whereBetween('created_at', function ($q) {
|
||||
$start = $this->input['start'] ?? null;
|
||||
$end = $this->input['end'] ?? null;
|
||||
$q->where('created_at', '>=', $start)
|
||||
->where('created_at', '<=', $end);
|
||||
})->datetime();
|
||||
$filter->scope(admin_trans('dujiaoka.trashed'))->onlyTrashed();
|
||||
});
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
if (request('_scope_') == admin_trans('dujiaoka.trashed')) {
|
||||
$actions->append(new Restore(OrderModel::class));
|
||||
}
|
||||
});
|
||||
$grid->batchActions(function (Grid\Tools\BatchActions $batch) {
|
||||
if (request('_scope_') == admin_trans('dujiaoka.trashed')) {
|
||||
$batch->add(new BatchRestore(OrderModel::class));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
return Show::make($id, new Order(['goods', 'coupon', 'pay']), function (Show $show) {
|
||||
$show->field('id');
|
||||
$show->field('order_sn');
|
||||
$show->field('title');
|
||||
$show->field('email');
|
||||
$show->field('goods.gd_name', admin_trans('order.fields.goods_id'));
|
||||
$show->field('goods_price');
|
||||
$show->field('buy_amount');
|
||||
$show->field('coupon.coupon', admin_trans('order.fields.coupon_id'));
|
||||
$show->field('coupon_discount_price');
|
||||
$show->field('wholesale_discount_price');
|
||||
$show->field('total_price');
|
||||
$show->field('actual_price');
|
||||
$show->field('buy_ip');
|
||||
$show->field('info')->unescape()->as(function ($info) {
|
||||
return "<textarea class=\"form-control field_wholesale_price_cnf _normal_\" rows=\"10\" cols=\"30\">" . $info . "</textarea>";
|
||||
});
|
||||
$show->field('pay.pay_name', admin_trans('order.fields.pay_id'));
|
||||
$show->field('status')->using(OrderModel::getStatusMap());
|
||||
$show->field('search_pwd');
|
||||
$show->field('trade_no');
|
||||
$show->field('type')->using(OrderModel::getTypeMap());
|
||||
$show->field('created_at');
|
||||
$show->field('updated_at');
|
||||
$show->disableEditButton();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
return Form::make(new Order(['goods', 'coupon', 'pay']), function (Form $form) {
|
||||
$form->display('id');
|
||||
$form->display('order_sn');
|
||||
$form->text('title');
|
||||
$form->display('goods.gd_name', admin_trans('order.fields.goods_id'));
|
||||
$form->display('goods_price');
|
||||
$form->display('buy_amount');
|
||||
$form->display('coupon.coupon', admin_trans('order.fields.coupon_id'));
|
||||
$form->display('coupon_discount_price');
|
||||
$form->display('wholesale_discount_price');
|
||||
$form->display('total_price');
|
||||
$form->display('actual_price');
|
||||
$form->display('email');
|
||||
$form->textarea('info');
|
||||
$form->display('buy_ip');
|
||||
$form->display('pay.pay_name', admin_trans('order.fields.pay_id'));
|
||||
$form->radio('status')->options(OrderModel::getStatusMap());
|
||||
$form->text('search_pwd');
|
||||
$form->display('trade_no');
|
||||
$form->radio('type')->options(OrderModel::getTypeMap());
|
||||
$form->display('created_at');
|
||||
$form->display('updated_at');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Actions\Post\BatchRestore;
|
||||
use App\Admin\Actions\Post\Restore;
|
||||
use App\Admin\Repositories\Pay;
|
||||
use Dcat\Admin\Form;
|
||||
use Dcat\Admin\Grid;
|
||||
use Dcat\Admin\Show;
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
use App\Models\Pay as PayModel;
|
||||
|
||||
class PayController extends AdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
return Grid::make(new Pay(), function (Grid $grid) {
|
||||
$grid->column('id')->sortable();
|
||||
$grid->column('pay_name');
|
||||
$grid->column('pay_check');
|
||||
$grid->column('pay_method')->select(PayModel::getMethodMap());
|
||||
$grid->column('merchant_id')->limit(20);
|
||||
$grid->column('merchant_key')->limit(20);
|
||||
$grid->column('merchant_pem')->limit(20);
|
||||
$grid->column('pay_client')->select(PayModel::getClientMap());
|
||||
$grid->column('pay_handleroute');
|
||||
$grid->column('is_open')->switch();
|
||||
$grid->column('created_at');
|
||||
$grid->column('updated_at')->sortable();
|
||||
$grid->disableDeleteButton();
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
$filter->equal('id');
|
||||
$filter->equal('pay_check');
|
||||
$filter->like('pay_name');
|
||||
$filter->scope(admin_trans('dujiaoka.trashed'))->onlyTrashed();
|
||||
});
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
if (request('_scope_') == admin_trans('dujiaoka.trashed')) {
|
||||
$actions->append(new Restore(PayModel::class));
|
||||
}
|
||||
});
|
||||
$grid->batchActions(function (Grid\Tools\BatchActions $batch) {
|
||||
if (request('_scope_') == admin_trans('dujiaoka.trashed')) {
|
||||
$batch->add(new BatchRestore(PayModel::class));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
return Show::make($id, new Pay(), function (Show $show) {
|
||||
$show->field('id');
|
||||
$show->field('pay_name');
|
||||
$show->field('merchant_id');
|
||||
$show->field('merchant_key');
|
||||
$show->field('merchant_pem');
|
||||
$show->field('pay_check');
|
||||
$show->field('pay_client')->as(function ($payClient) {
|
||||
if ($payClient == PayModel::PAY_CLIENT_PC) {
|
||||
return admin_trans('pay.fields.pay_client_pc');
|
||||
} else {
|
||||
return admin_trans('pay.fields.pay_client_mobile');
|
||||
}
|
||||
});
|
||||
$show->field('pay_handleroute');
|
||||
$show->field('pay_method')->as(function ($payMethod) {
|
||||
if ($payMethod == PayModel::METHOD_JUMP) {
|
||||
return admin_trans('pay.fields.method_jump');
|
||||
} else {
|
||||
return admin_trans('pay.fields.method_scan');
|
||||
}
|
||||
});
|
||||
$show->field('is_open')->as(function ($isOpen) {
|
||||
if ($isOpen == PayModel::STATUS_OPEN) {
|
||||
return admin_trans('dujiaoka.status_open');
|
||||
} else {
|
||||
return admin_trans('dujiaoka.status_close');
|
||||
}
|
||||
});
|
||||
$show->field('created_at');
|
||||
$show->field('updated_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
return Form::make(new Pay(), function (Form $form) {
|
||||
$form->display('id');
|
||||
$form->text('pay_name')->required();
|
||||
$form->text('merchant_id')->required();
|
||||
$form->textarea('merchant_key');
|
||||
$form->textarea('merchant_pem')->required();
|
||||
$form->text('pay_check')->required();
|
||||
$form->radio('pay_client')
|
||||
->options(PayModel::getClientMap())
|
||||
->default(PayModel::PAY_CLIENT_PC)
|
||||
->required();
|
||||
$form->radio('pay_method')
|
||||
->options(PayModel::getMethodMap())
|
||||
->default(PayModel::METHOD_JUMP)
|
||||
->required();
|
||||
$form->text('pay_handleroute')->required();
|
||||
$form->switch('is_open')->default(PayModel::STATUS_OPEN);
|
||||
$form->display('created_at');
|
||||
$form->display('updated_at');
|
||||
$form->disableDeleteButton();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* The file was created by Assimon.
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
|
||||
use App\Admin\Forms\SystemSetting;
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
use Dcat\Admin\Layout\Content;
|
||||
use Dcat\Admin\Widgets\Card;
|
||||
|
||||
class SystemSettingController extends AdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* 系统设置
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public function systemSetting(Content $content)
|
||||
{
|
||||
return $content
|
||||
->title(admin_trans('menu.titles.system_setting'))
|
||||
->body(new Card(new SystemSetting()));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user