|
|
|
@ -1995,8 +1995,40 @@ function get_default_payment_config($way=1) {
|
|
|
|
|
return ['code' => 0, 'msg' => '', 'data' => $merchant];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getMasterPaymentMerchant($way)
|
|
|
|
|
{
|
|
|
|
|
$conditions = [];
|
|
|
|
|
$conditions['_string'] = 'ways&' . $way . '=' . $way;
|
|
|
|
|
$conditions['status'] = 1;
|
|
|
|
|
$conditions['is_master'] = 1;
|
|
|
|
|
return M('payment_merchant', 'tab_')->where($conditions)->select();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function checkIsUserMasterMerchant($baseGame, $userId, $payAmount)
|
|
|
|
|
{
|
|
|
|
|
$rule = M('game_master_merchant_rule', 'tab_')->where(['base_game_id' => $baseGame['id']])->find();
|
|
|
|
|
if (empty($rule)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$count = M('spend', 'tab_')->where([
|
|
|
|
|
'game_id' => ['in', [$baseGame['android_game_id'], $baseGame['ios_game_id']]],
|
|
|
|
|
'pay_status' => 1,
|
|
|
|
|
'user_id' => $userId
|
|
|
|
|
])->count();
|
|
|
|
|
if ($rule['is_first_pay'] == 1 && $count == 0) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if ($count <= $rule['max_times'] + ($rule['is_first_pay'] == 1 ? 1 : 0)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if ($payAmount <= $rule['max_pay_amount']) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取支付配置 way 1 支付宝 2微信 3快捷
|
|
|
|
|
function get_payment_config($way=1, $game=0, $user_id=0) {
|
|
|
|
|
function get_payment_config($way=1, $game=0, $user_id=0, $payAmount = 0) {
|
|
|
|
|
$time = time();
|
|
|
|
|
$company = get_promote_company($user_id);
|
|
|
|
|
|
|
|
|
@ -2009,13 +2041,21 @@ function get_payment_config($way=1, $game=0, $user_id=0) {
|
|
|
|
|
$map['end_time'] = 0;
|
|
|
|
|
$map['_logic'] = 'or';
|
|
|
|
|
|
|
|
|
|
$baseGameId = M('base_game', 'tab_')->where([
|
|
|
|
|
$baseGame = M('base_game', 'tab_')->where([
|
|
|
|
|
'android_game_id|ios_game_id' => $game['id']
|
|
|
|
|
])->getField('id');
|
|
|
|
|
if (!$baseGameId) {
|
|
|
|
|
])->find();
|
|
|
|
|
if (!$baseGame) {
|
|
|
|
|
return ['code' => -3, 'msg' => '找不到游戏ID'.$game['id'], 'data' => []];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (checkIsUserMasterMerchant($baseGame, $user_id, $payAmount)) {
|
|
|
|
|
$payConf = getMasterPaymentMerchant($way);
|
|
|
|
|
if (!empty($payConf)) {
|
|
|
|
|
return ['code' => 0, 'msg' => '', 'data' => $payConf];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$baseGameId = $baseGame['id'];
|
|
|
|
|
$payment_rule = M('payment_rule', 'tab_')->where($map)->select();
|
|
|
|
|
$find_rule = false;
|
|
|
|
|
$rule = array();
|
|
|
|
|