<?php

/**
 * 兑换码
 */
defined('IN_WEB') or die('Include Error!');

class ExchangeCode {

	public function __construct() {
		
	}

	/**
	 * @function  exchange
	 * @desc      兑换码兑奖
	 * @return array 兑奖结果
	 */
	function exchange($param) {
		$data = array('code' => -1);
		$uid = oo::functions()->uint($param['uid']);
		$code = oo::functions()->escape($param['code']);
		if ( !$uid || !$code ) {
			return json_encode($data);
		}
		
		$data = oo::commonOprModel('exchangecode')->exchange($code, $uid);
		return json_encode($data,JSON_NUMERIC_CHECK);
	}

}
