|
|
@@ -163,7 +163,7 @@ class PtAssetClass extends BaseClass
|
|
|
PtYeChangeClass::addChange($change, true);
|
|
|
}
|
|
|
|
|
|
- //平台余额增加 shish 20210519
|
|
|
+ //平台余额减少 shish 20210519
|
|
|
public static function reduceBalance($shop, $amount, $order, $capitalType, $tx)
|
|
|
{
|
|
|
$ptStyle = $shop->ptStyle;
|
|
|
@@ -218,6 +218,63 @@ class PtAssetClass extends BaseClass
|
|
|
PtYeChangeClass::addChange($change, true);
|
|
|
}
|
|
|
|
|
|
+ public static function saleRefundReduceBalance($shop, $refund, $refundPrice)
|
|
|
+ {
|
|
|
+ $ptStyle = $shop->ptStyle;
|
|
|
+ $asset = null;
|
|
|
+ if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
|
|
|
+ $asset = self::getHdBalance();
|
|
|
+ } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
|
|
|
+ $asset = self::getGhsBalance();
|
|
|
+ } else {
|
|
|
+ util::fail('没有找到平台');
|
|
|
+ }
|
|
|
+ if (bccomp($refundPrice, $asset->amount, 2) == 1) {
|
|
|
+ util::fail('平台余额不足');
|
|
|
+ }
|
|
|
+ $currentAmount = bcsub($asset->amount, $refundPrice, 2);
|
|
|
+ $asset->amount = $currentAmount;
|
|
|
+ $asset->save();
|
|
|
+
|
|
|
+ $txAsset = null;
|
|
|
+ if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
|
|
|
+ $txAsset = self::getHdTxBalance();
|
|
|
+ } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
|
|
|
+ $txAsset = self::getGhsTxBalance();
|
|
|
+ } else {
|
|
|
+ util::fail('没有找到平台');
|
|
|
+ }
|
|
|
+ $tx = dict::getDict('yeTx', 'can');
|
|
|
+ $currentTxBalance = $txAsset->amount;
|
|
|
+ if (!empty($currentTxBalance)) {
|
|
|
+ $reduceTxBalance = $currentTxBalance > $refundPrice ? $refundPrice : $currentTxBalance;
|
|
|
+ $currentTxBalance = bcsub($currentTxBalance, $reduceTxBalance, 2);
|
|
|
+ $txAsset->amount = $currentTxBalance;
|
|
|
+ $txAsset->save();
|
|
|
+ }
|
|
|
+
|
|
|
+ $id = $refund->id;
|
|
|
+ $currentType = dict::getDict('capitalType', 'saleRefund');
|
|
|
+ $change = [
|
|
|
+ 'relateId' => $id,
|
|
|
+ 'capitalType' => $currentType,
|
|
|
+ 'amount' => $refundPrice,
|
|
|
+ 'balance' => $currentAmount,
|
|
|
+ 'txBalance' => $currentTxBalance,
|
|
|
+ 'io' => 0,
|
|
|
+ 'payWay' => 0,
|
|
|
+ 'event' => "【{$shop->merchantName} {$shop->shopName}】 的销售单发起退款",
|
|
|
+ 'sjId' => $shop->sjId,
|
|
|
+ 'shopId' => $shop->shopId,
|
|
|
+ 'tx' => $tx,
|
|
|
+ 'ptStyle' => $ptStyle,
|
|
|
+ 'shopName' => $shop->shopName,
|
|
|
+ 'sjName' => $shop->merchantName,
|
|
|
+ ];
|
|
|
+ PtYeChangeClass::addChange($change, true);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//零售平台余额对象 shish 20210519
|
|
|
public static function getHdBalance()
|
|
|
{
|
|
|
@@ -290,4 +347,51 @@ class PtAssetClass extends BaseClass
|
|
|
return $asset;
|
|
|
}
|
|
|
|
|
|
+ //零售采购退款
|
|
|
+ public static function cgRefundAddBalance($shop, $refundPrice, $cgRefund, $currentType, $tx)
|
|
|
+ {
|
|
|
+ $ptStyle = $shop->ptStyle;
|
|
|
+ $asset = null;
|
|
|
+ if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
|
|
|
+ $asset = PtAssetClass::getHdBalance();
|
|
|
+ } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
|
|
|
+ $asset = PtAssetClass::getGhsBalance();
|
|
|
+ } else {
|
|
|
+ util::fail('没有找到平台');
|
|
|
+ }
|
|
|
+ $currentPtBalance = bcadd($asset->amount, $refundPrice, 2);
|
|
|
+ $asset->amount = $currentPtBalance;
|
|
|
+ $asset->save();
|
|
|
+
|
|
|
+ $txAsset = null;
|
|
|
+ if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
|
|
|
+ $txAsset = PtAssetClass::getHdTxBalance();
|
|
|
+ } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
|
|
|
+ $txAsset = PtAssetClass::getGhsTxBalance();
|
|
|
+ } else {
|
|
|
+ util::fail('没有找到平台');
|
|
|
+ }
|
|
|
+ $currentPtTxBalance = $txAsset->amount;
|
|
|
+ $id = $cgRefund->id;
|
|
|
+ $sjId = $shop->sjId;
|
|
|
+ $shopId = $shop->id;
|
|
|
+ $change = [
|
|
|
+ 'relateId' => $id,
|
|
|
+ 'capitalType' => $currentType,
|
|
|
+ 'amount' => $refundPrice,
|
|
|
+ 'balance' => $currentPtBalance,
|
|
|
+ 'txBalance' => $currentPtTxBalance,
|
|
|
+ 'io' => 1,
|
|
|
+ 'payWay' => 0,
|
|
|
+ 'event' => "【{$shop->merchantName} {$shop->shopName}】的采购被退款",
|
|
|
+ 'sjId' => $sjId,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'tx' => dict::getDict('yeTx', 'canNot'),
|
|
|
+ 'ptStyle' => $ptStyle,
|
|
|
+ 'shopName' => $shop->shopName,
|
|
|
+ 'sjName' => $shop->merchantName,
|
|
|
+ ];
|
|
|
+ PtYeChangeClass::addChange($change, true);
|
|
|
+ }
|
|
|
+
|
|
|
}
|