|
@@ -1,105 +1,51 @@
|
|
<?php
|
|
<?php
|
|
-
|
|
|
|
namespace Account\Lib;
|
|
namespace Account\Lib;
|
|
-
|
|
|
|
use Dever;
|
|
use Dever;
|
|
-
|
|
|
|
class Info
|
|
class Info
|
|
{
|
|
{
|
|
- # 获取账户
|
|
|
|
- public function getInfo($uid, $config_id = false)
|
|
|
|
|
|
+ # 获取用户账户基本信息
|
|
|
|
+ public function getUserInfo($uid, $config_id = false)
|
|
{
|
|
{
|
|
- if (!$config_id) {
|
|
|
|
- $config = Dever::db('account/config')->one(array('type' => 1));
|
|
|
|
- } else {
|
|
|
|
- $config = Dever::db('account/config')->one($config_id);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ($config) {
|
|
|
|
- $where = array();
|
|
|
|
- $where['uid'] = $uid;
|
|
|
|
- $where['config_id'] = $config['id'];
|
|
|
|
- $account = Dever::db('account/info')->one($where);
|
|
|
|
- if ($account) {
|
|
|
|
- return array('name' => $config['name'], 'cash' => $account['cash'], 'z_cash' => $account['z_cash'], 't_cash' => $account['t_cash']);
|
|
|
|
- } else {
|
|
|
|
- return array();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return array();
|
|
|
|
|
|
+ $info = $this->getInfo($uid, $config_id);
|
|
|
|
+ return array('name' => $info['config']['name'], 'cash' => $info['cash']);
|
|
}
|
|
}
|
|
|
|
|
|
- # 获取列表
|
|
|
|
- public function getList($uid, $config_id = false, $type = false, $type_id = false)
|
|
|
|
|
|
+ # 获取账户信息
|
|
|
|
+ public function getInfo($uid, $config_id = false, $check = 0)
|
|
{
|
|
{
|
|
- if (!$config_id) {
|
|
|
|
- $config = Dever::db('account/config')->one(array('type' => 1));
|
|
|
|
|
|
+ $key = Dever::input('account_key');
|
|
|
|
+ if ($key) {
|
|
|
|
+ $config = Dever::db('account/config')->one(array('key' => $account));
|
|
} else {
|
|
} else {
|
|
- $config = Dever::db('account/config')->one($config_id);
|
|
|
|
|
|
+ if (!$config_id) {
|
|
|
|
+ $config = Dever::db('account/config')->one(array('type' => 1));
|
|
|
|
+ } else {
|
|
|
|
+ $config = Dever::db('account/config')->one($config_id);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if ($config) {
|
|
if ($config) {
|
|
|
|
+ # 检测是否可以充值
|
|
|
|
+ if ($check == 1 && $config['is_pay'] == 2) {
|
|
|
|
+ Dever::alert('当前账户不允许充值');
|
|
|
|
+ }
|
|
|
|
+ # 检测是否可以提现
|
|
|
|
+ if ($check == 2 && $config['is_withdraw'] == 2) {
|
|
|
|
+ Dever::alert('当前账户不允许提现');
|
|
|
|
+ }
|
|
$where = array();
|
|
$where = array();
|
|
$where['uid'] = $uid;
|
|
$where['uid'] = $uid;
|
|
$where['config_id'] = $config['id'];
|
|
$where['config_id'] = $config['id'];
|
|
-
|
|
|
|
- $result = Dever::db('account/info_log')->getList($where);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ($result) {
|
|
|
|
- $type = Dever::db('account/config_type')->getData();
|
|
|
|
- foreach ($result as $k => $v) {
|
|
|
|
- $result[$k]['cdate'] = date('Y-m-d H:i', $v['cdate']);
|
|
|
|
- if (isset($type[$v['type_id']])) {
|
|
|
|
- $result[$k]['type_name'] = $type[$v['type_id']]['name'];
|
|
|
|
- } else {
|
|
|
|
- $result[$k]['type_name'] = '未知';
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return $result;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function test_api()
|
|
|
|
- {
|
|
|
|
- //return $this->up(1, 500, 'tixian', 'role_zijin', 'test');
|
|
|
|
- return $this->up_commit(1, 1, 'chongzhi', 'role_zijin', 'test');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function getName($uid, $config_id)
|
|
|
|
- {
|
|
|
|
- $name = $uid;
|
|
|
|
- $info = Dever::db('account/config')->find($config_id);
|
|
|
|
- if ($info) {
|
|
|
|
- $project = Dever::db('account/config_project')->find($info['project_id']);
|
|
|
|
- $source = Dever::db($project['source'])->find($uid);
|
|
|
|
- if ($source) {
|
|
|
|
- return $source[$project['source_name']];
|
|
|
|
|
|
+ $account = Dever::db('account/info')->one($where);
|
|
|
|
+ if (!$account) {
|
|
|
|
+ $id = Dever::db('account/info')->insert($where);
|
|
|
|
+ $account = Dever::db('account/info')->one($id);
|
|
}
|
|
}
|
|
|
|
+ $account['config'] = $config;
|
|
|
|
+ return $account;
|
|
|
|
+ } else {
|
|
|
|
+ Dever::alert('钱包配置不存在');
|
|
}
|
|
}
|
|
- return $name;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function getSearch($config_id)
|
|
|
|
- {
|
|
|
|
- $result = '';
|
|
|
|
- $info = Dever::db('account/config')->find($config_id);
|
|
|
|
- if ($info) {
|
|
|
|
- $project = Dever::db('account/config_project')->find($info['project_id']);
|
|
|
|
- $result = array
|
|
|
|
- (
|
|
|
|
- 'api' => $project['source'] . '-all',
|
|
|
|
- 'col' => $project['source_name'],
|
|
|
|
- 'result' => 'id',
|
|
|
|
- 'search' => 'uid',
|
|
|
|
- 'project_name' => $project['name'],
|
|
|
|
- 'name' => $info['name'],
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return $result;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
# 入账
|
|
# 入账
|
|
@@ -127,7 +73,6 @@ class Info
|
|
if ($type['project_id'] != -1 && $type['project_id'] != $config['project_id']) {
|
|
if ($type['project_id'] != -1 && $type['project_id'] != $config['project_id']) {
|
|
return $this->alert('交易类型不正确', $state);
|
|
return $this->alert('交易类型不正确', $state);
|
|
}
|
|
}
|
|
- $data['status'] = 2;
|
|
|
|
$data['uid'] = $uid;
|
|
$data['uid'] = $uid;
|
|
$data['config_id'] = $config['id'];
|
|
$data['config_id'] = $config['id'];
|
|
$data['project_id'] = $config['project_id'];
|
|
$data['project_id'] = $config['project_id'];
|
|
@@ -140,13 +85,13 @@ class Info
|
|
}
|
|
}
|
|
$info['cash'] = 0;
|
|
$info['cash'] = 0;
|
|
}
|
|
}
|
|
|
|
+ $data['status'] = 2;
|
|
|
|
|
|
$func = 'inc';
|
|
$func = 'inc';
|
|
if ($type['type'] == 2) {
|
|
if ($type['type'] == 2) {
|
|
if ($info['cash'] < $cash) {
|
|
if ($info['cash'] < $cash) {
|
|
return $this->alert('账户余额不足', $state);
|
|
return $this->alert('账户余额不足', $state);
|
|
}
|
|
}
|
|
- $cash = -1*$cash;
|
|
|
|
$func = 'dec';
|
|
$func = 'dec';
|
|
}
|
|
}
|
|
$data['info_id'] = $info['id'];
|
|
$data['info_id'] = $info['id'];
|
|
@@ -207,17 +152,7 @@ class Info
|
|
|
|
|
|
$yue = $data['yue'];
|
|
$yue = $data['yue'];
|
|
$data['method'] = $method;
|
|
$data['method'] = $method;
|
|
- if ($data['status'] == 2) {
|
|
|
|
- $admin = Dever::load('manage/auth.data');
|
|
|
|
- if ($admin) {
|
|
|
|
- $data['audit_admin'] = $admin['id'];
|
|
|
|
- }
|
|
|
|
- $data['audit_date'] = time();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $data['clear'] = true;
|
|
|
|
-
|
|
|
|
- $id = Dever::db('account/info_log')->insert($data);
|
|
|
|
|
|
+ $id = Dever::load('account/lib/log')->create($data);
|
|
if ($id) {
|
|
if ($id) {
|
|
$update = array();
|
|
$update = array();
|
|
$update['where_id'] = $info['id'];
|
|
$update['where_id'] = $info['id'];
|