This commit is contained in:
wangwei01 2019-07-24 17:47:46 +08:00
parent 402b1c14e1
commit 938464da79
3 changed files with 81 additions and 52 deletions

View File

@ -142,12 +142,12 @@ DROP TABLE IF EXISTS `sign`;
CREATE TABLE `sign` ( CREATE TABLE `sign` (
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id', `idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', `accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
`sign_days` int(11) NOT NULL COMMENT '已签天数', `sign_days` int(11) NOT NULL DEFAULT '0' COMMENT '已签天数',
`sign_time` varchar(50) NOT NULL DEFAULT '签到时间', `sign_time` int(50) NOT NULL DEFAULT '0' COMMENT '签到时间',
`item_id` int(11) NOT NULL COMMENT '奖励物品id', `item_id` varchar(50) NOT NULL DEFAULT '' COMMENT '奖励物品id',
`item_num` int(11) NOT NULL COMMENT '奖励物品数量', `item_num` varchar(50) NOT NULL DEFAULT '' COMMENT '奖励物品数量',
`create_time` int(11) NOT NULL COMMENT '创建时间', `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modify_time` int(11) NOT NULL COMMENT '修改时间', `modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`), PRIMARY KEY (`idx`),
UNIQUE KEY `accountid` (`accountid`) UNIQUE KEY `accountid` (`accountid`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

View File

@ -97,8 +97,14 @@ class DouRewardController{
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return; return;
} }
$item_id = $row['item_id']; $delim = "|";
$num = $row['item_num']; $drop_multiply = explode($delim, $row['item_id']);
$num_multiply = explode($delim, $row['item_num']);
error_log(json_encode($drop_multiply));
error_log(json_encode($num_multiply));
for ($i = 0; $i < count($drop_multiply); $i++) {
$item_id = $drop_multiply[$i];
$num = $num_multiply[$i];
switch ($_REQUEST['type']) switch ($_REQUEST['type'])
{ {
//签到双倍奖励 //签到双倍奖励
@ -131,6 +137,7 @@ class DouRewardController{
$addreward = new classes\AddReward(); $addreward = new classes\AddReward();
$addreward->addReward($item_id, $num, $account_id); $addreward->addReward($item_id, $num, $account_id);
$addreward->updateReward(0, 0, $account_id); $addreward->updateReward(0, 0, $account_id);
}
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,
'errmsg' => '', 'errmsg' => '',

View File

@ -93,6 +93,7 @@ class ShareController{
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
return; return;
} }
$item_list = array();
switch ($_REQUEST['type']) switch ($_REQUEST['type'])
{ {
//视频或金币开箱子 //视频或金币开箱子
@ -129,12 +130,12 @@ class ShareController{
return; return;
} }
} }
$item_list = $this->randReward($drop_id, $item_list, $account_id);
break; break;
} }
//钥匙开箱子 //钥匙开箱子
case 2: case 2:
{ {
$drop_id = 24002;
$p = $this->getParameter(KEYBOX_COST); $p = $this->getParameter(KEYBOX_COST);
if ($row['keys_num'] < $p['param_value']) { if ($row['keys_num'] < $p['param_value']) {
phpcommon\sendError(ERR_USER_BASE + 4, '钥匙不足'); phpcommon\sendError(ERR_USER_BASE + 4, '钥匙不足');
@ -152,12 +153,15 @@ class ShareController{
die(); die();
return; return;
} }
$drop_id = 24002;
$item_list = $this->randReward($drop_id, $item_list, $account_id);
$drop_id = 24007;
$item_list = $this->randReward($drop_id, $item_list, $account_id);
break; break;
} }
//钻石开箱子 //钻石开箱子
case 3: case 3:
{ {
$drop_id = 24003;
$p = $this->getParameter(DIAMONDBOX_COST); $p = $this->getParameter(DIAMONDBOX_COST);
if ($row['diamond_num'] < $p['param_value']) { if ($row['diamond_num'] < $p['param_value']) {
phpcommon\sendError(ERR_USER_BASE + 5, '钻石不足'); phpcommon\sendError(ERR_USER_BASE + 5, '钻石不足');
@ -175,12 +179,39 @@ class ShareController{
die(); die();
return; return;
} }
$drop_id = 24003;
$item_list = $this->randReward($drop_id, $item_list, $account_id);
$drop_id = 24008;
$item_list = $this->randReward($drop_id, $item_list, $account_id);
break; break;
} }
default: default:
break; break;
} }
//随机奖励 $quest = new classes\Quest();
$quest->triggerQuest(71004, 1, 1, $account_id);
$quest->triggerQuest(72004, 2, 1, $account_id);
$addreward = new classes\AddReward();
$item_id_list = '';
$item_num_list = '';
$item_id_arr = array();
$item_num_arr = array();
foreach ($item_list as $item) {
array_push($item_id_arr, $item['item_id']);
array_push($item_num_arr, $item['item_num']);
}
$item_id_list = implode("|", $item_id_arr);
$item_num_list = implode("|", $item_num_arr);
$addreward->updateReward($item_id_list, $item_num_list, $account_id);
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'item_list' => $item_list,
));
}
protected function randReward($drop_id, $item_list, $account_id)
{
$d = $this->getDrop($drop_id); $d = $this->getDrop($drop_id);
if (!$d) { if (!$d) {
phpcommon\sendError(ERR_USER_BASE + 6, '没有这个奖励'); phpcommon\sendError(ERR_USER_BASE + 6, '没有这个奖励');
@ -207,20 +238,11 @@ class ShareController{
$item_num = $item_num_array[$keys][0]; $item_num = $item_num_array[$keys][0];
$addreward = new classes\AddReward(); $addreward = new classes\AddReward();
$addreward->addReward($item_id, $item_num, $account_id); $addreward->addReward($item_id, $item_num, $account_id);
$addreward->updateReward($item_id, $item_num, $account_id);
$item_list = array();
array_push($item_list, array( array_push($item_list, array(
'item_id' => $item_id, 'item_id' => $item_id,
'item_num' => $item_num, 'item_num' => $item_num,
)); ));
$quest = new classes\Quest(); return $item_list;
$quest->triggerQuest(71004, 1, 1, $account_id);
$quest->triggerQuest(72004, 2, 1, $account_id);
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'item_list' => $item_list,
));
} }
public function shareFriendInfo() public function shareFriendInfo()