|
|
@@ -272,39 +272,8 @@ class BookItemClass extends BaseClass
|
|
|
//新增待采数量 = 预订数量 - 超出库存
|
|
|
$needCgNumValue = bcsub($num, $overNum);
|
|
|
$addNeedCgNum = $needCgNumValue < 0 ? 0 : $needCgNumValue;
|
|
|
- $currentNum = bcadd($bookItemRes->bookNum, $num);
|
|
|
- $bookItemRes->bookNum = $currentNum;
|
|
|
- $bookItemRes->needCgNum = bcadd($bookItemRes->needCgNum, $addNeedCgNum);
|
|
|
- $bookItemRes->save();
|
|
|
-
|
|
|
- //预订增加变动记录
|
|
|
- $currentCapitalType = dict::getDict('capitalType', 'addBook');
|
|
|
- $staffName = $params['staffName']??'';
|
|
|
- $staffId = $params['staffId']??0;
|
|
|
- $event = $customName.'预订'.$name.$num.'份';
|
|
|
- $globalChangeData = [
|
|
|
- 'mainId'=>$mainId,
|
|
|
- 'bookSn'=>$bookSn,
|
|
|
- 'name'=>$name,
|
|
|
- 'py'=>$py,
|
|
|
- 'itemId'=>$itemId,
|
|
|
- 'ptItemId'=>$ptItemId,
|
|
|
- 'customId'=>$customId,
|
|
|
- 'customName'=>$customName,
|
|
|
- 'customNamePy'=>$customNamePy,
|
|
|
- 'relateId'=>$bookItemResId,
|
|
|
- 'relateSecondId'=>0,
|
|
|
- 'ptStyle'=>2,
|
|
|
- 'capitalType'=>$currentCapitalType,
|
|
|
- 'io'=>1,
|
|
|
- 'changeNum'=>$num,
|
|
|
- 'num'=>$bookItemRes->bookNum,
|
|
|
- 'event'=>$event,
|
|
|
- 'staffId'=>$staffId,
|
|
|
- 'staffName'=>$staffName,
|
|
|
- 'remark'=>'',
|
|
|
- ];
|
|
|
- BookChangeGlobalClass::add($globalChangeData,true);
|
|
|
+ $bookItemRes = self::addBookNum($bookItemRes,$num,$order,$shop,$product,$params);
|
|
|
+ self::addNeedCgNum($bookItemRes,$addNeedCgNum,$num,$order,$shop,$product,$params);
|
|
|
|
|
|
$bookItemCustomRes = BookItemCustomClass::getByCondition(['mainId' => $mainId, 'bookSn' => $bookSn, 'customId' => $customId, 'itemId' => $itemId], true);
|
|
|
if (empty($bookItemCustomRes)) {
|
|
|
@@ -326,33 +295,8 @@ class BookItemClass extends BaseClass
|
|
|
}
|
|
|
$bookItemCustomResId = $bookItemCustomRes->id ?? 0;
|
|
|
$bookItemCustomRes = BookItemCustomClass::getLockById($bookItemCustomResId);
|
|
|
- $bookItemCustomRes->bookNum = bcadd($bookItemCustomRes->bookNum, $num);
|
|
|
- $bookItemCustomRes->needCgNum = bcadd($bookItemCustomRes->needCgNum, $addNeedCgNum);
|
|
|
- $bookItemCustomRes->save();
|
|
|
-
|
|
|
- $changeData = [
|
|
|
- 'mainId'=>$mainId,
|
|
|
- 'bookSn'=>$bookSn,
|
|
|
- 'name'=>$name,
|
|
|
- 'py'=>$py,
|
|
|
- 'itemId'=>$itemId,
|
|
|
- 'ptItemId'=>$ptItemId,
|
|
|
- 'customId'=>$customId,
|
|
|
- 'customName'=>$customName,
|
|
|
- 'customNamePy'=>$customNamePy,
|
|
|
- 'relateId'=>$bookItemCustomResId,
|
|
|
- 'relateSecondId'=>0,
|
|
|
- 'ptStyle'=>2,
|
|
|
- 'capitalType'=>$currentCapitalType,
|
|
|
- 'io'=>1,
|
|
|
- 'changeNum'=>$num,
|
|
|
- 'num'=>$bookItemCustomRes->bookNum,
|
|
|
- 'event'=>$event,
|
|
|
- 'staffId'=>$staffId,
|
|
|
- 'staffName'=>$staffName,
|
|
|
- 'remark'=>'',
|
|
|
- ];
|
|
|
- BookChangeClass::add($changeData,true);
|
|
|
+ $bookItemCustomRes = BookItemCustomClass::addBookNum($bookItemCustomRes,$num,$order,$shop,$product,$params);
|
|
|
+ BookItemCustomClass::addNeedCgNum($bookItemCustomRes,$addNeedCgNum,$num,$order,$shop,$product,$params);
|
|
|
|
|
|
$bookCustomRes = BookCustomClass::getByCondition(['mainId' => $mainId, 'bookSn' => $bookSn, 'customId' => $customId], true);
|
|
|
if (empty($bookCustomRes)) {
|
|
|
@@ -379,4 +323,99 @@ class BookItemClass extends BaseClass
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static function addBookNum($bookItemRes,$num,$order,$shop,$product,$params)
|
|
|
+ {
|
|
|
+ $currentNum = bcadd($bookItemRes->bookNum, $num);
|
|
|
+ $bookItemRes->bookNum = $currentNum;
|
|
|
+ $bookItemRes->save();
|
|
|
+ $bookItemResId = $bookItemRes->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'=>$bookItemResId,
|
|
|
+ 'relateSecondId'=>0,
|
|
|
+ 'ptStyle'=>2,
|
|
|
+ 'capitalType'=>$currentCapitalType,
|
|
|
+ 'io'=>1,
|
|
|
+ 'changeNum'=>$num,
|
|
|
+ 'num'=>$bookItemRes->bookNum,
|
|
|
+ 'event'=>$event,
|
|
|
+ 'staffId'=>$staffId,
|
|
|
+ 'staffName'=>$staffName,
|
|
|
+ 'remark'=>'',
|
|
|
+ ];
|
|
|
+ BookChangeGlobalClass::add($changeData,true);
|
|
|
+ return $bookItemRes;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function addNeedCgNum($bookItemRes,$addNeedCgNum,$totalBookNum,$order,$shop,$product,$params)
|
|
|
+ {
|
|
|
+ $bookItemRes->needCgNum = bcadd($bookItemRes->needCgNum, $addNeedCgNum);
|
|
|
+ $bookItemRes->save();
|
|
|
+ $bookItemResId = $bookItemRes->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.$totalBookNum.$bigUnit.',增加待采'.$addNeedCgNum.$bigUnit;
|
|
|
+ $changeData = [
|
|
|
+ 'mainId'=>$mainId,
|
|
|
+ 'bookSn'=>$bookSn,
|
|
|
+ 'name'=>$name,
|
|
|
+ 'py'=>$py,
|
|
|
+ 'itemId'=>$itemId,
|
|
|
+ 'ptItemId'=>$ptItemId,
|
|
|
+ 'customId'=>$customId,
|
|
|
+ 'customName'=>$customName,
|
|
|
+ 'customNamePy'=>$customNamePy,
|
|
|
+ 'relateId'=>$bookItemResId,
|
|
|
+ 'relateSecondId'=>0,
|
|
|
+ 'ptStyle'=>2,
|
|
|
+ 'capitalType'=>$currentCapitalType,
|
|
|
+ 'io'=>1,
|
|
|
+ 'changeNum'=>$addNeedCgNum,
|
|
|
+ 'num'=>$bookItemRes->needCgNum,
|
|
|
+ 'event'=>$event,
|
|
|
+ 'staffId'=>$staffId,
|
|
|
+ 'staffName'=>$staffName,
|
|
|
+ 'remark'=>'',
|
|
|
+ ];
|
|
|
+ BookCgChangeGlobalClass::add($changeData,true);
|
|
|
+ return $bookItemRes;
|
|
|
+ }
|
|
|
+
|
|
|
}
|