예제 #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
파일: 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;
 }
예제 #3
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;
 }
예제 #4
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;
 }
예제 #5
0
파일: Advert.php 프로젝트: uning/mall-back
 /**
  * 使用广告
  * @param $params
  *   require  u      --  玩家id
  *            tag    --  某类广告id;
  *            
  * @return 
  *            s      --  OK,other failed
  *            s      --  nofind,没有该广告
  *            s      --  error,
  */
 public function set($params)
 {
     $uid = $params['u'];
     $adv_tag = $params['tag'];
     $adv = AdvertConfig::getAdvert($adv_tag);
     if (!$adv) {
         $ret['s'] = 'notexsit';
         return $ret;
     }
     $tu = new TTUser($uid);
     //增加扣钱操作和加人气值
     $id = $tu->getoid('advert', TT::OTHER_GROUP);
     $advbag = $tu->getbyid($id);
     if (!$advbag || $advbag['bag'][$adv_tag] < 1) {
         $ret['s'] = 'notexsit';
         $ret['r'] = $advbag;
         return $ret;
     }
     $now = time();
     $advbag['use'][$now] = $adv_tag;
     $advbag['bag'][$adv_tag] -= 1;
     $exp = $tu->getf(TT::EXP_STAT);
     $ua = UpgradeConfig::getUpgradeNeed($exp);
     $maxpopu = $ua['maxpopu'] + $adv['maxpopular'];
     if ($maxpopu > $tu->getf('max_popu')) {
         $tu->putf('maxpopu', $maxpopu);
     }
     //使用广告次数
     $ret['s'] = 'OK';
     $ret['t'] = $now;
     $ret['tag'] = $adv_tag;
     $tu->puto($advbag, TT::ADVERT_GROUP, false);
     return $ret;
 }
예제 #6
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;
 }
예제 #7
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;
 }
예제 #8
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;
 }
예제 #9
0
파일: op_bar.php 프로젝트: uning/mall-back
require_once '../config.php';
/*
$ret['query'] = $_REQUEST;
$ret['post'] = $_POST;
$ret['get'] = $_GET;
echo json_encode($ret);
*/
$op = $_REQUEST['op'];
$pid = $_REQUEST['xn_sig_user'];
if ($op && $pid) {
    $sess = TTGenid::getbypid($pid);
    $uid = $sess['id'];
    if (!$sess && $uid) {
        echo "{'s':'fail','msg':'not find {$pid} op={$op}'}";
        return;
    }
    $tu = new TTUser($uid);
    $id = $tu->getdid('installbar', TT::OTHER_GROUP);
    $barobj = $tu->getbyid($id);
    if ($barobj[$op]) {
        echo "{'s':'fail','msg':'not find {$pid} op={$op}'}";
        return;
    } else {
        $barobj['id'] = $id;
        $barobj[$op]['save'] = time();
        $tu->puto($barobj, TT::OTHER_GROUP, false);
        echo "{'s':'ok'}";
        return;
    }
}
echo "{'s':'fail','error':'pid={$pid} op={$op}'}";
예제 #10
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;
 }
예제 #11
0
 /**
  * 完成任务
  *   
  * @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;
 }
예제 #12
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;
 }
예제 #13
0
 /**
  * 移动
  * @param $params
  *  require u              --             user id
  *          d              --             item数组
  *                         id             --        type id(类型id)
  *                         pos            --        position information of items
  * @return 
  *                         s              --        OK ,or other fail
  *                                     notexsit ,不存在
  *				      gem
  */
 public function move($params)
 {
     $uid = $params['u'];
     $tu = new TTUser($uid);
     if ($tu->check_dup($params['_cid'], $ret)) {
         return $ret;
     }
     $index = 1;
     $ids = array();
     $pop = 0;
     $now = time();
     foreach ($params['d'] as $index => $row) {
         $item_obj = $tu->getbyid($row['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;
         }
         if ($item['type'] == 'ro' && $row['pos'] == 's') {
             //todo $tu 结算
             if ($item_obj['pos'] != 's') {
                 require_once 'GoodsController.php';
                 GoodsController::checkout($params);
                 $item_obj = $tu->getbyid($row['id']);
             }
             //*{//对货物尚未卖完的店面进行移动时要先单个结算,确定货物队列为空时才能移动
             if ($item_obj['_s'] == 'goods') {
                 $ret['error'] = 'notempty';
                 $ret['s'] = 'OK';
                 $ret['index'] = $index;
                 TTLog::record(array('m' => __METHOD__, 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $uid, 'sp2' => 'movegoodsshop', 'shoptag' => $item_obj['tag'], 'sp1' => $item_obj['id']));
                 continue;
             }
         }
         if ($item['type'] != 'ro') {
             //改为不计算店面的人气
             if ($row['pos'] != 's' && $item_obj['pos'] == 's') {
                 $pop += $item['pop'];
                 if ($item['type'] == 'rs') {
                     //特殊店需从仓库摆出,结算时间为摆放时间
                     $row['ctime'] = $now;
                 }
             } else {
                 if ($row['pos'] == 's' && $item_obj['pos'] != 's') {
                     $pop -= $item['pop'];
                     if ($item['type'] == 'rs') {
                         //特殊店放入仓库结算时间需置零
                         unset($row['ctime']);
                     }
                 }
             }
         }
         foreach ($row as $k => $v) {
             $item_obj[$k] = $v;
         }
         $ret[$row['id']] = $item;
         $tu->puto($item_obj, '', false);
         //reduce a get op
     }
     if ($pop) {
         $popu = $tu->numch(TT::POPU, $pop);
     }
     if (!$ret['s']) {
         $ret['s'] = 'OK';
     }
     return $ret;
 }
예제 #14
0
 /**
  * 使用副驾驶
  * @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;
 }
예제 #15
0
 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;
 }
예제 #16
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);
예제 #17
0
파일: Tool.php 프로젝트: uning/mall-back
 public function addgoods($params)
 {
     $goods_obj = array();
     $uid = $params['u'];
     $tu = new TTUser($uid);
     for ($tag = 10101; $tag < 10113; $tag++) {
         for ($j = 0; $j < 5; $j++) {
             if (isset($goods_obj['id'])) {
                 unset($goods_obj['id']);
             }
             $goods = ItemConfig::getItem($tag);
             $goods_obj['num'] = $goods['unitcout'];
             $goods_obj['tag'] = $tag;
             $goods_obj['pos'] = 's';
             $tu->puto($goods_obj, TT::GOODS_GROUP);
         }
     }
     $ret['s'] = 'OK';
     return $ret;
 }
예제 #18
0
파일: accept.php 프로젝트: uning/mall-back
		<?php 
        }
        ?>
	         <a href='<?php 
        echo RenrenConfig::$canvas_url;
        ?>
' class='giftformsubmit' >返回游戏</a>	
	</div>
	</div>
		<?php 
        if (!$got) {
            $id = $ttu->getdid('', $gift[$gid]['group']);
            $data['tag'] = $gid;
            $data['id'] = $id;
            $data['pos'] = 's';
            $ttu->puto($data);
        }
    }
    if (!$got) {
        $link['geted'][$touser] = 1;
        $tw->put($link);
    }
    if (!$gid) {
        ?>
		<xn:redirect url="<?php 
        echo RenrenConfig::$canvas_url;
        ?>
" />
		<?php 
    }
}
예제 #19
0
                 $tu->chGem(5);
                 $copilot['bag'][2002] += 2;
                 //加两箱的道具
                 $copilot['bag'][2004] += 2;
                 //加6小时的道具
                 $str = '100000金币,5个宝石,2份加两箱的道具,2份加6小时的道具';
             } else {
                 $tu->chMoney(50000);
                 $tu->chGem(3);
                 $copilot['bag'][2002] += 1;
                 //加两箱的道具
                 $str = '50000金币,3个宝石,1份加两箱的道具';
             }
         }
     }
     $tu->puto($copilot);
     $sess['caward'] += 1;
     TTGenid::genid($sess);
     echo "<div style='font-size:16px;margin:20px;'>已经补偿给你<span style='font-weigth:bold;color:red;'>{$str}</span>请注意查收。<a href='" . RenrenConfig::$canvas_url . "'>返回游戏</a></div>";
 } else {
     if ($sess['caward'] && $sess['caward'] == 2) {
         $tu = new TTUser($u);
         //$getids[]=$tu->getdid('caward');
         $getids[] = $tu->getdid('exp');
         $getids[] = $tu->getdid('');
         $coid = $tu->getoid('copilot', TT::OTHER_GROUP);
         $getids[] = $coid;
         $datas = $tu->getbyids($getids);
         $level = $tu->getLevel($datas['exp']);
         $str = "";
         if ($level > 30) {