You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
172 lines
4.7 KiB
172 lines
4.7 KiB
<?php
|
|
namespace app\controller;
|
|
|
|
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
|
|
{
|
|
|
|
|
|
/**
|
|
* 找回密码
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function modifyPassword()
|
|
{
|
|
$data = Request::param();
|
|
|
|
try {
|
|
// 验证用户输入
|
|
validate(UserValidate::class)->scene('modifyPassword')->check($data);
|
|
|
|
$userModel = new UserModel();
|
|
|
|
$user = $userModel->modifyPassword($data);
|
|
|
|
if ($user['status']) {
|
|
return $this->renderSuccess('修改成功');
|
|
} else {
|
|
return $this->renderError($user['msg']);
|
|
}
|
|
} catch (ValidateException $exception) {
|
|
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'], 'status' => 1])
|
|
->field('withdrawal_amount,withdrawal_balance,apply_time')
|
|
->order('id' ,'desc')
|
|
->paginate($limit);
|
|
|
|
$listArr = $list->items();
|
|
|
|
foreach ($listArr as &$item) {
|
|
give_symbol($item['withdrawal_amount'],'-');
|
|
$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) {
|
|
give_symbol($item['recharge_amount']);
|
|
$item['recharge_time'] = date("m月d日 H:i",strtotime($item['recharge_time']));
|
|
}
|
|
|
|
return $this->renderSuccess('数据获取成功',[
|
|
'list' => $listArr,
|
|
'total' => $list->total()
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 消费记录
|
|
* @return array
|
|
* @throws \think\db\exception\DbException
|
|
*/
|
|
public function consumptionRecords()
|
|
{
|
|
$userData = Session::get('login_user_data');
|
|
|
|
$data = Request::param();
|
|
|
|
$limit = $data['limit'] ?: 10;
|
|
|
|
$list = Db::name('consumption_records')
|
|
->where(['user_id' => $userData['id'],'status' => 1])
|
|
->field('actual_price,residue_amount,create_time')
|
|
->order('id' ,'desc')
|
|
->paginate($limit);
|
|
|
|
$listArr = $list->items();
|
|
|
|
foreach ($listArr as &$item) {
|
|
give_symbol($item['actual_price'],'-');
|
|
$item['create_time'] = date("m月d日 H:i",strtotime($item['create_time']));
|
|
}
|
|
|
|
return $this->renderSuccess('数据获取成功',[
|
|
'list' => $listArr,
|
|
'total' => $list->total()
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 中奖记录
|
|
* @return array
|
|
* @throws \think\db\exception\DbException
|
|
*/
|
|
public function awardsRecords()
|
|
{
|
|
$userData = Session::get('login_user_data');
|
|
|
|
$data = Request::param();
|
|
|
|
$limit = $data['limit'] ?: 10;
|
|
|
|
$list = Db::name('awards_records')
|
|
->where(['status' => 1,'user_id' => $userData['id']])
|
|
->field('awards_amount,withdrawal_balance,create_time')
|
|
->order('id' ,'desc')
|
|
->paginate($limit);
|
|
|
|
$listArr = $list->items();
|
|
|
|
foreach ($listArr as &$item) {
|
|
give_symbol($item['awards_amount']);
|
|
$item['create_time'] = date("m月d日 H:i",strtotime($item['create_time']));
|
|
}
|
|
|
|
return $this->renderSuccess('数据获取成功',[
|
|
'list' => $listArr,
|
|
'total' => $list->total()
|
|
]);
|
|
}
|
|
}
|