You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							51 lines
						
					
					
						
							1.2 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							51 lines
						
					
					
						
							1.2 KiB
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								namespace App\Providers;
							 | 
						|
								
							 | 
						|
								use App\Models\Demand;
							 | 
						|
								use App\Models\DemandBidding;
							 | 
						|
								use App\Service\SmsService;
							 | 
						|
								use App\Traits\SmsTraits;
							 | 
						|
								use Illuminate\Support\ServiceProvider;
							 | 
						|
								
							 | 
						|
								class DemandBiddingServiceProvider extends ServiceProvider
							 | 
						|
								{
							 | 
						|
								    /**
							 | 
						|
								     * Register services.
							 | 
						|
								     *
							 | 
						|
								     * @return void
							 | 
						|
								     */
							 | 
						|
								    public function register()
							 | 
						|
								    {
							 | 
						|
								        //
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     * Bootstrap services.
							 | 
						|
								     *
							 | 
						|
								     * @return void
							 | 
						|
								     */
							 | 
						|
								    public function boot()
							 | 
						|
								    {
							 | 
						|
										DemandBidding::created(function ($order) {
							 | 
						|
											if(env('SMS_SWITCH','') == true){
							 | 
						|
												$demand = Demand::query()->with(['publisher'])->where('id', $order->demand_id)->first();
							 | 
						|
												if (!empty($demand->publisher->contact_mobile)) {
							 | 
						|
													$sms = new SmsService();
							 | 
						|
													$sms->send('bidding', [$order->biddingUser->name, $demand->id, SmsTraits::$systeaNameText['agent']], [$demand->publisher->contact_mobile]);
							 | 
						|
												}
							 | 
						|
											}
							 | 
						|
										});
							 | 
						|
								
							 | 
						|
								
							 | 
						|
										Demand::updated(function ($demand) {
							 | 
						|
											//如果状态改变了
							 | 
						|
											if(env('SMS_SWITCH' , '') == true && $demand->isDirty('bidding_id')) {
							 | 
						|
												if(!empty($demand->publisher->contact_mobile)) {
							 | 
						|
													$sms = new SmsService();
							 | 
						|
													$sms->send('demand',[$demand->id,SmsTraits::$systeaNameText['supplier']],[$demand->biddingUser->contact_mobile]);
							 | 
						|
												}
							 | 
						|
											}
							 | 
						|
										});
							 | 
						|
								    }
							 | 
						|
								}
							 |