|
@@ -3,6 +3,8 @@
|
|
namespace App\Console\Commands;
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
use App\Modules\Book\Services\BookSubscribleChapterService;
|
|
use App\Modules\Book\Services\BookSubscribleChapterService;
|
|
|
|
+use App\Modules\Subscribe\Services\ChapterOrderService;
|
|
|
|
+use App\Modules\YunQi\Models\BookUser;
|
|
use GuzzleHttp\Client;
|
|
use GuzzleHttp\Client;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
@@ -18,6 +20,7 @@ use App\Jobs\SendStatisticsList;
|
|
use App\Modules\OfficialAccount\Models\ForceSubscribeUsers;
|
|
use App\Modules\OfficialAccount\Models\ForceSubscribeUsers;
|
|
use App\Modules\User\Services\UserSignService;
|
|
use App\Modules\User\Services\UserSignService;
|
|
use App\Modules\Book\Models\BookUvStat;
|
|
use App\Modules\Book\Models\BookUvStat;
|
|
|
|
+use App\Modules\Subscribe\Models\ChapterOrder;
|
|
|
|
|
|
class BookTest extends Command
|
|
class BookTest extends Command
|
|
{
|
|
{
|
|
@@ -59,7 +62,8 @@ class BookTest extends Command
|
|
//$this->testTest();
|
|
//$this->testTest();
|
|
//$this->activity();
|
|
//$this->activity();
|
|
//$this->testBookSmartPushStats();
|
|
//$this->testBookSmartPushStats();
|
|
- $this->sendOrderStats105();
|
|
|
|
|
|
+ //$this->sendOrderStats105();
|
|
|
|
+ $this->you2();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -311,4 +315,95 @@ class BookTest extends Command
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private function you2(){
|
|
|
|
+ $result = [];
|
|
|
|
+ $info = BookUser::where('bid','>',0)->select('bid','uid','type','updated_at')->get();
|
|
|
|
+ $info2 = BookUser::where('type','GROUP_1')->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');
|
|
|
|
+ $all_price = Order::where('uid',$item->uid)
|
|
|
|
+ ->where('status','PAID')
|
|
|
|
+ ->where('created_at','>=',$item->updated_at)
|
|
|
|
+ ->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');
|
|
|
|
+ $all_fee = $chapter_model->where('uid', $item->uid)
|
|
|
|
+ ->where('created_at','>=',$item->updated_at)
|
|
|
|
+ ->sum('fee');
|
|
|
|
+ $result[] = [
|
|
|
|
+ 'uid'=>$item->uid,
|
|
|
|
+ 'type'=>$item->type,
|
|
|
|
+ 'amount'=>$bid_price?$bid_price:0,
|
|
|
|
+ 'fee'=>$chapter_fee?$chapter_fee:0,
|
|
|
|
+ 'bid'=>$item->bid,
|
|
|
|
+ 'all_price'=>$all_price?$all_price:0,
|
|
|
|
+ 'all_fee'=>$all_fee?$all_fee:0
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ $item = null;
|
|
|
|
+ foreach ($info2 as $item){
|
|
|
|
+ $all_price = Order::where('uid',$item->uid)
|
|
|
|
+ ->where('status','PAID')
|
|
|
|
+ ->where('created_at','>=',$item->updated_at)
|
|
|
|
+ ->sum('price');
|
|
|
|
+ $chapter_model = new ChapterOrder();
|
|
|
|
+ $chapter_model->setCurrentTable($item->uid);
|
|
|
|
+ $all = $chapter_model->where('uid', $item->uid)
|
|
|
|
+ ->where('created_at','>=',$item->updated_at)
|
|
|
|
+ ->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'=>$bid,
|
|
|
|
+ 'all_price'=>$all_price?$all_price:0,
|
|
|
|
+ 'all_fee'=>$all_fee?$all_fee:0,
|
|
|
|
+ 'book_name'=>$book_name
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $str = "图书id,书名,用户类型,用户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) {
|
|
|
|
+ $books = DB::table('book_configs')->where('bid',$val['bid'])->select('book_name')->first();
|
|
|
|
+ if($books){
|
|
|
|
+ $book_name = $books->book_name;
|
|
|
|
+ }else{
|
|
|
|
+ $book_name = 'un';
|
|
|
|
+ }
|
|
|
|
+ if($val['type'] == 'GROUP_1'){
|
|
|
|
+ $type = 'GROUP_1';
|
|
|
|
+ }else{
|
|
|
|
+ $type = 'GROUP_2';
|
|
|
|
+ }
|
|
|
|
+ $t = "{$val['bid']},{$book_name},{$type},{$val['uid']},{$val['fee']},{$val['amount']},{$val['all_price']},{$val['all_fee']}\r\n";
|
|
|
|
+ $temp .= mb_convert_encoding($t, 'gbk');
|
|
|
|
+ }
|
|
|
|
+ file_put_contents($file_name, $temp, FILE_APPEND);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|