TaskSubscribe.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. namespace crmeb\subscribes;
  3. use app\admin\model\system\SystemAttachment;
  4. use app\models\store\StoreBargainUser;
  5. use app\models\store\StoreOrder;
  6. use app\models\store\StorePink;
  7. use app\models\user\UserToken;
  8. use think\Exception;
  9. use think\facade\Db;
  10. use think\facade\Log;
  11. /**
  12. * 定时任务类
  13. * Class TaskSubscribe
  14. * @package crmeb\subscribes
  15. */
  16. class TaskSubscribe
  17. {
  18. public function handle()
  19. {
  20. }
  21. /**
  22. * 2秒钟执行的方法
  23. */
  24. public function onTask_2()
  25. {
  26. }
  27. /**
  28. * 6秒钟执行的方法
  29. */
  30. public function onTask_6()
  31. {
  32. }
  33. /**
  34. * 10秒钟执行的方法
  35. */
  36. public function onTask_10()
  37. {
  38. }
  39. /**
  40. * 30秒钟执行的方法
  41. */
  42. public function onTask_30()
  43. {
  44. // @file_put_contents('30.txt', date('Y-m-d H:i:s') . PHP_EOL, FILE_APPEND);
  45. try {
  46. Db::startTrans();
  47. StoreBargainUser::startBargainUserStatus();//批量修改砍价状态为 砍价失败
  48. Db::commit();
  49. } catch (\Exception $e) {
  50. Log::error('startBargainUserStatus:' . $e->getMessage());
  51. Db::rollback();
  52. }
  53. try {
  54. Db::startTrans();
  55. StoreOrder::orderUnpaidCancel();//订单未支付默认取消
  56. Db::commit();
  57. } catch (\Exception $e) {
  58. Log::error('orderUnpaidCancel:' . $e->getMessage());
  59. Db::rollback();
  60. }
  61. try {
  62. Db::startTrans();
  63. StoreOrder::startTakeOrder();//7天自动收货
  64. Db::commit();
  65. } catch (\Exception $e) {
  66. Log::error('startTakeOrder:' . $e->getMessage());
  67. Db::rollback();
  68. }
  69. try {
  70. Db::startTrans();
  71. StorePink::statusPink();//拼团到期修改状态
  72. Db::commit();
  73. } catch (\Exception $e) {
  74. Log::error('statusPink:' . $e->getMessage());
  75. Db::rollback();
  76. }
  77. // @file_put_contents('30.txt', date('Y-m-d H:i:s') . '_END' . PHP_EOL, FILE_APPEND);
  78. }
  79. /**
  80. * 60秒钟执行的方法
  81. */
  82. public function onTask_60()
  83. {
  84. }
  85. /**
  86. * 180秒钟执行的方法
  87. */
  88. public function onTask_180()
  89. {
  90. }
  91. /**
  92. * 300秒钟执行的方法
  93. */
  94. public function onTask_300()
  95. {
  96. UserToken::delToken();//删除一天前的过期token
  97. SystemAttachment::emptyYesterdayAttachment();//清除昨日海报
  98. StoreOrder::sendTen();//10分钟未付款发送通知
  99. }
  100. }