TaskSubscribe.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 think\facade\Log;
  10. use crmeb\utils\Auto as AutoJob;
  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. /**
  31. * 10秒钟执行的方法
  32. */
  33. public function onTask_10()
  34. {
  35. //自动拼团
  36. $time = time();
  37. $orderGroup =StoreOrder::where('is_del',0)->where('is_system_del',0)->where('paid',1)->where('refund_status',0)->where('is_auto_pink',1)->where('is_ok',0)->where('begin_time','<',$time)->where('pink_num','<>',0)->where('pink_id',0)->order('id desc')->select()->toArray();
  38. foreach ($orderGroup as $item) {
  39. AutoJob::create($item); //自动拼团
  40. }
  41. }
  42. /**
  43. * 30秒钟执行的方法
  44. */
  45. public function onTask_30()
  46. {
  47. try {
  48. Db::startTrans();
  49. StoreBargainUser::startBargainUserStatus();//批量修改砍价状态为 砍价失败
  50. Db::commit();
  51. } catch (\Exception $e) {
  52. Db::rollback();
  53. }
  54. try {
  55. Db::startTrans();
  56. StoreOrder::orderUnpaidCancel();//订单未支付默认取消
  57. Db::commit();
  58. } catch (\Exception $e) {
  59. Db::rollback();
  60. }
  61. try {
  62. Db::startTrans();
  63. StoreOrder::startTakeOrder();//7天自动收货
  64. Db::commit();
  65. } catch (\Exception $e) {
  66. Db::rollback();
  67. }
  68. try {
  69. Db::startTrans();
  70. StorePink::statusPink();//拼团到期修改状态
  71. Db::commit();
  72. } catch (\Exception $e) {
  73. Db::rollback();
  74. }
  75. }
  76. /**
  77. * 60秒钟执行的方法
  78. */
  79. public function onTask_60()
  80. {
  81. }
  82. /**
  83. * 180秒钟执行的方法
  84. */
  85. public function onTask_180()
  86. {
  87. }
  88. /**
  89. * 300秒钟执行的方法
  90. */
  91. public function onTask_300()
  92. {
  93. UserToken::delToken();//删除一天前的过期token
  94. SystemAttachment::emptyYesterdayAttachment();//清除昨日海报
  95. StoreOrder::sendTen();//10分钟未付款发送通知
  96. }
  97. }