|
|
@@ -26,20 +26,20 @@ class BookItemCustomClass extends BaseClass
|
|
|
if (empty($bookItemRes)) {
|
|
|
util::fail('预订信息缺失');
|
|
|
}
|
|
|
- $onNum = $bookItemCustomRes->onNum??0;
|
|
|
- if($num>$onNum){
|
|
|
+ $onNum = $bookItemCustomRes->onNum ?? 0;
|
|
|
+ if ($num > $onNum) {
|
|
|
util::fail('下架数量超过已上架数');
|
|
|
}
|
|
|
$needOffNum = $num;
|
|
|
$params['currentChangeType'] = 'stockOff';
|
|
|
- $bookItemRes = BookItemClass::delOnNum($bookItemRes, $needOffNum, 0,null, $shop, $product, $params);
|
|
|
- $bookItemCustomRes = self::delOnNum($bookItemCustomRes, $needOffNum, 0,null, $shop, $product, $params);
|
|
|
- $customId = $bookItemCustomRes->customId??0;
|
|
|
- $bookCustomRes = BookCustomClass::getByCondition(['bookSn' => $bookSn,'customId'=>$customId],true);
|
|
|
- if(empty($bookCustomRes)){
|
|
|
+ $bookItemRes = BookItemClass::delOnNum($bookItemRes, $needOffNum, 0, null, $shop, $product, $params);
|
|
|
+ $bookItemCustomRes = self::delOnNum($bookItemCustomRes, $needOffNum, 0, null, $shop, $product, $params);
|
|
|
+ $customId = $bookItemCustomRes->customId ?? 0;
|
|
|
+ $bookCustomRes = BookCustomClass::getByCondition(['bookSn' => $bookSn, 'customId' => $customId], true);
|
|
|
+ if (empty($bookCustomRes)) {
|
|
|
util::fail('上架库存没有bookCustom...');
|
|
|
}
|
|
|
- $bookCustomRes = BookCustomClass::delOnNum($bookCustomRes,$needOffNum, 0,null, $shop, $product, $params);
|
|
|
+ $bookCustomRes = BookCustomClass::delOnNum($bookCustomRes, $needOffNum, 0, null, $shop, $product, $params);
|
|
|
}
|
|
|
|
|
|
//上架
|
|
|
@@ -64,15 +64,15 @@ class BookItemCustomClass extends BaseClass
|
|
|
$hasOnNum = $bookItemRes->onNum;
|
|
|
$stock = $product->stock ?? 0;
|
|
|
$couldOnNum = bcsub($stock, $hasOnNum);
|
|
|
- if($couldOnNum<0){
|
|
|
+ if ($couldOnNum < 0) {
|
|
|
util::fail('上架数量超过库存数量 bookItem');
|
|
|
}
|
|
|
if ($num > 0) {
|
|
|
//上指定数量
|
|
|
$needOnNum = $num;
|
|
|
$maxNum = bcsub($bookNum, $onNum);
|
|
|
- if($needOnNum>$maxNum){
|
|
|
- util::fail("只需要上".$maxNum.'份');
|
|
|
+ if ($needOnNum > $maxNum) {
|
|
|
+ util::fail("只需要上" . $maxNum . '份');
|
|
|
}
|
|
|
} else {
|
|
|
//上齐
|
|
|
@@ -84,31 +84,58 @@ class BookItemCustomClass extends BaseClass
|
|
|
$params['currentChangeType'] = 'stockOn';
|
|
|
$bookItemRes = BookItemClass::addOnNum($bookItemRes, $needOnNum, null, $shop, $product, $params);
|
|
|
$bookItemCustomRes = self::addOnNum($bookItemCustomRes, $needOnNum, null, $shop, $product, $params);
|
|
|
- $customId = $bookItemCustomRes->customId??0;
|
|
|
- $bookCustomRes = BookCustomClass::getByCondition(['bookSn' => $bookSn,'customId'=>$customId],true);
|
|
|
- if(empty($bookCustomRes)){
|
|
|
+ $customId = $bookItemCustomRes->customId ?? 0;
|
|
|
+ $bookCustomRes = BookCustomClass::getByCondition(['bookSn' => $bookSn, 'customId' => $customId], true);
|
|
|
+ if (empty($bookCustomRes)) {
|
|
|
util::fail('上架库存没有bookCustom...');
|
|
|
}
|
|
|
- $bookCustomRes = BookCustomClass::addOnNum($bookCustomRes,$needOnNum, null, $shop, $product, $params);
|
|
|
+ $bookCustomRes = BookCustomClass::addOnNum($bookCustomRes, $needOnNum, null, $shop, $product, $params);
|
|
|
}
|
|
|
|
|
|
- public static function cancelBox($book){
|
|
|
- $book->box = 0;
|
|
|
- $book->save();
|
|
|
- return $book;
|
|
|
+ public static function cancelBox($bookItemCustomRes)
|
|
|
+ {
|
|
|
+ $bookItemCustomRes->box = 0;
|
|
|
+ $bookItemCustomRes->save();
|
|
|
+ $bookSn = $bookItemCustomRes->bookSn ?? 0;
|
|
|
+ $customId = $bookItemCustomRes->customId ?? 0;
|
|
|
+ $bookCustomRes = BookCustomClass::getByCondition(['bookSn' => $bookSn, 'customId' => $customId], true);
|
|
|
+ if (!empty($bookCustomRes)) {
|
|
|
+ $bookCustomRes->box = 0;
|
|
|
+ $bookCustomRes->save();
|
|
|
+ }
|
|
|
+ return $bookItemCustomRes;
|
|
|
}
|
|
|
|
|
|
- public static function toBox($book)
|
|
|
+ public static function toBox($bookItemCustomRes)
|
|
|
{
|
|
|
- if ($book->box == 1) {
|
|
|
+ if ($bookItemCustomRes->box == 1) {
|
|
|
util::fail('已装过箱了');
|
|
|
}
|
|
|
- if ($book->bookNum != $book->onNum) {
|
|
|
+ if ($bookItemCustomRes->bookNum != $bookItemCustomRes->onNum) {
|
|
|
util::fail('上架数量不等于预订数量');
|
|
|
}
|
|
|
- $book->box = 1;
|
|
|
- $book->save();
|
|
|
- return $book;
|
|
|
+ $bookItemCustomRes->box = 1;
|
|
|
+ $bookItemCustomRes->save();
|
|
|
+
|
|
|
+ $bookSn = $bookItemCustomRes->bookSn ?? 0;
|
|
|
+ $customId = $bookItemCustomRes->customId ?? 0;
|
|
|
+ $list = BookItemCustomClass::getAllByCondition(['bookSn' => $bookSn, 'customId' => $customId,], null, '*', null, true);
|
|
|
+ $allHasBox = 1;
|
|
|
+ if (!empty($list)) {
|
|
|
+ foreach ($list as $info) {
|
|
|
+ if ($info->box == 0) {
|
|
|
+ $allHasBox = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($allHasBox == 1) {
|
|
|
+ $bookCustomRes = BookCustomClass::getByCondition(['bookSn' => $bookSn, 'customId' => $customId], true);
|
|
|
+ if (!empty($bookCustomRes)) {
|
|
|
+ $bookCustomRes->box = 1;
|
|
|
+ $bookCustomRes->save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $bookItemCustomRes;
|
|
|
}
|
|
|
|
|
|
public static function delOnNum($bookItemCustomRes, $delOnNum, $num, $bill, $shop, $product, $params)
|
|
|
@@ -146,7 +173,7 @@ class BookItemCustomClass extends BaseClass
|
|
|
$customName = $bookItemCustomRes->customName ?? '';
|
|
|
$customNamePy = $bookItemCustomRes->customNamePy ?? '';
|
|
|
$currentCapitalType = 0;
|
|
|
- $event = $staffName.'手动下架' .$name. $delOnNum . $bigUnit;
|
|
|
+ $event = $staffName . '手动下架' . $name . $delOnNum . $bigUnit;
|
|
|
} elseif ($currentChangeType == 'delBook') {
|
|
|
$customId = $bill->customId ?? 0;
|
|
|
$customName = $bill->customName ?? '';
|
|
|
@@ -406,8 +433,8 @@ class BookItemCustomClass extends BaseClass
|
|
|
$event = $staffName . "增加待入库单 {$orderSn} 减少待采 {$name} " . $delNeedCgNum . $bigUnit;
|
|
|
} elseif ($currentChangeType == 'loanStock') {
|
|
|
$currentCapitalType = dict::getDict('capitalType', 'loanStock');
|
|
|
- $outName = $params['outName']??'';
|
|
|
- $event = $staffName . '向' . $outName .'借库存'.$delNeedCgNum.$bigUnit.',减少待采' . $delNeedCgNum . $bigUnit;
|
|
|
+ $outName = $params['outName'] ?? '';
|
|
|
+ $event = $staffName . '向' . $outName . '借库存' . $delNeedCgNum . $bigUnit . ',减少待采' . $delNeedCgNum . $bigUnit;
|
|
|
} elseif ($currentChangeType == 'delBook') {
|
|
|
$currentCapitalType = dict::getDict('capitalType', 'delBook');
|
|
|
$event = $customName . '减少预订' . $name . $totalBookNum . $bigUnit . ',其中减少待采' . $delNeedCgNum . $bigUnit;
|
|
|
@@ -512,6 +539,7 @@ class BookItemCustomClass extends BaseClass
|
|
|
{
|
|
|
$currentNum = bcadd($bookItemCustomRes->bookNum, $num);
|
|
|
$bookItemCustomRes->bookNum = $currentNum;
|
|
|
+ $bookItemCustomRes->box = 0;
|
|
|
$bookItemCustomRes->save();
|
|
|
$bookItemCustomResId = $bookItemCustomRes->id ?? 0;
|
|
|
|