SmsAdminJob.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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\notice;
  12. use app\services\message\sms\SmsSendServices;
  13. use crmeb\basic\BaseJobs;
  14. use crmeb\traits\QueueTrait;
  15. use think\facade\Log;
  16. /**
  17. * 短信通知管理员
  18. * Class SmsAdminJob
  19. * @package app\jobs
  20. */
  21. class SmsAdminJob extends BaseJobs
  22. {
  23. use QueueTrait;
  24. /**
  25. * 退款发送管理员消息任务
  26. * @param $switch
  27. * @param $adminList
  28. * @param $order
  29. * @return bool
  30. */
  31. public function sendAdminRefund($switch, $adminList, $order)
  32. {
  33. if (!$switch) {
  34. return true;
  35. }
  36. try {
  37. /** @var SmsSendServices $smsServices */
  38. $smsServices = app()->make(SmsSendServices::class);
  39. foreach ($adminList as $item) {
  40. $data = ['order_id' => $order['order_id'], 'admin_name' => $item['nickname']];
  41. $smsServices->send(true, $item['phone'], $data, 'ADMIN_RETURN_GOODS_CODE');
  42. }
  43. } catch (\Throwable $e) {
  44. Log::error('退款发送管理员消息失败,原因:' . $e->getMessage());
  45. }
  46. return true;
  47. }
  48. /**
  49. * 用户确认收货管理员短信提醒
  50. * @param $switch
  51. * @param $adminList
  52. * @param $order
  53. * @return bool
  54. */
  55. public function sendAdminConfirmTakeOver($switch, $adminList, $order)
  56. {
  57. if (!$switch) {
  58. return true;
  59. }
  60. try {
  61. /** @var SmsSendServices $smsServices */
  62. $smsServices = app()->make(SmsSendServices::class);
  63. foreach ($adminList as $item) {
  64. $data = ['order_id' => $order['order_id'], 'admin_name' => $item['nickname']];
  65. $smsServices->send(true, $item['phone'], $data, 'ADMIN_TAKE_DELIVERY_CODE');
  66. }
  67. } catch (\Throwable $e) {
  68. Log::error('用户确认收货管理员短信提醒失败,原因:' . $e->getMessage());
  69. }
  70. return true;
  71. }
  72. /**
  73. * 下单成功给客服管理员发送短信
  74. * @param $switch
  75. * @param $adminList
  76. * @param $order
  77. * @return bool
  78. */
  79. public function sendAdminPaySuccess($switch, $adminList, $order)
  80. {
  81. if (!$switch) {
  82. return true;
  83. }
  84. /** @var SmsSendServices $smsServices */
  85. $smsServices = app()->make(SmsSendServices::class);
  86. foreach ($adminList as $item) {
  87. $data = ['order_id' => $order['order_id'], 'admin_name' => $item['nickname']];
  88. $smsServices->send(true, $item['phone'], $data, 'ADMIN_PAY_SUCCESS_CODE');
  89. }
  90. return true;
  91. }
  92. }