Exemplo n.º 1
0
 function do_export($io = 'csv')
 {
     $this->system->__session_close(0);
     if ($io == 'taobaoordercsv' || $io == 'taobaogoodscsv') {
         include_once 'shopObject.php';
         $step = 20;
         $offset = 0;
         $dataio = $this->system->loadModel('system/dataio');
         $taobaoordercsv = $this->system->loadModel('trading/taobaoordercsv');
         $cols = $dataio->columns($io);
         $list = $this->model->getList($cols, $_POST, $offset, $step, array('order_id', 'ASC'));
     } else {
         parent::do_export($io);
         exit;
     }
     $count = $this->model->count($_POST);
     if ($io == 'taobaoordercsv') {
         //淘宝CSV格式 by yangbing 2009-11-4
         while ($count > $offset) {
             if ($offset == 0) {
                 $keys = $taobaoordercsv->orderExportTitle();
                 $dataio->export_begin($io, $keys, 'ExportOrderList', $count);
             }
             foreach ($list as $v) {
                 $data = $taobaoordercsv->getOrdersExportData($v);
                 $dataio->export_rows($io, $data);
             }
             $offset += $step;
             $list = $this->model->getList($cols, $_POST, $offset, $step, array('order_id', 'ASC'));
         }
     } elseif ($io == 'taobaogoodscsv') {
         while ($count > $offset) {
             if ($offset == 0) {
                 $keys = $taobaoordercsv->goodsExportTitle();
                 $dataio->export_begin($io, $keys, 'ExportOrderDetailList', $count);
             }
             $setMemo = true;
             foreach ($list as $v) {
                 $rows = $this->model->db->select('SELECT name, price, nums, addon FROM sdb_order_items WHERE order_id=' . $v['order_id']);
                 $order = $this->model->db->selectRow('SELECT memo FROM sdb_orders WHERE order_id=' . $v['order_id']);
                 $export['order_id'] = $v['order_id'];
                 foreach ($rows as $delivery) {
                     $export['name'] = $delivery['name'];
                     $export['price'] = $delivery['price'];
                     $export['nums'] = $delivery['nums'];
                     $export['sysid'] = '';
                     $addon = unserialize($delivery['addon']);
                     $export['pdt_desc'] = $addon['spec'][1];
                     $export['pdt_desc'] .= $addon['spec'][2] ? '、' . $addon['spec'][2] : '';
                     $export['tinfo'] = '';
                     $export['memo'] = $setMemo ? $order['memo'] : '';
                     $setMemo = false;
                     $data[] = $export;
                 }
                 $dataio->export_rows($io, $data);
                 unset($data);
             }
             $offset += $step;
             $list = $this->model->getList($cols, $_POST, $offset, $step, array('order_id', 'ASC'));
         }
     } else {
     }
     $dataio->export_finish($io);
 }
Exemplo n.º 2
0
 function do_export($io = 'csv')
 {
     $this->system->__session_close(0);
     //review: 这种方式是否还可以再。。。
     include_once 'shopObject.php';
     if ($io != 'csv') {
         parent::do_export($io);
         exit;
     }
     $step = 20;
     $offset = 0;
     $dataio =& $this->system->loadModel('system/dataio');
     $p =& $this->system->loadModel('goods/products');
     $gtype =& $this->system->loadModel('goods/gtype');
     $cols = 'goods_id,type_id,cat_id,marketable,pdt_desc,name,bn,brand,cost,brief,intro,mktprice,price,weight,unit,store,store_place,params,spec,spec_desc,image_file';
     //todo ...当前列
     $cols_attr = 'p_1';
     for ($i = 2; $i < 29; $i++) {
         $cols_attr .= ',p_' . $i;
     }
     $last_type_id = -1;
     $list = $this->model->getList($cols . ',' . $cols_attr, $_POST, $offset, $step, array('type_id', 'asc'));
     $count = $this->model->count($_POST);
     while ($count > $offset) {
         if ($offset == 0) {
             $dataio->export_begin($io, null, 'goods', $count);
         } else {
             $list = $this->model->getList($cols . ',' . $cols_attr, $_POST, $offset, $step, array('type_id', 'asc'));
         }
         foreach ($list as $v) {
             if (trim($v['bn']) == '') {
                 continue;
             }
             if ($last_type_id != $v['type_id']) {
                 $aGtype = $gtype->instance($v['type_id']);
                 $keys = $p->getTypeExportTitle($aGtype);
                 $a = array($keys);
                 $dataio->export_rows($io, $a);
                 unset($proto);
                 foreach ($keys as $k1 => $v1) {
                     $proto[$k1] = '';
                 }
             }
             $data = $p->getGoodsExportData($v, $proto, $aGtype['name'], unserialize($aGtype['props']), $aGtype['params']);
             $dataio->export_rows($io, $data);
             $last_type_id = $v['type_id'];
         }
         $offset += $step;
     }
     $dataio->export_finish($io);
 }