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', 'project_name' => $project['name'], 'name' => $info['name'], ); } return $result; } # 入账 public function up_commit($uid, $cash, $type, $config, $desc = '', $source = '', $source_id = '', $method = 1, $state = true) { if ($cash == 0) { return $this->alert('金额不能为0', $state); } $config = Dever::db('account/config')->find(array('key' => $config)); if (!$config) { return $this->alert('账户信息不存在', $state); } $project = Dever::db('account/config_project')->find($config['project_id']); $user = Dever::db($project['source'])->find($uid); if (!$user) { return $this->alert('用户信息不存在', $state); } $type = Dever::db('account/config_type')->find(array('key' => $type)); if (!$type) { return $this->alert('交易类型不存在', $state); } if ($type['project_id'] != -1 && $type['project_id'] != $config['project_id']) { return $this->alert('交易类型不正确', $state); } $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']) { return $this->alert('用户信息不存在', $state); } $info['cash'] = 0; } if ($type['key'] == 'tixian') { if ($config['is_withdraw'] == 2) { return $this->alert('当前账户不能提现', $state); } if ($config['withdraw_down'] > 0 && $cash < $config['withdraw_down']) { return $this->alert('提现金额不能少于' . $config['withdraw_down'], $state); } if ($config['withdraw_up'] > 0 && $cash > $config['withdraw_up']) { return $this->alert('提现金额不能大于' . $config['withdraw_up'], $state); } if ($cash > $info['cash']) { return $this->alert('提现金额不能大于账户余额', $state); } } $func = 'inc'; if ($type['type'] == 2) { $cash = -1*$cash; $func = 'dec'; } $data['info_id'] = $info['id']; $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; } private function alert($msg, $state = true) { if ($state) { return Dever::alert($msg); } return -1; } }