|
|
@@ -17,7 +17,7 @@ class BookItemClass extends BaseClass
|
|
|
|
|
|
public static $baseFile = '\bizGhs\book\models\BookItem';
|
|
|
|
|
|
- public static function delBathItem($batchData, $order)
|
|
|
+ public static function delBathItem($batchData, $order, $params = [])
|
|
|
{
|
|
|
$shopId = $order->shopId ?? 0;
|
|
|
$shop = ShopClass::getById($shopId, true);
|
|
|
@@ -83,12 +83,8 @@ class BookItemClass extends BaseClass
|
|
|
];
|
|
|
$bookItemCustomRes = BookItemCustomClass::add($currentData, true);
|
|
|
}
|
|
|
- $thisNum = bcsub($bookItemCustomRes->bookNum, $num);
|
|
|
- if ($thisNum < 0) {
|
|
|
- util::unlock($cacheKey);
|
|
|
- util::fail($customName . '预订的' . $name . '不够减 bookItemCustom');
|
|
|
- }
|
|
|
- $bookItemCustomRes->bookNum = $thisNum;
|
|
|
+ $params['cacheKey'] = $cacheKey;
|
|
|
+ $bookItemCustomRes = BookItemCustomClass::delBookNum($bookItemCustomRes, $num, $order, $shop, $product, $params);
|
|
|
|
|
|
$bookItemRes = self::getByCondition(['bookSn' => $bookSn, 'itemId' => $itemId,], true);
|
|
|
if (empty($bookItemRes)) {
|
|
|
@@ -104,12 +100,7 @@ class BookItemClass extends BaseClass
|
|
|
];
|
|
|
$bookItemRes = self::add($statData, true);
|
|
|
}
|
|
|
- $currentNum = bcsub($bookItemRes->bookNum, $num);
|
|
|
- if ($currentNum < 0) {
|
|
|
- util::unlock($cacheKey);
|
|
|
- util::fail($customName . '预订的' . $name . '不够减哦 bookItem');
|
|
|
- }
|
|
|
- $bookItemRes->bookNum = $currentNum;
|
|
|
+ $bookItemRes = self::delBookNum($bookItemRes, $num, $order, $shop, $product, $params);
|
|
|
|
|
|
$bookCustomRes = BookCustomClass::getByCondition(['bookSn' => $bookSn, 'customId' => $customId], true);
|
|
|
if (empty($bookCustomRes)) {
|
|
|
@@ -122,12 +113,7 @@ class BookItemClass extends BaseClass
|
|
|
];
|
|
|
$bookCustomRes = BookCustomClass::add($currentData, true);
|
|
|
}
|
|
|
- $nowNum = bcsub($bookCustomRes->bookNum, $num);
|
|
|
- if ($nowNum < 0) {
|
|
|
- util::unlock($cacheKey);
|
|
|
- util::fail($customName . '预订的' . $name . '不够减哈 bookCustom');
|
|
|
- }
|
|
|
- $bookCustomRes->bookNum = $nowNum;
|
|
|
+ $bookCustomRes = BookCustomChangeClass::delBookNum($bookCustomRes, $num, $order, $shop, $product, $params);
|
|
|
|
|
|
$firstRemainSubNum = 0;
|
|
|
if ($bookItemCustomRes->needCgNum >= $num) {
|
|
|
@@ -138,13 +124,10 @@ class BookItemClass extends BaseClass
|
|
|
//待采数量不够扣
|
|
|
$firstRemainSubNum = bcsub($num, $firstNeedSubNum);
|
|
|
}
|
|
|
- $bookItemCustomRes->needCgNum = bcsub($bookItemCustomRes->needCgNum, $firstNeedSubNum);
|
|
|
- $bookItemRes->needCgNum = bcsub($bookItemRes->needCgNum, $firstNeedSubNum);
|
|
|
- $bookCustomRes->needCgNum = bcsub($bookCustomRes->needCgNum, $firstNeedSubNum);
|
|
|
+ $bookItemRes = self::delNeedCgNum($bookItemRes, $firstNeedSubNum, $num, $order, $shop, $product, $params);
|
|
|
+ $bookCustomRes = BookCustomClass::delNeedCgNum($bookCustomRes, $firstNeedSubNum, $num, $order, $shop, $product, $params);
|
|
|
+ $bookItemCustomRes = BookItemCustomClass::delNeedCgNum($bookItemCustomRes, $firstNeedSubNum, $num, $order, $shop, $product, $params);
|
|
|
if ($firstRemainSubNum <= 0) {
|
|
|
- $bookItemCustomRes->save();
|
|
|
- $bookItemRes->save();
|
|
|
- $bookCustomRes->save();
|
|
|
util::unlock($cacheKey);
|
|
|
continue;
|
|
|
}
|
|
|
@@ -157,17 +140,19 @@ class BookItemClass extends BaseClass
|
|
|
$secondNeedSubNum = $bookItemCustomRes->roadNum;
|
|
|
$secondRemainSubNum = bcsub($firstRemainSubNum, $secondNeedSubNum);
|
|
|
}
|
|
|
+
|
|
|
$bookItemCustomRes->roadNum = bcsub($bookItemCustomRes->roadNum, $secondNeedSubNum);
|
|
|
$bookItemRes->roadNum = bcsub($bookItemRes->roadNum, $secondNeedSubNum);
|
|
|
$bookCustomRes->roadNum = bcsub($bookCustomRes->roadNum, $secondNeedSubNum);
|
|
|
|
|
|
+ $bookItemRes = self::delRoadNum($bookItemRes, $secondNeedSubNum, $num, $order, $shop, $product, $params);
|
|
|
+ $bookItemCustomRes = BookItemCustomClass::delRoadNum($bookItemCustomRes, $secondNeedSubNum, $num, $order, $shop, $product, $params);
|
|
|
+ $bookCustomRes = BookCustomClass::delRoadNum($bookCustomRes, $secondNeedSubNum, $num, $order, $shop, $product, $params);
|
|
|
+
|
|
|
//删除供货商的路上数量!!!
|
|
|
BookItemGhsClass::delRoadNum($bookItemCustomRes, $secondNeedSubNum, $bookSn, $order);
|
|
|
|
|
|
if ($secondRemainSubNum <= 0) {
|
|
|
- $bookItemCustomRes->save();
|
|
|
- $bookItemRes->save();
|
|
|
- $bookCustomRes->save();
|
|
|
util::unlock($cacheKey);
|
|
|
continue;
|
|
|
}
|
|
|
@@ -180,17 +165,15 @@ class BookItemClass extends BaseClass
|
|
|
$thirdNeedSubNum = $bookItemCustomRes->onNum;
|
|
|
$thirdRemainSubNum = bcsub($secondRemainSubNum, $thirdNeedSubNum);
|
|
|
}
|
|
|
- $bookItemCustomRes->onNum = bcsub($bookItemCustomRes->onNum, $thirdNeedSubNum);
|
|
|
- $bookItemRes->onNum = bcsub($bookItemRes->onNum, $thirdNeedSubNum);
|
|
|
- $bookCustomRes->onNum = bcsub($bookCustomRes->onNum, $thirdNeedSubNum);
|
|
|
+
|
|
|
+ $bookItemRes = self::delOnNum($bookItemRes, $thirdNeedSubNum, $num, $order, $shop, $product, $params);
|
|
|
+ $bookItemCustomRes = BookItemCustomClass::delOnNum($bookItemCustomRes, $thirdNeedSubNum, $num, $order, $shop, $product, $params);
|
|
|
+ $bookCustomRes = BookCustomClass::delOnNum($bookCustomRes, $thirdNeedSubNum, $num, $order, $shop, $product, $params);
|
|
|
|
|
|
//预订减少造成下架而产生通知
|
|
|
NotifyClass::bookReduceOutItem($bookItemCustomRes, $thirdNeedSubNum, $shop);
|
|
|
|
|
|
if ($thirdRemainSubNum <= 0) {
|
|
|
- $bookItemCustomRes->save();
|
|
|
- $bookItemRes->save();
|
|
|
- $bookCustomRes->save();
|
|
|
util::unlock($cacheKey);
|
|
|
continue;
|
|
|
}
|
|
|
@@ -203,7 +186,7 @@ class BookItemClass extends BaseClass
|
|
|
}
|
|
|
|
|
|
//批量添加预订花材 ssh 20240711
|
|
|
- public static function addBatchItem($batchData, $order,$params=[])
|
|
|
+ public static function addBatchItem($batchData, $order, $params = [])
|
|
|
{
|
|
|
$shopId = $order->shopId ?? 0;
|
|
|
$shop = ShopClass::getById($shopId, true);
|
|
|
@@ -277,8 +260,8 @@ class BookItemClass extends BaseClass
|
|
|
//新增待采数量 = 预订数量 - 超出库存
|
|
|
$needCgNumValue = bcsub($num, $overNum);
|
|
|
$addNeedCgNum = $needCgNumValue < 0 ? 0 : $needCgNumValue;
|
|
|
- $bookItemRes = self::addBookNum($bookItemRes,$num,$order,$shop,$product,$params);
|
|
|
- self::addNeedCgNum($bookItemRes,$addNeedCgNum,$num,$order,$shop,$product,$params);
|
|
|
+ $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)) {
|
|
|
@@ -298,8 +281,8 @@ class BookItemClass extends BaseClass
|
|
|
];
|
|
|
$bookItemCustomRes = BookItemCustomClass::add($currentData, true);
|
|
|
}
|
|
|
- $bookItemCustomRes = BookItemCustomClass::addBookNum($bookItemCustomRes,$num,$order,$shop,$product,$params);
|
|
|
- BookItemCustomClass::addNeedCgNum($bookItemCustomRes,$addNeedCgNum,$num,$order,$shop,$product,$params);
|
|
|
+ $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)) {
|
|
|
@@ -324,98 +307,295 @@ class BookItemClass extends BaseClass
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static function addBookNum($bookItemRes,$num,$order,$shop,$product,$params)
|
|
|
+ public static function addBookNum($bookItemRes, $num, $order, $shop, $product, $params)
|
|
|
{
|
|
|
$currentNum = bcadd($bookItemRes->bookNum, $num);
|
|
|
$bookItemRes->bookNum = $currentNum;
|
|
|
$bookItemRes->save();
|
|
|
- $bookItemResId = $bookItemRes->id??0;
|
|
|
+ $bookItemResId = $bookItemRes->id ?? 0;
|
|
|
|
|
|
//预订增加变动记录
|
|
|
- $itemId = $product->id??0;
|
|
|
+ $itemId = $product->id ?? 0;
|
|
|
$ptItemId = $product->itemId ?? 0;
|
|
|
$name = $product->name ?? '';
|
|
|
$py = $product->py ?? '';
|
|
|
- $bigUnit = $product->bigUnit??'扎';
|
|
|
+ $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;
|
|
|
+ $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 delOnNum($bookItemRes,$delOnNum, $num, $order, $shop, $product, $params)
|
|
|
+ {
|
|
|
+ $bookItemRes->onNum = bcsub($bookItemRes->onNum, $delOnNum);
|
|
|
+ $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', 'delBook');
|
|
|
+ $staffName = $params['staffName'] ?? '';
|
|
|
+ $staffId = $params['staffId'] ?? 0;
|
|
|
+ $event = $customName . '减少预订' . $name . $num . $bigUnit . ',其中下架' . $delOnNum . $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'=>'',
|
|
|
+ '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' => 0,
|
|
|
+ 'changeNum' => $delOnNum,
|
|
|
+ 'num' => $bookItemRes->onNum,
|
|
|
+ 'event' => $event,
|
|
|
+ 'staffId' => $staffId,
|
|
|
+ 'staffName' => $staffName,
|
|
|
+ 'remark' => '',
|
|
|
];
|
|
|
- BookChangeGlobalClass::add($changeData,true);
|
|
|
+ BookOnChangeGlobalClass::add($changeData, true);
|
|
|
return $bookItemRes;
|
|
|
}
|
|
|
|
|
|
- public static function addNeedCgNum($bookItemRes,$addNeedCgNum,$totalBookNum,$order,$shop,$product,$params)
|
|
|
+ public static function delRoadNum($bookItemRes, $delRoadNum, $num, $order, $shop, $product, $params)
|
|
|
+ {
|
|
|
+ $bookItemRes->roadNum = bcsub($bookItemRes->roadNum, $delRoadNum);
|
|
|
+ $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', 'delBook');
|
|
|
+ $staffName = $params['staffName'] ?? '';
|
|
|
+ $staffId = $params['staffId'] ?? 0;
|
|
|
+ $event = $customName . '减少预订' . $name . $num . $bigUnit . ',其中减少路上' . $delRoadNum . $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' => 0,
|
|
|
+ 'changeNum' => $delRoadNum,
|
|
|
+ 'num' => $bookItemRes->roadNum,
|
|
|
+ 'event' => $event,
|
|
|
+ 'staffId' => $staffId,
|
|
|
+ 'staffName' => $staffName,
|
|
|
+ 'remark' => '',
|
|
|
+ ];
|
|
|
+ BookRoadChangeGlobalClass::add($changeData, true);
|
|
|
+ return $bookItemRes;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function delNeedCgNum($bookItemRes, $delNeedCgNum, $totalBookNum, $order, $shop, $product, $params)
|
|
|
+ {
|
|
|
+ $bookItemRes->needCgNum = bcsub($bookItemRes->needCgNum, $delNeedCgNum);
|
|
|
+ $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 . ',其中减少待采' . $delNeedCgNum . $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' => 0,
|
|
|
+ 'changeNum' => $delNeedCgNum,
|
|
|
+ 'num' => $bookItemRes->needCgNum,
|
|
|
+ 'event' => $event,
|
|
|
+ 'staffId' => $staffId,
|
|
|
+ 'staffName' => $staffName,
|
|
|
+ 'remark' => '',
|
|
|
+ ];
|
|
|
+ BookCgChangeGlobalClass::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;
|
|
|
+ $bookItemResId = $bookItemRes->id ?? 0;
|
|
|
|
|
|
//预订增加变动记录
|
|
|
- $itemId = $product->id??0;
|
|
|
+ $itemId = $product->id ?? 0;
|
|
|
$ptItemId = $product->itemId ?? 0;
|
|
|
$name = $product->name ?? '';
|
|
|
$py = $product->py ?? '';
|
|
|
- $bigUnit = $product->bigUnit??'扎';
|
|
|
+ $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;
|
|
|
+ $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;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function delBookNum($bookItemRes, $num, $order, $shop, $product, $params)
|
|
|
+ {
|
|
|
+ $mainId = $order->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 ?? '';
|
|
|
+
|
|
|
+ $currentNum = bcsub($bookItemRes->bookNum, $num);
|
|
|
+ if ($currentNum < 0) {
|
|
|
+ $cacheKey = $params['cacheKey'] ?? '';
|
|
|
+ if (!empty($cacheKey)) {
|
|
|
+ util::unlock($cacheKey);
|
|
|
+ }
|
|
|
+ util::fail($customName . '预订的' . $name . '不够减 bookItemCustom');
|
|
|
+ }
|
|
|
+ $bookItemRes->bookNum = $currentNum;
|
|
|
+ $bookItemRes->save();
|
|
|
+ $bookItemCustomResId = $bookItemRes->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'=>$bookItemResId,
|
|
|
- 'relateSecondId'=>0,
|
|
|
- 'ptStyle'=>2,
|
|
|
- 'capitalType'=>$currentCapitalType,
|
|
|
- 'io'=>1,
|
|
|
- 'changeNum'=>$addNeedCgNum,
|
|
|
- 'num'=>$bookItemRes->needCgNum,
|
|
|
- 'event'=>$event,
|
|
|
- 'staffId'=>$staffId,
|
|
|
- 'staffName'=>$staffName,
|
|
|
- 'remark'=>'',
|
|
|
+ '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' => 0,
|
|
|
+ 'changeNum' => $num,
|
|
|
+ 'num' => $bookItemRes->bookNum,
|
|
|
+ 'event' => $event,
|
|
|
+ 'staffId' => $staffId,
|
|
|
+ 'staffName' => $staffName,
|
|
|
+ 'remark' => '',
|
|
|
];
|
|
|
- BookCgChangeGlobalClass::add($changeData,true);
|
|
|
+ BookChangeGlobalClass::add($changeData, true);
|
|
|
return $bookItemRes;
|
|
|
}
|
|
|
|