|
|
@@ -23,6 +23,7 @@ use common\components\dict;
|
|
|
use common\components\orderSn;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
+use common\components\lakala\Lakala;
|
|
|
|
|
|
class HdRefundService extends BaseService
|
|
|
{
|
|
|
@@ -241,44 +242,30 @@ class HdRefundService extends BaseService
|
|
|
//门店余额减少
|
|
|
\biz\shop\classes\ShopClass::hdSaleRefundReduceBalance($main, $shop, $refund, $refundPrice);
|
|
|
|
|
|
- //微信收款的原路退回
|
|
|
- ini_set('date.timezone', 'Asia/Shanghai');
|
|
|
- $wx = Yii::getAlias("@vendor/wxPayApi_v3.0.10");
|
|
|
- require_once($wx . '/lib/WxPay.Api.php');
|
|
|
- require_once($wx . '/example/WxPay.Config.php');
|
|
|
-
|
|
|
- $totalFee = $order->mainPay * 100;
|
|
|
$refundFee = $refundPrice * 100;
|
|
|
-
|
|
|
- $merchantExt = WxOpenClass::getMallWxInfo();
|
|
|
- $mid = $merchantExt['wxPayMerchantId'] ?? '';
|
|
|
- $appId = $merchantExt['miniAppId'] ?? '';
|
|
|
- $key = $merchantExt['wxPayKey'] ?? '';
|
|
|
-
|
|
|
- $input = new \WxPayRefund();
|
|
|
- $input->SetTransaction_id($transaction_id);
|
|
|
- $input->SetTotal_fee($totalFee);
|
|
|
- $input->SetRefund_fee($refundFee);
|
|
|
- Yii::info('totalFee:' . $totalFee . ' refundFee:' . $refundFee);
|
|
|
- $input->SetNotify_url(Yii::$app->params['mallHost'] . '/notice/wx-refund-callback/');
|
|
|
-
|
|
|
- $config = new \WxPayConfig();
|
|
|
- $config->SetAppId($appId);
|
|
|
- $config->SetMerchantId($mid);
|
|
|
- $config->SetKey($key);
|
|
|
-
|
|
|
- $input->SetOut_refund_no($refundSn);
|
|
|
- $input->SetOp_user_id($mid);
|
|
|
- $return = \WxPayApi::refund($config, $input);
|
|
|
- if (isset($return['return_code']) == false || $return['return_code'] != 'SUCCESS' || isset($return['result_code']) == false || $return['result_code'] != 'SUCCESS') {
|
|
|
- $str = '退款失败:';
|
|
|
- foreach ($return as $rKey => $text) {
|
|
|
- $str .= $rKey . ':' . $text . " | ";
|
|
|
- }
|
|
|
- Yii::info($str);
|
|
|
+ $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);
|
|
|
+ $refundReason = '';
|
|
|
+ $aliParams = [
|
|
|
+ 'refundSn' => $refundSn,
|
|
|
+ 'orderSn' => $xsOrderSn,
|
|
|
+ 'refundAmount' => $refundFee,
|
|
|
+ 'refundReason' => $refundReason,
|
|
|
+ ];
|
|
|
+ $response = $laResource->refund($aliParams);
|
|
|
+ if (isset($response['code']) == false || $response['code'] != 'BBS00000') {
|
|
|
util::fail('退款失败');
|
|
|
}
|
|
|
- $wxRefundId = $return['refund_id'] ?? '';
|
|
|
+ $wxRefundId = isset($response['resp_data']['trade_no']) ? $response['resp_data']['trade_no'] : '';
|
|
|
$refund->thirdRefundNo = $wxRefundId;
|
|
|
$refund->save();
|
|
|
}
|