示例#1
0
 public function view_neutralExport()
 {
     $start = isset($_GET['start']) ? post_check($_GET['start']) : '';
     $end = isset($_GET['end']) ? post_check($_GET['end']) : '';
     $type = isset($_GET['type']) ? post_check($_GET['type']) : '';
     $start = strtotime($start);
     $end = strtotime($end);
     //$start	= 1356972800;
     //$end	= 1399972800;
     $where = " where is_delete = 0";
     if ($start != '') {
         $where .= " and feedbacktime >= '{$start}' ";
     }
     if ($end != '') {
         $where .= " and feedbacktime <= '{$end}' ";
     }
     if ($type == 'neutral') {
         $where .= " and (CommentType='Neutral' or status='21' or status='23')";
     } else {
         if ($type == 'negative') {
             $where .= " and (CommentType='Negative' or status='31' or status='32')";
         }
     }
     $condition = $where;
     $FBAct = new EbayFeedbackAct();
     $where .= " order by account,id ";
     $field = " distinct(sku) ";
     $fbkList = $FBAct->act_getOrderList($field, $where);
     $menuList = $FBAct->act_getEbayReasonCategoryInfo('*', 'order by id');
     $titlelist = array();
     $reasonlist = array();
     foreach ($menuList as $gtitle) {
         $titlelist[] = $gtitle['content'];
     }
     $reasonlist = $titlelist;
     $countReason = count($reasonlist);
     array_unshift($titlelist, '料号', '单价', '采购员');
     $fileName = ucfirst($type);
     $exporter = new ExportDataExcel("browser", $fileName . '_' . date('Y-m-d') . ".xls");
     $exporter->initialize();
     $exporter->addRow($titlelist);
     $comAct = new CommonAct();
     foreach ($fbkList as $v) {
         $sku = $v['sku'];
         if (!empty($sku)) {
             $countlist = array();
             for ($kk = 0; $kk < $countReason; $kk++) {
                 $reasonId = $reasonlist[$kk]['id'];
                 $condition .= " and reasonId = '{$reasonId}' and sku = '{$sku}'";
                 $count = $FBAct->act_getOrderList('count(*)', $condition);
                 $countlist[] = $count[0]['count(*)'];
             }
             $goodsInfo = $comAct->act_getGoodsInfo('goodsCost,purchaseId', " where sku = '{$sku}'");
             $price = $goodsInfo[0]['goodsCost'];
             $purchaseId = $goodsInfo[0]['purchaseId'];
             $purchaserInfo = $comAct->act_getPurchaserInfo('global_user_name', " where global_user_id = '{$purchaseId}'");
             $purchaser = $purchaserInfo[0]['global_user_name'];
             array_unshift($countlist, $sku, $price, $purchaser);
             $exporter->addRow($countlist);
         }
     }
     $exporter->finalize();
     exit;
 }