Exemplo n.º 1
0
 public function view_exportsToXls1()
 {
     error_reporting(E_ALL);
     /*$searchPlatformId			=	isset($_GET['platformId']) ? $_GET['platformId'] : '';				//搜索平台
     		$searchAccountId			=	isset($_GET['accountId']) ? $_GET['accountId'] : '';				//搜索账号
     		$searchIsNote				=	isset($_GET['isNote']) ? $_GET['isNote'] : '';						//是否有留言
     		$searchTransportationType	=	isset($_GET['transportationType']) ? $_GET['transportationType'] : '';//运输类型
     		$searchTransportation		=	isset($_GET['transportation']) ? $_GET['transportation'] : '';		//运输方式
     		$searchIsBuji				=	isset($_GET['isBuji']) ? $_GET['isBuji'] : '';						//是否补寄订单
     		$searchIsLock				=	isset($_GET['isLock']) ? $_GET['isLock'] : '';						//是否锁定
     		$searchOrderTime1			=	isset($_GET['OrderTime1']) ? $_GET['OrderTime1'] : '';				//搜索下单初始时间
     		$searchOrderTime2			=	isset($_GET['OrderTime2']) ? $_GET['OrderTime2'] : '';				//搜索下单结束时间
     		//order_detail表
     		$searchReviews				=	isset($_GET['reviews']) ? $_GET['reviews'] : '';					//是否评价
     		$searchSku					=	isset($_GET['sku']) ? $_GET['sku'] : '';							//sku
     		$searchOmOrderId			=	'';																	//订单编号
     		$searchOrderType			=	isset($_GET['selectOrderType']) ? $_GET['selectOrderType'] : '';*/
     //foreach($_GET as $k=>$v){
     //			//if(isset($_))
     //		}
     $type = isset($_GET['type']) ? trim($_GET['type']) : "";
     $order = isset($_GET['order']) ? trim($_GET['order']) : "";
     $where = " WHERE ";
     $where_arr = array();
     $accountList = $_SESSION['accountList'];
     $platformList = $_SESSION['platformList'];
     //echo "<pre>"; print_r($accountList); exit;
     $platformsee = array();
     for ($i = 0; $i < count($platformList); $i++) {
         $platformsee[] = $platformList[$i];
     }
     if ($platformsee) {
         $where_arr[] = ' da.platformId IN ( ' . join(',', $platformsee) . ' ) ';
     }
     $accountsee = array();
     for ($i = 0; $i < count($accountList); $i++) {
         $accountsee[] = $accountList[$i];
     }
     if ($accountsee) {
         $where_arr[] = ' da.accountId IN ( ' . join(",", $accountsee) . ' ) ';
     }
     if ($type == 1) {
         $arr = explode(",", $order);
         $ostatus = $arr[0];
         $otype = $arr[1];
         $where_arr[] = " da.is_delete=0 ";
         if ($ostatus) {
             $where_arr[] = " da.orderStatus='{$ostatus}' ";
         }
         if ($otype) {
             $where_arr[] = " da.orderType='{$otype}' ";
         }
         //$where = "where da.orderStatus='{$ostatus}' and da.orderType='{$otype}' and da.is_delete=0";
     } elseif ($type == 2) {
         $where_arr[] = " da.id in({$order}) ";
     }
     $where .= join(' AND ', $where_arr);
     //echo $where; exit;
     $orderarr = OrderindexModel::showSearchOrderList("om_unshipped_order", $where);
     //echo count($orderarr); exit;
     $exporter = new ExportDataExcel("browser", "xls1" . $date . ".xls");
     //echo "<pre>"; print_r($orderarr[98]);exit;
     $exporter->initialize();
     // starts streaming data to web browser
     $exporter->addRow(array("日期", "账号", "订单编号", "重量", "邮费", "运输方式", "交易号", "客户ID", "仓位号", "料号", "数量", "国家", "包裹总价值", "币种", "包装员", "挂号条码", "是/否"));
     foreach ($orderarr as $key => $value) {
         $paymentTime = date("Y-m-d", $value['orderData']['paymentTime']);
         $accountArr = OmAccountModel::accountInfo($value['orderData']['accountId']);
         $account = $accountArr['account'];
         //$account 			= $account['account'];
         $orderid = $key;
         $weight = $value['orderWarehouse']['actualWeight'];
         $shipfee = $value['orderWarehouse']['actualShipping'];
         $packagerId = $value['orderWarehouse']['packagerId'];
         $packager = UserModel::getUsernameById($packagerId);
         $transportation = CommonModel::getCarrierList();
         //所有的
         $transportationList = array();
         foreach ($transportation as $tranValue) {
             if ($tranValue['id'] == $value['orderData']['transportId']) {
                 $transport = $tranValue['carrierNameCn'];
                 break;
             }
             //$transportationList[$tranValue['id']] = $tranValue['carrierNameCn'];
         }
         //$plateform 			= exportsToXlsModel::plateformIdToName($value['orderData']['platformId']);
         $plateformArr = OmAccountModel::platformListById($value['orderData']['platformId']);
         $plateform = $plateformArr[$value['orderData']['platformId']];
         //$plateform			= $plateform['platform'];
         $transId = $value['orderExtenData']['transId'];
         $currency = $value['orderExtenData']['currency'];
         $userId = $value['orderUserInfoData']['platformUsername'];
         $countryName = $value['orderUserInfoData']['countryName'];
         $actualTotal = $value['orderData']['actualTotal'];
         $recordNumber = $value['orderData']['recordNumber'];
         $trackNumber = $value['orderTracknumber'][0]['tracknumber'];
         $orderDetails = $value['orderDetail'];
         if (count($orderDetails) == 1) {
             foreach ($value['orderDetail'] as $key => $detail) {
                 $skuId = $key;
             }
             $exporter->addRow(array($paymentTime, $account, $orderid, $weight, $shipfee, $transport, $recordNumber, $userId, "", $orderDetails[$skuId]['orderDetailData']['sku'], $orderDetails[$skuId]['orderDetailData']['amount'], $countryName, $actualTotal, $currency, $packager, $trackNumber, ""));
         } else {
             $exporter->addRow(array($paymentTime, $account, $orderid, $weight, $shipfee, $transport, $recordNumber, $userId, "", "", "", $countryName, $actualTotal, $currency, $packager, $trackNumber, ""));
             foreach ($orderDetails as $detail) {
                 $exporter->addRow(array($paymentTime, $account, $orderid, "", "", $transport, "", "", "", $detail['orderDetailData']['sku'], $detail['orderDetailData']['amount'], $countryName, "", "", "", "", ""));
             }
         }
     }
     $exporter->finalize();
     // writes the footer, flushes remaining data to browser.
     exit;
 }
Exemplo n.º 2
0
    public static function showOrderAPI($purchaseId, $storeId = 1)
    {
        // 提供超大订单数据
        !self::$dbConn ? self::initDB() : null;
        //echo time(); echo "<br>";
        //!self::$dbConn ? self::initDB() : null;
        //取出两个where 下的所有订单
        /*if(!empty($whereDetail)){
        			$orderIdStr =implode(",",self::api_getOrdIdByDetWhe($whereDetail));
        		}
        		if(!empty($whereOrder)){
        			$whereOrder  = "AND ".$whereOrder;
        		}*/
        /*if(!empty($orderIdStr)){
        			$whereOrder .= " AND  id in ({$orderIdStr})";
        		}*/
        $showOrder = array();
        $ordersql = 'SELECT         a.id as orderid, a.accountId, b.sku, b.amount
						FROM 			om_unshipped_order AS a 
						LEFT JOIN       om_unshipped_order_detail AS b 
						ON 			    b.omOrderId = a.id 
						WHERE			a.orderStatus = ' . C('STATEOVERSIZEDORDERS') . ' 
						AND				a.orderType   != ' . C('STATEOVERSIZEDORDERS_CONFIRM') . ' 
						AND 			a.is_delete=0 
						AND				b.is_delete=0 
						AND 			a.storeId= ' . $storeId;
        //echo $ordersql; echo "<br>"; exit;
        $query = self::$dbConn->query($ordersql);
        $orders = self::$dbConn->fetch_array_all($query);
        //echo count($orders); exit;
        //echo time(); echo "<br>"; exit;
        foreach ($orders as $ordervalue) {
            $orderid = $ordervalue['orderid'];
            $sku = $ordervalue['sku'];
            //$amount = $ordervalue['amount'];
            //echo $sku; echo "<br>";
            $skus = GoodsModel::get_realskuinfo($sku);
            //var_dump($skus); echo "<br>"; exit;
            foreach ($skus as $_sku => $_num) {
                $_skuinfo = GoodsModel::getSkuinfoByPurchaseId($_sku, $purchaseId);
                //var_dump($_skuinfo); echo "<br>"; exit;
                if ($_skuinfo) {
                    $auditRecord = CommonModel::getRecordsOrderAudit($orderid, $_sku);
                    $accountInfo = OmAccountModel::accountInfo($accountId);
                    //var_dump($accountInfo); echo "<br>"; exit;
                    //echo $_sku; echo "<br>";
                    $nosaleand = CommonModel::getpartsaleandnosendall($_sku);
                    //var_dump($nosaleand); echo "<br>"; exit;
                    $ordervalue['accountId'] = $accountInfo['account'];
                    $ordervalue['sku'] = $_skuinfo;
                    $ordervalue['auditRecord'] = $auditRecord;
                    $ordervalue['nosaleand'] = $nosaleand;
                    //var_dump($ordervalue); echo "<br>";
                    $showOrder[] = $ordervalue;
                }
            }
        }
        if (!empty($showOrder)) {
            return json_encode($showOrder);
        } else {
            return false;
        }
    }