예제 #1
0
파일: Achieve.php 프로젝트: uning/mall-back
 /**
  * 达成成就
  * @param $params
  *  require    u      --  userid
  *             tag    --  成就种类,对应xml的id
  * @return
  *   s                --  OK,others fail
  */
 public function finish($params)
 {
     $uid = $params['u'];
     $tag = $params['tag'];
     $tu = new TTUser($uid);
     $id = $tu->getoid('achieves', TT::OTHER_GROUP);
     $achieves = $tu->getbyid($id);
     if ($achieves[$tag]) {
         $ret['s'] = 'repeat';
         return $ret;
     }
     $config = AchieveConfig::getAchieve($tag);
     $count = $tu->getf($config['group']);
     if ($count < $config['aimNum']) {
         //检验是否真的完成
         $ret['s'] = 'unfinish';
         return $ret;
     }
     $achieves[$tag] = time();
     $money = $tu->chMoney($config['rewardMoney']);
     $exp = $tu->numch('exp', $config['rewardRep']);
     if ($config['item']) {
         //成就达成的物品奖励
     }
     $achieves['id'] = $id;
     //		$ret['b'] = $achieves;
     $tu->puto($achieves);
     $ret['a'] = $tu->getbyid($id);
     $ret['s'] = 'OK';
     return $ret;
 }
예제 #2
0
파일: Cinema.php 프로젝트: uning/mallb
 /**
  * 捡钱并结算
  * @param $params
  *   require  u               -- 玩家id
  *            sid             -- shop id 不仅限于cinema
  * @return 
  *            s         --  OK
  */
 public function pick($params)
 {
     $uid = $params['u'];
     $sid = $params['sid'];
     $now = time();
     $tu = new TTUser($uid);
     $shop_obj = $tu->getbyid($sid);
     //		$ret['now'] = $now;  //for debug
     //		$ret['fnow'] = date( TM_FORMAT,$now );  //for debug
     //		$ret['bshopobj'] = $shop_obj;  //for debug
     //		$ret['fbshopobj'] = date( TM_FORMAT,$shop_obj['ctime'] );  //for debug
     if (!$shop_obj) {
         $ret['s'] = 'notexist';
         return $ret;
     }
     $item = ItemConfig::getItem($shop_obj['tag']);
     if (!$item) {
         $ret['s'] = 'itemnotexsit';
         return $ret;
     }
     if ($now - $shop_obj['ctime'] < $item['mintime']) {
         //开业mintime后就可以收钱,但最多只能积累maxtime
         $ret['s'] = 'time';
         return $ret;
     }
     $gap = $now - $shop_obj['ctime'];
     $factor = floor($gap / $item['mintime']);
     $money = $factor * $item['sellmoney'];
     $shop_obj['ctime'] += $factor * $item['mintime'];
     if ($gap > $item['maxtime']) {
         $money = floor($item['maxtime'] / $item['mintime']) * $item['sellmoney'];
         $shop_obj['ctime'] = $now;
     }
     $tu->chMoney($money);
     $tu->puto($shop_obj, TT::CINEMA_GROUP);
     //		$ret['fashopobj'] = date( TM_FORMAT,$shop_obj['ctime'] );  //for debug
     //		$ret['ashopobj'] = $shop_obj;  //for debug
     TTLog::record(array('m' => __METHOD__, 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $uid, 'intp1' => $money, 'sp1' => $shop_obj['ctime']));
     $ret['money'] = $money;
     $ret['s'] = 'OK';
     return $ret;
 }
예제 #3
0
파일: Cinema.php 프로젝트: uning/mall-back
 /**
  * 捡钱并结算
  * @param $params
  *   require  u               -- 玩家id
  *            sid             -- shop id 不仅限于cinema
  * @return 
  *            s         --  OK
  */
 public function pick($params)
 {
     $uid = $params['u'];
     $sid = $params['sid'];
     $now = time();
     $tu = new TTUser($uid);
     $shop_obj = $tu->getbyid($sid);
     //		$ret['now'] = $now;  //for debug
     //		$ret['fnow'] = date( TM_FORMAT,$now );  //for debug
     //		$ret['bshopobj'] = $shop_obj;  //for debug
     //		$ret['fbshopobj'] = date( TM_FORMAT,$shop_obj['ctime'] );  //for debug
     if (!$shop_obj) {
         $ret['s'] = 'notexist';
         return $ret;
     }
     $item = ItemConfig::getItem($shop_obj['tag']);
     if (!$item) {
         $ret['s'] = 'itemnotexsit';
         return $ret;
     }
     if ($shop_obj['tag'] == '60102') {
         //电影院
         if ($now - $shop_obj['ctime'] < $item['selltime'] * 60) {
             //坐满30个才开映,再过2小时才放映结束
             $ret['s'] = 'time';
             return $ret;
         }
         $money = $item['sellmoney'];
         $shop_obj['ctime'] = $now;
     } elseif ($shop_obj['tag'] == '60103' || $shop_obj['tag'] == '60104') {
         //健身房和按摩店
         if ($now - $shop_obj['ctime'] < $item['settletime']) {
             //开业时间需满足一定条件才可以收钱
             $ret['s'] = 'time';
             return $ret;
         }
         $money = $item['sellmoney'];
         $shop_obj['ctime'] = $now;
     } elseif ($shop_obj['tag'] == '60105' || $shop_obj['tag'] == '60106') {
         //月巴克和8-11便利店
         if ($now - $shop_obj['ctime'] < 3600) {
             //开业1小时后就可以收钱,但最多只能积累6~9小时
             $ret['s'] = 'time';
             return $ret;
         }
         $gap = $now - $shop_obj['ctime'];
         $factor = floor($gap / 3600);
         $money = $factor * $item['sellmoney'];
         $shop_obj['ctime'] += $factor * 3600;
         if ($gap > $item['settletime']) {
             $money = floor($item['settletime'] / 3600) * $item['sellmoney'];
             //			    $shop_obj['ctime'] += floor( $gap/3600 ) * 3600;
             $shop_obj['ctime'] = $now;
         }
     }
     $tu->chMoney($money);
     $tu->puto($shop_obj, TT::CINEMA_GROUP);
     //		$ret['fashopobj'] = date( TM_FORMAT,$shop_obj['ctime'] );  //for debug
     //		$ret['ashopobj'] = $shop_obj;  //for debug
     TTLog::record(array('m' => __METHOD__, 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $uid, 'intp1' => $money, 'sp1' => $shop_obj['ctime']));
     $ret['money'] = $money;
     $ret['s'] = 'OK';
     return $ret;
 }
예제 #4
0
파일: Man.php 프로젝트: uning/mall-back
 /**
          * update
 * @param $params
 *  require u        -- user 
 *                    step  -- 新手步数
 *                 //  v  -- view
 *                 //  d  -- do
 * @return 
 *  s   -- OK ,or other fail
          *  money  -- total money
          *  exp    -- total exp 
 *  award 
                  money
                  exp
                  items(物品对象数组) 
 *  d   --新的manual对象
 */
 public function update($params)
 {
     $uid = $params['u'];
     //$da = $params['d'];
     $step = $params['step'];
     //$v = ;//$da['v'];
     $d = 1;
     //;$da['d'];
     $ret = array();
     $conf = self::getAwardConf($step);
     if (!$v && !$d) {
         $ret['s'] = 'noaction';
         return $ret;
     }
     if (!$conf) {
         $ret['s'] = 'noconf';
         return $ret;
     }
     $tu = new TTUser($uid);
     $id = $tu->getoid('mannual', TT::OTHER_GROUP);
     $mano = $tu->getbyid($id);
     $mean_gap = 20;
     $now = time();
     $mano['id'] = $id;
     $level = $tu->getLevel();
     if ($level > $conf['maxlevel']) {
         $ret['s'] = 'level';
         $ret['d'] = $mano;
         //return $ret;
     }
     if ($v && $mano[$step]['vtime'] > 0) {
         $ret['s'] = 'already';
         $ret['d'] = $mano;
         return $ret;
     }
     if ($d && $mano[$step]['dtime'] > 0) {
         $ret['s'] = 'already';
         $ret['d'] = $mano;
         return $ret;
         //
     }
     $award = array();
     if ($v) {
         $mano[$step]['vtime'] = $now;
         $m = $conf['v_money'];
         if ($m > 0) {
             $ret['money'] = $tu->chMoney($m);
             $award['money'] = $m;
         }
         $m = $conf['v_gem'];
         if ($m > 0) {
             $ret['gem'] = $tu->chGem($m);
             $award['gem'] = $m;
         }
         $m = $conf['v_exp'];
         if ($m > 0) {
             $ret['exp'] = $tu->addExp($m);
             $award['exp'] = $m;
         }
         $items = $conf['v_items'];
         if ($items) {
             foreach ($items as $item) {
                 $config = ItemConfig::getItem($item['tag']);
                 $idp = $item['idp'];
                 //					$item['id']=$uid.$idp;
                 unset($item['idp']);
                 $item['pos'] = 's';
                 if ($config['group'] == 'g') {
                     $item['num'] = $config['unitcout'];
                     $tu->puto($item, TT::GOODS_GROUP);
                 } else {
                     $tu->puto($item, TT::ITEM_GROUP);
                 }
                 $award['items'][] = $item;
             }
         }
         $tu->puto($mano);
         $ret['award'] = $award;
         $ret['s'] = 'OK';
         return $ret;
     }
     $mano[$step]['dtime'] = $now;
     $m = $conf['d_money'];
     if ($m > 0) {
         $ret['money'] = $tu->chMoney($m);
         $award['money'] = $m;
     }
     $m = $conf['d_gem'];
     if ($m > 0) {
         $ret['gem'] = $tu->chGem($m);
         $award['gem'] = $m;
     }
     $m = $conf['d_exp'];
     if ($m > 0) {
         $ret['exp'] = $tu->addExp($m);
         $award['exp'] = $m;
     }
     $items = $conf['d_items'];
     if ($items) {
         foreach ($items as $item) {
             $config = ItemConfig::getItem($item['tag']);
             $idp = $item['idp'];
             //			    $item['id']=$uid.$idp;
             unset($item['idp']);
             $item['pos'] = 's';
             if ($config['group'] == 'g') {
                 $item['num'] = $config['unitcout'];
                 $tu->puto($item, TT::GOODS_GROUP);
             } else {
                 $tu->puto($item, TT::ITEM_GROUP);
             }
             $award['items'][] = $item;
         }
     }
     $tu->puto($mano);
     TTLog::record(array('m' => __METHOD__, 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $uid, 'intp1' => $step));
     $ret['s'] = 'OK';
     $ret['award'] = $award;
     return $ret;
 }
예제 #5
0
파일: test.php 프로젝트: uning/mall-back
        echo "{$usage} use time {$cost} us\n";
    }
    $start = $end;
}
function dodebug($str)
{
    echo "{$str}=";
    eval('echo  ' . $str . ';');
    echo "\n";
}
record_time($st);
//require_once('TTt.php');
require_once 'test_config.php';
$tu = new TTUser(1);
echo $tu->getf('money') . "\n";
$tu->chMoney(100);
echo $tu->getf('money') . "\n";
exit;
$ltt = TT::LinkTT();
$lid = 'dfdf';
$data = array('lid' => $lid);
$id = $ltt->put($data);
print_r($ltt->get($id));
print_r($ltt->getbyuidx('lid', $lid));
print_r($ltt->getbyuidx('lid', '9A18326D4627EF4F0B0A43A638C6E96'));
return;
$logt = TT::get_tt('order');
$id = $logt->put(array('a' => 'b'));
print_r($logt->get($id));
return;
$logt = TT::get_tt('log');
예제 #6
0
 /**
  * 结算卖货
  * @param $params use shop
  *   u   - userid
  *   sids  - shop ids
  * @return 
  *   s  - OK,noneed(短期内没有需要结算的商品),busy(太快)
  *   income  - 获得金币
  *   money   - 总金币
  *   selloutids - 卖完删除的id
  *   goods   --数量有辩护的商品列表
  */
 public static function shop_checkout($params)
 {
     $uid = $params['u'];
     $sids = $params['sids'];
     $now = $params['now'];
     if (!$now) {
         $now = time();
     }
     $tu = new TTUser($uid);
     //获取人气和宣传值
     $shops = $tu->get(TT::SHOP_GROUP);
     foreach ($shops as $shop) {
         if ($shop['pos'] != 's') {
             $item = ItemConfig::getItem($shop['tag']);
             @asort($shop['goods']);
             $gids = @array_keys($shop['goods']);
             if ($gids) {
                 $gs = $tu->getbyids($gids);
                 if ($gs['g']) {
                     $condata[$shop['id']]['sconfig'] = $item;
                     $condata[$shop['id']]['shop'] = $shop;
                     $condata[$shop['id']]['goods'] =& $gs['g'];
                     $total_width += $item['gridWidth'];
                 } else {
                     unset($shop['goods']);
                     //=array();
                     $tu->puto($shop);
                 }
             }
         }
     }
     if (!$condata || !$total_width) {
         $ret['s'] = 'OK';
         $ret['msg'] = 'nogoods';
         return $ret;
     }
     $params = $tu->getf(array(TT::POPU, TT::EXP_STAT));
     $popu = $params[TT::POPU];
     $ua = UpgradeConfig::getUpgradeNeed($params['exp']);
     $maxpopu = $ua['maxpopu'];
     $aid = $tu->getoid('advert', TT::OTHER_GROUP);
     $adv = $tu->getbyid($aid);
     $used_advert = $adv['use'];
     if (!$used_advert) {
         $used_advert = array();
     }
     //处理广告
     foreach ($used_advert as $k => $v) {
         $adv = AdvertConfig::getAdvert($tag);
         if ($start + $adv['allTime'] < $now) {
             continue;
         }
         $savead[$k] = $v;
     }
     if ($savead) {
         $adv['use'] = $savead;
         $tu->puto($adv);
     } else {
         if ($used_advert) {
             unset($adv['use']);
             $tu->puto($adv);
         }
     }
     $selloutids = array();
     $income = 0;
     $sale_count = 0;
     //销售份数
     $popu += 15 * $total_width;
     foreach ($condata as $s => $vvv) {
         $sconfig =& $vvv['sconfig'];
         $gs =& $vvv['goods'];
         $shop =& $vvv['shop'];
         $curtime = $shop['ctime'];
         //可以售卖新商品时间
         $cgoods = array();
         $shop_changed = false;
         foreach ($gs as $t => $g) {
             $gconfig = ItemConfig::getItem($g['tag']);
             if (!$gconfig) {
                 continue;
             }
             $ctime = $g['ctime'];
             //上次结算时间
             if ($curtime < $t) {
                 $curtime = $t;
             }
             //上架时间
             if ($curtime < $ctime) {
                 $curtime = $ctime;
             }
             if ($curtime < $g['stime']) {
                 $curtime = $g['stime'];
             }
             $gaps = self::getTimeRates($used_advert, $curtime, $now, $popu, $maxpopu, $total_width);
             foreach ($gaps as $k => $gr) {
                 //测试信息需要该索引值
                 //$snum = floor( $gr[0]/$gconfig['selltime']*$gr[1] );
                 $pertime = $gr[0] / $gconfig['selltime'] * $gr[1] * $sconfig['gridWidth'];
                 $snum = floor($gr[0] / $pertime);
                 if ($snum >= $g['num']) {
                     //卖完了
                     $asnum = $g['num'];
                 } else {
                     $asnum = $snum;
                 }
                 if ($asnum == 0) {
                     break;
                 }
                 $ret['sell'][$g['tag']] += $asnum;
                 $sale_count += $asnum;
                 //记录销售份数,成就用
                 $income += $asnum * $gconfig['sellmoney'];
                 //sellmoney是单份物品的卖价
                 $g['num'] -= $asnum;
                 $curtime += floor($asnum * $pertime);
                 //
                 $shop_changed = true;
                 $shop['ctime'] = $curtime;
                 $g['ctime'] = $curtime;
                 if ($g['num'] == 0) {
                     //当前时间段卖光此箱货物,继续卖下一个货物
                     $cgoods[] = $g;
                     $selloutids[] = $g['id'];
                     unset($shop['goods'][$g['id']]);
                     break;
                     //跳出时间段循环,继续卖同一商店下一个上架时间的货物(在同一商店,同一时间上架但售卖顺序不同的货物,已在上架时微调成不同上架时间)
                 }
             }
             //foreach group
             if ($g['num'] != 0) {
                 $tu->puto($g, TT::GOODS_GROUP);
                 break;
                 //跳出上架时间循环,但是继续店铺循环,终止同一店铺的货物队列中其他货物的结算
             }
         }
         //foreach goods
         if ($shop_changed) {
             $tu->puto($shop);
         }
     }
     //foreach shop
     //总销售份数
     $now_sale_count = $tu->numch('total_count', $sale_count);
     //总销售额
     $now_total_sale = $tu->numch('total_sale', $income);
     //记录玩家每一种物品卖出量
     if ($ret['sell']) {
         foreach ($ret['sell'] as $gid => $num) {
             $tu->numch("sale_goods_{$gid}", $num);
         }
     }
     $ret['s'] = 'OK';
     $ret['income'] = $income;
     $ret['money'] = $tu->chMoney($income);
     $ret['t'] = $now;
     $ret['rids'] = $selloutids;
     $ret['u'] = $uid;
     TTLog::record(array('m' => __METHOD__, 'u' => $uid, 'tm' => $_SERVER['REQUEST_TIME'], 'p' => json_encode($ret)));
     $tu->remove($selloutids);
     return $ret;
 }
예제 #7
0
require_once 'freeGift.php';
print_r($_REQUEST);
$key = $_GET['key'];
$tt = TT::TTWeb();
$value = $tt->get($key);
$type = $value['type'];
$uid = $_POST['uid'];
$user = new TTUser($uid);
if ($type == 2 && $value['count'] > 0) {
    echo '<script type="text/javacsript">';
    echo 'wodows.location = "http://apps.renren.com/livemall/";';
    echo '</script>';
} elseif ($type == 1 && $value['count'] > 0) {
    $recv = $value['rcv'];
    if (!array_key_exists($uid, $recv)) {
        $user->chMoney(1000);
        $value['count'] = $value['count'] - 1;
        $value['clickTime'] += 1;
        $value['rcv'][] = $uid;
        $tt->puto($value);
        echo '<script type="text/javacsript">';
        echo 'wodows.location = "http://apps.renren.com/livemall/";';
        echo '</script>';
    }
} elseif ($type == 3 && $value['count'] > 0) {
    ?>
<div class="padding_content center">
			<div class="main_giftConfirm_cont">
									<h3>您接受了<?php 
    echo $gift[$value['gift']]['name'];
    ?>
예제 #8
0
 /**
  * 金手指
  * @param $params
  *   require  u               -- 玩家id
  *            money           -- 增加金币数
  *            gem             -- 增加宝石数
  *            exp             -- 增加经验数
  * @return 
  *            s         --  OK
  */
 public function cheat($params)
 {
     $uid = $params['u'];
     $tu = new TTUser($uid);
     $tu->chMoney($params['money']);
     $tu->numch(TT::GEM_STAT, $params['gem']);
     //		$tu->numch( TT::EXP_STAT,$params['exp'] );
     $tu->addExp($params['exp']);
     $ret['a'] = $tu->getf(array(TT::MONEY_STAT, TT::GEM_STAT, TT::EXP_STAT));
     $ret['s'] = 'OK';
     return $ret;
 }
예제 #9
0
    $data = TTGenid::getbyid($u);
}
if (!$data || !$data['id']) {
    echo "<p>查找用户</p>";
    echo "<p><form method='get'>PID: <input name='pid' type='text' /><input type='submit' value='获取用户' /> </form></p>";
} else {
    $u = $data['id'];
    $name = $data['name'];
    if (!$u) {
        die("no u get");
    }
    $tu = new TTUser($u);
    echo "<p><a href='add_user_money.php'>换个用户</a>&nbsp&nbsp;&nbsp;<a target='_blank' href='get_user.php?u=" . $u . "'>用户信息</a><p>";
    echo "<p>" . $name . "</p>";
    if ($_POST['money'] !== null && $_POST['gem'] !== null && $_POST['money'] >= 0 && $_POST['gem'] >= 0 && $_POST['money'] <= 1000000000 && $_POST['gem'] <= 1000) {
        $tu->numch('money', $_POST['money']);
        $tu->numch('gem', $_POST['gem']);
        echo "<p>OK,  <a target='_blank' href='http://msg.renren.com/SendMessage.do?id=" . $data['pid'] . "'>发送站内信通知" . $name . "</a></p>";
    } else {
        echo "<p>输入要加的金币和宝石数</p>";
        echo "<form method='post'>";
        echo "<p>金币: <input name='money' value='0' type='text' /></p>";
        echo "<p>宝石: <input name='gem' value='0' type='text' /></p>";
        echo "<p><input type='submit' value='确定'/></p></form>";
    }
    echo "<p>现有金币" . $tu->chMoney(0) . ",宝石" . $tu->chGem(0) . "</p><br/><br/>";
}
?>
</body>
</html>
예제 #10
0
    echo "<form action='user_coward.php'> <input type='hidden' name='do' value='1'/> <input type='submit' class='giftformsubmit' value='领取补偿'/></form>";
} else {
    if ($sess['caward'] && $sess['caward'] == 1 && $_POST['do']) {
        $curaward = 1;
        $tu = new TTUser($u);
        //$getids[]=$tu->getdid('caward');
        $getids[] = $tu->getdid('exp');
        $coid = $tu->getdid('copilot', TT::OTHER_GROUP);
        $getids[] = $coid;
        $datas = $tu->getbyids($getids);
        $level = $tu->getLevel($datas['exp']);
        $copilot = $datas['copilot'];
        $copilot['id'] = $coid;
        $str = '';
        if ($level > 30) {
            $tu->chMoney(300000);
            $tu->chGem(15);
            $copilot['bag'][2002] += 4;
            //加两箱的道具
            $copilot['bag'][2004] += 6;
            //加6小时的道具
            $str = '300000金币,15个宝石,4份加两箱的道具,6份加6小时的道具';
        } else {
            if ($level > 20) {
                $tu->chMoney(150000);
                $tu->chGem(8);
                $copilot['bag'][2002] += 3;
                //加两箱的道具
                $copilot['bag'][2004] += 4;
                //加6小时的道具
                $str = '150000金币,8个宝石,3份加两箱的道具,4份加6小时的道具';