onNum = bcadd($bookCustomRes->onNum, $addOnNum); $bookCustomRes->save(); $bookCustomResId = $bookCustomRes->id ?? 0; $ioRes = $params['ioRes'] ?? null; $relatedId = $ioRes->id ?? 0; //变动记录 $itemId = $product->id ?? 0; $ptItemId = $product->itemId ?? 0; $name = $product->name ?? ''; $py = $product->py ?? ''; $bigUnit = $product->bigUnit ?? '扎'; $bookSn = $shop->bookSn ?? ''; $mainId = $shop->mainId ?? 0; $customId = $bookCustomRes->customId ?? 0; $customName = $bookCustomRes->name ?? ''; $customNamePy = $bookCustomRes->py ?? ''; $currentCapitalType = dict::getDict('capitalType', 'ghsCheckIn'); $staffName = $params['staffName'] ?? ''; $staffId = $params['staffId'] ?? 0; $orderSn = $bill->orderSn ?? ''; $currentChangeType = $params['currentChangeType'] ?? 'putIn'; if ($currentChangeType == 'stockOn') { $currentCapitalType = 0; $event = "{$staffName} 手动上架 {$name} " . $addOnNum . $bigUnit; } elseif ($currentChangeType == 'putIn') { $event = "采购单 {$orderSn} 入库,{$name} 上架 " . $addOnNum . $bigUnit; } else { $event = ''; util::fail('无效动作'); } $changeData = [ 'mainId' => $mainId, 'bookSn' => $bookSn, 'name' => $name, 'py' => $py, 'itemId' => $itemId, 'ptItemId' => $ptItemId, 'customId' => $customId, 'customName' => $customName, 'customNamePy' => $customNamePy, 'relateId' => $relatedId, 'relateSecondId' => $bookCustomResId, 'ptStyle' => 2, 'capitalType' => $currentCapitalType, 'io' => 1, 'changeNum' => $addOnNum, 'num' => $bookCustomRes->onNum, 'event' => $event, 'staffId' => $staffId, 'staffName' => $staffName, 'remark' => '', ]; BookCustomOnChangeClass::add($changeData, true); return $bookCustomRes; } public static function delOnNum($bookCustomRes, $delOnNum, $num, $bill, $shop, $product, $params) { $bookCustomRes->onNum = bcsub($bookCustomRes->onNum, $delOnNum); $bookCustomRes->save(); $bookCustomResId = $bookCustomRes->id ?? 0; $ioRes = $params['ioRes'] ?? null; $relatedId = $ioRes->id ?? 0; $itemId = $product->id ?? 0; $ptItemId = $product->itemId ?? 0; $name = $product->name ?? ''; $py = $product->py ?? ''; $bigUnit = $product->bigUnit ?? '扎'; $bookSn = $shop->bookSn ?? ''; $mainId = $shop->mainId ?? 0; $staffName = $params['staffName'] ?? ''; $staffId = $params['staffId'] ?? 0; $currentChangeType = $params['currentChangeType'] ?? 'delBook'; if ($currentChangeType == 'ghsCgRefund') { //供货商采购单售后 $customId = $bookCustomRes->customId ?? 0; $customName = $bookCustomRes->name ?? ''; $customNamePy = $bookCustomRes->py ?? ''; $orderSn = $bill->orderSn ?? ''; $event = $staffName . ' 售后采购单' . $orderSn . ',下架' . $name . $delOnNum . $bigUnit; $currentCapitalType = dict::getDict('capitalType', 'ghsCgRefund'); } elseif ($currentChangeType == 'stockOff') { $customId = $bookCustomRes->customId ?? 0; $customName = $bookCustomRes->name ?? ''; $customNamePy = $bookCustomRes->py ?? ''; $currentCapitalType = 0; $event = $staffName . '手动下架' . $name . $delOnNum . $bigUnit; } elseif ($currentChangeType == 'delBook') { $customId = $bill->customId ?? 0; $customName = $bill->customName ?? ''; $customNamePy = $bill->customNamePy ?? ''; $currentCapitalType = dict::getDict('capitalType', 'delBook'); $event = $customName . '减少预订' . $name . $num . $bigUnit . ',其中下架' . $delOnNum . $bigUnit; } else { $currentCapitalType = dict::getDict('capitalType', 'delBook'); $customId = 0; $customName = ''; $customNamePy = ''; $event = ''; util::fail('不存在的运作哈。。。'); } $changeData = [ 'mainId' => $mainId, 'bookSn' => $bookSn, 'name' => $name, 'py' => $py, 'itemId' => $itemId, 'ptItemId' => $ptItemId, 'customId' => $customId, 'customName' => $customName, 'customNamePy' => $customNamePy, 'relateId' => $relatedId, 'relateSecondId' => $bookCustomResId, 'ptStyle' => 2, 'capitalType' => $currentCapitalType, 'io' => 0, 'changeNum' => $delOnNum, 'num' => $bookCustomRes->onNum, 'event' => $event, 'staffId' => $staffId, 'staffName' => $staffName, 'remark' => '', ]; BookCustomOnChangeClass::add($changeData, true); return $bookCustomRes; } public static function addRoadNum($bookCustomRes, $addRoadNum, $bill, $shop, $product, $params) { $bookCustomRes->roadNum = bcadd($bookCustomRes->roadNum, $addRoadNum); $bookCustomRes->save(); $bookItemCustomResId = $bookCustomRes->id ?? 0; $ioRes = $params['ioRes'] ?? null; $relatedId = $ioRes->id ?? 0; $itemId = $product->id ?? 0; $ptItemId = $product->itemId ?? 0; $name = $product->name ?? ''; $py = $product->py ?? ''; $bigUnit = $product->bigUnit ?? '扎'; $bookSn = $shop->bookSn ?? ''; $mainId = $shop->mainId ?? 0; $staffName = $params['staffName'] ?? ''; $staffId = $params['staffId'] ?? 0; $currentCapitalType = dict::getDict('capitalType', 'ghsPurchase'); $customId = $bookCustomRes->customId ?? 0; $customName = $bookCustomRes->name ?? ''; $customNamePy = $bookCustomRes->py ?? ''; $orderSn = $bill->orderSn ?? ''; $event = "{$staffName} 新增待入库 {$orderSn},路上增加 {$name}" . $addRoadNum . $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' => 1, 'changeNum' => $addRoadNum, 'num' => $bookCustomRes->roadNum, 'event' => $event, 'staffId' => $staffId, 'staffName' => $staffName, 'remark' => '', ]; BookCustomRoadChangeClass::add($changeData, true); return $bookCustomRes; } public static function delRoadNum($bookCustomRes, $delRoadNum, $num, $bill, $shop, $product, $params) { $bookCustomRes->roadNum = bcsub($bookCustomRes->roadNum, $delRoadNum); $bookCustomRes->save(); $bookItemCustomResId = $bookCustomRes->id ?? 0; $ioRes = $params['ioRes'] ?? null; $relatedId = $ioRes->id ?? 0; //路上减少变动记录 $itemId = $product->id ?? 0; $ptItemId = $product->itemId ?? 0; $name = $product->name ?? ''; $py = $product->py ?? ''; $bigUnit = $product->bigUnit ?? '扎'; $bookSn = $shop->bookSn ?? ''; $mainId = $shop->mainId ?? 0; $currentCapitalType = dict::getDict('capitalType', 'delBook'); $staffName = $params['staffName'] ?? ''; $staffId = $params['staffId'] ?? 0; $currentChangeType = $params['currentChangeType'] ?? 'delBook'; if ($currentChangeType == 'putIn') { //入库 $currentCapitalType = dict::getDict('capitalType', 'ghsCheckIn'); $customId = $bookCustomRes->customId ?? 0; $customName = $bookCustomRes->name ?? ''; $customNamePy = $bookCustomRes->py ?? ''; $orderSn = $bill->orderSn ?? ''; $event = "采购单 {$orderSn} 入库上架,{$name} 路上减少" . $delRoadNum . $bigUnit; } elseif ($currentChangeType == 'delBook') { //减少预订 $currentCapitalType = dict::getDict('capitalType', 'delBook'); $customId = $bill->customId ?? 0; $customName = $bill->customName ?? ''; $customNamePy = $bill->customNamePy ?? ''; $event = $customName . '减少预订' . $name . $num . $bigUnit . ',其中路上减少' . $delRoadNum . $bigUnit; } elseif ($currentChangeType == 'cgCancel') { $currentCapitalType = dict::getDict('capitalType', 'ghsCgCancel'); $customId = $bookCustomRes->customId ?? 0; $customName = $bookCustomRes->customName ?? ''; $customNamePy = $bookCustomRes->customNamePy ?? ''; $orderSn = $bill->orderSn ?? ''; $event = "采购单 {$orderSn} 取消,{$name} 路上减少" . $delRoadNum . $bigUnit; } else { $event = ''; $customId = 0; $customName = ''; $customNamePy = ''; util::fail('此变动方式没有找到'); } $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' => $delRoadNum, 'num' => $bookCustomRes->roadNum, 'event' => $event, 'staffId' => $staffId, 'staffName' => $staffName, 'remark' => '', ]; BookCustomRoadChangeClass::add($changeData, true); return $bookCustomRes; } public static function delNeedCgNum($bookCustomRes, $delNeedCgNum, $totalBookNum, $bill, $shop, $product, $params) { $bookCustomRes->needCgNum = bcsub($bookCustomRes->needCgNum, $delNeedCgNum); $bookCustomRes->save(); $bookItemCustomResId = $bookCustomRes->id ?? 0; $ioRes = $params['ioRes'] ?? null; $relatedId = $ioRes->id ?? 0; $itemId = $product->id ?? 0; $ptItemId = $product->itemId ?? 0; $name = $product->name ?? ''; $py = $product->py ?? ''; $bigUnit = $product->bigUnit ?? '扎'; $bookSn = $shop->bookSn ?? ''; $mainId = $shop->mainId ?? 0; $currentCapitalType = dict::getDict('capitalType', 'delBook'); $staffName = $params['staffName'] ?? ''; $staffId = $params['staffId'] ?? 0; $currentChangeType = $params['currentChangeType'] ?? 'delBook'; if ($currentChangeType == 'addCg') { $currentCapitalType = dict::getDict('capitalType', 'ghsPurchase'); $customId = $bookCustomRes->customId ?? 0; $customName = $bookCustomRes->name ?? ''; $customNamePy = $bookCustomRes->py ?? ''; $orderSn = $bill->orderSn ?? ''; $event = $staffName . "增加待入库单 {$orderSn} 减少待采 {$name} " . $delNeedCgNum . $bigUnit; } elseif ($currentChangeType == 'pdAddStock') { $customId = 0; $customName = ''; $customNamePy = ''; $currentCapitalType = dict::getDict('capitalType', 'pd'); $event = $staffName . '盘点增加库存' . $delNeedCgNum . $bigUnit . ',减少待采' . $delNeedCgNum . $bigUnit; } elseif ($currentChangeType == 'loanStock') { $currentCapitalType = dict::getDict('capitalType', 'loanStock'); $customId = $bookCustomRes->customId ?? 0; $customName = $bookCustomRes->name ?? ''; $customNamePy = $bookCustomRes->py ?? ''; $outName = $params['outName'] ?? ''; $event = $staffName . '向' . $outName . '借库存' . $delNeedCgNum . $bigUnit . ',减少待采' . $delNeedCgNum . $bigUnit; } elseif ($currentChangeType == 'delBook') { $currentCapitalType = dict::getDict('capitalType', 'delBook'); $customId = $bill->customId ?? 0; $customName = $bill->customName ?? ''; $customNamePy = $bill->customNamePy ?? ''; $event = $customName . '减少预订' . $name . $totalBookNum . $bigUnit . ',其中减少待采' . $delNeedCgNum . $bigUnit; } else { $customId = 0; $customName = ''; $customNamePy = ''; $event = ''; util::fail('没有找到的操作'); } $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' => $delNeedCgNum, 'num' => $bookCustomRes->needCgNum, 'event' => $event, 'staffId' => $staffId, 'staffName' => $staffName, 'remark' => '', ]; BookCustomCgChangeClass::add($changeData, true); return $bookCustomRes; } public static function addBookNum($bookCustomRes, $num, $order, $shop, $product, $params) { $currentNum = bcadd($bookCustomRes->bookNum, $num); $bookCustomRes->bookNum = $currentNum; $bookCustomRes->box = 0; $bookCustomRes->save(); $bookItemCustomResId = $bookCustomRes->id ?? 0; $ioRes = $params['ioRes'] ?? 0; $relatedId = $ioRes->id ?? 0; //预订增加变动记录 $itemId = $product->id ?? 0; $ptItemId = $product->itemId ?? 0; $name = $product->name ?? ''; $py = $product->py ?? ''; $bigUnit = $product->bigUnit ?? '扎'; $bookSn = $shop->bookSn ?? ''; $mainId = $order->mainId ?? 0; $customId = $order->customId ?? 0; $customName = $order->customName ?? ''; $customNamePy = $order->customNamePy ?? ''; $currentCapitalType = dict::getDict('capitalType', 'addBook'); $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' => 1, 'changeNum' => $num, 'num' => $bookCustomRes->bookNum, 'event' => $event, 'staffId' => $staffId, 'staffName' => $staffName, 'remark' => '', ]; BookCustomChangeClass::add($changeData, true); return $bookCustomRes; } public static function addNeedCgNum($bookCustomRes, $addNeedCgNum, $num, $bill, $shop, $product, $params) { $bookCustomRes->needCgNum = bcadd($bookCustomRes->needCgNum, $addNeedCgNum); $bookCustomRes->save(); $bookCustomResId = $bookCustomRes->id ?? 0; $ioRes = $params['ioRes'] ?? 0; $relatedId = $ioRes->id ?? 0; //待采增加变动记录 $itemId = $product->id ?? 0; $ptItemId = $product->itemId ?? 0; $name = $product->name ?? ''; $py = $product->py ?? ''; $bigUnit = $product->bigUnit ?? '扎'; $bookSn = $shop->bookSn ?? ''; $mainId = $shop->mainId ?? 0; $staffName = $params['staffName'] ?? ''; $staffId = $params['staffId'] ?? 0; $currentChangeType = $params['currentChangeType'] ?? 'addBook'; if ($currentChangeType == 'cgCancel') { $currentCapitalType = dict::getDict('capitalType', 'ghsCgCancel'); $customId = $bookCustomRes->customId ?? 0; $customName = $bookCustomRes->name ?? ''; $customNamePy = $bookCustomRes->py ?? ''; $orderSn = $bill->orderSn ?? ''; $event = "采购单 {$orderSn} 取消,{$name} 增加待采" . $addNeedCgNum . $bigUnit; } elseif ($currentChangeType == 'addBook') { $currentCapitalType = dict::getDict('capitalType', 'addBook'); $customId = $bill->customId ?? 0; $customName = $bill->customName ?? ''; $customNamePy = $bill->customNamePy ?? ''; $event = $customName . '预订 ' . $name . $num . $bigUnit . ',增加待采' . $addNeedCgNum . $bigUnit; } else { $currentCapitalType = dict::getDict('capitalType', 'addBook'); $customId = 0; $customName = ''; $customNamePy = ''; $event = ''; util::fail('无效动作哈...'); } $changeData = [ 'mainId' => $mainId, 'bookSn' => $bookSn, 'name' => $name, 'py' => $py, 'itemId' => $itemId, 'ptItemId' => $ptItemId, 'customId' => $customId, 'customName' => $customName, 'customNamePy' => $customNamePy, 'relateId' => $relatedId, 'relateSecondId' => $bookCustomResId, 'ptStyle' => 2, 'capitalType' => $currentCapitalType, 'io' => 1, 'changeNum' => $addNeedCgNum, 'num' => $bookCustomRes->needCgNum, 'event' => $event, 'staffId' => $staffId, 'staffName' => $staffName, 'remark' => '', ]; BookCustomCgChangeClass::add($changeData, true); return $bookCustomRes; } }