Files
tuiguangzhushou/application/mobile/controller/Account.php
2020-08-06 15:26:41 +08:00

80 lines
2.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\AccountLogs as AccountLogsModel;
use app\common\model\Member as MemberModel;
use app\common\model\Withdrawal as WithdrawalModel;
use app\common\service\Withdrawal as WithdrawalService;
use think\Request;
class Account extends _Init
{
public function _initialize()
{
parent::_initialize();
$this->user = MemberModel::get(UID);
$this->nav = 5;
if (empty($this->user->info->is_agent)) {
$this->redirect('finance/agent');
}
}
public function index($uid = '')
{
// $money = 50000;
// $this->user->account()->exp('price', 'price+' . $money)->update();
// $this->user->account->logs()->save([
// 'rule_id' => 9,
// 'type' => 'price',
// 'increase' => $money,
// 'balance' => $this->user->account->price,
// 'remark' => '测试充值',
// ]);
$map = [
'uid' => UID,
'type' => "price",
];
$this->list = AccountLogsModel::where($map)->order('create_time desc')->select();
$this->meta_title = '收益明细';
return $this->fetch();
}
public function withdrawal(Request $request)
{
if (IS_POST) {
$data = $request->post();
$data['uid'] = UID;
$res = WithdrawalService::create($data);
if ($res === true) {
return $this->success("操作成功", url('account/withdrawal_logs'));
} else {
return $this->error($res);
}
} else {
$this->meta_title = '收益提现';
return $this->fetch();
}
}
public function withdrawal_logs()
{
$map = [
'uid' => UID,
];
$this->total = number_format(WithdrawalModel::where($map)->sum('money'), 2) ?? 0;
$list = WithdrawalModel::where($map)->order('create_time desc')->paginate(10);
$this->assign('list', $list);
$this->meta_title = '提现记录';
return $this->fetch();
}
}