$item) { $orderSn = $item->orderSn ?? ''; if (empty($orderSn)) { continue; } $refund = RefundOrderClass::getByCondition(['orderSn' => $orderSn], true); if (empty($refund)) { continue; } $sjId = $refund->sjId ?? 0; $shopId = $refund->shopId ?? 0; $item->sjId = $sjId; $item->shopId = $shopId; $item->save(); $date = date('Ymd', strtotime($refund->addTime)); StatItemClass::refundReplace($item, $date); } } // ./yii refund-item/order public function actionOrder() { ini_set('memory_limit', '2045M'); set_time_limit(0); $list = OrderClass::getAllByCondition([], null, '*', null, true); echo "数量:" . count($list) . "\n"; if (empty($list)) { return false; } foreach ($list as $key => $order) { $status = $order->status ?? 0; if (in_array($status, [1, 5])) { continue; } $orderSn = $order->orderSn ?? ''; if (empty($orderSn)) { continue; } $itemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true); if (!empty($itemList)) { foreach ($itemList as $itemInfo) { $sjId = $itemInfo->sjId ?? 0; $shopId = $itemInfo->shopId ?? 0; $productId = $itemInfo->productId ?? 0; if (empty($sjId) || empty($shopId)) { $p = ProductClass::getById($productId, true); $sjId = $p->sjId ?? 0; $shopId = $p->shopId ?? 0; $itemInfo->sjId = $sjId; $itemInfo->shopId = $shopId; $itemInfo->save(); echo "发现没有sjId shopId 已经补充 orderItemId:{$itemInfo->id} sjId:{$sjId} shopId:{$shopId} 如果是0表示没有补到 \n"; } $date = date('Ymd', strtotime($order->addTime)); StatItemClass::replace($itemInfo, $date); } } } } }