This commit is contained in:
		
							parent
							
								
									1788b590ae
								
							
						
					
					
						commit
						07d82d25da
					
				@ -4,8 +4,10 @@
 | 
			
		||||
 | 
			
		||||
use App\Mail\HelloMail;
 | 
			
		||||
use App\Notifications\HelloNotification;
 | 
			
		||||
use BYDAuto\Models\Activity;
 | 
			
		||||
use BYDAuto\Models\Contact;
 | 
			
		||||
use BYDAuto\Models\Testdrive;
 | 
			
		||||
use BYDAuto\Notifications\TestdirveNotification;
 | 
			
		||||
use Illuminate\Console\Command;
 | 
			
		||||
use Illuminate\Notifications\Messages\MailMessage;
 | 
			
		||||
use Illuminate\Support\Facades\Mail;
 | 
			
		||||
@ -42,6 +44,35 @@ public function action_init()
 | 
			
		||||
        $this->call('migrate');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // 同步试驾数据给到经销商联系人 按顺序每个联系人分配一个试驾数据
 | 
			
		||||
    public function action_push2contact()
 | 
			
		||||
    {
 | 
			
		||||
        $items = Testdrive::query()
 | 
			
		||||
            ->whereNotNull('source')
 | 
			
		||||
            ->where('status', Testdrive::STATUS_DRAFT)
 | 
			
		||||
            ->get();
 | 
			
		||||
 | 
			
		||||
        $contacts = Contact::query()->where('status', Contact::STATUS_PUBLISHED)->get();
 | 
			
		||||
        $count = $contacts->count();
 | 
			
		||||
        $offset = cache()->get('push2contact:offset', 0);
 | 
			
		||||
        foreach ($items as $item) {
 | 
			
		||||
            $contact = $contacts[$offset];
 | 
			
		||||
            // $contact->notify(new TestdirveNotification($item));
 | 
			
		||||
            // $item->update(['status' => Testdrive::STATUS_PUBLISHED]);
 | 
			
		||||
            Activity::create([
 | 
			
		||||
                'name' => '试驾通知(测试)',
 | 
			
		||||
                'content' => ['testdrive' => $item->id, 'contact' => $contact->id],
 | 
			
		||||
                'related_id' => $contact->id,
 | 
			
		||||
                'related_type' => Contact::class
 | 
			
		||||
            ]);
 | 
			
		||||
            $this->info("分配试驾数据 {$item->id} 给联系人 {$contact->id}");
 | 
			
		||||
            $offset = ($offset + 1) % $count;
 | 
			
		||||
        }
 | 
			
		||||
        cache()->forever('push2contact:offset', $offset);
 | 
			
		||||
 | 
			
		||||
        return Command::SUCCESS;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function action_testdrive()
 | 
			
		||||
    {
 | 
			
		||||
        $items = Testdrive::query()->orderBy('id', 'desc')->get();
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user