|
|
|
@ -6,6 +6,7 @@ use App\Models\Demand; |
|
|
|
use App\Models\DemandBidding; |
|
|
|
use App\Service\SmsService; |
|
|
|
use App\Traits\DemandTraits; |
|
|
|
use App\Traits\SmsTraits; |
|
|
|
use Illuminate\Support\Facades\Log; |
|
|
|
use Illuminate\Support\ServiceProvider; |
|
|
|
|
|
|
|
@ -28,23 +29,25 @@ class DemandBiddingServiceProvider extends ServiceProvider |
|
|
|
*/ |
|
|
|
public function boot() |
|
|
|
{ |
|
|
|
//DemandBidding::created(function ($order) {
|
|
|
|
// $demand = Demand::query()->with(['publisher'])->where('id',$order->demand_id)->first();
|
|
|
|
// if(!empty($demand->publisher->contact_phone)) {
|
|
|
|
// $sms = new SmsService();
|
|
|
|
// $sms->send('bidding',[$order->biddingUser->name,$demand->id,DemandTraits::$polymorphic[$demand->publisher_type]],[$demand->publisher->contact_phone]);
|
|
|
|
// }
|
|
|
|
//});
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//Demand::updated(function ($demand) {
|
|
|
|
// //如果状态改变了
|
|
|
|
// if($demand->isDirty('bidding_id')) {
|
|
|
|
// if(!empty($demand->publisher->contact_phone)) {
|
|
|
|
// $sms = new SmsService();
|
|
|
|
// $sms->send('demand',[$demand->publisher->name,$demand->id,DemandTraits::$polymorphic[$demand->bidding_user_type]],[$demand->biddingUser->contact_phone]);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//});
|
|
|
|
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_phone)) { |
|
|
|
$sms = new SmsService(); |
|
|
|
$sms->send('bidding', [$order->biddingUser->name, $demand->id, SmsTraits::$systeaNameText['agent']], [$demand->publisher->contact_phone]); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Demand::updated(function ($demand) { |
|
|
|
//如果状态改变了
|
|
|
|
if(env('SMS_SWITCH' , '') == true && $demand->isDirty('bidding_id')) { |
|
|
|
if(!empty($demand->publisher->contact_phone)) { |
|
|
|
$sms = new SmsService(); |
|
|
|
$sms->send('demand',[$demand->publisher->name,$demand->id,SmsTraits::$systeaNameText['supplier']],[$demand->biddingUser->contact_phone]); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |