From 043406c356949d877e22e5d2cf99aeb62db55ed3 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Mon, 6 Nov 2023 15:26:01 +0800 Subject: [PATCH] update --- .../controllers/Alipay/BPassController.php | 18 +++++ .../Service/AliBPass/demo/AliEcoService.php | 67 +++++++++++++++++++ src/common/Service/Pay/AlipayK12Service.php | 2 +- 3 files changed, 86 insertions(+), 1 deletion(-) diff --git a/src/applet/app/controllers/Alipay/BPassController.php b/src/applet/app/controllers/Alipay/BPassController.php index e29aa39..86054f0 100644 --- a/src/applet/app/controllers/Alipay/BPassController.php +++ b/src/applet/app/controllers/Alipay/BPassController.php @@ -108,4 +108,22 @@ class BPassController extends ControllerBase } } + public function AlipayPlanetEcocampusApiRosterConsumeLimitAction() + { + if ($this->request->isPost()) { + $args = $this->request->getJsonRawBody(true); + + $result = (new AliEcoService())->alipayPlanetEcocampusApiRosterConsumeLimit( + $args["consume_limit_sync_info"], $args["school_code"], $args["school_name"] + ); + + if (!$result["status"]) { + $this->api(Msg::NewError($result["data"]["code"] ?? 500, $result["msg"])); + } + $this->api($result["data"]); + } else { + $this->api(Msg::NewError(500, '提交方式错误!')); + } + } + } diff --git a/src/common/Service/AliBPass/demo/AliEcoService.php b/src/common/Service/AliBPass/demo/AliEcoService.php index 75ea86e..dfc1ae8 100644 --- a/src/common/Service/AliBPass/demo/AliEcoService.php +++ b/src/common/Service/AliBPass/demo/AliEcoService.php @@ -371,6 +371,73 @@ class AliEcoService extends BaseService } } + /** + * alipay.planet.ecocampus.api.roster.consumeLimit(消费限制信息批量同步) + * @param $consume_limit_sync_info string 消费限制信息同步请求 + * @param $school_code string 学校内标 + * @param $school_name string 学校名称 + * @return array + */ + public function alipayPlanetEcocampusApiRosterConsumeLimit($consume_limit_sync_info, $school_code, $school_name): array + { + + // cleint初始 + $client = new \EcoApiClient(); + + // 根据环境,选择行星OPENAPI网关地址 + $client->gatewayUrl = $this->serverUrl; + $client->rsaPrivateKey = $this->privateKey; + $client->alipayrsaPublicKey = $this->alipayPublicKey; + $client->signType = $this->signType; + $client->format = $this->format; + + // 业务参数 + $bizContent["consume_limit_sync_info"] = $consume_limit_sync_info; + $bizContent["school_code"] = $school_code; + $bizContent["school_name"] = $school_name; + + // 指定需要调用的service接口 + $params["service"] = "alipay.planet.ecocampus.api.roster.consumeLimit"; + $params["request_id"] = "" . uuid(); + $params["biz_content"] = json_encode($bizContent); + $params["version"] = "1.0"; + + // 其他参数 + $params["charset"] = $this->charset; + $params["isv_app_id"] = $this->appId; + $params["utc_timestamp"] = "" . msectime(); + + //获取签名 + $sign = $client->generateSign($params, $this->signType); + + // 调用ECOAPI + $result = $client->call($params); + + $jsonStr = json_encode($result); + + + // 响应的签名验证 转成Array 而非 Object + $resMapData = json_decode($jsonStr, true); + $this->logger($resMapData, 'alipayPlanetEcocampusApiRosterConsumeLimit', true); + + // 验签 + $verifyRes = checkResponse($resMapData, $client->alipayrsaPublicKey); + + if ($verifyRes) { +// echo "响应验签成功"; + $responseData = $resMapData["response"]; + if ($responseData['code'] == 10000) { + return $this->returnRes(true, $responseData["msg"], $responseData); + } else { + return $this->returnRes(false, ($responseData['sub_msg'] ?? $responseData['msg']), $resMapData); + } + } else { +// echo "响应验签失败"; + return $this->returnRes(false, "响应验签失败", []); + + } + } + } diff --git a/src/common/Service/Pay/AlipayK12Service.php b/src/common/Service/Pay/AlipayK12Service.php index aaf95a8..5f39d8a 100644 --- a/src/common/Service/Pay/AlipayK12Service.php +++ b/src/common/Service/Pay/AlipayK12Service.php @@ -69,7 +69,7 @@ class AlipayK12Service extends BaseService * 教育场景子业务码: SCHOOL_PAYMENT_REMOTE_OPEN_ACCOUNT:校园一脸通行集采邀请(生成的token用于集采邀请发送采集阶段); * SCHOOL_FACE_PASS_QUERY:校园一脸通行查询(生成的token用于查询用户的一脸通行开通状态); * SCHOOL_FACE_PASS_NAVIGATE:校园一脸通行跳转(生成的token用于个采开通阶段的用户信息填充) - * @param $cert_type string 证件类型。{1:居民身份证;A:护照} + * @param $cert_type string 证件类型。{1:居民身份证;A:护照; X:学工号} * @param $cert_no string 证件号码 * @param $school_std_code string 学校外标 * @param $student_name string 学生/教职工/访客姓名