mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
增加折扣管理
This commit is contained in:
parent
1ac730b654
commit
96d2ffee4b
115
app/data/controller/UserDiscount.php
Normal file
115
app/data/controller/UserDiscount.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace app\data\controller;
|
||||
|
||||
use think\admin\Controller;
|
||||
|
||||
/**
|
||||
* 折扣方案管理
|
||||
* Class UserDiscount
|
||||
* @package app\data\controller
|
||||
*/
|
||||
class UserDiscount extends Controller
|
||||
{
|
||||
/**
|
||||
* 绑定数据表
|
||||
* @var string
|
||||
*/
|
||||
private $table = 'DataUserDiscount';
|
||||
|
||||
/**
|
||||
* 折扣方案管理
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '折扣方案管理';
|
||||
$query = $this->_query($this->table);
|
||||
$query->where(['deleted' => 0])->order('sort desc,id desc')->page();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表处理
|
||||
* @param array $data
|
||||
*/
|
||||
protected function _page_filter(array &$data)
|
||||
{
|
||||
foreach ($data as &$vo) {
|
||||
$vo['items'] = json_decode($vo['items'], true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加折扣方案
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑折扣方案
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$this->_form($this->table, 'form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单数据处理
|
||||
* @param array $vo
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
protected function _form_filter(array &$vo)
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$rule = [];
|
||||
foreach ($vo as $k => $v) if (stripos($k, '_level_') !== false) {
|
||||
[, $level] = explode('_level_', $k);
|
||||
$rule[] = ['level' => $level, 'discount' => $v];
|
||||
}
|
||||
$vo['items'] = json_encode($rule, JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$map = ['status' => 1];
|
||||
$this->levels = $this->app->db->name('DataUserLevel')->where($map)->order('number asc')->select()->toArray();
|
||||
if (!empty($vo['items'])) foreach (json_decode($vo['items'], true) as $item) {
|
||||
$vo["_level_{$item['level']}"] = $item['discount'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改折扣方案状态
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function state()
|
||||
{
|
||||
$this->_save($this->table);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除折扣方案配置
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function remove()
|
||||
{
|
||||
$this->_delete($this->table);
|
||||
}
|
||||
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\data\controller;
|
||||
|
||||
use app\data\service\PrizeService;
|
||||
use think\admin\Controller;
|
||||
|
||||
/**
|
||||
@ -39,6 +40,9 @@ class UserLevel extends Controller
|
||||
{
|
||||
foreach ($data as &$vo) {
|
||||
$vo['rebate_rule'] = str2arr($vo['rebate_rule']);
|
||||
foreach ($vo['rebate_rule'] as &$v) {
|
||||
$v = PrizeService::instance()->getName($v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +77,7 @@ class UserLevel extends Controller
|
||||
protected function _form_filter(array &$vo)
|
||||
{
|
||||
if ($this->request->isGet()) {
|
||||
$this->rules = ['首推奖利', '复购奖利', '直属团队', '间接团队', '差额奖励'];
|
||||
$this->prizes = PrizeService::PRIZES;
|
||||
$vo['rebate_rule'] = str2arr($vo['rebate_rule'] ?? '');
|
||||
} else {
|
||||
$vo['utime'] = time();
|
||||
@ -103,7 +107,7 @@ class UserLevel extends Controller
|
||||
{
|
||||
if ($state) {
|
||||
$order = 'number asc,utime desc';
|
||||
if (input('old_level', 100) < input('level', '0')) $order = 'number asc,utime asc';
|
||||
if (input('old_number', 100) < input('number', '0')) $order = 'number asc,utime asc';
|
||||
foreach ($this->app->db->name($this->table)->order($order)->cursor() as $k => $vo) {
|
||||
$this->app->db->name($this->table)->where(['id' => $vo['id']])->update(['number' => $k + 1]);
|
||||
}
|
||||
|
253
app/data/service/PrizeService.php
Normal file
253
app/data/service/PrizeService.php
Normal file
@ -0,0 +1,253 @@
|
||||
<?php
|
||||
|
||||
namespace app\data\service;
|
||||
|
||||
use think\admin\Service;
|
||||
use think\Exception;
|
||||
|
||||
/**
|
||||
* 用户奖励配置
|
||||
* Class PrizeService
|
||||
* @package app\data\service
|
||||
*/
|
||||
class PrizeService extends Service
|
||||
{
|
||||
const PRIZE_01 = 'prize_01';
|
||||
const PRIZE_02 = 'prize_02';
|
||||
const PRIZE_03 = 'prize_03';
|
||||
const PRIZE_04 = 'prize_04';
|
||||
const PRIZE_05 = 'prize_05';
|
||||
|
||||
const PRIZES = [
|
||||
self::PRIZE_01 => ['code' => self::PRIZE_01, 'name' => '首推奖励', 'func' => '_prize01'],
|
||||
self::PRIZE_02 => ['code' => self::PRIZE_02, 'name' => '复购奖励', 'func' => '_prize02'],
|
||||
self::PRIZE_03 => ['code' => self::PRIZE_03, 'name' => '直属团队', 'func' => '_prize03'],
|
||||
self::PRIZE_04 => ['code' => self::PRIZE_04, 'name' => '间接团队', 'func' => '_prize04'],
|
||||
self::PRIZE_05 => ['code' => self::PRIZE_05, 'name' => '差额奖励', 'func' => '_prize05'],
|
||||
];
|
||||
|
||||
protected $user;
|
||||
protected $order;
|
||||
protected $fromer;
|
||||
|
||||
/**
|
||||
* 获取奖励名称
|
||||
* @param string $prize
|
||||
* @return string
|
||||
*/
|
||||
public function getName(string $prize): string
|
||||
{
|
||||
return self::PRIZES[$prize]['name'] ?? $prize;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行订单返利
|
||||
* @param string $orderNo
|
||||
* @throws Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function execute(string $orderNo)
|
||||
{
|
||||
// 获取订单数据
|
||||
$map = ['order_no' => $orderNo, 'payment_status' => 1];
|
||||
$this->order = $this->app->db->name('ShopOrder')->where($map)->find();
|
||||
if (empty($this->order)) throw new Exception('订单不存在');
|
||||
// 获取用户数据
|
||||
$map = ['id' => $this->order['uid']];
|
||||
$this->user = $this->app->db->name('DataUser')->where($map)->find();
|
||||
if (empty($this->user)) throw new Exception('用户不存在');
|
||||
// 获取推荐用户
|
||||
if ($this->order['from'] > 0) {
|
||||
$map = ['id' => $this->order['from']];
|
||||
$this->fromer = $this->app->db->name('DataUser')->where($map)->find();
|
||||
if (empty($this->fromer)) throw new Exception('推荐不存在');
|
||||
}
|
||||
// 批量发放奖励
|
||||
foreach (self::PRIZES as $vo) {
|
||||
if (method_exists($this, $vo['func'])) {
|
||||
$this->{$vo['func']}();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 首推奖励
|
||||
* @return boolean
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
protected function _prize01(): bool
|
||||
{
|
||||
if (empty($this->fromer)) return false;
|
||||
$map = ['order_uid' => $this->user['id']];
|
||||
if ($this->app->db->name('DataUserRebate')->where($map)->count() > 0) return false;
|
||||
if (!$this->checkLevelPrize(PrizeService::PRIZE_01, $this->fromer['vip_number'])) return false;
|
||||
// 创建返利奖励记录
|
||||
$map = ['type' => PrizeService::PRIZE_01, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
|
||||
if ($this->app->db->name('DataUserRebate')->where($map)->count() < 1) {
|
||||
if (sysconf('shop.fristType') == 1) {
|
||||
$amount = sysconf('shop.fristValue') ?: '0.00';
|
||||
$name = PrizeService::instance()->getName(PrizeService::PRIZE_01) . ",每人 {$amount} 元";
|
||||
} else {
|
||||
$amount = sysconf('shop.fristValue') * $this->order['amount_total'] / 100;
|
||||
$name = PrizeService::instance()->getName(PrizeService::PRIZE_01) . ",订单 " . sysconf('shop.fristValue') . '%';
|
||||
}
|
||||
$this->app->db->name('DataUserRebate')->insert(array_merge($map, [
|
||||
'uid' => $this->fromer['id'], 'name' => $name, 'amount' => $amount, 'order_amount' => $this->order['amount_total'],
|
||||
]));
|
||||
// 更新会员奖利金额
|
||||
UserService::instance()->syncLevel($this->fromer['id']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 复购奖励
|
||||
* @return boolean
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
protected function _prize02(): bool
|
||||
{
|
||||
if (empty($this->fromer)) return false;
|
||||
$map = ['order_uid' => $this->user['id']];
|
||||
if ($this->app->db->name('DataUserRebate')->where($map)->count() < 1) return false;
|
||||
if (!$this->checkLevelPrize(PrizeService::PRIZE_02, $this->fromer['vip_number'])) return false;
|
||||
// 创建返利奖励记录
|
||||
$map = ['type' => PrizeService::PRIZE_02, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
|
||||
if ($this->app->db->name('DataUserRebate')->where($map)->count() < 1) {
|
||||
if (sysconf('shop.repeatType') == 1) {
|
||||
$amount = sysconf('shop.repeatValue') ?: '0.00';
|
||||
$name = PrizeService::instance()->getName(PrizeService::PRIZE_02) . ",每人 {$amount} 元";
|
||||
} else {
|
||||
$amount = sysconf('shop.repeatValue') * $this->order['amount_total'] / 100;
|
||||
$name = PrizeService::instance()->getName(PrizeService::PRIZE_02) . ",订单 " . sysconf('shop.repeatValue') . '%';
|
||||
}
|
||||
$this->app->db->name('DataUserRebate')->insert(array_merge($map, [
|
||||
'uid' => $this->fromer['id'], 'name' => $name, 'amount' => $amount, 'order_amount' => $this->order['amount_total'],
|
||||
]));
|
||||
// 更新会员奖利金额
|
||||
UserService::instance()->syncLevel($this->fromer['id']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直属团队
|
||||
* @return boolean
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
private function _prize03(): bool
|
||||
{
|
||||
if (empty($this->fromer)) return false;
|
||||
if (!$this->checkLevelPrize(PrizeService::PRIZE_03, $this->fromer['vip_number'])) return false;
|
||||
// 创建返利奖励记录
|
||||
$map = ['type' => PrizeService::PRIZE_03, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
|
||||
if ($this->app->db->name('DataUserRebate')->where($map)->count() < 1) {
|
||||
$amount = sysconf('shop.repeatValue') * $this->order['amount_total'] / 100;
|
||||
$name = PrizeService::instance()->getName(PrizeService::PRIZE_03) . ",订单 " . sysconf('shop.repeatValue') . '%';
|
||||
$this->app->db->name('DataUserRebate')->insert(array_merge($map, [
|
||||
'uid' => $this->fromer['id'], 'name' => $name, 'amount' => $amount, 'order_amount' => $this->order['amount_total'],
|
||||
]));
|
||||
// 更新会员奖利金额
|
||||
UserService::instance()->syncLevel($this->fromer['id']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 间接团队
|
||||
* @return boolean
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
private function _prize04(): bool
|
||||
{
|
||||
if (empty($this->fromer)) return false;
|
||||
$pm2 = $this->app->db->name('DataUser')->where(['id' => $this->fromer['from']])->find();
|
||||
if (empty($pm2)) return false;
|
||||
if (!$this->checkLevelPrize(PrizeService::PRIZE_04, $pm2['vip_number'])) return false;
|
||||
$map = ['type' => PrizeService::PRIZE_04, 'order_no' => $this->order['order_no'], 'order_uid' => $this->order['uid']];
|
||||
if ($this->app->db->name('DataUserRebate')->where($map)->count() < 1) {
|
||||
$amount = sysconf('shop.indirectValue') * $this->order['amount_total'] / 100;
|
||||
$name = PrizeService::instance()->getName(PrizeService::PRIZE_04) . ",订单 " . sysconf('shop.indirectValue') . '%';
|
||||
$this->app->db->name('DataUserRebate')->insert(array_merge($map, [
|
||||
'uid' => $pm2['id'], 'name' => $name, 'amount' => $amount, 'order_amount' => $this->order['amount_total'],
|
||||
]));
|
||||
// 更新代理奖利金额
|
||||
UserService::instance()->syncLevel($pm2['id']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 差额奖励
|
||||
* @return false
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
private function _prize05(): bool
|
||||
{
|
||||
$pids = array_reverse(explode('-', trim($this->user['path'], '-')));
|
||||
if (empty($pids)) return false;
|
||||
// 获取拥有差额奖励的等级
|
||||
$query = $this->app->db->name('DataUserLevel');
|
||||
$numbs = $query->whereLike('rule', '%,' . PrizeService::PRIZE_05 . ',%')->column('number');
|
||||
// 获取可以参与奖励的代理
|
||||
$query = $this->app->db->name('DataUser')->whereIn('vip_number', $numbs);
|
||||
$users = $query->whereIn('id', $pids)->orderField('id', $pids)->select()->toArray();
|
||||
// 查询需要计算奖励的商品
|
||||
$map = [['order_no', '=', $this->order['order_no']], ['discount_rate', '<', 100]];
|
||||
$this->app->db->name('StoreOrderItem')->where($map)->select()->each(function ($item) use ($users) {
|
||||
foreach ($users as $user) {
|
||||
$map = [
|
||||
'order_no' => $this->order['order_no'],
|
||||
'',
|
||||
];
|
||||
|
||||
$discountRule = $this->app->db->name('DataUserDiscount')->where(['status' => '1', 'is_deleted' => '0'])->value('rule');
|
||||
if (!empty($discountRule) && is_array($rules = json_decode($discountRule, true))) {
|
||||
[$tempLevel, $tempRate] = [$item['vip_number'], $item['discount_rate']];
|
||||
foreach ($rules as $rule) if ($rule['level'] > $tempLevel) foreach ($uids as $mem) if ($mem['vip_number'] > $tempLevel) {
|
||||
if ($tempRate > $rule['discount'] && $tempRate < 100) {
|
||||
$diffRate = $tempRate - $rule['discount'];
|
||||
$this->orderno = "{$this->order['order_no']}#{$tempLevel}-{$mem['vip_number']}";
|
||||
if ($this->app->db->name('DataUserRebate')->where(['order_no' => $this->orderno])->count() < 1) {
|
||||
$this->app->db->name('DataUserRebate')->insert([
|
||||
'order_no' => $this->orderno, 'order_uid' => $this->order['mid'],
|
||||
'order_price' => $this->order['amount_total'], 'type' => '5', 'mid' => $mem['id'],
|
||||
'profit_price' => $diffRate * $item['goods_amount_total'] / 100,
|
||||
'profit_state' => intval(empty($this->settlement)),
|
||||
'description' => "等级差额奖励{$tempLevel}#{$mem['vip_number']}商品金额{$diffRate}%",
|
||||
]);
|
||||
$this->app->db->name('StoreOrderItem')->where(['id' => $item['id']])->update(['discount_state' => '1']);
|
||||
}
|
||||
[$tempLevel, $tempRate] = [$mem['vip_number'], $rule['discount']];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查等级是否有奖励
|
||||
* @param string $prize
|
||||
* @param integer $level
|
||||
* @return boolean
|
||||
*/
|
||||
protected function checkLevelPrize(string $prize, int $level): bool
|
||||
{
|
||||
$map = [['number', '=', $level], ['rebate_rule', 'like', "%,{$prize},%"]];
|
||||
return $this->app->db->name('DataUserLevel')->where($map)->count() > 0;
|
||||
}
|
||||
}
|
@ -230,7 +230,7 @@ class UserService extends Service
|
||||
// 计算会员级别
|
||||
foreach ($this->app->db->name('DataUserLevel')->where(['status' => 1])->order('number desc')->select()->toArray() as $item) {
|
||||
$l1 = empty($item['goods_vip_status']) || $user['vip_auth'] > 0;
|
||||
$l2 = empty($item['teams_user_status']) || $item['teams_user_number'] <= $teamsDirect + $teamsIndirect;
|
||||
$l2 = empty($item['teams_users_status']) || $item['teams_users_number'] <= $teamsDirect + $teamsIndirect;
|
||||
$l3 = empty($item['teams_direct_status']) || $item['teams_direct_number'] <= $teamsDirect;
|
||||
$l4 = empty($item['teams_indirect_status']) || $item['teams_indirect_number'] <= $teamsIndirect;
|
||||
$l5 = empty($item['order_amount_status']) || $item['order_amount_number'] <= $amountTotal;
|
||||
|
66
app/data/view/user_discount/form.html
Normal file
66
app/data/view/user_discount/form.html
Normal file
@ -0,0 +1,66 @@
|
||||
<form class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">
|
||||
<div class="layui-card-body padding-left-40">
|
||||
|
||||
<label class="layui-form-item block relative">
|
||||
<span class="color-green font-w7 label-required-prev">折扣方案名称</span>
|
||||
<span class="color-desc margin-left-5">Discount Name</span>
|
||||
<input class="layui-input" name="name" required value="{$vo.name|default=''}" placeholder="请输入折扣方案名称">
|
||||
</label>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<span class="color-green font-w7 label-required-prev">用户级别折扣</span>
|
||||
<span class="color-desc margin-left-5">Discount Scheme</span>
|
||||
<table class="layui-table think-level-box" lay-skin="line">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-left">会员级别</th>
|
||||
<th class="text-right" style="width:150px">原价比例</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach $levels as $level}
|
||||
<tr class="think-bg-white">
|
||||
<td class="nowrap notselect">
|
||||
[ <span class="color-blue">VIP{$level.number}</span> ] {$level.name|default=''}
|
||||
</td>
|
||||
<td class="nowrap padding-0">
|
||||
<label>
|
||||
{php} $key = "_level_".$level['number']; {/php}
|
||||
<input name="_level_{$level.number}" data-blur-number="4" value="{$vo[$key]??'100.0000'}" placeholder="请输入用户级别折扣"> %
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<label class="layui-form-item block relative">
|
||||
<span class="color-green font-w7 label-required-prev">折扣方案备注</span>
|
||||
<span class="color-desc margin-left-5">Discount Remark</span>
|
||||
<textarea name="remark" class="layui-textarea" placeholder="请输入折扣方案备注">{$vo.remark|default=''}</textarea>
|
||||
</label>
|
||||
|
||||
<div class="hr-line-dashed"></div>
|
||||
{notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
|
||||
|
||||
<div class="layui-form-item text-center">
|
||||
<button class="layui-btn" type='submit'>保存数据</button>
|
||||
<button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗?" data-close>取消编辑</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>form.render()</script>
|
||||
</form>
|
||||
|
||||
<style>
|
||||
.think-level-box tr input {
|
||||
width: 90%;
|
||||
height: 38px;
|
||||
border: none;
|
||||
text-align: right;
|
||||
line-height: 38px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
73
app/data/view/user_discount/index.html
Normal file
73
app/data/view/user_discount/index.html
Normal file
@ -0,0 +1,73 @@
|
||||
{extend name="../../admin/view/main"}
|
||||
|
||||
{block name="button"}
|
||||
|
||||
{if auth("add")}
|
||||
<button data-modal="{:url('add')}" data-title="添加折扣方案" class='layui-btn layui-btn-sm layui-btn-primary'>添加折扣方案</button>
|
||||
{/if}
|
||||
|
||||
{/block}
|
||||
|
||||
{block name='content'}
|
||||
<div class="think-box-shadow">
|
||||
<table class="layui-table margin-top-10" lay-skin="line">
|
||||
{notempty name='list'}
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='list-table-check-td think-checkbox'>
|
||||
<label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
|
||||
</th>
|
||||
<th class='list-table-sort-td'>
|
||||
<button type="button" data-reload class="layui-btn layui-btn-xs">刷 新</button>
|
||||
</th>
|
||||
<th class="text-left nowrap">折扣方案</th>
|
||||
<th class="text-left nowrap">等级折扣</th>
|
||||
<th class="text-left nowrap">使用状态</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
{/notempty}
|
||||
<tbody>
|
||||
{foreach $list as $key=>$vo}
|
||||
<tr>
|
||||
<td class='list-table-check-td think-checkbox'>
|
||||
<label><input class="list-check-box" value='{$vo.id}' type='checkbox'></label>
|
||||
</td>
|
||||
<td class='list-table-sort-td'>
|
||||
<label><input data-action-blur="{:request()->url()}" data-value="id#{$vo.id};action#sort;sort#{value}" data-loading="false" value="{$vo.sort}" class="list-sort-input"></label>
|
||||
</td>
|
||||
<td class="text-left nowrap">{$vo.name|default=''}</td>
|
||||
<td class="text-left">
|
||||
{foreach $vo.items as $v}
|
||||
<span class="layui-badge-rim margin-right-5 margin-bottom-5 nowrap">
|
||||
<b class="color-green">VIP{$v.level}</b> : <b class="color-blue">{$v.discount+0}%</b>
|
||||
</span>
|
||||
{/foreach}
|
||||
</td>
|
||||
<td class='text-left nowrap'>
|
||||
{if $vo.status eq 0}<span class="color-red">已禁用</span>{elseif $vo.status eq 1}<span class="color-green">使用中</span>{/if}
|
||||
</td>
|
||||
<td class='text-left nowrap'>
|
||||
|
||||
{if auth("edit")}
|
||||
<a class="layui-btn layui-btn-sm" data-modal='{:url("edit")}?id={$vo.id}' data-title="编辑折扣方案">编 辑</a>
|
||||
{/if}
|
||||
|
||||
{if auth("state") and $vo.status eq 1}
|
||||
<a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}" data-value="id#{$vo.id};status#0" data-csrf="{:systoken('state')}">禁 用</a>
|
||||
{elseif auth("state")}
|
||||
<a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}" data-value="id#{$vo.id};status#1" data-csrf="{:systoken('state')}">启 用</a>
|
||||
{/if}
|
||||
|
||||
{if auth("remove")}
|
||||
<a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除折扣方案吗?" data-action="{:url('remove')}" data-value="id#{$vo.id}" data-csrf="{:systoken('remove')}">删 除</a>
|
||||
{/if}
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
{empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
|
||||
</div>
|
||||
{/block}
|
@ -2,13 +2,12 @@
|
||||
<div class="layui-card-body padding-left-40">
|
||||
|
||||
<fieldset class="layui-form-item">
|
||||
<legend class="layui-bg-cyan">用户等级</legend>
|
||||
<div class="layui-form-item layui-row layui-col-space10">
|
||||
<legend><span class="layui-badge layui-bg-cyan">用户等级</span></legend>
|
||||
<div class="layui-form-item layui-row layui-col-space15">
|
||||
<div class="layui-col-xs3 block relative">
|
||||
<span class="color-green label-required-prev">等级序号</span>
|
||||
<select class="layui-select" name="level">
|
||||
{for start="1" end="9" name="i"}
|
||||
{if isset($vo.number) and $vo.number eq $i}
|
||||
<span class="color-green label-required-prev">等级序号</span><span class="color-desc">Number</span>
|
||||
<select class="layui-select" name="number">
|
||||
{for start="1" end="10" name="i"}{if isset($vo.number) and $vo.number eq $i}
|
||||
<option selected value="{$i}">当前 VIP {$vo.number} 等级</option>
|
||||
{else}
|
||||
<option value="{$i}">设置 VIP {$i} 等级</option>
|
||||
@ -16,14 +15,14 @@
|
||||
</select>
|
||||
</div>
|
||||
<label class="layui-col-xs9 block relative">
|
||||
<span class="color-green label-required-prev">等级名称</span>
|
||||
<span class="color-green label-required-prev">等级名称</span><span class="color-desc">Level Name</span>
|
||||
<input class="layui-input" name="name" required value="{$vo.name|default=''}" placeholder="请输入等级名称">
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="layui-form-item">
|
||||
<legend class="layui-bg-cyan">升级规则</legend>
|
||||
<legend><span class="layui-badge layui-bg-cyan">升级规则</span></legend>
|
||||
<div class="layui-form-item">
|
||||
{php}$vo['upgrade_type'] = isset($vo['upgrade_type'])?$vo['upgrade_type']:1;{/php}
|
||||
{foreach [1=>'达成所有条件',0=>'达成任何条件'] as $k => $v}
|
||||
@ -36,7 +35,7 @@
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="layui-form-item">
|
||||
<legend class="layui-bg-cyan">升级条件</legend>
|
||||
<legend><span class="layui-badge layui-bg-cyan">升级条件</span></legend>
|
||||
<div class="font-s13">
|
||||
<label class="layui-form-item block relative think-checkbox notselect">
|
||||
{if isset($vo.goods_vip_status) and $vo.goods_vip_status eq 1}
|
||||
@ -70,13 +69,13 @@
|
||||
</label>
|
||||
|
||||
<label class="layui-form-item block relative think-checkbox notselect">
|
||||
{if isset($vo.teams_user_status) and $vo.teams_user_status eq 1}
|
||||
④ <input type="checkbox" checked name="teams_user_status" value="1" lay-ignore>开启
|
||||
{if isset($vo.teams_users_status) and $vo.teams_users_status eq 1}
|
||||
④ <input type="checkbox" checked name="teams_users_status" value="1" lay-ignore>开启
|
||||
{else}
|
||||
④ <input type="checkbox" name="teams_user_status" value="1" lay-ignore>开启
|
||||
④ <input type="checkbox" name="teams_users_status" value="1" lay-ignore>开启
|
||||
{/if}
|
||||
<span class="color-blue">团队总数</span> 升级,<span class="color-blue">团队总数</span> 达到
|
||||
<input class="inline-block text-center" data-blur-number="0" style="width:80px" name="teams_user_number" value="{$vo.teams_user_number|default='0'}">
|
||||
<input class="inline-block text-center" data-blur-number="0" style="width:80px" name="teams_users_number" value="{$vo.teams_users_number|default='0'}">
|
||||
人;
|
||||
</label>
|
||||
|
||||
@ -94,18 +93,18 @@
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="layui-form-item">
|
||||
<legend class="layui-bg-cyan">发放奖利</legend>
|
||||
<div class="layui-form-item">
|
||||
{foreach $rules as $key}{if isset($vo.rebate_rule) && is_array($vo.rebate_rule) && in_array($key,$vo.rebate_rule)}
|
||||
<label class="think-checkbox"><input checked type="checkbox" name="rebate_rule[]" value="{$key}" lay-ignore> {$key}</label>
|
||||
<legend><span class="layui-badge layui-bg-cyan">发放奖利</span></legend>
|
||||
<div class="layui-form-item notselect">
|
||||
{foreach $prizes as $prize}{if isset($vo.rebate_rule) && is_array($vo.rebate_rule) && in_array($prize.code, $vo.rebate_rule)}
|
||||
<label class="think-checkbox"><input type="checkbox" name="rebate_rule[]" value="{$prize.code}" lay-ignore checked> {$prize.name}</label>
|
||||
{else}
|
||||
<label class="think-checkbox"><input type="checkbox" name="rebate_rule[]" value="{$key}" lay-ignore> {$key}</label>
|
||||
<label class="think-checkbox"><input type="checkbox" name="rebate_rule[]" value="{$prize.code}" lay-ignore> {$prize.name}</label>
|
||||
{/if}{/foreach}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="layui-form-item layui-hide">
|
||||
<legend class="layui-bg-cyan">等级描述</legend>
|
||||
<legend><span class="layui-badge layui-bg-cyan">等级描述</span></legend>
|
||||
<label class="layui-form-item block relative">
|
||||
<textarea name="remark" class="layui-textarea" placeholder="请输入用户等级描述">{$vo.remark|default=''}</textarea>
|
||||
</label>
|
||||
@ -113,7 +112,7 @@
|
||||
|
||||
<div class="hr-line-dashed"></div>
|
||||
{notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
|
||||
{notempty name='vo.level'}<input type='hidden' value='{$vo.level}' name='old_level'>{/notempty}
|
||||
{notempty name='vo.number'}<input type='hidden' value='{$vo.number}' name='old_number'>{/notempty}
|
||||
|
||||
<div class="layui-form-item text-center">
|
||||
<button class="layui-btn" type='submit'>保存数据</button>
|
||||
|
@ -2,20 +2,20 @@
|
||||
|
||||
{block name="button"}
|
||||
<!--{if auth("add")}-->
|
||||
<button data-modal="{:url('add')}" data-title="添加用户级别" class='layui-btn layui-btn-sm layui-btn-primary'>添加用户级别</button>
|
||||
<button data-modal="{:url('add')}" class='layui-btn layui-btn-sm layui-btn-primary'>添加用户等级</button>
|
||||
<!--{/if}-->
|
||||
|
||||
<!--{if auth("sync")}-->
|
||||
<button data-queue="{:url('sync')}" data-confirm="确定要刷新所有用户的统计数据吗?" class='layui-btn layui-btn-sm layui-btn-primary'>刷新用户数据</button>
|
||||
<button data-queue="{:url('sync')}" data-confirm="确定要刷新用户数据数据吗?" class='layui-btn layui-btn-sm layui-btn-primary'>刷新用户数据</button>
|
||||
<!--{/if}-->
|
||||
{/block}
|
||||
|
||||
{block name='content'}
|
||||
<div class="layui-badge think-bg-red padding-5 padding-left-10 font-s15 layui-anim layui-anim-upbit">
|
||||
<div class="layui-badge think-bg-red text-left padding-10 border-radius-5 padding-left-20 font-s15 block shadow">
|
||||
注意,用户级别配置不能随意修改或删除,会影响系统结算与用户升级!
|
||||
</div>
|
||||
<div class="think-box-shadow">
|
||||
<table class="layui-table margin-top-10" lay-skin="line">
|
||||
<div class="think-box-shadow margin-top-10">
|
||||
<table class="layui-table" lay-skin="line">
|
||||
{notempty name='list'}
|
||||
<thead>
|
||||
<tr>
|
||||
@ -44,11 +44,15 @@
|
||||
<td class="text-left nowrap"> [ <span class="color-blue">{$vo.number}</span> ] {$vo.name|default=''}</td>
|
||||
<td class="text-left nowrap">{if $vo.upgrade_type eq 1}<span class="color-green">全部完成</span>{else}<span class="color-blue">任何条件</span>{/if}</td>
|
||||
<td class="text-center nowrap">{if $vo.goods_vip_status>0}<b class="layui-icon layui-icon-ok-circle color-green"></b> {else} - {/if}</td>
|
||||
<td class="text-center nowrap">{if $vo.teams_user_status>0} <b class="color-green">{$vo.teams_user_number}</b> 人 {else} - {/if}</td>
|
||||
<td class="text-center nowrap">{if $vo.teams_users_status>0} <b class="color-green">{$vo.teams_users_number}</b> 人 {else} - {/if}</td>
|
||||
<td class="text-center nowrap">{if $vo.teams_direct_status>0} <b class="color-green">{$vo.teams_direct_number}</b> 人 {else} - {/if}</td>
|
||||
<td class="text-center nowrap">{if $vo.teams_indirect_status>0} <b class="color-green">{$vo.teams_indirect_number}</b> 人 {else} - {/if}</td>
|
||||
<td class="text-center nowrap">{if $vo.order_amount_status>0} <b class="color-green">{$vo.order_amount_number+0}</b> 元 {else} - {/if}</td>
|
||||
<td class="text-left">{:join(', ',$vo.rebate_rule)}</td>
|
||||
<td class="text-left">
|
||||
{foreach $vo.rebate_rule as $v}
|
||||
<span class="nowrap margin-right-5">{$v}</span>
|
||||
{/foreach}
|
||||
</td>
|
||||
<td class='text-left nowrap'>
|
||||
{if $vo.status eq 0}<span class="color-red">已禁用</span>{elseif $vo.status eq 1}<span class="color-green">使用中</span>{/if}
|
||||
</td>
|
||||
|
Loading…
x
Reference in New Issue
Block a user