|
|
@@ -2,6 +2,14 @@
|
|
|
|
|
|
namespace bizHd\recharge\classes;
|
|
|
|
|
|
+use biz\shop\classes\ShopClass;
|
|
|
+use bizHd\balance\classes\BalanceChangeClass;
|
|
|
+use bizHd\custom\classes\CustomClass;
|
|
|
+use bizHd\custom\classes\HdClass;
|
|
|
+use bizHd\shop\classes\MainClass;
|
|
|
+use common\components\dict;
|
|
|
+use common\components\noticeUtil;
|
|
|
+use common\components\util;
|
|
|
use Yii;
|
|
|
use bizHd\base\classes\BaseClass;
|
|
|
|
|
|
@@ -15,4 +23,99 @@ class RechargeClass extends BaseClass
|
|
|
return self::add($data, true);
|
|
|
}
|
|
|
|
|
|
+ //第三支付后流程 ssh 2021.4.27
|
|
|
+ public static function thirdPay($payWay, $orderSn, $totalFee, $attach)
|
|
|
+ {
|
|
|
+ $recharge = RechargeClass::getByCondition(['orderSn' => $orderSn], true);
|
|
|
+ if (empty($recharge)) {
|
|
|
+ noticeUtil::push('充值付款成功,收到回调,但没有找到充值记录,orderSn:' . $orderSn, '15280215347');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if ($totalFee != $recharge->amount) {
|
|
|
+ noticeUtil::push("充值付款成功,收到回调,但金额不一致 {$totalFee} {$recharge->amount},orderSn:" . $orderSn, '15280215347');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if ($recharge->payStatus == 1) {
|
|
|
+ noticeUtil::push("充值付款成功,收到回调,但订单是已经支付过了,orderSn:" . $orderSn, '15280215347');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $id = $recharge->id;
|
|
|
+ $recharge = RechargeClass::getLockById($id);
|
|
|
+ $params = [
|
|
|
+ 'onlinePay' => 2,
|
|
|
+ 'side' => 1,
|
|
|
+ ];
|
|
|
+ self::complete($recharge, $payWay, $params);
|
|
|
+ return $recharge;
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理充值流程 ssh 20250321
|
|
|
+ public static function complete($recharge, $payWay, $params)
|
|
|
+ {
|
|
|
+ $onlinePay = $params['onlinePay'];
|
|
|
+ $side = $params['side'];
|
|
|
+ $recharge->onlinePay = $onlinePay;
|
|
|
+ $recharge->payWay = $payWay;
|
|
|
+ $recharge->payStatus = 1;
|
|
|
+ $recharge->status = 1;
|
|
|
+ $recharge->save();
|
|
|
+
|
|
|
+ $shopId = $recharge->shopId;
|
|
|
+ $mainId = $recharge->mainId;
|
|
|
+ $hdId = $recharge->hdId;
|
|
|
+ $amount = $recharge->amount;
|
|
|
+ $staffId = $recharge->staffId;
|
|
|
+ $payWay = $recharge->payWay;
|
|
|
+ $staffName = $recharge->staffName;
|
|
|
+ $customId = $recharge->customId;
|
|
|
+ $customName = $recharge->customName;
|
|
|
+ $capitalType = dict::getDict('capitalType', 'xhRecharge', 'id');
|
|
|
+ $relateId = $recharge->id;
|
|
|
+
|
|
|
+ $custom = CustomClass::getLockById($customId);
|
|
|
+ if (empty($custom)) {
|
|
|
+ util::fail('充值回调失败,没有找到客户');
|
|
|
+ }
|
|
|
+ $custom->balance = bcadd($custom->balance, $amount, 2);
|
|
|
+ $custom->save();
|
|
|
+
|
|
|
+ $hd = HdClass::getLockById($hdId);
|
|
|
+ if (empty($hd)) {
|
|
|
+ util::fail('充值回调失败,没有找到花店');
|
|
|
+ }
|
|
|
+ $hd->balance = bcadd($custom->balance, $amount, 2);
|
|
|
+ $hd->save();
|
|
|
+
|
|
|
+ if ($hd->balance != $custom->balance) {
|
|
|
+ util::fail('充值回调失败,金额不一致');
|
|
|
+ }
|
|
|
+
|
|
|
+ $change = [
|
|
|
+ 'customId' => $customId,
|
|
|
+ 'customName' => $customName,
|
|
|
+ 'relateId' => $relateId,
|
|
|
+ 'onlinePay' => $onlinePay,
|
|
|
+ 'capitalType' => $capitalType,
|
|
|
+ 'amount' => $amount,
|
|
|
+ 'balance' => $hd->balance,
|
|
|
+ 'io' => 1,
|
|
|
+ 'side' => $side,
|
|
|
+ 'payWay' => $payWay,
|
|
|
+ 'event' => '充值',
|
|
|
+ 'staffId' => $staffId,
|
|
|
+ 'staffName' => $staffName,
|
|
|
+ 'shopId' => $shopId,
|
|
|
+ 'mainId' => $mainId,
|
|
|
+ 'remark' => '',
|
|
|
+ ];
|
|
|
+ $returnChange = BalanceChangeClass::add($change, true);
|
|
|
+ if ($recharge->onlinePay == 2) {
|
|
|
+ //如果线上充值,门店余额增加
|
|
|
+ $shop = ShopClass::getLockById($shopId);
|
|
|
+ $main = MainClass::getLockById($mainId);
|
|
|
+ ShopClass::skRechargeAddBalance($main, $shop, $recharge);
|
|
|
+ }
|
|
|
+ return $returnChange;
|
|
|
+ }
|
|
|
+
|
|
|
}
|