Beispiel #1
0
 /**
  * 结算收入
  *   
  * @param $params
  *    require   u      -- uid
  * @return 
  *    s   -- ok
  */
 public function checkout($params)
 {
     $uid = $params['u'];
     $db = ServerConfig::getdb_by_userid($uid);
     $ug = ModelFactory::UserGood();
     $ua = ModelFactory::UserAccount($db);
     $ret['s'] = 'ok';
     return $ret;
 }
Beispiel #2
0
 /**
  * 登录游戏
  *   
  * @param $params
  *    require   pid      -- platformid
  *    optional  anyfield  --头像等保存到 infos
  * @return 
  *    u      userid
  * 	  infos  map 玩家基本信息,头
  *    accs   map 玩家相关数值信息
  */
 public function login($params)
 {
     $pid = $params['pid'];
     $uid = AutoIncIdGenerator::genid($pid);
     $db = ServerConfig::getdb_by_userid($uid);
     $ua = ModelFactory::UserAccount($db);
     $uin = ModelFactory::UserInfo();
     $uin->put($params, $uid);
     $ret['s'] = 'ok';
     $ret['infos'] = $uin->get($uid);
     $ret['u'] = $uid;
     return $ret;
 }
Beispiel #3
0
 /**
  * 进货
  * @param $params
  * require  u  -- user_id
  * require  c  -- car be lold
  * require  g  -- the goods to be load
  * @return unknown_type
  * s   -- ok
  * c   -- car status
  * t   -- current time
  */
 public function go_goods($params)
 {
     //todo:添加购买验证逻辑
     //购买多个支持
     $uid = $params['u'];
     $car = ModelFactory::UserCar();
     $goods = ModelFactory::UserGood();
     $db = ServerConfig::getdb_by_userid($uid);
     $ua = ModelFactory::UserAccount($db);
     $car->put_super($params['c'], $uid);
     $item_count = 10;
     //货车容量从配置文件读取
     for ($i = 0; $i < $item_count; $i++) {
         $goods->put_super($params['c'], $uid);
     }
     $ret['s'] = 'ok';
     $ret['t'] = time();
     return $ret;
 }
Beispiel #4
0
<?php

//用户授权应用后的回调
//使用user_profiles 中的intparam2来记录用户的状态, -1来表示用户删除应用,1表示用户授权应用
include "./header.php";
$platform_id = "renren" . $renren->user;
$session_key = $renren->session_key;
$user_id = AutoIncIdGenerator::genid($platform_id);
$db = ServerConfig::getdb_by_userid($user_id);
$up = ModelFactory::UserProfile($db);
$up->find($user_id);
$up->setAttr("intparam2", 1);
$up->setAttr("intparam1", time());
$up->save();
Beispiel #5
0
$renren->api_key = RenrenConfig::$api_key;
$renren->secret = RenrenConfig::$secret;
$renren->init();
$platform_id = "renren" . $renren->user;
$session_key = $renren->session_key;
$user_id = AutoIncIdGenerator::genid($platform_id);
$db = ServerConfig::getdb_by_userid($user_id);
$secret = Renrenconfig::$pay_secure;
//
if ($_POST['xn_sig_password'] != $secret) {
    echo "!!";
    exit;
}
$ua = ModelFactory::UserAccount($db);
$ua->find($user_id);
$order_db = ServerConfig::getdb_by_userid(0);
$order = ModelFactory::Order($order_db);
$order->find($_POST['xn_sig_order_number']);
if ($order->getAttr("is_paid")) {
    print json_encode(array('user_id' => $order->getAttr("platform_id"), 'amount' => $order->getAttr("amount"), 'order_number' => $order->getAttr("id")));
    exit;
}
$gem = $ua->getAttr("gem");
$gem += $order->getAttr("gem");
$ua->setAttr("gem", $gem);
$order->setAttr("is_paid", true);
$order->setAttr("paid_at", Date('Y-m-d H:i:s', time()));
if (!$order->save()) {
    Logger::error("order save error: " . $_POST['xn_sig_order_number']);
    print json_encode(array('user_id' => $order->getAttr("platform_id"), 'amount' => $order->getAttr("amount"), 'order_number' => $order->getAttr("id")));
    exit;