public function order_report() { //搜索条件 $search = IFilter::act(IReq::get('search'), 'strict'); //条件筛选处理 list($join, $where) = order_class::getSearchCondition($search); //拼接sql $orderHandle = new IQuery('order as o'); $orderHandle->order = "o.id desc"; $orderHandle->fields = "o.*,d.name as distribute_name,u.username,p.name as payment_name"; $orderHandle->join = $join; $orderHandle->where = $where; $orderList = $orderHandle->find(); $strTable = '<table width="500" border="1">'; $strTable .= '<tr>'; $strTable .= '<td style="text-align:center;font-size:12px;width:120px;">订单编号</td>'; $strTable .= '<td style="text-align:center;font-size:12px;width:120px;">商家id</td>'; $strTable .= '<td style="text-align:center;font-size:12px;width:120px;">区</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="100">日期</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">收货人</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">电话</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">订单金额</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">实际支付</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">支付方式</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">支付状态</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">发货状态</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">商品信息</td>'; $strTable .= '</tr>'; foreach ($orderList as $k => $val) { $strTable .= '<tr>'; $strTable .= '<td style="text-align:center;font-size:12px;"> ' . $val['order_no'] . '</td>'; $strTable .= '<td style="text-align:center;font-size:12px;"> ' . $val['seller_id'] . '</td>'; $strTable .= '<td style="text-align:center;font-size:12px;"> ' . $val['area'] . '</td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['create_time'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['accept_name'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;"> ' . $val['telphone'] . ' ' . $val['mobile'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['payable_amount'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['real_amount'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['payment_name'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . Order_Class::getOrderPayStatusText($val) . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . Order_Class::getOrderDistributionStatusText($val) . ' </td>'; $orderGoods = Order_class::getOrderGoods($val['id']); $strGoods = ""; foreach ($orderGoods as $good) { $strGoods .= "商品编号:" . $good->goodsno . " 商品名称:" . $good->name; if ($good->value != '') { $strGoods .= " 规格:" . $good->value; } $strGoods .= "<br />"; } unset($orderGoods); $strTable .= '<td style="text-align:left;font-size:12px;">' . $strGoods . ' </td>'; $strTable .= '</tr>'; } $strTable .= '</table>'; unset($orderList); $reportObj = new report(); $reportObj->setFileName('order'); $reportObj->toDownload($strTable); exit; }
public function order_report() { $seller_id = $this->seller['seller_id']; $search = IFilter::act(IReq::get('search')); /* //必须为已支付状态 $search['pay_status='] = 1; //必须为未发货状态 $search['distribution_status='] = 0; */ $condition = Util::search($search); $where = "go.seller_id = " . $seller_id; $where .= $condition ? " and " . $condition : ""; //拼接sql $orderHandle = new IQuery('order_goods as og'); $orderHandle->order = "o.id desc"; $orderHandle->fields = "o.*,p.name as payment_name"; $orderHandle->join = "left join goods as go on go.id=og.goods_id left join order as o on o.id=og.order_id left join payment as p on p.id = o.pay_type"; $orderHandle->where = $where; $orderList = $orderHandle->find(); //pr($orderList); //对订单进行重构 if (empty($orderList)) { IError::show(403, "数据为空"); exit; } else { $addrObj = new IModel("address"); foreach ($orderList as $k => $v) { if ($v['address_id']) { $order_addr = explode(',', $v['address_id']); $count = count($order_addr); for ($i = 0; $i < $count; $i++) { $new = $v; $new['old_book_count'] = $count; $new['one_book_price'] = round($new['order_amount'] / $count, 2); $addr_detil = $this->getAddr($addrObj, $order_addr[$i]); if ($addr_detil) { $new['accept_name'] = $addr_detil['accept_name']; $new['province_val'] = $addr_detil['province_val']; $new['city_val'] = $addr_detil['city_val']; $new['area_val'] = $addr_detil['area_val']; $new['address'] = $addr_detil['address']; $new['school'] = $addr_detil['school']; $new['grade'] = $addr_detil['grade']; $new['class'] = $addr_detil['class']; $new['mobile'] = $addr_detil['mobile']; $new['telphone'] = $addr_detil['telphone']; } else { $new['province_val'] = ''; $new['city_val'] = ''; $new['area_val'] = ''; $new['school'] = ''; $new['grade'] = ''; $new['class'] = ''; } $new_order[] = $new; } } } } //pr($new_order); //构建 Excel table $strTable = '<table width="500" border="1">'; $strTable .= '<tr>'; $strTable .= '<td style="text-align:center;font-size:12px;width:120px;">订单编号</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="100">下单日期</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">收货人</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">省</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">市</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">区</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">学校</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">年级</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">班级</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">电话</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">订单金额</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">原有本数</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">单本金额</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">支付方式</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">支付状态</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">支付时间</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">发货状态</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">商品信息</td>'; $strTable .= '</tr>'; foreach ($new_order as $k => $val) { $strTable .= '<tr>'; $strTable .= '<td style="text-align:center;font-size:12px;"> ' . $val['order_no'] . '</td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['create_time'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['accept_name'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['province_val'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['city_val'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['area_val'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['school'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['grade'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['class'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;"> ' . $val['telphone'] . ' ' . $val['mobile'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['order_amount'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['old_book_count'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['one_book_price'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['payment_name'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . Order_Class::getOrderPayStatusText($val) . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['pay_time'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . Order_Class::getOrderDistributionStatusText($val) . ' </td>'; $orderGoods = Order_class::getOrderGoods($val['id']); $strGoods = ""; foreach ($orderGoods as $good) { $strGoods .= "商品编号:" . $good->goodsno . " 商品名称:" . $good->name; if ($good->value != '') { $strGoods .= " 规格:" . $good->value; } $strGoods .= "<br />"; } unset($orderGoods); $strTable .= '<td style="text-align:left;font-size:12px;">' . $strGoods . ' </td>'; $strTable .= '</tr>'; } $strTable .= '</table>'; //输出成EXcel格式文件并下载 $reportObj = new report(); $reportObj->setFileName('order'); $reportObj->toDownload($strTable); exit; }
public function order_report() { $seller_id = $this->seller['seller_id']; $condition = Util::search(IFilter::act(IReq::get('search'), 'strict')); $where = "go.seller_id = " . $seller_id; $where .= $condition ? " and " . $condition : ""; //拼接sql $orderHandle = new IQuery('order_goods as og'); $orderHandle->order = "o.id desc"; $orderHandle->fields = "o.*,p.name as payment_name"; $orderHandle->join = "left join goods as go on go.id=og.goods_id left join order as o on o.id=og.order_id left join payment as p on p.id = o.pay_type"; $orderHandle->where = $where; $orderList = $orderHandle->find(); //构建 Excel table $strTable = '<table width="500" border="1">'; $strTable .= '<tr>'; $strTable .= '<td style="text-align:center;font-size:12px;width:120px;">订单编号</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="100">日期</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">收货人</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">电话</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">订单金额</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">实际支付</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">支付方式</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">支付状态</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">发货状态</td>'; $strTable .= '<td style="text-align:center;font-size:12px;" width="*">商品信息</td>'; $strTable .= '</tr>'; foreach ($orderList as $k => $val) { $strTable .= '<tr>'; $strTable .= '<td style="text-align:center;font-size:12px;"> ' . $val['order_no'] . '</td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['create_time'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['accept_name'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;"> ' . $val['telphone'] . ' ' . $val['mobile'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['payable_amount'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['real_amount'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . $val['payment_name'] . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . Order_Class::getOrderPayStatusText($val) . ' </td>'; $strTable .= '<td style="text-align:left;font-size:12px;">' . Order_Class::getOrderDistributionStatusText($val) . ' </td>'; $orderGoods = Order_class::getOrderGoods($val['id']); $strGoods = ""; foreach ($orderGoods as $good) { $strGoods .= "商品编号:" . $good->goodsno . " 商品名称:" . $good->name; if ($good->value != '') { $strGoods .= " 规格:" . $good->value; } $strGoods .= "<br />"; } unset($orderGoods); $strTable .= '<td style="text-align:left;font-size:12px;">' . $strGoods . ' </td>'; $strTable .= '</tr>'; } $strTable .= '</table>'; //输出成EXcel格式文件并下载 $reportObj = new report(); $reportObj->setFileName('order'); $reportObj->toDownload($strTable); exit; }