request->get(); $classId = $get['classId'] ?? 0; $info = PxClassClass::getClassInfo($classId); PxClassClass::valid($info, $this->sjId); $customId = $this->customId; if (empty($customId)) { util::fail('没有找到学员信息'); } $custom = CustomClass::getCustomInfo($customId); if (empty($custom)) { util::fail('没有学员信息'); } CustomClass::valid($custom, $this->shopId); $get['sjId'] = $this->sjId; $get['prePrice'] = $info['tuition']; $get['actPrice'] = $info['tuition']; $get['shopId'] = $this->shopId; $get['shopAdminId'] = 0; $get['customId'] = $this->customId; $get['customName'] = $custom['name'] ?? ''; $get['customAvatar'] = $custom['avatar'] ?? ''; $get['className'] = $info['name'] ?? ''; $get['classCover'] = $info['cover'] ?? ''; $get['applyTime'] = date("Y-m-d H:i:s"); $get['status'] = PxApplyClass::STATUS_UN_CONFIRM; $respond = \bizHd\px\classes\PxApplyClass::addApply($get, true); util::success($respond); } //新学员 学员管理 ssh 2021.3.17 public function actionList() { $where = ['shopId' => $this->shopId]; $respond = PxApplyClass::getApplyList($where); util::success($respond); } public function actionWxPay() { ini_set('date.timezone', 'Asia/Shanghai'); $get = Yii::$app->request->get(); $orderSn = $get['orderSn'] ?? ''; if (empty($orderSn)) { util::fail('没有订单号'); } $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']; //强制使用小程序miniOpenId,不再考虑web $openId = $this->user['miniOpenId']; $wxPayType = 1; $capitalType = dict::getDict('capitalType', 'pxApply', 'id'); $attach = "couponId=" . $couponId . "&capitalType=" . $capitalType . '&wxPayType=' . $wxPayType; //订单30分钟后过期 $now = time(); $expireTime = $now + 1800; $wx = Yii::getAlias("@vendor/weixin"); require_once($wx . '/lib/WxPay.Api.php'); require_once($wx . '/example/WxPay.JsApiPay.php'); $input = new \WxPayUnifiedOrder(); $input->SetBody($name); $input->SetOut_trade_no($orderSn); $input->SetTotal_fee($totalFee * 100); $input->SetTime_start(date("YmdHis", $now)); $input->SetAttach($attach);//将流水类型、代金劵等传给微信再回传 $input->SetTime_expire(date("YmdHis", $expireTime)); $input->SetNotify_url(Yii::$app->params['mallHost'] . '/notice/wx-callback/'); $input->SetTrade_type("JSAPI"); $input->SetOpenid($openId); $sjExtend = WxOpenClass::getMallWxInfo(); $sjExtend['wxAppId'] = $sjExtend['miniAppId']; $wxOrder = \WxPayApi::unifiedOrder($input, 6, $sjExtend); $tools = new \JsApiPay(); $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $sjExtend); $newParams = json_decode($jsApiParameters, true); util::success($newParams); } }