remainDebtPrice ?? 0; $balance = bcadd($ghs->debtAmount, $order->remainDebtPrice, 2); $ghs->debt = 2; $ghs->debtAmount = $balance; $ghs->save(); $relateId = $order->id ?? 0; $orderSn = $order->orderSn ?? ''; $ghsId = $ghs->id ?? 0; $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id'); $event = '购买花材,采购单号:' . $orderSn; if ($bookOrder) { $event = '预订单多退少补,单号' . $orderSn; } $change = [ 'relateId' => $relateId, 'ghsId' => $ghsId, 'ptStyle' => dict::getDict('ptStyle', 'hd'), 'capitalType' => $capitalType, 'amount' => $amount, 'balance' => $balance, 'io' => 1, 'payWay' => $order->payWay, 'event' => $event, 'sjId' => $order->sjId ?? 0, 'shopId' => $order->shopId ?? 0, ]; GhsDebtChangeClass::addChange($change); } //供货商结账欠款金额减少 ssh 20220306 public static function clearDebtAmountReduce($ghs, $custom, $amount, $clear) { $remainAmount = bcsub($ghs->debtAmount, $amount, 2); if ($remainAmount < 0) { noticeUtil::push("结账没有成功,欠供货商总金额:{$ghs->debtAmount} 本次结账金额:{$amount} 供货商ID:{$ghs->id}", '15280215347'); util::fail('结账没有成功'); } $ghs->debtAmount = $remainAmount; $ghs->debt = $remainAmount > 0 ? 2 : 1; $ghs->save(); $relateId = $clear->id ?? 0; $ghsId = $ghs->id ?? 0; $orderSn = $clear->orderSn ?? ''; $capitalType = dict::getDict('capitalType', 'hdPurchaseClear', 'id'); $change = [ 'relateId' => $relateId, 'ghsId' => $ghsId, 'ptStyle' => dict::getDict('ptStyle', 'hd'), 'capitalType' => $capitalType, 'amount' => $amount, 'balance' => $remainAmount, 'io' => 0, 'payWay' => 1, 'event' => "结账,单号:{$orderSn}", 'sjId' => $custom->sjId ?? 0, 'shopId' => $custom->shopId ?? 0, ]; GhsDebtChangeClass::addChange($change); } //供货商退款欠款金额减少 ssh 20220306 public static function refundDebtAmountReduce($ghs, $refund, $cg) { $refundPrice = $refund->refundPrice ?? 0; $currentDebtAmount = bcsub($ghs->debtAmount, $refundPrice, 2); $ghs->debtAmount = $currentDebtAmount; $ghs->save(); $relateId = $order->id ?? 0; $ghsId = $ghs->id ?? 0; $capitalType = dict::getDict('capitalType', 'cgRefund', 'id'); $cgOrderSn = $cg->orderSn ?? ''; $change = [ 'relateId' => $relateId, 'ghsId' => $ghsId, 'ptStyle' => dict::getDict('ptStyle', 'hd'), 'capitalType' => $capitalType, 'amount' => $refundPrice, 'balance' => $currentDebtAmount, 'io' => 0, 'payWay' => 0, 'event' => "采购单:{$cgOrderSn} 退款", 'sjId' => $refund->sjId ?? 0, 'shopId' => $refund->shopId ?? 0, ]; GhsDebtChangeClass::addChange($change); } //验证供货商 ssh 20220307 public static function valid($ghs, $shopId) { if (empty($ghs)) { util::fail('没有找到供货商'); } if ($ghs->ownShopId != $shopId) { util::fail('不是您的供货商'); } return true; } }