|
|
@@ -16,6 +16,7 @@ use bizGhs\order\classes\OrderClass;
|
|
|
use bizGhs\order\classes\OrderExpressClass;
|
|
|
use bizGhs\order\classes\OrderSendClass;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
+use bizGhs\shop\classes\MainClass;
|
|
|
use bizGhs\stat\classes\StatYjClass;
|
|
|
use bizGhs\ws\services\WsService;
|
|
|
use bizHd\cg\services\CgRefundService;
|
|
|
@@ -656,28 +657,33 @@ class OrderService extends BaseService
|
|
|
if (empty($shop)) {
|
|
|
util::fail('没有找到门店');
|
|
|
}
|
|
|
- $shop->unPayOrder -= 1;
|
|
|
+ $mainId = $shop->mainId ?? 0;
|
|
|
+ $main = MainClass::getLockById($mainId);
|
|
|
+ if (empty($main)) {
|
|
|
+ util::fail('没有main信息');
|
|
|
+ }
|
|
|
+ $main->unPayOrder -= 1;
|
|
|
//预订单的待发货订单增加
|
|
|
if ($book == 1) {
|
|
|
- $shop->unSendOrder += 1;
|
|
|
+ $main->unSendOrder += 1;
|
|
|
} else {
|
|
|
- $shop->finishOrder += 1;
|
|
|
+ $main->finishOrder += 1;
|
|
|
}
|
|
|
- $shop->totalOrderNum += 1;
|
|
|
- $currentTotalIncome = bcadd($shop->totalIncome, $amount, 2);
|
|
|
- $shop->totalIncome = $currentTotalIncome;
|
|
|
- $totalSale = bcadd($shop->totalSale, $amount, 2);
|
|
|
- $shop->totalSale = $totalSale;
|
|
|
+ $main->totalOrderNum += 1;
|
|
|
+ $currentTotalIncome = bcadd($main->totalIncome, $amount, 2);
|
|
|
+ $main->totalIncome = $currentTotalIncome;
|
|
|
+ $totalSale = bcadd($main->totalSale, $amount, 2);
|
|
|
+ $main->totalSale = $totalSale;
|
|
|
if ($payWay == dict::getDict('payWay', 'debtPay')) {
|
|
|
//客户欠款支付会增加【应收客户款】
|
|
|
- $currentGathering = bcadd($shop->mayGathering, $realPrice, 2);
|
|
|
- $shop->mayGathering = $currentGathering;
|
|
|
+ $currentGathering = bcadd($main->mayGathering, $realPrice, 2);
|
|
|
+ $main->mayGathering = $currentGathering;
|
|
|
//客户第一次欠款的增加一个欠款客户
|
|
|
if ($custom->debtNum == 0) {
|
|
|
- $shop->mayGatheringNum += 1;
|
|
|
+ $main->mayGatheringNum += 1;
|
|
|
}
|
|
|
}
|
|
|
- $shop->save();
|
|
|
+ $main->save();
|
|
|
|
|
|
$orderId = $order->id;
|
|
|
$capitalType = dict::getDict('capitalType', 'xhGhsOrder', 'id');
|
|
|
@@ -690,7 +696,6 @@ class OrderService extends BaseService
|
|
|
$event = $custom->name . '采购';
|
|
|
}
|
|
|
}
|
|
|
- $mainId = $shop->mainId ?? 0;
|
|
|
$sjId = $order->sjId ?? 0;
|
|
|
$shopId = $order->shopId ?? 0;
|
|
|
$capital = [
|
|
|
@@ -706,6 +711,7 @@ class OrderService extends BaseService
|
|
|
'shopId' => $shopId,
|
|
|
'shopAdminId' => $shopAdminId,
|
|
|
'shopAdminName' => $shopAdminName,
|
|
|
+ 'mainId' => $mainId,
|
|
|
];
|
|
|
ShopCapitalClass::addCapital($capital);
|
|
|
|
|
|
@@ -713,7 +719,7 @@ class OrderService extends BaseService
|
|
|
if ($isPurchase == true) {
|
|
|
//余额支付和在线支付(微信支付、支付宝支付)会增加余额
|
|
|
if ($order->onlinePay == dict::getDict('onlinePay', 'yes') || $payWay == dict::getDict('payWay', 'balancePay')) {
|
|
|
- ShopClass::customKdAddBalance($shop, $realPrice, $order, $capitalType);
|
|
|
+ ShopClass::customKdAddBalance($main, $shop, $realPrice, $order, $capitalType);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -754,13 +760,13 @@ class OrderService extends BaseService
|
|
|
$custom->save();
|
|
|
|
|
|
//收入统计
|
|
|
- StatIncomeClass::updateOrInsert($shop, $amount);
|
|
|
+ StatIncomeClass::updateOrInsert($main, $shop, $amount);
|
|
|
//各渠道收入金额统计
|
|
|
StatKdClass::replace($shop, $amount, $payWay);
|
|
|
//今日订单+1
|
|
|
- StatOrderClass::updateOrInsert($shop);
|
|
|
+ StatOrderClass::updateOrInsert($main, $shop);
|
|
|
//销售统计
|
|
|
- StatSaleClass::replace($shop, $amount);
|
|
|
+ StatSaleClass::replace($main, $shop, $amount);
|
|
|
//客户采购统计
|
|
|
StatKhCgClass::replace($order, $amount);
|
|
|
|