"https://hx-mini.jsshuita.com.cn/license.jpg" ]); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } /** * @param Request $request * @return Response */ #[Route(path: "login",methods: "post")] public function setLogin(Request $request): Response { try { $param = $request->post(); print_r($param); $sessionKey = (new Crypt)->config($this->getDyConfig())->getSessionKey($param['auth']); if (!isset($sessionKey['openid'])) return error("获取数据失败"); $openId = $sessionKey['openid']; $userIn = [ 'open_id' => $openId, "create_ip" => $request->getRealIp(), "nickname" => "用户_".strtoupper(CodeExtend::random(3,5)), "avatar" => "https://img.inmei.cc/logo.png" ]; $user = (new SaasMember)->where("open_id",$openId)->findOrEmpty(); $userIn['id'] = $user['id']; if ($user->isEmpty()) { $userIn['id'] = $user->insertGetId($userIn); } // 同步已经下单的订单 if (!empty($param['account'])) { $this->asyncDyOrder($param['account'],$openId); } return successTrans("success.data",[ "user" => get_object_vars((new AuthMode)->guard("member")->login($userIn)), "coupon" => (new SaasOrderLife)->with(['goods' => function($query){ $query->field("out_id,product_img"); }])->append(['expire_at'])->withAttr(['expire_at' => function($data,$resp){ return date("Y-m-d",strtotime($resp['expire_at'])); }])->where("open_id",$openId)->where("status",1)->select() ]); } catch (\Throwable $throwable) { echo getDateFull()."==授权登陆===".$throwable->getMessage()."\n"; echo getDateFull()."==授权登陆===".$throwable->getFile()."\n"; echo getDateFull()."==授权登陆===".$throwable->getLine()."\n"; return error($throwable->getMessage()); } } protected function decrypt2code($private_key, $ciphertext_str) { // 解码 base64 密文 $ciphertext = base64_decode($ciphertext_str); // 使用私钥解密 openssl_private_decrypt($ciphertext, $plaintext, $private_key, OPENSSL_PKCS1_PADDING); if ($plaintext === false) { return []; } return json_decode($plaintext,true); } protected function decrypt($encrypted_data, $session_key, $iv) { $data = base64_decode($encrypted_data); $key = base64_decode($session_key); $iv_decoded = base64_decode($iv); // 使用 AES-256-CBC 模式解密 return openssl_decrypt($data, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv_decoded); } }