$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; $customName = $custom->name??''; $ghsMainId = $ghsInfo->mainId ?? 0; $ghsShopId = $ghsInfo->shopId ?? 0; $ghsName = $ghsInfo->name??''; $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, 'customName'=>$customName, '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; $gbData = [ 'ghsId' => $ghsId, 'ghsName'=>$ghsName, '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); $ghsRecharge->balance = $ghsInfo->balance; $ghsRecharge->save(); $customRecharge->balance = $custom->balance; $customRecharge->save(); if ($customRecharge->onlinePay == dict::getDict('onlinePay', 'yes')) { //供货商门店余额增加 $ghsShop = ShopClass::getById($ghsShopId, true); $ghsMain = MainClass::getLockById($ghsMainId); ShopClass::customRechargeAddBalance($ghsMain, $ghsShop, $customRecharge); } } }