138 lines
5.8 KiB
PHP
138 lines
5.8 KiB
PHP
<?php
|
|
/**
|
|
* SAAS应用系统 --- 十年开发经验汇集巨献!
|
|
* ==========================================================
|
|
* Copy right 2020-2050 成都众联思索科技有限公司,保留所有权利。
|
|
* ----------------------------------------------------------
|
|
* 官方网址: https://www.zoomtk.com
|
|
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
|
* 任何企业和个人未经允许对程序代码以任何形式任何目的再发布传播。
|
|
* 唯一发布渠道www.zoomtk.com;非官方渠道统一视为侵权行为。
|
|
* ==========================================================
|
|
*/
|
|
namespace addon\saas\shop\controller;
|
|
use app\model\system\Promotion as PrmotionModel;
|
|
use app\model\system\SiteGroup;
|
|
class Group extends SaasBase
|
|
{
|
|
/***
|
|
* 获取套餐列表
|
|
* @return array|mixed
|
|
*/
|
|
public function lists()
|
|
{
|
|
if (request()->isAjax()) {
|
|
$page = input('page', 1);
|
|
$page_size = input('page_size', PAGE_LIST_ROWS);
|
|
$search_text = input('search_text', '');
|
|
$condition = [];
|
|
$condition[] = ['site_id', '=', $this->site_id];
|
|
$condition[] = ['group_name', 'like', '%' . $search_text . '%'];
|
|
$order = 'fee asc';
|
|
$field = '*';
|
|
$group_model = new SiteGroup();
|
|
$info = $group_model->getSiteGroupPageList($condition, $page, $page_size, $order, $field);
|
|
return $info;
|
|
}
|
|
return $this->fetch('group/lists');
|
|
}
|
|
|
|
/**
|
|
* 添加套餐
|
|
* @return array|mixed
|
|
*/
|
|
public function addgroup()
|
|
{
|
|
$promotion_model = new PrmotionModel();
|
|
$promotions = $promotion_model->getPromotions();
|
|
if (request()->isAjax()) {
|
|
$data = [
|
|
'site_id' => $this->site_id,
|
|
'group_name' => input('group_name', ''),//分组名称
|
|
'fee_type' => input('fee_type', 'fixed_fee'),//年费
|
|
'image' => input('group_image', ''),//年费
|
|
'cloud_ids' => input('cloud_ids', ''),//云市场关联产品ID
|
|
'status' => input('status', 0),
|
|
'fee_commission' => input('fee_commission', 0),//年费
|
|
'fee' => input('fee', 0.00),//年费
|
|
'unit' => input('unit', 'month'),
|
|
'goods_number' => input('goods_number', 100),
|
|
'store_number' => input('store_number', 0),
|
|
'leader_number' => input('leader_number', 0),
|
|
'addon_array' => input('addon_array', ''),//营销插件权限组
|
|
'desc' => input('desc', ''),//备注
|
|
'ad_image' => input('ad_image', ''),//ad_image
|
|
];
|
|
$shop_group_model = new SiteGroup();
|
|
return $shop_group_model->addSiteGroup($data);
|
|
}
|
|
$this->assign("agent_type", $this->AgentInfo['agent_type']);
|
|
$this->assign("promotions", $promotions['shop']);
|
|
return $this->fetch('group/add');
|
|
}
|
|
|
|
/***
|
|
* 编辑套餐
|
|
* @return array|mixed
|
|
*/
|
|
public function editgroup()
|
|
{
|
|
$site_group_model = new SiteGroup();
|
|
$promotion_model = new PrmotionModel();
|
|
$promotions = $promotion_model->getPromotions();
|
|
$promotions = $promotions['shop'];
|
|
if (request()->isAjax()) {
|
|
$data = [
|
|
'site_id' => $this->site_id,
|
|
'group_name' => input('group_name', ''),//分组名称
|
|
'fee_type' => input('fee_type', 'fixed_fee'),//年费
|
|
'image' => input('group_image', ''),//年费
|
|
'cloud_ids' => input('cloud_ids', ''),//云市场关联产品ID
|
|
'fee_commission' => input('fee_commission', 0),//年费
|
|
'fee' => input('fee', 0.00),//年费
|
|
'status' => input('status', 0),
|
|
'unit' => input('unit', 'month'),
|
|
'goods_number' => input('goods_number', 100),
|
|
'store_number' => input('store_number', 0),
|
|
'leader_number' => input('leader_number', 0),
|
|
'addon_array' => input('addon_array', ''),//营销插件权限组
|
|
'desc' => input('desc', ''),//备注
|
|
'ad_image' => input('ad_image', ''),//ad_image
|
|
];
|
|
return $site_group_model->editSiteGroup($data, [['group_id', '=', input('group_id')]]);
|
|
} else {
|
|
$group_id = input('group_id', 0);
|
|
$group_info = $site_group_model->getSiteGroupInfo([['group_id', '=', $group_id], ['site_id', '=', $this->site_id]]);
|
|
$addon_array = !empty($group_info['data']['addon_array']) ? explode(',', $group_info['data']['addon_array']) : [];
|
|
foreach ($promotions as $key => &$promotion) {
|
|
if (!empty($promotion['is_developing'])) {
|
|
unset($promotions[$key]);
|
|
continue;
|
|
}
|
|
$promotion['is_checked'] = 0;
|
|
if (in_array($promotion['name'], $addon_array)) {
|
|
$promotion['is_checked'] = 1;
|
|
}
|
|
}
|
|
$this->assign("agent_type", $this->AgentInfo['agent_type']);
|
|
$this->assign('group_info', $group_info['data']);
|
|
$this->assign("promotions", $promotions);
|
|
return $this->fetch('group/edit');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 删除套餐
|
|
* @return array|void
|
|
*/
|
|
public function delgroup()
|
|
{
|
|
if (request()->isAjax() && $this->AgentInfo) {
|
|
$shop_group_model = new SiteGroup();
|
|
$where = [['group_id', '=', input('group_ids')], ['site_id', '=', $this->site_id]];
|
|
return $shop_group_model->deleteSiteGroup($where);
|
|
} else {
|
|
return $this->error('', '无权删除!或不存在');
|
|
}
|
|
}
|
|
} |