瀏覽代碼

yunqi test

zz 6 年之前
父節點
當前提交
b50a125cdd
共有 1 個文件被更改,包括 16 次插入4 次删除
  1. 16 4
      app/Console/Commands/BookTest.php

+ 16 - 4
app/Console/Commands/BookTest.php

@@ -357,17 +357,29 @@ class BookTest extends Command
                 ->sum('price');
             $chapter_model = new ChapterOrder();
             $chapter_model->setCurrentTable($item->uid);
-            $all_fee = $chapter_model->where('uid', $item->uid)
+            $all = $chapter_model->where('uid', $item->uid)
                 ->where('created_at','>=',$item->updated_at)
-                ->sum('fee');
+                ->groupBy('bid')
+                ->select(DB::raw('sum(fee) as fee'),'bid','book_name')
+                ->orderBy('fee','desc')
+                ->first();
+            $all_fee = 0;
+            $bid = 0;
+            $book_name = '';
+            if($all){
+                $all_fee = $all->fee;
+                $bid = $all->bid;
+                $book_name = $all->book_name;
+            }
             $result[] = [
                 'uid'=>$item->uid,
                 'type'=>$item->type,
                 'amount'=>0,
                 'fee'=>0,
-                'bid'=>$item->bid,
+                'bid'=>$bid,
                 'all_price'=>$all_price?$all_price:0,
-                'all_fee'=>$all_fee?$all_fee:0
+                'all_fee'=>$all_fee?$all_fee:0,
+                'book_name'=>$book_name
             ];
         }