137 lines
4.6 KiB
PHP
137 lines
4.6 KiB
PHP
<?php
|
|
namespace Yunshop\Rebate;
|
|
|
|
use Yunshop\Rebate\listener\OrderPaidListener;
|
|
use Yunshop\Rebate\models\Rebate;
|
|
|
|
class PluginApplication extends \app\common\services\PluginApplication{
|
|
|
|
protected function setMenuConfig(){
|
|
|
|
\app\backend\modules\menu\Menu::current()->setPluginMenu('rebate', [
|
|
'name' => '消费返利',
|
|
'type' => 'marketing',
|
|
'url' => 'plugin.rebate.admin.index.index',// url 可以填写http 也可以直接写路由
|
|
'url_params' => '',//如果是url填写的是路由则启用参数否则不启用
|
|
'permit' => 1,//如果不设置则不会做权限检测
|
|
'menu' => 1,//如果不设置则不显示菜单,子菜单也将不显示
|
|
'icon' => '',//菜单图标
|
|
'list_icon' => 'rebate',
|
|
'parents' => [],
|
|
'top_show' => 0,
|
|
'left_first_show' => 0,
|
|
'left_second_show' => 1,
|
|
'child' => [
|
|
'plugin_rebate_index' => [
|
|
'name' => '返利列表',
|
|
'permit' => 1,
|
|
'menu' => 1,
|
|
'icon' => '',
|
|
'url' => 'plugin.rebate.admin.index.index',
|
|
'url_params' => '',
|
|
'item' => 'plugin_rebate_index',
|
|
'parents' => ['rebate'],
|
|
'child' => [
|
|
// 权限补充
|
|
'plugin_rebate_index_index' => [
|
|
'name' => '返利列表',
|
|
'url' => 'plugin.rebate.admin.index.index',
|
|
'url_params' => '',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'item' => 'plugin_rebate_index_index',
|
|
'parents' => ['rebate','plugin_rebate_index']
|
|
],
|
|
]
|
|
],
|
|
'plugin_rebate_set' => [
|
|
'name' => '基本设置',
|
|
'permit' => 1,
|
|
'menu' => 1,
|
|
'icon' => '',
|
|
'url' => 'plugin.rebate.admin.index.set',
|
|
'url_params' => '',
|
|
'parents' => ['rebate'],
|
|
'child' => [
|
|
// 权限补充
|
|
'plugin_rebate_index_set' => [
|
|
'name' => '基本设置',
|
|
'url' => 'plugin.rebate.admin.index.set',
|
|
'url_params' => '',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'item' => 'plugin_rebate_index_set',
|
|
'parents' => ['rebate', 'plugin_rebate_set'],
|
|
],
|
|
]
|
|
],
|
|
]
|
|
]);
|
|
}
|
|
|
|
public function getWidgetItems()
|
|
{
|
|
return [
|
|
'withdraw.rebate_commission' => [
|
|
'title' => '消费返利提现',
|
|
'class' => 'Yunshop\Rebate\admin\widget\RebateWithdrawWidget'
|
|
],
|
|
'vue-goods.rebate' => [
|
|
'title' => '消费返利',
|
|
'class' => \Yunshop\Rebate\admin\widget\RebateWidget::class,
|
|
],
|
|
];
|
|
}
|
|
|
|
protected function setConfig(){
|
|
\app\common\modules\shop\ShopConfig::current()->set(
|
|
'observer.goods.rebate', [
|
|
'class' => 'Yunshop\Rebate\models\GoodsRebate',
|
|
'function_save' => 'relationSave'
|
|
]
|
|
);
|
|
}
|
|
|
|
public function getIncomeItems(){
|
|
return [
|
|
'rebate' => [
|
|
'title' => '养殖收益',
|
|
'type' => 'rebate',
|
|
'type_name' => '养殖收益',
|
|
'class' => 'Yunshop\Rebate\models\Rebate',
|
|
]
|
|
];
|
|
}
|
|
|
|
public function boot(){
|
|
$events = app('events');
|
|
// 订单支付成功
|
|
$events->subscribe(OrderPaidListener::class);
|
|
|
|
}
|
|
|
|
|
|
public function cronConfig(){
|
|
\Event::listen('cron.collectJobs', function () {
|
|
// 每5分钟 执行一次消费返利解冻判断
|
|
\Cron::add('rebate-settlement', '*/5 * * * *', function () {
|
|
Rebate::rebateThaw();
|
|
return;
|
|
});
|
|
// 每5分钟 执行一次消费返利失效判断
|
|
\Cron::add('rebate-lose-efficacy', '*/1 * * * *', function () {
|
|
Rebate::loseEfficacy();
|
|
return;
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
}
|
|
|
|
|
|
|
|
} |