Exemplo n.º 1
0
function exportOrder($data)
{
    global $dbConn;
    $num = 0;
    $dataArr = array();
    foreach ($data as $id) {
        $sql = "SELECT a.addtime, a.recordnumber, a.purchaseuser_id, b.sku, b.price, b.count, b.parid, b.stockqty, b.sendqty  FROM ph_ow_order as a ";
        $sql .= " JOIN ph_ow_order_detail as b ON a.id = b.po_id WHERE a.id = '{$id}' AND a.is_delete = 0 AND b.is_delete = 0 ";
        $query = $dbConn->query($sql);
        $datalist = array();
        if ($query) {
            $rtnData = $dbConn->fetch_array_all($query);
            if (!empty($rtnData)) {
                $ii = 0;
                foreach ($rtnData as $k => $v) {
                    $addtime = $v['addtime'];
                    $recordnumber = $v['recordnumber'];
                    $parid = $v['parid'];
                    //$purid        = $v['purchaseuser_id'];
                    $price = $v['price'];
                    $count = $v['count'];
                    $sku = $v['sku'];
                    $stockqty = $v['stockqty'];
                    $sendqty = $v['sendqty'];
                    $skuinfo = getSkuById($sku);
                    $name = $skuinfo[0]['goodsName'];
                    $parname = getParNameById($parid);
                    $purid = getOverCguser($sku);
                    $purname = getNameById($purid);
                    $datalist[$ii]['addtime'] = $addtime;
                    $datalist[$ii]['recordnumber'] = $recordnumber;
                    $datalist[$ii]['parname'] = $parname;
                    $datalist[$ii]['purname'] = $purname;
                    $datalist[$ii]['stockqty'] = $stockqty;
                    $datalist[$ii]['sendqty'] = $sendqty;
                    $datalist[$ii]['sku'] = $sku;
                    $datalist[$ii]['name'] = $name;
                    $datalist[$ii]['price'] = $price;
                    $datalist[$ii]['count'] = $count;
                    $datalist[$ii]['totalmoney'] = $price * $count;
                    $ii++;
                }
                $dataArr[$num] = $datalist;
                $num++;
            }
        }
    }
    return $dataArr;
}
Exemplo n.º 2
0
$lastStart = strtotime($dateFarmat . "00:00:00");
$lastEnd = strtotime($dateFarmat . "23:59:59");
var_dump($lastStart, $lastEnd);
$sql = "select distinct a.id, a.*,b.*,c.price,c.count from ph_order_arrive_log as a left join ph_order as b \n\t\ton a.ordersn=b.recordnumber left join ph_order_detail as c\n\t\ton b.id=c.po_id \n\t\twhere a.sku=c.sku\n\t\tand a.arrive_time>{$lastStart} and a.arrive_time<{$lastEnd}\n  \t";
echo $sql;
$sql = $dbConn->execute($sql);
$skuReachInfo = $dbConn->getResultArray($sql);
print_r($skuReachInfo);
$row = 2;
foreach ($skuReachInfo as $itemSku) {
    $addtime = $itemSku['addtime'];
    $recordnumber = $itemSku['recordnumber'];
    $partnerName = getParterNameById($itemSku['partner_id']);
    $purchaseName = getNameById($itemSku['purchaseuser_id']);
    $sku = $itemSku['sku'];
    $goodsName = getSkuById($sku);
    $price = $itemSku['price'];
    $count = $itemSku['count'];
    $totalmoney = $price * $count;
    $arrive_time = $itemSku['arrive_time'];
    $amount = $itemSku['amount'];
    //到货数量
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $row, date("Y/m/d", $addtime));
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('B' . $row, $recordnumber);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('C' . $row, $partnerName);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('D' . $row, $sku);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('E' . $row, $goodsName);
    //产品名称
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('F' . $row, $count);
    //
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('G' . $row, $price);