master
tping 3 years ago
parent a1cb135e41
commit db15df0a61

@ -135,6 +135,7 @@ class BaseController extends Controller
$out_trade_no = "PF_" . date('Ymd') . date('His') . sp_random_string(4);
$request = $d;
$request['discount_amount'] = 0;
$request['pay_order_number'] = $out_trade_no;
$request['price'] = $bind_balance;
$request['deduction_amount'] = 0;
@ -186,8 +187,58 @@ class BaseController extends Controller
}
}
}
if ($d['discount_amount'] > 0) { // 折扣金额大于0
$balance = M('user', 'tab_')->where(array(
'id' => $d['user_id'],
))->getField('balance');
$di = discountInfo($d['game_id']);
if (!$di || $di['status'] != 1 || $di['start_time'] > time() || $di['end_time'] < time()) {
$this->record_logs($d['discount_amount'] . "折扣失效,退还平台币" . serialize($di));
$createTime = time();
$depositId = M('deposit', "tab_")->add([
'order_number' => $data['trade_no'],
'pay_order_number' => 'PF_' . $data['out_trade_no'],
'user_id' => $d['user_id'],
'user_account' => $d['user_account'],
'user_nickname' => $d['user_nickname'],
'promote_id' => $d['promote_id'],
'promote_account' => $d['promote_account'],
'pay_amount' => $d['pay_amount'],
'pay_status' => 1,
'pay_way' => $d['pay_way'],
'pay_source' => 2, // 0官网 1推广后台 2移动端
'pay_ip' => $d['spend_ip'],
'create_time' => $createTime,
'payed_time' => time(),
'sdk_version' => $d['sdk_version'],
'check_sign' => get_check_sign($d['user_id'], $data['trade_no'], $d['pay_amount'], $createTime),
]);
$valueDetailLogModel->addLog($d['user_id'], 'PF_' . $data['out_trade_no'],
$balance, $d['pay_amount'], $balance + $d['pay_amount'], $valueDetailLogModel::BALANCE, "游戏支付时候折扣失效,增加到平台币", 2);
$user = M("user", "tab_");
$user->where("id=" . $d['user_id'])->setInc("balance", $d['pay_amount']);
$user->where("id=" . $d['user_id'])->setInc("cumulative", $d['pay_amount']);
//APP邀请好友消费奖励平台币
$this->inviteFriendAward($d['user_id'], $d['pay_amount'], 'PF_' . $data['out_trade_no']);
//充值奖励积分
$this->rechargeAwardPoint($d['user_id'], $d['pay_amount']);
// 当天累计充值
$this->payTodayTotal($d['pay_amount'], $d['pay_way']);
$data_save['pay_status'] = 1;
$data_save['order_number'] = $data['trade_no'];
$data_save['payed_time'] = time();
$data_save['pay_time'] = $data_save['payed_time'];
$map_s['pay_order_number'] = $data['out_trade_no'];
$r = $spend->where($map_s)->save($data_save);
return false;
}
}
$data_save['pay_status'] = 1;
$data_save['order_number'] = $data['trade_no'];

@ -3216,3 +3216,23 @@ function post_async($url="'http://47.111.118.107:9501/game-event/recharge'", $da
return true;
}
function discountInfo($gameId, $time=0)
{
if (!$time) $time = time();
$baseGame = M('base_game', 'tab_')->where([
'android_game_id|ios_game_id' => $gameId
])->find();
if (!$baseGame) {
return false;
}
$discount = M('game_discount','tab_')->where([
'base_game_id' => $baseGame['id'],
'start_time' => ['elt', $time],
'end_time' => ['gt', $time],
'status' => 1,
])->find();
return $discount;
}

Loading…
Cancel
Save