|
|
@@ -8,6 +8,7 @@ use biz\stat\classes\StatOutClass;
|
|
|
use biz\stat\classes\StatWastClass;
|
|
|
use bizGhs\order\traits\OrderTrait;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
+use bizGhs\shop\classes\MainClass;
|
|
|
use bizGhs\stock\classes\StockRecordClass;
|
|
|
use common\components\dict;
|
|
|
use common\components\orderSn;
|
|
|
@@ -78,6 +79,10 @@ class StockWastageOrderClass extends BaseClass
|
|
|
if (empty($shop)) {
|
|
|
util::fail('没有找到门店');
|
|
|
}
|
|
|
+ $main = MainClass::getLockById($mainId);
|
|
|
+ if (empty($main)) {
|
|
|
+ util::fail('没有main信息');
|
|
|
+ }
|
|
|
|
|
|
//计算成本价
|
|
|
$wastage = 0;
|
|
|
@@ -86,13 +91,13 @@ class StockWastageOrderClass extends BaseClass
|
|
|
$cost = $v['itemCost'] ?? 0;
|
|
|
$wastage = bcadd($wastage, bcmul($num, $cost, 2), 2);
|
|
|
}
|
|
|
- $currentTotalExpend = bcadd($shop->totalExpend, $wastage, 2);
|
|
|
- $shop->totalExpend = $currentTotalExpend;
|
|
|
- $currentWast = bcadd($shop->totalWast, $wastage, 2);
|
|
|
- $shop->totalWast = $currentWast;
|
|
|
- $shop->save();
|
|
|
+ $currentTotalExpend = bcadd($main->totalExpend, $wastage, 2);
|
|
|
+ $main->totalExpend = $currentTotalExpend;
|
|
|
+ $currentWast = bcadd($main->totalWast, $wastage, 2);
|
|
|
+ $main->totalWast = $currentWast;
|
|
|
+ $main->save();
|
|
|
|
|
|
- StatWastClass::replace($shop, $wastage);
|
|
|
+ StatWastClass::replace($main, $shop, $wastage);
|
|
|
|
|
|
return $order;
|
|
|
|