|
|
@@ -2,7 +2,10 @@
|
|
|
|
|
|
namespace biz\sj\classes;
|
|
|
|
|
|
+use biz\pt\classes\PtAssetClass;
|
|
|
+use biz\pt\classes\PtYeChangeClass;
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
+use biz\shop\classes\ShopYeChangeClass;
|
|
|
use bizHd\base\classes\BaseClass;
|
|
|
use common\components\dict;
|
|
|
use common\components\noticeUtil;
|
|
|
@@ -40,6 +43,7 @@ class CashClass extends BaseClass
|
|
|
//申请提现
|
|
|
public static function addApply($params)
|
|
|
{
|
|
|
+ $sjId = $params['sjId'] ?? 0;
|
|
|
$shopId = $params['shopId'] ?? 0;
|
|
|
if (empty($shopId)) {
|
|
|
util::fail('没有找到门店');
|
|
|
@@ -70,9 +74,11 @@ class CashClass extends BaseClass
|
|
|
}
|
|
|
|
|
|
//可提现余额减少,总余额减少,冻结金额增加
|
|
|
- $shop->txBalance = 0;
|
|
|
+ $currentTxBalance = bcsub($shop->txBalance, $txBalance, 2);
|
|
|
+ $shop->txBalance = $currentTxBalance;
|
|
|
$shop->freezeBalance = bcadd($shop->freezeBalance, $txBalance, 2);
|
|
|
- $shop->balance = bcsub($shop->balance, $txBalance, 2);
|
|
|
+ $currentBalance = bcsub($shop->balance, $txBalance, 2);
|
|
|
+ $shop->balance = $currentBalance;
|
|
|
$shop->save();
|
|
|
|
|
|
//应转金额
|
|
|
@@ -96,6 +102,73 @@ class CashClass extends BaseClass
|
|
|
$params['amount'] = $txBalance;
|
|
|
$params['beAmount'] = $beAmount;
|
|
|
$return = self::add($params, true);
|
|
|
+
|
|
|
+ $tx = dict::getDict('yeTx', 'can');
|
|
|
+ $capitalType = dict::getDict('capitalType', 'xhDrawCash', 'id');
|
|
|
+ //余额减少记录
|
|
|
+ $id = $return->id;
|
|
|
+ $change = [
|
|
|
+ 'relateId' => $id,
|
|
|
+ 'capitalType' => $capitalType,
|
|
|
+ 'amount' => $txBalance,
|
|
|
+ 'balance' => $currentBalance,
|
|
|
+ 'txBalance' => $currentTxBalance,
|
|
|
+ 'io' => 0,
|
|
|
+ 'payWay' => 0,
|
|
|
+ 'event' => "提现",
|
|
|
+ 'sjId' => $sjId,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'tx' => $tx,
|
|
|
+ 'ptStyle' => $ptStyle,
|
|
|
+ ];
|
|
|
+ ShopYeChangeClass::addChange($change, true);
|
|
|
+
|
|
|
+ $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;
|
|
|
+ $currentPtTxBalance = bcsub($currentPtTxBalance, $txBalance, 2);
|
|
|
+ $txAsset->amount = $currentPtTxBalance;
|
|
|
+ $txAsset->save();
|
|
|
+
|
|
|
+ $asset = null;
|
|
|
+ if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
|
|
|
+ $asset = PtAssetClass::getHdBalance();
|
|
|
+ } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
|
|
|
+ $asset = PtAssetClass::getGhsBalance();
|
|
|
+ } else {
|
|
|
+ util::fail('没有找到平台');
|
|
|
+ }
|
|
|
+ if (bccomp($txBalance, $asset->amount, 2) == 1) {
|
|
|
+ util::fail('平台余额不足');
|
|
|
+ }
|
|
|
+ $currentPtBalance = bcsub($asset->amount, $txBalance, 2);
|
|
|
+ $asset->amount = $currentPtBalance;
|
|
|
+ $asset->save();
|
|
|
+
|
|
|
+ $change = [
|
|
|
+ 'relateId' => $id,
|
|
|
+ 'capitalType' => $capitalType,
|
|
|
+ 'amount' => $txBalance,
|
|
|
+ 'balance' => $currentPtBalance,
|
|
|
+ 'txBalance' => $currentPtTxBalance,
|
|
|
+ 'io' => 0,
|
|
|
+ 'payWay' => 0,
|
|
|
+ 'event' => "【{$shop->merchantName} {$shop->shopName}】提现",
|
|
|
+ 'sjId' => $sjId,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'tx' => $tx,
|
|
|
+ 'ptStyle' => $ptStyle,
|
|
|
+ 'shopName' => $shop->shopName,
|
|
|
+ 'sjName' => $shop->merchantName,
|
|
|
+ ];
|
|
|
+ PtYeChangeClass::addChange($change, true);
|
|
|
+
|
|
|
noticeUtil::push("客户:{$sjName} {$shopName}申请提现,金额:{$txBalance}元", '15280215347');
|
|
|
return $return;
|
|
|
}
|
|
|
@@ -107,9 +180,82 @@ class CashClass extends BaseClass
|
|
|
$cash->save();
|
|
|
//冻结金额回滚
|
|
|
$shop->freezeBalance = bcsub($shop->freezeBalance, $cashAmount, 2);
|
|
|
- $shop->balance = bcadd($shop->balance, $cashAmount, 2);
|
|
|
- $shop->txBalance = bcadd($shop->txBalance, $cashAmount, 2);
|
|
|
+ $currentBalance = bcadd($shop->balance, $cashAmount, 2);
|
|
|
+ $shop->balance = $currentBalance;
|
|
|
+ $currentTxBalance = bcadd($shop->txBalance, $cashAmount, 2);
|
|
|
+ $shop->txBalance = $currentTxBalance;
|
|
|
$shop->save();
|
|
|
+
|
|
|
+ $sjId = $shop->sjId;
|
|
|
+ $shopId = $shop->id;
|
|
|
+ $tx = dict::getDict('yeTx', 'can');
|
|
|
+ $ptStyle = $shop->ptStyle ?? dict::getDict('ptStyle', 'hd');
|
|
|
+ $capitalType = dict::getDict('capitalType', 'xhDrawCash', 'id');
|
|
|
+ //余额增加记录
|
|
|
+ $id = $cash->id;
|
|
|
+ $change = [
|
|
|
+ 'relateId' => $id,
|
|
|
+ 'capitalType' => $capitalType,
|
|
|
+ 'amount' => $cashAmount,
|
|
|
+ 'balance' => $currentBalance,
|
|
|
+ 'txBalance' => $currentTxBalance,
|
|
|
+ 'io' => 1,
|
|
|
+ 'payWay' => 0,
|
|
|
+ 'event' => "提现回退",
|
|
|
+ 'sjId' => $sjId,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'tx' => $tx,
|
|
|
+ 'ptStyle' => $ptStyle,
|
|
|
+ ];
|
|
|
+ ShopYeChangeClass::addChange($change, true);
|
|
|
+
|
|
|
+ $txAsset = null;
|
|
|
+ if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
|
|
|
+ $txAsset = PtAssetClass::getHdTxBalance();
|
|
|
+ } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
|
|
|
+ $txAsset = self::getGhsTxBalance();
|
|
|
+ } else {
|
|
|
+ CashClass::rollback($cash, $shop, $transaction, $cashAmount, $remark);
|
|
|
+ util::fail('没有找到平台');
|
|
|
+ }
|
|
|
+ $currentPtTxBalance = $txAsset->amount;
|
|
|
+ $currentPtTxBalance = bcadd($currentPtTxBalance, $cashAmount, 2);
|
|
|
+ $txAsset->amount = $currentPtTxBalance;
|
|
|
+ $txAsset->save();
|
|
|
+
|
|
|
+ $asset = null;
|
|
|
+ if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
|
|
|
+ $asset = PtAssetClass::getHdBalance();
|
|
|
+ } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
|
|
|
+ $asset = PtAssetClass::getGhsBalance();
|
|
|
+ } else {
|
|
|
+ util::fail('没有找到平台');
|
|
|
+ }
|
|
|
+ if (bccomp($cashAmount, $asset->amount, 2) == 1) {
|
|
|
+ util::fail('平台余额不足');
|
|
|
+ }
|
|
|
+ $currentPtBalance = bcadd($asset->amount, $cashAmount, 2);
|
|
|
+ $asset->amount = $currentPtBalance;
|
|
|
+ $asset->save();
|
|
|
+
|
|
|
+ $change = [
|
|
|
+ 'relateId' => $id,
|
|
|
+ 'capitalType' => $capitalType,
|
|
|
+ 'amount' => $cashAmount,
|
|
|
+ 'balance' => $currentPtBalance,
|
|
|
+ 'txBalance' => $currentPtTxBalance,
|
|
|
+ 'io' => 1,
|
|
|
+ 'payWay' => 0,
|
|
|
+ 'event' => "【{$shop->merchantName} {$shop->shopName}】提现回退",
|
|
|
+ 'sjId' => $sjId,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'tx' => $tx,
|
|
|
+ 'ptStyle' => $ptStyle,
|
|
|
+ 'shopName' => $shop->shopName,
|
|
|
+ 'sjName' => $shop->merchantName,
|
|
|
+ ];
|
|
|
+ PtYeChangeClass::addChange($change, true);
|
|
|
+
|
|
|
$transaction->commit();
|
|
|
}
|
|
|
|