|
|
@@ -247,7 +247,7 @@ class OrderController extends BaseController
|
|
|
$cg->save();
|
|
|
|
|
|
$shop = $this->shop;
|
|
|
-
|
|
|
+ $currentCapitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
|
|
|
$wxPayWay = dict::getDict('payWay', 'wxPay');
|
|
|
$aliPayWay = dict::getDict('payWay', 'alipay');
|
|
|
$payWay = Yii::$app->request->get('payWay', $wxPayWay);
|
|
|
@@ -255,38 +255,33 @@ class OrderController extends BaseController
|
|
|
if (isset($order->wxPayUrl) && !empty($order->wxPayUrl)) {
|
|
|
$url = $order->wxPayUrl;
|
|
|
} else {
|
|
|
- $wx = Yii::getAlias("@vendor/wxPayApi_v3.0.10");
|
|
|
- require_once($wx . '/lib/WxPay.Api.php');
|
|
|
- require_once($wx . '/example/WxPay.NativePay.php');
|
|
|
-
|
|
|
- //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
|
|
|
- $wxPayType = 0;
|
|
|
- if (httpUtil::isMiniProgram()) {
|
|
|
- $wxPayType = 1;
|
|
|
+ $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->lklScanTermNo,
|
|
|
+ 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
|
|
|
+ 'lklCertificatePath' => $lklCertificatePath,
|
|
|
+ ];
|
|
|
+ $laResource = new Lakala($params);
|
|
|
+ $notifyUrl = Yii::$app->params['hdHost'] . "/notice/pay-callback";
|
|
|
+ $wxParams = [
|
|
|
+ 'orderSn' => $orderSn,
|
|
|
+ 'amount' => $totalFee,
|
|
|
+ 'capitalType' => $currentCapitalType,
|
|
|
+ 'notifyUrl' => $notifyUrl,
|
|
|
+ 'subject' => $subject,
|
|
|
+ 'couponId' => 0,
|
|
|
+ ];
|
|
|
+ $response = $laResource->driveWxPay($wxParams);
|
|
|
+ if (isset($response['code']) == false || $response['code'] != 'BBS00000') {
|
|
|
+ util::fail('二维码生成失败');
|
|
|
}
|
|
|
- $purchaseCapital = dict::getDict('capitalType', 'xhPurchase', 'id');
|
|
|
- $attach = "couponId=0&capitalType=" . $purchaseCapital . '&wxPayType=' . $wxPayType;
|
|
|
-
|
|
|
- $input = new \WxPayUnifiedOrder();
|
|
|
- $input->SetBody($subject);
|
|
|
- $input->SetOut_trade_no($orderSn);
|
|
|
- $input->SetTotal_fee($totalFee * 100);
|
|
|
- $input->SetAttach($attach);
|
|
|
- $input->SetTime_start(date("YmdHis"));
|
|
|
- $input->SetTime_expire(date("YmdHis", time() + 600));
|
|
|
- $input->SetNotify_url(Yii::$app->params['hdHost'] . '/notice/wx-callback/');
|
|
|
- $input->SetTrade_type("NATIVE");
|
|
|
- //native支付必传
|
|
|
- $input->SetProduct_id("hdCG_" . $cgId);
|
|
|
-
|
|
|
- //获取微信商户号等信息
|
|
|
- $sjExtend = WxOpenClass::getWxInfo();
|
|
|
-
|
|
|
- $notify = new \NativePay();
|
|
|
- $result = $notify->GetPayUrl($input, $sjExtend);
|
|
|
- $url = $result["code_url"] ?? '';
|
|
|
+ $url = isset($response['resp_data']['acc_resp_fields']['code']) ? $response['resp_data']['acc_resp_fields']['code'] : '';
|
|
|
if (empty($url)) {
|
|
|
- util::success(['returnStatus' => 'FAILURE'], '二维码生成失败');
|
|
|
+ util::fail('二维码生成失败..');
|
|
|
}
|
|
|
$order->wxPayUrl = $url;
|
|
|
$order->save();
|
|
|
@@ -311,7 +306,6 @@ class OrderController extends BaseController
|
|
|
];
|
|
|
$laResource = new Lakala($params);
|
|
|
$notifyUrl = Yii::$app->params['hdHost'] . "/notice/pay-callback";
|
|
|
- $currentCapitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
|
|
|
$aliParams = [
|
|
|
'orderSn' => $orderSn,
|
|
|
'amount' => $totalFee,
|