' => '2022-11-10 00:00:00'], null, '*', null, true); if (empty($list)) { return false; } foreach ($list as $out) { $orderSn = $out->orderSn ?? ''; $inOrderSn = $out->inOrderSn ?? ''; $in = StockInOrderClass::getByCondition(['orderSn' => $inOrderSn], true); if (empty($in)) { echo $orderSn . " 没有找到入库记录\n"; } $itemList = StockOutOrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true); $totalCost = 0; if (!empty($itemList)) { foreach ($itemList as $item) { $itemNum = $item->itemNum ?? 0; $itemPrice = $item->itemPrice ?? 0; $current = bcmul($itemNum, $itemPrice, 2); $totalCost = bcadd($totalCost, $current, 2); } } $in->price = $totalCost; $in->save(); $out->price = $totalCost; $out->save(); echo $orderSn . " 总成本{$totalCost}\n"; } } //可以删除 public function actionUpdateGhs() { ini_set('memory_limit', '2045M'); set_time_limit(0); $ghsList = GhsClass::getAllByCondition(['id>' => 0], null, '*', null, true); if (!empty($ghsList)) { foreach ($ghsList as $ghs) { $shopId = $ghs->shopId; $shop = ShopClass::getById($shopId, true); if (!empty($shop)) { $mobile = $shop->mobile; if (!empty($mobile)) { $ghs->mobile = $mobile; $ghs->save(); echo $mobile . ' ' . $ghs->id . " ok \n"; } } } } } }