Commit 95fa5e61 by allen

Merge branch 'master' of ssh://119.23.72.7:22611/zhujilai/Order into lt_订单周迭代3.09

parents 73f24e4f 70918906
...@@ -25,7 +25,7 @@ class UserSampleApplyModel extends Model ...@@ -25,7 +25,7 @@ class UserSampleApplyModel extends Model
{ {
$page = $request->input('page', 1); $page = $request->input('page', 1);
$limit = $request->input('limit', 10); $limit = $request->input('limit', 10);
$field = ['a.apply_id', 'a.user_id', 'a.account', 'a.order_id', 'order_sn', 'a.goods_id', 'a.goods_name', 'a.apply_num', 'a.create_time']; $field = ['a.apply_id', 'a.user_id', 'a.account', 'a.order_id', 'order_sn', 'a.goods_id', 'a.goods_name', 'a.apply_num', 'a.quota', 'a.create_time'];
$map['account'] = $request->input('account', ''); // 用户账户 $map['account'] = $request->input('account', ''); // 用户账户
$map['goods_name'] = $request->input('goods_name', ''); // 商品名称 $map['goods_name'] = $request->input('goods_name', ''); // 商品名称
...@@ -98,17 +98,29 @@ class UserSampleApplyModel extends Model ...@@ -98,17 +98,29 @@ class UserSampleApplyModel extends Model
$UserInfoModel = new UserInfoModel; $UserInfoModel = new UserInfoModel;
$v['invite_count'] = $UserSampleInviteModel->getUserInviteCount($v['user_id']); $v['invite_count'] = $UserSampleInviteModel->getUserInviteCount($v['user_id']);
$v['apply_num_total'] = $this->getSampleApplySum($v['user_id']); $v['apply_num_total'] = $this->getSampleApplySum($v['user_id']); // 获取指定用户申请的样片总数
// $v['quota_total'] = $this->getSampleApplySum($v['user_id'], 'quota'); // 获取指定用户申请的样片总数
$v['quota_total'] = $this->getUsedCount($v['user_id']); // 获取指定用户申请的样片消耗总人数
$v['apply_count'] = $UserInfoModel->getUserApplyCount($v['user_id']); $v['apply_count'] = $UserInfoModel->getUserApplyCount($v['user_id']);
} }
return $data; return $data;
} }
// 获取指定用户申请的样片总数 // 获取指定字段的总数
public function getSampleApplySum($user_id) public function getSampleApplySum($user_id, $field='apply_num')
{ {
return $this->where('user_id', $user_id)->sum('apply_num'); return $this->where('user_id', $user_id)->sum($field);
}
// 获取指定用户申请的样片消耗总人数
public function getUsedCount($user_id)
{
return $this->from('lie_user_sample_apply as s')
->join('lie_order as o', 's.order_id', '=', 'o.order_id')
->where('s.user_id', '=', $user_id)
->where('o.status', '<>', '-1')
->sum('quota');
} }
// 获取领取记录 // 获取领取记录
...@@ -118,7 +130,7 @@ class UserSampleApplyModel extends Model ...@@ -118,7 +130,7 @@ class UserSampleApplyModel extends Model
$page = $request->input('page', 1); $page = $request->input('page', 1);
$limit = $request->input('limit', 10); $limit = $request->input('limit', 10);
$field = ['apply_id', 'user_id', 'account', 'order_id', 'order_sn', 'goods_id', 'goods_name', 'apply_num', 'create_time']; $field = ['apply_id', 'user_id', 'account', 'order_id', 'order_sn', 'goods_id', 'goods_name', 'apply_num', 'quota', 'create_time'];
$list = $this->where('user_id', $user_id) $list = $this->where('user_id', $user_id)
->select($field) ->select($field)
...@@ -126,7 +138,25 @@ class UserSampleApplyModel extends Model ...@@ -126,7 +138,25 @@ class UserSampleApplyModel extends Model
->orderBy('apply_id', 'asc') ->orderBy('apply_id', 'asc')
->paginate($limit, ['*'], 'page', $page)->toArray(); ->paginate($limit, ['*'], 'page', $page)->toArray();
$list['data'] = $this->handleData($list['data']);
return [0, '获取成功', $list['data'], $list['total']]; return [0, '获取成功', $list['data'], $list['total']];
} }
// 处理记录
public function handleData($data)
{
if (!$data) return false;
$OrderModel = new OrderModel();
foreach ($data as &$v) {
$order = $OrderModel->where('order_id', $v['order_id'])->select('status')->first();
$v['order_status'] = Config('params.order_status')[$order->status];
}
return $data;
}
} }
\ No newline at end of file
...@@ -24,7 +24,8 @@ layui.use(['form', 'table', 'laydate'], function(){ ...@@ -24,7 +24,8 @@ layui.use(['form', 'table', 'laydate'], function(){
,{field: 'account', title: '用户账户', width: 150} ,{field: 'account', title: '用户账户', width: 150}
,{field: 'invite_count', title: '邀请人数', width: 100} ,{field: 'invite_count', title: '邀请人数', width: 100}
,{field: 'apply_num_total', title: '已申请样片数', width: 120} ,{field: 'apply_num_total', title: '已申请样片数', width: 120}
,{field: 'apply_count', title: '剩余领取次数', width: 120} ,{field: 'apply_count', title: '剩余有效人数', width: 120}
,{field: 'quota_total', title: '总消耗人数', width: 120}
,{field: 'order_id', title: '订单ID', width: 100} ,{field: 'order_id', title: '订单ID', width: 100}
,{field: 'order_sn', title: '订单编号', width: 150} ,{field: 'order_sn', title: '订单编号', width: 150}
,{field: 'goods_id', title: '样片ID', width: 100} ,{field: 'goods_id', title: '样片ID', width: 100}
......
...@@ -14,14 +14,16 @@ layui.use(['table'], function(){ ...@@ -14,14 +14,16 @@ layui.use(['table'], function(){
} }
,cols: [[ //表头 ,cols: [[ //表头
{title: '序号', type: 'numbers', fixed: 'left', width: 80} {title: '序号', type: 'numbers', fixed: 'left', width: 80}
,{field: 'user_id', title: '用户ID', width: 150} ,{field: 'user_id', title: '用户ID', width: 120}
,{field: 'account', title: '用户账户', width: 200} ,{field: 'account', title: '用户账户', width: 200}
,{field: 'order_id', title: '订单ID', width: 150} ,{field: 'order_id', title: '订单ID', width: 120}
,{field: 'order_sn', title: '订单编号', width: 200} ,{field: 'order_sn', title: '订单编号', width: 200}
,{field: 'goods_id', title: '样片ID', width: 150} ,{field: 'order_status', title: '订单状态', width: 100}
,{field: 'goods_id', title: '样片ID', width: 120}
,{field: 'goods_name', title: '样片名称', width: 300} ,{field: 'goods_name', title: '样片名称', width: 300}
,{field: 'apply_num', title: '领取数量', width: 150} ,{field: 'apply_num', title: '领取数量', width: 120}
,{field: 'create_time', title: '领取时间', width: 218} ,{field: 'quota', title: '样片消耗人数', width: 120}
,{field: 'create_time', title: '领取时间', width: 215}
]] ]]
,limit: 10 ,limit: 10
,limits: [10, 20, 50,] ,limits: [10, 20, 50,]
......
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