批量处理数据

admin9个月前Laravel369


   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 function qrcode()    {        $qcode = "http...

按照距离远近排序

   $distance = "ACOS(SIN(( $lat * 3.1415) / 180 ) *SIN((lat * 3.1415) / 180 ) +COS((...

编辑用户信息

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

获取微信的Token

 public function Token()    {        $this->path = __DIR__ . &...

base64 处理图片

public function images(){    $image = request()->input('image');    i...

查找下级所有数据

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