Rewardcollect.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. use think\Controller;
  5. class Rewardcollect extends Backend{
  6. protected $admin_id;
  7. protected $type = 1; //type=1自身 ,type=2 渠道商下属,type=3 代理商下属
  8. protected $adminInfo;
  9. public function _initialize()
  10. {
  11. parent::_initialize();
  12. $this->admin_id = $this->auth->id;
  13. if(!empty($this->request->get('aid'))){ //渠道商查看某个代理商
  14. $this->admin_id = $this->request->get('aid');
  15. $this->type = 2;
  16. }
  17. if(!empty($this->request->get('caid'))){
  18. $this->admin_id = $this->request->get('caid');
  19. $this->type = 3;
  20. }
  21. $this->adminInfo = model('admin')->where(['id'=>intval($this->admin_id)])->find();
  22. $this->assign('nickname',$this->adminInfo->nickname);
  23. $this->assign('type',$this->type);
  24. }
  25. //赏金统计
  26. public function recollect(){
  27. $today = date('Ymd',time());
  28. $rewardModel = model('RewardCollect');
  29. $res = null;
  30. $resAll = null;
  31. $resToday = null;
  32. if($this->type==3){ //单个被邀请人统计
  33. $condition=[
  34. 'admin_id'=>$this->admin_id,
  35. 'type'=>'1',
  36. 'flag'=>'1'
  37. ];
  38. $conditionAll = [
  39. 'admin_id'=>$this->admin_id,
  40. 'type'=>'2',
  41. 'flag'=>'1'
  42. ];
  43. $conditionToday=[
  44. 'admin_id'=>$this->admin_id,
  45. 'createdate'=>$today,
  46. 'type'=>'1',
  47. 'flag'=>'1'
  48. ];
  49. $resToday = $rewardModel->where($conditionToday)->find();
  50. $resAll = $rewardModel->where($conditionAll)->find();
  51. $res = $rewardModel->where($condition)->paginate(10);
  52. }else{ //单个邀请人
  53. $condition=[
  54. 'invite_id'=>0,
  55. 'admin_id'=>$this->admin_id,
  56. 'type'=>'1',
  57. 'flag'=>'2'
  58. ];
  59. $conditionAll = [
  60. 'invite_id'=>0,
  61. 'admin_id'=>$this->admin_id,
  62. 'type'=>'2',
  63. 'flag'=>'2'
  64. ];
  65. $conditionToday=[
  66. 'invite_id'=>0,
  67. 'admin_id'=>$this->admin_id,
  68. 'createdate'=>$today,
  69. 'type'=>'1',
  70. 'flag'=>'2'
  71. ];
  72. $resToday = $rewardModel->where($conditionToday)->find();
  73. $resAll = $rewardModel->where($conditionAll)->find();
  74. $res = $rewardModel->where($condition)->paginate(10);
  75. }
  76. $this->assign('resToday',$resToday);
  77. $this->assign('resAll',$resAll);
  78. $this->assign('res',$res);
  79. return $this->fetch();
  80. }
  81. }