' => 0], 'id asc', '*', null, true); if (!empty($list)) { foreach ($list as $item) { $orderSn = $item->orderSn ?? ''; $addTime = $item->addTime ?? ''; $totalNum = 0; $mainId = $item->mainId ?? 0; $productList = StockWastageOrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true); if (!empty($productList)) { foreach ($productList as $product) { $itemInfo = $product->itemInfo ?? ''; if (empty($itemInfo)) { continue; } $arr = json_decode($itemInfo, true); if (is_array($arr) == false) { continue; } $name = $arr['itemName'] ?? ''; $cover = $arr['itemCover'] ?? ''; $product->name = $name; $product->mainId = $mainId; $product->cover = $cover; $product->addTime = $addTime; $product->save(); $totalNum = bcadd($totalNum, $product->itemNum, 2); } } $item->num = $totalNum; $item->save(); } } } }