|
|
@@ -5,6 +5,7 @@ namespace bizGhs\book\classes;
|
|
|
use bizGhs\base\classes\BaseClass;
|
|
|
use bizGhs\cg\classes\CgOrderItemClass;
|
|
|
use bizGhs\cg\classes\CgOrderItemSendClass;
|
|
|
+use bizGhs\shop\classes\ShopAdminClass;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
|
|
|
@@ -13,28 +14,28 @@ class BookItemGhsClass extends BaseClass
|
|
|
|
|
|
public static $baseFile = '\bizGhs\book\models\BookItemGhs';
|
|
|
|
|
|
- public static function delRoadNum($bookItemCustomRes, $totalNum)
|
|
|
+ public static function delRoadNum($bookItemCustomRes, $totalNum, $bookSn, $order)
|
|
|
{
|
|
|
$bookItemCustomResId = $bookItemCustomRes->id ?? 0;
|
|
|
$ghsList = self::getAllByCondition(['parentId' => $bookItemCustomResId], null, '*', null, true);
|
|
|
if (empty($ghsList)) {
|
|
|
util::fail('预订减少删路上数时,没找到供货');
|
|
|
}
|
|
|
- foreach ($ghsList as $ghsInfo) {
|
|
|
- $status = $ghsInfo->status ?? 0;
|
|
|
+ foreach ($ghsList as $ghsRes) {
|
|
|
+ $status = $ghsRes->status ?? 0;
|
|
|
if ($status != 0) {
|
|
|
continue;
|
|
|
}
|
|
|
if ($totalNum <= 0) {
|
|
|
break;
|
|
|
}
|
|
|
- $num = $ghsInfo->num ?? 0;
|
|
|
- $cgSendId = $ghsInfo->cgSendId ?? 0;
|
|
|
+ $num = $ghsRes->num ?? 0;
|
|
|
+ $cgSendId = $ghsRes->cgSendId ?? 0;
|
|
|
$send = CgOrderItemSendClass::getById($cgSendId, true);
|
|
|
if (empty($send)) {
|
|
|
util::fail('预订减少删路上数时,没找到供货2');
|
|
|
}
|
|
|
-
|
|
|
+ $cgOrderId = $send->parentOrderId ?? 0;
|
|
|
$cgOrderItemId = $send->parentId ?? 0;
|
|
|
$cgOrderItemRes = CgOrderItemClass::getById($cgOrderItemId, true);
|
|
|
if (empty($cgOrderItemRes)) {
|
|
|
@@ -48,12 +49,12 @@ class BookItemGhsClass extends BaseClass
|
|
|
}
|
|
|
$totalNum = bcsub($totalNum, $delNum);
|
|
|
|
|
|
- $ghsRemainNum = bcsub($ghsInfo->num, $delNum);
|
|
|
- $ghsInfo->num = $ghsRemainNum;
|
|
|
+ $ghsRemainNum = bcsub($ghsRes->num, $delNum);
|
|
|
+ $ghsRes->num = $ghsRemainNum;
|
|
|
if ($ghsRemainNum <= 0) {
|
|
|
- $ghsInfo->status = 2;
|
|
|
+ $ghsRes->status = 2;
|
|
|
}
|
|
|
- $ghsInfo->save();
|
|
|
+ $ghsRes->save();
|
|
|
|
|
|
$sendRemainNum = bcsub($send->num, $delNum);
|
|
|
$send->num = $sendRemainNum;
|
|
|
@@ -70,8 +71,19 @@ class BookItemGhsClass extends BaseClass
|
|
|
$cgOrderItemRes->confirmSendNum = $lastConfirm;
|
|
|
$cgOrderItemRes->save();
|
|
|
|
|
|
- // todo 通知页面要刷新货位!!!!!!!!!!!!!!!!!
|
|
|
-
|
|
|
+ // todo 通知采购单页要刷新货位
|
|
|
+ $cacheKey = 'ghs_cg_order_staff_refresh_seat_' . $bookSn;
|
|
|
+ $mainId = $order->mainId ?? 0;
|
|
|
+ $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
|
|
|
+ if (!empty($staffList)) {
|
|
|
+ foreach ($staffList as $staff) {
|
|
|
+ $staffId = $staff->id ?? 0;
|
|
|
+ $params = $cgOrderId . '-' . $staffId;
|
|
|
+ Yii::$app->redis->executeCommand('SADD', [$cacheKey, $params]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $cacheKey = 'ghs_cg_order_guest_refresh_seat_' . $bookSn;
|
|
|
+ Yii::$app->redis->executeCommand('SADD', [$cacheKey, $cgOrderId]);
|
|
|
}
|
|
|
}
|
|
|
|