admin/addon/divideticket/event/ShowPromotion.php

89 lines
2.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* ThinkShop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 成都云之牛科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.cdcloudshop.com
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
* =========================================================
*/
namespace addon\divideticket\event;
use think\facade\Db;
/**
* 活动展示
*/
class ShowPromotion
{
/**
* 活动展示
* @param array $params
* @return array
*/
public function handle($params = [])
{
$data = [
'shop' => [
[
//插件名称
'name' => 'divideticket',
//展示分类根据平台端设置admin平台营销shop店铺营销member:会员营销, tool:应用工具)
'show_type' => 'member',
//展示主题
'title' => '好友瓜分券',
//展示介绍
'description' => '帮助商家提升客单价',
//展示图标
'icon' => 'addon/divideticket/icon.png',
//跳转链接
'url' => 'divideticket://shop/divideticket/lists',
'summary' => $this->summary($params)
],
],
];
return $data;
}
/**
* 营销活动概况
* @param $params
* @return array
*/
private function summary($params)
{
if (empty($params)) {
return [];
}
//获取活动数量
if (isset($params[ 'count' ])) {
$count = model("promotion_friends_coupon")->getCount();
return [
'count' => $count
];
}
//获取活动概况,需要获取开始时间与结束时间
if (isset($params[ 'summary' ])) {
$list = model("promotion_friends_coupon")->getList([
[ '', 'exp', Db::raw('not ( (`start_time` >= ' . $params[ 'end_time' ] . ') or (`end_time` <= ' . $params[ 'start_time' ] . '))') ],
[ 'site_id', '=', $params[ 'site_id' ] ],
[ 'status', '<>', 2 ],
[ 'status', '<>', -1 ]
], 'name as promotion_name,coupon_id as promotion_id,start_time,end_time');
return !empty($list) ? [
'time_limit' => [
'count' => count($list),
'detail' => $list,
'color' => '#7BE295'
]
] : [];
}
}
}