|
|
@@ -9,8 +9,10 @@ use bizHd\ghs\classes\GhsClass;
|
|
|
use bizHd\shop\classes\ShopClass;
|
|
|
use common\components\lakala\Lakala;
|
|
|
use common\components\dict;
|
|
|
+use common\components\noticeUtil;
|
|
|
use common\components\orderSn;
|
|
|
use common\components\util;
|
|
|
+use bizHd\wx\classes\WxOpenClass;
|
|
|
use Yii;
|
|
|
|
|
|
class CustomRechargeController extends BaseController
|
|
|
@@ -25,6 +27,7 @@ class CustomRechargeController extends BaseController
|
|
|
$post = Yii::$app->request->post();
|
|
|
$payWay = isset($post['payWay']) ? $post['payWay'] : 0;
|
|
|
$actPrice = $post['actPrice'] ?? 0;
|
|
|
+ $totalFee = $actPrice;
|
|
|
$ghsId = $post['ghsId'] ?? 0;
|
|
|
$salt = $post['salt'] ?? '';
|
|
|
$ghs = GhsClass::getById($ghsId, true);
|
|
|
@@ -39,7 +42,6 @@ class CustomRechargeController extends BaseController
|
|
|
if (empty($custom)) {
|
|
|
util::fail('供货商信息不完整那');
|
|
|
}
|
|
|
-
|
|
|
$capitalType = dict::getDict('capitalType', 'customRechargeToGhs', 'id');
|
|
|
|
|
|
$customOrderSn = orderSn::getGhsCustomRechargeSn();
|
|
|
@@ -121,11 +123,77 @@ class CustomRechargeController extends BaseController
|
|
|
$gRecharge->customRechargeId = $cRechargeId;
|
|
|
$gRecharge->save();
|
|
|
|
|
|
+ $subject = '充值销账 单号' . $customOrderSn;
|
|
|
if ($payWay == 0) {
|
|
|
|
|
|
+ $openId = '';
|
|
|
+ if (isset($post['currentMiniOpenId']) && !empty($post['currentMiniOpenId'])) {
|
|
|
+ $openId = $post['currentMiniOpenId'];
|
|
|
+ }
|
|
|
+ if (empty($openId)) {
|
|
|
+ if (isset($this->admin) && !empty($this->admin)) {
|
|
|
+ if (isset($this->admin->miniOpenId) && !empty($this->admin->miniOpenId)) {
|
|
|
+ $openId = $this->admin->miniOpenId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (empty($openId)) {
|
|
|
+ $currentShop = ShopClass::getById($customShopId, true);
|
|
|
+ $currentShopName = $currentShop->merchantName . ' ' . $currentShop->shopName;
|
|
|
+ $currentMobile = $currentShop->mobile ?? '';
|
|
|
+ noticeUtil::push("花店充值时,发现没有openId,请跟进是否充值成功。{$currentShopName} {$currentMobile}", '15280215347');
|
|
|
+ util::success(['hasError' => 1, 'hasNoMiniOpenId' => 1]);
|
|
|
+ }
|
|
|
+ $merchantExtend = WxOpenClass::getWxInfo();
|
|
|
+
|
|
|
+ $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/cash-pay-callback";
|
|
|
+ $wxParams = [
|
|
|
+ 'orderSn' => $customOrderSn,
|
|
|
+ 'amount' => $totalFee,
|
|
|
+ 'capitalType' => $capitalType,
|
|
|
+ 'notifyUrl' => $notifyUrl,
|
|
|
+ 'wxAppId' => $merchantExtend['miniAppId'],
|
|
|
+ 'openId' => $openId,
|
|
|
+ 'subject' => $subject,
|
|
|
+ 'couponId' => 0,
|
|
|
+ ];
|
|
|
+ $response = $laResource->driveWxPay($wxParams);
|
|
|
+ if (isset($response['code']) == false || $response['code'] != 'BBS00000') {
|
|
|
+ $errMsg = $response['msg'] ?? '';
|
|
|
+ noticeUtil::push('编号99891:' . $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' => $gRechargeId,
|
|
|
+ 'appId' => $appId,
|
|
|
+ 'nonceStr' => $nonceStr,
|
|
|
+ 'paySign' => $paySign,
|
|
|
+ 'package' => $package,
|
|
|
+ 'signType' => $signType,
|
|
|
+ 'timeStamp' => $timeStamp,
|
|
|
+ 'orderSn' => $customOrderSn,
|
|
|
+ ];
|
|
|
+ util::success($new);
|
|
|
+
|
|
|
} elseif ($payWay == 1) {
|
|
|
- $totalFee = $actPrice;
|
|
|
- $subject = '充值销账 单号' . $customOrderSn;
|
|
|
$merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
|
|
|
$lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
|
|
|
$params = [
|