Example #1
0
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);
}
Example #2
0
$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;
} else {