<?php
$menumark = 'prodv';
switch ($act) {	
	case 'tgpic':
	case 'tgword':
		$info = $db->pe_select('prodv', array('id'=>$_g_id), '`tgpic`, `tgword`, `domainmark`');
		$info_list = $act == 'tgpic' ? (array)unserialize($info['tgpic']) : (array)unserialize($info['tgword']);
		$maindomain = "http://";
		$urlmodel = $pe['url_model'] == 'pathinfo_safe' ? '/index.php' : '';
		if ($info['domainmark']) {
			$maindomain .= "{$info['domainmark']}/";
		}
		else {
			$maindomain .= "{$pe['domain_mark']}/";
		}

		$maindomain .= "?u={$user['user_subdomain']}";


		$seo = pe_seo('推广联盟');
		include(pe_tpl('package_tg_dialog.html'));
	break;
	case 'porder':
		$menumark = 'prodv_order';
		$data = $db->pe_selectall('prodv_order',array('userid'=>$_s_user_id));
		$seo = pe_seo('积分购买记录');
		include(pe_tpl('prodv_order_list.html'));
	break;
	case 'buy':
		if($_p_id){
			$r=$db->pe_select('prodv_order',array('userid'=>$_s_user_id,'prodvid'=>$_p_id));
			if($r)pe_alert('您已经购买了该产品!','user.php?mod=prodv');
			$r=$db->pe_select('setting',array('setting_key'=>'huilv'));
			$arr=unserialize(base64_decode($r['setting_value']));
			$k=array_keys($arr);
			$hl_p=$k[1];$hl_t=$arr[$hl_p];
			$tjnum=(int)($_p_point*$hl_t/$hl_p);
			if($user['tj_user_num']<$tjnum){
				$r=$db->pe_select('editsetting',array('name'=>'tip_buy_tj'));
				pe_alert($r['content']);
			}
			$info['prodvid']=$_p_id;
			$info['addtime']=TIME;
			$info['userid']=$_s_user_id;
			if ($db->pe_insert('prodv_order', $info)) {
				$tjnum=0-$tjnum;
				$point=0-$_p_point;
				$remark='购买产品';
				point($_s_user_id,$point,$remark,$tjnum,$_p_id);
				pe_success('产品成功购买!','user.php?mod=prodv&act=porder');
			}
			else {
				pe_error('产品购买失败...');
			}
		}
		else
		{
			$info = $db->pe_select('prodv',array('id'=>$_g_id));
			if($info['status']==0)pe_error('产品已经下架!','user.php?mod=prodv');
			$seo = pe_seo('购买产品');
			include(pe_tpl('prodv_buy.html'));
		}
		
	break;
	case 'show':
	 	$info = $db->pe_select('prodv', array('id'=>$_g_id));
		if($info['status']==0)pe_error('产品已经下架!','user.php?mod=prodv');
		$info_list =(array)unserialize($info['tgword']);
		$maindomain = "http://";
		$urlmodel = $pe['url_model'] == 'pathinfo_safe' ? '/index.php' : '';
		if ($info['domainmark']) {
			$maindomain .= "{$info['domainmark']}/";
		}
		else {
			$maindomain .= "{$pe['domain_mark']}/";
		}
		$maindomain .= "?u={$user['user_subdomain']}";
		$seo = pe_seo('积分产品详情');
		include(pe_tpl('prodv_show.html'));
	break;
	//#####################@ 推广联盟  @#####################//
	default:
		$info_list = $db->pe_selectall('prodv',array('order by'=>'status desc'), '*', array(10, $_g_page));
		$seo = pe_seo('推广联盟');
		include(pe_tpl('prodv_list.html'));
	break;
}
?>