Manage.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. namespace Account\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. public function push($id, $name, $data)
  7. {
  8. Dever::config('base')->hook = true;
  9. $uid = Dever::param('uid', $data);
  10. $cash = Dever::param('cash', $data);
  11. $desc = Dever::param('desc', $data);
  12. $config_id = Dever::param('config_id', $data);
  13. $type_id = Dever::param('type_id', $data);
  14. $config = $type = array();
  15. if ($config_id) {
  16. $config = Dever::db('account/config')->find($config_id);
  17. }
  18. if ($type_id) {
  19. $type = Dever::db('account/config_type')->find($type_id);
  20. }
  21. if (!$config) {
  22. Dever::alert('账户信息不存在');
  23. }
  24. if (!$type) {
  25. Dever::alert('交易类型不存在');
  26. }
  27. Dever::load('account/lib/info.up_commit', $uid, $cash, $type['key'], $config['key'], $desc, 'account/push', $id, 2);
  28. }
  29. /**
  30. * 设置主账户
  31. *
  32. * @return mixed
  33. */
  34. public function config($id, $name, $param)
  35. {
  36. Dever::config('base')->hook = true;
  37. $type = Dever::param('type', $param);
  38. if ($type == 1) {
  39. Dever::db('account/config')->updates(array('option_type' => 1, 'set_type' => 2));
  40. Dever::db('account/config')->update(array('where_id' => $id, 'type' => 1));
  41. }
  42. }
  43. public function getSearch($config_id)
  44. {
  45. $result = '';
  46. $info = Dever::db('account/config')->find($config_id);
  47. if ($info) {
  48. $project = Dever::db('account/config_project')->find($info['project_id']);
  49. $result = array
  50. (
  51. 'api' => $project['source'] . '-all',
  52. 'col' => $project['source_name'],
  53. 'result' => 'id',
  54. 'search' => 'uid',
  55. 'project_name' => $project['name'],
  56. 'name' => $info['name'],
  57. );
  58. }
  59. return $result;
  60. }
  61. # 获取钱包信息
  62. public function getInfo($uid, $account)
  63. {
  64. if (!$account) {
  65. return '无账户信息';
  66. }
  67. $config = Dever::db('account/config')->getData(array('ids' => $account));
  68. $table = array();
  69. $table['head'] = array('账户名称', '余额', '总获取金额', '总消耗金额');
  70. $table['body'] = array();
  71. if ($config) {
  72. foreach ($config as $k => $v) {
  73. $info = Dever::db('account/info')->find(array('uid' => $uid, 'config_id' => $v['id']));
  74. if ($info) {
  75. $table['body'][$k] = array
  76. (
  77. $v['name'], $info['cash'], $info['z_cash'], $info['t_cash']
  78. );
  79. }
  80. }
  81. }
  82. $body[''] = array
  83. (
  84. 'type' => 'table',
  85. 'content' => $table,
  86. );
  87. if ($table['body']) {
  88. return Dever::show('', $body);
  89. } else {
  90. return '无账户信息';
  91. }
  92. }
  93. # 获取日志记录
  94. public function getLog($order_table, $order_id)
  95. {
  96. $log = Dever::load('account/lib/log')->getListBySource($source, $source_id);
  97. if ($log) {
  98. $content['head'] = array('用户名称', '账户名称', '交易类型', '金额', '操作后余额', '资金说明', '交易时间');
  99. $content['body'] = array();
  100. foreach ($log as $k => $v) {
  101. $detail = array();
  102. $detail[] = $v['username'];
  103. $detail[] = $v['config_name'];
  104. $detail[] = $v['type_name'];
  105. $detail[] = $v['cash'];
  106. $detail[] = $v['yue'];
  107. $detail[] = $v['desc'];
  108. $detail[] = $v['cdate'];
  109. $content['body'][] = $detail;
  110. }
  111. return array
  112. (
  113. 'type' => 'table',
  114. 'content' => $content,
  115. );
  116. }
  117. return array();
  118. }
  119. # 资金审核
  120. public function audit($id, $name, $data)
  121. {
  122. Dever::config('base')->hook = true;
  123. $audit = Dever::param('audit_status', $data);
  124. if ($audit > 1) {
  125. $list = Dever::mul($id);
  126. foreach ($list as $k => $v) {
  127. if (is_array($v)) {
  128. $id = $v['id'];
  129. $info = Dever::db('account/info_log')->find(array('id' => $id, 'clear' => true));
  130. } else {
  131. $id = $v;
  132. $info = Dever::db('account/info_log')->find(array('id' => $id, 'clear' => true));
  133. }
  134. if ($info['status'] != 1) {
  135. continue;
  136. }
  137. # 已作废
  138. if ($audit == 4) {
  139. $update = array();
  140. $update['where_id'] = $info['info_id'];
  141. $update['set_cash'] = $info['cash'];
  142. $update['set_col'] = $info['cash'];
  143. Dever::db('account/info')->inc($update);
  144. }
  145. $update = array('where_id' => $id, 'status' => $audit, 'audit_date' => time());
  146. $admin = Dever::load('manage/auth.data');
  147. $update['audit_admin'] = $admin['id'];
  148. Dever::db('account/info_log')->update($update);
  149. }
  150. }
  151. }
  152. }