PrintJob.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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\activity\collage\UserCollageServices;
  13. use app\services\activity\integral\StoreIntegralOrderServices;
  14. use app\services\order\StoreOrderServices;
  15. use crmeb\basic\BaseJobs;
  16. use crmeb\services\printer\Printer;
  17. use crmeb\traits\QueueTrait;
  18. use think\facade\Log;
  19. /**
  20. * 小票打印
  21. * Class PrintJob
  22. * @package app\jobs\notice
  23. */
  24. class PrintJob extends BaseJobs
  25. {
  26. use QueueTrait;
  27. /**
  28. * 小票打印
  29. * @param $name
  30. * @param $configData
  31. * @param $order
  32. * @param $product
  33. * @return bool|void
  34. */
  35. public function doJob($id, $isTable = true)
  36. {
  37. try {
  38. if (!$id) {
  39. return true;
  40. }
  41. /** @var StoreOrderServices $orderServices */
  42. $orderServices = app()->make(StoreOrderServices::class);
  43. $orderServices->orderPrint((int)$id, -1, -1, !!$isTable);
  44. } catch (\Throwable $e) {
  45. Log::error('小票打印失败失败,失败原因:' . $e->getMessage());
  46. }
  47. return true;
  48. }
  49. /**
  50. * 桌码流水小票打印
  51. * @param $tableId
  52. * @param $store_id
  53. * @return bool
  54. */
  55. public function tableDoJob($tableId, $store_id)
  56. {
  57. try {
  58. if (!(int)$tableId || !(int)$store_id) {
  59. return true;
  60. }
  61. /** @var UserCollageServices $collageServices */
  62. $collageServices = app()->make(UserCollageServices::class);
  63. $collageServices->tablePrint((int)$tableId, (int)$store_id);
  64. } catch (\Throwable $e) {
  65. Log::error('桌码流水小票打印失败失败,失败原因:' . $e->getMessage());
  66. }
  67. return true;
  68. }
  69. /**
  70. * 积分订单小票打印
  71. * @param $id
  72. * @return bool
  73. */
  74. public function IntegralDoJob($id)
  75. {
  76. try {
  77. /** @var StoreIntegralOrderServices $storeIntegralOrderServices */
  78. $storeIntegralOrderServices = app()->make(StoreIntegralOrderServices::class);
  79. $storeIntegralOrderServices->orderPrint((int)$id);
  80. } catch (\Throwable $e) {
  81. Log::error('桌码流水小票打印失败失败,失败原因:' . $e->getMessage());
  82. }
  83. return true;
  84. }
  85. }