初始上传
This commit is contained in:
28
addon/manjian/event/CloseManjian.php
Executable file
28
addon/manjian/event/CloseManjian.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\manjian\event;
|
||||
|
||||
use addon\manjian\model\Manjian;
|
||||
|
||||
/**
|
||||
* 关闭活动
|
||||
*/
|
||||
class CloseManjian
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$manjian = new Manjian();
|
||||
$res = $manjian->cronCloseManjian($params['relate_id']);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
31
addon/manjian/event/Install.php
Executable file
31
addon/manjian/event/Install.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\manjian\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
execute_sql('addon/manjian/data/install.sql');
|
||||
return success();
|
||||
} catch (\Exception $e) {
|
||||
return error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
37
addon/manjian/event/MemberAccountFromType.php
Executable file
37
addon/manjian/event/MemberAccountFromType.php
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\manjian\event;
|
||||
|
||||
/**
|
||||
* 会员账户变化来源类型
|
||||
*/
|
||||
class MemberAccountFromType
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
$from_type = [
|
||||
'point' => [
|
||||
'manjian' => [
|
||||
'type_name' => '满减送',
|
||||
'type_url' => '',
|
||||
],
|
||||
]
|
||||
];
|
||||
if ($data == '') {
|
||||
return $from_type;
|
||||
} else {
|
||||
return $from_type[$data] ?? [];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
28
addon/manjian/event/OpenManjian.php
Executable file
28
addon/manjian/event/OpenManjian.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\manjian\event;
|
||||
|
||||
use addon\manjian\model\Manjian;
|
||||
|
||||
/**
|
||||
* 启动活动
|
||||
*/
|
||||
class OpenManjian
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$manjian = new Manjian();
|
||||
$res = $manjian->cronOpenManjian($params['relate_id']);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
28
addon/manjian/event/OrderPayAfter.php
Executable file
28
addon/manjian/event/OrderPayAfter.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\manjian\event;
|
||||
|
||||
use addon\manjian\model\Order;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* 订单完成
|
||||
*/
|
||||
class OrderPayAfter
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$order = new Order();
|
||||
$order->orderPay($params);
|
||||
}
|
||||
}
|
||||
70
addon/manjian/event/OrderRefundAllFinish.php
Executable file
70
addon/manjian/event/OrderRefundAllFinish.php
Executable file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\manjian\event;
|
||||
|
||||
use addon\coupon\model\MemberCoupon;
|
||||
use app\dict\member_account\AccountDict;
|
||||
use app\model\member\MemberAccount;
|
||||
|
||||
/**
|
||||
* 订单完全退款后收回奖励
|
||||
*/
|
||||
class OrderRefundAllFinish
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$order_info = $params['order_info'];
|
||||
$member_id = $order_info['member_id'];
|
||||
$site_id = $order_info['site_id'];
|
||||
//散客不参与
|
||||
if ($member_id > 0) {
|
||||
$order_id = $order_info['order_id'];
|
||||
$list = model('promotion_mansong_record')->getList([['order_id', '=', $order_id], ['status', '=', 1]]);
|
||||
if (!empty($list)) {
|
||||
$member_coupon_model = new MemberCoupon();
|
||||
foreach ($list as $item) {
|
||||
try {
|
||||
// 发放积分
|
||||
$point = $item[ 'point' ] ?? 0;
|
||||
if ($point > 0) {
|
||||
$member_account = new Memberaccount();
|
||||
$member_account->addMemberAccount($site_id, $member_id, AccountDict::point, -$point, 'point_cancel', $item[ 'manjian_id' ], '活动奖励取消');
|
||||
}
|
||||
// 发放优惠券
|
||||
$coupon = $item['coupon'] ?? '';
|
||||
$coupon_num = $item['coupon_num'] ?? '';
|
||||
if ($coupon && $coupon_num) {
|
||||
$coupon_list = explode(',', $coupon);
|
||||
$coupon_num = explode(',', $coupon_num);
|
||||
$coupon_data = [];
|
||||
foreach ($coupon_list as $k => $coupon_item) {
|
||||
$coupon_data[] = [
|
||||
'coupon_type_id' => $coupon_item,
|
||||
'num' => $coupon_num[ $k ] ?? 1
|
||||
];
|
||||
}
|
||||
$member_coupon_model->cancelByPromotion([
|
||||
'coupon_data' => $coupon_data,
|
||||
'member_id' => $member_id,
|
||||
]);
|
||||
}
|
||||
// 定义为收回奖励
|
||||
model('promotion_mansong_record')->update([ 'status' => 2 ], [ [ 'id', '=', $item[ 'id' ] ] ]);
|
||||
model('promotion_mansong_record')->commit();
|
||||
} catch (\Exception $e) {
|
||||
model('promotion_mansong_record')->rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
90
addon/manjian/event/ShowPromotion.php
Executable file
90
addon/manjian/event/ShowPromotion.php
Executable file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\manjian\event;
|
||||
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class ShowPromotion
|
||||
{
|
||||
public $promotion_type = 'time_limit';
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
public function handle($params = [])
|
||||
{
|
||||
$data = [
|
||||
'shop' => [
|
||||
[
|
||||
//插件名称
|
||||
'name' => 'manjian',
|
||||
//店铺端展示分类 shop:营销活动 member:互动营销
|
||||
'show_type' => 'shop',
|
||||
//展示主题
|
||||
'title' => '满减活动',
|
||||
//展示介绍
|
||||
'description' => '购满指定金额享受优惠',
|
||||
//展示图标
|
||||
'icon' => 'addon/manjian/icon.png',
|
||||
//跳转链接
|
||||
'url' => 'manjian://shop/manjian/lists',
|
||||
'summary' => $this->summary($params)
|
||||
]
|
||||
]
|
||||
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 营销活动概况
|
||||
* @param $params
|
||||
* @return array
|
||||
*/
|
||||
private function summary($params)
|
||||
{
|
||||
if (empty($params)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if(isset($params['promotion_type']) && $params['promotion_type'] != $this->promotion_type){
|
||||
return [];
|
||||
}
|
||||
|
||||
//获取活动数量
|
||||
if (isset($params[ 'count' ])) {
|
||||
$count = model("promotion_manjian")->getCount([ [ 'site_id', '=', $params[ 'site_id' ] ] ]);
|
||||
return [
|
||||
'count' => $count
|
||||
];
|
||||
}
|
||||
//获取活动概况,需要获取开始时间与结束时间
|
||||
if (isset($params[ 'summary' ])) {
|
||||
$list = model("promotion_manjian")->getList([
|
||||
[ '', 'exp', Db::raw('not ( (`start_time` >= ' . $params[ 'end_time' ] . ') or (`end_time` <= ' . $params[ 'start_time' ] . '))') ],
|
||||
[ 'site_id', '=', $params[ 'site_id' ] ],
|
||||
[ 'status', '<>', -1 ]
|
||||
], 'manjian_name as promotion_name,manjian_id as promotion_id,start_time,end_time');
|
||||
return !empty($list) ? [
|
||||
'time_limit' => [
|
||||
'count' => count($list),
|
||||
'detail' => $list,
|
||||
'color' => '#FFA666'
|
||||
]
|
||||
] : [];
|
||||
}
|
||||
}
|
||||
}
|
||||
31
addon/manjian/event/UnInstall.php
Executable file
31
addon/manjian/event/UnInstall.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\manjian\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
return error('', "系统插件不允许删除");
|
||||
//execute_sql('addon/manjian/data/uninstall.sql');
|
||||
//return success();
|
||||
} catch (\Exception $e) {
|
||||
return error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user