fix(gateway): 修复安全进价验证逻辑
- 将安全进价验证逻辑从签名开始位置移动到签名结束位置 -完善了安全进价的计算和对比逻辑 - 增加了对不同产品类型的处理- 优化了百分比计算方式,支持固定值和比例两种方式
This commit is contained in:
parent
29511e09f5
commit
ce2f6cfc62
@ -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')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user