微调
This commit is contained in:
@@ -13,7 +13,7 @@ class CouponController extends AdminController
|
||||
|
||||
protected $title = '卡券列表管理';
|
||||
|
||||
protected function grid()
|
||||
protected function grid(): Grid
|
||||
{
|
||||
$grid = new Grid(new ActivityCoupon);
|
||||
$grid->model()->with(['outlet'])->latest();
|
||||
@@ -24,6 +24,11 @@ class CouponController extends AdminController
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->equal('status', '状态')->select(ActivityCoupon::STATUS);
|
||||
$filter->between('used_at', '核销时间')->datetime();
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
|
||||
>>>>>>> a7719d7038809738262e66c70e301947845f680d
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('outlet', function ($query) {
|
||||
$query->whereHas('info', function ($query) {
|
||||
@@ -52,7 +57,11 @@ class CouponController extends AdminController
|
||||
})
|
||||
->get()
|
||||
->pluck('nickname', 'id');
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
|
||||
>>>>>>> a7719d7038809738262e66c70e301947845f680d
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('outlet', function ($query) {
|
||||
$query->whereHas('parent', function ($query) {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Admin\Controllers\Activity;
|
||||
|
||||
use App\Admin\Renderable\Activity\Grants;
|
||||
use App\Admin\Renderable\Activity\Verifications;
|
||||
use App\Models\Activity;
|
||||
use App\Models\ActivityRule;
|
||||
use App\Models\User;
|
||||
@@ -18,7 +20,7 @@ class IndexController extends AdminController
|
||||
protected function grid(): Grid
|
||||
{
|
||||
$grid = new Grid(new Activity);
|
||||
$grid->model()->withCount('coupons');
|
||||
$grid->model()->with(['rule', 'grants', 'verifications'])->withCount('coupons');
|
||||
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableView();
|
||||
@@ -28,15 +30,14 @@ class IndexController extends AdminController
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->equal('status', '状态')->select(Activity::STATUS);
|
||||
$filter->equal('type', '类型')->select(Activity::TYPES);
|
||||
$filter->equal('code', '活动编号');
|
||||
});
|
||||
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->between('start_at', '开始时间')->datetime();
|
||||
$filter->between('end_at', '结束时间')->datetime();
|
||||
$filter->equal('channel', '核销途径')->select(Activity::CHANNELS);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$grid->column('id', '#ID#');
|
||||
@@ -48,13 +49,13 @@ class IndexController extends AdminController
|
||||
$grid->column('类型')->display(function () {
|
||||
return $this->type_text;
|
||||
});
|
||||
|
||||
$grid->column('channel', '核销途径')
|
||||
->using(Activity::CHANNELS)
|
||||
->label([
|
||||
Activity::CHANNEL_YSD => 'info',
|
||||
Activity::CHANNEL_UNION => 'success',
|
||||
]);
|
||||
<<<<<<< HEAD
|
||||
|
||||
$grid->column('days', '延期(天)');
|
||||
$grid->column('rule.full', '满足金额');
|
||||
@@ -74,6 +75,17 @@ class IndexController extends AdminController
|
||||
->label()
|
||||
->width(350)
|
||||
->hide();
|
||||
=======
|
||||
$grid->column('days', '延期(天)');
|
||||
$grid->column('rule.full', '满足金额');
|
||||
$grid->column('rule.take', '扣除金额');
|
||||
$grid->column('发券渠道')->display(function ($title, $column) {
|
||||
return '查看';
|
||||
})->modal(Grants::class);
|
||||
$grid->column('核券渠道')->display(function ($title, $column) {
|
||||
return '查看';
|
||||
})->modal(Verifications::class);
|
||||
>>>>>>> a7719d7038809738262e66c70e301947845f680d
|
||||
|
||||
$grid->column('开始时间')->display(function () {
|
||||
return $this->type == Activity::TYPE_SCOPE ? $this->start_at->format('Y-m-d') : '---';
|
||||
@@ -123,7 +135,10 @@ class IndexController extends AdminController
|
||||
->when(Activity::TYPE_SCOPE, function (Form $form) {
|
||||
$form->dateRange('start_at', 'end_at', '有效时间');
|
||||
})
|
||||
<<<<<<< HEAD
|
||||
->help('当月券,领取的月底到期')
|
||||
=======
|
||||
>>>>>>> a7719d7038809738262e66c70e301947845f680d
|
||||
->required();
|
||||
|
||||
$form->radio('channel', '核销途径')
|
||||
@@ -131,8 +146,11 @@ class IndexController extends AdminController
|
||||
->default(Activity::CHANNEL_YSD)
|
||||
->help('券码核销的途径:亿时代是自己核销,银联是银联pos核销')
|
||||
->required();
|
||||
<<<<<<< HEAD
|
||||
|
||||
$form->number('day_times','每天可用次数')->default(0)->help('每天可用次数,0未不限制');
|
||||
=======
|
||||
>>>>>>> a7719d7038809738262e66c70e301947845f680d
|
||||
|
||||
$form->switch('status', '状态')->default(1);
|
||||
$form->switch('need_check', '多次校验')
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Admin\Controllers\Activity;
|
||||
|
||||
use App\Admin\Renderable\Activity\Grants;
|
||||
use App\Models\ActivityCouponLog;
|
||||
use Encore\Admin\Controllers\HasResourceActions;
|
||||
use Encore\Admin\Grid;
|
||||
@@ -18,19 +17,21 @@ class LogController extends AdminController
|
||||
|
||||
/**
|
||||
* Get content title.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function title()
|
||||
protected function title(): string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Index interface.
|
||||
*
|
||||
* @param Content $content
|
||||
* @return Content
|
||||
*/
|
||||
public function index(Content $content)
|
||||
public function index(Content $content): Content
|
||||
{
|
||||
return $content
|
||||
->title($this->title())
|
||||
@@ -38,7 +39,7 @@ class LogController extends AdminController
|
||||
->body($this->grid());
|
||||
}
|
||||
|
||||
protected function grid()
|
||||
protected function grid(): Grid
|
||||
{
|
||||
$grid = new Grid(new ActivityCouponLog);
|
||||
|
||||
@@ -54,35 +55,30 @@ class LogController extends AdminController
|
||||
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->equal('status', '状态')->select(ActivityCouponLog::STATUS);
|
||||
|
||||
$filter->between('created_at', '开始时间')->datetime();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$grid->column('id', '#ID#');
|
||||
$grid->column('code', '卡券编号');
|
||||
$grid->column('type', '分类')
|
||||
->using(ActivityCouponLog::TYPES)
|
||||
->label([
|
||||
1 => 'default',
|
||||
2 => 'warning',
|
||||
3 => 'info',
|
||||
]);
|
||||
->using(ActivityCouponLog::TYPES)
|
||||
->label([
|
||||
1 => 'default',
|
||||
2 => 'warning',
|
||||
3 => 'info',
|
||||
]);
|
||||
|
||||
$grid->column('status', '状态')
|
||||
->using(ActivityCouponLog::STATUS)
|
||||
->label([
|
||||
1 => 'default',
|
||||
2 => 'warning',
|
||||
3 => 'info',
|
||||
]);
|
||||
->using(ActivityCouponLog::STATUS)
|
||||
->label([
|
||||
1 => 'default',
|
||||
2 => 'warning',
|
||||
3 => 'info',
|
||||
]);
|
||||
|
||||
$grid->column('remark', '处理结果');
|
||||
|
||||
$grid->column('created_at', '操作时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,10 +12,9 @@ use RuLong\Identity\Models\Identity;
|
||||
|
||||
class RuleController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = '规则管理';
|
||||
|
||||
protected function grid()
|
||||
protected function grid(): Grid
|
||||
{
|
||||
$grid = new Grid(new ActivityRule);
|
||||
|
||||
@@ -34,15 +33,15 @@ class RuleController extends AdminController
|
||||
]);
|
||||
|
||||
$grid->column('created_at', '创建时间');
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
protected function form(): Form
|
||||
{
|
||||
$form = new Form(new ActivityRule);
|
||||
|
||||
@@ -58,7 +57,7 @@ class RuleController extends AdminController
|
||||
$code = $form->code;
|
||||
|
||||
$ticket = explode('-', $code);
|
||||
if (!is_array($ticket) || count($ticket) != 3) {
|
||||
if (! is_array($ticket) || count($ticket) != 3) {
|
||||
$error = new MessageBag([
|
||||
'title' => '错误',
|
||||
'message' => '规则编号格式错误',
|
||||
@@ -79,5 +78,4 @@ class RuleController extends AdminController
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Admin\Controllers\Coupon;
|
||||
|
||||
use App\Admin\Actions\Coupon\RefreshPAOrder;
|
||||
use App\Models\ActivityRule;
|
||||
use App\Models\Coupon;
|
||||
use App\Models\User;
|
||||
@@ -15,6 +16,7 @@ class IndexController extends AdminController
|
||||
|
||||
/**
|
||||
* Notes:
|
||||
*
|
||||
* @Author: <C.Jason>
|
||||
* @Date : 2019/9/18 14:50
|
||||
* @return Grid
|
||||
@@ -26,10 +28,14 @@ class IndexController extends AdminController
|
||||
$grid->disableBatchActions();
|
||||
$grid->disableActions();
|
||||
|
||||
$grid->tools(function (Grid\Tools $tools) {
|
||||
$tools->append(new refreshPAOrder());//刷新平安订单id
|
||||
});
|
||||
|
||||
$grid->model()
|
||||
->with(['outlet.province', 'outlet.city', 'outlet.district', 'user', 'user.info'])
|
||||
->whereIn('status', [2, 3])
|
||||
->orderBy('id', 'desc');
|
||||
->with(['outlet.province', 'outlet.city', 'outlet.district', 'user', 'user.info'])
|
||||
->whereIn('status', [2, 3])
|
||||
->orderBy('id', 'desc');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
@@ -44,6 +50,7 @@ class IndexController extends AdminController
|
||||
|
||||
$filter->equal('user_id', '渠道')->select($users);
|
||||
$filter->equal('thirdPartyGoodsId', '优惠政策')->select(ActivityRule::pluck('title', 'code'));
|
||||
$filter->like('couponName', '优惠政策名');
|
||||
});
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->like('redemptionCode', '卡券编号');
|
||||
@@ -56,6 +63,8 @@ class IndexController extends AdminController
|
||||
}, '网点名称');
|
||||
|
||||
$filter->equal('type', '类型')->select(Coupon::TYPES);
|
||||
$filter->like('pa_order_id', '平安主订单号');
|
||||
$filter->like('pa_sub_order_id', '平安子订单号');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -64,11 +73,11 @@ class IndexController extends AdminController
|
||||
return $this->user->nickname;
|
||||
});
|
||||
$grid->column('type', '类型')
|
||||
->using(Coupon::TYPES)
|
||||
->label([
|
||||
'1' => 'info',
|
||||
'2' => 'success',
|
||||
]);
|
||||
->using(Coupon::TYPES)
|
||||
->label([
|
||||
'1' => 'info',
|
||||
'2' => 'success',
|
||||
]);
|
||||
|
||||
$grid->column('网点名称/编号')->display(function () {
|
||||
return $this->outlet ? $this->outlet->nickname : $this->outletId;
|
||||
@@ -79,19 +88,21 @@ class IndexController extends AdminController
|
||||
$grid->column('price', '核销金额');
|
||||
$grid->column('total', '订单金额');
|
||||
$grid->column('orderid', '订单id');
|
||||
$grid->column('pa_order_id', '平安主订单号');
|
||||
$grid->column('pa_sub_order_id', '平安子订单号')->hide();
|
||||
|
||||
$grid->column('资金通道结算')->display(function () {
|
||||
$profit = $this->status == 2 ? $this->profit : '0.00';
|
||||
|
||||
return '<span style="color:red">' . $profit . '</span>';
|
||||
return '<span style="color:red">'.$profit.'</span>';
|
||||
});
|
||||
$grid->column('状态')->display(function () {
|
||||
switch ($this->status) {
|
||||
case 2:
|
||||
return '<span style="color:green">' . $this->status_text . '</span>';
|
||||
return '<span style="color:green">'.$this->status_text.'</span>';
|
||||
break;
|
||||
case 3:
|
||||
return '<span style="color:red">' . $this->status_text . '</span>';
|
||||
return '<span style="color:red">'.$this->status_text.'</span>';
|
||||
break;
|
||||
default:
|
||||
return $this->status_text;
|
||||
@@ -119,17 +130,17 @@ class IndexController extends AdminController
|
||||
// $all = $query->get();
|
||||
// $pass = $all->where('status', 2)->all();
|
||||
// $pass = collect($pass);
|
||||
$total = $query->count();
|
||||
$success = $query->where('status', 2)->count();
|
||||
$total = (clone $query)->count();
|
||||
$success = (clone $query)->where('status', 2)->count();
|
||||
$faield = $total - $success;
|
||||
|
||||
return '<label class="label label-success">全部:' . $total . '张</label> '
|
||||
. '<label class="label label-success">成功:' . $success . '张</label> '
|
||||
. '<label class="label label-success">失败:' . $faield . '张</label> '
|
||||
. '<label class="label label-success">核销金额:' . $query->sum('price') . '元</label> '
|
||||
. '<label class="label label-success">资金通道结算:' . $query->sum('profit') . '元</label> '
|
||||
. '<label class="label label-success">打款金额:' . $query->where('is_profit', 1)
|
||||
->sum('profit') . '元</label> ';
|
||||
return '<label class="label label-success">全部:'.$total.'张</label> '
|
||||
.'<label class="label label-success">成功:'.$success.'张</label> '
|
||||
.'<label class="label label-success">失败:'.$faield.'张</label> '
|
||||
.'<label class="label label-success">核销金额:'.(clone $query)->sum('price').'元</label> '
|
||||
.'<label class="label label-success">资金通道结算:'.(clone $query)->sum('profit').'元</label> '
|
||||
.'<label class="label label-success">打款金额:'.(clone $query)->where('is_profit', 1)
|
||||
->sum('profit').'元</label> ';
|
||||
});
|
||||
$grid->disableExport(false);
|
||||
|
||||
@@ -141,13 +152,13 @@ class IndexController extends AdminController
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->column('redemptionCode', function ($value, $original) {
|
||||
return $value . "\t";
|
||||
return $value."\t";
|
||||
});
|
||||
// $export->column('price', function ($value, $original) {
|
||||
// return $value . "\t";
|
||||
// });
|
||||
$export->column('orderid', function ($value, $original) {
|
||||
return $value . "\t";
|
||||
return $value."\t";
|
||||
});
|
||||
// $export->column('total', function ($value, $original) {
|
||||
// return $value . "\t";
|
||||
@@ -155,7 +166,7 @@ class IndexController extends AdminController
|
||||
$export->column('资金通道结算', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->filename('卡券列表' . date("YmdHis"));
|
||||
$export->filename('卡券列表'.date("YmdHis"));
|
||||
});
|
||||
|
||||
return $grid;
|
||||
|
||||
55
app/Admin/Controllers/Coupon/PaCouponController.php
Normal file
55
app/Admin/Controllers/Coupon/PaCouponController.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Coupon;
|
||||
|
||||
use App\Admin\Actions\Coupon\SettleCoupon;
|
||||
use App\Models\ActivityRule;
|
||||
use App\Models\Coupon;
|
||||
use App\Models\CouponPaCheck;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
|
||||
class PaCouponController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = '未找到数据';
|
||||
|
||||
/**
|
||||
* Notes:
|
||||
*
|
||||
* @Author: <C.Jason>
|
||||
* @Date : 2019/9/18 14:50
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid(): Grid
|
||||
{
|
||||
$grid = new Grid(new CouponPaCheck());
|
||||
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableBatchActions();
|
||||
$grid->disableActions();
|
||||
|
||||
|
||||
$grid->model()->oldest('id');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->equal('pa_order_id', '平安主订单号');
|
||||
});
|
||||
});
|
||||
|
||||
$grid->column('id', '#ID#');
|
||||
|
||||
$grid->column('pa_order_id', '平安主订单号');
|
||||
|
||||
$grid->disableExport(false);
|
||||
|
||||
$grid->export(function ($export) {
|
||||
$export->filename($this->title.date("YmdHis"));
|
||||
});
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
145
app/Admin/Controllers/Coupon/SettleCouponController.php
Normal file
145
app/Admin/Controllers/Coupon/SettleCouponController.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers\Coupon;
|
||||
|
||||
use App\Admin\Actions\Coupon\SettleCoupon;
|
||||
use App\Models\ActivityRule;
|
||||
use App\Models\Coupon;
|
||||
use App\Models\User;
|
||||
use Encore\Admin\Controllers\AdminController;
|
||||
use Encore\Admin\Grid;
|
||||
|
||||
class SettleCouponController extends AdminController
|
||||
{
|
||||
|
||||
protected $title = '平安券核销列表';
|
||||
|
||||
/**
|
||||
* Notes:
|
||||
*
|
||||
* @Author: <C.Jason>
|
||||
* @Date : 2019/9/18 14:50
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid(): Grid
|
||||
{
|
||||
$grid = new Grid(new Coupon);
|
||||
|
||||
$grid->disableCreateButton();
|
||||
$grid->disableBatchActions();
|
||||
$grid->disableActions();
|
||||
|
||||
$grid->tools(function (Grid\Tools $tools) {
|
||||
$tools->append(new SettleCoupon());//上传等待校验数据
|
||||
});
|
||||
|
||||
$grid->model()
|
||||
->where('type', 1)
|
||||
->with(['outlet.province', 'outlet.city', 'outlet.district', 'user', 'user.info'])
|
||||
->where('status', 2)
|
||||
->orderBy('id', 'desc');
|
||||
|
||||
$grid->filter(function ($filter) {
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->between('created_at', '核销时间')->datetime();
|
||||
$users = User::whereHas('identity', function ($query) {
|
||||
$query->where('identity_id', 1);
|
||||
})->get()->pluck('nickname', 'id');
|
||||
|
||||
$filter->equal('user_id', '渠道')->select($users);
|
||||
$filter->equal('thirdPartyGoodsId', '优惠政策')->select(ActivityRule::pluck('title', 'code'));
|
||||
$filter->like('couponName', '优惠政策名');
|
||||
});
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->like('redemptionCode', '卡券编号');
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('outlet', function ($query) {
|
||||
$query->whereHas('info', function ($query) {
|
||||
$query->where('nickname', 'like', "%{$this->input}%");
|
||||
});
|
||||
});
|
||||
}, '网点名称');
|
||||
|
||||
$filter->like('pa_order_id', '平安主订单号');
|
||||
$filter->equal('is_settle', '是否结算')->select(Coupon::SETTLES);
|
||||
});
|
||||
});
|
||||
|
||||
$grid->column('id', '#ID#');
|
||||
$grid->column('渠道')->display(function () {
|
||||
return $this->user->nickname;
|
||||
});
|
||||
$grid->column('type', '类型')
|
||||
->using(Coupon::TYPES)
|
||||
->label([
|
||||
'1' => 'info',
|
||||
'2' => 'success',
|
||||
]);
|
||||
|
||||
$grid->column('网点名称/编号')->display(function () {
|
||||
return $this->outlet ? $this->outlet->nickname : $this->outletId;
|
||||
});
|
||||
|
||||
$grid->column('redemptionCode', '卡券编号');
|
||||
$grid->column('couponName', '优惠政策');
|
||||
$grid->column('price', '核销金额');
|
||||
$grid->column('total', '订单金额');
|
||||
$grid->column('orderid', '订单id');
|
||||
$grid->column('pa_order_id', '平安主订单号');
|
||||
$grid->column('pa_sub_order_id', '平安子订单号')->hide();
|
||||
$grid->column('is_settle', '是否结算')->bool();
|
||||
|
||||
$grid->column('资金通道结算')->display(function () {
|
||||
$profit = $this->status == 2 ? $this->profit : '0.00';
|
||||
|
||||
return '<span style="color:red">'.$profit.'</span>';
|
||||
});
|
||||
$grid->column('startTime', '起始时间')->hide();
|
||||
$grid->column('endTime', '到期时间')->hide();
|
||||
$grid->column('created_at', '核销时间');
|
||||
$grid->column('省')->display(function () {
|
||||
return ($this->outlet && $this->outlet->province) ? $this->outlet->province->name : '';
|
||||
});
|
||||
|
||||
$grid->column('市')->display(function () {
|
||||
return ($this->outlet && $this->outlet->province) ? $this->outlet->city->name : '';
|
||||
});
|
||||
|
||||
$grid->column('区')->display(function () {
|
||||
return ($this->outlet && $this->outlet->province) ? $this->outlet->district->name : '';
|
||||
});
|
||||
|
||||
$grid->footer(function ($query) {
|
||||
$total = (clone $query)->count();
|
||||
$no = (clone $query)->where('is_settle', 0)->count();
|
||||
$yes = $total - $no;
|
||||
|
||||
return '<label class="label label-success">全部:'.$total.'张</label> '
|
||||
.'<label class="label label-success">已结算:'.$yes.'张</label> '
|
||||
.'<label class="label label-success">未结算:'.$no.'张</label> ';
|
||||
});
|
||||
|
||||
$grid->disableExport(false);
|
||||
|
||||
$grid->export(function ($export) {
|
||||
$export->column('type', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->column('redemptionCode', function ($value, $original) {
|
||||
return $value."\t";
|
||||
});
|
||||
|
||||
$export->column('orderid', function ($value, $original) {
|
||||
return $value."\t";
|
||||
});
|
||||
|
||||
$export->column('资金通道结算', function ($value, $original) {
|
||||
return strip_tags($value);
|
||||
});
|
||||
$export->filename($this->title.date("YmdHis"));
|
||||
});
|
||||
|
||||
return $grid;
|
||||
}
|
||||
|
||||
}
|
||||
111
app/Admin/Controllers/PetroController.php
Normal file
111
app/Admin/Controllers/PetroController.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use XuanChen\Petro;
|
||||
use XuanChen\PetroYsd;
|
||||
use XuanChen\PetroYsd\Kernel\Event\CouponNotice;
|
||||
|
||||
class PetroController
|
||||
{
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
try {
|
||||
$coupon = PetroYsd\Kernel\Models\PetroYsdCoupon::find($request->coupon_id);
|
||||
dump($coupon);
|
||||
event(new CouponNotice($coupon));
|
||||
dd(1);
|
||||
// dd(
|
||||
// base64_decode('6buR6b6Z5rGfNuWFg+ayueWTgea1i+ivleWIuA==')
|
||||
// );
|
||||
|
||||
// $res = PetroYsd::Invalid()
|
||||
// ->setParams([
|
||||
// 'requestId' => Str::random(32),
|
||||
// 'couponId' => '2830025247791780434',
|
||||
// 'couponType' => 0,
|
||||
// ])->start();
|
||||
//
|
||||
// dd($res);
|
||||
|
||||
// $res = PetroYsd::Query()
|
||||
// ->setParams([
|
||||
// 'requestId' => Str::random(32),
|
||||
// 'thirdOrderId' => 'B6Q1rzCITRretxUFkIlFUtEciW7kNnq5',
|
||||
// ])->start();
|
||||
//
|
||||
// dd($res);
|
||||
// $res = PetroYsd::Detail()
|
||||
// ->setParams([
|
||||
// 'requestId' => Str::random(32),
|
||||
// 'couponId' => '2830025247791780426',
|
||||
// 'couponType' => 0,
|
||||
// ])->start();
|
||||
//
|
||||
// dd($res);
|
||||
$res = PetroYsd::Grant()->setParams([
|
||||
'requestId' => Str::random(32),
|
||||
'productNo' => 'hljlt_hlj6yypcs',
|
||||
'mobile' => '15663876870',
|
||||
'num' => 1,
|
||||
'notifyUrl' => route('petro_new.grant_notice'),
|
||||
'thirdOrderId' => Str::random(32),
|
||||
])->start();
|
||||
|
||||
|
||||
dd($res);
|
||||
dd('老板程序');
|
||||
//获取动态码
|
||||
// $res = Petro::Check()->setParams([
|
||||
// 'ticketNum' => '61578832475977235',
|
||||
// 'random' => Str::random(6),
|
||||
// ])->start();
|
||||
//
|
||||
// dd($res);
|
||||
|
||||
// $res = Petro::Bill()->setParams([
|
||||
// 'matchDate' => Carbon::now()->format('Ymd'),
|
||||
// 'pageNo' => 1,
|
||||
// 'dzmaxResult' => 1000,
|
||||
// 'random' => Str::random(6),
|
||||
// ])->start();
|
||||
// dd($res);
|
||||
|
||||
// dd('作废');
|
||||
// $res = Petro::Invalid()->setParams([
|
||||
// 'cxcouponNo' => '61578832475977235',
|
||||
// 'random' => Str::random(6),
|
||||
// ])->start();
|
||||
// dd($res);
|
||||
|
||||
// dd('查询');
|
||||
$res = Petro::Detail()->setParams([
|
||||
'couponNo' => '61578832475977235',
|
||||
'random' => Str::random(6),
|
||||
])->start();
|
||||
//
|
||||
dd($res);
|
||||
// $grant = [
|
||||
// 'requestCode' => 'Z591xRQ9fv1u',
|
||||
// 'tradeId' => 111222,
|
||||
// 'ticketSum' => 1,
|
||||
// 'amount' => 10,
|
||||
// 'random' => Str::random(6),
|
||||
// ];
|
||||
//
|
||||
// $res = Petro::Grant()->setParams($grant)->start();
|
||||
// dd($res);
|
||||
|
||||
} catch (\Exception $exception) {
|
||||
dd('error'.$exception->getMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,65 +2,73 @@
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Jobs\CheckCouponByLog;
|
||||
use App\Jobs\CheckCouponLog;
|
||||
use App\Models\Coupon;
|
||||
use App\Models\Log;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
use XuanChen\Coupon\Action\pingan\Verification;
|
||||
|
||||
class TestController
|
||||
{
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$str = Str::uuid();
|
||||
$date = $request->date ?? date('Y-m-d');
|
||||
$time = Carbon::parse($date);
|
||||
|
||||
$all = Coupon::where('status', 2)
|
||||
->whereBetween('created_at', [
|
||||
$time->startOfDay()->toDateTimeString(),
|
||||
$time->endOfDay()->toDateTimeString(),
|
||||
])
|
||||
->count();
|
||||
->whereBetween('created_at', [
|
||||
$time->startOfDay()->toDateTimeString(),
|
||||
$time->endOfDay()->toDateTimeString(),
|
||||
])
|
||||
->count();
|
||||
$self = Coupon::where('status', 2)
|
||||
->where('type', Coupon::TYPE_YSD)
|
||||
->whereBetween('created_at', [
|
||||
$time->startOfDay()->toDateTimeString(),
|
||||
$time->endOfDay()->toDateTimeString(),
|
||||
])
|
||||
->count();
|
||||
->where('type', Coupon::TYPE_YSD)
|
||||
->whereBetween('created_at', [
|
||||
$time->startOfDay()->toDateTimeString(),
|
||||
$time->endOfDay()->toDateTimeString(),
|
||||
])
|
||||
->count();
|
||||
$pingan = Coupon::where('status', 2)
|
||||
->where('type', Coupon::TYPE_PINGAN)
|
||||
->whereBetween('created_at', [
|
||||
$time->startOfDay()->toDateTimeString(),
|
||||
$time->endOfDay()->toDateTimeString(),
|
||||
])
|
||||
->count();
|
||||
->where('type', Coupon::TYPE_PINGAN)
|
||||
->whereBetween('created_at', [
|
||||
$time->startOfDay()->toDateTimeString(),
|
||||
$time->endOfDay()->toDateTimeString(),
|
||||
])
|
||||
->count();
|
||||
|
||||
$error = Coupon::where('status', 3)
|
||||
->whereBetween('created_at', [
|
||||
$time->startOfDay()->toDateTimeString(),
|
||||
$time->endOfDay()->toDateTimeString(),
|
||||
])
|
||||
->count();
|
||||
->whereBetween('created_at', [
|
||||
$time->startOfDay()->toDateTimeString(),
|
||||
$time->endOfDay()->toDateTimeString(),
|
||||
])
|
||||
->count();
|
||||
|
||||
$lists = DB::table('coupons')
|
||||
->where('status', 2)
|
||||
->whereBetween('created_at', [
|
||||
$time->startOfDay()->toDateTimeString(),
|
||||
$time->endOfDay()->toDateTimeString(),
|
||||
])
|
||||
->select('redemptionCode', DB::raw('COUNT(*) as code_count'))
|
||||
->groupBy('redemptionCode')
|
||||
->having('code_count', '>', 1)
|
||||
->get();
|
||||
->where('status', 2)
|
||||
->whereBetween('created_at', [
|
||||
$time->startOfDay()->toDateTimeString(),
|
||||
$time->endOfDay()->toDateTimeString(),
|
||||
])
|
||||
->select('redemptionCode', DB::raw('COUNT(*) as code_count'))
|
||||
->groupBy('redemptionCode')
|
||||
->having('code_count', '>', 1)
|
||||
->get();
|
||||
|
||||
$data = [
|
||||
' 日期为:' . $time->format('Y-m-d'),
|
||||
' 核销总数为:' . $all,
|
||||
' 自有卡券总数为:' . $self,
|
||||
' 平安卡券总数为:' . $pingan,
|
||||
' 核销错误总数为:' . $error,
|
||||
' 核销重复数据数为:' . $lists->count(),
|
||||
' 日期为:'.$time->format('Y-m-d'),
|
||||
' 核销总数为:'.$all,
|
||||
' 自有卡券总数为:'.$self,
|
||||
' 平安卡券总数为:'.$pingan,
|
||||
' 核销错误总数为:'.$error,
|
||||
' 核销重复数据数为:'.$lists->count(),
|
||||
];
|
||||
|
||||
foreach ($data as $info) {
|
||||
@@ -69,4 +77,122 @@ class TestController
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 设置日志关联
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2022/1/19 11:12
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*/
|
||||
public function coupon(Request $request)
|
||||
{
|
||||
$type = $request->type ?? '';
|
||||
$date = $request->date ?? '';
|
||||
|
||||
if (! $type) {
|
||||
dd('type 错误');
|
||||
}
|
||||
|
||||
if (! $date) {
|
||||
dd('date 错误');
|
||||
}
|
||||
|
||||
$name = 'api_log_'.$date;//表名
|
||||
if (! Schema::hasTable($name)) {
|
||||
dd('数据表不存在');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn($name, 'coupon_no')) {
|
||||
Schema::table($name, function (Blueprint $table) {
|
||||
$table->string('coupon_no')->after('out_source')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置日志
|
||||
*/
|
||||
if ($type == 'log') {
|
||||
|
||||
(new Log())->setTable($name)
|
||||
->whereNull('coupon_no')
|
||||
->where('path', 'http://api.pingan.com.cn/open/vassPartner/appsvr/property/api/new/partner/redemption')
|
||||
->where('out_source->code', 200)
|
||||
->chunkById(1000, function ($logs) use ($name) {
|
||||
foreach ($logs as $log) {
|
||||
$data = (new Verification())->decrypt($log->in_source['json']['data']);
|
||||
$data = json_decode($data, true);
|
||||
$log->update([
|
||||
'coupon_no' => $data['couponNo']
|
||||
]);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
dd($name.' 表日志设置完成');
|
||||
|
||||
}
|
||||
|
||||
if ($type == 'coupon') {
|
||||
(new Log())->setTable($name)
|
||||
->whereHas('coupon', function ($q) {
|
||||
$q->whereNull('pa_order_id');
|
||||
})
|
||||
->where('path', 'http://api.pingan.com.cn/open/vassPartner/appsvr/property/api/new/partner/redemption')
|
||||
->where('out_source->code', 200)
|
||||
->chunkById(1000, function ($logs) use ($name) {
|
||||
foreach ($logs as $log) {
|
||||
$log->coupon->update([
|
||||
'pa_order_id' => $log->out_source['data']['orderId'],
|
||||
'pa_sub_order_id' => $log->out_source['data']['subOrderId'],
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
dd($name.' 表关联的优惠券设置完成');
|
||||
}
|
||||
|
||||
|
||||
dd(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 设置数据
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2022/1/19 13:29
|
||||
*/
|
||||
public function checkCouponLog(Request $request)
|
||||
{
|
||||
$type = $request->type ?? '';
|
||||
|
||||
if (! $type) {
|
||||
dd('type 错误');
|
||||
}
|
||||
|
||||
$tables = DB::connection()->getDoctrineSchemaManager()->listTableNames();
|
||||
|
||||
foreach ($tables as $table) {
|
||||
|
||||
if (Str::contains($table, 'api_log_')) {
|
||||
echo " 开始处理 ".$table." <br>";
|
||||
|
||||
if (! Schema::hasColumn($table, 'coupon_no')) {
|
||||
Schema::table($table, function (Blueprint $table) {
|
||||
$table->string('coupon_no')->after('out_source')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
if ($type == 'log') {
|
||||
CheckCouponLog::dispatch($table);
|
||||
}
|
||||
|
||||
if ($type == 'coupon') {
|
||||
CheckCouponByLog::dispatch($table);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class IndexController extends AdminController
|
||||
* @Date : 2019/9/18 14:50
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
protected function grid(): Grid
|
||||
{
|
||||
$user = Auth::guard('admin')->user();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user