Commit 20d6032c by 朱继来

添加团购列表

parent 2be495d2
......@@ -16,6 +16,7 @@ use App\Model\OrderItemsTrackModel;
use App\Model\UserSampleApplyModel;
use App\Model\UserSampleInviteModel;
use App\Model\OrderItemsModel;
use App\Model\UserGroupModel;
class ApiController extends Controller
{
......@@ -229,4 +230,11 @@ class ApiController extends Controller
}
}
// 获取团购信息
public function ApiGroupList($request)
{
$UserGroupModel = new UserGroupModel;
$this->ExportLayui($UserGroupModel->lists($request));
}
}
......@@ -301,4 +301,11 @@ class WebController extends Controller
return view('web', $data);
}
// 团购列表
public function groupList($request, $data, $id)
{
$data['title'] = '团购列表';
return view('web', $data);
}
}
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Request;
class UserGroupJoinModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_user_group_join';
protected $primaryKey = 'id';
public $timestamps = false;
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class UserGroupModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_user_group';
protected $primaryKey = 'id';
protected $guarded = ['id'];
public $timestamps = false;
// 获取客服
public function lists($request, $export='')
{
$page = $request->input('page', 1);
$limit = $request->input('limit', 10);
$map['account'] = $request->input('account', ''); // 用户账号
$map['status'] = $request->input('status', ''); // 状态
$map['begin_time'] = $request->input('begin_time', '') ? strtotime($request->input('begin_time')) : '';
$map['end_time'] = $request->input('end_time', '') ? strtotime($request->input('end_time')) + 86399 : '';
$list = $this->where(function($query) use ($map) {
// 客服名称
if ($map['account']) {
$query->where('account', 'like', $map['account'].'%');
}
})->where(function($query) use ($map) {
// 邮箱
if ($map['status']) {
$query->where('status', '=', $map['status']);
}
})->where(function($query) use ($map) {
// 创建时间
if(!empty($map['begin_time']) && !empty($map['end_time'])) {
$query->whereBetween('create_time', [$map['begin_time'], $map['end_time']]);
}
else if(!empty($map['begin_time'])) {
$query->where('create_time', '>=', $map['begin_time']);
}
else if(!empty($map['end_time'])) {
$query->where('create_time', '<=', $map['end_time']);
}
})
->orderBy('create_time', 'desc')
->orderBy('id', 'desc');
if ($export) {
$list = $list->get()->toArray();
if (empty($list)) {
echo '<script>alert("导出数据为空");history.go(-1);</script>';die;
}
return $list;
} else {
$list = $list->paginate($limit, ['*'], 'page', $page)->toArray();
$data = $this->handle($list['data']);
return [0, '获取成功', $data, $list['total']];
}
}
// 处理数据
public function handle($data)
{
if (!$data) return false;
$UserGroupJoinModel = new UserGroupJoinModel();
foreach ($data as &$v) {
// 若已参团,且非系统分配,则查询参团表
if ($v['status'] == 1 && $v['is_assign'] == -1) {
$join = $UserGroupJoinModel->where('group_id', $v['id'])->first()->toArray();
$v['join_user_id'] = $join['user_id'];
$v['join_account'] = $join['account'];
$v['join_order_id'] = $join['order_id'];
$v['join_order_sn'] = $join['order_sn'];
$v['join_time'] = date('Y-m-d H:i:s', $join['join_time']);
} else {
$v['join_user_id'] = '';
$v['join_account'] = '';
$v['join_order_id'] = '';
$v['join_order_sn'] = '';
$v['join_time'] = '';
}
$v['create_time'] = date('Y-m-d H:i:s', $v['create_time']);
}
return $data;
}
}
\ No newline at end of file
layui.use(['form', 'table', 'laydate'], function(){
var form = layui.form;
var table = layui.table;
var laydate = layui.laydate;
laydate.render({
elem: '#begin_time' //指定元素
});
laydate.render({
elem: '#end_time' //指定元素
});
var renderTable = function () {
table.render({
id: 'list'
,elem: '#list'
,url: '/api/ApiGroupList' //数据接口
,method:'post'
,cellMinWidth: 80 //全局定义常规单元格的最小宽度
,page: true //开启分页
,cols: [[ //表头
{title: '序号', type: 'numbers', fixed: 'left', width: 80}
,{field: 'user_id', title: '用户ID', width: 100}
,{field: 'account', title: '用户账号', width: 150}
,{field: 'order_id', title: '订单ID', width: 100}
,{field: 'order_sn', title: '订单号', width: 150}
,{field: 'status', title: '参团状态', templet: '#status', width: 100}
,{field: 'is_assign', title: '是否系统分配', templet: '#is_assign', width: 150}
,{field: 'join_user_id', title: '参团用户ID', width: 120}
,{field: 'join_account', title: '参团用户账号', width: 150}
,{field: 'join_order_id', title: '参团订单ID', width: 120}
,{field: 'join_order_sn', title: '参团订单号', width: 150}
,{field: 'join_time', title: '参团时间', width: 180}
,{field: 'limited_time', title: '团购限时(小时)', width: 200}
,{field: 'create_time', title: '创建时间', width: 180}
]]
,limit: 10
,limits: [10, 20, 50,]
});
};
renderTable();
form.on('submit(load)', function(data) {
//执行重载
table.reload('list', {
page: {
curr: 1
}
,where: data.field
});
return false;
});
$('.add').click(function() {
layer.open({
area: ['400px', '200px'],
title: '新增客服',
type: 1,
content: $('#kefu-action'),
btn: ['确认', '取消'],
yes: function(index) {
var email = $('.kefu-email').val();
if (!email) {
layer.tips('请输入邮箱', $('.kefu-email'));
return false;
}
$.ajax({
url : '/api/ApiAddKefu',
type: 'post',
data: {email: email},
dataType: 'json',
success: function(resp) {
if (resp.errcode == 0) {
layer.close(index);
layer.msg(resp.errmsg);
renderTable(); // 重新加载table
return false;
}
layer.msg(resp.errmsg);
},
error: function(err) {
console.log(err)
}
})
layer.msg('新增客服中...', {icon: 16, time: 0, shade: 0.3}); // 阻止重复提交
return false;
},
cancel: function(index) {
layer.close(index);
}
})
$('.kefu-email').val('');
})
// tool操作
table.on('tool(kefu)', function(obj){ //注:tool是工具条事件名,test是table原始容器的属性lay-filter="对应的值"
var data = obj.data; //获得当前行数据
var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
var url = '';
var title = '';
var content = '';
var datax = {};
datax.id = data.id;
if(layEvent === 'edit') {
url = '/api/ApiEditKefu';
title = '编辑客服';
content = $('#kefu-action');
} else if (layEvent === 'del') {
url = '/api/ApiDelKefu';
title = '删除客服';
content = '<div style="margin: 40px;">确定删除该客服吗?</div>';
datax.status = data.status;
} else if (layEvent === 'top') {
url = '/api/ApiTopKefu';
title = '置顶客服';
content = '<div style="margin: 40px;">确定置顶该客服吗?</div>';
}
layer.open({
area: ['400px', '200px'],
title: title,
type: 1,
content: content,
btn: ['确认', '取消'],
yes: function(index) {
if (layEvent == 'edit') {
var email = $('.kefu-email').val();
if (!email) {
layer.tips('请输入邮箱', $('.kefu-email'));
return false;
}
datax.email = email;
}
$.ajax({
url : url,
type: 'post',
data: datax,
dataType: 'json',
success: function(resp) {
if (resp.errcode == 0) {
layer.close(index);
layer.msg(resp.errmsg);
renderTable(); // 重新加载table
return false;
}
layer.msg(resp.errmsg);
},
error: function(err) {
console.log(err)
}
})
layer.msg(title+'中...', {icon: 16, time: 0, shade: 0.3}); // 阻止重复提交
return false;
},
cancel: function(index) {
layer.close(index);
}
})
if (layEvent == 'edit') {
$('.kefu-email').val(data.email);
}
});
});
\ No newline at end of file
<form class="layui-form layui-box" method="post">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">用户账号</label>
<div class="layui-input-inline">
<input type="text" name="account" placeholder="填写用户账号" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">参团状态</label>
<div class="layui-input-inline">
<select name="status" lay-verify="" lay-search>
<option value=""></option>
<option value="1">已参团</option>
<option value="-1">未参团</option>
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">创建时间</label>
<div class="layui-input-inline">
<input type="text" name="begin_time" value="" autocomplete="off" placeholder="选择开始时间" class="layui-input" id="begin_time" readonly>
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" name="end_time" value="" autocomplete="off" placeholder="选择结束时间" class="layui-input" id="end_time" readonly>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-btn-container" style="text-align: center; margin-top: 10px;">
<button lay-submit lay-filter="load" class="layui-btn" data-type="search">搜索</button>
<!-- <button type="button" class="layui-btn layui-btn-normal export">导出</button> -->
</div>
</div>
</form>
<table id="list" lay-filter="list"></table>
<script type="text/html" id="status">
@{{# if (d.status == 1) { }}
<div style="color:green;">已参团</div>
@{{# } else { }}
<div style="color:#ccc;">未参团</div>
@{{# } }}
</script>
<script type="text/html" id="is_assign">
@{{# if (d.is_assign == 1) { }}
<div style="color:green;"></div>
@{{# } else { }}
<div style="color:#ccc;"></div>
@{{# } }}
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment