mainId ?? 0; $customId = $order->customId ?? 0; $customName = $order->customName ?? ''; $customNamePy = $order->customNamePy ?? ''; $itemId = $product->id ?? 0; $ptItemId = $product->itemId ?? 0; $name = $product->name ?? ''; $py = $product->py ?? ''; $bigUnit = $product->bigUnit ?? '扎'; $bookSn = $shop->bookSn ?? ''; $nowNum = bcsub($bookCustomRes->bookNum, $num); if ($nowNum < 0) { $cacheKey = $params['cacheKey'] ?? ''; if (!empty($cacheKey)) { util::unlock($cacheKey); } util::fail($customName . '预订的' . $name . '不够减哈 bookCustom'); } $bookCustomRes->bookNum = $nowNum; $bookCustomRes->save(); $bookItemCustomResId = $bookCustomRes->id ?? 0; $ioRes = $params['ioRes'] ?? null; $relatedId = $ioRes->id ?? 0; //变动记录 $currentCapitalType = dict::getDict('capitalType', 'delBook'); $staffName = $params['staffName'] ?? ''; $staffId = $params['staffId'] ?? 0; $event = $customName . '减少' . $name . $num . $bigUnit; $changeData = [ 'mainId' => $mainId, 'bookSn' => $bookSn, 'name' => $name, 'py' => $py, 'itemId' => $itemId, 'ptItemId' => $ptItemId, 'customId' => $customId, 'customName' => $customName, 'customNamePy' => $customNamePy, 'relateId' => $relatedId, 'relateSecondId' => $bookItemCustomResId, 'ptStyle' => 2, 'capitalType' => $currentCapitalType, 'io' => 0, 'changeNum' => $num, 'num' => $bookCustomRes->bookNum, 'event' => $event, 'staffId' => $staffId, 'staffName' => $staffName, 'remark' => '', ]; BookCustomChangeClass::add($changeData, true); return $bookCustomRes; } }