|
|
@@ -32,20 +32,22 @@ class GhsOrderController extends Controller
|
|
|
$params = ['staffId' => 0, 'staffName' => '系统', 'notice' => false]; // notice设置为 false,实现不发送发货通知
|
|
|
foreach ($mainIds as $mainId) {
|
|
|
$condition = array_merge(['mainId' => $mainId], $extraCondition);
|
|
|
- $orders = OrderClass::getAllByCondition($condition, 'id asc', '*', null, true);
|
|
|
- if (empty($orders)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- foreach ($orders as $order) {
|
|
|
- $connection = Yii::$app->db;
|
|
|
- $transaction = $connection->beginTransaction();
|
|
|
- try {
|
|
|
- OrderClass::confirmReach($order, $params);
|
|
|
- $transaction->commit();
|
|
|
- } catch (\Exception $e) {
|
|
|
- $transaction->rollBack();
|
|
|
- $orderId = $order->id ?? 0;
|
|
|
- noticeUtil::push("订单自动完结失败 orderId={$orderId}, message={$e->getMessage()}", '15280215347');
|
|
|
+ $query = OrderClass::getActiveRecord()->conditionQuery($condition)->orderBy('id asc');
|
|
|
+ foreach ($query->batch(1000) as $orders) {
|
|
|
+ if (empty($orders)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ foreach ($orders as $order) {
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ OrderClass::confirmReach($order, $params);
|
|
|
+ $transaction->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ $orderId = $order->id ?? 0;
|
|
|
+ noticeUtil::push("订单自动完结失败 orderId={$orderId}, message={$e->getMessage()}", '15280215347');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -72,21 +74,23 @@ class GhsOrderController extends Controller
|
|
|
$params = ['staffId' => 0, 'staffName' => '系统', 'notice' => false]; // notice设置为 false,实现不发送发货通知
|
|
|
foreach ($mainIds as $mainId) {
|
|
|
$condition = array_merge(['mainId' => $mainId], $extraCondition);
|
|
|
- $orders = OrderClass::getAllByCondition($condition, 'id asc', '*', null, true);
|
|
|
- if (empty($orders)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- foreach ($orders as $order) {
|
|
|
- $connection = Yii::$app->db;
|
|
|
- $transaction = $connection->beginTransaction();
|
|
|
- try {
|
|
|
- OrderClass::confirmReach($order, $params);
|
|
|
- $transaction->commit();
|
|
|
- echo $order->id . " ok \n";
|
|
|
- } catch (\Exception $e) {
|
|
|
- $transaction->rollBack();
|
|
|
- $orderId = $order->id ?? 0;
|
|
|
- noticeUtil::push("自动完结失败,orderId={$orderId}, message={$e->getMessage()}", '15280215347');
|
|
|
+ $query = OrderClass::getActiveRecord()->conditionQuery($condition)->orderBy('id asc');
|
|
|
+ foreach ($query->batch(1000) as $orders) {
|
|
|
+ if (empty($orders)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ foreach ($orders as $order) {
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ OrderClass::confirmReach($order, $params);
|
|
|
+ $transaction->commit();
|
|
|
+ echo $order->id . " ok \n";
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ $orderId = $order->id ?? 0;
|
|
|
+ noticeUtil::push("自动完结失败,orderId={$orderId}, message={$e->getMessage()}", '15280215347');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|