Index.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: qisse
  5. * Date: 2017/6/27
  6. * Time: 20:02
  7. */
  8. namespace app\master\logic;
  9. use app\core\exception\AppException;
  10. use app\core\model\Cang as Model;
  11. use app\core\model\CangRepay;
  12. use app\core\model\User;
  13. use app\core\model\Subject;
  14. use app\core\model\Sms;
  15. use app\core\service\Stat;
  16. use think\Db;
  17. use think\Exception;
  18. use think\Log;
  19. use tool\Common;
  20. class Index extends Base
  21. {
  22. public function getCangList() {
  23. $map = [
  24. 'isForged'=>['eq', 0],
  25. /*'status'=>2*/
  26. ];
  27. if( isset($this->app['addTimeTo']) &&
  28. isset($this->app['addTimeFrom'])) {
  29. $map['addTime'] = ['between', [Common::datetotime($this->app['addTimeFrom']),Common::datetotime($this->app['addTimeTo']) + 86400]];
  30. }
  31. if(isset($this->app['status']) && $this->app['status']) {
  32. $map['status'] = $this->app['status'];
  33. }
  34. if(isset($this->app['typeID']) && $this->app['typeID']) {
  35. $map['subject.subjectTypeID'] = $this->app['typeID'];
  36. }
  37. if(isset($this->app['osType']) && $this->app['osType']) {
  38. $map['user.osType'] = $this->app['osType'];
  39. }
  40. if(isset($this->app['channelID']) && $this->app['channelID']) {
  41. $map['user.channelID'] = $this->app['channelID'];
  42. }
  43. if(isset($this->app['keyword']) && $this->app['keyword']) {
  44. $map['mobile|trueName|title'] = ['like', '%'.$this->app['keyword'].'%'];
  45. }
  46. if(!isset($this->app['pageIndex']) || !$this->app['pageIndex']) {
  47. $this->app['pageIndex'] = 1;
  48. }
  49. if(!isset($this->app['pageItemCount']) || !$this->app['pageItemCount']) {
  50. $this->app['pageItemCount'] = 10;
  51. }
  52. $list = Db::view('cang','cangID,subjectID,moneySubject,status,addTime,year,investDay,interest,money,userID,isForged,hongbao,yearExt')
  53. ->view('user','userID,trueName,mobile,channelID,isNewInvest,osType','cang.userID=user.userID')
  54. ->view('subject','subjectID,title','cang.subjectID=subject.subjectID')
  55. ->view('channel','channelID,name as channelName','user.channelID=channel.channelID', 'left')
  56. ->view('master','trueName as customer,masterID,mobile as customerMobile','master.masterID=cang.masterID', 'left')
  57. //->view('user_hongbao','userHongbaoID,sum(money),sum(interest)','cang.hongbao in (user_hongbao.userHongbaoID)', 'left')
  58. ->where($map)
  59. ->order('cangID desc')
  60. ->limit(($this->app['pageIndex'] - 1) * $this->app['pageItemCount'], $this->app['pageItemCount'])
  61. ->select();
  62. foreach ($list as $k=>$item) {
  63. $list[$k]['addTime'] = Common::timetodate($list[$k]['addTime']);
  64. $list[$k]['money'] = Common::price2($list[$k]['money'] / 100);
  65. $list[$k]['moneySubject'] = Common::price2($list[$k]['moneySubject'] / 100);
  66. $list[$k]['interest'] = Common::price2($list[$k]['interest'] / 100);
  67. if($list[$k]['osType'] == 1) {
  68. $list[$k]['osType'] = 'ios';
  69. }
  70. else if($list[$k]['osType'] == 2) {
  71. $list[$k]['osType'] = 'android';
  72. }
  73. else if($list[$k]['osType'] == 3) {
  74. $list[$k]['osType'] = 'pc';
  75. }
  76. else if($list[$k]['osType'] == 4) {
  77. $list[$k]['osType'] = 'wap';
  78. }
  79. $list[$k]['moneyHongbao'] = $list[$k]['moneySubject'] - $list[$k]['money'];
  80. }
  81. //所有表
  82. $listAll = Db::view('cang','cangID,subjectID,moneySubject,status,addTime,year,investDay,interest,money,userID,isForged,hongbao')
  83. ->view('user','userID,trueName,mobile,channelID,isNewInvest,osType','cang.userID=user.userID')
  84. ->view('subject','subjectID,title','cang.subjectID=subject.subjectID')
  85. ->view('channel','channelID,name as channelName','user.channelID=channel.channelID','left')
  86. ->where($map)
  87. ->select();
  88. $moneyTotal_moneySubject = 0;
  89. $moneyTotal_interest = 0;
  90. $moneyTotal_money = 0;
  91. foreach ($listAll as $k=>$item) {
  92. $moneyTotal_moneySubject += $listAll[$k]['moneySubject'];
  93. $moneyTotal_interest += $listAll[$k]['interest'];
  94. $moneyTotal_money += $listAll[$k]['money'];
  95. }
  96. return Common::rm(1, '操作成功', [
  97. 'cangList'=>$list,
  98. 'count'=>count($listAll),
  99. 'pageItemCount'=>$this->app['pageItemCount'],
  100. 'moneyTotal_moneySubject'=>Common::price2($moneyTotal_moneySubject / 100),
  101. 'moneyTotal_interest'=>Common::price2($moneyTotal_interest / 100),
  102. 'moneyTotal_money'=>Common::price2($moneyTotal_money / 100)
  103. ]);
  104. }
  105. public function getStat() {
  106. $stat = Stat::getStat();
  107. return Common::rm(1, '操作成功', [
  108. 'stat'=>$stat
  109. ]);
  110. }
  111. }