first commit
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* The file was created by Assimon.
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
|
||||
namespace App\Admin\Actions\Post;
|
||||
|
||||
|
||||
use Dcat\Admin\Grid\BatchAction;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BatchRestore extends BatchAction
|
||||
{
|
||||
|
||||
protected $title;
|
||||
|
||||
protected $model;
|
||||
|
||||
// 注意构造方法的参数必须要有默认值
|
||||
public function __construct(string $model = null)
|
||||
{
|
||||
$this->title = admin_trans('dujiaoka.restore');
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function handle(Request $request)
|
||||
{
|
||||
$model = $request->get('model');
|
||||
|
||||
foreach ((array) $this->getKey() as $key) {
|
||||
$model::withTrashed()->findOrFail($key)->restore();
|
||||
}
|
||||
|
||||
return $this->response()->success(admin_trans('dujiaoka.restored'))->refresh();
|
||||
}
|
||||
|
||||
public function confirm()
|
||||
{
|
||||
return [admin_trans('dujiaoka.are_you_restore_sure')];
|
||||
}
|
||||
|
||||
public function parameters()
|
||||
{
|
||||
return [
|
||||
'model' => $this->model,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* The file was created by Assimon.
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
|
||||
namespace App\Admin\Actions\Post;
|
||||
|
||||
|
||||
use Dcat\Admin\Grid\RowAction;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Restore extends RowAction
|
||||
{
|
||||
|
||||
protected $title;
|
||||
|
||||
protected $model;
|
||||
|
||||
// 注意构造方法的参数必须要有默认值
|
||||
public function __construct(string $model = null)
|
||||
{
|
||||
$this->title = admin_trans('dujiaoka.restore');
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function handle(Request $request)
|
||||
{
|
||||
$key = $this->getKey();
|
||||
$model = $request->get('model');
|
||||
|
||||
$model::withTrashed()->findOrFail($key)->restore();
|
||||
|
||||
return $this->response()->success(admin_trans('dujiaoka.restored'))->refresh();
|
||||
}
|
||||
|
||||
public function confirm()
|
||||
{
|
||||
return [admin_trans('dujiaoka.are_you_restore_sure')];
|
||||
}
|
||||
|
||||
public function parameters()
|
||||
{
|
||||
return [
|
||||
'model' => $this->model,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
/**
|
||||
* The file was created by Assimon.
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
|
||||
namespace App\Admin\Charts;
|
||||
|
||||
|
||||
use App\Models\Order;
|
||||
use Dcat\Admin\Widgets\Metrics\RadialBar;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class DashBoard extends RadialBar
|
||||
{
|
||||
|
||||
/**
|
||||
* 初始化卡片内容
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->title(admin_trans('dujiaoka.sales_data'));
|
||||
$this->height(400);
|
||||
$this->chartHeight(300);
|
||||
$this->chartLabels(admin_trans('dujiaoka.order_success_rate'));
|
||||
$this->dropdown([
|
||||
'today' => admin_trans('dujiaoka.last_today'),
|
||||
'seven' => admin_trans('dujiaoka.last_seven_days'),
|
||||
'month' => admin_trans('dujiaoka.last_month'),
|
||||
'year' => admin_trans('dujiaoka.last_year'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理请求
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function handle(Request $request)
|
||||
{
|
||||
$endTime = Carbon::now();
|
||||
switch ($request->get('option')) {
|
||||
case 'seven':
|
||||
$startTime = Carbon::now()->subDays(7);
|
||||
break;
|
||||
case 'month':
|
||||
$startTime = Carbon::now()->subDays(30);
|
||||
break;
|
||||
case 'year':
|
||||
$startTime = Carbon::now()->subDays(365);
|
||||
break;
|
||||
case 'today':
|
||||
default:
|
||||
$startTime = Carbon::today();
|
||||
}
|
||||
// 分组查询
|
||||
$orderGroup = Order::query()
|
||||
->where('created_at', '>=', $startTime)
|
||||
->where('created_at', '<=', $endTime)
|
||||
->select('status', DB::raw('count(id) as num'))
|
||||
->groupBy('status')
|
||||
->pluck('num', 'status')
|
||||
->toArray();
|
||||
$pending = $orderGroup[Order::STATUS_PENDING] ?? 0;
|
||||
$processing = $orderGroup[Order::STATUS_PROCESSING] ?? 0;
|
||||
$completed = $orderGroup[Order::STATUS_COMPLETED] ?? 0;
|
||||
$failure = $orderGroup[Order::STATUS_FAILURE] ?? 0;
|
||||
$abnormal = $orderGroup[Order::STATUS_ABNORMAL] ?? 0;
|
||||
$orderCount = array_sum($orderGroup);
|
||||
if ($orderCount == 0) {
|
||||
$successRate = 0;
|
||||
} else {
|
||||
$rate = bcdiv($completed, $orderCount, 2);
|
||||
$successRate = bcmul($rate, 100);
|
||||
}
|
||||
// 订单数
|
||||
$this->withOrderCount($orderCount);
|
||||
// 卡片底部
|
||||
$this->withFooter($pending, $processing, $completed, $failure, $abnormal);
|
||||
// 图表数据
|
||||
$this->withChart($successRate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单总数
|
||||
*
|
||||
* @param $count
|
||||
* @return DashBoard
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public function withOrderCount($count)
|
||||
{
|
||||
$title = admin_trans('dujiaoka.order_count_number');
|
||||
return $this->content(
|
||||
<<<HTML
|
||||
<div class="d-flex flex-column flex-wrap text-center">
|
||||
<h1 class="font-lg-2 mt-2 mb-0">{$count}</h1>
|
||||
<small>{$title}</small>
|
||||
</div>
|
||||
HTML
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成交率.
|
||||
*
|
||||
* @param int $data
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function withChart(int $data)
|
||||
{
|
||||
return $this->chart([
|
||||
'series' => [$data],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pending
|
||||
* @param $processing
|
||||
* @param $completed
|
||||
* @param $failure
|
||||
* @param $abnormal
|
||||
* @return DashBoard
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public function withFooter($pending, $processing, $completed, $failure, $abnormal)
|
||||
{
|
||||
$statusPendingTitle = admin_trans('dujiaoka.status_pending_number');
|
||||
$statusProcessingNumber = admin_trans('dujiaoka.status_processing_number');
|
||||
$statusCompletedNumber = admin_trans('dujiaoka.status_completed_number');
|
||||
$statusFailureNumber = admin_trans('dujiaoka.status_failure_number');
|
||||
$statusAbnormalNumber = admin_trans('dujiaoka.status_abnormal_number');
|
||||
return $this->footer(
|
||||
<<<HTML
|
||||
<div class="d-flex justify-content-between p-1" style="padding-top: 0!important;">
|
||||
<div class="text-center">
|
||||
<p>{$statusPendingTitle}</p>
|
||||
<span class="font-lg-1">{$pending}</span>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<p>{$statusProcessingNumber}</p>
|
||||
<span class="font-lg-1">{$processing}</span>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<p>{$statusCompletedNumber}</p>
|
||||
<span class="font-lg-1">{$completed}</span>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<p>{$statusFailureNumber}</p>
|
||||
<span class="font-lg-1">{$failure}</span>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<p>{$statusAbnormalNumber}</p>
|
||||
<span class="font-lg-1">{$abnormal}</span>
|
||||
</div>
|
||||
</div>
|
||||
HTML
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* The file was created by Assimon.
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
|
||||
namespace App\Admin\Charts;
|
||||
|
||||
|
||||
use App\Models\Order;
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Widgets\Metrics\Donut;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class PayoutRateCard extends Donut
|
||||
{
|
||||
|
||||
protected $labels;
|
||||
|
||||
/**
|
||||
* 初始化卡片内容
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->labels = [admin_trans('dujiaoka.payment_successful_number'), admin_trans('dujiaoka.unpaid_number')];
|
||||
$color = Admin::color();
|
||||
$colors = [$color->primary(), $color->alpha('blue2', 0.5)];
|
||||
|
||||
$this->title(admin_trans('dujiaoka.payment_chart'));
|
||||
$this->chartLabels($this->labels);
|
||||
// 设置图表颜色
|
||||
$this->chartColors($colors);
|
||||
$this->dropdown([
|
||||
'seven' => admin_trans('dujiaoka.last_seven_days'),
|
||||
'today' => admin_trans('dujiaoka.last_today'),
|
||||
'month' => admin_trans('dujiaoka.last_month'),
|
||||
'year' => admin_trans('dujiaoka.last_year'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理请求
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function handle(Request $request)
|
||||
{
|
||||
$endTime = Carbon::now();
|
||||
switch ($request->get('option')) {
|
||||
case 'seven':
|
||||
$startTime = Carbon::now()->subDays(7);
|
||||
break;
|
||||
case 'month':
|
||||
$startTime = Carbon::now()->subDays(30);
|
||||
break;
|
||||
case 'year':
|
||||
$startTime = Carbon::now()->subDays(365);
|
||||
break;
|
||||
case 'today':
|
||||
$startTime = Carbon::today();
|
||||
break;
|
||||
default:
|
||||
$startTime = Carbon::now()->subDays(7);
|
||||
}
|
||||
// 成功的数量
|
||||
$success = Order::query()
|
||||
->where('created_at', '>=', $startTime)
|
||||
->where('created_at', '<=', $endTime)
|
||||
->where('status', '>', Order::STATUS_WAIT_PAY)
|
||||
->count();
|
||||
// 待支付的数量
|
||||
$unpaid = Order::query()
|
||||
->where('created_at', '>=', $startTime)
|
||||
->where('created_at', '<=', $endTime)
|
||||
->where('status', '<=', Order::STATUS_WAIT_PAY)
|
||||
->count();
|
||||
$this->withContent($success, $unpaid);
|
||||
// 图表数据
|
||||
$this->withChart([$success, $unpaid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置图表数据.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function withChart(array $data)
|
||||
{
|
||||
return $this->chart([
|
||||
'series' => $data
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置卡片头部内容.
|
||||
*
|
||||
* @param mixed $success
|
||||
* @param mixed $unpaid
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function withContent($success, $unpaid)
|
||||
{
|
||||
$blue = Admin::color()->alpha('blue2', 0.5);
|
||||
|
||||
$style = 'margin-bottom: 8px';
|
||||
$labelWidth = 120;
|
||||
|
||||
return $this->content(
|
||||
<<<HTML
|
||||
<div class="d-flex pl-1 pr-1 pt-1" style="{$style}">
|
||||
<div style="width: {$labelWidth}px">
|
||||
<i class="fa fa-circle text-primary"></i> {$this->labels[0]}
|
||||
</div>
|
||||
<div>{$success}</div>
|
||||
</div>
|
||||
<div class="d-flex pl-1 pr-1" style="{$style}">
|
||||
<div style="width: {$labelWidth}px">
|
||||
<i class="fa fa-circle" style="color: $blue"></i> {$this->labels[1]}
|
||||
</div>
|
||||
<div>{$unpaid}</div>
|
||||
</div>
|
||||
HTML
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/**
|
||||
* The file was created by Assimon.
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
|
||||
namespace App\Admin\Charts;
|
||||
|
||||
|
||||
use App\Models\Order;
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Widgets\Metrics\Bar;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class SalesCard extends Bar
|
||||
{
|
||||
|
||||
/**
|
||||
* 初始化卡片内容
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$color = Admin::color();
|
||||
|
||||
$dark35 = $color->dark35();
|
||||
|
||||
// 卡片内容宽度
|
||||
$this->contentWidth(5, 7);
|
||||
// 标题
|
||||
$this->title(admin_trans('dujiaoka.sales_chart'));
|
||||
// 设置下拉选项
|
||||
$this->dropdown([
|
||||
'seven' => admin_trans('dujiaoka.last_seven_days'),
|
||||
'today' => admin_trans('dujiaoka.last_today'),
|
||||
'month' => admin_trans('dujiaoka.last_month'),
|
||||
]);
|
||||
// 设置图表颜色
|
||||
$this->chartColors([
|
||||
$dark35,
|
||||
$color->primary(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理请求
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function handle(Request $request)
|
||||
{
|
||||
$endTime = Carbon::now();
|
||||
switch ($request->get('option')) {
|
||||
case 'seven':
|
||||
$startTime = Carbon::now()->subDays(7);
|
||||
break;
|
||||
case 'month':
|
||||
$startTime = Carbon::now()->subDays(30);
|
||||
break;
|
||||
case 'today':
|
||||
$startTime = Carbon::today();
|
||||
break;
|
||||
default:
|
||||
$startTime = Carbon::now()->subDays(7);
|
||||
}
|
||||
// 分组查询
|
||||
$orderGroup = Order::query()
|
||||
->where('created_at', '>=', $startTime)
|
||||
->where('created_at', '<=', $endTime)
|
||||
->where('status', '>', Order::STATUS_PENDING)
|
||||
->select(DB::raw('DATE(created_at) as date'), DB::raw('sum(actual_price) as actual_price'))
|
||||
->groupBy('date')
|
||||
->pluck('actual_price')
|
||||
->toArray();
|
||||
$totalPrice = array_sum($orderGroup);
|
||||
$this->withContent($totalPrice, '', '', $startTime, $endTime);
|
||||
$this->withChart([
|
||||
[
|
||||
'name' => admin_trans('dujiaoka.sales_chart'),
|
||||
'data' => $orderGroup,
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置图表数据.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function withChart(array $data)
|
||||
{
|
||||
return $this->chart([
|
||||
'series' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置卡片内容.
|
||||
*
|
||||
* @param string $title
|
||||
* @param string $value
|
||||
* @param string $style
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function withContent($title, $value, $style = 'success', $startTime, $endTime)
|
||||
{
|
||||
$minHeight = '183px';
|
||||
$uri = admin_route('order.index', [
|
||||
'created_at[start]' => $startTime->format('Y-m-d H:i:s'),
|
||||
'created_at[end]' => $endTime->format('Y-m-d H:i:s')
|
||||
]);
|
||||
return $this->content(
|
||||
<<<HTML
|
||||
<div class="d-flex p-1 flex-column justify-content-between" style="padding-top: 0;width: 100%;height: 100%;min-height: {$minHeight}">
|
||||
<div class="text-left">
|
||||
<h1 class="font-lg-2 mt-2 mb-0">{$title}¥</h1>
|
||||
<h5 class="font-medium-2" style="margin-top: 10px;">
|
||||
<span class="text-{$style}">{$value} </span>
|
||||
</h5>
|
||||
</div>
|
||||
|
||||
<a href="{$uri}" class="btn btn-primary shadow waves-effect waves-light">View Details <i class="feather icon-chevrons-right"></i></a>
|
||||
</div>
|
||||
HTML
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* The file was created by Assimon.
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
|
||||
namespace App\Admin\Charts;
|
||||
|
||||
|
||||
use App\Models\Order;
|
||||
use Dcat\Admin\Widgets\Metrics\Line;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class SuccessOrderCard extends Line
|
||||
{
|
||||
|
||||
/**
|
||||
* 初始化卡片内容
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->title(admin_trans('dujiaoka.status_completed_number'));
|
||||
$this->dropdown([
|
||||
'seven' => admin_trans('dujiaoka.last_seven_days'),
|
||||
'today' => admin_trans('dujiaoka.last_today'),
|
||||
'month' => admin_trans('dujiaoka.last_month'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理请求
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function handle(Request $request)
|
||||
{
|
||||
$endTime = Carbon::now();
|
||||
switch ($request->get('option')) {
|
||||
case 'seven':
|
||||
$startTime = Carbon::now()->subDays(7);
|
||||
break;
|
||||
case 'month':
|
||||
$startTime = Carbon::now()->subDays(30);
|
||||
break;
|
||||
case 'today':
|
||||
$startTime = Carbon::today();
|
||||
break;
|
||||
default:
|
||||
$startTime = Carbon::now()->subDays(7);
|
||||
}
|
||||
// 分组查询
|
||||
$orderGroup = Order::query()
|
||||
->where('created_at', '>=', $startTime)
|
||||
->where('created_at', '<=', $endTime)
|
||||
->where('status', Order::STATUS_COMPLETED)
|
||||
->select(DB::raw('DATE(created_at) as date'), DB::raw('count(id) as num'))
|
||||
->groupBy('date')
|
||||
->pluck('num')
|
||||
->toArray();
|
||||
$successCount = array_sum($orderGroup);
|
||||
// 卡片内容
|
||||
$this->withContent($successCount);
|
||||
// 图表数据
|
||||
$this->withChart($orderGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置图表数据.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function withChart(array $data)
|
||||
{
|
||||
return $this->chart([
|
||||
'series' => [
|
||||
[
|
||||
'name' => $this->title,
|
||||
'data' => $data,
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置卡片内容.
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function withContent($content)
|
||||
{
|
||||
return $this->content(
|
||||
<<<HTML
|
||||
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px">
|
||||
<h2 class="ml-1 font-lg-1">{$content}</h2>
|
||||
<span class="mb-0 mr-1 text-80">{$this->title}</span>
|
||||
</div>
|
||||
HTML
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* The file was created by Assimon.
|
||||
*
|
||||
* @author ZhangYiQiu<me@zhangyiqiu.net>
|
||||
* @copyright ZhangYiQiu<me@zhangyiqiu.net>
|
||||
* @link http://zhangyiqiu.net/
|
||||
*/
|
||||
|
||||
namespace App\Admin\Forms;
|
||||
|
||||
use App\Models\BaseModel;
|
||||
use Dcat\Admin\Widgets\Form;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Mail\MailServiceProvider;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class EmailTest extends Form
|
||||
{
|
||||
/**
|
||||
* Handle the form request.
|
||||
*
|
||||
* @param array $input
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(array $input)
|
||||
{
|
||||
$to = $input['to'];
|
||||
$title = $input['title'];
|
||||
$body = $input['body'];
|
||||
$sysConfig = cache('system-setting');
|
||||
$mailConfig = [
|
||||
'driver' => $sysConfig['driver'] ?? 'smtp',
|
||||
'host' => $sysConfig['host'] ?? '',
|
||||
'port' => $sysConfig['port'] ?? '465',
|
||||
'username' => $sysConfig['username'] ?? '',
|
||||
'from' => [
|
||||
'address' => $sysConfig['from_address'] ?? '',
|
||||
'name' => $sysConfig['from_name'] ?? '独角发卡'
|
||||
],
|
||||
'password' => $sysConfig['password'] ?? '',
|
||||
'encryption' => $sysConfig['encryption'] ?? 'ssl'
|
||||
];
|
||||
// 覆盖 mail 配置
|
||||
config([
|
||||
'mail' => array_merge(config('mail'), $mailConfig)
|
||||
]);
|
||||
// 重新注册驱动
|
||||
(new MailServiceProvider(app()))->register();
|
||||
try
|
||||
{
|
||||
Mail::send(['html' => 'email.mail'], ['body' => $body], function ($message) use ($to, $title){
|
||||
$message->to($to)->subject($title);
|
||||
});
|
||||
}
|
||||
catch(\Exception $e)
|
||||
{
|
||||
return $this
|
||||
->response()
|
||||
->error($e->getMessage());
|
||||
}
|
||||
return $this
|
||||
->response()
|
||||
->success(admin_trans('email-test.labels.success'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a form here.
|
||||
*/
|
||||
public function form()
|
||||
{
|
||||
$this->tab(admin_trans('menu.titles.email_test'), function () {
|
||||
$this->text('to', admin_trans('email-test.labels.to'))->required();
|
||||
$this->text('title', admin_trans('email-test.labels.title'))->default('这是一条测试邮件')->required();
|
||||
$this->editor('body', admin_trans('email-test.labels.body'))->default("这是一条测试邮件的正文内容<br/><br/>正文比较长<br/><br/>非常长<br/><br/>测试测试测试")->required();
|
||||
});
|
||||
}
|
||||
|
||||
public function default()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Forms;
|
||||
|
||||
use App\Models\Carmis;
|
||||
use App\Models\Goods;
|
||||
use Dcat\Admin\Widgets\Form;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ImportCarmis extends Form
|
||||
{
|
||||
|
||||
/**
|
||||
* Handle the form request.
|
||||
*
|
||||
* @param array $input
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(array $input)
|
||||
{
|
||||
if (empty($input['carmis_list']) && empty($input['carmis_txt'])) {
|
||||
return $this->response()->error(admin_trans('carmis.rule_messages.carmis_list_and_carmis_txt_can_not_be_empty'));
|
||||
}
|
||||
$carmisContent = "";
|
||||
if (!empty($input['carmis_txt'])) {
|
||||
$carmisContent = Storage::disk('public')->get($input['carmis_txt']);
|
||||
}
|
||||
if (!empty($input['carmis_list'])) {
|
||||
$carmisContent = $input['carmis_list'];
|
||||
}
|
||||
$carmisData = [];
|
||||
$tempList = explode(PHP_EOL, $carmisContent);
|
||||
foreach ($tempList as $val) {
|
||||
if (trim($val) != "") {
|
||||
$carmisData[] = [
|
||||
'goods_id' => $input['goods_id'],
|
||||
'carmi' => trim($val),
|
||||
'status' => Carmis::STATUS_UNSOLD,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
}
|
||||
}
|
||||
if ($input['remove_duplication'] == 1) {
|
||||
$carmisData = assoc_unique($carmisData, 'carmi');
|
||||
}
|
||||
Carmis::query()->insert($carmisData);
|
||||
// 删除文件
|
||||
Storage::disk('public')->delete($input['carmis_txt']);
|
||||
return $this
|
||||
->response()
|
||||
->success(admin_trans('carmis.rule_messages.import_carmis_success'))
|
||||
->location('/carmis');
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a form here.
|
||||
*/
|
||||
public function form()
|
||||
{
|
||||
$this->confirm(admin_trans('carmis.fields.are_you_import_sure'));
|
||||
$this->select('goods_id')->options(
|
||||
Goods::query()->where('type', Goods::AUTOMATIC_DELIVERY)->pluck('gd_name', 'id')
|
||||
)->required();
|
||||
$this->textarea('carmis_list')
|
||||
->rows(20)
|
||||
->help(admin_trans('carmis.helps.carmis_list'));
|
||||
$this->file('carmis_txt')
|
||||
->disk('public')
|
||||
->uniqueName()
|
||||
->accept('txt')
|
||||
->maxSize(5120)
|
||||
->help(admin_trans('carmis.helps.carmis_list'));
|
||||
$this->switch('remove_duplication');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Forms;
|
||||
|
||||
use App\Models\BaseModel;
|
||||
use Dcat\Admin\Widgets\Form;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class SystemSetting extends Form
|
||||
{
|
||||
/**
|
||||
* Handle the form request.
|
||||
*
|
||||
* @param array $input
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(array $input)
|
||||
{
|
||||
Cache::put('system-setting', $input);
|
||||
return $this
|
||||
->response()
|
||||
->success(admin_trans('system-setting.rule_messages.save_system_setting_success'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a form here.
|
||||
*/
|
||||
public function form()
|
||||
{
|
||||
$this->tab(admin_trans('system-setting.labels.base_setting'), function () {
|
||||
$this->text('title', admin_trans('system-setting.fields.title'))->required();
|
||||
$this->image('img_logo', admin_trans('system-setting.fields.img_logo'));
|
||||
$this->text('text_logo', admin_trans('system-setting.fields.text_logo'));
|
||||
$this->text('keywords', admin_trans('system-setting.fields.keywords'));
|
||||
$this->textarea('description', admin_trans('system-setting.fields.description'));
|
||||
$this->select('template', admin_trans('system-setting.fields.template'))
|
||||
->options(config('dujiaoka.templates'))
|
||||
->required();
|
||||
$this->select('language', admin_trans('system-setting.fields.language'))
|
||||
->options(config('dujiaoka.language'))
|
||||
->required();
|
||||
$this->text('manage_email', admin_trans('system-setting.fields.manage_email'));
|
||||
$this->number('order_expire_time', admin_trans('system-setting.fields.order_expire_time'))
|
||||
->default(5)
|
||||
->required();
|
||||
$this->switch('is_open_anti_red', admin_trans('system-setting.fields.is_open_anti_red'))
|
||||
->default(BaseModel::STATUS_CLOSE);
|
||||
$this->switch('is_open_img_code', admin_trans('system-setting.fields.is_open_img_code'))
|
||||
->default(BaseModel::STATUS_CLOSE);
|
||||
$this->switch('is_open_search_pwd', admin_trans('system-setting.fields.is_open_search_pwd'))
|
||||
->default(BaseModel::STATUS_CLOSE);
|
||||
$this->switch('is_open_google_translate', admin_trans('system-setting.fields.is_open_google_translate'))
|
||||
->default(BaseModel::STATUS_CLOSE);
|
||||
$this->editor('notice', admin_trans('system-setting.fields.notice'));
|
||||
$this->textarea('footer', admin_trans('system-setting.fields.footer'));
|
||||
});
|
||||
$this->tab(admin_trans('system-setting.labels.order_push_setting'), function () {
|
||||
$this->switch('is_open_server_jiang', admin_trans('system-setting.fields.is_open_server_jiang'))
|
||||
->default(BaseModel::STATUS_CLOSE);
|
||||
$this->text('server_jiang_token', admin_trans('system-setting.fields.server_jiang_token'));
|
||||
$this->switch('is_open_telegram_push', admin_trans('system-setting.fields.is_open_telegram_push'))
|
||||
->default(BaseModel::STATUS_CLOSE);
|
||||
$this->text('telegram_bot_token', admin_trans('system-setting.fields.telegram_bot_token'));
|
||||
$this->text('telegram_userid', admin_trans('system-setting.fields.telegram_userid'));
|
||||
$this->switch('is_open_bark_push', admin_trans('system-setting.fields.is_open_bark_push'))
|
||||
->default(BaseModel::STATUS_CLOSE);
|
||||
$this->switch('is_open_bark_push_url', admin_trans('system-setting.fields.is_open_bark_push_url'))
|
||||
->default(BaseModel::STATUS_CLOSE);
|
||||
$this->text('bark_server', admin_trans('system-setting.fields.bark_server'));
|
||||
$this->text('bark_token', admin_trans('system-setting.fields.bark_token'));
|
||||
$this->switch('is_open_qywxbot_push', admin_trans('system-setting.fields.is_open_qywxbot_push'))
|
||||
->default(BaseModel::STATUS_CLOSE);
|
||||
$this->text('qywxbot_key', admin_trans('system-setting.fields.qywxbot_key'));
|
||||
});
|
||||
$this->tab(admin_trans('system-setting.labels.mail_setting'), function () {
|
||||
$this->text('driver', admin_trans('system-setting.fields.driver'))->default('smtp')->required();
|
||||
$this->text('host', admin_trans('system-setting.fields.host'));
|
||||
$this->text('port', admin_trans('system-setting.fields.port'))->default(587);
|
||||
$this->text('username', admin_trans('system-setting.fields.username'));
|
||||
$this->text('password', admin_trans('system-setting.fields.password'));
|
||||
$this->text('encryption', admin_trans('system-setting.fields.encryption'));
|
||||
$this->text('from_address', admin_trans('system-setting.fields.from_address'));
|
||||
$this->text('from_name', admin_trans('system-setting.fields.from_name'));
|
||||
});
|
||||
$this->tab(admin_trans('system-setting.labels.geetest'), function () {
|
||||
$this->text('geetest_id', admin_trans('system-setting.fields.geetest_id'));
|
||||
$this->text('geetest_key', admin_trans('system-setting.fields.geetest_key'));
|
||||
$this->switch('is_open_geetest', admin_trans('system-setting.fields.is_open_geetest'))->default(BaseModel::STATUS_CLOSE);
|
||||
});
|
||||
$this->confirm(
|
||||
admin_trans('dujiaoka.warning_title'),
|
||||
admin_trans('system-setting.rule_messages.change_reboot_php_worker')
|
||||
);
|
||||
}
|
||||
|
||||
public function default()
|
||||
{
|
||||
return Cache::get('system-setting');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Repositories;
|
||||
|
||||
use App\Models\Carmis as Model;
|
||||
use Dcat\Admin\Repositories\EloquentRepository;
|
||||
|
||||
class Carmis extends EloquentRepository
|
||||
{
|
||||
|
||||
/**
|
||||
* Model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $eloquentClass = Model::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Repositories;
|
||||
|
||||
use App\Models\Coupon as Model;
|
||||
use Dcat\Admin\Repositories\EloquentRepository;
|
||||
|
||||
class Coupon extends EloquentRepository
|
||||
{
|
||||
/**
|
||||
* Model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $eloquentClass = Model::class;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Repositories;
|
||||
|
||||
use App\Models\Emailtpl as Model;
|
||||
use Dcat\Admin\Repositories\EloquentRepository;
|
||||
|
||||
class Emailtpl extends EloquentRepository
|
||||
{
|
||||
/**
|
||||
* Model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $eloquentClass = Model::class;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Repositories;
|
||||
|
||||
use App\Models\Goods as Model;
|
||||
use Dcat\Admin\Repositories\EloquentRepository;
|
||||
|
||||
class Goods extends EloquentRepository
|
||||
{
|
||||
/**
|
||||
* Model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $eloquentClass = Model::class;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Repositories;
|
||||
|
||||
use App\Models\GoodsGroup as Model;
|
||||
use Dcat\Admin\Repositories\EloquentRepository;
|
||||
|
||||
class GoodsGroup extends EloquentRepository
|
||||
{
|
||||
|
||||
/**
|
||||
* Model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $eloquentClass = Model::class;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Repositories;
|
||||
|
||||
use App\Models\Order as Model;
|
||||
use Dcat\Admin\Repositories\EloquentRepository;
|
||||
|
||||
class Order extends EloquentRepository
|
||||
{
|
||||
/**
|
||||
* Model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $eloquentClass = Model::class;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Repositories;
|
||||
|
||||
use App\Models\Pay as Model;
|
||||
use Dcat\Admin\Repositories\EloquentRepository;
|
||||
|
||||
class Pay extends EloquentRepository
|
||||
{
|
||||
/**
|
||||
* Model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $eloquentClass = Model::class;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Grid;
|
||||
use Dcat\Admin\Form;
|
||||
use Dcat\Admin\Grid\Filter;
|
||||
use Dcat\Admin\Show;
|
||||
|
||||
/**
|
||||
* Dcat-admin - admin builder based on Laravel.
|
||||
* @author jqh <https://github.com/jqhph>
|
||||
*
|
||||
* Bootstraper for Admin.
|
||||
*
|
||||
* Here you can remove builtin form field:
|
||||
*
|
||||
* extend custom field:
|
||||
* Dcat\Admin\Form::extend('php', PHPEditor::class);
|
||||
* Dcat\Admin\Grid\Column::extend('php', PHPEditor::class);
|
||||
* Dcat\Admin\Grid\Filter::extend('php', PHPEditor::class);
|
||||
*
|
||||
* Or require js and css assets:
|
||||
* Admin::css('/packages/prettydocs/css/styles.css');
|
||||
* Admin::js('/packages/prettydocs/js/main.js');
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Dcat\Admin\Admin;
|
||||
|
||||
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');
|
||||
$router->resource('goods', 'GoodsController');
|
||||
$router->resource('goods-group', 'GoodsGroupController');
|
||||
$router->resource('carmis', 'CarmisController');
|
||||
$router->resource('coupon', 'CouponController');
|
||||
$router->resource('emailtpl', 'EmailtplController');
|
||||
$router->resource('pay', 'PayController');
|
||||
$router->resource('order', 'OrderController');
|
||||
$router->get('import-carmis', 'CarmisController@importCarmis');
|
||||
$router->get('system-setting', 'SystemSettingController@systemSetting');
|
||||
$router->get('email-test', 'EmailTestController@emailTest');
|
||||
});
|
||||
Reference in New Issue
Block a user