123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- namespace Account\Lib;
- use Dever;
- class Log
- {
- # 创建钱包日志
- public function create($data)
- {
- if ($data['status'] == 2) {
- $admin = Dever::load('manage/auth.data');
- if ($admin) {
- $data['audit_admin'] = $admin['id'];
- }
- $data['audit_date'] = time();
- }
- $data['order_num'] = $this->createOrderNum();
- return Dever::db('account/info_log')->insert($data);
- }
- # 生成订单号
- private function createOrderNum()
- {
- $where['order_num'] = Dever::order('A');
- $state = Dever::db('account/info_log')->one($where);
- if (!$state) {
- return $where['order_num'];
- } else {
- return $this->createOrderNum();
- }
- }
- # 获取日志列表
- public function getList($config_id, $info_id)
- {
- $where['config_id'] = $config_id;
- $where['info_id'] = $info_id;
- list($start, $end) = Dever::month();
- if ($start && $end) {
- $where['start'] = $start;
- $where['end'] = $end;
- }
- $data = Dever::db('account/info_log')->getData($where, function(&$info) {
- return $this->info($info);
- });
- return $data;
- }
- # 根据来源获取日志列表
- public function getListBySource($source, $source_id)
- {
- $where['source'] = $source;
- $where['source_id'] = $source_id;
- $data = Dever::db('account/info_log')->select($where, function(&$info) {
- return $this->info($info);
- });
- return $data;
- }
- # 获取日志详情
- public function getInfo($id)
- {
- $data = Dever::db('account/info_log')->find($id);
- $data = $this->info($data);
- return $data;
- }
- # 获取详情
- private function info($info)
- {
- $info['username'] = '无';
- $config = Dever::db('account/config')->find($info['config_id']);
- $project = Dever::db('account/config_project')->find($config['project_id']);
- $source = Dever::db($project['source'])->find($info['uid']);
- if ($source) {
- $info['username'] = $source[$project['source_name']];
- }
- $info['config_name'] = $config['name'];
- if ($info['type_id'] == 2) {
- if ($info['status'] == 1) {
- $info['status_name'] = '待审核';
- } elseif ($info['status'] == 2) {
- $info['status_name'] = '已审核(待发放)';
- } elseif ($info['status'] == 3) {
- $info['status_name'] = '已审核(已发放)';
- } else {
- $info['status_name'] = '已作废';
- }
- } elseif ($info['status'] == 2) {
- $info['status_name'] = '已入账';
- } else {
- $info['status_name'] = '待入账';
- }
-
- $info['type_name'] = Dever::load("account/config_type-one#name", $info['type_id']);
- $info['cdate'] = date('Y-m-d H:i', $info['cdate']);
- $info['fee'] = Dever::number($info['ycash'] - $info['cash']);
- return $info;
- }
- }
|