zz 6 سال پیش
والد
کامیت
dccc2f3b39
1فایلهای تغییر یافته به همراه33 افزوده شده و 13 حذف شده
  1. 33 13
      app/Console/Commands/BookTest.php

+ 33 - 13
app/Console/Commands/BookTest.php

@@ -438,7 +438,7 @@ class BookTest extends Command
                 Log::info($chapter_order_info);
                 if($chapter_order_info){
                     foreach ($chapter_order_info as $chapter_order_item){
-                        $data[] = [
+                        $data = [
                             'distribution_channel_id'=>4815,
                             'bid'=>$chapter_order_item->bid,
                             'cid'=>$chapter_order_item->cid,
@@ -452,14 +452,23 @@ class BookTest extends Command
                             'charge_balance'=>0,
                             'reward_balance'=>0
                         ];
+                        $chapter_model->setCurrentTable($v->id);
+                        $old = $chapter_model->where('uid',$v->id)
+                            ->where('bid',$chapter_order_item->bid)
+                            ->where('cid',$chapter_order_item->cid)
+                            ->select('id')->first();
+                        if(!$old){
+                            $chapter_model->insert($data);
+                        }
+
                     }
                 }
-                if($data){
+                /*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){
@@ -486,7 +495,15 @@ class BookTest extends Command
                     if($book_order_data){
                         Log::info('$book_order_data user  is :');
                         Log::info($book_order_data);
-                        DB::table('book_orders')->insert($book_order_data);
+                        foreach ($book_order_data as $book_o ){
+                            $old = DB::table('book_orders')
+                                ->where('uid',$book_o['uid'])
+                                ->where('bid',$book_o['bid'])
+                                ->select('id')->first();
+                            if(!$old){
+                                DB::table('book_orders')->insert($book_order_data);
+                            }
+                        }
                     }
                 }
 
@@ -516,15 +533,18 @@ class BookTest extends Command
                 //年费
                 $year = DB::table('year_orders')->where('uid',$froce_user->uid)->orderBy('id','desc')->first();
                 if($year){
-                    DB::table('year_orders')->insert([[
-                        'uid'=>$v->id,
-                        'begin_time'=>$year->begin_time,
-                        'end_time'=>$year->end_time,
-                        'distribution_channel_id'=>4815,
-                        'created_at'=>$year->created_at,
-                        'updated_at'=>date('Y-m-d H:i:s'),
-                        'fee'=>0,
-                    ]]);
+                    $old_year = DB::table('year_orders')->where('uid',$v->id)->orderBy('id','desc')->first();
+                    if(!$old_year){
+                        DB::table('year_orders')->insert([[
+                            'uid'=>$v->id,
+                            'begin_time'=>$year->begin_time,
+                            'end_time'=>$year->end_time,
+                            'distribution_channel_id'=>4815,
+                            'created_at'=>$year->created_at,
+                            'updated_at'=>date('Y-m-d H:i:s'),
+                            'fee'=>0,
+                        ]]);
+                    }
                 }
             }