db->createCommand($sql)->execute(); $query = new \yii\db\Query(); $query->from(Order::tableName()); $query->where(['>', 'status', 1]); foreach ($query->batch() as $batch) { foreach ($batch as $order) { $status = $order['status'] ?? 0; if ($status == 1 || $status == 5) { continue; } $payWay = $order['payWay'] ?? 0; $amount = $order['actPrice'] ?? 0; $shopId = $order['shopId'] ?? 0; $shop = ShopClass::getLockById($shopId); if (empty($shop)) { continue; } $date = date('Ymd', strtotime($order['addTime'])); StatKdClass::replace($shop, $amount, $payWay, $date); } } } }