|
|
@@ -149,7 +149,18 @@ class PayMentService
|
|
|
$matrix = [];
|
|
|
foreach ($services as $v) {
|
|
|
for ($i = 0; $i < $v->sort; $i++) {
|
|
|
- if(Redis::exists("PayErro_".$v->config_key)) continue;
|
|
|
+// if(Redis::exists("PayErro_".$v->config_key)) continue;
|
|
|
+ if(!empty($v->remarks)&&$v->remarks!=null){
|
|
|
+ $remarks=json_decode($v->remarks,true);
|
|
|
+ // 按支付类型校验金额是否在允许范围内:不满足则跳过该渠道
|
|
|
+ if(isset($remarks['limit'])){
|
|
|
+ $typeKey='type_'.$pay_method;
|
|
|
+ $limitConfig=$remarks['limit'][$typeKey]??null;
|
|
|
+ if($limitConfig!==null && !self::isAmountInLimit($payAmt,$limitConfig)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
$matrix[] = $v->config_key;
|
|
|
}
|
|
|
}
|
|
|
@@ -163,6 +174,36 @@ class PayMentService
|
|
|
$res = $matrix[mt_rand(0, count($matrix)-1)];
|
|
|
return $res;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断支付金额是否在 limit 配置的取值范围内
|
|
|
+ * @param float $payAmt 支付金额
|
|
|
+ * @param mixed $limitConfig 配置:数组为允许金额列表;['min'=>x,'max'=>y] 为区间;'all' 或 ['全部'] 为不限制
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ public static function isAmountInLimit($payAmt, $limitConfig)
|
|
|
+ {
|
|
|
+ if ($limitConfig === 'all' || $limitConfig === '全部' || $limitConfig === ['全部']) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (isset($limitConfig['min']) && isset($limitConfig['max'])) {
|
|
|
+ $min = (float)$limitConfig['min'];
|
|
|
+ $max = (float)$limitConfig['max'];
|
|
|
+ $amt = (float)$payAmt;
|
|
|
+ return $amt >= $min && $amt <= $max;
|
|
|
+ }
|
|
|
+ if (is_array($limitConfig)) {
|
|
|
+ $payAmtRounded = round((float)$payAmt, 2);
|
|
|
+ foreach ($limitConfig as $allowed) {
|
|
|
+ if (round((float)$allowed, 2) === $payAmtRounded) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据支付方式随机获取充值渠道
|
|
|
* @param $method
|