Browse Source

you2 stats

zz 6 years ago
parent
commit
3ef0eadff3
1 changed files with 45 additions and 1 deletions
  1. 45 1
      app/Console/Commands/BookTest.php

+ 45 - 1
app/Console/Commands/BookTest.php

@@ -3,6 +3,8 @@
 namespace App\Console\Commands;
 
 use App\Modules\Book\Services\BookSubscribleChapterService;
+use App\Modules\Subscribe\Services\ChapterOrderService;
+use App\Modules\YunQi\Models\BookUser;
 use GuzzleHttp\Client;
 use Illuminate\Console\Command;
 
@@ -18,6 +20,7 @@ use App\Jobs\SendStatisticsList;
 use App\Modules\OfficialAccount\Models\ForceSubscribeUsers;
 use App\Modules\User\Services\UserSignService;
 use App\Modules\Book\Models\BookUvStat;
+use App\Modules\Subscribe\Models\ChapterOrder;
 
 class BookTest extends Command
 {
@@ -59,7 +62,8 @@ class BookTest extends Command
         //$this->testTest();
         //$this->activity();
         //$this->testBookSmartPushStats();
-        $this->sendOrderStats105();
+        //$this->sendOrderStats105();
+        $this->you2();
     }
 
 
@@ -311,4 +315,44 @@ class BookTest extends Command
             }
         }
     }
+
+    private function you2(){
+        $result = [];
+        $info = BookUser::where('bid','>',0)->select('bid','uid','type','updated_at')->get();
+        foreach ($info as $item){
+            $bid_price = Order::where('uid',$item->uid)
+                ->where('status','PAID')
+                ->where('created_at','>=',$item->updated_at)
+                ->where('from_bid',$item->bid)
+                ->sum('price');
+            $chapter_model = new ChapterOrder();
+            $chapter_model->setCurrentTable($item->uid);
+            $chapter_fee = $chapter_model->where('uid', $item->uid)
+                ->where('bid', $item->bid)
+                ->where('created_at','>=',$item->updated_at)
+                ->sum('fee');
+            $result[] = [
+                'type'=>$item->type,
+                'amount'=>$bid_price?$bid_price:0,
+                'fee'=>$chapter_fee?$chapter_fee:0,
+                'bid'=>$item->bid
+            ];
+        }
+
+        $str = "图书id,类型,订阅书币,充值\r\n";
+        $str = mb_convert_encoding($str, 'gbk');
+        $file_name = date('Y-m-d') . '-you2.csv';
+        file_put_contents($file_name, $str);
+        $temp = '';
+        foreach ($result as $val) {
+            if($val['type'] == 'GROUP_1'){
+                $type = 'GROUP_1';
+            }else{
+                $type = 'GROUP_2';
+            }
+            $temp .= "{$val['bid']},{$type},{$val['fee']},{$val['amount']}\r\n";
+        }
+        file_put_contents($file_name, $temp, FILE_APPEND);
+    }
+
 }