This commit is contained in:
yangduo 2024-12-31 16:34:57 +08:00
parent 98b1abbd12
commit 87ca99a9e1
2 changed files with 44 additions and 34 deletions

View File

@ -343,6 +343,7 @@ CREATE TABLE `recharge` (
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id', `idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`accountid` varchar(60) COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '账号id', `accountid` varchar(60) COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '账号id',
`first_data` mediumblob COMMENT '首充数据', `first_data` mediumblob COMMENT '首充数据',
`present_diamond` int(11) NOT NULL DEFAULT '0' COMMENT '充值赠送钻石总量',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', `modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`), PRIMARY KEY (`idx`),

View File

@ -3,7 +3,8 @@
require 'classes/Quest.php'; require 'classes/Quest.php';
require 'classes/AddReward.php'; require 'classes/AddReward.php';
class RechargeController{ class RechargeController
{
protected function getMysql($account_id) protected function getMysql($account_id)
{ {
@ -18,7 +19,8 @@ class RechargeController{
return $conn; return $conn;
} }
public function prePay() { public function prePay()
{
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
//登录校验 //登录校验
$login = loginVerify($account_id, $_REQUEST['session_id']); $login = loginVerify($account_id, $_REQUEST['session_id']);
@ -40,7 +42,7 @@ class RechargeController{
} else { } else {
$url = 'https://payservice-test.kingsome.cn/api/ingame/spreorder'; $url = 'https://payservice-test.kingsome.cn/api/ingame/spreorder';
} }
$sign = md5($_REQUEST['account_id'].$_REQUEST['goods_id'].'f3a6a9a5-217a-4079-ab99-b5d69b8212be'.$_REQUEST['session_id']); $sign = md5($_REQUEST['account_id'] . $_REQUEST['goods_id'] . 'f3a6a9a5-217a-4079-ab99-b5d69b8212be' . $_REQUEST['session_id']);
$params = array( $params = array(
'account_id' => $_REQUEST['account_id'], 'account_id' => $_REQUEST['account_id'],
'goods_id' => $goods_id, 'goods_id' => $goods_id,
@ -57,16 +59,17 @@ class RechargeController{
phpcommon\sendError(ERR_RETRY, '系统繁忙2'); phpcommon\sendError(ERR_RETRY, '系统繁忙2');
return; return;
} }
$response = json_decode($rsp, true); $response = json_decode($rsp, true);
echo json_encode(array( echo json_encode(array(
'errcode' => $response['errcode'], 'errcode' => $response['errcode'],
'errmsg'=> $response['errmsg'], 'errmsg' => $response['errmsg'],
'order_id' => $response['order_id'] 'order_id' => $response['order_id']
)); ));
} }
public function payDone() { public function payDone()
{
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
//登录校验 //登录校验
$login = loginVerify($account_id, $_REQUEST['session_id']); $login = loginVerify($account_id, $_REQUEST['session_id']);
@ -88,7 +91,7 @@ class RechargeController{
} else { } else {
$url = 'https://payservice-test.kingsome.cn/api/ingame/paid'; $url = 'https://payservice-test.kingsome.cn/api/ingame/paid';
} }
$sign = md5($_REQUEST['account_id'].$_REQUEST['order_id'].'f3a6a9a5-217a-4079-ab99-b5d69b8212be'.$_REQUEST['session_id']); $sign = md5($_REQUEST['account_id'] . $_REQUEST['order_id'] . 'f3a6a9a5-217a-4079-ab99-b5d69b8212be' . $_REQUEST['session_id']);
$params = array( $params = array(
'account_id' => $_REQUEST['account_id'], 'account_id' => $_REQUEST['account_id'],
'order_id' => $order_id, 'order_id' => $order_id,
@ -105,7 +108,7 @@ class RechargeController{
phpcommon\sendError(ERR_RETRY, '系统繁忙 2'); phpcommon\sendError(ERR_RETRY, '系统繁忙 2');
return; return;
} }
$response = json_decode($rsp, true); $response = json_decode($rsp, true);
$diamonds = $response['diamond']; $diamonds = $response['diamond'];
$diamond_num = -1; $diamond_num = -1;
@ -144,15 +147,18 @@ class RechargeController{
) )
); );
if (!$rechargerow) { if (!$rechargerow) {
$ret = $conn->execScript('INSERT INTO recharge(accountid, first_data, create_time, modify_time) ' . $ret = $conn->execScript(
' VALUES(:account_id, :first_data, :create_time, :modify_time) ' . 'INSERT INTO recharge(accountid, first_data, present_diamond, create_time, modify_time) ' .
' ON DUPLICATE KEY UPDATE accountid=:account_id, first_data=:first_data, modify_time=:modify_time;', ' VALUES(:account_id, :first_data, :present_diamond, :create_time, :modify_time) ' .
array( ' ON DUPLICATE KEY UPDATE accountid=:account_id, first_data=:first_data, present_diamond=:present_diamond, modify_time=:modify_time;',
':account_id' => $account_id, array(
':first_data' => $goodsid, ':account_id' => $account_id,
':create_time' => time(), ':first_data' => $goodsid,
':modify_time' => time() ':present_diamond' => $diamond_present,
)); ':create_time' => time(),
':modify_time' => time()
)
);
} else { } else {
$firstlist = explode(',', $rechargerow['first_data']); $firstlist = explode(',', $rechargerow['first_data']);
$firstrecharge = true; $firstrecharge = true;
@ -163,13 +169,16 @@ class RechargeController{
} }
if ($firstrecharge) { if ($firstrecharge) {
$ret = $conn->execScript('UPDATE recharge SET first_data=:first_data, modify_time=:modify_time' . $ret = $conn->execScript(
' WHERE accountid=:accountid;', 'UPDATE recharge SET first_data=:first_data, present_diamond=:present_diamond, modify_time=:modify_time' .
array( ' WHERE accountid=:accountid;',
':accountid' => $account_id, array(
':first_data' => $rechargerow['first_data'].','.$goodsid, ':accountid' => $account_id,
':modify_time' => time() ':first_data' => $rechargerow['first_data'] . ',' . $goodsid,
)); ':present_diamond' => $rechargerow['present_diamond'] + $diamond_present,
':modify_time' => time()
)
);
} else { } else {
$diamond_present = 0; $diamond_present = 0;
} }
@ -178,26 +187,26 @@ class RechargeController{
} }
$diamond_num = $userrow['diamond_num'] + $diamonds + $diamond_present; $diamond_num = $userrow['diamond_num'] + $diamonds + $diamond_present;
$ret = $conn->execScript('UPDATE user SET diamond_num=:diamond_num' . $ret = $conn->execScript(
' WHERE accountid=:accountid;', 'UPDATE user SET diamond_num=:diamond_num' .
array( ' WHERE accountid=:accountid;',
':accountid' => $account_id, array(
':diamond_num' => $diamond_num ':accountid' => $account_id,
)); ':diamond_num' => $diamond_num
)
);
if (!$ret) { if (!$ret) {
die(); die();
return; return;
} }
} }
echo json_encode(array( echo json_encode(array(
'errcode' => $response['errcode'], 'errcode' => $response['errcode'],
'errmsg'=> $response['errmsg'], 'errmsg' => $response['errmsg'],
'order_id' => $response['order_id'], 'order_id' => $response['order_id'],
'diamond_nums' => $diamond_num, 'diamond_nums' => $diamond_num,
'diamond_present' => $diamond_present 'diamond_present' => $diamond_present
)); ));
} }
} }
?>