OrderTakeJob.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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\StoreOrderStatusServices;
  13. use app\services\order\StoreOrderTakeServices;
  14. use crmeb\basic\BaseJobs;
  15. use crmeb\traits\QueueTrait;
  16. use think\facade\Log;
  17. /**
  18. * 订单收货任务
  19. * Class OrderTakeJob
  20. * @package app\jobs
  21. */
  22. class OrderTakeJob extends BaseJobs
  23. {
  24. use QueueTrait;
  25. /**
  26. * @return string
  27. */
  28. protected static function queueName()
  29. {
  30. return 'CRMEB_PRO_TASK';
  31. }
  32. public function doJob($order)
  33. {
  34. if (!$order) return true;
  35. /** @var StoreOrderTakeServices $service */
  36. $service = app()->make(StoreOrderTakeServices::class);
  37. /** @var StoreOrderStatusServices $statusService */
  38. $statusService = app()->make(StoreOrderStatusServices::class);
  39. $res = $service->update($order['id'], ['status' => 2]) && $statusService->save([
  40. 'oid' => $order['id'],
  41. 'change_type' => 'user_take_delivery',
  42. 'change_message' => '用户已收货',
  43. 'change_time' => time()
  44. ]);
  45. $order = $service->get((int)$order['id']);
  46. $res = $res && $service->storeProductOrderUserTakeDelivery($order);
  47. if (!$res) {
  48. Log::error('收货失败:' . $order['order_id']);
  49. }
  50. return true;
  51. }
  52. }