|
@@ -4,6 +4,7 @@ namespace App\Console\Commands;
|
|
|
|
|
|
use App\Modules\Book\Services\BookSubscribleChapterService;
|
|
|
use App\Modules\Subscribe\Services\ChapterOrderService;
|
|
|
+use App\Modules\User\Services\ReadRecordService;
|
|
|
use App\Modules\YunQi\Models\BookUser;
|
|
|
use App\Modules\YunQi\Models\YqUserBidRelation;
|
|
|
use App\Modules\YunQi\Models\YqZsyTest;
|
|
@@ -66,7 +67,8 @@ class BookTest extends Command
|
|
|
//$this->activity();
|
|
|
//$this->testBookSmartPushStats();
|
|
|
//$this->sendOrderStats105();
|
|
|
- $this->you2();
|
|
|
+ //$this->you2();
|
|
|
+ $this->transfromUserOrder();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -406,4 +408,109 @@ class BookTest extends Command
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private function transfromUserOrder(){
|
|
|
+ $user = DB::table('users')
|
|
|
+ ->where('distribution_channel_id',4815)
|
|
|
+ ->where('created_at','>=','2019-01-31 11:12:00')
|
|
|
+ ->select('openid','id')
|
|
|
+ ->get();
|
|
|
+ $chapter_model = new ChapterOrder();
|
|
|
+ foreach ($user as $v){
|
|
|
+ Log::info('now user is :');
|
|
|
+ Log::info('openid is: '.$v->openid.',old uid is :'.$v->id);
|
|
|
+ $froce_user = DB::table('force_subscribe_users')
|
|
|
+ ->where('openid',$v->openid)
|
|
|
+ ->where('distribution_channel_id',384)
|
|
|
+ ->select('uid')
|
|
|
+ ->first();
|
|
|
+ Log::info('$froce_user user is :');
|
|
|
+ Log::info('$froce_user is: '.$froce_user->uid);
|
|
|
+ if($froce_user && $froce_user->uid != $v->id){
|
|
|
+ $chapter_model->setCurrentTable($froce_user->uid);
|
|
|
+ $data = [];
|
|
|
+ //章节订购
|
|
|
+ $chapter_order_info = $chapter_model->where('uid',$froce_user->uid)->get();
|
|
|
+ Log::info('$chapter_order_info user is :');
|
|
|
+ Log::info($chapter_order_info);
|
|
|
+ if($chapter_order_info){
|
|
|
+ foreach ($chapter_order_info as $chapter_order_item){
|
|
|
+ $data[] = [
|
|
|
+ 'distribution_channel_id'=>4815,
|
|
|
+ 'bid'=>$chapter_order_item->bid,
|
|
|
+ 'cid'=>$chapter_order_item->cid,
|
|
|
+ 'chapter_name'=>$chapter_order_item->chapter_name,
|
|
|
+ 'book_name'=>$chapter_order_item->book_name,
|
|
|
+ 'uid'=>$v->id,
|
|
|
+ 'send_order_id'=>0,
|
|
|
+ 'fee'=>0,
|
|
|
+ 'created_at'=>$chapter_order_item->created_at,
|
|
|
+ 'updated_at'=>date('Y-m-d H:i:s'),
|
|
|
+ 'charge_balance'=>0,
|
|
|
+ 'reward_balance'=>0
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if($data){
|
|
|
+ Log::info('$chapter_order_info user $data is :');
|
|
|
+ Log::info($data);
|
|
|
+ $chapter_model->setCurrentTable($v->id);
|
|
|
+ $chapter_model->insert($data);
|
|
|
+ }
|
|
|
+
|
|
|
+ //单本订购
|
|
|
+ if($froce_user && $froce_user->uid != $v->id){
|
|
|
+ $book_order_data = [];
|
|
|
+ $book_orders = DB::table('book_orders')->where('uid',$froce_user->uid)->get();
|
|
|
+ Log::info('$book_orders user is :');
|
|
|
+ if($book_orders){
|
|
|
+ foreach ($book_orders as $book_order_item){
|
|
|
+ $book_order_data[] = [
|
|
|
+ 'uid'=>$v->id,
|
|
|
+ 'distribution_channel_id'=>4815,
|
|
|
+ 'bid'=>$book_order_item->bid,
|
|
|
+ 'book_name'=>$book_order_item->book_name,
|
|
|
+ 'u'=>$book_order_item->u,
|
|
|
+ 'send_order_id'=>0,
|
|
|
+ 'charge_balance'=>0,
|
|
|
+ 'reward_balance'=>0,
|
|
|
+ 'fee'=>0,
|
|
|
+ 'created_at'=>$book_order_item->created_at,
|
|
|
+ 'updated_at'=>date('Y-m-d H:i:s'),
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if($book_order_data){
|
|
|
+ Log::info('$book_order_data user is :');
|
|
|
+ Log::info($book_order_data);
|
|
|
+ DB::table('book_orders')->insert($book_order_data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //阅读记录
|
|
|
+ $read_bids = Redis::hgetall('book_read:' . $froce_user->uid);
|
|
|
+
|
|
|
+ Log::info('$read_bids is :');
|
|
|
+ Log::info($read_bids);
|
|
|
+
|
|
|
+ if ($read_bids){
|
|
|
+ foreach ($read_bids as $key=>$field){
|
|
|
+ Redis::hset('book_read:' . $v->id,$key,$field);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //用户信息
|
|
|
+ $old_user = DB::table('users')->where('id', $froce_user->uid)->first();
|
|
|
+ if($old_user){
|
|
|
+ DB::table('users')->where('id',$v->id)->update([
|
|
|
+ 'balance'=>$old_user->balance,
|
|
|
+ 'charge_balance'=>$old_user->charge_balance,
|
|
|
+ 'reward_balance'=>$old_user->reward_balance,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|