select(); $list = $userPledge::alias('a') ->join('product_pledge b', 'a.pledge_id = b.id', 'left') ->where('a.status', '>', 0) ->field('a.*,b.day_num') ->select(); $i = 0; $time= time(); $day = 86400; foreach ($list as $item) { //修改详情订单状态 $detail = json_decode($item['details'], true); $productOrder::where('status', 6)->whereIn('id', array_column($detail, 'id'))->setField('status', ProductOrder::Paid); //更新存储订单状态 $item->last_time = $time; $item->status = 0; //关闭 $item->save(); $i++; } $this->success('ok:'. $i); } public function reset_user_pledge() { $list = UserPledge::where('status', 1)->select(); $ids = ''; foreach ($list as $item){ $info = json_decode($item->details, true); foreach ($info as $value){ $ids .= $value->id . ','; } } dump($ids); } //去掉重复订单 public function removeOrder(ProductOrder $productOrder) { $i = 0; $rows = Db::name('product_order')->field('id,order_no,count(*) as count')->group('order_no')->having('count > 1')->limit(500)->select(); foreach ($rows as $row) { $order = $productOrder::where('order_no', $row['order_no'])->order('id asc')->select(); foreach ($order as $key => $vv) { if($key > 0){ $vv->order_no = $row['order_no']. $key; $vv->save(); $i++; } } } // 如果需要,可以在这里进行一些批量操作 $this->success('ok:'. $i); } public function check_is_super() { $i = 0; $rows = Db::name('product_order')->field('id,order_no,count(*) as count')->group('order_no')->having('count > 1')->limit(500)->select(); foreach ($rows as $row) { $order = $productOrder::where('order_no', $row['order_no'])->order('id asc')->select(); foreach ($order as $key => $vv) { if($key > 0){ $vv->order_no = $row['order_no']. $key; $vv->save(); $i++; } } } // 如果需要,可以在这里进行一些批量操作 $this->success('ok:'. $i); } }