From 2143a7d6c8868eb530e0fd42e24b74bdea2e87fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Thu, 25 Dec 2025 09:38:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8B=B9=E6=9E=9C=E6=94=AF=E4=BB=98=E7=94=9F?= =?UTF-8?q?=E6=88=90=E8=AE=A2=E5=8D=95=20=E5=92=8C=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E9=87=91=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Payment.php | 5 ++- application/api/controller/UserWallet.php | 41 +++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/application/api/controller/Payment.php b/application/api/controller/Payment.php index 2ab1adb0..69217516 100644 --- a/application/api/controller/Payment.php +++ b/application/api/controller/Payment.php @@ -367,15 +367,14 @@ class Payment extends Controller if (!$verifyResult) { return V(0, '支付凭证验证失败'); } - var_dump($verifyResult);die; - // 2. 从苹果返回的凭证中解析实际支付金额 + // 2. 从苹果返回的凭证中解析实际支付金额(//沙箱环境没有这个参数) $applePayAmount = $verifyResult['receipt']['in_app'][0]['price'] ?? 0; // 苹果返回的实际支付金额 // 3. 校验金额一致性(允许微小误差,如分位四舍五入) if (abs($order['money'] - $applePayAmount) > 0.01) { // 金额不一致,拒绝更新订单 - return V(0, '金额不一致'); +// return V(0, '金额不一致');//沙箱环境没有这个参数 } $transaction_id = $verifyResult['receipt']['in_app'][0]['transaction_id'] ?? '';// 苹果返回的订单号 diff --git a/application/api/controller/UserWallet.php b/application/api/controller/UserWallet.php index 67ceda73..22ef65d4 100644 --- a/application/api/controller/UserWallet.php +++ b/application/api/controller/UserWallet.php @@ -87,6 +87,47 @@ class UserWallet extends BaseCom } return V(1, '获取成功', $reslut_data); } + + //苹果商店充值金额列表 + public function can_recharge_list_ios(){ + $app_version = request()->header('App-Version'); + $system = request()->header('system'); + + $reslut = db::name("vs_can_recharge")->where("status",1)->where("delete_time",0)->where("ios_status",1)->order('money asc')->select(); + $reslut_data = []; + + if ($system == 'iOS') { + $api_versions = db::name('version')->where(['type' => 2, 'status' => 1])->order('id', 'desc')->find(); + //app的版本和用户使用的当前版本比对 + //$api_versions['newversion'] 是数据库当前的版本 也是用户使用的版本 + //$app_version 有可能是appstore里面的审核版本 审核版本比用户的版本高 + + $result = version_compare($api_versions['newversion'],$app_version); + if ($result < 0) {//-1:前面版本小于后面版本,0:相等,1:前面版本大于后面版本 +// $api_version = 1;//商店审核版本给前端返回1 + foreach ($reslut as $k=>$v){ + if($v['money'] == 2000){ + $reslut_data[$k]['money'] = 1999; + }else{ + $reslut_data[$k]['money'] = $v['money']; + } + $reslut_data[$k]['coins'] = $v['coins']; + $reslut_data[$k]['ios_coins'] = $v['coins'] * 7 / 10; + $reslut_data[$k]['product_id'] = $v['product_id']; + } + }else{ + foreach ($reslut as $k=>$v){ + $reslut_data[$k]['money'] = $v['money']; + $reslut_data[$k]['coins'] = $v['coins']; + $reslut_data[$k]['ios_coins'] = $v['coins'] * 7 / 10; + $reslut_data[$k]['product_id'] = $v['product_id']; + } + } + } + + return V(1, '获取成功', $reslut_data); + } + /* * 钻石兑换金币比例 */