diff --git a/app/controller/User.php b/app/controller/User.php index 96f467f..576c74d 100644 --- a/app/controller/User.php +++ b/app/controller/User.php @@ -5,7 +5,9 @@ use app\BaseController; use app\model\User as UserModel; use app\validate\User as UserValidate; use think\exception\ValidateException; +use think\facade\Db; use think\facade\Request; +use think\facade\Session; class User extends BaseController { @@ -39,4 +41,66 @@ class User extends BaseController return $this->renderError($exception->getMessage()); } } + + /** + * 提现记录 + * @return array + * @throws \think\db\exception\DbException + */ + public function withdrawalRecords() + { + $userData = Session::get('login_user_data'); + + $data = Request::param(); + + $limit = $data['limit'] ?: 10; + + $list = Db::name('withdrawal_records') + ->where('user_id',$userData['id']) + ->field('withdrawal_amount,withdrawal_balence,apply_time') + ->order('id' ,'desc') + ->paginate($limit); + + $listArr = $list->items(); + + foreach ($listArr as &$item) { + $item['apply_time'] = date("m月d日 H:i",strtotime($item['apply_time'])); + } + + return $this->renderSuccess('数据获取成功',[ + 'list' => $listArr, + 'total' => $list->total() + ]); + } + + /** + * 充值记录 + * @return array + * @throws \think\db\exception\DbException + */ + public function rechargeRecords() + { + $userData = Session::get('login_user_data'); + + $data = Request::param(); + + $limit = $data['limit'] ?: 10; + + $list = Db::name('recharge_records') + ->where('user_id',$userData['id']) + ->field('recharge_amount,residue_amount,recharge_time') + ->order('id' ,'desc') + ->paginate($limit); + + $listArr = $list->items(); + + foreach ($listArr as &$item) { + $item['recharge_time'] = date("m月d日 H:i",strtotime($item['recharge_time'])); + } + + return $this->renderSuccess('数据获取成功',[ + 'list' => $listArr, + 'total' => $list->total() + ]); + } } \ No newline at end of file diff --git a/route/app.php b/route/app.php index 7be4698..1df59ea 100644 --- a/route/app.php +++ b/route/app.php @@ -23,7 +23,9 @@ Route::group('passport',function (){ }); Route::group('user',function (){ - Route::post('modifyPassword','user/modifyPassword')->middleware(CheckToken::class); + Route::post('modifyPassword','user/modifyPassword'); + Route::post('withdrawalRecords','user/withdrawalRecords')->middleware(CheckToken::class); + Route::post('rechargeRecords','user/rechargeRecords')->middleware(CheckToken::class); });