PinkJob.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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\activity\pink;
  12. use app\services\activity\combination\StorePinkServices;
  13. use app\services\order\StoreOrderRefundServices;
  14. use app\services\order\StoreOrderServices;
  15. use crmeb\basic\BaseJobs;
  16. use crmeb\traits\QueueTrait;
  17. use think\facade\Log;
  18. /**
  19. * 拼团失败
  20. * Class PinkJob
  21. * @package app\jobs
  22. */
  23. class PinkJob extends BaseJobs
  24. {
  25. use QueueTrait;
  26. public function doJob($pinkId)
  27. {
  28. try {
  29. /** @var StorePinkServices $pinkService */
  30. $pinkService = app()->make(StorePinkServices::class);
  31. $info = $pinkService->get((int)$pinkId);
  32. if (!$info) {
  33. return true;
  34. }
  35. //已经成功 || 失败处理
  36. if (in_array($info['status'], [2, 3])) {
  37. return true;
  38. }
  39. [$pinkAll, $pinkT, $count, $idAll, $uidAll] = $pinkService->getPinkMemberAndPinkK($info);
  40. $pinkService->pinkFail($pinkAll, $pinkT, 0);
  41. } catch (\Throwable $e) {
  42. Log::error('拼团超时处理失败,原因:' . $e->getMessage());
  43. }
  44. return true;
  45. }
  46. /**
  47. * 创建拼团
  48. * @param $orderInfo
  49. * @return bool
  50. */
  51. public function createPink($orderInfo)
  52. {
  53. if (!$orderInfo) {
  54. return true;
  55. }
  56. try {
  57. /** @var StorePinkServices $pinkServices */
  58. $pinkServices = app()->make(StorePinkServices::class);
  59. /** @var StoreOrderServices $orderServices */
  60. $orderServices = app()->make(StoreOrderServices::class);
  61. $resPink = $pinkServices->createPink($orderServices->tidyOrder($orderInfo, true));//创建拼团
  62. } catch (\Throwable $e) {
  63. Log::error('创建拼团失败失败,原因:' . $e->getMessage());
  64. }
  65. return true;
  66. }
  67. }