|
|
@@ -7,6 +7,7 @@ use biz\sj\services\MerchantService;
|
|
|
use bizHd\saas\services\RenewService;
|
|
|
use bizHd\saas\services\SetMealService;
|
|
|
use bizHd\user\services\UserService;
|
|
|
+use bizHd\wx\classes\WxOpenClass;
|
|
|
use common\components\dict;
|
|
|
use common\components\httpUtil;
|
|
|
use common\components\util;
|
|
|
@@ -25,26 +26,24 @@ class RenewController extends BaseController
|
|
|
//微信支付购买 ssh 2020.1.11
|
|
|
public function actionWxPay()
|
|
|
{
|
|
|
- util::fail('即将开通...');
|
|
|
ini_set('date.timezone', 'Asia/Shanghai');
|
|
|
- $merchantId = Yii::$app->request->get('merchantId', 0);
|
|
|
- $merchant = MerchantService::getMerchantById($merchantId);
|
|
|
- if (empty($merchant)) {
|
|
|
- util::fail('没有找到商家');
|
|
|
- }
|
|
|
- $setId = isset($merchant['setId']) ? $merchant['setId'] : 0;
|
|
|
+ $sj = $this->sj;
|
|
|
+ $setId = isset($sj['setId']) ? $sj['setId'] : 0;
|
|
|
$set = SetMealService::getById($setId);
|
|
|
if (empty($set)) {
|
|
|
util::fail('没有找到套餐');
|
|
|
}
|
|
|
- $userId = $this->userId;
|
|
|
- $addData['userId'] = $userId;
|
|
|
+ $shopAdminId = $this->shopAdminId;
|
|
|
+ $addData['shopAdminId'] = $shopAdminId;
|
|
|
+ $shopAdmin = $this->shopAdmin;
|
|
|
+ $adminName = $shopAdmin['name'] ?? '';
|
|
|
+ $addData['shopAdminName'] = $adminName;
|
|
|
$price = $set['price'];
|
|
|
$prePrice = $price;
|
|
|
$actPrice = $price;
|
|
|
$addData['actPrice'] = $actPrice;
|
|
|
$addData['prePrice'] = $prePrice;
|
|
|
- $addData['merchantId'] = $merchantId;
|
|
|
+ $addData['merchantId'] = $this->sjId;
|
|
|
$now = time();
|
|
|
$expireTime = $now + 300;//订单5分钟后过期
|
|
|
$addData['deadline'] = $expireTime;
|
|
|
@@ -54,15 +53,11 @@ class RenewController extends BaseController
|
|
|
$couponId = 0;
|
|
|
$name = $set['name'] . '开通续费';
|
|
|
$totalFee = $actPrice;
|
|
|
- $userId = $addData['userId'];
|
|
|
- $user = UserService::getById($userId);
|
|
|
+ $admin = $this->admin;
|
|
|
//小程序使用miniOpenId
|
|
|
- if (httpUtil::isMiniProgram()) {
|
|
|
- $openId = $user['miniOpenId'];
|
|
|
- } else {
|
|
|
- $openId = $user['openId'];
|
|
|
- }
|
|
|
- $capitalType = dict::getDict('capitalType','xhRenew','id');
|
|
|
+ $openId = $admin['miniOpenId'];
|
|
|
+
|
|
|
+ $capitalType = dict::getDict('capitalType', 'xhRenew', 'id');
|
|
|
$attach = 'capitalType=' . $capitalType . '&couponId=' . $couponId;//将流水类型、优惠卷传过去
|
|
|
$wx = Yii::getAlias("@vendor/weixin");
|
|
|
require_once($wx . '/lib/WxPay.Api.php');
|
|
|
@@ -78,23 +73,23 @@ class RenewController extends BaseController
|
|
|
$input->SetTrade_type("JSAPI");
|
|
|
|
|
|
//花卉宝代为申请的微信支付
|
|
|
- $merchantExtend = MerchantExtendService::getByMerchantId($this->sjId);
|
|
|
- if (isset($merchantExtend['wxPayApply']) && $merchantExtend['wxPayApply'] == 1) {
|
|
|
+ $sjExtend = WxOpenClass::getGhsWxInfo();
|
|
|
+ if (isset($sjExtend['wxPayApply']) && $sjExtend['wxPayApply'] == 1) {
|
|
|
$input->SetSub_openid($openId);
|
|
|
} else {
|
|
|
$input->SetOpenid($openId);
|
|
|
}
|
|
|
//小程序使用miniAppId
|
|
|
if (httpUtil::isMiniProgram()) {
|
|
|
- $merchantExtend['wxAppId'] = $merchantExtend['miniAppId'];
|
|
|
+ $sjExtend['wxAppId'] = $sjExtend['miniAppId'];
|
|
|
}
|
|
|
|
|
|
- $wxOrder = \WxPayApi::unifiedOrder($input, 6, $merchantExtend);
|
|
|
+ $wxOrder = \WxPayApi::unifiedOrder($input, 6, $sjExtend);
|
|
|
$tools = new \JsApiPay();
|
|
|
- $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $merchantExtend);
|
|
|
+ $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $sjExtend);
|
|
|
$newParams = json_decode($jsApiParameters, true);
|
|
|
$newParams['orderId'] = $orderId;
|
|
|
- $newParams['merchantId'] = $merchantId;
|
|
|
+ $newParams['merchantId'] = $this->sjId;
|
|
|
util::success($newParams);
|
|
|
}
|
|
|
|