1
This commit is contained in:
parent
778475967e
commit
59cae52fe8
@ -2,11 +2,13 @@
|
||||
|
||||
class OpsController {
|
||||
|
||||
private $gameid = 1009;
|
||||
|
||||
public function selfChecking()
|
||||
{
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'errmsg' => "gameid:{$this->gameid}",
|
||||
'healthy' => 1,
|
||||
'max_rundelay' => 1,
|
||||
));
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
require 'classes/AddReward.php';
|
||||
require_once 'metatable/shop.php';
|
||||
require_once 'metatable/shopGoods.php';
|
||||
|
||||
class ShopController{
|
||||
|
||||
@ -67,21 +69,7 @@ class ShopController{
|
||||
|
||||
protected function getShop($shop_id)
|
||||
{
|
||||
$g_conf_shop_cluster = require('../res/shop@shop.php');
|
||||
$shop_conf = getShopConfig($g_conf_shop_cluster, $shop_id);
|
||||
$s = array(
|
||||
'shop_id' => $shop_conf['shop_id'],
|
||||
'item_id' => $shop_conf['item_id'],
|
||||
'num' => $shop_conf['num'],
|
||||
'item_weight' => $shop_conf['item_weight'],
|
||||
'discount' => $shop_conf['discount'],
|
||||
'discount_weight' => $shop_conf['discount_weight'],
|
||||
'tip' => $shop_conf['tip'],
|
||||
//'type' => $shop_conf['shop_type'],
|
||||
'time' => $shop_conf['time'],
|
||||
'price' => $shop_conf['price'],
|
||||
);
|
||||
return $s;
|
||||
|
||||
}
|
||||
|
||||
protected function getParameter($para_id)
|
||||
@ -109,6 +97,156 @@ class ShopController{
|
||||
return $arr;
|
||||
}
|
||||
|
||||
//新版商店
|
||||
public function newShopInfo()
|
||||
{
|
||||
$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 + 2, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$new_shop_uuid = 'game2004api_new_shop_uuid: ' . md5($_REQUEST['account_id']);
|
||||
//商店信息
|
||||
$this->getNewShopInfo($new_shop_uuid);
|
||||
$r = $this->getRedis($new_shop_uuid);
|
||||
if (!$r) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||
return;
|
||||
}
|
||||
$user_db_str = $r->get($new_shop_uuid);
|
||||
if (empty($user_db_str)) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||
return;
|
||||
}
|
||||
$user_db = json_decode($user_db_str, true);
|
||||
if (empty($user_db)) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||
return;
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg'=> '',
|
||||
'shop_uuid' => $new_shop_uuid,
|
||||
'act_list' => $user_db['act_list'],
|
||||
'free_list' => $user_db['free_list'],
|
||||
'sel_list' => $user_db['sel_list'],
|
||||
'equ_list' => $user_db['equ_list'],
|
||||
'clo_list' => $user_db['clo_list'],
|
||||
'item_list' => $user_db['item_list'],
|
||||
));
|
||||
}
|
||||
|
||||
protected function getNewShopInfo($shop_uuid)
|
||||
{
|
||||
$r = $this->getRedis($shop_uuid);
|
||||
if (!$r) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
$act_list = array();
|
||||
$free_list = array();
|
||||
$sel_list = array();
|
||||
$equ_list = array();
|
||||
$clo_list = array();
|
||||
$item_list = array();
|
||||
$user_db_str = $r->get($shop_uuid);
|
||||
if (empty($user_db_str)) {
|
||||
$act_list = $this->randomNewShop(1);
|
||||
$free_list = $this->randomNewShop(2);
|
||||
$sel_list = $this->randomNewShop(3);
|
||||
$equ_list = $this->randomNewShop(4);
|
||||
$clo_list = $this->randomNewShop(5);
|
||||
$item_list = $this->randomNewShop(6);
|
||||
} else {
|
||||
$user_db = json_decode($user_db_str, true);
|
||||
if (empty($user_db)) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||
return;
|
||||
}
|
||||
$act_list = $this->getNewShopList($user_db['act_list'], 1);
|
||||
$free_list = $this->getNewShopList($user_db['free_list'],2);
|
||||
$sel_list = $this->getNewShopList($user_db['sel_list'], 3);
|
||||
$equ_list = $this->getNewShopList($user_db['equ_list'], 4);
|
||||
$clo_list = $this->getNewShopList($user_db['clo_list'], 5);
|
||||
$item_list = $this->getNewShopList($user_db['item_list'],6);
|
||||
}
|
||||
|
||||
$shop_db = array(
|
||||
'shop_uuid' => $shop_uuid,
|
||||
'act_list' => $act_list,
|
||||
'free_list' => $free_list,
|
||||
'sel_list' => $sel_list,
|
||||
'equ_list' => $equ_list,
|
||||
'clo_list' => $clo_list,
|
||||
'item_list' => $item_list,
|
||||
);
|
||||
$r -> set($shop_uuid, json_encode($shop_db));
|
||||
$r -> pexpire($shop_uuid, 1000 * 3600 * 24 * 7);
|
||||
}
|
||||
|
||||
protected function randomNewShop($id)
|
||||
{
|
||||
$shop_list = array();
|
||||
$shop_conf = metatable\getShopById($id);
|
||||
if (!$shop_conf) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
return metatable\randGoods($shop_conf, $shop_list);
|
||||
}
|
||||
|
||||
protected function getNewShopList($list, $id)
|
||||
{
|
||||
$exclude_goods = array();
|
||||
$shop_conf = metatable\getShopById($id);
|
||||
$nowTime = phpcommon\getdayseconds(time());
|
||||
$remove_list = array();
|
||||
foreach ($list as $s) {
|
||||
$sgoods_conf = metatable\getShopGoodsById($s['id']);
|
||||
$passed_days = floor(($nowTime - phpcommon\getdayseconds($s['active_time'])) / (3600 * 24));
|
||||
//小于一天不刷新
|
||||
if ($passed_days < 1) {
|
||||
$exclude_goods[$s['id']]= 1;
|
||||
//小于两天未购买道具不刷新
|
||||
} else if ($sgoods_conf['time'] == 2 && $passed_days < 2) {
|
||||
if ($s['status'] == 0 || $passed_days < 1) {
|
||||
$exclude_goods[$s['id']]= 1;
|
||||
} else if ($s['status'] == 1 && $passed_days >= 1){
|
||||
$remove_list[$s['id']]= 1;
|
||||
}
|
||||
//刷新时间两天并大于两天刷新
|
||||
} else if ($sgoods_conf['time'] == 2 && $passed_days >= 2) {
|
||||
$remove_list[$s['id']]= 1;
|
||||
//刷新时间一天并大于一天刷新
|
||||
} else if ($sgoods_conf['time'] == 1 && $passed_days >= 1) {
|
||||
$remove_list[$s['id']]= 1;
|
||||
}
|
||||
}
|
||||
//删除多余的道具
|
||||
if (!empty($remove_list)) {
|
||||
for ($i = count($list) - 1; $i >= 0; --$i) {
|
||||
if (array_key_exists($list[$i]['id'], $remove_list)) {
|
||||
array_splice($list, $i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
$good_list = metatable\randGoods($shop_conf, $exclude_goods);
|
||||
if (!empty($remove_list)) {
|
||||
array_push($list, $good_list);
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
//旧版商店/////////////////////////////////////////////
|
||||
protected function getShopInfo($shop_uuid)
|
||||
{
|
||||
$r = $this->getRedis($shop_uuid);
|
||||
|
@ -34,4 +34,17 @@ class UnitTestController
|
||||
echo json_encode(metatable\getParameterByName($_REQUEST['param_name']));
|
||||
}
|
||||
|
||||
public function shopRandGoods()
|
||||
{
|
||||
require_once 'metatable/shop.php';
|
||||
echo json_encode(metatable\randGoods(
|
||||
metatable\getShopById($_REQUEST['shop_id']),
|
||||
array(
|
||||
'102' => 1,
|
||||
'103' => 1,
|
||||
'104' => 1
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user