初始上传
This commit is contained in:
27
addon/discount/event/CloseDiscount.php
Executable file
27
addon/discount/event/CloseDiscount.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\discount\event;
|
||||
|
||||
use addon\discount\model\Discount;
|
||||
|
||||
/**
|
||||
* 关闭活动
|
||||
*/
|
||||
class CloseDiscount
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$discount = new Discount();
|
||||
$res = $discount->cronCloseDiscount($params[ 'relate_id' ]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
61
addon/discount/event/GoodsPromotion.php
Executable file
61
addon/discount/event/GoodsPromotion.php
Executable file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\discount\event;
|
||||
|
||||
use addon\discount\model\Discount;
|
||||
use app\model\goods\Goods as GoodsModel;
|
||||
|
||||
/**
|
||||
* 商品营销活动信息
|
||||
*/
|
||||
class GoodsPromotion
|
||||
{
|
||||
|
||||
/**
|
||||
* 商品营销活动信息
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
if (isset($param['goods_sku_detail'])) {
|
||||
$goods_info = $param['goods_sku_detail'];
|
||||
if (!empty($goods_info['promotion_addon'])) {
|
||||
$promotion_addon = json_decode($goods_info['promotion_addon'], true);
|
||||
if (!empty($promotion_addon['discount'])) {
|
||||
return [
|
||||
'promotion_type' => 'discount',
|
||||
'promotion_name' => '限时折扣',
|
||||
'goods_id' => $promotion_addon['discount']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (empty($param['goods_id'])) return [];
|
||||
$goods_model = new GoodsModel();
|
||||
$goods_info = $goods_model->getGoodsInfo([['goods_id', '=', $param['goods_id']]], 'promotion_addon')['data'];
|
||||
if (!empty($goods_info['promotion_addon'])) {
|
||||
$promotion_addon = json_decode($goods_info['promotion_addon'], true);
|
||||
if (!empty($promotion_addon['discount'])) {
|
||||
$discount_model = new Discount();
|
||||
$goods_detail = $discount_model->getDiscountGoodsDetail($promotion_addon['discount'], $param['goods_id'], $param['sku_id'])['data'];
|
||||
if (!empty($goods_detail)) {
|
||||
$goods_detail['promotion_type'] = 'discount';
|
||||
$goods_detail['promotion_name'] = '限时折扣';
|
||||
return $goods_detail;
|
||||
}
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
28
addon/discount/event/GoodsPromotionType.php
Executable file
28
addon/discount/event/GoodsPromotionType.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\discount\event;
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
*/
|
||||
class GoodsPromotionType
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return [ 'name' => '限时折扣', 'short' => '折', 'type' => 'discount', 'color' => '#22AFB9', 'url' => 'discount://shop/discount/lists' ];
|
||||
}
|
||||
}
|
||||
26
addon/discount/event/Install.php
Executable file
26
addon/discount/event/Install.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\discount\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
28
addon/discount/event/OpenDiscount.php
Executable file
28
addon/discount/event/OpenDiscount.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\discount\event;
|
||||
|
||||
use addon\discount\model\Discount;
|
||||
|
||||
/**
|
||||
* 启动活动
|
||||
*/
|
||||
class OpenDiscount
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$discount = new Discount();
|
||||
$res = $discount->cronOpenDiscount($params['relate_id']);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
97
addon/discount/event/ShowPromotion.php
Executable file
97
addon/discount/event/ShowPromotion.php
Executable file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\discount\event;
|
||||
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class ShowPromotion
|
||||
{
|
||||
public $promotion_type = 'time_limit';
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
public function handle($params = [])
|
||||
{
|
||||
$data = [
|
||||
'shop' => [
|
||||
[
|
||||
//插件名称
|
||||
'name' => 'discount',
|
||||
//店铺端展示分类 shop:营销活动 member:互动营销
|
||||
'show_type' => 'shop',
|
||||
//展示主题
|
||||
'title' => '限时折扣',
|
||||
//展示介绍
|
||||
'description' => '商品限时促销打折',
|
||||
//展示图标
|
||||
'icon' => 'addon/discount/icon.png',
|
||||
//跳转链接
|
||||
'url' => 'discount://shop/discount/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_discount")->getCount([ [ 'site_id', '=', $params[ 'site_id' ] ] ]);
|
||||
return [
|
||||
'count' => $count
|
||||
];
|
||||
}
|
||||
//获取活动概况,需要获取开始时间与结束时间
|
||||
if (isset($params[ 'summary' ])) {
|
||||
$join = [
|
||||
[ 'goods g', 'd.goods_id = g.goods_id', 'inner' ]
|
||||
];
|
||||
$list = model("promotion_discount")->getList([
|
||||
[ '', 'exp', Db::raw('not ( (`start_time` >= ' . $params[ 'end_time' ] . ') or (`end_time` <= ' . $params[ 'start_time' ] . '))') ],
|
||||
[ 'd.site_id', '=', $params[ 'site_id' ] ],
|
||||
[ 'd.status', '<>', 2 ],
|
||||
[ 'd.status', '<>', -1 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
], 'd.discount_name as promotion_name,d.discount_id as promotion_id,d.start_time,d.end_time', 'd.create_time desc', 'd', $join);
|
||||
return !empty($list) ? [
|
||||
'time_limit' => [
|
||||
'count' => count($list),
|
||||
'detail' => $list,
|
||||
'color' => '#6D66FF'
|
||||
]
|
||||
] : [];
|
||||
}
|
||||
}
|
||||
}
|
||||
26
addon/discount/event/UnInstall.php
Executable file
26
addon/discount/event/UnInstall.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\discount\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return error("系统插件不能删除");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user