EcardUser.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
  4. * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
  5. * @author pillar<ltmn@qq.com>
  6. * 行业分类
  7. */
  8. namespace app\allwin\controller;
  9. use app\allwin\model\AllwinEcardOrder;
  10. use app\allwin\model\AllwinEcardUser;
  11. use think\facade\Request;
  12. use think\helper\Time;
  13. class EcardUser extends Common{
  14. public function initialize() {
  15. parent::initialize();
  16. $this->assign('pathMaps', [['name'=>'账号余额','url'=>url("ecard_user/index")]]);
  17. }
  18. /**
  19. * 列表
  20. */
  21. public function index(int $types = 0){
  22. $keyword = $this->request->param('keyword');
  23. $condition = [];
  24. $condition[] = ['AllwinEcardUser.member_miniapp_id','=',$this->member_miniapp_id];
  25. $condition[] = ['is_del', '=',$types];
  26. $time = Request::param('time/d',0);
  27. $starttime = Request::param('starttime/s');
  28. $endtime = Request::param('endtime/s');
  29. if ($time) {
  30. switch ($time) {
  31. case 2:
  32. list($start, $end) = Time::yesterday();
  33. break;
  34. case 30:
  35. list($start, $end) = Time::month();
  36. break;
  37. case 60:
  38. list($start, $end) = Time::lastMonth();
  39. break;
  40. default:
  41. list($start, $end) = Time::today();
  42. break;
  43. }
  44. $condition[] = ['AllwinEcardUser.create_time', '>=', $start];
  45. $condition[] = ['AllwinEcardUser.create_time', '<=', $end];
  46. } else {
  47. if ($starttime) {
  48. $condition[] = ['AllwinEcardUser.create_time', '>=', strtotime($starttime)];
  49. }
  50. if ($endtime) {
  51. $condition[] = ['AllwinEcardUser.create_time', '<=', strtotime($endtime)];
  52. }
  53. }
  54. $view['lists'] = AllwinEcardUser::hasWhere('user', function($query) use($keyword) {
  55. if($keyword){
  56. $query->where('phone_uid|nickname', 'like', '%'.$keyword.'%', 'or');
  57. }
  58. })->where($condition)->order('id desc')->paginate(20);
  59. $view['normal'] = AllwinEcardUser::where($this->mini_program)->where(['is_del' => 0])->count();
  60. $view['delete'] = AllwinEcardUser::where($this->mini_program)->where(['is_del' => 1])->count();
  61. $view['invalid'] = AllwinEcardUser::where($this->mini_program)->where(['is_del' => 2])->count();
  62. $view['types'] = $types;
  63. $view['time'] = $time;
  64. $view['starttime'] = $starttime;
  65. $view['endtime'] = $endtime;
  66. $view['keyword'] = $keyword;
  67. return view()->assign($view);
  68. }
  69. //订单列表
  70. public function order(){
  71. $uid = $this->request->param('uid');
  72. $view['lists'] = AllwinEcardOrder::where(['member_miniapp_id' => $this->member_miniapp_id,'uid' => $uid])->order('id desc')->paginate(20);
  73. return view()->assign($view);
  74. }
  75. }