From ce2f6cfc6201db243cb443d6cdb821b3c4b1ad75 Mon Sep 17 00:00:00 2001 From: mzeros Date: Fri, 27 Dec 2024 17:47:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(gateway):=20=E4=BF=AE=E5=A4=8D=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E8=BF=9B=E4=BB=B7=E9=AA=8C=E8=AF=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将安全进价验证逻辑从签名开始位置移动到签名结束位置 -完善了安全进价的计算和对比逻辑 - 增加了对不同产品类型的处理- 优化了百分比计算方式,支持固定值和比例两种方式 --- app/gateway/controller/v4/Core.php | 41 ++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/app/gateway/controller/v4/Core.php b/app/gateway/controller/v4/Core.php index 8ea7e62..070fabd 100644 --- a/app/gateway/controller/v4/Core.php +++ b/app/gateway/controller/v4/Core.php @@ -151,11 +151,7 @@ class Core extends Controller $this->getMerchant(); - #验证安全进价是否匹配 - if ($this->product && $this->product != 'query' && $this->product != '' && isset($this->input['safe_price'])) { - $safe_price = $this->input['safe_price']; -// $actual_price = ; - } + } /** @@ -204,6 +200,41 @@ class Core extends Controller $this->no($signature); } + #签名结束 + + #验证安全进价是否匹配 + if ($this->product && $this->product != 'query' && $this->product != '' && isset($this->input['safe_price']) && isset($this->input['cash'])) { + $safe_price = $this->input['safe_price']; + $info = PercentService::instance()->get($this->mid, $this->product); + $percent_type = 1; + if ($info && $info['percent']) { + $percent = $info['percent']; + if (isset($info['percent_type']) && $info['percent_type']) { + $percent_type = $info['percent_type']; + } + if($this->product == 'dhcz'){ + $percent = MerchantService::instance()->getPercent($percent, $this->input['mobile'], $this->product, $this->input['cash'], $info['rule']); + }else{ + $percent = MerchantService::instance()->getPercent($percent, '', $this->product, $this->input['cash'], $info['rule']); + } + + } + + $new_cash = $this->input['cash']; + if (isset($percent) && $percent > 0) { + if ($percent_type == 2) { + $new_cash = $percent; + } else { + $new_cash = $percent*$this->input['cash']; + } + } + #对比 + if($safe_price < $new_cash){ + $this->no(-201); + } + + } + // 检测如果商户开启了特定商品指定携转检测,则进入此验证 if (isset($this->merchant['other_param']) && str_contains($this->merchant['other_param'], 'mnp_SProduct_isp')) {