SpliteStoreOrderJob.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\jobs\order;
  3. use app\jobs\notice\PrintJob;
  4. use app\jobs\store\StoreFinanceJob;
  5. use app\services\order\StoreOrderCartInfoServices;
  6. use app\services\store\StoreUserServices;
  7. use app\webscoket\SocketPush;
  8. use crmeb\basic\BaseJobs;
  9. use crmeb\traits\QueueTrait;
  10. use think\facade\Log;
  11. /**
  12. * 门店分配订单
  13. * Class SpliteStoreOrderJob
  14. * @package app\jobs
  15. */
  16. class SpliteStoreOrderJob extends BaseJobs
  17. {
  18. use QueueTrait;
  19. /**
  20. * 订单分配完成后置方法
  21. * @param $orderInfo
  22. */
  23. public function splitAfter($orderInfo, bool $only_print = false)
  24. {
  25. //分配好向用户设置标签
  26. OrderJob::dispatchDo('setUserLabel', [$orderInfo]);
  27. //分配门店账单流水
  28. StoreFinanceJob::dispatch([$orderInfo, 1]);
  29. if ($only_print) {
  30. PrintJob::dispatch([(int)$orderInfo['id']]);
  31. } else {
  32. $orderInfoServices = app()->make(StoreOrderCartInfoServices::class);
  33. $storeName = $orderInfoServices->getCarIdByProductTitle((int)$orderInfo['id']);
  34. $orderInfo['storeName'] = substrUTf8($storeName, 20, 'UTF-8', '');
  35. $orderInfo['send_name'] = $orderInfo['real_name'];
  36. //分配完成用户推送消息事件(门店小票打印)
  37. event('notice.notice', [$orderInfo, 'order_pay_success']);
  38. }
  39. if (isset($orderInfo['store_id']) && $orderInfo['store_id']) {
  40. //记录门店用户
  41. /** @var StoreUserServices $storeUserServices */
  42. $storeUserServices = app()->make(StoreUserServices::class);
  43. $storeUserServices->setStoreUser((int)$orderInfo['uid'], (int)$orderInfo['store_id']);
  44. }
  45. event('notice.notice', [$orderInfo, 'admin_pay_success_code']);
  46. return true;
  47. }
  48. }