request->post(); $payWay = isset($post['payWay']) ? $post['payWay'] : 0; $actPrice = $post['actPrice'] ?? 0; $totalFee = $actPrice; $shopId = $this->shopId; if (empty($shopId)) { util::fail('没有找到花店'); } $shop = ShopClass::getById($shopId, true); if (empty($shop)) { util::fail('没有找到花店呢'); } $mainId = $this->mainId; $hdId = $post['hdId'] ?? 0; $salt = $post['salt'] ?? ''; $hd = HdClass::getById($hdId, true); if (empty($hd)) { util::fail('没有找到花店哦!'); } if (empty($salt) || $hd->salt != $salt) { util::fail('不是你的花店哦'); } $customId = $hd->customId ?? 0; $custom = CustomClass::getById($customId, true); if (empty($custom)) { util::fail('花店客户缺失'); } $customName = $custom->name; $hd = HdClass::getById($hdId, true); if (empty($hd)) { util::fail('花店信息缺失'); } $hdName = $hd->name; $capitalType = dict::getDict('capitalType', 'xhRecharge', 'id'); $orderSn = orderSn::getRechargeSn(); $rechargeData = [ 'orderSn' => $orderSn, 'modPrice' => 0, 'payWay' => $payWay, 'returnCode' => '', 'shopId' => $shopId, 'mainId' => $mainId, 'hdId' => $hdId, 'hdName' => $hdName, 'amount' => $actPrice, 'onlinePay' => 1, 'payStatus' => 0, 'status' => 0, 'customId' => $customId, 'customName' => $customName, ]; $respond = RechargeClass::addRecharge($rechargeData); $rechargeId = $respond->id; $subject = '线上充值,单号' . $orderSn; if ($payWay == 0) { $openId = !empty($post['currentMiniOpenId']) ? $post['currentMiniOpenId'] : ''; if (empty($openId)) { if (!empty($this->admin)) { if (isset($this->admin->miniOpenId) && !empty($this->admin->miniOpenId)) { $openId = $this->admin->miniOpenId; } } } $merchantExtend = WxOpenClass::getMallWxInfo(); $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem'; $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer'; $params = [ 'appid' => 'OP00002119', 'serial_no' => '018b08cfddbd', 'merchant_no' => $shop->lklSjNo, 'term_no' => $shop->lklScanTermNo, 'merchantPrivateKeyPath' => $merchantPrivateKeyPath, 'lklCertificatePath' => $lklCertificatePath, ]; $laResource = new Lakala($params); $notifyUrl = Yii::$app->params['mallHost'] . "/notice/pay-callback"; $wxParams = [ 'orderSn' => $orderSn, 'amount' => $totalFee, 'capitalType' => $capitalType, 'notifyUrl' => $notifyUrl, 'wxAppId' => $merchantExtend['miniAppId'], 'openId' => $openId, 'subject' => $subject, 'couponId' => 0, ]; $response = $laResource->driveWxPay($wxParams); if ($response['code'] != 'BBS00000') { $errMsg = $response['msg'] ?? ''; noticeUtil::push('编号666993:' . $errMsg, '15280215347'); util::fail('支付失败'); } $newParams = isset($response['resp_data']['acc_resp_fields']) ? $response['resp_data']['acc_resp_fields'] : []; $appId = $newParams['app_id'] ?? ''; $nonceStr = $newParams['nonce_str'] ?? ''; $paySign = $newParams['pay_sign'] ?? ''; $package = $newParams['package'] ?? ''; $signType = $newParams['sign_type'] ?? ''; $timeStamp = $newParams['time_stamp'] ?? ''; $new = [ 'id' => $rechargeId, 'appId' => $appId, 'nonceStr' => $nonceStr, 'paySign' => $paySign, 'package' => $package, 'signType' => $signType, 'timeStamp' => $timeStamp, 'orderSn' => $orderSn, ]; util::success($new); } elseif ($payWay == 1) { util::fail('开发中'); // $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem'; // $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer'; // $params = [ // 'appid' => 'OP00002119', // 'serial_no' => '018b08cfddbd', // 'merchant_no' => $ghsShop->lklSjNo, // 'term_no' => $ghsShop->lklB2BTermNo, // 'merchantPrivateKeyPath' => $merchantPrivateKeyPath, // 'lklCertificatePath' => $lklCertificatePath, // ]; // $laResource = new Lakala($params); // $notifyUrl = Yii::$app->params['hdHost'] . "/notice/cash-pay-callback"; // $cashParams = [ // 'orderSn' => $customOrderSn, // 'amount' => $totalFee, // 'capitalType' => $capitalType, // 'notifyUrl' => $notifyUrl, // 'subject' => $subject, // ]; // $response = $laResource->cashierPay($cashParams); // if (isset($response['code']) == false || $response['code'] != '000000') { // util::fail('支付失败了'); // } // $url = $response['resp_data']['counter_url'] ? $response['resp_data']['counter_url'] : ''; // if (empty($url)) { // util::fail('支付失败'); // } // util::success(['url' => $url]); } else { util::fail('暂不支持的付款方式'); } } }