批量处理数据

admin1年前Laravel501


   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...

微信退款v3

/** * 微信 退款 操作 */ public function refund($out_trade_no, $refund_money) { $time = time();...

获取域名

/** * 获取域名 */public function domain(){    return request()->getSchemeAndHttpHost();}...

微信支付V2

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

解密微信绑定的手机号

public function mobile() { $code = request()->input('code'); if (!$code) { return $this-&...

接口返回处理

public function __construct()    {        $action = request()->rout...