query("update {$dbtbpre}enewsshopdd set checked='$checked' where ".$add);
$mess="SetCheckedSuccess";
$log="doing=$doing&do=SetChecked&checked=$checked
ddid=$ids";
//订单日志
$log_ecms='SetChecked';
$log_bz='';
if($checked==1)
{
$log_addbz='确认';
}
elseif($checked==2)
{
$log_addbz='取消';
}
elseif($checked==3)
{
$log_addbz='退货';
}
elseif($checked==0)
{
$log_addbz='未确认';
}
//写入订单日志
if($ids)
{
$logsql=$empire->query("select ddid,havecutnum from {$dbtbpre}enewsshopdd where ".$add);
while($logr=$empire->fetch($logsql))
{
ShopSys_DdInsertLog($logr['ddid'],$log_ecms,$log_bz,$log_addbz);//订单日志
//库存
if($shoppr['cutnumtype']==0&&$checked==2&&$logr['havecutnum'])
{
$ddaddr=$empire->fetch1("select buycar from {$dbtbpre}enewsshopdd_add where ddid='$logr[ddid]'");
Shopsys_hCutMaxnum($logr['ddid'],$ddaddr['buycar'],$logr['havecutnum'],$shoppr,1);
}
}
}
}
elseif($doing==2) //发货状态
{
$sql=$empire->query("update {$dbtbpre}enewsshopdd set outproduct='$outproduct' where ".$add);
$mess="SetOutProductSuccess";
$log="doing=$doing&do=SetOutProduct&outproduct=$outproduct
ddid=$ids";
//订单日志
$log_ecms='SetOutProduct';
$log_bz='';
if($outproduct==1)
{
$log_addbz='已发货';
}
elseif($outproduct==2)
{
$log_addbz='备货中';
}
elseif($outproduct==0)
{
$log_addbz='未发货';
}
//写入订单日志
if($ids)
{
$logsql=$empire->query("select ddid from {$dbtbpre}enewsshopdd where ".$add);
while($logr=$empire->fetch($logsql))
{
ShopSys_DdInsertLog($logr['ddid'],$log_ecms,$log_bz,$log_addbz);//订单日志
}
}
}
elseif($doing==3) //付款状态
{
$sql=$empire->query("update {$dbtbpre}enewsshopdd set haveprice='$haveprice' where ".$add);
$mess="SetHavepriceSuccess";
$log="doing=$doing&do=SetHaveprice&haveprice=$haveprice
ddid=$ids";
//订单日志
$log_ecms='SetHaveprice';
$log_bz='';
if($haveprice==1)
{
$log_addbz='已付款';
}
elseif($haveprice==0)
{
$log_addbz='未付款';
}
//写入订单日志
if($ids)
{
$logsql=$empire->query("select ddid,havecutnum from {$dbtbpre}enewsshopdd where ".$add);
while($logr=$empire->fetch($logsql))
{
ShopSys_DdInsertLog($logr['ddid'],$log_ecms,$log_bz,$log_addbz);//订单日志
//库存
if($shoppr['cutnumtype']==1&&$haveprice==1&&!$logr['havecutnum'])
{
$ddaddr=$empire->fetch1("select buycar from {$dbtbpre}enewsshopdd_add where ddid='$logr[ddid]'");
Shopsys_hCutMaxnum($logr['ddid'],$ddaddr['buycar'],$logr['havecutnum'],$shoppr,0);
}
}
}
}
elseif($doing==4) //删除订单
{
$log_ecms='DelDd';
$log_bz='';
$log_addbz='';
//库存
if($ids)
{
$logsql=$empire->query("select ddid,havecutnum,checked,haveprice from {$dbtbpre}enewsshopdd where ".$add." and havecutnum=1");
while($logr=$empire->fetch($logsql))
{
if($logr['haveprice']==1)
{
continue;
}
if($logr['havecutnum'])
{
$ddaddr=$empire->fetch1("select buycar from {$dbtbpre}enewsshopdd_add where ddid='$logr[ddid]'");
Shopsys_hCutMaxnum($logr['ddid'],$ddaddr['buycar'],$logr['havecutnum'],$shoppr,1);
}
}
}
$sql=$empire->query("delete from {$dbtbpre}enewsshopdd where ".$add);
$sql2=$empire->query("delete from {$dbtbpre}enewsshopdd_add where ".$add);
$sql3=$empire->query("delete from {$dbtbpre}enewsshop_ddlog where ".$add);
$mess="DelDdSuccess";
$log="doing=$doing&do=DelDd
ddid=$ids";
}
else
{
printerror("ErrorUrl","history.go(-1)");
}
if($sql)
{
//操作日志
insert_dolog($log);
printerror($mess,EcmsGetReturnUrl());
}
else
{printerror("DbError","history.go(-1)");}
}
$enews=$_POST['enews'];
if(empty($enews))
{$enews=$_GET['enews'];}
if($enews)
{
hCheckEcmsRHash();
}
if($enews=="SetShopDd")
{
SetShopDd($_POST,$logininid,$loginin);
}
else
{}
//更新库存
$shoppr=ShopSys_hReturnSet();
ShopSys_hTimeCutMaxnum(0,$shoppr);
$search=$ecms_hashur['ehref'];
$page=(int)$_GET['page'];
$page=RepPIntvar($page);
$start=0;
$line=25;//每页显示条数
$page_line=18;//每页显示链接数
$offset=$page*$line;//总偏移量
$totalquery="select count(*) as total from {$dbtbpre}enewsshopdd";
$query="select ddid,ddno,ddtime,userid,username,outproduct,haveprice,checked,truename,psid,psname,pstotal,alltotal,payfsid,payfsname,payby,alltotalfen,fp,fptotal,pretotal from {$dbtbpre}enewsshopdd";
$add='';
$and=' where ';
//搜索
$sear=RepPostStr($_GET['sear'],1);
if($sear)
{
$keyboard=$_GET['keyboard'];
$keyboard=RepPostVar2($keyboard);
if($keyboard)
{
$show=(int)$_GET['show'];
if($show==1)//搜索订单号
{
$add=$and."ddno like '%$keyboard%'";
}
elseif($show==2)//用户名
{
$add=$and."username like '%$keyboard%'";
}
elseif($show==3)//姓名
{
$add=$and."truename like '%$keyboard%'";
}
elseif($show==4)//邮箱
{
$add=$and."email like '%$keyboard%'";
}
else//地址
{
$add=$and."address like '%$keyboard%'";
}
$and=' and ';
}
//订单状态
$checked=(int)$_GET['checked'];
if($checked==1)//已确认
{
$add.=$and."checked=1";
$and=' and ';
}
elseif($checked==9)//未确认
{
$add.=$and."checked=0";
$and=' and ';
}
elseif($checked==2)//取消
{
$add.=$and."checked=2";
$and=' and ';
}
elseif($checked==3)//退货
{
$add.=$and."checked=3";
$and=' and ';
}
//是否付款
$haveprice=(int)$_GET['haveprice'];
if($haveprice==1)//已付款
{
$add.=$and."haveprice=1";
$and=' and ';
}
elseif($haveprice==9)//未付款
{
$add.=$and."haveprice=0";
$and=' and ';
}
//是否发货
$outproduct=(int)$_GET['outproduct'];
if($outproduct==1)//已发货
{
$add.=$and."outproduct=1";
$and=' and ';
}
elseif($outproduct==9)//未发货
{
$add.=$and."outproduct=0";
$and=' and ';
}
elseif($outproduct==2)//备货中
{
$add.=$and."outproduct=2";
$and=' and ';
}
//时间
$starttime=RepPostVar($_GET['starttime']);
$endtime=RepPostVar($_GET['endtime']);
if($endtime!="")
{
$ostarttime=$starttime." 00:00:00";
$oendtime=$endtime." 23:59:59";
$add.=$and."ddtime>='$ostarttime' and ddtime<='$oendtime'";
$and=' and ';
}
$search.="&sear=1&keyboard=$keyboard&show=$show&checked=$checked&outproduct=$outproduct&haveprice=$haveprice&starttime=$starttime&endtime=$endtime";
}
//排序
$myorder=(int)$_GET['myorder'];
if($myorder==2)//商品金额
{
$orderby='alltotal desc';
}
elseif($myorder==3)
{
$orderby='alltotal asc';
}
elseif($myorder==4)//商品点数
{
$orderby='alltotalfen desc';
}
elseif($myorder==5)
{
$orderby='alltotalfen asc';
}
elseif($myorder==6)//优惠金额
{
$orderby='pretotal desc';
}
elseif($myorder==7)
{
$orderby='pretotal asc';
}
elseif($myorder==1)//订单时间
{
$orderby='ddid asc';
}
else
{
$orderby='ddid desc';
}
$totalquery.=$add;
$query.=$add;
$num=$empire->gettotal($totalquery);//取得总条数
$query=$query." order by ".$orderby." limit $offset,$line";
$sql=$empire->query($query);
$returnpage=page2($num,$line,$page_line,$start,$page,$search);
?>
位置:管理订单 |