123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- <?php
- namespace crmeb\subscribes;
- use app\admin\model\system\SystemAttachment;
- use app\models\lala\LalaPinkJoin;
- use app\models\mining\UserMiningMachine;
- use app\models\point_plan\UserPointPlan;
- use app\models\store\StoreBargainUser;
- use app\models\store\StoreOrder;
- use app\models\store\StorePink;
- use app\models\user\UserRecharge;
- use app\models\user\UserToken;
- use crmeb\basic\BaseModel;
- use crmeb\services\blockchain\BlockChianService;
- use think\facade\Db;
- use think\facade\Log;
- /**
- * 定时任务类
- * Class TaskSubscribe
- * @package crmeb\subscribes
- */
- class TaskSubscribe
- {
- public function handle()
- {
- }
- /**
- * 2秒钟执行的方法
- */
- public function onTask_2()
- {
- }
- /**
- * 6秒钟执行的方法
- */
- public function onTask_6()
- {
- }
- /**
- * 10秒钟执行的方法
- */
- public function onTask_10()
- {
- }
- /**
- * 30秒钟执行的方法
- */
- public function onTask_30()
- {
- try {
- $start_time = time();
- $res = LalaPinkJoin::openAward();
- $end_time = time();
- @file_put_contents('openAwardTime.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
- if (!$res) {
- @file_put_contents('openAward.txt', '【' . date('Y-m-d H:i:s') . '】' . BaseModel::getErrorInfo() . PHP_EOL, FILE_APPEND);
- }
- } catch (\Exception $e) {
- Log::error('openAward:' . $e->getMessage());
- }
- try {
- $start_time = time();
- LalaPinkJoin::autoPink();//自动拼团
- $end_time = time();
- @file_put_contents('autoPinkTime.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
- } catch (\Exception $e) {
- Log::error('autoPink:' . $e->getMessage());
- }
- try {
- Db::startTrans();
- StoreBargainUser::startBargainUserStatus();//批量修改砍价状态为 砍价失败
- Db::commit();
- } catch (\Exception $e) {
- Db::rollback();
- }
- try {
- Db::startTrans();
- StoreOrder::orderUnpaidCancel();//订单未支付默认取消
- Db::commit();
- } catch (\Exception $e) {
- Db::rollback();
- }
- try {
- Db::startTrans();
- StoreOrder::startTakeOrder();//7天自动收货
- Db::commit();
- } catch (\Exception $e) {
- Db::rollback();
- }
- try {
- Db::startTrans();
- StorePink::statusPink();//拼团到期修改状态
- Db::commit();
- } catch (\Exception $e) {
- Db::rollback();
- }
- }
- /**
- * 60秒钟执行的方法
- */
- public function onTask_60()
- {
- try {
- $start_time = time();
- LalaPinkJoin::sendMoney();//自动拼团
- $end_time = time();
- @file_put_contents('sendMoneyTime.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
- } catch (\Exception $e) {
- Log::error('sendMoney:' . $e->getMessage());
- }
- try {
- $start_time = time();
- $res = UserMiningMachine::dayMining();//每日挖矿
- $end_time = time();
- @file_put_contents('dayMiningTime.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
- if (!$res) {
- @file_put_contents('mining.txt', '【' . date('Y-m-d H:i:s') . '】' . UserMiningMachine::getErrorInfo() . PHP_EOL, FILE_APPEND);
- }
- } catch (\Exception $e) {
- @file_put_contents('mining.txt', '【' . date('Y-m-d H:i:s') . '】' . $e->getMessage() . PHP_EOL, FILE_APPEND);
- }
- try {
- $start_time = time();
- UserPointPlan::day_release();//每日释放
- $end_time = time();
- @file_put_contents('dayReleaseTime.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
- } catch (\Exception $e) {
- Log::error('day_release:' . $e->getMessage());
- }
- try {
- $start_time = time();
- UserPointPlan::day_release_ticket();//每日释放
- $end_time = time();
- @file_put_contents('dayReleaseTicketTime.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
- } catch (\Exception $e) {
- Log::error('day_release_ticket:' . $e->getMessage());
- }
- }
- /**
- * 180秒钟执行的方法
- */
- public function onTask_180()
- {
- }
- /**
- * 300秒钟执行的方法
- */
- public function onTask_300()
- {
- try {
- UserToken::startTrans();
- $start_time = time();
- UserToken::delToken();
- $end_time = time();
- @file_put_contents('delTokenTime.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
- UserToken::commit();
- } catch (\Exception $e) {
- Log::error('delToken:' . $e->getMessage());
- UserToken::rollback();
- }
- try {
- BaseModel::beginTrans();
- $start_time = time();
- $res = StoreOrder::sendProductReturn();
- $end_time = time();
- @file_put_contents('sendProductReturn.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
- BaseModel::checkTrans($res);
- if (!$res) {
- Log::error('sendProductReturn:' . StoreOrder::getErrorInfo());
- }
- } catch (\Exception $e) {
- Log::error('sendProductReturn:' . $e->getMessage());
- BaseModel::rollbackTrans();
- }
- try {
- BaseModel::beginTrans();
- $start_time = time();
- $res = UserRecharge::sendReturn();
- $end_time = time();
- @file_put_contents('sendRechargeReturn.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
- BaseModel::checkTrans($res);
- if (!$res) {
- Log::error('sendRechargeReturn:' . UserRecharge::getErrorInfo());
- }
- } catch (\Exception $e) {
- Log::error('sendRechargeReturn:' . $e->getMessage());
- BaseModel::rollbackTrans();
- }
- try {
- BaseModel::beginTrans();
- $start_time = time();
- $res = StoreOrder::returnAreaPrice();
- $end_time = time();
- @file_put_contents('returnAreaPrice.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
- BaseModel::checkTrans($res);
- if (!$res) {
- Log::error('returnAreaPrice:' . StoreOrder::getErrorInfo());
- }
- } catch (\Exception $e) {
- Log::error('returnAreaPrice:' . $e->getMessage());
- BaseModel::rollbackTrans();
- }
- try {
- BaseModel::beginTrans();
- $start_time = time();
- $res = StoreOrder::returnPartnerPrice();
- $end_time = time();
- @file_put_contents('returnPartnerPrice.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
- BaseModel::checkTrans($res);
- if (!$res) {
- Log::error('returnPartnerPrice:' . StoreOrder::getErrorInfo());
- }
- } catch (\Exception $e) {
- Log::error('returnPartnerPrice:' . $e->getMessage());
- BaseModel::rollbackTrans();
- }
- SystemAttachment::emptyYesterdayAttachment();//清除昨日海报
- StoreOrder::sendTen();//10分钟未付款发送通知
- // $start_time = time();
- // BlockChianService::autoGetTransfer();
- // $end_time = time();
- // @file_put_contents('autoGetTransferTime.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
- // $start_time = time();
- // BlockChianService::autoCheckTransfer();
- // $end_time = time();
- // @file_put_contents('autoCheckTransferTime.txt', '【' . date('Y-m-d H:i:s') . '】' . ($start_time - $end_time) . '秒' . PHP_EOL, FILE_APPEND);
- }
- /**
- * 300秒钟执行的方法
- */
- public function onTask_7200()
- {
- }
- }
|