| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace app\api\command;
- use app\common\logic\ScanLogic;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- use app\common\model\ProductOrder;
- use app\common\model\UserModel;
- use think\Model;
- class Task extends Command
- {
- protected function configure()
- {
- $this->setName('task')->setDescription('Here is the remark ');
- }
- protected function execute(Input $input, Output $output)
- {
- /* 永不超时 */
- // ini_set('max_execution_time', 0);
- // 记录开始运行的时间
- $GLOBALS['_beginTime'] = microtime(TRUE);
- $output->writeln('定时任务开始执行:' . date('Y-m-d H:i:s', time()));
- /*** 发放分红收益 ***/
- $output->writeln("开始发放加权分红:");
- $i = 0;
- $count = $this->reset_user_pledge($i);
- $output->writeln('定时任务执行结束,总执行:' . $count . '个');
- }
- public function reset_user_pledge($i){
- $productOrder = new ProductOrder(); //Loader::model('ProductOrder');
- $num = 6; //空投数量
- $ids = 14; //空投产品
- UserModel::chunk(500, function($items) use ($i,$num , $ids, $productOrder) {
- foreach ($items as $item) {
- // 判断空投是否只够6个
- $res = $productOrder::where('user_id', $item->id)->where('product_id', $ids)->where('type_id', 5)->count();
- if($res < 6){
- $num = $num - $res;
- $productOrder::setPopularNoAreaOrder($num, 0, 0, $ids, $item->id, 5);
- $i ++;
- }
-
- }
- });
-
- return $i;
- }
- }
|