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']]; } } 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', ); } return $result; } # 入账 public function up_commit($uid, $cash, $type, $config, $desc = '', $source = '', $source_id = '', $method = 1) { if ($cash == 0) { Dever::alert('金额不能为0'); } $config = Dever::db('account/config')->find(array('key' => $config)); if (!$config) { Dever::alert('账户信息不存在'); } $project = Dever::db('account/config_project')->find($config['project_id']); $user = Dever::db($project['source'])->find($uid); if (!$user) { Dever::alert('用户信息不存在'); } $type = Dever::db('account/config_type')->find(array('key' => $type)); if (!$type) { Dever::alert('交易类型不存在'); } if ($type['project_id'] != -1 && $type['project_id'] != $config['project_id']) { Dever::alert('交易类型不正确'); } $data['uid'] = $uid; $data['config_id'] = $config['id']; $data['project_id'] = $config['project_id']; $data['clear'] = true; $info = Dever::db('account/info')->find($data); if (!$info) { $info['id'] = Dever::db('account/info')->insert($data); if (!$info['id']) { Dever::alert('用户信息不存在'); } $info['cash'] = 0; } if ($type['key'] == 'tixian') { if ($config['is_withdraw'] == 2) { Dever::alert('当前账户不能提现'); } if ($config['withdraw_down'] > 0 && $cash < $config['withdraw_down']) { Dever::alert('提现金额不能少于' . $config['withdraw_down']); } if ($config['withdraw_up'] > 0 && $cash > $config['withdraw_up']) { Dever::alert('提现金额不能大于' . $config['withdraw_up']); } if ($cash > $info['cash']) { Dever::alert('提现金额不能大于账户余额'); } } $func = 'inc'; if ($type['type'] == 2) { $cash = -1*$cash; $func = 'dec'; } $data['cash'] = $cash; $data['type_id'] = $type['id']; if ($source) { $data['source'] = $source; } if ($source_id) { $data['source_id'] = $source_id; } if ($desc) { $data['desc'] = $desc; } if ($info) { $data['yue'] = $info['cash'] + $data['cash']; } else { $data['yue'] = 0; } if ($data['yue'] < 0) { $data['yue'] = 0; } $yue = $data['yue']; $data['method'] = $method; $admin = Dever::load('manage/auth.data'); if ($admin) { $data['admin_id'] = $admin['id']; } $data['clear'] = true; $id = Dever::db('account/info_log')->insert($data); if ($id) { $update = array(); $update['where_id'] = $info['id']; $update['set_cash'] = $data['cash']; $update['set_col'] = $data['cash']; $update['clear'] = true; Dever::db('account/info')->$func($update); } return $yue; } }