在导单的新增一个商家备注

2016-07-07 15:17 来源:www.chinab4c.com 作者:ecshop专家

我用这个来导单的,想在导出的excel里有个商家备注
<?php
define('IN_ECS', true);
include ('includes/init.php');
$filename='orderexcel';
header("Content-type: application/vnd.ms-excel; charset=gbk");
header("Content-Disposition: attachment; filename=$filename.xls");

$data='订单号'."\t";
$data.='购货人'."\t";
$data.='支付方式'."\t";
$data.='配送方式'."\t";
$data.='收货人'."\t";
$data.='收货地址'."\t";
$data.='电话'."\t";
$data.='下单时间'."\t";
$data.='商品名称'."\t\n";

$sql="select o.order_sn,o.c**ignee,o.address,o.tel,o.add_time,o.shipping_name,o.pay_name,g.goods_name,g.goods_attr,g.goods_number,u.user_name from". $GLOBALS['ecs']->table('order_info').
" as o left join " . $GLOBALS['ecs']->table('users')." as u on o.user_id=u.user_id "."left join". $GLOBALS['ecs']->table('order_goods')." as g on o.order_id=g.order_id ";
$res=$db->getAll($sql);
//print_r($res);
//echo $sql;
while (!empty($res))
{
foreach ($res as $key=>$var)
{
$res1[$key]['add_time']='';
$res1[$key]['goods']='';
$res1[$key]['address']='';
$res1[$key]['c**ignee']='';
$res1[$key]['pay_name']='';
$res1[$key]['user_name']='';
$res1[$key]['order_sn']='';
$res1[$key]['tel']='';
$res1[$key]['shipping_name']='';
$a=$var['order_sn'];
foreach ($res as $keys=>$vars)
{

if($a==$vars['order_sn'])
{
$res1[$key]['order_sn']=$vars['order_sn'];
$res1[$key]['user_name']=$vars['user_name'];
$res1[$key]['pay_name']=$vars['pay_name'];
$res1[$key]['shipping_name']=$vars['shipping_name'];
$res1[$key]['c**ignee']=$vars['c**ignee'];
$res1[$key]['address']=$vars['address'];
$vars['goods_attr']= trim($vars['goods_attr']);
$res1[$key]['goods'].="$vars[goods_name] $vars[goods_attr] $vars[goods_number]"."\n";
$res1[$key]['tel'] .= $vars['tel'];
$res1[$key]['add_time']=date('y-m-d h:i:s',$vars['add_time']);
unset ($res[$keys]);
}
}
}
}
foreach ($res1 as $key =>$var)
{
$data.=$var['order_sn']."\t";
$data.=$var['user_name']."\t";
$data.=$var['pay_name']."\t";
$data.=$var['shipping_name']."\t";
$data.=$var['c**ignee']."\t";
$data.=$var['address']."\t";
$data.=$var['tel']."\t";
$data.=$var['add_time']."\t";
$data.="\"";
$data.=$var['goods']."\"";
$data.="\t\n";
}

if (EC_CHARSET != 'gbk')
{
echo ecs_iconv(EC_CHARSET, 'gbk', $data) . "\t";
}
else
{
echo $data. "\t";
}
//print_r($res1);


?>

回答:
你直接取得postscript就可以了