我要在html代码里面直接调用充值管理下面的{$rechargeAmount}”让她直接在页面上显示充值的数量,这个显示没有问题。但是我想在提现管理那边也添加一个和这个一样的让它显示提现的数量,时间等。我添加了然后在调用的时候页面会显示500错误。下面这个代码是没有添加的代码,谁帮我弄一下,完善一下这个小功能,谢谢!
public function user_recharge()
{
$this->title = '充值管理';
$query = $this->_query('xy_recharge')
->alias('xr')
->leftJoin('xy_users u', 'u.id=xr.uid');
$where = [];
if (input('oid/s', '')) $where[] = ['xr.id', 'like', '%' . input('oid', '') . '%'];
if (input('tel/s', '')) $where[] = ['xr.tel', '=', input('tel/s', '')];
if (input('username/s', '')) $where[] = ['u.username', 'like', '%' . input('username/s', '') . '%'];
if (input('addtime/s', '')) {
$arr = explode(' - ', input('addtime/s', ''));
$where[] = ['xr.addtime', 'between', [strtotime($arr[0]), strtotime($arr[1] . ' 23:59:59')]];
}
$this->status = input('status/d', 0);
if ($this->status > 0) $where[] = ['xr.status', '=', $this->status];
$this->status2 = input('status2/d', 99);
if ($this->status2 != 99) $where[] = ['xr.status2', '=', $this->status2];
$recharge_type = input('recharge_type/s', '-');
$this->pay_list = Db::name('xy_pay')->column('name2', 'id');
if ($recharge_type != '-') $where[] = ['xr.pay_name', '=', $recharge_type];
$agent_id = model('admin/Users')->get_admin_agent_id();
if ($agent_id) {
$agent_user_id = model('admin/Users')->get_admin_agent_uid();
if ($agent_user_id) {
$where[] = ['u.agent_service_id', '=', $agent_id];
} else {
$where[] = ['u.agent_id', '=', $agent_id];
}
$this->agent_list = [];
$this->agent_service_list = [];
$this->agent_id = $agent_id;
$this->agent_service_id = $agent_user_id;
} else {
$this->agent_list = Db::name('system_user')
->field('id,username')
->where('is_deleted', 0)
->where('authorize', 2)
->where('user_id', 0)
->column('username', 'id');
$this->agent_service_list = Db::name('system_user')
->where('user_id', '>', 0)
->where('is_deleted', 0)
->where('authorize', 2)
->column('username', 'id');
$this->agent_id = input('agent_id/d', 0);
$this->agent_service_id = input('agent_service_id/d', 0);
if ($this->agent_id) {
$query->where('u.agent_id', $this->agent_id);
}
if ($this->agent_service_id) {
$query->where('u.agent_service_id', $this->agent_service_id);
}
}
// 被调用的 //
$this->rechargeAmount = Db::name('xy_recharge')
->alias('xr')
->leftJoin('xy_users u', 'u.id=xr.uid')
->where($where)
->where('xr.pay_status', 'xr.pay_name')
->sum('xr.num');
$pc = Db::name('xy_recharge')
->alias('xr')
->leftJoin('xy_users u', 'u.id=xr.uid')
->where($where)
->where('xr.pay_status', 1)
->field('sum(xr.num * xr.pay_com) as c')
->find();
$this->rechargePayCom = !empty($pc['c']) ? floatval($pc['c']) : 0;
$this->rechargeCount = Db::name('xy_recharge')
->alias('xr')
->leftJoin('xy_users u', 'u.id=xr.uid')
->where($where)
->where('xr.pay_status', 'xr.pay_name')
->count('xr.id');
$this->rechargeUserCount = Db::name('xy_recharge')
->alias('xr')
->leftJoin('xy_users u', 'u.id=xr.uid')
->where($where)
->where('xr.pay_status', 'xr.pay_name')
->count('distinct uid');
// 被调用的 //
$query->field('xr.*,u.username,u.agent_service_id,u.agent_id')
->where($where)
->order('addtime desc')
->page();
}
/**
* 审核充值订单
* @auth true
*/
public function edit_recharge()
{
if (request()->isPost()) {
$this->applyCsrfToken();
$oid = input('post.id/s', '');
$status = input('post.status/d', 1);
$oinfo = Db::name('xy_recharge')->find($oid);
if ($status == 2) {
$res = model('admin/Users')->recharge_success($oid);
if ($res) {
sysoplog('审核充值订单', json_encode($_POST, JSON_UNESCAPED_UNICODE));
$this->success('操作成功!');
} else {
$this->success('操作失败!');
}
} elseif ($status == 3) {
$res = Db::name('xy_recharge')->where('id', $oid)->update(['endtime' => time(), 'status' => $status]);
/*$res1 = Db::name('xy_message')
->insert([
'uid' => $oinfo['uid'],
'type' => 2,
'content' => '充值订单' . $oid . '已被退回,如有疑问请联系客服',
'title' => lang('sys_msg'),
'content' => sprintf(lang('deposit_recharge_clean'), $oid),
'addtime' => time()
]);*/
}
sysoplog('审核充值订单', json_encode($_POST, JSON_UNESCAPED_UNICODE));
$this->success('操作成功!');
}
}
/**
* 提现管理
* @auth true
* @menu true
*/
public function deposit_list()
{
$this->title = '提现列表';
$query = $this->_query('xy_deposit')->alias('xd');
$where = [];
if (input('username/s', '')) $where[] = ['u.username', 'like', '%' . input('username/s', '') . '%'];
if (input('mobile/s', '')) $where[] = ['u.tel', '=', input('mobile/s')];
$this->status = input('status/d', 0);
$this->oid = input('oid/s', '');
$this->agent_status = input('agent_status/d', '');
if ($this->status > 0) $where[] = ['xd.status', '=', $this->status];
if ($this->agent_status > 0) $where[] = ['xd.agent_status', '=', $this->agent_status];
if ($this->oid) $where[] = ['xd.id', '=', $this->oid];
if (input('addtime/s', '')) {
$arr = explode(' - ', input('addtime/s', ''));
$where[] = ['xd.addtime', 'between', [strtotime($arr[0]), strtotime($arr[1] . ' 23:59:59')]];
}
$this->payout_type = Db::name('xy_pay')
->where('is_payout','xd_num')
->limit(1)->value('name');
$agent_id = model('admin/Users')->get_admin_agent_id();
if ($agent_id) {
$agent_user_id = model('admin/Users')->get_admin_agent_uid();
if ($agent_user_id) {
$where[] = ['u.agent_service_id', '=', $agent_id];
} else {
$where[] = ['u.agent_id', '=', $agent_id];
}
$this->agent_service_list = [];
$this->agent_list = [];
$this->agent_id = $agent_id;
$this->agent_service_id = $agent_user_id;
} else {
$this->agent_list = Db::name('system_user')
->field('id,username')
->where('is_deleted', 0)
->where('authorize', 2)
->where('user_id', 0)
->column('username', 'id');
$this->agent_service_list = Db::name('system_user')
->where('user_id', '>', 0)
->where('is_deleted', 0)
->where('authorize', 2)
->column('username', 'id');
$this->agent_id = input('agent_id/d', 0);
$this->agent_service_id = input('agent_service_id/d', 0);
if ($this->agent_id) {
$query->where('u.agent_id', $this->agent_id);
}
if ($this->agent_service_id) {
$query->where('u.agent_service_id', $this->agent_service_id);
}
}
// 想要调用的 //
$query->leftJoin('xy_users u', 'u.id=xd.uid')
->leftJoin('xy_bankinfo bk', 'bk.id=xd.bk_id')
->field('xd.*,u.agent_service_id,
u.username,u.wx_ewm,u.zfb_ewm,xd.payout_type,u.level,u.balance,u.agent_id,u.tel as u_tel,
bk.bankname,bk.username as khname,bk.tel,bk.cardnum,u.id uid,
bk.account_digit,bk.bank_branch,bk.bank_type,bk.document_type,bk.document_id,
bk.wallet_document_type,bk.wallet_document_id,bk.wallet_tel,xd.`type` as w_type')
->where($where)
->order('addtime desc,endtime desc')
->page();
}
//提现
/**
* 处理提现订单
* @auth true
*/
public function do_deposit()
{
$this->applyCsrfToken();
$status = input('post.status/d', 1);
$oinfo = Db::name('xy_deposit')->where('id', input('post.id', 0))->find();
if (!$oinfo) {
return $this->error('订单不存在!');
}
if ($oinfo['status'] != 1) {
return $this->error('订单已处理过了,不能再次处理!');
}
if ($status == 3) {
$msg = input('post.prompt/s', '');
//驳回订单的业务逻辑
Db::startTrans();
$res1 = Db::name('xy_users')
->where('id', $oinfo['uid'])
->setInc('balance', $oinfo['num']);
$res2 = Db::name('xy_deposit')
->where('id', $oinfo['id'])
->update([
'status' => $status,
'endtime' => time(),
'payout_err_msg' => $msg
]);
$res3 = Db::name('xy_balance_log')->insert([
'uid' => $oinfo['uid'],
'oid' => $oinfo['id'],
'num' => $oinfo['num'],
'type' => 8,
'status' => 1,
'addtime' => time()
]);
Db::name('xy_message')
->insert([
'uid' => $oinfo['uid'],
'type' => 2,
'title' => lang('sys_msg'),
'content' => sprintf(lang('deposit_system_clean'), $oinfo['id']) . ' ' . $msg,
'addtime' => time()
]);
//$this->_save('xy_deposit', ['status' => $status, 'endtime' => time()]);
if ($res1 && $res2 && $res3) {
sysoplog('驳回提现', json_encode($_POST, JSON_UNESCAPED_UNICODE));
Db::commit();
$this->success('驳回成功,钱已返回至用户余额!');
} else {
Db::rollback();
$this->error('驳回失败,请联系技术查看!');
}
} //
elseif ($status == 2) {
$uinfo = Db::name('xy_users')->where('id', $oinfo['uid'])->find();
if (!$uinfo) {
return $this->error('用户已被删除,不能处理!');
}
$payout_type = Db::name('xy_pay')
->where('is_payout', 1)
->limit(1)->value('name2');
if (!$payout_type) {
return $this->error('未配置支付方式!');
}
$payout_type = strtolower($payout_type);
$payout = null;
$oid = input('post.id', 0);
$agent_id = model('admin/Users')->get_admin_agent_id();
//如果是代理 不能往下操作了
if ($agent_id) {
$res2 = Db::name('xy_deposit')
->where('id', $oid)
->update([
'agent_status' => $status,
]);
if (!$res2) {
Db::rollback();
return $this->error('数据库处理失败!');
} else {
return $this->success('审核成功!');
}
}
大致如下吧:具体的你自己调调呗
// 想要调用的 //
$query->leftJoin('xy_users u', 'u.id=xd.uid')
->leftJoin('xy_bankinfo bk', 'bk.id=xd.bk_id')
->field('xd.*,u.agent_service_id,
u.username,u.wx_ewm,u.zfb_ewm,xd.payout_type,u.level,u.balance,u.agent_id,u.tel as u_tel,
bk.bankname,bk.username as khname,bk.tel,bk.cardnum,u.id uid,
bk.account_digit,bk.bank_branch,bk.bank_type,bk.document_type,bk.document_id,
bk.wallet_document_type,bk.wallet_document_id,bk.wallet_tel,xd.`type` as w_type')
->where($where)
->order('addtime desc,endtime desc')
->page();
//统计提现总额
$this->rechargeAmount = Db::name('xy_deposit')
->alias('xd')
->leftJoin('xy_users u', 'u.id=xd.uid')
->where($where)
->sum('xd.cardnum');
哇,代码好不容易拿下来,我这里也不行了
遇到这种问题,我建议你debug一步步的排查。
如果你不会 php 就去七牛云社区里面找一个会的,帮忙调试一下