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

53 lines
1.3 KiB

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