Profit.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace Account\Src;
  3. use Dever;
  4. use User\Lib\Core;
  5. class Profit extends Core
  6. {
  7. public function getHome()
  8. {
  9. $data['account'] = Dever::load('account/lib/info')->getInfo($this->uid);
  10. $data['list'] = Dever::db('account/config_profit')->select(array('config_id' => $data['account']['config_id']));
  11. $data['total'] = 0;
  12. if ($data['list']) {
  13. foreach ($data['list'] as $k => $v) {
  14. $profit = Dever::db('account/profit')->one(array('uid' => $this->uid, 'config_profit_id' => $v['id']));
  15. if ($profit) {
  16. $data['total'] += $profit['cash'];
  17. }
  18. }
  19. }
  20. $data['total'] = Dever::number($data['total']);
  21. return $data;
  22. }
  23. public function getList()
  24. {
  25. $id = Dever::input('id');
  26. if (!$id) {
  27. Dever::alert('收益错误');
  28. }
  29. $account = Dever::load('account/lib/info')->getInfo($this->uid);
  30. $data['info'] = Dever::load('account/lib/profit')->get($this->uid, $id, $account['config_id'], $account['project_id']);
  31. $data['list'] = Dever::load('account/lib/profit')->getList($this->uid, $data['info']['id']);
  32. return $data;
  33. }
  34. public function getView()
  35. {
  36. $id = Dever::input('id');
  37. $id = Dever::input('id');
  38. if (!$id) {
  39. Dever::alert('收益错误');
  40. }
  41. return Dever::load('account/lib/profit')->getInfo($id);
  42. }
  43. public function test()
  44. {
  45. # 插入一个收益记录
  46. //Dever::load('account/lib/profit.up_commit', $this->uid, 100, 'zhitui', 'type', 1, 'xxx订单记录', 1, 'test');
  47. # 结算5块钱
  48. Dever::load('account/lib/profit.up_commit', $this->uid, 100, 'zhitui', 1, 'type', 5, 'xxx订单记录', 'test');
  49. return 'ok';
  50. }
  51. }