批量处理数据

admin2年前Laravel596


   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>';
       }
   }

相关文章

PHP 严格类型

只需在 PHP 代码文件的开头加上declare(strict_types = 1);这一行魔法代码,就能开启严格类型检查之旅。...

用户注册账号

public function register(){    $mobile = request()->input('mobile');   &nb...

编辑用户信息

*/public function useredit(){    $avatar = request()->input('avatar');   &...

压缩图片

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

微信支付V2

   public static function unifiedorder($openid, $out_trade_no, $total_fee, $notify)...

微信开放平台-扫码登录

public function wx_info(){    $code = request()->input('code');    if...