TaskSubscribe.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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\subscribes;
  12. use app\services\activity\combination\StorePinkServices;
  13. use app\services\agent\AgentManageServices;
  14. use app\services\activity\live\LiveGoodsServices;
  15. use app\services\activity\live\LiveRoomServices;
  16. use app\services\order\StoreOrderServices;
  17. use app\services\order\StoreOrderTakeServices;
  18. use app\services\product\product\StoreProductServices;
  19. use app\services\system\attachment\SystemAttachmentServices;
  20. use think\facade\Log;
  21. /**
  22. * 定时任务类
  23. * Class TaskSubscribe
  24. * @package crmeb\subscribes
  25. */
  26. class TaskSubscribe
  27. {
  28. public function handle()
  29. {
  30. }
  31. /**
  32. * 2秒钟执行的方法
  33. */
  34. public function onTask_2()
  35. {
  36. }
  37. /**
  38. * 6秒钟执行的方法
  39. */
  40. public function onTask_6()
  41. {
  42. file_put_contents(runtime_path() . '.timer', time());
  43. }
  44. /**
  45. * 10秒钟执行的方法
  46. */
  47. public function onTask_10()
  48. {
  49. }
  50. /**
  51. * 30秒钟执行的方法
  52. */
  53. public function onTask_30()
  54. {
  55. //自动取消订单
  56. /** @var StoreOrderServices $orderServices */
  57. $orderServices = app()->make(StoreOrderServices::class);
  58. $orderServices->orderUnpaidCancel();
  59. }
  60. /**
  61. * 60秒钟执行的方法
  62. */
  63. public function onTask_60()
  64. {
  65. //拼团失败处理
  66. /** @var StorePinkServices $storePinkServices */
  67. $storePinkServices = app()->make(StorePinkServices::class);
  68. $storePinkServices->statusPink();
  69. //自动解绑上级绑定
  70. try {
  71. /** @var AgentManageServices $agentManage */
  72. $agentManage = app()->make(AgentManageServices::class);
  73. $agentManage->removeSpread();
  74. } catch (\Throwable $e) {
  75. Log::error('自动解除上级绑定失败,失败原因:' . $e->getMessage());
  76. }
  77. }
  78. /**
  79. * 180秒钟执行的方法
  80. */
  81. public function onTask_180()
  82. {
  83. //更新直播商品状态
  84. try {
  85. /** @var LiveGoodsServices $liveGoods */
  86. $liveGoods = app()->make(LiveGoodsServices::class);
  87. $liveGoods->syncGoodStatus();
  88. } catch (\Throwable $e) {
  89. Log::error('更新直播商品状态失败,失败原因:' . $e->getMessage());
  90. }
  91. //更新直播间状态
  92. try {
  93. /** @var LiveRoomServices $liveRoom */
  94. $liveRoom = app()->make(LiveRoomServices::class);
  95. $liveRoom->syncRoomStatus();
  96. } catch (\Throwable $e) {
  97. Log::error('更新直播间状态失败,失败原因:' . $e->getMessage());
  98. }
  99. }
  100. /**
  101. * 300秒钟执行的方法
  102. */
  103. public function onTask_300()
  104. {
  105. //自动收货
  106. /** @var StoreOrderTakeServices $services */
  107. $services = app()->make(StoreOrderTakeServices::class);
  108. $services->autoTakeOrder();
  109. //清除昨日海报
  110. /** @var SystemAttachmentServices $attach */
  111. $attach = app()->make(SystemAttachmentServices::class);
  112. $attach->emptyYesterdayAttachment();
  113. //查询预售到期商品自动下架
  114. /** @var StoreProductServices $product */
  115. $product = app()->make(StoreProductServices::class);
  116. $product->downAdvance();
  117. //自动好评
  118. /** @var StoreOrderServices $orderServices */
  119. $orderServices = app()->make(StoreOrderServices::class);
  120. $orderServices->autoComment();
  121. }
  122. }