TaskSubscribe.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. namespace crmeb\subscribes;
  3. use app\models\system\MerchantDailyReport;
  4. use app\models\system\SystemAttachment;
  5. use app\models\store\StoreBargainUser;
  6. use app\models\store\StoreOrder;
  7. use app\models\store\StorePink;
  8. use app\models\system\SystemDailyReport;
  9. use app\models\user\UserToken;
  10. use app\adminapi\controller\v1\setting\PushBinding;
  11. use crmeb\basic\BaseModel;
  12. use think\db\exception\DataNotFoundException;
  13. use think\db\exception\DbException;
  14. use think\db\exception\ModelNotFoundException;
  15. use think\facade\Db;
  16. /**
  17. * 定时任务类
  18. * Class TaskSubscribe
  19. * @package crmeb\subscribes
  20. */
  21. class TaskSubscribe
  22. {
  23. public function handle()
  24. {
  25. }
  26. /**
  27. * 2秒钟执行的方法
  28. */
  29. public function onTask_2()
  30. {
  31. }
  32. /**
  33. * 6秒钟执行的方法
  34. */
  35. public function onTask_6()
  36. {
  37. }
  38. /**
  39. * 10秒钟执行的方法
  40. */
  41. public function onTask_10()
  42. {
  43. }
  44. /**
  45. * 30秒钟执行的方法
  46. */
  47. public function onTask_30()
  48. {
  49. try {
  50. Db::startTrans();
  51. StoreBargainUser::startBargainUserStatus();//批量修改砍价状态为 砍价失败
  52. Db::commit();
  53. } catch (\Exception $e) {
  54. Db::rollback();
  55. }
  56. try {
  57. Db::startTrans();
  58. StoreOrder::orderUnpaidCancel();//订单未支付默认取消
  59. Db::commit();
  60. } catch (\Exception $e) {
  61. Db::rollback();
  62. }
  63. try {
  64. Db::startTrans();
  65. StoreOrder::startTakeOrder();//7天自动收货
  66. Db::commit();
  67. } catch (\Exception $e) {
  68. Db::rollback();
  69. }
  70. try {
  71. Db::startTrans();
  72. StorePink::statusPink();//拼团到期修改状态
  73. Db::commit();
  74. } catch (\Exception $e) {
  75. Db::rollback();
  76. }
  77. }
  78. /**
  79. * 60秒钟执行的方法
  80. */
  81. public function onTask_60()
  82. {
  83. }
  84. /**
  85. * 180秒钟执行的方法
  86. */
  87. public function onTask_180()
  88. {
  89. }
  90. /**
  91. * 300秒钟执行的方法
  92. */
  93. public function onTask_300()
  94. {
  95. SystemAttachment::emptyYesterdayAttachment();//清除昨日海报
  96. StoreOrder::sendTen();//10分钟未付款发送通知
  97. self::checkHour(9);//发送商户报表模板消息
  98. BaseModel::beginTrans();
  99. try {
  100. MerchantDailyReport::recordYesterdayReport();
  101. SystemDailyReport::recordYesterdayReport();
  102. BaseModel::commitTrans();
  103. } catch (DbException $e) {
  104. BaseModel::rollbackTrans();
  105. }
  106. }
  107. public static function checkHour($hour){
  108. $h=date("G");
  109. if($h >= $hour){
  110. MerchantDailyReport::sendMerchantMessage();
  111. }
  112. }
  113. }