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

55 lines
1.4 KiB

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