Commit 70918906 by 朱继来

调整自营样片列表消耗人数

parent 0f672840
......@@ -99,7 +99,8 @@ class UserSampleApplyModel extends Model
$v['invite_count'] = $UserSampleInviteModel->getUserInviteCount($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->getSampleApplySum($v['user_id'], 'quota'); // 获取指定用户申请的样片总数
$v['quota_total'] = $this->getUsedCount($v['user_id']); // 获取指定用户申请的样片消耗总人数
$v['apply_count'] = $UserInfoModel->getUserApplyCount($v['user_id']);
}
......@@ -112,6 +113,16 @@ class UserSampleApplyModel extends Model
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');
}
// 获取领取记录
public function applyLog($request)
{
......@@ -127,7 +138,25 @@ class UserSampleApplyModel extends Model
->orderBy('apply_id', 'asc')
->paginate($limit, ['*'], 'page', $page)->toArray();
$list['data'] = $this->handleData($list['data']);
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
......@@ -18,6 +18,7 @@ layui.use(['table'], function(){
,{field: 'account', title: '用户账户', width: 200}
,{field: 'order_id', title: '订单ID', width: 120}
,{field: 'order_sn', title: '订单编号', width: 200}
,{field: 'order_status', title: '订单状态', width: 100}
,{field: 'goods_id', title: '样片ID', width: 120}
,{field: 'goods_name', title: '样片名称', width: 300}
,{field: 'apply_num', title: '领取数量', width: 120}
......
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