|
|
@@ -8,7 +8,10 @@ namespace bizHd\ghs\classes;
|
|
|
* 金额与 bizGhs\custom\classes\AccountMoneyClass 一致:写前 ensureGhsMoneyReady(仅行锁);
|
|
|
* 挂账=balance 减少,结账/退款=balance 增加;只记 GhsBalanceChange,不再新增 GhsDebtChange(历史仍可查)。
|
|
|
*/
|
|
|
+
|
|
|
use bizGhs\custom\classes\AccountMoneyClass;
|
|
|
+use bizGhs\custom\classes\CustomClass;
|
|
|
+use bizHd\purchase\classes\PurchaseClass;
|
|
|
use common\components\dict;
|
|
|
use common\components\noticeUtil;
|
|
|
use common\components\util;
|
|
|
@@ -20,6 +23,30 @@ class GhsClass extends BaseClass
|
|
|
|
|
|
public static $baseFile = '\bizHd\ghs\models\Ghs';
|
|
|
|
|
|
+ public static function checkBalance($ghs, $custom = null)
|
|
|
+ {
|
|
|
+ if (empty($custom)) {
|
|
|
+ $customId = $ghs->customId ?? 0;
|
|
|
+ $ghs = CustomClass::getLockById($customId);
|
|
|
+ if (empty($ghs)) {
|
|
|
+ util::fail('供货商信息缺了哦');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $ghsName = $ghs->name ?? '';
|
|
|
+ $customName = $custom->name ?? '';
|
|
|
+ if ($ghs->balance != $custom->balance) {
|
|
|
+ noticeUtil::push("账单有异常。 {$ghsName} {$customName}", '15280215347');
|
|
|
+ util::fail('账单有异常,请联系门店');
|
|
|
+ }
|
|
|
+ if ($ghs->balance < 0) {
|
|
|
+ $remain = PurchaseClass::sum(['ghsId' => $ghsId, 'debt' => 1], 'remainDebtPrice');
|
|
|
+ if ($remain != abs($ghs->balance)) {
|
|
|
+ noticeUtil::push("账单有异常哦 {$ghsName} {$customName}", '15280215347');
|
|
|
+ util::fail('账单有异常哦,请联系门店');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/** 采购挂账开单:balance 减少(原 debtAmount 增加) */
|
|
|
public static function cgDebtAmountAdd($ghs, $order, $bookOrder = false)
|
|
|
{
|