コード例 #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
ファイル: Task.php プロジェクト: uning/mall-back
 /**
  * 领取任务奖励
  *   
  * @param $params
  *  require   u                 --    uid
  *            tid               --    任务id
  * @return 
  *            s                 --   OK,正常
  *                                    notexsit,该任务不存在
  *                                    cantgetaward,未完成的任务,不能领取奖励
  *            tid               --    task id
  */
 public function get_award($params)
 {
     $uid = $params['u'];
     $tid = $params['tid'];
     //判断用户是否正在任务中
     $tu = new TTUser($uid);
     $task_obj = $tu->getbyid($tid);
     //        $ret['task_obj'] = $task_obj;
     if (!$task_obj) {
         $ret['s'] = 'notexsit';
         return $ret;
     }
     if ($task_obj['s'] != '2') {
         $ret['s'] = 'cantgetaward';
         return $ret;
     }
     //两种奖励,分别根据$task_obj['ac'] (分享的奖励) 结算
     $today_start = strtotime(date('Y-m-d', time()));
     if ($task_obj['ct'] < $today_start) {
         //如果是昨天的任务,领取奖励后此条记录删除
         $tu->remove($tid);
     } else {
         $task_obj['s'] = '4';
         $tu->puto($task_obj, TT::TASK_GROUP);
     }
     $ret['id'] = $tid;
     $ret['s'] = 'OK';
     return $ret;
 }
コード例 #4
0
ファイル: old_checkshop.php プロジェクト: uning/mall-back
 public function checkshop($params)
 {
     $uid = $params['u'];
     $sid = $params['sid'];
     $tu = new TTUser($uid);
     $shop_obj = $tu->getbyid($sid);
     if (!$shop_obj) {
         $ret['s'] = 'notexsit';
         return $ret;
     }
     $goods_list = $shop_obj['goods'];
     $condata = array();
     if (!$goods_list) {
         $ret['s'] = 'nogoods';
         return $ret;
     }
     foreach ($goods_list as $goods_id => $stime) {
         $goods_obj = $tu->getbyid($goods_id);
         $condata[$stime] = $goods_obj;
     }
     $ret['condata'] = $condata;
     $popu = $params[TT::POPU];
     $ret['bpopu'] = $popu;
     $ua = UpgradeConfig::getUpgradeNeed($params['exp']);
     $ret['ua'] = $ua;
     //算人气
     $shops = $tu->get(TT::SHOP_GROUP);
     foreach ($shops as $shop) {
         $ret['shop_num_shop'][] = $shop;
         if ($shop['pos'] != 's') {
             $item = ItemConfig::getItem($shop['tag']);
             $shop_num += $item['gridWidth'];
         }
     }
     $ret['ashopnum'] = $shop_num;
     if (!$shop_num) {
         $ret['s'] = 'noshopexist';
         return $ret;
     }
     $shop_popu = $shop_num * 15;
     //只算店面人气
     $popu += $shop_popu;
     if ($popu > $ua['maxpopu']) {
         $popu = $ua['maxpopu'];
     }
     $ret['apopu'] = $popu;
     $aid = $tu->getoid('advert', TT::OTHER_GROUP);
     $adv = $tu->getbyid($aid);
     $used_advert = $adv['use'];
     //		$ret['bbbbbadvert'] = $adv;
     $computetime = $params[TT::COMPUTE_PONIT];
     //		$ret['now'] = date( TM_FORMAT,$now );
     //		$ret['lastcomputetime'] = date( TM_FORMAT,$computetime );
     $selloutids = array();
     $income = 0;
     $special = 0;
     //特殊商店的收入
     $sale_count = 0;
     //销售份数
     $now = time();
     $sconfig = ItemConfig::getItem($shop_obj['tag']);
     //			$ret['sconfig'][$s] = $sconfig;
     ksort($condata);
     $curtime = 0;
     //可以售卖新商品时间
     $cgoods = array();
     foreach ($condata as $t => $g) {
         $gconfig = ItemConfig::getItem($g['tag']);
         $ctime = $g['ctime'];
         //上次结算时间
         if ($curtime < $t) {
             $curtime = $t;
         }
         //上架时间
         if ($curtime < $ctime) {
             $curtime = $ctime;
         }
         $g['ctime'] = $now;
         $ret['tloop'][$t] = date(TM_FORMAT, $curtime);
         $gaps = array();
         if ($used_advert) {
             $tmp = self::getTimeRates($tu, $gaps, $used_advert, $curtime, $popu, $ua['maxpopu'], $now, $shop_num);
             //			            $ret['advertisement'][$s][$t] = $tmp;
         } else {
             $gaps = array(array($now - $curtime, $popu / ($shop_num * 15)));
         }
         $ret['gaps'][$t] = $gaps;
         //			foreach($gaps as $gr){
         foreach ($gaps as $k => $gr) {
             //测试信息需要该索引值
             $stime = $gr[0];
             if ($sconfig['gridWidth']) {
                 $pertime = $gconfig['selltime'] / ($sconfig['gridWidth'] * $gr[1]);
             }
             if ($pertime) {
                 $snum = floor($stime / $pertime);
             }
             $ret['pertime'][$t][$k] = $pertime;
             if ($snum >= $g['num']) {
                 //卖完了
                 $asnum = $g['num'];
             } else {
                 $asnum = $snum;
             }
             //				$ret['asnum'][$s][$t][$k][$g['tag'] ] = $asnum;
             $ret['sell'][$g['tag']] += $asnum;
             $sale_count += $asnum;
             //记录销售份数,成就用
             $income += $asnum * $gconfig['sellmoney'];
             //sellmoney是单份物品的卖价
             $g['num'] -= $asnum;
             //				$g['scount'] += $asnum;
             if ($g['num'] == 0) {
                 //当前时间段卖光此箱货物,继续卖下一个货物
                 $cgoods[] = $g;
                 $selloutids[] = $g['id'];
                 unset($shop_obj['goods'][$g['id']]);
                 break;
                 //跳出时间段循环,继续卖同一商店下一个上架时间的货物(在同一商店,同一时间上架但售卖顺序不同的货物,已在上架时微调成不同上架时间)
             }
         }
         $tu->puto($shop_obj, TT::SHOP_GROUP);
         if ($g['num'] != 0) {
             $tu->puto($g, TT::GOODS_GROUP);
             //未卖完的商品需要保存回库,继续卖同一商店下一个上架时间的货物(在同一商店,一时间上架但售卖顺序不同的货物,已在上架时微调成不同上架时间)
             break;
             //跳出上架时间循环,但是继续店铺循环,终止同一店铺的货物队列中其他货物的结算
         }
     }
     //删除使用过的广告队列
     unset($adv['use']);
     if ($used_advert) {
         //如果是空数组
         $adv['use'] = $used_advert;
     }
     $adv['id'] = $aid;
     $tu->puto($adv, TT::ADVERT_GROUP, false);
     //总销售份数
     $now_sale_count = $tu->numch('total_count', $sale_count);
     //总销售额
     $now_total_sale = $tu->numch('total_sale', $income);
     $ret['s'] = 'OK';
     $ret['income'] = $income;
     $ret['money'] = $tu->numch('money', $income);
     $ret['t'] = $now;
     $tu->remove($selloutids);
     $tu->putf(TT::COMPUTE_PONIT, $now);
     return $ret;
 }
コード例 #5
0
ファイル: Man.php プロジェクト: uning/mall-back
 /**
          * update
 * @param $params
 *  require u        -- user 
 *          type     -- 满足type
 * @return 
 *  s   -- OK ,or other fail
                    max,超出限制
                    notype,超出限制
          *  money  -- total money
          *  exp    -- total exp 
 *  award 
                  money
                  exp
 *  d   --新的对象
 */
 public function satisfy($params)
 {
     static $type2award = array(1 => array('money' => 10, 'exp' => 2));
     $uid = $params['u'];
     $type = $params['type'];
     $award = $type2award[$type];
     //$type  = 1;
     if (!$award) {
         $ret['s'] = 'notype';
         return $ret;
     }
     $tu = new TTUser($uid);
     $id = $tu->getoid('satisfy', TT::OTHER_GROUP);
     $data = $tu->getbyid($id);
     $data['id'] = $id;
     $now = time();
     $now_date = date('Ymd', $now);
     if ($data['date'] != $now_date) {
         $data['r'] = array();
         $data['date'] = $now_date;
     }
     if (++$data['r'][$type] > 10) {
         $ret['s'] = 'max';
         return $ret;
     }
     $ret['award'] = $award;
     foreach ($award as $k => $v) {
         $ret[$k] = $tu->numch($k, $v);
     }
     $ret['d'] = $data;
     $ret['s'] = 'OK';
     $tu->puto($data, '', false);
     return $ret;
 }
コード例 #6
0
ファイル: index.php プロジェクト: uning/mall-back
    $renren = new Renren();
    $renren->api_key = RenrenConfig::$api_key;
    $renren->secret = RenrenConfig::$secret;
    $renren->session_key = $session_key;
    $renren->init($session_key);
    $rt = $renren->api_client->users_getLoggedInUser();
    if ($rt['uid'] == $pid) {
        $sess['session_key'] = $session_key;
        TTGenid::update($sess, $sess['id']);
    } else {
        header('Location: ' . RenrenConfig::$canvas_url);
    }
}
$tu = new TTUser($uid);
$iid = $tu->getdid('installbar', TT::OTHER_GROUP);
$barobj = $tu->getbyid($iid);
$install_bar = true;
if ($barobj == null || $barobj['email'] == null) {
    $install_bar = true;
} else {
    $install_bar = false;
}
if ($gflg) {
    $data = $ts->getbyid($gflg);
    $bids = $data['rfids'];
    if (strstr($bids, $pid)) {
    } else {
        //给玩家礼物
        $flag = $data['gift_id'];
        $fconf = ItemConfig::get($flag);
        //取礼物信息
コード例 #7
0
ファイル: Friend.php プロジェクト: uning/mall-back
 /**
 			  五,增加好友箱数:						
  说明:	货车出发之后,放进仓库之前,好友均可点击,点击会增加货物箱数。				
 			  按钮问题:好友帮助加箱数的按钮,在货车运货过程中和货车回来都有。而当货车回来,但是没有放进仓库时,只有到好友家才有按钮,自己的副驾驶功能消失。				
 			  限制:	每人每日可帮一个好友一次。				
 			  级别越高增加的箱数越多。					
 			  级别:	箱数:				
 			  1	1				
 			  20	2				
 			  40	3				
 			  被帮助者奖励:	礼物为一箱货物。				
 			  帮助者奖励:	获得所进货物经验(进货+取货的经验和)相等的经验。	
 			 * @param $params
 			 *  require  u           --  user id
 			 *           f         --  friend id
 			 *           cid         --  car id
 			 * @return 
 			 *           s           --  OK
 			 --  helped,已经拜访过
 			 --  nofriend,不是朋友
 			 award        
 			 exp         --奖励经验
 			 money       --奖励金钱 
 */
 public function help_car($params)
 {
     $uid = $params['u'];
     $nid = $params['f'];
     $cid = $params['cid'];
     $tu = new TTUser($uid);
     $ftu = new TTUser($nid);
     $fdid = $tu->getdid($nid, 'fr');
     $now = time();
     $now_date = date('Ymd', $now);
     $fdata = $tu->getbyid($fdid);
     if (!$fdata) {
         $ret['s'] = 'nofriend';
         return $ret;
     }
     $vt = $fdata['ht'];
     $vt_date = date('Ymd', $vt);
     if ($vt_date == $now_date && $fdata['help_car'] == '1') {
         $ret['s'] = 'helped';
         return $ret;
         //for test
     }
     $car = $ftu->getbyid($cid);
     if (!$car) {
         $ret['s'] = 'nocar ' . $cid;
         return $ret;
     }
     $carconf = ItemConfig::getItem($car['tag']);
     $counts = count($car['help']);
     if ($counts > $carconf['gridWidth']) {
         $ret['help_time'] = $counts;
         $ret['gridW'] = $car['help'];
         $ret['s'] = 'max';
         return $ret;
     }
     $goodsid = $car['goodsTag'];
     $gconfig = ItemConfig::getItem($goodsid);
     $add_exp = $gconfig['exp'];
     if (!$add_exp) {
         $ret['s'] = 'nogoods';
         $ret['g'] = $gconfig;
         return $ret;
     }
     $level = $tu->getLevel();
     $num = 1;
     if ($level > 39) {
         $num = 2;
     }
     if ($level > 69) {
         $num = 3;
     }
     //$mydata = TTGenid::getbyid($uid);
     $car['help'][$uid] = $num;
     $add_exp *= 4;
     $ret['exp'] = $tu->addExp($add_exp);
     $ret['award']['exp'] = $add_exp;
     $fdata['ht'] = $now;
     $fdata['help_car'] = 1;
     $tu->puto($fdata, 'fr', false);
     $ftu->puto($car, '', false);
     $ret['cid'] = $cid;
     $ret['s'] = 'OK';
     $ret['t'] = $now;
     return $ret;
 }
コード例 #8
0
ファイル: ItemController.php プロジェクト: uning/mallb
 /**
  * 卖出
  * @param $params
  *  require u  -- user id
  *  require d  -- item_id 数组
  *     
  * @return 
  *  s   -- OK ,or other fail
  *                                     notexsit ,不存在配置
  *                                     notsale ,不能购买的物品
  *                                     level,等级未到 
  *                                     achive, 所需成就buy_need_achiveid 未达成 
  *                                     task,所需任务未达成
  *                                     buynumlimit,限量版已经卖完
  *                                     money,
  *				      gem
  */
 public function sale($params)
 {
     $uid = $params['u'];
     $tu = new TTUser($uid);
     if ($tu->check_dup($params['_cid'], $ret)) {
         return $ret;
     }
     foreach ($params['d'] as $index => $id) {
         $item_obj = $tu->getbyid($id);
         if (!$item_obj) {
             $ret['s'] = 'notexsit';
             $ret['index'] = $index;
             return $ret;
         }
         $item = ItemConfig::getItem($item_obj['tag']);
         if (!$item) {
             $ret['s'] = 'notexsit';
             $ret['index'] = $index;
             return $ret;
         }
         $sale_ret = $tu->saleItem($item_obj);
         if ($sale_ret['s'] != 'OK') {
             $sale_ret['index'] = $index;
             return $sale_ret;
         }
         if ($item_obj['pos'] != 's') {
             $pop -= $item['pop'];
         }
     }
     if ($pop) {
         $tu->numch(TT::POPU, $pop);
     }
     $tu->remove($params['d']);
     $ret['s'] = 'OK';
     return $ret;
 }
コード例 #9
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;
 }
コード例 #10
0
ファイル: Tool.php プロジェクト: uning/mall-back
 public function test_feed($params)
 {
     $uid = $params['u'];
     $tu = new TTUser($uid);
     $id = $tu->getoid('achieves', TT::OTHER_GROUP);
     $achieves = $tu->getbyid($id);
     $aparams = $tu->getf(array('popu', 'invite_count', 'gogoods_count', 'total_count', 'total_sale'));
     $ret['baparams'] = $aparams;
     foreach (AchieveConfig::$_config as $tag => $conf) {
         $ret['tag'][] = $tag;
         $ret['conf'][] = $conf;
     }
     $data = array('total_count' => 50000, 'total_sale' => 100000, 'gogoods_count' => 3000);
     $tu->mputf($data);
     $aparams = $tu->getf(array('popu', 'invite_count', 'gogoods_count', 'total_count', 'total_sale'));
     $ret['aaparams'] = $aparams;
     $ret['s'] = 'OK';
     return $ret;
 }
コード例 #11
0
ファイル: GoodsController.php プロジェクト: uning/mallb
 public static function dcheckout($params)
 {
     $uid = $params['u'];
     $sids = $params['sids'];
     $now = $params['now'];
     $tu = new TTUser($uid);
     if (!$now) {
         $now = time();
     }
     $debug = true;
     $goods = $tu->get(TT::GOODS_GROUP);
     //$ret['goods']=$goods;
     foreach ($goods as $g) {
         $shopid = $g['pos']['y'];
         if (!$shopid || $shopid == 's') {
             continue;
         }
         if (!isset($condata[$shopid]['shop'])) {
             $shop = $tu->getbyid($shopid);
             if (!$shop) {
                 //error log
                 $ret['goods_no_shop'][] = $g;
                 continue;
             }
             $condata[$shopid]['shop'] = $shop;
             $item = ItemConfig::getItem($shop['tag']);
             $condata[$shopid]['sconfig'] = $item;
             $total_width += $item['gridWidth'];
         }
         $stime = $g['stime'];
         //上架时间
         $condata[$shopid]['goods'][$stime] = $g;
     }
     //$ret['condata'] = $condata;
     if (!$condata || !$total_width) {
         $ret['s'] = 'OK';
         $ret['msg'] = 'nogoods';
         $ret['condata'] = $condata;
         $ret['total_width'] = $total_width;
         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'];
         ksort($gs);
         $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);
             $ret[$g['id']]['startctime'] = $curtime;
             $ret[$g['id']]['gaps'] = $gaps;
             $ret[$g['id']]['shop'] = $s;
             $ret[$g['id']]['mydata'] = $g;
             foreach ($gaps as $k => $gr) {
                 //测试信息需要该索引值
                 $pertime = $gconfig['selltime'] / $gr[1] / $sconfig['gridWidth'];
                 $snum = floor($gr[0] / $pertime);
                 if ($snum >= $g['num']) {
                     //卖完了
                     $asnum = $g['num'];
                 } else {
                     $asnum = $snum;
                 }
                 $ret['sell'][$g['tag']] += $asnum;
                 $sale_count += $asnum;
                 //记录销售份数,成就用
                 $income += $asnum * $gconfig['sellmoney'];
                 //sellmoney是单份物品的卖价
                 $g['num'] -= $asnum;
                 $curtime += floor($asnum * $pertime);
                 //
                 $g['ctime'] = $curtime;
                 $shop['ctime'] = $curtime;
                 if ($debug) {
                     $ret[$g['id']][$k]['sell_num'] = $asnum;
                     $ret[$g['id']][$k]['endcurtime'] = $curtime;
                     $ret[$g['id']][$k]['gap'] = $gr[0];
                     $ret[$g['id']][$k]['pertime'] = $pertime;
                     $ret[$g['id']][$k]['ratio'] = $gr[1];
                     $ret[$g['id']][$k]['left_num'] = $g['num'];
                     $ret[$g['id']][$k]['basespertime'] = $gconfig['selltime'];
                     $ret[$g['id']][$k]['shopwidth'] = $sconfig['gridWidth'];
                 }
                 if ($g['num'] == 0) {
                     //当前时间段卖光此箱货物,继续卖下一个货物
                     $cgoods[] = $g;
                     $selloutids[] = $g['id'];
                     $shop_changed = true;
                     unset($shop['goods'][$g['id']]);
                     break;
                     //跳出时间段循环,继续卖同一商店下一个上架时间的货物(在同一商店,同一时间上架但售卖顺序不同的货物,已在上架时微调成不同上架时间)
                 }
             }
             if ($g['num'] != 0) {
                 if (!$debug) {
                     $tu->puto($g, TT::GOODS_GROUP);
                 }
                 break;
                 //跳出上架时间循环,但是继续店铺循环,终止同一店铺的货物队列中其他货物的结算
             }
         }
         //foreach goods
         if ($shop_changed) {
             if (!$debug) {
                 $tu->puto($g, TT::GOODS_GROUP);
             }
         }
     }
     //foreach shop
     if ($debug) {
         $ret['total_width'] = $total_width;
         $ret['popu'] = $popu;
         $ret['maxpopu'] = $maxpopu;
         $ret['params'] = $params;
     }
     //总销售份数
     //总销售额
     //记录玩家每一种物品卖出量
     $ret['s'] = 'OK';
     $ret['income'] = $income;
     //$ret['money']  = $tu->numch('money',$income);
     $ret['t'] = $now;
     $ret['rids'] = $selloutids;
     $ret['u'] = $uid;
     return $ret;
 }
コード例 #12
0
ファイル: Friend.php プロジェクト: uning/mallb
 /**
 			  五,增加好友箱数:						
  说明:	货车出发之后,放进仓库之前,好友均可点击,点击会增加货物箱数。				
 			  按钮问题:好友帮助加箱数的按钮,在货车运货过程中和货车回来都有。而当货车回来,但是没有放进仓库时,只有到好友家才有按钮,自己的副驾驶功能消失。				
 			  限制:	每人每日可帮一个好友一次。				
 			  级别越高增加的箱数越多。					
 			  级别:	箱数:				
 			  1	1				
 			  40	2				
 			  70	3				
 			  被帮助者奖励:	礼物为一箱货物。				
 			  帮助者奖励:	获得所进货物经验(进货+取货的经验和)相等的经验。	
 			 * @param $params
 			 *  require  u           --  user id
 			 *           f           --  friend id
 			 *           cid         --  car id
 			 *           type        --  1    表示加货
 			 *                           2    表示保鲜
 			 * @return 
 			 *           s           --  OK
 			 --  helped,已经拜访过
 			 --  nofriend,不是朋友
 			 --  freshed  今天已经操作过了
 			 --  alreadyfresh  可能已被别人保鲜了
 			 --  notexpiration  货物未过期
 			 award        
 			 exp         --奖励经验
 			 money       --奖励金钱 
 */
 public function help_car($params)
 {
     $uid = $params['u'];
     $nid = $params['f'];
     $cid = $params['cid'];
     $type = $params['type'];
     //兼容在线的旧flash版本
     if (!$type) {
         $type = 1;
     }
     $tu = new TTUser($uid);
     $ftu = new TTUser($nid);
     $fdid = $tu->getdid($nid, 'fr');
     $now = time();
     $now_date = date('Ymd', $now);
     $fdata = $tu->getbyid($fdid);
     if (!$fdata) {
         $ret['s'] = 'nofriend';
         return $ret;
     }
     $car = $ftu->getbyid($cid);
     if (!$car) {
         $ret['s'] = 'nocar ' . $cid;
         return $ret;
     }
     $goodsid = $car['goodsTag'];
     $gconfig = ItemConfig::getItem($goodsid);
     $add_exp = $gconfig['exp'];
     if (!$add_exp) {
         $ret['s'] = 'nogoods';
         $ret['g'] = $gconfig;
         return $ret;
     }
     $level = $tu->getLevel();
     $vt = $fdata['ht'];
     $vt_date = date('Ymd', $vt);
     $fdata['ht'] = $now;
     if ($type == 1) {
         //加货
         if ($vt_date == $now_date && $fdata['help_car'] == '1') {
             $ret['s'] = 'helped';
             return $ret;
         }
         $carconf = ItemConfig::getItem($car['tag']);
         $counts = count($car['help']);
         if ($counts > $carconf['gridWidth']) {
             $ret['help_time'] = $counts;
             $ret['gridW'] = $car['help'];
             $ret['s'] = 'max';
             return $ret;
         }
         $num = 1;
         if ($level > 39) {
             $num = 2;
         }
         if ($level > 69) {
             $num = 3;
         }
         $car['help'][$uid] = $num;
         $fdata['help_car'] = 1;
     }
     if ($type == 2) {
         //保鲜
         if ($vt_date == $now_date && $fdata['fresh'] == '1') {
             $ret['s'] = 'freshed';
             return $ret;
         }
         if ($car['fresh']) {
             $ret['s'] = 'alreadyfresh';
             return $ret;
         }
         if ($now - $car['t'] <= 3 * $gconfig['buytime']) {
             //货物未过期
             $ret['s'] = 'notexpiration';
             return $ret;
         }
         $car['fresh'] = $nid;
         $car['fresh'] = $params['f'];
         $fdata['fresh'] = 1;
     }
     $add_exp *= 2;
     $ret['type'] = $type;
     $ret['exp'] = $tu->addExp($add_exp);
     $ret['award']['exp'] = $add_exp;
     $tu->puto($fdata, 'fr', false);
     $ftu->puto($car, '', false);
     $ret['cid'] = $cid;
     $ret['s'] = 'OK';
     $ret['t'] = $now;
     $ret['car'] = $car;
     // for debug
     return $ret;
 }
コード例 #13
0
ファイル: get_user.php プロジェクト: uning/mallb
            print_r($car_obj);
            break;
        }
    }
}
//检查店铺相关
$shops = $tu->get(TT::SHOP_GROUP);
$shop_pos = array();
foreach ($shops as $shop_obj) {
    if ($shop_obj['pos'] == 's' && $shop_obj['goods']) {
        echo "出现shop['goods']不为空,但实际货物已经卖完的情况: \n";
        echo "店铺数据: \n";
        print_r($shop_obj);
        echo "货物数据: \n";
        foreach ($shop_obj['goods'] as $id) {
            $goods = $tu->getbyid($id);
            print_r($goods);
            if ($goods['stime']) {
                $time1 = date(TM_FORMAT, $goods['stime']);
                echo "上架时间: {$time1} \n";
            }
            if ($goods['ctime']) {
                $time2 = date(TM_FORMAT, $goods['ctime']);
                echo "结算时间: {$time2} \n";
            }
        }
    }
    if ($shop_obj['pos'] != 's') {
        $shop = ItemConfig::getItem($shop_obj['tag']);
        if ($shop_obj['goods']) {
            foreach ($shop_obj['goods'] as $id) {
コード例 #14
0
ファイル: TaskOnce.php プロジェクト: uning/mall-back
 /**
  * 完成任务
  *   
  * @param $params
  *  require   u       --  uid
  *            tag     --  任务id
  *            rids     -- 消耗物品ids(只能是空闲物品)
  *            minus  (money=>11,gem=>122)
  * @return 
  *            s       --  OK,正常
  *            award    --  和新手等一致
  *                        finished,该任务不存在
  */
 public function finish($params)
 {
     $uid = $params['u'];
     $tag = $params['tag'];
     //判断用户是否正在任务中
     $tu = new TTUser($uid);
     $tid = $tu->getoid($tag, 'to');
     $to = $tu->getbyid($tid);
     if (!$to) {
         //	$ret['s']='no';
         //	return $ret;
         $to['id'] = $tid;
     }
     if ($to['s'] == 'finished') {
         $ret['s'] = 'finished';
         return $ret;
     }
     $conf = self::getConf($tag);
     $d = $conf['award'];
     if ($d) {
         foreach ($d as $k => $v) {
             $tu->numch($k, $v);
             $award[$k] = $v;
         }
     }
     $d = $params['minus'];
     if ($d) {
         foreach ($d as $k => $v) {
             $tu->numch($k, -$v);
         }
     }
     $items = $conf['items'];
     if ($items) {
         foreach ($items as $item) {
             $num = $item['num'];
             unset($item['num']);
             $iconf = ItemConfig::getItem($item['tag']);
             $g = $iconf['group'];
             if (!$g) {
                 $g = 'o';
             }
             if (!$num) {
                 $num = 1;
             }
             for ($i = 0; $i < $num; $i++) {
                 $item['pos'] = 's';
                 $item['id'] = $tu->getoid(null, $g);
                 $tu->puto($item);
                 $award['items'][] = $item;
             }
         }
     }
     $rids = $params['rids'];
     if ($rids) {
         $tu->remove($rids);
     }
     $ret['award'] = $award;
     $to['id'] = $tid;
     $to['s'] = 'finished';
     $to['ut'] = time();
     $tu->puto($to);
     $ret['s'] = 'OK';
     return $ret;
 }
コード例 #15
0
ファイル: HelpGet.php プロジェクト: uning/mallb
 /**
 * 领取
 * @param $params
 *   require  u      --  玩家id
 *            tag    --  对应xml的id,物品
 *            
 * @return 
 *            s      --  OK,other failed
 no,不能open的物品
 nopen,没有打开
 cond,没有达到条件
 award,已经领取
 *            ids    --  新增物品id
 */
 public function award($params)
 {
     $uid = $params['u'];
     $tu = new TTUser($uid);
     $tag = $params['tag'];
     $conf = self::getConf($tag);
     if (!$conf) {
         $ret['s'] = 'no';
         return $ret;
     }
     $id = $tu->getoid($tag, 'ho');
     $obj = $tu->getbyid($id);
     if (!$obj) {
         $ret['s'] = 'nopen';
         return $ret;
     }
     if (count($obj['help']) < $conf['need_num']) {
         $ret['s'] = 'cond';
         return $ret;
     }
     if ($obj['award']) {
         $ret['s'] = 'award';
         return $ret;
     }
     $obj['award'] = $_SERVER['REQUEST_TIME'];
     $obj['id'] = $id;
     $tu->puto($obj);
     $iid = $tu->getoid(null, $conf['group']);
     $item['id'] = $iid;
     $item['pos'] = 's';
     $item['tag'] = $tag;
     $tu->puto($item);
     $ret['s'] = 'OK';
     $ret['id'] = $iid;
     $ret['tag'] = $tag;
     return $ret;
 }
コード例 #16
0
ファイル: CarController.php プロジェクト: uning/mallb
 /**
  * 使用副驾驶
  * @param $params
  * require          u             --   user_id
  *                  tag           --   副驾驶类别
  *                  cid           --   car id
  * @return
  *                  s             --   OK
  *                  tag           --   副驾驶tag
  *                  car           --   测试信息
  *                  copi          --   测试信息
  */
 public function apply_copolit($params)
 {
     $uid = $params['u'];
     $tag = $params['tag'];
     $cid = $params['cid'];
     $copi = self::$_config[$tag];
     $stat['tag'] = $tag;
     $stat['op'] = 'apply_copolit';
     $stat['num'] = $num;
     $stat['u'] = $uid;
     $stat['tm'] = $_SERVER['REQUEST_TIME'];
     $gemt = TT::GemTT();
     if (!$copi) {
         $ret['s'] = 'copinotexist';
         $stat['s'] = $ret['s'];
         $gemt->putKeep(null, $stat);
         return $ret;
     }
     $tu = new TTUser($uid);
     $id = $tu->getoid('copilot', TT::OTHER_GROUP);
     $copilot = $tu->getbyid($id);
     $car_obj = $tu->getbyid($cid);
     if (!$car_obj) {
         $ret['s'] = 'carnotexsit';
         $stat['s'] = $ret['s'];
         $gemt->putKeep(null, $stat);
         return $ret;
     }
     if ($tag != 2006 && $car_obj['copolitTag']) {
         $ret['s'] = 'repeat';
         $stat['s'] = $ret['s'];
         $gemt->putKeep(null, $stat);
         return $ret;
     }
     $goods = ItemConfig::getItem($car_obj['goodsTag']);
     if ($tag != 2006) {
         if ($copilot['bag'][$tag] < 1) {
             $ret['s'] = 'needbuy';
             $stat['s'] = $ret['s'];
             $gemt->putKeep(null, $stat);
             return $ret;
         }
         $copilot['bag'][$tag] -= 1;
         $car_obj['copolitTag'] = $tag;
     } else {
         if ($goods['buytime'] >= 1800) {
             $car = ItemConfig::getItem($car_obj['tag']);
             $add_exp = $goods['exp'] * $car['goodsNumber'];
             //乘以载重箱,经验不包括好友帮助增加的箱数
             if ($add_exp) {
                 $tu->addExp($add_exp);
             }
         }
         unset($car_obj['addgoods']);
         unset($car_obj['accelerate']);
         unset($car_obj['t']);
         unset($car_obj['help']);
         unset($car_obj['goodsTag']);
         unset($car_obj['copolitTag']);
     }
     $copilot['id'] = $id;
     $now = time();
     $tu->puto($copilot);
     if ($copi['addgoods']) {
         $car_obj['addgoods'] += $copi['addgoods'];
     }
     if ($copi['accelerate'] && $car_obj['t']) {
         if ($now - $car_obj['t'] + $copi['accelerate'] > $goods['buytime']) {
             $car_obj['t'] = $now - $goods['buytime'];
         } else {
             $car_obj['t'] -= $copi['accelerate'];
         }
     }
     $tu->puto($car_obj);
     $ret['s'] = 'OK';
     $ret['tag'] = $tag;
     $stat['s'] = $ret['s'];
     $gemt->putKeep(null, $stat);
     return $ret;
 }
コード例 #17
0
ファイル: test.php プロジェクト: uning/mall-back
<?php

/*	$myloc=dirname(__FILE__);
    require_once  $myloc.'/bg/base.php'; 
	require_once LIB_ROOT.'ModelFactory.php';
	require_once LIB_ROOT.'AutoIncIdGenerator.php';
    $platform_id = "302268025";
    $pid = "renren302268025";
	$user_id = AutoIncIdGenerator::genid($platform_id);
	$p_user = AutoIncIdGenerator::genid($pid);
	echo "user_id = $user_id\n";
	echo "p_user = $p_user\n";
require_once('config.php');
$linkid =':4c60c7314f3ef';
$tw = TT::TTWeb();
	echo 'i.m here<br>';	
	$irec = $tw->getbyid($linkid);
	print_r($irec);*/
require_once 'config.php';
$user = new TTUser(13);
$v = $user->getbyid('13:o:4c7dd4debd11e');
print_r($v);
$v['tag'] = 60002;
$user->puto($v);
コード例 #18
0
ファイル: Gift.php プロジェクト: uning/mall-back
 /**
  * 收取礼物
  * @param $params
  *  require         u        -- user id
  *                  gids      -- gift ids
  * @return 
  *  s       -- OK ,or other fail
  *  id2id   -- 新旧ids映射
  */
 public function accept($params)
 {
     $uid = $params['u'];
     $tu = new TTUser($uid);
     $gifts = $params['gids'];
     foreach ($gifts as $gid) {
         $d = $tu->getbyid($gid);
         $oid = $d['id'];
         if ($d) {
             $tag = $d['gtag'];
             if ($tag) {
                 $d['tag'] = $tag;
             } else {
                 $tag = $d['tag'];
             }
             $conf = ItemConfig::getItem($tag);
             if (!$conf) {
                 continue;
             }
             $g = $conf['group'];
             if (!$g) {
                 $g = TT::ITEM_GROUP;
             }
             $id = $tu->getdid(null, $g);
             $id2id[$gid] = $id;
             $d['id'] = $id;
             unset($d['msg']);
             $d['pos'] = 's';
             $tu->puto($d);
         } else {
             $id2id[$gid] = null;
         }
         $rids[] = $oid;
     }
     $tu->remove($rids);
     $ret['s'] = 'OK';
     $ret['id2id'] = $id2id;
     TTLog::record(array('m' => __METHOD__, 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $uid, 'intp1' => $d['fid'], 'sp1' => $tag));
     return $ret;
 }
コード例 #19
0
ファイル: accept.php プロジェクト: uning/mall-back
    }
} else {
    if (!is_array($ids)) {
        $ids = array();
    }
    if (array_key_exists($touser, $ids)) {
        $invite = true;
    }
    if (array_key_exists($touser, $getted)) {
        $got = true;
    }
}
if ($invite && $new == 1 && !$gemd && !$ut && !$got) {
    $ftu->numch('invite_num', 1);
    $cid = $ftu->getoid('copilot', TT::OTHER_GROUP);
    $copilot = $ftu->getbyid($cid);
    $copilot['id'] = $cid;
    $copilot['bag'][2004] += 1;
    $ftu->puto($copilot);
    $tsess['gemd'] = 1;
    TTGenid::update($tsess, $tsess['id']);
}
if ($invite) {
    $gid = $link['gift'];
    if ($gid) {
        ?>
		<div id='content'>
	<div class='container'>
        <div class='canvas'>
			<div id="header">
				<div id="navga">
コード例 #20
0
ファイル: Advert.php プロジェクト: uning/mall-back
 /**
  * 获取广告
  * @param $params
  *   require  u       --  玩家id
  * @return 
  *   s                --  OK,other failed
  *   use              -- 使用广告宣传队列,包括历史和当前正在使用
  *                    starttime=>tag
  *                    1234445=>122
  *   bag              tag=>num,数组
  */
 public function get($params)
 {
     $uid = $params['u'];
     $tu = new TTUser($uid);
     $id = $tu->getoid('advert', TT::OTHER_GROUP);
     $advbag = $tu->getbyid($id);
     //      $ret['advbag'] = $advbag;
     if (!$advbag['bag'] && !$advbag['use']) {
         $ret['s'] = 'notexsit';
         return $ret;
     }
     $advbag['s'] = 'OK';
     $advbag['id'] = $id;
     return $advbag;
 }