| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 | 
							- <?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 getCash($config_id, $info_id, $type_id)
 
-     {
 
-         $where['config_id'] = $config_id;
 
-         $where['info_id'] = $info_id;
 
-         $where['type_id'] = $type_id;
 
-         $where['status'] = '1,2';
 
-         $data = Dever::db('account/info_log')->getCash($where);
 
-         
 
-         return $data;
 
-     }
 
-     # 获取日志列表
 
-     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 (strstr($info['source'], '/')) {
 
-             $source = Dever::db($info['source'])->find($info['source_id']);
 
-             if ($source) {
 
-                 $user = Dever::db($project['source'])->find($source['uid']);
 
-                 $info['username'] = $user['name'];
 
-                 $info['avatar'] = $user['avatar'];
 
-             }
 
-         }
 
-         
 
-         $info['config_name'] = $config['name'];
 
-         $info['status_name'] = $this->status($info['type_id'], $info['status']);
 
-         $info['type_name'] = Dever::load("account/config_type-one#name", $info['type_id']);
 
-         $info['cdate_string'] = date('Y-m-d H:i', $info['cdate']);
 
-         if ($info['audit_date']) {
 
-             $info['audit_date_string'] = date('Y-m-d H:i', $info['audit_date']);
 
-         } else {
 
-             $info['audit_date_string'] = '-';
 
-         }
 
-         
 
-         $info['fee'] = Dever::number($info['ycash'] - $info['cash']);
 
-         $type = Dever::db('account/config_type')->one($info['type_id']);
 
-         if ($type['type'] == 2) {
 
-             $info['ycash'] = Dever::number(-1*$info['ycash']);
 
-             $info['cash'] = Dever::number(-1*$info['cash']);
 
-             $info['fee'] = Dever::number(-1*$info['fee']);
 
-         }
 
-         return $info;
 
-     }
 
-     # 获取状态名称
 
-     public function status($type, $status)
 
-     {
 
-         if ($type == 2) {
 
-             if ($status == 1) {
 
-                 $status_name = '待审核';
 
-             } elseif ($status == 2) {
 
-                 $status_name = '已审核(待发放)';
 
-             } elseif ($status == 3) {
 
-                 $status_name = '发放成功';
 
-             } elseif ($status == 4) {
 
-                 $status_name = '审核驳回';
 
-             } elseif ($status == 6) {
 
-                 $status_name = '已审核(待发放)';
 
-             } else {
 
-                 $status_name = '发放失败';
 
-             }
 
-         } elseif ($status == 2) {
 
-             $status_name = '已入账';
 
-         } else {
 
-             $status_name = '待入账';
 
-         }
 
-         return $status_name;
 
-     }
 
-     # 修改记录状态
 
-     public function upStatus($id, $status, $cash = false, $update = array())
 
-     {
 
-         $info = Dever::db('account/info_log')->find($id);
 
-         if ($info) {
 
-             $update['where_id'] = $info['id'];
 
-             $update['status'] = $status;
 
-             $state = Dever::db('account/info_log')->update($update);
 
-             if ($state && $status >= 4 && $cash) {
 
-                 $cash = $info['cash'];
 
-                 $update = array();
 
-                 $update['where_id'] = $info['info_id'];
 
-                 $update['set_cash'] = $cash;
 
-                 $update['set_col'] = $cash;
 
-                 $update['clear'] = true;
 
-                 $func = 'inc';
 
-                 Dever::db('account/info')->$func($update);
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |