CrontabController.php 4.2 KB

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