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

    <?php
define("ROOTPATH", "../../");
include(ROOTPATH."includes/admin.inc.php");
include("language/".$sLan.".php");
include("func/upload.inc.php");
include("func/comm.inc.php");
NeedAuth(700);

$act=$_POST["act"];

switch($act){
	
	//电话订餐-非会员订餐录入
	case "notmemberorder":
		
		$ordertype=$_POST["ordertype"];
		$payid=$_POST["payid"];
		$zoneid=$_POST["zoneid"];
		$sctime=$_POST["sctime"];
		$pscenter=$_POST["pscenter"];
		$cname=htmlspecialchars($_POST["cname"]);
		$phone=htmlspecialchars($_POST["phone"]);
		$address=htmlspecialchars($_POST["address"]);
		$pscost=htmlspecialchars($_POST["pscost"]);
		
		$zx=$_POST["zx"];
		$gd=$_POST["gd"];
		
		//获取所选组合套餐的数量信息
		$zhtclist_arr=$_POST["zhtclist"];  
		$zhtclist_nums=count($zhtclist_arr);
		
		//获取所选组合套餐的ID信息
		$zhtcid_arr=$_POST["zhtcid"];
		$zhtcid_nums=count($zhtcid_arr);
	
		//数据处理
		if($payid==""){
			echo $strOrderNotice22;
			exit;
		}
		if($cname==""){
			echo $strOrderNotice11;
			exit;
		}
		if($phone==""){
			echo $strOrderNotice12;
			exit;
		}
		if($zoneid==""){
			echo $strOrderNotice13;
			exit;
		}
		if($address==""){
			echo $strOrderNotice14;
			exit;
		}
		if($sctime==""){
			echo $strOrderNotice15;
			exit;
		}
		if($pscenter==""){
			echo $strOrderNotice16;
			exit;
		}
		
		//读取支付方式的中文名称
		$msql->query("select pcenter from {P}_member_paycenter where id='$payid'");
		if($msql->next_record()){
			$paytype=$msql->f('pcenter');
		}
		
		//处理自选餐品的提交情况
		$nums_zx=sizeof($zx);
		for($i=0;$i<$nums_zx;$i++){
			$zxc_name="zxc_".$zx[$i];
			$zxc=$_POST[$zxc_name];
			$nums_zxc+=$zxc;
			
			$msql->query("select * from {P}_dingcan_zxcon where id='$zx[$i]'");
			if($msql->next_record()){
				$zxtitle=$msql->f('title');
				$zxperprice=$msql->f('perprice');
				$zxsparecopy=$msql->f('sparecopy');
			}
			
			//所选自选餐品费用小计
			$subtotalprice_zx+=$zxperprice*$zxc;
			
			//商品摘要
			//$goodsmemo_zx.=$zxtitle."&nbsp;".$zxc.",&nbsp;&nbsp;";
			$goodsmemo_zx.=$zxtitle."(".$zxc."),";
			
			//对所选餐品进行判断
			if($zxsparecopy==0){
				$zxstr.=$zxtitle.$strOrderNotice5.";";
			}elseif($zxc>$zxsparecopy){
				$cha=$zxc-$zxsparecopy;
				$zxstr.=$zxtitle.$strOrderNotice6.$zxsparecopy.$strCopy.";";
			}
		}
		if($zxstr!=""){
			$zxnotice=$strOrderNotice2.substr($zxstr,0,-1).".&nbsp;&nbsp;";
		}
		
		//处理固定套餐的提交情况
		$nums_gd=sizeof($gd);
		for($i=0;$i<$nums_gd;$i++){
			$gdc_name="gdc_".$gd[$i];
			$gdc=$_POST[$gdc_name];
			$nums_gdc+=$gdc;
			
			$msql->query("select * from {P}_dingcan_gdcon where id='$gd[$i]'");
			if($msql->next_record()){
				$gdtitle=$msql->f('title');
				$gdperprice=$msql->f('perprice');
				$gdsparecopy=$msql->f('sparecopy');
			}
			
			//所选固定套餐费用小计
			$subtotalprice_gd+=$gdperprice*$gdc;
			
			//商品摘要
			//$goodsmemo_gd.=$gdtitle."&nbsp;".$gdc.",&nbsp;&nbsp;";
			$goodsmemo_gd.=$gdtitle."(".$gdc."),";
			
			//对所选餐品进行判断
			if($gdsparecopy==0){
				$gdstr.=$gdtitle.$strOrderNotice5.";";
			}elseif($gdc>$gdsparecopy){
				$cha=$gdc-$gdsparecopy;
				$gdstr.=$gdtitle.$strOrderNotice6.$gdsparecopy.$strCopy.";";
			}
		}
		if($gdstr!=""){
			$gdnotice=$strOrderNotice3.substr($gdstr,0,-1).".&nbsp;&nbsp;";
		}
		
		//处理组合套餐的提交情况-所选套餐数量计算
		for($i=0;$i<$zhtclist_nums;$i++){
			$nums_zhc+=$zhtclist_arr[$i];
		}
		//处理组合套餐的提交情况-出错及提示信息处理
		for($i=0;$i<$zhtclist_nums;$i++){
			
			$zhid=$zhtcid_arr[$i];
			$msql->query("select * from {P}_dingcan_zhcon where id='$zhid'");
			if($msql->next_record()){
				$zhtitle=$msql->f('title');
				$zhzucheng=$msql->f('zucheng');
			}
	
			//对此套餐下的餐品组成进行解析,并做出错提示处理
			$zhzucheng_arr=explode(",", $zhzucheng);
			$zhzucheng_nums=count($zhzucheng_arr);
			
			for($k=0; $k<$zhzucheng_nums; $k++){
			
				$zhzucheng_arr2=explode(":", $zhzucheng_arr[$k]);
				
				if($zhzucheng_arr2[1]!="" && $zhzucheng_arr2[1]!=0){
					
					//读取套餐下的餐品类型
					$msql->query("select cat from {P}_dingcan_zhcat where catid='$zhzucheng_arr2[0]'");
					if($msql->next_record()){
						$zhcat=$msql->f('cat');
					}
					
					$msql->query("select * from {P}_dingcan_zhcpcon where catid='$zhzucheng_arr2[0]' order by xuhao");
					while($msql->next_record()){
						$zhcpid=$msql->f('id');
						
						$zhcpfs_name="zhcpfs_".$zhzucheng_arr2[0]."_".$zhcpid."_".$zhid;
						$zhcpfs_nums+=$_POST[$zhcpfs_name];
					}	
					
					$zhcpfs_nums_cha=$zhzucheng_arr2[1]-$zhcpfs_nums;
					$zhcpfs_nums_cha_value=abs($zhcpfs_nums_cha);
					
					if($zhcpfs_nums_cha>0){
						echo "<div style='text-align:left;'>".$strOrderNotice1."<br />".$strOrderNotice4."<font style='font-weight:bold;'>".$zhtitle."</font>".$strOrderNotice19.$zhcat.$strOrderNotice20.$zhcpfs_nums_cha_value.$strCopy."</div>";
						exit;
					}elseif($zhcpfs_nums_cha<0){
						echo "<div style='text-align:left;'>".$strOrderNotice1."<br />".$strOrderNotice4."<font style='font-weight:bold;'>".$zhtitle."</font>".$strOrderNotice19.$zhcat.$strOrderNotice21.$zhcpfs_nums_cha_value.$strCopy."</div>";
						exit;
					}
				
				}
				
				$zhcpfs_nums="";
				
			}
			
		}
		//处理组合套餐的提交情况-获取所选套餐信息
		for($i=0;$i<$zhtclist_nums;$i++){
			
			$zhid=$zhtcid_arr[$i];
			$msql->query("select * from {P}_dingcan_zhcon where id='$zhid'");
			if($msql->next_record()){
				$zhtitle=$msql->f('title');
				$zhperprice=$msql->f('perprice');
				$zhsparecopy=$msql->f('sparecopy');
			}
			
			//所选组合套餐费用小计
			$subtotalprice_zh+=$zhperprice*$zhtclist_arr[$i];
			
			//商品摘要
			//$goodsmemo_zh.=$zhtitle."&nbsp;".$zhtclist_arr[$i].",&nbsp;&nbsp;";
			$goodsmemo_zh.=$zhtitle."(".$zhtclist_arr[$i]."),";
		}
	
		//判断有无选择餐品
		if($nums_zxc+$nums_gdc+$nums_zhc=="" || $nums_zxc+$nums_gdc+$nums_zhc==0){
			echo $strOrderNotice17;
			exit;
		}
		
		//汇总两种餐品的提示信息
		if($zxstr!="" || $gdstr!=""){
			echo "<div style='text-align:left;'>".$strOrderNotice1."<br />".$zxnotice."<br />".$gdnotice."</div>";
			exit;
		}
		
		//处理订单号
		/*$msql->query("select max(OrderNo) from {P}_dingcan_order where orderid!='0'");
		if($msql->next_record()){
			$maxOrderNo=$msql->f('max(OrderNo)');
		}
		
		if($maxOrderNo=="" || $maxOrderNo=="0"){
			$newOrderNo="10001";
		}else{
			$newOrderNo=$maxOrderNo+1;
		}*/
		
		//计算商品总金额
		$totalgoodsprice=$subtotalprice_zx+$subtotalprice_gd+$subtotalprice_zh;
		$totalgoodsprice=number_format($totalgoodsprice,2,'.','');
		
		//计算订单总金额
		$totalorderprice=$totalgoodsprice+$pscost;
		$totalorderprice=number_format($totalorderprice,2,'.','');
		
		//汇总商品摘要
		$goodsmemo=$goodsmemo_zx.$goodsmemo_gd.$goodsmemo_zh;
		//$goodsmemo=substr($goodsmemo,0,-13);
		$goodsmemo=substr($goodsmemo,0,-1);
		
		//获取订单受理人姓名
		$slname=$_COOKIE['SYSNAME'];
		
		$dtime=time();
		$ip=$_SERVER["REMOTE_ADDR"];
				
		//标签过滤
		$title=str_replace("{#","",$title);
		$title=str_replace("#}","",$title);
		
		//入库-生成订单
		$msql->query("insert into {P}_dingcan_order set
			ordertype='$ordertype',
			goodstotal='$totalgoodsprice',
			pscost='$pscost',
			totalcost='$totalorderprice',
			totalcent='0',
			payid='$payid',
			paytype='$paytype',
			goodsmemo='$goodsmemo',
			memberid='0',
			cname='$cname',
			zoneid='$zoneid',
			address='$address',
			phone='$phone',
			sctime='$sctime',
			pscenter='$pscenter',
			ordertime='$dtime',
			slname='$slname',
			ddname='',
			psname='',
			dtime='$dtime',
			ifcheck='1',
			ip='$ip'
		");
		
		$orderid=$msql->instid();
		$OrderNo=$orderid+10000;
		$msql->query("update {P}_dingcan_order set OrderNo='$OrderNo' where orderid='$orderid'");
	
		//入库-记录商品条目-自选餐品
		for($i=0;$i<$nums_zx;$i++){
			$zxc_name="zxc_".$zx[$i];
			$zxc=$_POST[$zxc_name];
			
			$msql->query("select * from {P}_dingcan_zxcon where id='$zx[$i]'");
			if($msql->next_record()){
				$zxtitle=$msql->f('title');
				$zxperprice=$msql->f('perprice');
			}
			
			//小计餐品总价
			$subtotal_zx=$zxperprice*$zxc;
			$subtotal_zx=number_format($subtotal_zx,2,'.','');
			
			//入库
			$msql->query("insert into {P}_dingcan_orderitems set
				memberid='0',
				orderid='$orderid',
				gid='$zx[$i]',
				goodstype='diy',
				goods='$zxtitle',
				memo='',
				price='$zxperprice',
				nums='$zxc',
				subtotal='$subtotal_zx',
				cent='0',
				subtotalcent='0',
				ordertime='$dtime',
				dtime='$dtime',
				ordertype='$ordertype'
			");
		}
		
		//入库-记录商品条目-固定套餐
		for($i=0;$i<$nums_gd;$i++){
			$gdc_name="gdc_".$gd[$i];
			$gdc=$_POST[$gdc_name];
			
			$msql->query("select * from {P}_dingcan_gdcon where id='$gd[$i]'");
			if($msql->next_record()){
				$gdtitle=$msql->f('title');
				$gdperprice=$msql->f('perprice');
			}
			
			//小计餐品总价
			$subtotal_gd=$gdperprice*$gdc;
			$subtotal_gd=number_format($subtotal_gd,2,'.','');
			
			//入库
			$msql->query("insert into {P}_dingcan_orderitems set
				memberid='0',
				orderid='$orderid',
				gid='$gd[$i]',
				goodstype='tc',
				goods='$gdtitle',
				memo='',
				price='$gdperprice',
				nums='$gdc',
				subtotal='$subtotal_gd',
				cent='0',
				subtotalcent='0',
				ordertime='$dtime',
				dtime='$dtime',
				ordertype='$ordertype'
			");
		}
		
		//入库-记录商品条目-组合套餐
		for($i=0;$i<$zhtclist_nums;$i++){
			
			$zhc=$zhtclist_arr[$i];  //所选套餐数量
			$zhid=$zhtcid_arr[$i];  //所选套餐ID
		
			//读取套餐信息
			$msql->query("select * from {P}_dingcan_zhcon where id='$zhid'");
			if($msql->next_record()){
				$zhtitle=$msql->f('title');
				$zhperprice=$msql->f('perprice');
			}
			
			//小计餐品总价
			$subtotal_zh=$zhperprice*$zhc;
			$subtotal_zh=number_format($subtotal_zh,2,'.','');
			
			//获取所选套餐下餐品的信息
			$zhcp_name="zhcp_".$zhid;
			$zhcpid_arr=$_POST[$zhcp_name];
			$zhcpid_nums=count($zhcpid_arr);
			
			for($k=0;$k<$zhcpid_nums;$k++){
				$zhcpid_str=$zhcpid_arr[$k];
				$zhcpid_str_arr=explode("_",$zhcpid_str);
				
				$zhcpfs_name="zhcpfs_".$zhcpid_str_arr[1]."_".$zhcpid_str_arr[0]."_".$zhid;
				$zhcpid2.=$zhcpid_str_arr[0].":".$_POST[$zhcpfs_name].",";
				
			}
			
			$zhcpid2=substr($zhcpid2,0,-1);
		
			//入库
			$msql->query("insert into {P}_dingcan_orderitems set
				memberid='0',
				orderid='$orderid',
				gid='$zhid',
				goodstype='zh',
				goods='$zhtitle',
				memo='$zhcpid2',
				price='$zhperprice',
				nums='$zhc',
				subtotal='$subtotal_zh',
				cent='0',
				subtotalcent='0',
				ordertime='$dtime',
				dtime='$dtime',
				ordertype='$ordertype'
			");
			
			$zhcpid2="";
		}

		echo "OK-".$OrderNo;
		exit;

	break;
	
	
	//电话订餐录入-选择商品-增加组合套餐
	case "addzhtclist":
		
		$zhid=$_REQUEST["zhid"];
		$zhtcdivnums=$_REQUEST["zhtcdivnums"];

		if($zhid==""){
			echo $strOrderNotice18;
			exit;
		}
		
		//取出所选组合套餐的信息
		$msql->query("select * from {P}_dingcan_zhcon where id='$zhid'");
		if($msql->next_record()){
			$zhtitle=$msql->f('title');
			$zhzucheng=$msql->f('zucheng');
			$zhperprice=$msql->f('perprice');
			
			$zhzucheng_arr=explode(",", $zhzucheng);
			$zhzucheng_nums=count($zhzucheng_arr);
				
			$zhinfo="(";
			for($i=0;$i<$zhzucheng_nums; $i++){
				$zhzucheng_arr2=explode(":", $zhzucheng_arr[$i]);
				
				$fsql->query("select * from {P}_dingcan_zhcat where catid='$zhzucheng_arr2[0]'");
				if($fsql->next_record()){
					$cat=$fsql->f('cat');
				}
					
				$zhinfo.=$cat.":".$zhzucheng_arr2[1]."&nbsp;&nbsp;&nbsp;&nbsp;";
			}
			$zhinfo=substr($zhinfo,0,-24);
			$zhinfo.=")";
		}
		
		//统计所选的餐品类别
		$zhzucheng_arr=explode(",", $zhzucheng);
		$zhzucheng_nums=count($zhzucheng_arr);
		
		for($i=0; $i<$zhzucheng_nums; $i++){
			$zhzucheng_arr2=explode(":", $zhzucheng_arr[$i]);
			if($zhzucheng_arr2[1]!="" && $zhzucheng_arr2[1]!=0){
				$zhcpcat_str.=$zhzucheng_arr2[0].",";
			}
		}
		$zhcpcat_str=substr($zhcpcat_str,0,-1);

		//模板解释
		$Temp=LoadEsetTemp(ROOTPATH,"order_luru_zhtclist.php");
		$TempArr=SplitTblTemp($Temp);
		
		$var=array (
			'zhid' => $zhid,
			'zhtcdivnums' => $zhtcdivnums,
			'zhtitle' => $zhtitle,
			'zhinfo' => $zhinfo,
			'zhperprice' => $zhperprice,
			'strCopy' => $strCopy,
			'strYuanPerFen' => $strYuanPerFen,
			'strDelete' => $strDelete
		);
		
		$str=ShowTplTemp($TempArr["start"],$var);
		
		$msql->query("select * from {P}_dingcan_zhcat where catid in ($zhcpcat_str) order by xuhao");
		while($msql->next_record()){
			$zhcatid=$msql->f('catid');
			$zhcat=$msql->f('cat');
			
			$fsql->query("select * from {P}_dingcan_zhcpcon where catid='$zhcatid' order by xuhao");
			while($fsql->next_record()){
				$zhcpid=$fsql->f('id');
				$zhcptitle=$fsql->f('title');
					
				$zhcplist.="<div style='white-space:nowrap;width:150px;float:left'><input type='checkbox' name='zhcp_".$zhid."[]' id='zhcp_".$zhcatid."_".$zhcpid."_".$zhid."' value='".$zhcpid."_".$zhcatid."' class='zhcpcheckbox' />&nbsp;".$zhcptitle."&nbsp;<input type='text' name='zhcpfs_".$zhcatid."_".$zhcpid."_".$zhid."' id='zhcpfs_".$zhcatid."_".$zhcpid."_".$zhid."' value='' class='input' style='width:15px;height:15px;padding:0px;font:12px/14px arial' />&nbsp;&nbsp;</div>";
			}
		
			$var=array (
				'zhcat' => $zhcat,
				'zhcplist' => $zhcplist
			);
			
			$str.=ShowTplTemp($TempArr["list"],$var);
			
			$zhcplist="";
			$zhcatid_info="";
		}
		
		$str.=$TempArr["end"];

		echo "OK-".$str;
		exit;

	break;

}
?>