TimerSubscribe.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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\facade\Db;
  9. use crmeb\services\async\WechatNotify;
  10. /**
  11. * 定时任务类
  12. * Class TaskSubscribe
  13. * @package crmeb\subscribes
  14. */
  15. class TimerSubscribe
  16. {
  17. public function handle()
  18. {
  19. }
  20. /**
  21. * 2秒钟执行的方法
  22. */
  23. public function onTimer_2()
  24. {
  25. }
  26. /**
  27. * 6秒钟执行的方法
  28. */
  29. public function onTimer_6()
  30. {
  31. }
  32. /**
  33. * 10秒钟执行的方法
  34. */
  35. public function onTimer_10()
  36. {
  37. WechatNotify::notify();
  38. }
  39. /**
  40. * 30秒钟执行的方法
  41. */
  42. public function onTimer_30()
  43. {
  44. try {
  45. Db::startTrans();
  46. StoreBargainUser::startBargainUserStatus();//批量修改砍价状态为 砍价失败
  47. Db::commit();
  48. } catch (\Exception $e) {
  49. Db::rollback();
  50. }
  51. try {
  52. Db::startTrans();
  53. StoreOrder::orderUnpaidCancel();//订单未支付默认取消
  54. Db::commit();
  55. } catch (\Exception $e) {
  56. Db::rollback();
  57. }
  58. try {
  59. Db::startTrans();
  60. StoreOrder::startTakeOrder();//7天自动收货
  61. Db::commit();
  62. } catch (\Exception $e) {
  63. Db::rollback();
  64. }
  65. try {
  66. Db::startTrans();
  67. StorePink::statusPink();//拼团到期修改状态
  68. Db::commit();
  69. } catch (\Exception $e) {
  70. Db::rollback();
  71. }
  72. }
  73. /**
  74. * 60秒钟执行的方法
  75. */
  76. public function onTimer_60()
  77. {
  78. }
  79. /**
  80. * 180秒钟执行的方法
  81. */
  82. public function onTimer_180()
  83. {
  84. }
  85. /**
  86. * 300秒钟执行的方法
  87. */
  88. public function onTimer_300()
  89. {
  90. UserToken::delToken();//删除一天前的过期token
  91. SystemAttachment::emptyYesterdayAttachment();//清除昨日海报
  92. StoreOrder::sendTen();//10分钟未付款发送通知
  93. }
  94. }