diff --git a/app/middleapi/controller/WithdrawController.php b/app/middleapi/controller/WithdrawController.php new file mode 100644 index 000000000..f66f7325b --- /dev/null +++ b/app/middleapi/controller/WithdrawController.php @@ -0,0 +1,96 @@ +request->isPost()){ + return $this->fail('请求方式错误'); + } + $params = $this->request->post(['page_no','page_size', 'order_sn', 'status']); + $where = []; + if (!empty($params['order_sn'])) { + $where[] = ['order_sn', '=', $params['order_sn']]; + } + if (isset($params['status']) && $params['status'] != '') { + $where[] = ['status', '=', $params['status']]; + } + $pageNo = !empty($params['page_no']) ? $params['page_no'] : 1; + $pageSize = !empty($params['page_size']) ? $params['page_size'] : 20; + $lists = Withdraw::where($where) + ->append(['s_date', 'e_date', 'company_name'], true) + ->with('user') + ->withAttr('company_name', function ($value, $data) { + $company = Company::where(['admin_id'=>$data['admin_id']])->find(); + return $company['company_name']??''; + }) + ->withAttr('s_date', function ($value, $data) { + $withdrawedCount = Withdraw::where(['user_id'=>$data['user_id'], 'status'=>3])->count(); + $company = Company::where(['admin_id'=>$data['admin_id']])->find(); + if ($withdrawedCount == 0) { + $firstUserLog = UserAccountLog::where(['company_id'=>$company['id'] ?? 0])->order('id', 'asc')->find(); + return $firstUserLog['create_time'] ?? ''; + } else { + $withdrawedCount = Withdraw::where(['user_id'=>$data['user_id'], 'status'=>3])->order('id', 'desc')->find(); + return $withdrawedCount['transfer_end_cycel'] ?? ''; + } + }) + ->withAttr('e_date', function ($value, $data) { + return date('Y-m-d H:i:s', $data['transfer_end_cycel']); + }) + ->order('id', 'desc') + ->page($pageNo, $pageSize) + ->select() + ->toArray(); + $count = Withdraw::where($where)->count(); + $result = [ + 'lists' => $lists, + 'count' => $count, + 'page_no' => $pageNo, + 'page_size' => $pageSize + ]; + return $this->success('请求成功',$result); + } + + public function update($id) + { + $status = $this->request->param('status'); + if (!in_array($status, [1, 2, 3])) { + return $this->fail('参数错误'); + } + $data = Withdraw::find($id); + if (empty($data)) { + return $this->fail('数据不存在'); + } + $data->status = $status; + $data->udpate_time = time(); + $data->save(); + return $this->success('操作成功', [], 1, 1); + } + + /** + * 提现申请审核 + */ + public function audit() + { + try { + $params = $this->request->param(); + $re = WithdrawLogic::audit($params); + if (!$re) { + return $this->fail(WithdrawLogic::getError()); + } + return $this->success('操作成功', [], 1, 1); + } catch (Exception $exception) { + return $this->fail($exception->getMessage()); + } + } +} \ No newline at end of file