Ejemplo n.º 1
0
 /**
  * 接受礼物赠送
  * @param $params
  *   require  u         -- 受礼人id
  *            f         -- 送礼人id
  *            tag       -- 礼物种类
  * @return 
  *            s         --  OK
  */
 public function accept_gift($params)
 {
     $uid = $params['u'];
     $fid = $params['f'];
     $xid = $params['xid'];
     $msg = $params['msg'];
     if (0) {
         //验证xml中是否存在此物品
     }
     $db = ServerConfig::connect_main_mysql(0);
     $present = ModelFactory::Present($db);
     $gift = $present->findByIDs($uid, $fid, $xid);
     //验证逻辑
     if (!$gift) {
         $ret['s'] = 'notexsit';
         return $ret;
     }
     $tm = new TTMain();
     $gift_obj['tag'] = $gift['item_id'];
     $tm->put($gift_obj, $uid, TT::ITEM_GROUP);
     $ret['s'] = 'OK';
     return $ret;
 }
Ejemplo n.º 2
0
 /**
  * function get db connection
  */
 public static function getdb_by_userid($userid)
 {
     return ServerConfig::connect_main_mysql($userid, 1);
 }
Ejemplo n.º 3
0
<?php

require_once dirname(__FILE__) . "/../../base.php";
require_once MODEL_ROOT . "ModelFactory.php";
function test_invitation(&$db)
{
    $invit = ModelFactory::Invitation($db);
    $data = array('user_id' => 1, 'to_id' => 2, 'gift_id' => 3, 'is_accepted' => 1, 'updated_at' => date(TM_FORMAT, time()));
    $invit->insert($data);
}
function test_order(&$db)
{
    $order = ModelFactory::Order($db);
    $now = time();
    $data = array('order_id' => "order.{$now}", 'user_id' => 1, 'pid' => "pid.{$now}", 'amount' => 10, 'gem' => 20, 'is_paid' => 1, 'order_type' => "facebook", 'paid_at' => date(TM_FORMAT, $now), 'created_at' => date(TM_FORMAT, $now));
    $order->insert($data);
}
function test_present(&$db)
{
    $now = time();
    $present = ModelFactory::Present($db);
    $now = time();
    $data = array('user_id' => 1, 'donor_id' => 2, 'message' => 'wahaha', 'item_id' => 3, 'done' => 0, 'created_at' => date(TM_FORMAT, $now));
    $present->insert($data);
}
//$db = ServerConfig::getdb_by_userid(0);
$db = ServerConfig::connect_main_mysql(0);
//test_invitation( $db );
test_order($db);
//test_present($db);