Kaynağa Gözat

培训报名

shish 5 yıl önce
ebeveyn
işleme
1e824fc986

+ 11 - 36
app-mall/controllers/PxApplyController.php

@@ -5,12 +5,10 @@ namespace mall\controllers;
 use bizHd\custom\classes\CustomClass;
 use bizMall\px\classes\PxApplyClass;
 use bizMall\px\classes\PxClassClass;
-use bizMall\wx\classes\WxOpenClass;
 use common\components\dict;
-use common\components\httpUtil;
 use common\components\util;
 use Yii;
-use bizMall\promote\services\CouponService;
+use bizHd\wx\classes\WxOpenClass;
 
 /**
  * 培训报名
@@ -56,35 +54,20 @@ class PxApplyController extends BaseController
 
     public function actionWxPay()
     {
-        $data = [
-            "appId" => "wx21b7c3ef12082099",
-            "nonceStr" => "i7f1e9z6ls42f3342m4j2bngxj6rq08e",
-            "package" => "prepay_id=wx042304351179687ee46ee32d8ecf420000",
-            "signType" => "MD5",
-            "timeStamp" => "1612451097",
-            "paySign" => "39FD249CD03B24FDA1755493F09D7C2E",
-        ];
-        util::success($data);
-
         ini_set('date.timezone', 'Asia/Shanghai');
         $post = Yii::$app->request->post();
-        $orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
-        $couponId = isset($post['couponId']) ? $post['couponId'] : 0;
-
+        $orderSn = $post['orderSn'] ?? 0;
+        $couponId = 0;
         $order = PxApplyClass::getByCondition(['customId' => $this->customId, 'orderSn' => $orderSn, 'status' => PxApplyClass::STATUS_UN_CONFIRM]);
         if (empty($order)) {
             util::fail('订单号无效');
         }
         $name = $orderSn;
         $totalFee = $order['actPrice'];
-        $wxPayType = 0;
-        //小程序使用miniOpenId
-        if (httpUtil::isMiniProgram()) {
-            $openId = $this->user['miniOpenId'];
-            $wxPayType = 1;
-        } else {
-            $openId = $this->user['openId'];
-        }
+
+        //强制使用小程序miniOpenId,不再考虑web
+        $openId = $this->user['miniOpenId'];
+        $wxPayType = 1;
 
         $typeList = dict::getConfig('capitalType');
         $capitalType = $typeList['pxApply']['id'];
@@ -106,19 +89,10 @@ class PxApplyController extends BaseController
         $input->SetTime_expire(date("YmdHis", $expireTime));
         $input->SetNotify_url(Yii::$app->params['mallHost'] . '/notice/wx-callback/');
         $input->SetTrade_type("JSAPI");
+        $input->SetOpenid($openId);
 
-        //花卉宝代为申请的微信支付
-        $sjExtend = $this->sjExtend;
-        if ($sjExtend['wxPayApply'] == 1) {
-            $input->SetSub_openid($openId);
-        } else {
-            $input->SetOpenid($openId);
-        }
-
-        //小程序使用miniAppId
-        if (httpUtil::isMiniProgram()) {
-            $sjExtend['wxAppId'] = $sjExtend['miniAppId'];
-        }
+        $sjExtend = WxOpenClass::getMallWxInfo();
+        $sjExtend['wxAppId'] = $sjExtend['miniAppId'];
 
         $wxOrder = \WxPayApi::unifiedOrder($input, 6, $sjExtend);
         $tools = new \JsApiPay();
@@ -126,4 +100,5 @@ class PxApplyController extends BaseController
         $newParams = json_decode($jsApiParameters, true);
         util::success($newParams);
     }
+
 }

+ 6 - 2
common/components/dict.php

@@ -71,12 +71,14 @@ class dict
         "io" => ['payout' => 0, 'income' => 1, 'other' => 2],
         "ioName" => [0 => '支出', 1 => '收入', 2 => '其它'],
 
-        "capitalType" => [//流水类型,充值支付回调时的订单类型
+
+        //流水类型,充值支付回调时的订单类型
+        "capitalType" => [
             'xhOrder' => ['id' => 0, 'name' => 'xhOrder'],
             'xhActiveOrder' => ['id' => 2, 'name' => 'xhActiveOrder'],
             //充值
             'xhRecharge' => ['id' => 4, 'name' => 'xhRecharge'],
-            //支付宝关联微信帐号,积分累加订单
+            //支付宝关联微信
             'xhUserUnite' => ['id' => 5, 'name' => 'xhUserUnite'],
             'xhDrawCash' => ['id' => 6, 'name' => 'xhDrawCash'],
             'xhApplyOrder' => ['id' => 7, 'name' => 'xhApplyOrder'],
@@ -86,6 +88,7 @@ class dict
             'xhGhsOrder' => ['id' => 10, 'name' => 'xhGhsOrder'],
             //花店采购
             'xhPurchase' => ['id' => 11, 'name' => 'xhPurchase'],
+            //培训报名
             'pxApply' => ['id' => 12, 'name' => 'pxApply'],
         ],
         "capitalTypeList" => [//流水类型的对应链接,后台收支明细查看时跳转的链接
@@ -102,6 +105,7 @@ class dict
             12 => ['link' => '/capital/purchase-detail', 'name' => '培训报名', 'orderLink' => '', 'id' => 12,],
         ],
 
+
         //模板消息
         'tMessage' => [
             'OPENTM207430125' => '操作成功通知',