作者 郭盛
1 个管道 的构建 通过 耗费 4 秒

修改全部订单

@@ -50,48 +50,131 @@ class OrderDetail extends Backend @@ -50,48 +50,131 @@ class OrderDetail extends Backend
50 return $this->selectpage(); 50 return $this->selectpage();
51 } 51 }
52 list($where, $sort, $order, $offset, $limit) = $this->buildparams(); 52 list($where, $sort, $order, $offset, $limit) = $this->buildparams();
53 - $total = $this->model  
54 - ->with(['user'])  
55 - ->where('user_id',$ids)  
56 - ->where($where)  
57 - ->order($sort, $order)  
58 - ->count();  
59 -  
60 - $list = $this->model  
61 - ->with(['user'])  
62 - ->where('user_id',$ids)  
63 - ->where($where)  
64 - ->order($sort, $order)  
65 - ->limit($offset, $limit)  
66 - ->select();  
67 -  
68 - $list = collection($list)->toArray();  
69 - $type = new \app\admin\model\Pic();  
70 - $video = new \app\admin\model\Video();  
71 - foreach ($list as &$v){  
72 - $type_ids = $type->whereIn('id',$v['pic_id'])->column('title');  
73 - if(!empty($v['video_id'])){  
74 - $a = [];  
75 - $v['video_id'] = unserialize($v['video_id']);  
76 - foreach ($v['video_id'] as &$v1){ 53 +
  54 + $user = Db::name('user')->where('id',$ids)->find();
  55 + if($user['type'] == 1){
  56 + $type = new \app\admin\model\Pic();
  57 + $video = new \app\admin\model\Video();
  58 +
  59 + //以往购买的订单
  60 + $one = Db::name('order')
  61 + ->where('status',2)
  62 + ->where('user_id',$ids)
  63 + ->count();
  64 + $one_info = Db::name('order')
  65 + ->where('status',2)
  66 + ->where('user_id',$ids)
  67 + ->field('createtime,paytime,shou_status,invoice_status',true)
  68 + ->select();
  69 + foreach ($one_info as &$v){
  70 + $type_ids = $type->whereIn('id',$v['pic_id'])->column('title');
  71 + if(!empty($v['video_id'])){
  72 + $a = [];
  73 + $v['video_id'] = unserialize($v['video_id']);
  74 + foreach ($v['video_id'] as &$v1){
  75 + //获取视频标题
  76 + $v1['id'] = $video->where('id',$v1['id'])->column('title');
  77 + //判断视频属性
  78 + if($v1['attr'] == 1){
  79 + $v1['attr'] = '2k';
  80 + }elseif ($v1['attr'] == 2){
  81 + $v1['attr'] = '4k';
  82 + }else{
  83 + $v1['attr'] = '8k';
  84 + }
  85 + array_push($a,$v1['id']);
  86 + }
  87 + $v['video_id'] = $a;
  88 + }
  89 + $v['pic_id'] = trim(implode(',',$type_ids),',');
  90 + }
  91 +
  92 +
  93 +
  94 + //苹果登录后的订单
  95 + $two = Db::name('iphone')
  96 + ->where('status',2)
  97 + ->where('user_id',$ids)
  98 + ->count();
  99 + $two_info = Db::name('iphone')
  100 + ->where('status',2)
  101 + ->where('user_id',$ids)
  102 + ->field('createtime,updatetime',true)
  103 + ->select();
  104 + foreach ($two_info as &$v){
  105 + $type_ids = $type->whereIn('id',$v['pic_id'])->column('title');
  106 + if(!empty($v['video_id'])){
  107 + $a = [];
  108 + $v['video_id'] = unserialize($v['video_id']);
  109 +
77 //获取视频标题 110 //获取视频标题
78 - $v1['id'] = $video->where('id',$v1['id'])->column('title'); 111 + $v['video_id']['id'] = $video->where('id',$v['video_id']['id'])->column('title');
79 //判断视频属性 112 //判断视频属性
80 - if($v1['attr'] == 1){  
81 - $v1['attr'] = '2k';  
82 - }elseif ($v1['attr'] == 2){  
83 - $v1['attr'] = '4k'; 113 + if($v['video_id']['attr'] == 1){
  114 + $v['video_id']['attr'] = '2k';
  115 + }elseif ($v['video_id']['attr'] == 2){
  116 + $v['video_id']['attr'] = '4k';
84 }else{ 117 }else{
85 - $v1['attr'] = '8k'; 118 + $v['video_id']['attr'] = '8k';
86 } 119 }
87 - array_push($a,$v1['id']); 120 + array_push($a,$v['video_id']['id']);
  121 + $v['video_id'] = $a;
88 } 122 }
89 - $v['video_id'] = $a; 123 + $v['pic_id'] = trim(implode(',',$type_ids),',');
90 } 124 }
91 - $v['pic_id'] = trim(implode(',',$type_ids),','); 125 +
  126 +
  127 + $total = $one + $two; //总条数
  128 + $list = array_merge($one_info,$two_info);
  129 +
  130 + $result = array("total" => $total, "rows" => $list);
  131 + return json($result);
  132 + }else{
  133 + $total = $this->model
  134 + ->with(['user'])
  135 + ->where('user_id',$ids)
  136 + ->where($where)
  137 + ->order($sort, $order)
  138 + ->count();
  139 +
  140 + $list = $this->model
  141 + ->with(['user'])
  142 + ->where('user_id',$ids)
  143 + ->where($where)
  144 + ->order($sort, $order)
  145 + ->limit($offset, $limit)
  146 + ->select();
  147 +
  148 + $list = collection($list)->toArray();
  149 + $type = new \app\admin\model\Pic();
  150 + $video = new \app\admin\model\Video();
  151 + foreach ($list as &$v){
  152 + $type_ids = $type->whereIn('id',$v['pic_id'])->column('title');
  153 + if(!empty($v['video_id'])){
  154 + $a = [];
  155 + $v['video_id'] = unserialize($v['video_id']);
  156 + foreach ($v['video_id'] as &$v1){
  157 + //获取视频标题
  158 + $v1['id'] = $video->where('id',$v1['id'])->column('title');
  159 + //判断视频属性
  160 + if($v1['attr'] == 1){
  161 + $v1['attr'] = '2k';
  162 + }elseif ($v1['attr'] == 2){
  163 + $v1['attr'] = '4k';
  164 + }else{
  165 + $v1['attr'] = '8k';
  166 + }
  167 + array_push($a,$v1['id']);
  168 + }
  169 + $v['video_id'] = $a;
  170 + }
  171 + $v['pic_id'] = trim(implode(',',$type_ids),',');
  172 + }
  173 + $result = array("total" => $total, "rows" => $list);
  174 + return json($result);
92 } 175 }
93 - $result = array("total" => $total, "rows" => $list);  
94 - return json($result); 176 +
  177 +
95 } 178 }
96 $this->assignconfig('ids',$ids); 179 $this->assignconfig('ids',$ids);
97 return $this->view->fetch(); 180 return $this->view->fetch();