This commit is contained in:
aozhiwei 2019-08-28 19:43:16 +08:00
parent 649e0b8fd8
commit 3b2ca4e9a7
6 changed files with 291 additions and 85 deletions

4
paydb.sql Normal file
View File

@ -0,0 +1,4 @@
Usage: mysqldump [OPTIONS] database [tables]
OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help

View File

@ -379,6 +379,21 @@ CREATE TABLE `emoji` (
KEY `accountid` (`accountid`), KEY `accountid` (`accountid`),
UNIQUE KEY `accountid_emojiid` (`accountid`, `emojiid`) UNIQUE KEY `accountid_emojiid` (`accountid`, `emojiid`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS `redpack`;
/*!40101 SET @saved_cs_client = @@character_set_client*/;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `redpack` (
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`red_type` int(11) NOT NULL DEFAULT '0' COMMENT '红包类型(1:红包雨红包,2:邀请好友红包)',
`red_sum` double NOT NULL DEFAULT '0' COMMENT '红包金额(已发放的)',
`red_date` int(11) NOT NULL DEFAULT '0' COMMENT '日期某天时间的00:00:00',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
UNIQUE KEY `red_type_red_date` (`red_type`, `red_date`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;

View File

@ -76,6 +76,7 @@ define('RAND_DIAMONDSHOP_GOLD', 59); //钻石商店刷新价格
define('RAND_DIAMONDSHOP_TIME', 60); //钻石商店刷新次数 define('RAND_DIAMONDSHOP_TIME', 60); //钻石商店刷新次数
define('DIAMONDBOX', 61); //钻石宝箱花费钻石数 define('DIAMONDBOX', 61); //钻石宝箱花费钻石数
define('DIAMONDBOX10', 62); //钻石视频宝箱花费钻石数 define('DIAMONDBOX10', 62); //钻石视频宝箱花费钻石数
define('REDLIMIT', 68); //红包上限
require 'config_loader.php'; require 'config_loader.php';

View File

@ -562,7 +562,7 @@ class ActivityController{
$airReward_num = 0; $airReward_num = 0;
$last_time = 0; $last_time = 0;
if (empty($user_db_str)) { if (empty($user_db_str)) {
$airReward_list = $this->getRandomAirReward(); $airReward_list = $this->getRandomAirReward(24106);
$airReward_db = array( $airReward_db = array(
'airReward_uuid' => $airReward_uuid, 'airReward_uuid' => $airReward_uuid,
'airReward_list' => $airReward_list, 'airReward_list' => $airReward_list,
@ -572,7 +572,7 @@ class ActivityController{
} else { } else {
$user_db = json_decode($user_db_str, true); $user_db = json_decode($user_db_str, true);
unset($user_db['airReward_list']); unset($user_db['airReward_list']);
$airReward_list = $this->getRandomAirReward(); $airReward_list = $this->getRandomAirReward(24106);
$airReward_db = array( $airReward_db = array(
'airReward_uuid' => $airReward_uuid, 'airReward_uuid' => $airReward_uuid,
'airReward_list' => $airReward_list, 'airReward_list' => $airReward_list,
@ -645,14 +645,14 @@ class ActivityController{
} }
protected function getRandomAirReward() protected function getRandomAirReward($drop_id)
{ {
$airReward_list = array(); $airReward_list = array();
//随机奖励 //随机奖励
$d = $this->getDrop(24106); $d = $this->getDrop($drop_id);
if (!$d) { if (!$d) {
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
return; die();
} }
$item_id_array = $this->getExplode($d['item_id']); $item_id_array = $this->getExplode($d['item_id']);
$item_num_array = $this->getExplode($d['num']); $item_num_array = $this->getExplode($d['num']);
@ -703,54 +703,209 @@ class ActivityController{
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
return; return;
} }
$conn = $this->getMysql($account_id); $p = $this->getParameter(REDLIMIT);
if (!$conn) { $limit = $p['value'];
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
return;
}
//随机奖励 //随机奖励
$item_list = array(); $item_list = $this->getRandomAirReward(24006);
$d = $this->getDrop(24006); foreach ($item_list as $item) {
if (!$d) { if ($item['item_id'] != 10004 ) {
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励'); //增加奖励
return; $addreward = new classes\AddReward();
} $addreward->addReward($item['item_id'], $item['item_num'], $account_id);
$item_id_array = $this->getExplode($d['item_id']); } else {
$item_num_array = $this->getExplode($d['num']); //判断今日红包是否领完
$weight_array = $this->getExplode($d['weight']); $red_conn = $this->getRedMysql();
$weight_sum = 0; $row = $red_conn->execQueryOne('SELECT red_sum FROM redpack ' .
$keys = 0; ' WHERE red_type=:red_type AND red_date=:red_date;',
for ($i = 0; $i < count($weight_array); $i++) { array(
$weight_sum += $weight_array[$i][0]; ':red_type' => $_REQUEST['type'],
} ':red_date' => phpcommon\getdayseconds(time())
$random = Rand(0, $weight_sum); ));
$weight = 0; if ($row['red_sum'] + $item_num > $limit) {
for ($i = 0; $i < count($weight_array); $i++) { phpcommon\sendError(ERR_USER_BASE + 3, '今日红包已领完');
$weight += $weight_array[$i][0]; return;
if ($weight > $random) { }
$keys = $i; //红包领取现金
break; $this->getRedPack($item['item_num'] * 100, $account_id);
//更新红包数据
$this->updateRedPack($item['item_num'], $_REQUEST['type']);
} }
} }
$item_id = $item_id_array[$keys][0];
$item_num = $item_num_array[$keys][0];
array_push($item_list, array(
'item_id' => $item_id,
'item_num' => $item_num,
));
if ($item_id != 10004) {
//增加奖励
$addreward = new classes\AddReward();
$addreward->addReward($item_id, $item_num, $account_id);
} else {
//红包领取现金
}
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,
'errmsg' => '', 'errmsg' => '',
'item_list' => $item_list 'item_list' => $item_list
)); ));
} }
protected function getRedMysql()
{
$mysql_conf = getMysqlConfig();
$conn = new phpcommon\Mysql(array(
'host' => $mysql_conf['host'],
'port' => $mysql_conf['port'],
'user' => $mysql_conf['user'],
'passwd' => $mysql_conf['passwd'],
'dbname' => 'gamedb2001_' . 1
));
return $conn;
}
protected function getPayMysql($accountid)
{
$mysql_conf = getMysqlConfig(crc32($accountid));
$conn = new phpcommon\Mysql(array(
'host' => $mysql_conf['host'],
'port' => $mysql_conf['port'],
'user' => $mysql_conf['user'],
'passwd' => $mysql_conf['passwd'],
'dbname' => 'paydb'
));
return $conn;
}
//redpack201908191405_xxxxx
protected function getOrderId($accountid)
{
$conn = $this->getPayMysql($accountid);
$orderid_pre = 'redpack' . strftime('%y%m%d%H%M%S');
$ret = $conn->execScript("INSERT INTO orderidx(createtime) VALUES(:createtime);",
array(
'createtime' => time()
));
if (!$ret) {
die();
}
$row = $conn->execQueryOne('SELECT LAST_INSERT_ID();', array());
if (empty($row)) {
die();
}
$orderid = $orderid_pre . 'idx' . $row[0];
return $orderid;
}
//红包提现
protected function getRedPack($amount, $account_id)
{
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
die();
}
$row = $conn->execQueryOne('SELECT user_name FROM user ' .
' WHERE accountid=:accountid ;',
array(
':accountid' => $account_id,
));
if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
die();
}
$mch_appid = '';
$appid_url = '';
if (SERVER_ENV == _ONLINE) {
$appid_url = 'https://login.kingsome.cn/webapp/index.php?c=SdkService&a=getAppId&';
} else {
$appid_url = 'https://login-test.kingsome.cn/webapp/index.php?c=SdkService&a=getAppId&';
}
$params['account_id'] = $account_id;
$app_response = '';
if (!phpcommon\HttpClient::get($appid_url, $params, $app_response)) {
phpcommon\sendError(ERR_RETRY, '系统繁忙');
die();
}
$app_data = json_decode($app_response, true);
$mch_appid = $app_data['appid'];
$openid = phpcommon\extractOpenId($account_id);
$re_user_name = $row['user_name'];
$url = '';
if (SERVER_ENV == _ONLINE) {
$url = 'https://cloud.kingsome.cn/webapp/index.php?c=Config&a=read&';
} else {
$url = 'https://cloud-test.kingsome.cn/webapp/index.php?c=Config&a=read&';
}
$params['gameid'] = phpcommon\extractGameId($account_id);
$params['channel'] = phpcommon\extractChannel($account_id);
$response = '';
if (!phpcommon\HttpClient::get($url, $params, $response)) {
phpcommon\sendError(ERR_RETRY, '系统繁忙');
die();
}
$desc = '';
$data = json_decode($response, true);
$data_list = json_decode($data['KVList'], true);
foreach ($data_list as $d) {
if ($d['key'] == 'red_env_tip') {
$desc = $d['value'];
break;
}
}
$partner_trade_no = $this->getOrderId($account_id);
$url = '';
if (SERVER_ENV == _ONLINE) {
$url = 'https://service.kingsome.cn/webapp/index.php?c=RedPack&a=sendRedPack&';
} else {
$url = 'https://service-test.kingsome.cn/webapp/index.php?c=RedPack&a=sendRedPack&';
}
$param['mch_appid'] = $mch_appid;
$param['partner_trade_no'] = $partner_trade_no;
$param['openid'] = $openid;
$param['re_user_name'] = $re_user_name;
$param['amount'] = $amount;
$param['desc'] = $desc;
$res = '';
if (!phpcommon\HttpClient::get($url, $param, $res)) {
phpcommon\sendError(ERR_RETRY, '系统繁忙');
die();
}
$data = json_decode($res, true);
if ($data['errcode'] != 0) {
phpcommon\sendError(ERR_USER_BASE + 2, '领取失败');
die();
}
}
//更新今日红包数据
protected function updateRedPack($item_num, $type)
{
$sum = 0;
$red_conn = $this->getRedMysql();
$row = $red_conn->execQueryOne('SELECT red_sum FROM redpack ' .
' WHERE red_type=:red_type AND red_date=:red_date;',
array(
':red_type' => $type,
':red_date' => phpcommon\getdayseconds(time())
));
if (!$row) {
$ret = $red_conn->execScript('INSERT INTO redpack(red_type, red_sum, red_date, create_time, modify_time) ' .
' VALUES(:red_type, :red_sum, :red_date, :create_time, :modify_time) ' .
' ON DUPLICATE KEY UPDATE red_type=1, red_sum=:red_sum, red_date=:red_date, modify_time=:modify_time;',
array(
':red_sum' => $item_num,
':create_time' => time(),
':red_type' => $type,
':red_date' => phpcommon\getdayseconds(time()),
':modify_time' => time()
));
if (!$ret) {
die();
}
} else {
$sum = $row['red_sum'] + $item_num;
$ret = $red_conn->execScript('UPDATE redpack set red_sum=:red_sum, red_date=:red_date, modify_time=:modify_time ' .
' WHERE red_type=:red_type;',
array(
':red_sum' => $sum,
':red_type' => $type,
':red_date' => phpcommon\getdayseconds(time()),
':modify_time' => time()
));
if (!$ret) {
die();
}
}
}
} }
?> ?>

View File

@ -286,14 +286,11 @@ class ShareController{
array( array(
':accountid' => $account_id ':accountid' => $account_id
)); ));
if (count($rows) == 0) { $share_meta_table = require('../res/share@share.php');
$share_meta_table = require('../res/share@share.php'); if (count($rows) < count($share_meta_table)) {
for ($i = 1; $i <= count($share_meta_table); $i++) { $num = count($rows) + 1;
for ($i = $num; $i <= count($share_meta_table); $i++) {
$id = $i; $id = $i;
$share_meta = getShareConfig($share_meta_table, $id);
if ($share_meta == NULL) {
$id = -10000;
}
$ret = $conn->execScript('INSERT INTO share_achievement(accountid, ach_id, status, create_time, modify_time) ' . $ret = $conn->execScript('INSERT INTO share_achievement(accountid, ach_id, status, create_time, modify_time) ' .
' VALUES(:account_id, :ach_id, :status, :create_time, :modify_time) ' . ' VALUES(:account_id, :ach_id, :status, :create_time, :modify_time) ' .
' ON DUPLICATE KEY UPDATE accountid=:account_id, ach_id=:ach_id, status=:status, modify_time=:modify_time;', ' ON DUPLICATE KEY UPDATE accountid=:account_id, ach_id=:ach_id, status=:status, modify_time=:modify_time;',
@ -308,29 +305,24 @@ class ShareController{
die(); die();
return; return;
} }
$sh = $this->getShare($id);
$array = $this->getExplode($sh['rewards']);
array_push($info_list, array(
'achivement_id' => $id,
'status' => 0,
'item_id' => $array[0][0],
'num' => $array[0][1],
'people_num' => $sh['people'],
));
}
} else {
foreach ($rows as $row) {
$sh = $this->getShare($row['ach_id']);
$array = $this->getExplode($sh['rewards']);
array_push($info_list, array(
'achivement_id' => $row['ach_id'],
'status' => $row['status'],
'item_id' => $array[0][0],
'num' => $array[0][1],
'people_num' => $sh['people'],
));
} }
} }
$rows = $conn->execQuery('SELECT ach_id, status FROM share_achievement WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
foreach ($rows as $row) {
$sh = $this->getShare($row['ach_id']);
$array = $this->getExplode($sh['rewards']);
array_push($info_list, array(
'achivement_id' => $row['ach_id'],
'status' => $row['status'],
'item_id' => $array[0][0],
'num' => $array[0][1],
'people_num' => $sh['people'],
));
}
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,
'errmsg' => '', 'errmsg' => '',
@ -388,13 +380,20 @@ class ShareController{
$data = json_decode($response, true); $data = json_decode($response, true);
$peo_num = $data['invitee_num']; $peo_num = $data['invitee_num'];
$sh = $this->getShare($ach_id); $sh = $this->getShare($ach_id);
if ($peo_num < $sh['people']) { /*if ($peo_num < $sh['people']) {
phpcommon\sendError(ERR_USER_BASE + 4, '未达到人数要求'); phpcommon\sendError(ERR_USER_BASE + 4, '未达到人数要求');
return; return;
}*/
$item_list = array();
if ($ach_id != 6) {
$array = $this->getExplode($sh['rewards']);
array_push($item_list, array(
'item_id' => $array[0][0],
'item_num' => $array[0][1],
));
$addreward = new classes\AddReward();
$addreward->addReward($array[0][0], $array[0][1], $account_id);
} }
$array = $this->getExplode($sh['rewards']);
$addreward = new classes\AddReward();
$addreward->addReward($array[0][0], $array[0][1], $account_id);
//更新状态 //更新状态
$ret = $conn->execScript('UPDATE share_achievement SET status=1, modify_time=:modify_time ' . $ret = $conn->execScript('UPDATE share_achievement SET status=1, modify_time=:modify_time ' .
' WHERE accountid=:accountid AND ach_id=:ach_id;', ' WHERE accountid=:accountid AND ach_id=:ach_id;',
@ -410,6 +409,7 @@ class ShareController{
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,
'errmsg' => '', 'errmsg' => '',
'item_list' => $item_list
)); ));
} }

View File

@ -189,11 +189,29 @@ class SignController{
array( array(
':accountid' => $account_id ':accountid' => $account_id
)); ));
//判断当前第几周
$item_list = array();
$week = ceil($rowUser['sign_sum'] / 7);
$dayid = ($week - 1) * 7;
//如果大于配置表最后一周,按最后一周奖励
$g_conf_sign_cluster = require('../res/signDaily@signDaily.php');
if ($dayid + 90000 > count($g_conf_sign_cluster)) {
$dayid = count($g_conf_sign_cluster) - 7;
}
for ($day = $dayid + 1; $day <= $dayid + 7; $day++)
{
$s = $this->getSign($day + 90000);
array_push($item_list, array(
'item_id' => $s['item_id'],
'item_num' => $s['num'],
));
}
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,
'errmsg' => '', 'errmsg' => '',
'sign_days' => $rowUser['sign_sum'], 'sign_days' => $rowUser['sign_sum'],
'sign_list' => $sign_list 'sign_list' => $sign_list,
'item_list' => $item_list
)); ));
} }
@ -237,19 +255,28 @@ class SignController{
':accountid' => $account_id ':accountid' => $account_id
)); ));
//获得奖励 //获得奖励
//判断当前第几周
$item_list = array();
$week = ceil($rowUser['sign_sum'] / 7);
$dayid = ($week - 1) * 7 + $_REQUEST['sign_id'];
//如果大于配置表最后一周,按最后一周奖励
$g_conf_sign_cluster = require('../res/signDaily@signDaily.php'); $g_conf_sign_cluster = require('../res/signDaily@signDaily.php');
$day = ($rowUser['sign_sum'] / 7 + $_REQUEST['sign_id']) % count($g_conf_sign_cluster); if ($dayid + 90000 > count($g_conf_sign_cluster)) {
if ($day == 0) { $dayid = count($g_conf_sign_cluster) - 7;
$day = count($g_conf_sign_cluster);
} }
$s = $this->getSign($day + 90000); $s = $this->getSign($dayid + 90000);
$item_id = $s['item_id']; $item_id = $s['item_id'];
$num = $s['num']; $num = $s['num'];
array_push($item_list, array(
'item_id' => $s['item_id'],
'item_num' => $s['num'],
));
$addreward = new classes\AddReward(); $addreward = new classes\AddReward();
$addreward->addReward($item_id, $num, $account_id); $addreward->addReward($item_id, $num, $account_id);
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,
'errmsg' => '', 'errmsg' => '',
'item_list' => $item_list
)); ));
} }
@ -274,10 +301,14 @@ class SignController{
':accountid' => $account_id ':accountid' => $account_id
)); ));
//获得奖励 //获得奖励
//判断当前第几周
$item_list = array();
$week = ceil($rowUser['sign_sum'] / 7);
$dayid = ($week - 1) * 7 + $_REQUEST['sign_id'];
//如果大于配置表最后一周,按最后一周奖励
$g_conf_sign_cluster = require('../res/signDaily@signDaily.php'); $g_conf_sign_cluster = require('../res/signDaily@signDaily.php');
$day = ($rowUser['sign_sum'] / 7 + $_REQUEST['sign_id']) % count($g_conf_sign_cluster); if ($dayid + 90000 > count($g_conf_sign_cluster)) {
if ($day == 0) { $dayid = count($g_conf_sign_cluster) - 7;
$day = count($g_conf_sign_cluster);
} }
$s = $this->getSign($day + 90000); $s = $this->getSign($day + 90000);
$item_id = $s['item_id']; $item_id = $s['item_id'];