457 lines
19 KiB
PHP
457 lines
19 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: shenyang
|
|
* Date: 2018/12/24
|
|
* Time: 3:38 PM
|
|
*/
|
|
|
|
namespace Yunshop\RedPacket;
|
|
|
|
|
|
use Config;
|
|
use Yunshop\Integral\Common\CommonService;
|
|
use Yunshop\Integral\Common\Config\MenuHook;
|
|
use Yunshop\InterestsDividend\listeners\OrderPaidListener;
|
|
use Yunshop\RedPacket\services\GoodsDetailService;
|
|
|
|
class PluginApplication extends \app\common\services\PluginApplication
|
|
{
|
|
|
|
public function getIncomePageItems()
|
|
{
|
|
return [
|
|
'RedPacket' => [
|
|
'class' => 'Yunshop\RedPacket\services\IncomePageService',
|
|
'type' => 'marketing'
|
|
]
|
|
];
|
|
}
|
|
|
|
public function getIncomeItems()
|
|
{
|
|
|
|
/**
|
|
* 收入页面信息配置
|
|
*/
|
|
return [
|
|
//每日红包
|
|
'RedPacket' => [
|
|
'title' => trans('Yunshop\RedPacket::index.title'),
|
|
'type' => 'RedPacket',
|
|
'type_name' => trans('Yunshop\RedPacket::index.title'),
|
|
'class' => 'Yunshop\RedPacket\models\ReceiveLogsModel',
|
|
'order_class' => '',
|
|
],
|
|
//每日红包-额外奖励
|
|
'RedPacketBonus' => [
|
|
'title' => trans('Yunshop\RedPacket::index.title') . '-额外奖励',
|
|
'type' => 'RedPacketBonus',
|
|
'type_name' => trans('Yunshop\RedPacket::index.title') . '-额外奖励',
|
|
'class' => 'Yunshop\RedPacket\models\BonusReceiveLogsModel',
|
|
'order_class' => '',
|
|
],
|
|
];
|
|
}
|
|
|
|
public function getWidgetItems()
|
|
{
|
|
return [
|
|
'withdraw.tab_red_packet' => [
|
|
'title' => '每日红包提现',
|
|
'class' => 'Yunshop\RedPacket\widgets\RedPacketWithdrawWidget'
|
|
],
|
|
'vue-goods.red_packet' => [
|
|
'title' => '每日红包',
|
|
'class' => \Yunshop\RedPacket\widgets\RedPacketGoodsVueWidget::class
|
|
],
|
|
|
|
];
|
|
}
|
|
|
|
public function getTemplateItems()
|
|
{
|
|
return ['red_packet_enrol' => [
|
|
'title' => '每日红包(获得红包额度奖励通知)',
|
|
'subtitle' => '获得红包额度奖励通知',
|
|
'value' => 'red_packet_enrol',
|
|
'param' => [
|
|
'昵称', '时间', '获得红包额度金额', '累计的红包额度金额', '已领取的红包总额', '未领取的红包总额'
|
|
]
|
|
], 'red_packet_sign_notice' => [
|
|
'title' => '每日红包(获得红包奖励通知)',
|
|
'subtitle' => '获得红包奖励通知',
|
|
'value' => 'red_packet_bonus_notice',
|
|
'param' => [
|
|
'昵称', '时间', '获得红包金额', '累计的红包额度金额', '当前已领取的红包总额', '当前未领取的红包总额'
|
|
]
|
|
]];
|
|
}
|
|
|
|
protected function setConfig()
|
|
{
|
|
/**
|
|
* 商品挂件
|
|
*/
|
|
|
|
\app\common\modules\shop\ShopConfig::current()->set(
|
|
'observer.goods.red_packet', [
|
|
'class' => 'Yunshop\RedPacket\models\RedPacketGoodsModel',
|
|
// 'function_validator'=>'relationValidator',
|
|
'function_save' => 'relationSave'
|
|
]
|
|
);
|
|
|
|
|
|
//订单支付成功页显示预计奖励数据
|
|
\app\common\modules\shop\ShopConfig::current()->push('shop-foundation.pay-page.reward',
|
|
[
|
|
'code' => 'red-packet',
|
|
'class' => function (\app\frontend\modules\payment\services\page\PaymentPageInterface $page) {
|
|
return new \Yunshop\RedPacket\common\RedPacketPayPageReward($page);
|
|
},
|
|
]
|
|
);
|
|
|
|
}
|
|
|
|
protected function setMenuConfig()
|
|
{
|
|
|
|
/**
|
|
* 菜单、权限、路由
|
|
*/
|
|
\app\backend\modules\menu\Menu::current()->setPluginMenu('red-packet', [
|
|
'name' => '每日红包',
|
|
'type' => 'marketing',
|
|
'url' => 'plugin.red-packet.admin.set.index',// url 可以填写http 也可以直接写路由
|
|
'url_params' => '',//如果是url填写的是路由则启用参数否则不启用
|
|
'permit' => 1,//如果不设置则不会做权限检测
|
|
'menu' => 1,//如果不设置则不显示菜单,子菜单也将不显示
|
|
'top_show' => 0,
|
|
'left_first_show' => 0,
|
|
'left_second_show' => 1,
|
|
'icon' => 'fa-link',//菜单图标
|
|
'list_icon' => 'red-packet',//菜单图标
|
|
'parents' => [],
|
|
'child' => [
|
|
'plugin.red-packet.admin.set' => [
|
|
'name' => '基础设置',
|
|
'permit' => 1,
|
|
'menu' => 1,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.set.index',
|
|
'url_parmas' => [],
|
|
'parents' => ['red-packet'],
|
|
'child' => [
|
|
'plugin.red-packet.admin.set.searchGoods' => [
|
|
'name' => '商品搜索',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.set.searchGoods',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'plugin.red-packet.admin.set.searchGoods']
|
|
]
|
|
]
|
|
],
|
|
'plugin.red-packet.admin.set.gradsPage' => [
|
|
'name' => '梯度设置',
|
|
'permit' => 1,
|
|
'menu' => 1,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.set.gradsPage',
|
|
'url_parmas' => [],
|
|
'parents' => ['red-packet'],
|
|
'child' => [
|
|
'plugin.red-packet.admin.set.gradsSave' => [
|
|
'name' => '梯度设置保存',
|
|
'permit' => 0,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.set.gradsSave',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'plugin.red-packet.admin.set.gradsPage']
|
|
]
|
|
]
|
|
],
|
|
'plugin.red-packet.admin.red-packet-logs' => [
|
|
'name' => '每日红包记录',
|
|
'permit' => 1,
|
|
'menu' => 1,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.red-packet-logs.index',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet'],
|
|
'child' => [
|
|
'plugin.red-packet.admin.red-packet-logs-export' => [
|
|
'name' => '红包记录导出',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.red-packet-logs.export',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'red-packet.admin.red-packet-logs']
|
|
],
|
|
'plugin.red-packet.admin.red-packet-logs' => [
|
|
'name' => '红包记录搜索',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.red-packet-logs.index',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'red-packet.admin.red-packet-logs']
|
|
],
|
|
'plugin.red-packet.admin.receive.log-index' => [
|
|
'name' => '领取记录',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.receive.log.index',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'red-packet.admin.red-packet-logs']
|
|
],
|
|
'plugin.red-packet.admin.red-packet-logs.red-detail' => [
|
|
'name' => '商城订单比例列表',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.red-packet-logs.red-detail',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'red-packet.admin.red-packet-logs']
|
|
],
|
|
'plugin.red-packet.admin.red-packet-logs.store-detail' => [
|
|
'name' => '门店订单比例列表',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.red-packet-logs.store-detail',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'red-packet.admin.red-packet-logs']
|
|
],
|
|
'plugin.red-packet.admin.red-packet-logs.cashier-detail' => [
|
|
'name' => '收银台订单比例列表',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.red-packet-logs.cashier-detail',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'red-packet.admin.red-packet-logs']
|
|
],
|
|
'plugin.red-packet.admin.red-packet-logs.cps-detail' => [
|
|
'name' => 'cps比例列表',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.red-packet-logs.cps-detail',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'red-packet.admin.red-packet-logs']
|
|
],
|
|
|
|
]
|
|
],
|
|
'plugin.red-packet.admin.receive-logs' => [
|
|
'name' => '领取记录',
|
|
'permit' => 1,
|
|
'menu' => 1,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.receive-logs.index',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet'],
|
|
'child' => [
|
|
'plugin.red-packet.admin.receive-logs-export' => [
|
|
'name' => '领取记录导出',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.receive-logs.export',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'red-packet.admin.receive-logs']
|
|
],
|
|
'plugin.red-packet.admin.receive-logs-index' => [
|
|
'name' => '领取记录搜索',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.receive-logs.index',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'red-packet.admin.receive-logs']
|
|
],
|
|
]
|
|
],
|
|
'plugin.red-packet.admin.quota-management' => [
|
|
'name' => '红包额度管理',
|
|
'permit' => 1,
|
|
'menu' => 1,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.quota-management.index',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet'],
|
|
'child' => [
|
|
'plugin.red-packet.admin.quota-management-export' => [
|
|
'name' => '红包管理额度导出',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.quota-management.export',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'red-packet.admin.quota-management']
|
|
],
|
|
'plugin.red-packet.admin.quota-management-index' => [
|
|
'name' => '红包管理额度搜索',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.quota-management.index',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'red-packet.admin.quota-management']
|
|
],
|
|
'plugin.red-packet.admin.quota-logs-index' => [
|
|
'name' => '红包管理额度记录',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.quota-logs.index',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'red-packet.admin.quota-logs']
|
|
]
|
|
]
|
|
],
|
|
'plugin.red-packet.admin.quota-logs' => [
|
|
'name' => '红包额度记录',
|
|
'permit' => 1,
|
|
'menu' => 1,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.quota-logs.index',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet'],
|
|
'child' => [
|
|
'plugin.red-packet.admin.quota-logs-export' => [
|
|
'name' => '红包额度记录导出',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.quota-logs.export',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'red-packet.admin.quota-logs']
|
|
],
|
|
'plugin.red-packet.admin.quota-logs' => [
|
|
'name' => '红包额度记录搜索',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.quota-logs.index',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'red-packet.admin.quota-logs']
|
|
]
|
|
]
|
|
],
|
|
'plugin.red-packet.admin.import' => [
|
|
'name' => '额度导入',
|
|
'permit' => 1,
|
|
'menu' => 1,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.import.index',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet'],
|
|
'child' => [
|
|
'plugin.red-packet.admin.import_example' => [
|
|
'name' => '额度导入模板',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.import.example',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'plugin.red-packet.admin.import']
|
|
],
|
|
'plugin.red-packet.admin.import_confirm' => [
|
|
'name' => '额度导入确定',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.import.confirm',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'plugin.red-packet.admin.import']
|
|
],
|
|
'plugin.red-packet.admin.import_records' => [
|
|
'name' => '额度导入记录',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.import.records',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'plugin.red-packet.admin.import']
|
|
],
|
|
]
|
|
],
|
|
'plugin.red-packet.admin.bonus-logs' => [
|
|
'name' => '额外奖励',
|
|
'permit'=> 1,
|
|
'menu' =>1,
|
|
'icon' =>'',
|
|
'url' => 'plugin.red-packet.admin.bonus-logs',
|
|
'url_params'=>[],
|
|
'parents' => ['red-packet'],
|
|
'child'=>[
|
|
'plugin.red-packet.admin.bonus-logs-export' => [
|
|
'name' => '额外奖励-导出',
|
|
'permit' => 1,
|
|
'menu' => 0,
|
|
'icon' => '',
|
|
'url' => 'plugin.red-packet.admin.bonus-logs.export',
|
|
'url_params' => [],
|
|
'parents' => ['red-packet', 'plugin.red-packet.admin.bonus-logs']
|
|
],
|
|
]
|
|
],
|
|
|
|
|
|
]
|
|
|
|
]);
|
|
}
|
|
|
|
public function getFrontendWidgetConfig(): array
|
|
{
|
|
return [
|
|
'goods_detail.red-packet' => GoodsDetailService::class,
|
|
];
|
|
}
|
|
|
|
public function boot()
|
|
{
|
|
|
|
$events = app('events');
|
|
/**
|
|
* 定时任务 红包
|
|
*/
|
|
|
|
|
|
/**
|
|
* 支付完成
|
|
*/
|
|
$events->subscribe(\Yunshop\RedPacket\Listener\OrderPaidListener::class);
|
|
/**
|
|
* 订单完成
|
|
*/
|
|
$events->subscribe(\Yunshop\RedPacket\Listener\OrderReceiveListener::class);
|
|
/**
|
|
* 订单关闭
|
|
*/
|
|
$events->subscribe(\Yunshop\RedPacket\Listener\OrderCanceledListener::class);
|
|
}
|
|
|
|
public function register()
|
|
{
|
|
}
|
|
public function cronConfig()
|
|
{
|
|
\Event::listen('cron.collectJobs', function () {
|
|
\Cron::add('RedPacket', '*/10 0 * * *', function () {
|
|
(new \Yunshop\RedPacket\services\TimedTaskServices)->handle();
|
|
return;
|
|
});
|
|
});
|
|
|
|
}
|
|
} |