海南旅游SAAS
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

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Providers;
  3. use App\Models\Demand;
  4. use App\Models\DemandBidding;
  5. use App\Service\SmsService;
  6. use App\Traits\SmsTraits;
  7. use Illuminate\Support\ServiceProvider;
  8. class DemandBiddingServiceProvider extends ServiceProvider
  9. {
  10. /**
  11. * Register services.
  12. *
  13. * @return void
  14. */
  15. public function register()
  16. {
  17. //
  18. }
  19. /**
  20. * Bootstrap services.
  21. *
  22. * @return void
  23. */
  24. public function boot()
  25. {
  26. DemandBidding::created(function ($order) {
  27. if(env('SMS_SWITCH','') == true){
  28. $demand = Demand::query()->with(['publisher'])->where('id', $order->demand_id)->first();
  29. if (!empty($demand->publisher->contact_mobile)) {
  30. $sms = new SmsService();
  31. $sms->send('bidding', [$order->biddingUser->name, $demand->id, SmsTraits::$systeaNameText['agent']], [$demand->publisher->contact_mobile]);
  32. }
  33. }
  34. });
  35. Demand::updated(function ($demand) {
  36. //如果状态改变了
  37. if(env('SMS_SWITCH' , '') == true && $demand->isDirty('bidding_id')) {
  38. if(!empty($demand->publisher->contact_mobile)) {
  39. $sms = new SmsService();
  40. $sms->send('demand',[$demand->id,SmsTraits::$systeaNameText['supplier']],[$demand->biddingUser->contact_mobile]);
  41. }
  42. }
  43. });
  44. }
  45. }