|
|
@@ -50,6 +50,46 @@ class RechargeController extends BaseController
|
|
|
if (empty($openId)) {
|
|
|
util::fail('没有找到openId');
|
|
|
}
|
|
|
+
|
|
|
+ //已经发起过支付,需要更换单号
|
|
|
+ if ($recharge->payRequest == 1 || $recharge->payRequest == 2) {
|
|
|
+ $closeOrderSn = $orderSn;
|
|
|
+ //老单号需要关单,否则有付款成功的风险,老单号关闭成功了,才能生成新单号
|
|
|
+ $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);
|
|
|
+ $closeParams = ['orderSn' => $closeOrderSn];
|
|
|
+ if ($recharge->payRequest == 1) {
|
|
|
+ //聚合支付关单
|
|
|
+ $response = $laResource->close($closeParams);
|
|
|
+ if (!isset($response['code']) || $response['code'] != 'BBS00000') {
|
|
|
+ $msg = $response['msg'] ?? '';
|
|
|
+ noticeUtil::push('重点注意,充值换单号没有成功,单号:' . $closeOrderSn . ',关单没有成功,' . $msg, '15280215347');
|
|
|
+ util::fail('出错了哦,请重新操作哈');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //收银台关单
|
|
|
+ $closeParams = ['orderSn' => $closeOrderSn];
|
|
|
+ $response = $laResource->cashClose($closeParams);
|
|
|
+ if (!isset($response['code']) || $response['code'] != '000000') {
|
|
|
+ $msg = $response['msg'] ?? '';
|
|
|
+ noticeUtil::push('单号:' . $closeOrderSn . ',关单没有成功(收银台-支付宝),' . $msg, '15280215347');
|
|
|
+ util::fail('出错了哦,请重新操作呢');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //生成新的订单,避免重复
|
|
|
+ $orderSn = orderSn::getRechargeSn();
|
|
|
+ $recharge->orderSn = $orderSn;
|
|
|
+ $recharge->save();
|
|
|
+ }
|
|
|
$name = '充值销账,单号' . $orderSn;
|
|
|
$totalFee = $recharge->amount ?? 0;
|
|
|
$orderId = $recharge->id;
|
|
|
@@ -79,6 +119,11 @@ class RechargeController extends BaseController
|
|
|
'couponId' => 0,
|
|
|
];
|
|
|
$response = $laResource->driveWxPay($wxParams);
|
|
|
+
|
|
|
+ //0没有唤起过第三方支付,1唤起过聚合支付,2唤起过收银台。主要针对拉卡拉支付。
|
|
|
+ $recharge->payRequest = 1;
|
|
|
+ $recharge->save();
|
|
|
+
|
|
|
if (!isset($response['code']) || $response['code'] != 'BBS00000') {
|
|
|
$errMsg = $response['msg'] ?? '';
|
|
|
noticeUtil::push($errMsg, '15280215347');
|
|
|
@@ -152,8 +197,8 @@ class RechargeController extends BaseController
|
|
|
}
|
|
|
if (empty($salt)) {
|
|
|
|
|
|
- }else{
|
|
|
- if($hd->salt != $salt){
|
|
|
+ } else {
|
|
|
+ if ($hd->salt != $salt) {
|
|
|
util::fail('不是你的花店哦');
|
|
|
}
|
|
|
}
|