|
|
@@ -22,6 +22,7 @@ use bizHd\admin\classes\ShopAdminClass;
|
|
|
use bizHd\base\services\BaseService;
|
|
|
use bizHd\purchase\classes\PurchaseClass;
|
|
|
use bizHd\purchase\classes\PurchaseItemClass;
|
|
|
+use bizHd\shop\classes\MainClass;
|
|
|
use common\components\dict;
|
|
|
use common\components\imgUtil;
|
|
|
use common\components\noticeUtil;
|
|
|
@@ -337,20 +338,25 @@ class PurchaseService extends BaseService
|
|
|
if (empty($shop)) {
|
|
|
util::fail('没有找到门店');
|
|
|
}
|
|
|
+ $mainId = $shop->mainId ?? 0;
|
|
|
+ $main = MainClass::getLockById($mainId);
|
|
|
+ if (empty($main)) {
|
|
|
+ util::fail('没有main信息');
|
|
|
+ }
|
|
|
$realPrice = $info->realPrice;
|
|
|
$actPrice = $info->actPrice;
|
|
|
//余额支付引起余额减少
|
|
|
if ($payWay == dict::getDict('payWay', 'balancePay')) {
|
|
|
- ShopClass::purchaseReduceBalance($shop, $realPrice, $info);
|
|
|
+ ShopClass::purchaseReduceBalance($shop, $realPrice, $info);//////////////////////////////////////////////////////////
|
|
|
}
|
|
|
- $shop->totalPurchase = bcadd($shop->totalPurchase, $actPrice, 2);
|
|
|
- $currentExpend = bcadd($shop->totalExpend, $actPrice, 2);
|
|
|
- $shop->totalExpend = $currentExpend;
|
|
|
- $shop->cgUnPay -= 1;
|
|
|
+ $main->totalPurchase = bcadd($main->totalPurchase, $actPrice, 2);
|
|
|
+ $currentExpend = bcadd($main->totalExpend, $actPrice, 2);
|
|
|
+ $main->totalExpend = $currentExpend;
|
|
|
+ $main->cgUnPay -= 1;
|
|
|
if ($book == 1) {
|
|
|
- $shop->cgUnSend += 1;
|
|
|
+ $main->cgUnSend += 1;
|
|
|
} else {
|
|
|
- $shop->cgFinish += 1;
|
|
|
+ $main->cgFinish += 1;
|
|
|
|
|
|
//加库存 lqh 2021-05-10
|
|
|
$orderSn = $info->orderSn;
|
|
|
@@ -380,10 +386,10 @@ class PurchaseService extends BaseService
|
|
|
$currentMayPay = bcadd($shop->mayPay, $realPrice, 2);
|
|
|
$shop->mayPay = $currentMayPay;
|
|
|
}
|
|
|
- $shop->save();
|
|
|
+ $main->save();
|
|
|
|
|
|
//支出统计
|
|
|
- StatOutClass::updateOrInsert($shop, $info->orderPrice);
|
|
|
+ StatOutClass::updateOrInsert($shop, $info->orderPrice);///////////////////////////////////////////////////
|
|
|
//支出流水
|
|
|
$capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
|
|
|
$sjId = $info->sjId ?? 0;
|
|
|
@@ -403,11 +409,11 @@ class PurchaseService extends BaseService
|
|
|
|
|
|
//采购总量统计
|
|
|
$cgNum = $info->bigNum ?? 0;
|
|
|
- StatCgClass::replace($shop, $info->orderPrice, $cgNum);
|
|
|
+ StatCgClass::replace($shop, $info->orderPrice, $cgNum);//////////////////////////////////////////////////////
|
|
|
//按供货商分别统计采购量
|
|
|
$num = $info->bigNum ?? 0;
|
|
|
$amount = $info->orderPrice ?? 0;
|
|
|
- StatCgGhsClass::hdCgGhsReplace(true,$info, $amount, $num);
|
|
|
+ StatCgGhsClass::hdCgGhsReplace(true, $info, $amount, $num);
|
|
|
|
|
|
//供应商资产变化
|
|
|
$ghsId = $info->ghsId ?? 0;
|
|
|
@@ -426,7 +432,7 @@ class PurchaseService extends BaseService
|
|
|
if (isset($info->ghsShopAdminId) && !empty($info->ghsShopAdminId)) {
|
|
|
$noNeedWxNotice = isset(Yii::$app->params['noNeedWxNotice']) ? Yii::$app->params['noNeedWxNotice'] : 0;
|
|
|
if ($noNeedWxNotice == 0) {
|
|
|
- WxMessageClass::generateCgOrder($shop, $info);
|
|
|
+ WxMessageClass::generateCgOrder($shop, $info);///////////////////////////////////////////////////////////////
|
|
|
}
|
|
|
}
|
|
|
|