UnpaidOrderSend.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\jobs\order;
  12. use app\services\order\StoreOrderServices;
  13. use crmeb\basic\BaseJobs;
  14. use crmeb\traits\QueueTrait;
  15. use think\facade\Log;
  16. /**
  17. * 未支付订单10分钟后发送短信
  18. * Class UnpaidOrderSend
  19. * @package app\jobs
  20. */
  21. class UnpaidOrderSend extends BaseJobs
  22. {
  23. use QueueTrait;
  24. /**
  25. * @param $id
  26. * @return bool
  27. */
  28. public function doJob($id)
  29. {
  30. try {
  31. /** @var StoreOrderServices $services */
  32. $services = app()->make(StoreOrderServices::class);
  33. $orderInfo = $services->get($id);
  34. if (!$orderInfo) {
  35. return true;
  36. }
  37. if ($orderInfo->paid) {
  38. return true;
  39. }
  40. if ($orderInfo->is_del) {
  41. return true;
  42. }
  43. //未支付用户发送消息
  44. event('notice.notice', [['order' => $orderInfo], 'order_pay_false']);
  45. } catch (\Throwable $e) {
  46. Log::error('未支付订单发送短信失败,原因:' . $e->getMessage());
  47. }
  48. return true;
  49. }
  50. }