会员卡搜索以及导出字段不一致的问题处理

This commit is contained in:
evoxwht 2023-03-24 15:16:13 +08:00
parent 4349a46a6d
commit 99501a40e7
4 changed files with 15 additions and 13 deletions

View File

@ -43,14 +43,13 @@ class MemberCardBatch extends AuthController
{
$where = $this->request->getMore([
['title', ''],
// ['page', 1],
// ['limit', 20],
]);
$data = $this->services->getList($where);
return app('json')->success($data);
}
/** 保存卡片资源
/**
* 保存卡片资源
* @param $id
* @return mixed
*/

View File

@ -45,7 +45,7 @@ class MemberCardBatch extends BaseModel
public function searchTitleAttr($query, $value)
{
if ($value !== '') {
$query->where('title', $value);
$query->where('title', 'like', '%' . $value . '%');
}
}

View File

@ -32,6 +32,10 @@ class MemberCardBatchServices extends BaseServices
/**
* 获取会员卡批次列表
* @param array $where
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getList(array $where = [])
{

View File

@ -49,16 +49,15 @@ class MemberCardServices extends BaseServices
}
unset($where['is_use']);
$list = $this->dao->getSearchList($where, $page, $limit);
if ($list) {
foreach ($list as $k => $v) {
if ($v['use_uid']) {
$user_info = $userService->getUserInfo($v['use_uid'], ['nickname', 'phone', 'real_name']);
$list[$k]['username'] = $user_info['real_name'] ? $user_info['real_name'] : $user_info['nickname'];
$list[$k]['phone'] = $user_info ? $user_info['phone'] : "";
}
$list[$k]['add_time'] = date('Y-m-d H:i:s', $v['add_time']);
$list[$k]['use_time'] = $v['use_time'] != 0 ? date('Y-m-d H:i:s', $v['use_time']) : "未使用";
$userIds = array_column($list->toArray(), 'use_uid');
$userList = $userService->getColumn([['uid', 'in', $userIds]], 'nickname,phone,real_name', 'uid');
foreach ($list as $k => $v) {
if ($v['use_uid']) {
$list[$k]['username'] = $userList[$v['use_uid']]['real_name'] ?: $userList[$v['use_uid']]['nickname'];
$list[$k]['phone'] = $userList[$v['use_uid']] ? $userList[$v['use_uid']]['phone'] : "";
}
$list[$k]['add_time'] = date('Y-m-d H:i:s', $v['add_time']);
$list[$k]['use_time'] = $v['use_time'] != 0 ? date('Y-m-d H:i:s', $v['use_time']) : "未使用";
}
$count = $this->dao->count($where);
return compact('list', 'count');