提交代码
This commit is contained in:
parent
fb188929b3
commit
724ce08559
|
|
@ -1132,6 +1132,75 @@ class Goods extends Base
|
|||
return $this->renderSuccess('获取成功', $syncAddresses);
|
||||
}
|
||||
|
||||
/**
|
||||
* 盒子自动下架日志
|
||||
*/
|
||||
public function offshelf_log(Request $request)
|
||||
{
|
||||
$goods_id = trim(input('get.goods_id'));
|
||||
$start_time = trim(input('get.start_time'));
|
||||
$end_time = trim(input('get.end_time'));
|
||||
|
||||
$whe = [];
|
||||
|
||||
if ($goods_id) {
|
||||
$whe[] = ['goods_id', '=', $goods_id];
|
||||
}
|
||||
|
||||
if ($start_time && $end_time) {
|
||||
$start = strtotime($start_time);
|
||||
$end = strtotime($end_time . ' 23:59:59');
|
||||
$whe[] = ['create_time', 'between', [$start, $end]];
|
||||
} elseif ($start_time) {
|
||||
$start = strtotime($start_time);
|
||||
$whe[] = ['create_time', '>=', $start];
|
||||
} elseif ($end_time) {
|
||||
$end = strtotime($end_time . ' 23:59:59');
|
||||
$whe[] = ['create_time', '<=', $end];
|
||||
}
|
||||
|
||||
// 获取日志数据
|
||||
$list = Db::name('goods_offshelf_log')
|
||||
->where($whe)
|
||||
->order('id desc')
|
||||
->paginate([
|
||||
'list_rows' => $this->page,
|
||||
'query' => request()->param(),
|
||||
]);
|
||||
|
||||
// 获取所有相关的盒子信息
|
||||
$goodsIds = array_column($list->items(), 'goods_id');
|
||||
$goodsInfo = [];
|
||||
|
||||
if (!empty($goodsIds)) {
|
||||
$goods = Db::name('goods')
|
||||
->field('id, title, status')
|
||||
->whereIn('id', $goodsIds)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ($goods as $item) {
|
||||
$goodsInfo[$item['id']] = [
|
||||
'title' => $item['title'],
|
||||
'status' => $item['status']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// 转换时间戳并处理数据
|
||||
$listItems = $list->items();
|
||||
foreach ($listItems as &$item) {
|
||||
$item['create_time_text'] = date('Y-m-d H:i:s', $item['create_time']);
|
||||
$item['goods_title'] = isset($goodsInfo[$item['goods_id']]) ? $goodsInfo[$item['goods_id']]['title'] : '未知盒子';
|
||||
$item['goods_status'] = isset($goodsInfo[$item['goods_id']]) ? $goodsInfo[$item['goods_id']]['status'] : 2; // 默认下架状态
|
||||
}
|
||||
|
||||
View::assign('list', $listItems);
|
||||
View::assign('page', $list->render());
|
||||
View::assign('count', $list->total());
|
||||
return View::fetch('Goods/offshelf/log');
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步盒子数据
|
||||
*/
|
||||
|
|
@ -1203,6 +1272,54 @@ class Goods extends Base
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空盒子抽奖数据
|
||||
*/
|
||||
public function clear_goods_data(Request $request)
|
||||
{
|
||||
$id = $request->post('id/d');
|
||||
if (!$id) {
|
||||
return $this->renderError('盒子ID不能为空');
|
||||
}
|
||||
|
||||
// 检查盒子是否存在
|
||||
$goods = GoodsModel::where(['id' => $id])->find();
|
||||
if (!$goods) {
|
||||
return $this->renderError('盒子不存在');
|
||||
}
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 清空订单表
|
||||
$orderCount = Db::name('order')->where('goods_id', $id)->delete();
|
||||
|
||||
// 清空订单详情表
|
||||
$orderListCount = Db::name('order_list')->where('goods_id', $id)->delete();
|
||||
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
|
||||
// 记录管理员操作日志
|
||||
AdminGoodsLog::add_goods_log(
|
||||
session('admin_id'),
|
||||
$id,
|
||||
0,
|
||||
json_encode(['operation' => '清空抽奖数据前']),
|
||||
json_encode([
|
||||
'operation' => '清空抽奖数据后',
|
||||
'clear_order_count' => $orderCount,
|
||||
'clear_order_list_count' => $orderListCount
|
||||
])
|
||||
);
|
||||
|
||||
return $this->renderSuccess("操作成功,共清空订单 {$orderCount} 条,订单详情 {$orderListCount} 条");
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return $this->renderError('操作失败:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成UUID
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -166,6 +166,8 @@ Route::rule('yushou_rili', 'Goods/yushou_rili', 'GET|POST');
|
|||
Route::rule('yushou_rili_add', 'Goods/yushou_rili_add', 'GET|POST');
|
||||
Route::rule('yushou_rili_edit', 'Goods/yushou_rili_edit', 'GET|POST');
|
||||
Route::rule('yushou_rili_del', 'Goods/yushou_rili_del', 'GET|POST');
|
||||
Route::rule('offshelf_log', 'Goods/offshelf_log', 'GET|POST');
|
||||
Route::rule('clear_goods_data', 'Goods/clear_goods_data', 'POST');
|
||||
Route::rule('draw_raffle', 'Draw/goods', 'GET|POST');
|
||||
Route::rule('draw_edit', 'Draw/draw_edit', 'GET|POST');
|
||||
Route::rule('drawlist', 'Draw/drawlist', 'GET|POST');
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@
|
|||
<xblock>
|
||||
<div style="padding-bottom: 10px;">
|
||||
<a class="layui-btn" onclick="goods_add()">添加盒子</a>
|
||||
<a class="layui-btn layui-btn-normal" onclick="offshelf_log()">自动下架日志</a>
|
||||
<span style="line-height:40px;float:right;">共有数据: {$count}条</span>
|
||||
</div>
|
||||
</xblock>
|
||||
|
|
@ -124,18 +125,7 @@
|
|||
<button class="layui-btn layui-btn-warm layui-btn-sm">时间:{$vo['lock_time']}秒</button>
|
||||
{/if}
|
||||
</td>
|
||||
<!-- <td>-->
|
||||
<!-- {if $vo['coupon_is'] eq 1}-->
|
||||
<!-- <button class="layui-btn layui-btn-warm layui-btn-sm">状态:开启</button>-->
|
||||
<!-- <br>-->
|
||||
<!-- <button class="layui-btn layui-btn-warm layui-btn-sm">概率:{$vo['coupon_pro']*1}%</button>-->
|
||||
<!-- {/if}-->
|
||||
<!-- </td>-->
|
||||
<!-- <td>-->
|
||||
<!-- {if $vo['integral_is'] eq 1}-->
|
||||
<!-- <button class="layui-btn layui-btn-warm layui-btn-radius layui-btn-sm">开启</button>-->
|
||||
<!-- {/if}-->
|
||||
<!-- </td>-->
|
||||
|
||||
<td>
|
||||
{if $vo['show_is'] eq 1}
|
||||
<button class="layui-btn layui-btn-danger layui-btn-radius layui-btn-sm">否</button>
|
||||
|
|
@ -182,11 +172,11 @@
|
|||
<a style="text-decoration:none" onclick="goods_sync({$vo['id']},{$vo['async_code']})"
|
||||
class="layui-btn layui-btn-normal layui-btn-xs"><i
|
||||
class="layui-icon layui-icon-sync"></i>同步</a>
|
||||
<!-- {if condition="$vo['status'] eq 1"}-->
|
||||
<!-- <button onClick="del({$vo.id},2,'下架')" class="layui-btn layui-btn-danger layui-btn-xs"><i class="layui-icon"></i>下架</button>-->
|
||||
<!-- {else /}-->
|
||||
|
||||
<!-- {/if}-->
|
||||
<div style="margin-top: 8px"></div>
|
||||
<a style="text-decoration:none" onclick="clear_goods_data({$vo.id})"
|
||||
class="layui-btn layui-btn-danger layui-btn-xs">
|
||||
<i class="layui-icon layui-icon-delete"></i>清空抽奖
|
||||
</a>
|
||||
<div style="margin-top: 8px"></div>
|
||||
<a style="text-decoration:none" onClick="del({$vo.id},3,'删除')"
|
||||
class="layui-btn layui-btn-danger layui-btn-xs">
|
||||
|
|
@ -231,6 +221,18 @@
|
|||
});
|
||||
}
|
||||
|
||||
//查看自动下架日志
|
||||
function offshelf_log() {
|
||||
var url = "{:url('/admin/offshelf_log')}";
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '盒子自动下架日志',
|
||||
shadeClose: false,
|
||||
shade: 0.3,
|
||||
area: ['90%', '90%'],
|
||||
content: url,
|
||||
});
|
||||
}
|
||||
|
||||
//编辑奖品
|
||||
function goodsextendlist_edit(goods_id, title) {
|
||||
|
|
@ -366,6 +368,31 @@
|
|||
|
||||
|
||||
}
|
||||
|
||||
// 清空盒子抽奖数据
|
||||
function clear_goods_data(id) {
|
||||
layer.confirm('警告:清空抽奖数据将删除该盒子所有订单记录,且无法恢复!确定要继续吗?', {
|
||||
btn: ['确定', '取消'],
|
||||
title: '危险操作确认',
|
||||
skin: 'layui-layer-danger'
|
||||
}, function (index) {
|
||||
var url = "{:url('/admin/clear_goods_data')}";
|
||||
var load = layer.load(2);
|
||||
var $ = layui.$;
|
||||
$.post(url, { "id": id }, function (data) {
|
||||
if (data.status == 1) {
|
||||
layer.msg(data.msg, { icon: 1, time: 2000 }, function () {
|
||||
location.reload();
|
||||
});
|
||||
} else {
|
||||
layer.msg(data.msg, { icon: 2, anim: 6, time: 2000 }, function () {
|
||||
layer.close(load);
|
||||
});
|
||||
}
|
||||
});
|
||||
layer.close(index);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- 在操作栏中添加同步按钮 -->
|
||||
|
|
|
|||
148
app/admin/view/Goods/offshelf/log.html
Normal file
148
app/admin/view/Goods/offshelf/log.html
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
{include file="Public:header2"/}
|
||||
|
||||
<body>
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-card">
|
||||
<form method="get" class="layui-form layui-card-header layuiadmin-card-header-auto">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline" style="width: 200px; margin-left: 0px">
|
||||
<input type="text" name="goods_id" value="{$Request.get.goods_id}" placeholder="请输入盒子ID"
|
||||
autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline" style="width: 180px; margin-left: 0px">
|
||||
<input type="text" id="start_time" name="start_time" value="{$Request.get.start_time}"
|
||||
placeholder="开始时间" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline" style="width: 180px; margin-left: 0px">
|
||||
<input type="text" id="end_time" name="end_time" value="{$Request.get.end_time}"
|
||||
placeholder="结束时间" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layuiadmin-btn-useradmin mmm" lay-submit
|
||||
lay-filter="LAY-user-front-search">
|
||||
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="layui-card-body">
|
||||
<xblock>
|
||||
<div style="padding-bottom: 10px;">
|
||||
<span style="line-height:40px;float:right;">共有数据: {$count}条</span>
|
||||
</div>
|
||||
</xblock>
|
||||
<table class="layui-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>盒子ID</th>
|
||||
<th>盒子名称</th>
|
||||
<th>当前利润率(%)</th>
|
||||
<th>配置下架利润(%)</th>
|
||||
<th>订单总价值</th>
|
||||
<th>出货总价值</th>
|
||||
<th>下架时间</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{volist name="list" id="vo"}
|
||||
<tr>
|
||||
<td>{$vo.id}</td>
|
||||
<td>{$vo.goods_id}</td>
|
||||
<td>{$vo.goods_title}</td>
|
||||
<td>{$vo.profit_rate}%</td>
|
||||
<td>{$vo.xiajia_lirun}%</td>
|
||||
<td>{$vo.order_total}</td>
|
||||
<td>{$vo.goods_total}</td>
|
||||
<td>{$vo.create_time_text}</td>
|
||||
<td>
|
||||
<a style="text-decoration:none" title="查看盒子" onclick="view_goods({$vo.goods_id})"
|
||||
class="layui-btn layui-btn-normal layui-btn-xs">
|
||||
<i class="layui-icon layui-icon-search"></i>查看盒子
|
||||
</a>
|
||||
{if condition="$vo.goods_status neq 1"}
|
||||
<div style="margin-top: 8px"></div>
|
||||
<a style="text-decoration:none" title="上架盒子" onclick="shelf_goods({$vo.goods_id})"
|
||||
class="layui-btn layui-btn-warm layui-btn-xs">
|
||||
<i class="layui-icon layui-icon-up"></i>上架盒子
|
||||
</a>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
|
||||
{if condition="empty($list)"}
|
||||
<tr>
|
||||
<td colspan='9' style="text-align:center;">暂时没有数据!</td>
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="layui-box layui-laypage layui-laypage-default">
|
||||
{$page|raw}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{include file="Public:footer"/}
|
||||
<script type="text/javascript">
|
||||
layui.use(['layer', 'table', 'laydate'], function () {
|
||||
var $ = layui.$;
|
||||
var laydate = layui.laydate;
|
||||
|
||||
// 日期选择器
|
||||
laydate.render({
|
||||
elem: '#start_time'
|
||||
});
|
||||
laydate.render({
|
||||
elem: '#end_time'
|
||||
});
|
||||
});
|
||||
|
||||
// 查看盒子详情
|
||||
function view_goods(id) {
|
||||
var url = "{:url('/admin/goods_edit')}?id=" + id;
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '盒子详情',
|
||||
shadeClose: false,
|
||||
shade: 0.3,
|
||||
area: ['90%', '90%'],
|
||||
content: url,
|
||||
});
|
||||
}
|
||||
|
||||
// 上架盒子
|
||||
function shelf_goods(id) {
|
||||
layer.confirm('确定要上架该盒子吗?', function(index) {
|
||||
var $ = layui.$;
|
||||
var url = "{:url('/admin/goods_del')}";
|
||||
var load = layer.load(2);
|
||||
$.post(url, {"id": id, "type": 1}, function(data) {
|
||||
if (data.status == 1) {
|
||||
layer.msg('上架成功', {icon: 1, time: 1000}, function() {
|
||||
// 刷新当前页面
|
||||
location.reload();
|
||||
});
|
||||
} else {
|
||||
layer.msg(data.msg, {icon: 2, anim: 6, time: 1000}, function() {
|
||||
layer.close(load);
|
||||
});
|
||||
}
|
||||
});
|
||||
layer.close(index);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Reference in New Issue
Block a user