getMainMenu2(); $storeid = $_COOKIE["storeid"]; $cur_store = $this->getStoreById($storeid); $type = isset($_GPC['type'])?$_GPC['type']:'today'; $pageindex = max(1, intval($_GPC['page'])); $pagesize = 10; $orderType = Order::TYPE_GROUP; $where = " where a.uniacid=:uniacid and a.type={$orderType} and a.store_id=:store_id and a.pay_type in (1,2) and a.state in (2,3,4,5,7,8,9,10)" ; $data[':uniacid'] = $_W['uniacid']; $data[':store_id'] = $storeid; if ($_GPC['time']) { $start = strtotime($_GPC['time']['start']); $end = strtotime($_GPC['time']['end']); $where .= " and UNIX_TIMESTAMP(a.time) >='{$start}' and UNIX_TIMESTAMP(a.time) <= '{$end}'"; $type = 'all'; } else { if ($type == 'today') { $time = date("Y-m-d",time()); $where .= " and a.time LIKE '%{$time}%' "; } if ($type == 'yesterday') { $time = date("Y-m-d",strtotime("-1 day")); $where .= " and a.time LIKE '%{$time}%' "; } if ($type == 'week') { $time = strtotime(date("Y-m-d",strtotime("-7 day"))); $where .= " and UNIX_TIMESTAMP(a.time) > ".$time; } if ($type == 'month') { $time = date("Y-m"); $where .= " and a.time LIKE '%{$time}%' "; } } //总数统计 $statSql = "select sum(ops.pay_price) as 'pay_price', sum(ops.goods_price) as 'goods_price',sum(ops.service_fee) as service_fee,sum(ops.delivery_fee) as delivery_fee, sum(ops.wx_pay_fee) as wx_pay_fee, sum(ops.refund_price) as refund_price, sum(ops.discount_price) as discount_price". " from ". tablename("cjdc_order") ." as a ". " left join ".tablename('cjdc_order_price_stat'). " as ops on ops.order_id = a.id". $where. ' group by ops.order_id'; $statArr = pdo_fetchcolumn($statSql, $data); $sql = "SELECT {selectedFields} ". " FROM ".tablename('cjdc_order'). " a". " left join ".tablename('cjdc_order_price_stat'). " as ops on ops.order_id = a.id". $where." ORDER BY a.id DESC"; $fields = "a.*,ops.delivery_fee,ops.pay_price, ops.wx_pay_fee, ops.refund_price, ops.service_fee"; $listSql = str_replace("{selectedFields}", $fields, $sql); $countSql = str_replace("{selectedFields}", "count(*)", $sql); $total = pdo_fetchcolumn($countSql, $data); $select_sql = $listSql." LIMIT " .($pageindex - 1) * $pagesize.",".$pagesize; $pager = pagination($total, $pageindex, $pagesize); $list = pdo_fetchall($select_sql, $data); // if(checksubmit('export_submit', true)) { $sql = "SELECT {selectedFields} ". " FROM ".tablename('cjdc_order'). " a". " left join ".tablename('cjdc_order_price_stat'). " as ops on ops.order_id = a.id". $where." ORDER BY a.id DESC"; $fields = "a.*,ops.delivery_fee,ops.pay_price, ops.wx_pay_fee, ops.refund_price, ops.service_fee"; $listSql = str_replace("{selectedFields}", $fields, $sql); $list = pdo_fetchall($listSql, $data); header('Content-Type: application/vnd.ms-excel;charset=utf-8'); header("Content-Disposition:attachment; filename=拼团资金数据.xls"); header('Cache-Control: max-age=0'); $fp = fopen('php://output', 'a'); include $this->template('web/groupfinanceExport'); exit(); } include $this->template('web/groupfinance');