|
|
@@ -2,11 +2,13 @@
|
|
|
|
|
|
namespace bizGhs\custom\classes;
|
|
|
|
|
|
+use bizGhs\ghs\classes\GhsRechargeClass;
|
|
|
+use bizHd\ghs\classes\GhsClass;
|
|
|
use common\components\dict;
|
|
|
-use common\components\imgUtil;
|
|
|
use common\components\noticeUtil;
|
|
|
use common\components\util;
|
|
|
use bizHd\base\classes\BaseClass;
|
|
|
+use bizGhs\ghs\classes\GhsBalanceChangeClass;
|
|
|
|
|
|
class CustomRechargeClass extends BaseClass
|
|
|
{
|
|
|
@@ -19,4 +21,120 @@ class CustomRechargeClass extends BaseClass
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
+ public static function thirdPay($payWay, $customRechargeSn, $totalFee, $attach, $transactionId)
|
|
|
+ {
|
|
|
+ $customRecharge = self::getByCondition(['orderSn' => $customRechargeSn], true);
|
|
|
+ if (empty($customRecharge)) {
|
|
|
+ noticeUtil::push('充值订单,单号:' . $customRechargeSn . ',没有找到订单', '15280215347');
|
|
|
+ $msg = "没有找到充值订单 orderSn:{$customRechargeSn}";
|
|
|
+ Yii::info($msg);
|
|
|
+ util::fail($msg);
|
|
|
+ }
|
|
|
+ if ($customRecharge->amount != $totalFee) {
|
|
|
+ noticeUtil::push("充值订单,支付回调错误,零售订单金额与回调通知金额不一致 orderSn:{$customRechargeSn} {$customRecharge->amount} {$totalFee}", '15280215347');
|
|
|
+ $msg = "充值订单金额与回调通知金额不一致 orderSn:{$customRechargeSn} {$customRecharge->amount} {$totalFee}";
|
|
|
+ Yii::info($msg);
|
|
|
+ util::fail($msg);
|
|
|
+ }
|
|
|
+ if ($customRecharge->payStatus == 1) {
|
|
|
+ noticeUtil::push("充值订单,支付回调错误,已经充值过了 orderSn:{$customRechargeSn}", '15280215347');
|
|
|
+ $msg = "充值订单,支付回调错误,已经充值过了 orderSn:{$customRechargeSn}";
|
|
|
+ Yii::info($msg);
|
|
|
+ util::fail($msg);
|
|
|
+ }
|
|
|
+ $amount = $totalFee;
|
|
|
+ $id = $customRecharge->id;
|
|
|
+ $customRecharge = self::getLockById($id);
|
|
|
+ $payDate = date("Y-m-d H:i:s");
|
|
|
+ $customRecharge->payTime = $payDate;
|
|
|
+ $customRecharge->payWay = $payWay;
|
|
|
+ $customRecharge->payStatus = 1;
|
|
|
+ $customRecharge->status = 1;
|
|
|
+ $customRecharge->returnCode = $transactionId;
|
|
|
+ $customRecharge->onlinePay = dict::getDict('onlinePay', 'yes');
|
|
|
+ $customRecharge->save();
|
|
|
+
|
|
|
+ $ghsRechargeId = $customRecharge->ghsRechargeId ?? 0;
|
|
|
+ $ghsRecharge = GhsRechargeClass::getById($ghsRechargeId, true);
|
|
|
+ if (empty($ghsRecharge)) {
|
|
|
+ noticeUtil::push("充值订单,支付回调错误,没有找到对应单号 orderSn:{$customRechargeSn}", '15280215347');
|
|
|
+ $msg = "充值订单,支付回调错误,没有找到对应单号 orderSn:{$customRechargeSn}";
|
|
|
+ Yii::info($msg);
|
|
|
+ util::fail($msg);
|
|
|
+ }
|
|
|
+ $ghsRecharge->payTime = $payDate;
|
|
|
+ $ghsRecharge->payWay = $payWay;
|
|
|
+ $ghsRecharge->payStatus = 1;
|
|
|
+ $ghsRecharge->status = 1;
|
|
|
+ $ghsRecharge->onlinePay = dict::getDict('onlinePay', 'yes');
|
|
|
+ $ghsRecharge->save();
|
|
|
+
|
|
|
+ //充值金额,有多个地方要同步修改,请搜索关键词custom_ghs_recharge ssh 20240310
|
|
|
+ $customRechargeId = $customRecharge->id ?? 0;
|
|
|
+ $customId = $customRecharge->customId ?? 0;
|
|
|
+ $ghsId = $customRecharge->ghsId ?? 0;
|
|
|
+ $custom = CustomClass::getLockById($customId);
|
|
|
+ $ghsInfo = GhsClass::getLockById($ghsId);
|
|
|
+ $rechargeEvent = '线上充值';
|
|
|
+ $customMainId = $custom->mainId ?? 0;
|
|
|
+ $customShopId = $custom->shopId ?? 0;
|
|
|
+ $ghsMainId = $ghs->mainId ?? 0;
|
|
|
+ $ghsShopId = $ghs->shopId ?? 0;
|
|
|
+ $customStaffId = $ghsRecharge->staffId ?? 0;
|
|
|
+ $customStaffName = $ghsRecharge->staffName ?? '';
|
|
|
+
|
|
|
+ $custom->balance = bcadd($custom->balance, $amount, 2);
|
|
|
+ $custom->save();
|
|
|
+ $capitalType = dict::getDict('capitalType', 'customRechargeToGhs', 'id');
|
|
|
+ $fromType = dict::getDict('fromType', 'shop');
|
|
|
+ $cbData = [
|
|
|
+ 'customId' => $customId,
|
|
|
+ 'relateId' => $customRechargeId,
|
|
|
+ 'onlinePay' => 2,
|
|
|
+ 'ptStyle' => 2,
|
|
|
+ 'capitalType' => $capitalType,
|
|
|
+ 'amount' => $amount,
|
|
|
+ 'balance' => $custom->balance,
|
|
|
+ 'staffId' => 0,
|
|
|
+ 'staffName' => '',
|
|
|
+ 'io' => 1,
|
|
|
+ 'side' => 1,
|
|
|
+ 'payWay' => $payWay,
|
|
|
+ 'fromType' => $fromType,
|
|
|
+ 'event' => $rechargeEvent,
|
|
|
+ 'mainId' => $ghsMainId,
|
|
|
+ 'shopId' => $ghsShopId,
|
|
|
+ 'sjId' => 0,
|
|
|
+ 'remark' => '',
|
|
|
+ ];
|
|
|
+ CustomBalanceChangeClass::add($cbData, true);
|
|
|
+
|
|
|
+ $ghsInfo->balance = bcadd($ghsInfo->balance, $amount, 2);
|
|
|
+ $ghsInfo->save();
|
|
|
+
|
|
|
+ $ghsRechargeId = $ghsRecharge->id ?? 0;
|
|
|
+ $capitalType = dict::getDict('capitalType', 'customAskGhsRecharge', 'id');
|
|
|
+ $gbData = [
|
|
|
+ 'ghsId' => $ghsId,
|
|
|
+ 'relateId' => $ghsRechargeId,
|
|
|
+ 'ptStyle' => 2,
|
|
|
+ 'capitalType' => $capitalType,
|
|
|
+ 'amount' => $amount,
|
|
|
+ 'balance' => $ghsInfo->balance,
|
|
|
+ 'staffId' => $customStaffId,
|
|
|
+ 'staffName' => $customStaffName,
|
|
|
+ 'io' => 1,
|
|
|
+ 'side' => 1,
|
|
|
+ 'onlinePay' => 2,
|
|
|
+ 'payWay' => $payWay,
|
|
|
+ 'fromType' => $fromType,
|
|
|
+ 'event' => $rechargeEvent,
|
|
|
+ 'sjId' => 0,
|
|
|
+ 'mainId' => $customMainId,
|
|
|
+ 'shopId' => $customShopId,
|
|
|
+ 'remark' => '',
|
|
|
+ ];
|
|
|
+ GhsBalanceChangeClass::add($gbData, true);
|
|
|
+ }
|
|
|
+
|
|
|
}
|