diff --git a/app/middleapi/controller/AccountLogController.php b/app/middleapi/controller/AccountLogController.php new file mode 100644 index 000000000..efc6d3fb4 --- /dev/null +++ b/app/middleapi/controller/AccountLogController.php @@ -0,0 +1,97 @@ +request->isPost()){ + return $this->fail('请求方式错误'); + } + $params = $this->request->post(['page_no','page_size', 'start_time', 'end_time', 'type','company_id']); + $where = []; + if (isset($params['type']) && $params['type'] == 'um') { + $where[] = ['change_type', 'in', AccountLogEnum::getUserMoneyChangeType()]; + } + if (!empty($params['company_id'])) { + $where[] = ['company_id', '=', $params['company_id']]; + } + if (!empty($params['start_time'])) { + $where[] = ['create_time', '>=', strtotime($params['start_time'])]; + } + if (!empty($this->params['end_time'])) { + $where[] = ['create_time', '<=', strtotime($params['end_time'])]; + } + $pageNo = !empty($params['page_no']) ? $params['page_no'] : 1; + $pageSize = !empty($params['page_size']) ? $params['page_size'] : 20; + $lists = UserAccountLog::where($where) + ->with(['company_info','user_info']) + ->order('id', 'desc') + ->page($pageNo, $pageSize) + ->select() + ->toArray(); + foreach ($lists as &$item) { + $item['user_info']['avatar'] = FileService::getFileUrl($item['user_info']['avatar']); + $item['user_info']['group_name']=UserRole::where('id',$item['user_info']['group_id'])->value('name'); + $item['change_type_desc'] = AccountLogEnum::getChangeTypeDesc($item['change_type']); + $symbol = $item['action'] == AccountLogEnum::INC ? '+' : '-'; + $item['change_amount'] = $symbol . $item['change_amount']; + // 用于导出 + $item['user_info_sn'] = $item['user_info']['sn']; + $item['company_info_company_name'] = $item['company_info']['company_name']; + $item['user_info_nickname'] = $item['user_info']['nickname']; + $item['user_info_group_name'] = $item['user_info']['group_name']; + $item['user_info_mobile'] = $item['user_info']['mobile']; + } + $count = UserAccountLog::where($where)->count(); + $result = [ + 'lists' => $lists, + 'count' => $count, + 'page_no' => $pageNo, + 'page_size' => $pageSize + ]; + return $this->success('请求成功',$result); + } + + + /** + * @notes 用户余额变动类型 + * @return \think\response\Json + * @author 段誉 + * @date 2023/2/24 15:25 + */ + public function getUmChangeType() + { + return $this->data(AccountLogEnum::getUserMoneyChangeTypeDesc()); + } + + public function getCompanyUserList() + { + $param = $this->request->param(); + $companyId = $param['company_id'] ?? 0; + $userList = User::where(['company_id' => $companyId])->field('id,nickname,avatar,sn,mobile,group_id,deposit,income')->select()->toArray(); + return $this->success('成功', $userList); + } + +} \ No newline at end of file