|
|
@@ -119,72 +119,6 @@ class PtAssetClass extends BaseClass
|
|
|
PtYeChangeClass::addChange($change, true);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 客户线上充值退款:扣减平台资产(与 customRechargeAddBalance 对称)。
|
|
|
- */
|
|
|
- public static function customRechargeRefundReduceBalance($shop, $order, $capitalType, $tx, $staffName = '')
|
|
|
- {
|
|
|
- $amount = bcadd((string)($order->amount ?? '0'), '0', 2);
|
|
|
- if (bccomp($amount, '0', 2) <= 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
- $ptStyle = $shop->ptStyle ?? 0;
|
|
|
- if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
|
|
|
- $asset = self::getHdBalance();
|
|
|
- } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
|
|
|
- $asset = self::getGhsBalance();
|
|
|
- } else {
|
|
|
- util::fail('没有找到平台');
|
|
|
- }
|
|
|
- $currentAmount = bcsub((string)($asset->amount ?? '0'), $amount, 2);
|
|
|
- if (bccomp($currentAmount, '0', 2) < 0) {
|
|
|
- util::fail('平台余额不足,无法退款');
|
|
|
- }
|
|
|
- $asset->amount = $currentAmount;
|
|
|
- $asset->save();
|
|
|
-
|
|
|
- if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
|
|
|
- $txAsset = self::getHdTxBalance();
|
|
|
- } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
|
|
|
- $txAsset = self::getGhsTxBalance();
|
|
|
- } else {
|
|
|
- util::fail('没有找到平台');
|
|
|
- }
|
|
|
- $currentTxBalance = $txAsset->amount ?? 0;
|
|
|
- if ($tx == dict::getDict('yeTx', 'can')) {
|
|
|
- $currentTxBalance = bcsub((string)$currentTxBalance, $amount, 2);
|
|
|
- if (bccomp($currentTxBalance, '0', 2) < 0) {
|
|
|
- $currentTxBalance = '0.00';
|
|
|
- }
|
|
|
- $txAsset->amount = $currentTxBalance;
|
|
|
- $txAsset->save();
|
|
|
- }
|
|
|
- $sjName = $shop->merchantName ?? '';
|
|
|
- if (!isset($shop->default) || $shop->default != 1 || ($shop->shopName ?? '') != '首店') {
|
|
|
- $sjName .= ' ' . ($shop->shopName ?? '');
|
|
|
- }
|
|
|
- $operator = $staffName !== '' ? "(操作人:{$staffName})" : '';
|
|
|
- $event = "客户向商家-{$sjName}充值退款{$operator},单号:" . ($order->orderSn ?? '');
|
|
|
- $change = [
|
|
|
- 'relateId' => $order->id ?? 0,
|
|
|
- 'capitalType' => $capitalType,
|
|
|
- 'amount' => $amount,
|
|
|
- 'balance' => $currentAmount,
|
|
|
- 'txBalance' => $currentTxBalance,
|
|
|
- 'io' => 0,
|
|
|
- 'payWay' => $order->payWay ?? 0,
|
|
|
- 'event' => $event,
|
|
|
- 'sjId' => $order->sjId ?? ($shop->sjId ?? 0),
|
|
|
- 'shopId' => $shop->shopId ?? ($shop->id ?? 0),
|
|
|
- 'mainId' => $shop->mainId ?? 0,
|
|
|
- 'tx' => $tx,
|
|
|
- 'ptStyle' => $ptStyle,
|
|
|
- 'shopName' => $shop->shopName ?? '',
|
|
|
- 'sjName' => $shop->merchantName ?? '',
|
|
|
- ];
|
|
|
- PtYeChangeClass::addChange($change, true);
|
|
|
- }
|
|
|
-
|
|
|
//客户结帐增加加余额 ssh 20210729
|
|
|
public static function customClearAddBalance($shop, $order, $capitalType, $tx)
|
|
|
{
|