批量处理数据

admin2年前Laravel704


   public function index44()
   {
       $domain = request()->server('HTTP_HOST');
       $p = request()->input('page', 1);
       $pause = request()->input('pause');
       $list = Order::query()->where('type', 2)->paginate('10')->withQueryString();
       if ($p > $list->lastPage()) {
           echo '完成';
           exit();
       }
       foreach ($list as $item) {
//            dd($item->uid);
           $mana = empty($item->mana) ? 7 * $item->num : $item->mana * ($item->num - 1);
           $uid = $item->uid;
           $score_log = new ScoreLog([
               'uid' => $uid,//$item->uid,
               'type' => '-',
               'score' => $mana,
               'msg' => 2,
               'time' => time(),
               'desc' => '补扣商标兑换管理费',
               'use' => 1,
               'tag' => 10,
               'data' => date('Y-m-d', time())
           ]);
           $score_log->save();
           $user = Member::query()->find($uid);
           if ($user) {
               $user->decrement('gold', $mana);
           }
//            dd($score_log);
       }
       echo '当前第' . $p . '页 ,共 ' . $list->lastPage() . ' 页';
       $next_page = 'https://' . $domain . '/test?page=' . ++$p;
       echo '   <a href="' . $next_page . '&pause=1">暂停</a>';
       if ($pause == 1) {
           echo '已暂停,<a href="' . $next_page . '">继续开始</a>';
       } else {
           echo '<script>setTimeout("window.location.href=\'' . $next_page . '\'",3000);</script>';
       }
   }

相关文章

压缩图片

public static function size($id, $img) { try { list($width, $height, $img_type, $attr) = @getimages...

忘记密码

publicfunction forget(){    $phone = request()->input('phone');    $c...

发送公众号信息

* 发送消息 */public function tosend($openid, $title, $content, $time, $aid){    $tokens = $thi...

不重复 的推荐码

public function getcode(){    do {        $code = rand(10000000, 99999...

过滤违禁词

/** * 内容验证 */public function check($content){    $count = 0; //违规词的个数    $list =...

查找下级所有数据

public function bottom($mid = 3){    $members = DB::select('select id,parent_id,`level...