www.gusucode.com > 2030网博士成品网站管理系统 PHP网站源码程序 > 2030/dingcan/module/DingCanStartOrder.php

    <?php

/*
	[插件名称] 订单处理
*/

function DingCanStartOrder(){

	global $fsql,$msql,$strOrderNotice2,$strOrderNotice3,$strGoodstype1,$strGoodstype2,$strGoodstype3,$strDanJia,$strMemberPrice;

	$tempname=$GLOBALS["PLUSVARS"]["tempname"];
		
	//根据会员是否登录进行一些信息判断
	if(isLogin()){
		$priceinfo=$strMemberPrice;
		$showcent="block";
	}else{
		$priceinfo=$strDanJia;
		$showcent="none";
	}
	
	//模版解释
	$Temp=LoadTemp($tempname);
	$TempArr=SplitTblTemp($Temp);

	//判断当前是否在订餐时间范围内
	$nowtime=time();
	$hour=date("H",$nowtime);
	$minute=date("i",$nowtime);
	$time_now=$hour+$minute/60;
		
	//读取送餐时间参数
	$time_am1_str=$GLOBALS["DINGCANCONF"]["DingCanAm_1"];
	$time_am2_str=$GLOBALS["DINGCANCONF"]["DingCanAm_2"];
	$time_pm1_str=$GLOBALS["DINGCANCONF"]["DingCanPm_1"];
	$time_pm2_str=$GLOBALS["DINGCANCONF"]["DingCanPm_2"];
		
	$time_am1_arr=explode(":", $time_am1_str);
	$time_am1=$time_am1_arr[0]+$time_am1_arr[1]/60;
	$time_am2_arr=explode(":", $time_am2_str);
	$time_am2=$time_am2_arr[0]+$time_am2_arr[1]/60;
	$time_pm1_arr=explode(":", $time_pm1_str);
	$time_pm1=$time_pm1_arr[0]+$time_pm1_arr[1]/60;
	$time_pm2_arr=explode(":", $time_pm2_str);
	$time_pm2=$time_pm2_arr[0]+$time_pm2_arr[1]/60;
		
	if(($time_now>=$time_am1 && $time_now<=$time_am2) || ($time_now>=$time_pm1 && $time_now<=$time_pm2)){
		$ifcontinue="YES";
		$iferr="none";
	}else{
		$ifcontinue="NO";
		$errstr=$strOrderNotice2.$time_am1_str."-".$time_am2_str.$strOrderNotice3.$time_pm1_str."-".$time_pm2_str;
		$iferr="block";
	}
	//判断当前是否在订餐时间范围内结束	

	$var=array(
		'iferr'=>$iferr,
		'errstr'=>$errstr
	);
	$str=ShowTplTemp($TempArr["start"],$var);


	if($ifcontinue=="YES"){	
		
		//读取购物车信息
		$var=array(
			'showcent'=>$showcent,
			'priceinfo'=>$priceinfo
		);
		$str.=ShowTplTemp($TempArr["m0"],$var);

		$CARTSTR=$_COOKIE["DINGCANCART"];

		$array=explode('#',$CARTSTR);
		$tnums=sizeof($array)-1;
		$tjine=0;  //小计
		$kk=0;
		
		for($t=0;$t<$tnums;$t++){
			$fff=explode('|',$array[$t]);
			$goodstype=$fff[0];
			$gid=$fff[1];
			$nums=$fff[2];
			$fz=$fff[3];
			
			if($goodstype=="diy"){
				$tbl="{P}_dingcan_zxcon";
				$gtinfo=$strGoodstype1;
				$ifmod="";
				$ifshowcaipin="none";
				$caipin_str="";
			}elseif($goodstype=="tc"){
				$tbl="{P}_dingcan_gdcon";
				$gtinfo=$strGoodstype2;
				$ifmod="";
				$ifshowcaipin="none";
				$caipin_str="";
			}else{
				$tbl="{P}_dingcan_zhcon";
				$gtinfo=$strGoodstype3;
				$ifmod="readonly";  //若为组合套餐,则不可修改份数
				
				//对于组合套餐,统计菜品详情
				$ifshowcaipin="block";
				$caipin_arr=explode(",", $fz);
				$caipin_nums=count($caipin_arr);
				for($i=0; $i<$caipin_nums; $i++){
					$caipin_arr2=explode(":", $caipin_arr[$i]);
					
					$fsql->query("select * from {P}_dingcan_zhcpcon where id='$caipin_arr2[0]'");
					if($fsql->next_record()){
						$cptitle=$fsql->f('title');
						
						$caipin_str.=$cptitle."(".$caipin_arr2[1]."),";
					}
				}
				$caipin_str=substr($caipin_str, 0, -1);
			}

			$fsql->query("select * from $tbl where id='$gid'");
			if($fsql->next_record()){
				$title=$fsql->f('title');
				$perprice=$fsql->f('perprice');
				$mcent=$fsql->f('mcent');
			
				$price=getMemberPrice($gid,$perprice);
				$showprice=number_format($price,2,'.','');
				$jine=$price*$nums;
				$jine=number_format($jine,2,'.','');
					

				//计算积分
				$jicent=$mcent*$nums;
					
				$goodsurl=ROOTPATH."dingcan/html/?".$gid.".html";
				
				$var=array (
					'gid' => $gid,
					'goodstype' => $goodstype,
					'gtinfo' => $gtinfo,
					'nums' => $nums,
					'jine' => $jine, 
					'price' => $showprice,
					'perprice' => $price,
					'fz' => '',
					'goodsname' => $title,
					'showcent'=>$showcent,
					'mcent'=>$mcent,
					'jicent'=>$jicent,
					'ifmod'=>$ifmod,
					'ifshowcaipin' => $ifshowcaipin,
					'caipin_str' => $caipin_str
				);
						
				$str.=ShowTplTemp($TempArr["list"],$var);
					
			}
			
			$allnums+=$nums;
			$tjine=$tjine+$jine;
			$tcent=$tcent+$jicent;
			$kk++;
		}
		$tjine=number_format($tjine,2,'.','');
		
		$var=array(
			'allnums' => $allnums,
			'tjine' => $tjine,
			'showcent'=>$showcent,
			'tcent'=>$tcent
		);
		$str.=ShowTplTemp($TempArr["m1"],$var);
		

		if($kk>0){
			if(isLogin()){
				
				$var=array(
					'tjine' => $tjine
				);
				$str.=ShowTplTemp($TempArr["m2"],$var);
			
			}else{
				
				$var=array(
					'tjine' => $tjine
				);
				$str.=ShowTplTemp($TempArr["m3"],$var);
			
			}
			
		}else{
			header("location:".ROOTPATH."index.php");
		}
		
		$str.=$TempArr["end"];

	}
	
	return $str;

}

?>