From ce54a90de5c1185d8c358496b095b6fb8e753590 Mon Sep 17 00:00:00 2001 From: wangwei01 Date: Fri, 23 Aug 2019 14:40:06 +0800 Subject: [PATCH] 1 --- third_party/phpcommon | 2 +- webapp/controller/EmojiController.class.php | 61 +++++++++++++++++++ webapp/controller/PassController.class.php | 2 +- webapp/controller/PayController.class.php | 66 +++++++++++++++++++++ webapp/controller/ShareController.class.php | 3 +- 5 files changed, 131 insertions(+), 3 deletions(-) diff --git a/third_party/phpcommon b/third_party/phpcommon index 7ecf558..1e3bb4d 160000 --- a/third_party/phpcommon +++ b/third_party/phpcommon @@ -1 +1 @@ -Subproject commit 7ecf558df93a2656631782e76c6d35697da72808 +Subproject commit 1e3bb4df855f6d11df75545d10b0c2aacea34a06 diff --git a/webapp/controller/EmojiController.class.php b/webapp/controller/EmojiController.class.php index 1867215..10b5702 100644 --- a/webapp/controller/EmojiController.class.php +++ b/webapp/controller/EmojiController.class.php @@ -179,5 +179,66 @@ class EmojiController{ 'emoji_list' => $emoji_list )); } + + public function buyEmoji() + { + $account_id = $_REQUEST['account_id']; + //登录校验 + $login = loginVerify($account_id, $_REQUEST['session_id']); + if (!$login) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); + return; + } + $conn = $this->getMysql($account_id); + if (!$conn) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + return; + } + $id = $_REQUEST['emoji_id']; + $emoji = $this->getEmoji($id); + if (!$emoji) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个表情'); + return; + } + if ($emoji['get_type'] != 2) { + phpcommon\sendError(ERR_USER_BASE + 1, '不能用钻石购买'); + return; + } + + //扣除钻石 + $row = $conn->execQueryOne('SELECT diamond_num FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + return; + } + if ($row['diamond_num'] < $emoji['number']) { + phpcommon\sendError(ERR_USER_BASE + 3, '钻石不足'); + return; + } + $ret = $conn->execScript('UPDATE user SET diamond_num=:diamond_num, modify_time=:modify_time ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':diamond_num' => $row['diamond_num'] - $emoji['number'], + ':modify_time' => time() + )); + if (!$ret) { + die(); + return; + } + + //修改状态 + $addreward = new classes\AddReward(); + $addreward->addReward($id, 1, $account_id); + + echo json_encode(array( + 'errcode' => 0, + 'errmsg'=> '', + 'emoji_status' => 1 + )); + } } ?> diff --git a/webapp/controller/PassController.class.php b/webapp/controller/PassController.class.php index 69e3795..c860eca 100644 --- a/webapp/controller/PassController.class.php +++ b/webapp/controller/PassController.class.php @@ -141,7 +141,7 @@ class PassController{ //奖励信息 $item_list = array(); $seaReward_meta_table = require('../res/seasonReward@seasonReward.php'); - for ($j = 1; $j <= count($season_meta_table); $j++) { + for ($j = 1; $j <= count($seaReward_meta_table); $j++) { $id = $j + $number * 100; if ($id >= ($number + 1) * 100 || $id <= ($number - 1) * 100) { continue; diff --git a/webapp/controller/PayController.class.php b/webapp/controller/PayController.class.php index 5250b11..e75538d 100644 --- a/webapp/controller/PayController.class.php +++ b/webapp/controller/PayController.class.php @@ -511,5 +511,71 @@ class PayController{ )); } + public function buyPayItem() + { + $account_id = $_REQUEST['account_id']; + //登录校验 + $login = loginVerify($account_id, $_REQUEST['session_id']); + if (!$login) { + phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); + return; + } + $conn = $this->getMysql($account_id); + if (!$conn) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); + return; + } + $item_id = $_REQUEST['item_id']; + $item_list = array(); + $diamond_meta_table = require('../res/diamondshop@diamondshop.php'); + for ($i = 1; $i <= count($diamond_meta_table); $i++) { + $diamond = $this->getDiamondShop($i); + if ($item_id != $diamond['item_id']) { + continue; + } + $item = $this->getItem($diamond['item_id']); + $item_list = $this->getItemInfo($item['fuctionindex']); + if (!$item_list) { + phpcommon\sendError(ERR_USER_BASE + 1, '没有这个道具'); + return; + } + if ($diamond['coin_type'] == 10003) { + //扣除钻石 + $row = $conn->execQueryOne('SELECT diamond_num FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + )); + if (!$row) { + phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); + return; + } + if ($row['diamond_num'] < $diamond['coin_num']) { + phpcommon\sendError(ERR_USER_BASE + 3, '钻石不足'); + return; + } + $ret = $conn->execScript('UPDATE user SET diamond_num=:diamond_num, modify_time=:modify_time ' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':diamond_num' => $row['diamond_num'] - $diamond['coin_num'], + ':modify_time' => time() + )); + if (!$ret) { + die(); + return; + } + } + } + + //添加道具 + foreach ($item_list as $item) { + $addreward = new classes\AddReward(); + $addreward->addReward($item['itemid'], $item['itemnum'], $account_id); + } + echo json_encode(array( + 'errcode' => 0, + 'errmsg'=> '', + )); + } } ?> diff --git a/webapp/controller/ShareController.class.php b/webapp/controller/ShareController.class.php index 8c78b32..9ea8385 100644 --- a/webapp/controller/ShareController.class.php +++ b/webapp/controller/ShareController.class.php @@ -131,11 +131,12 @@ class ShareController{ $free = $_REQUEST['free']; if ($free != 0) { $drop_id = 24002; + $p = $this->getParameter(DIAMONDBOX10); } else { $drop_id = 24001; + $p = $this->getParameter(DIAMONDBOX); } //扣除钻石 - $p = $this->getParameter(DIAMONDBOX); $diamond_num = $p['param_value']; $this->subCoin($diamond_num, $account_id); //随机奖励