mainId != $mainId) { util::fail('没有权限'); } $actPrice = $order->actPrice ?? 0; $tkPrice = $order->tkPrice ?? 0; $canRefundPrice = bcsub($actPrice, $tkPrice, 2); if ($canRefundPrice < 0) { $canRefundPrice = 0; } $refundList = ScanPayRefundClass::getAllByCondition(['scanPayId' => $id], 'id DESC', '*'); $payWay = $order->payWay ?? 0; $payWayMap = dict::getDict('payWay'); $payWayName = '未知'; if ($payWay == ($payWayMap['wxPay'] ?? 0)) { $payWayName = '微信'; } elseif ($payWay == ($payWayMap['alipay'] ?? 1)) { $payWayName = '支付宝'; } return [ 'info' => $order, 'refundList' => $refundList ?: [], 'canRefundPrice' => floatval($canRefundPrice), 'payWayName' => $payWayName, ]; } public static function addOrder($data) { $mainId = $data['mainId'] ?? 0; $shopId = $data['shopId'] ?? 0; $hdId = $data['hdId'] ?? 0; $customId = $data['customId'] ?? 0; $snData = ['mainId' => $mainId, 'shopId' => $shopId, 'hdId' => $hdId, 'customId' => $customId]; $data['orderSn'] = orderSn::getScanPaySn($snData); return self::add($data, true); } public static function thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId) { $order = self::getByCondition(['orderSn' => $orderSn], true); if (empty($order)) { noticeUtil::push('扫码付款成功,支付回调,单号:' . $orderSn . ' 金额:' . $totalFee . ' 回调id:' . $transactionId . ' 附件:' . $attach . ',没有找到单号', '15280215347'); $msg = "没有找到零售订单 orderSn:{$orderSn}"; Yii::info($msg); util::fail($msg); } if ($order->actPrice != $totalFee) { noticeUtil::push("扫码付款成功,支付回调错误,订单金额与回调通知金额不一致 orderSn:{$orderSn} {$order->actPrice} {$totalFee} 附件:{$attach}", '15280215347'); $msg = "零售订单金额与回调通知金额不一致 orderSn:{$orderSn} {$order->actPrice} {$totalFee}"; Yii::info($msg); util::fail($msg); } $id = $order->id; $order = self::getLockById($id); $date = date("Y-m-d H:i:s"); $order->payStatus = 1; $order->status = 2; $order->payTime = $date; $order->returnCode = $transactionId; $order->save(); self::payAfter($order); } public static function payAfter($order) { $capitalType = dict::getDict('capitalType', 'scanPay', 'id'); $mainId = $order->mainId; $shopId = $order->shopId; $amount = $order->actPrice ?? 0; $main = MainClass::getById($mainId, true); $shop = ShopClass::getLockById($shopId); ShopClass::customScanPayAddBalance($main, $shop, $amount, $order, $capitalType); } }