purchasedone
This commit is contained in:
parent
deaea1a59d
commit
e8c93156df
@ -10,6 +10,17 @@ require_once 'metatable/item.php';
|
||||
|
||||
class RechargeController
|
||||
{
|
||||
protected function getRedis($key)
|
||||
{
|
||||
$redis_conf = getRedisConfig(crc32($key));
|
||||
$r = new phpcommon\Redis(array(
|
||||
'host' => $redis_conf['host'],
|
||||
'port' => $redis_conf['port'],
|
||||
'passwd' => $redis_conf['passwd']
|
||||
|
||||
));
|
||||
return $r;
|
||||
}
|
||||
|
||||
protected function getMysql($account_id)
|
||||
{
|
||||
@ -284,6 +295,48 @@ class RechargeController
|
||||
));
|
||||
}
|
||||
|
||||
public function purchaseDone()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
//登录校验
|
||||
$login = loginVerify($account_id, $_REQUEST['session_id']);
|
||||
if (!$login) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
|
||||
return;
|
||||
}
|
||||
|
||||
$order_id = $_REQUEST['order_id'];
|
||||
if ($order_id == '') {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
|
||||
$key = 'game2004api-purchase:' . $account_id . '-' . $order_id;
|
||||
$r = $this->getRedis($key);
|
||||
if (!$r) {
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'order_id' => $order_id,
|
||||
'status' => 0,
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
$user_purchase_str = $r->get($key);
|
||||
if (empty($user_purchase_str)) {
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'order_id' => $order_id,
|
||||
'status' => 0,
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
echo $user_purchase_str;
|
||||
}
|
||||
|
||||
protected function checkPurchaseLimit($conn, $account_id, $productid)
|
||||
{
|
||||
$prod_conf = metatable\getShopGoodsById($productid);
|
||||
@ -419,8 +472,15 @@ class RechargeController
|
||||
)
|
||||
);
|
||||
|
||||
$all_item_list = array();
|
||||
$item_list = array();
|
||||
$addreward = new classes\AddReward();
|
||||
if ($shopgoods['first_present'] > 0) {
|
||||
array_push($item_list, array(
|
||||
'item_id' => 10003,
|
||||
'item_num' => $shopgoods['first_present'],
|
||||
'time' => 0,
|
||||
));
|
||||
$addreward->addReward(10003, $shopgoods['first_present'], $account_id, 0, 0);
|
||||
}
|
||||
|
||||
@ -522,14 +582,20 @@ class RechargeController
|
||||
}
|
||||
$itemidlist = explode('|', $dropconf['item_id']);
|
||||
$itemnumlist = explode('|', $dropconf['num']);
|
||||
$item_list = array();
|
||||
foreach ($itemidlist as $key => $itemid) {
|
||||
array_push($item_list, array(
|
||||
'item_id' => $itemid,
|
||||
'item_num' => $itemnumlist[$key],
|
||||
'time' => 0,
|
||||
));
|
||||
$addreward->addReward($itemid, $itemnumlist[$key], $account_id, 0, 0);
|
||||
$items = $addreward->addReward($itemid, $itemnumlist[$key], $account_id, 0, 0);
|
||||
foreach ($items as $i) {
|
||||
array_push($all_item_list, array(
|
||||
'item_id' => $i['item_id'],
|
||||
'item_num' => $i['item_num'],
|
||||
'time' => $i['time'],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
error_log(json_encode($item_list));
|
||||
@ -591,6 +657,27 @@ class RechargeController
|
||||
'errcode' => 0,
|
||||
'errmsg' => ''
|
||||
));
|
||||
|
||||
$key = 'game2004api-purchase:' . $account_id . '-' . $_REQUEST['orderid'];
|
||||
$r = $this->getRedis($key);
|
||||
if ($r) {
|
||||
$coin_num = $addreward->getCoinNum($account_id);
|
||||
$diamond_num = $addreward->getDiamondNum($account_id);
|
||||
$user_purchase = array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'order_id' => $_REQUEST['orderid'],
|
||||
'status' => 1,
|
||||
'coin_nums' => $coin_num,
|
||||
'diamond_nums' => $diamond_num,
|
||||
'item_list' => $item_list,
|
||||
'all_item_list' => $all_item_list,
|
||||
);
|
||||
$purchasestr = json_encode($user_purchase);
|
||||
$r->set($key, $purchasestr);
|
||||
$r->pexpire($key, 1000 * 15);
|
||||
error_log($key . ':' . $purchasestr);
|
||||
}
|
||||
}
|
||||
|
||||
private function insertNewOrder($conn, $nowtime)
|
||||
@ -692,7 +779,7 @@ class RechargeController
|
||||
if ($rechargerow['daily_purchase'] != null && $rechargerow['daily_purchase'] != '') {
|
||||
$dailypurchase = json_decode($rechargerow['daily_purchase'], true);
|
||||
$packtime = 0;
|
||||
foreach($dailypurchase as $key => $val) {
|
||||
foreach ($dailypurchase as $key => $val) {
|
||||
if ($val['id'] == 10 && $val['time'] > $daysecs) {
|
||||
$packtime = $val['time'];
|
||||
}
|
||||
@ -700,7 +787,7 @@ class RechargeController
|
||||
|
||||
if ($packtime > 0) {
|
||||
$shopconf = metatable\getShopGoodsConf();
|
||||
foreach($shopconf as $itemconf) {
|
||||
foreach ($shopconf as $itemconf) {
|
||||
if ($itemconf['type'] != 2) {
|
||||
continue;
|
||||
}
|
||||
@ -710,7 +797,7 @@ class RechargeController
|
||||
}
|
||||
|
||||
$found = false;
|
||||
foreach($dailypurchase as $key => $val) {
|
||||
foreach ($dailypurchase as $key => $val) {
|
||||
if ($val['id'] == $itemconf['shop_id']) {
|
||||
$found = true;
|
||||
$dailypurchase[$key]['time'] = $packtime;
|
||||
|
Loading…
x
Reference in New Issue
Block a user