CrontabController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\services\activity\combination\StorePinkServices;
  4. use app\services\activity\live\LiveGoodsServices;
  5. use app\services\activity\live\LiveRoomServices;
  6. use app\services\agent\AgentManageServices;
  7. use app\services\order\StoreOrderServices;
  8. use app\services\order\StoreOrderTakeServices;
  9. use app\services\product\product\StoreProductServices;
  10. use app\services\system\attachment\SystemAttachmentServices;
  11. use app\services\system\crontab\SystemCrontabServices;
  12. /**
  13. * 定时任务控制器
  14. * @author 吴汐
  15. * @email 442384644@qq.com
  16. * @date 2023/02/21
  17. */
  18. class CrontabController
  19. {
  20. /**
  21. * 定时任务调用接口
  22. * @author 吴汐
  23. * @email 442384644@qq.com
  24. * @date 2023/02/17
  25. */
  26. public function crontabRun()
  27. {
  28. app()->make(SystemCrontabServices::class)->crontabRun();
  29. }
  30. /**
  31. * 检测定时任务是否正常,必须6秒执行一次
  32. */
  33. public function crontabCheck()
  34. {
  35. file_put_contents(root_path() . 'runtime/.timer', time());
  36. }
  37. /**
  38. * 未支付自动取消订单
  39. * @throws \think\db\exception\DataNotFoundException
  40. * @throws \think\db\exception\DbException
  41. * @throws \think\db\exception\ModelNotFoundException
  42. */
  43. public function orderUnpaidCancel()
  44. {
  45. /** @var StoreOrderServices $orderServices */
  46. $orderServices = app()->make(StoreOrderServices::class);
  47. $orderServices->orderUnpaidCancel();
  48. }
  49. /**
  50. * 拼团到期订单处理
  51. * @throws \think\db\exception\DataNotFoundException
  52. * @throws \think\db\exception\ModelNotFoundException
  53. */
  54. public function pinkExpiration()
  55. {
  56. /** @var StorePinkServices $storePinkServices */
  57. $storePinkServices = app()->make(StorePinkServices::class);
  58. $storePinkServices->statusPink();
  59. }
  60. /**
  61. * 自动解绑上级绑定
  62. */
  63. public function agentUnbind()
  64. {
  65. /** @var AgentManageServices $agentManage */
  66. $agentManage = app()->make(AgentManageServices::class);
  67. $agentManage->removeSpread();
  68. }
  69. /**
  70. * 更新直播商品状态
  71. */
  72. public function syncGoodStatus()
  73. {
  74. /** @var LiveGoodsServices $liveGoods */
  75. $liveGoods = app()->make(LiveGoodsServices::class);
  76. $liveGoods->syncGoodStatus();
  77. }
  78. /**
  79. * 更新直播间状态
  80. */
  81. public function syncRoomStatus()
  82. {
  83. /** @var LiveRoomServices $liveRoom */
  84. $liveRoom = app()->make(LiveRoomServices::class);
  85. $liveRoom->syncRoomStatus();
  86. }
  87. /**
  88. * 自动收货
  89. */
  90. public function autoTakeOrder()
  91. {
  92. /** @var StoreOrderTakeServices $services */
  93. $services = app()->make(StoreOrderTakeServices::class);
  94. $services->autoTakeOrder();
  95. }
  96. /**
  97. * 查询预售到期商品自动下架
  98. */
  99. public function downAdvance()
  100. {
  101. /** @var StoreProductServices $product */
  102. $product = app()->make(StoreProductServices::class);
  103. $product->downAdvance();
  104. }
  105. /**
  106. * 自动好评
  107. */
  108. public function autoComment()
  109. {
  110. /** @var StoreOrderServices $orderServices */
  111. $orderServices = app()->make(StoreOrderServices::class);
  112. $orderServices->autoComment();
  113. }
  114. /**
  115. * 清除昨日海报
  116. * @throws \Exception
  117. */
  118. public function emptyYesterdayAttachment()
  119. {
  120. /** @var SystemAttachmentServices $attach */
  121. $attach = app()->make(SystemAttachmentServices::class);
  122. $attach->emptyYesterdayAttachment();
  123. }
  124. }