public function export() { //$_GET['price']=1; //var_dump($_GET); $where = " 1"; if (!empty($_GET)) { if ($_GET['start_time'] != "" && $_GET['start_time'] != "开始日期") { $where .= " and createTime >= '" . $_GET['start_time'] . "'"; } if ($_GET['end_time'] != "" && $_GET['end_time'] != "截止日期") { $where .= " and createTime <= '" . $_GET['end_time'] . " 23:59:59'"; } if ($_GET['code'] != "") { $where .= " and code = '" . $_GET['code'] . "'"; } if ($_GET['type'] != "") { $where .= " and type =" . $_GET['type']; } if ($_GET['inPrice'] != "") { $where .= " and inPrice =" . $_GET['inPrice']; } if ($_GET['status'] != "") { $where .= " and status =" . $_GET['status']; } } $yOb = M("yhq"); $data = $yOb->where($where)->order("id desc")->select(); //echo "<pre>";var_dump($data); echo "</pre>"; //echo $yOb->getLastSql();die(); import("ORG.Util.MyExcel"); $ob = new MyExcel(); ob_end_clean(); $ob->setTitle(array('ID', '优惠券码', '优惠券价钱', '类型', '状态', '生成时间', '修改时间'))->setFileName("优惠券")->dump($data, 2007); }
public function export() { //$_GET['price']=1; //var_dump($_GET); $where = " 1"; if (!empty($_GET)) { if ($_GET['start_time'] != "" && $_GET['start_time'] != "开始日期") { $where .= " and updated_at >= '" . $_GET['start_time'] . "'"; } if ($_GET['end_time'] != "" && $_GET['end_time'] != "截止日期") { $where .= " and updated_at <= '" . $_GET['end_time'] . " 23:59:59'"; } if ($_GET['title'] != "") { $where .= " and title like '%" . $_GET['title'] . "%'"; } if ($_GET['name'] != "") { $where .= " and name like '%" . $_GET['name'] . "%'"; } if ($_GET['tel'] != "") { $where .= " and tel like '%" . $_GET['tel'] . "%'"; } if ($_GET['orderId'] != "") { $where .= " and orderId like '%" . $_GET['orderId'] . "%'"; } if ($_GET['yhq'] != "") { $yOb = M("yhq"); $yArr = $yOb->where("code='{$_GET['yhq']}'")->select(); if (isset($yArr) && !empty($yArr)) { $yhqId = $yArr[0]['id']; } else { $yhqId == 0; } $where .= " and yhqId = {$yhqId}"; } if ($_GET['status'] != "") { $where .= " and status =" . $_GET['status']; } } $yOb = M("Order"); $data = $yOb->field("id,orderId,name,tel,address_id,title,price,isDiscount,discount,yhq,yhqId,payType,status,CCID,transfer,transferCode,time,updated_at")->where($where)->order("id desc")->select(); //echo "<pre>";var_dump($data); echo "</pre>"; //echo $yOb->getLastSql();die(); $addOb = M("address"); foreach ($data as $k => $dv) { //通过优惠券id得到优惠券码 $yOb = M("yhq"); $yId = $dv['yhqId']; $yArr = $yOb->where("id={$yId}")->select(); $data[$k]['yhqId'] = $yArr[0]['code']; //将状态翻译成文字 if ($dv['status'] == 1) { $data[$k]['status'] = "未付款"; } elseif ($dv['status'] == 2) { $data[$k]['status'] = "已付款"; } elseif ($dv['status'] == 3) { $data[$k]['status'] = "已发货"; } elseif ($dv['status'] == 4) { $data[$k]['status'] = "已过期"; } elseif ($dv['status'] == 5) { $data[$k]['status'] = "已关闭"; } elseif ($dv['status'] == 6) { $data[$k]['status'] = "已取消"; } //将支付方式翻译成文字 if ($dv['payType'] == 1) { $data[$k]['payType'] = "支付宝"; } elseif ($dv['payType'] == 2) { $data[$k]['payType'] = "财付通"; } //将是否打折翻译成文字 if ($dv['isDiscount'] == 1) { $data[$k]['isDiscount'] = "打折"; } elseif ($dv['isDiscount'] == 0) { $data[$k]['isDiscount'] = "不打折"; } //将订单id加上单引号,以免excel由于用科学计数法将后面改成0 $data[$k]['orderId'] = "'" . $data[$k]['orderId'] . "'"; //计算出交易价格 $data[$k]['price'] = $data[$k]['price'] - $data[$k]['discount'] - $data[$k]['yhq']; //将地址信息由码创成文字 $addArr = $addOb->where("id={$dv['address_id']}")->select(); // echo $addOb -> getLastSql(); //var_dump($addArr); if ($addArr != null) { $pOb = M("province"); $province = $pOb->where("provinceId=" . $addArr[0]['province'])->select(); $cOb = M("city"); $city = $cOb->where("cityId=" . $addArr[0]['city'])->select(); $aOb = M("area"); $area = $aOb->where("areaId=" . $addArr[0]['area'])->select(); $addr = $province[0]['province'] . $city[0]['city'] . $area[0]['area'] . $addArr[0]['detail']; $data[$k]['address_id'] = $addr; // echo $addr; $data[$k]['mailCode'] = $addArr[0]['mailCode']; } // var_dump($data); } import("ORG.Util.MyExcel"); $ob = new MyExcel(); ob_end_clean(); $ob->setTitle(array('ID', '订单号', '用户名', '用户电话', '收货地址', '商品名称', '交易价格', '是否打折', '折扣价格', '优惠券金额', '优惠券码', '支付方式', '订单状态', '卡号', '快递名称', '快递编号', '生成时间', '修改时间', '邮编'))->setFileName("订单")->dump($data, 2007); }
public function export() { $where = " status=3"; if (!empty($_GET)) { if ($_GET['start_time'] != "" && $_GET['start_time'] != "开始日期") { $where .= " and updated_at >= '" . $_GET['start_time'] . "'"; } if ($_GET['end_time'] != "" && $_GET['end_time'] != "截止日期") { $where .= " and updated_at <= '" . $_GET['end_time'] . " 23:59:59'"; } if ($_GET['title'] != "") { $where .= " and title like '%" . $_GET['title'] . "%'"; } if ($_GET['CCID'] != "") { $where .= " and CCID like '%" . $_GET['CCID'] . "%'"; } } $yOb = M("cardorder"); $data = $yOb->field("id,orderId,uid,pid,title,price,isDiscount,discount,yhqPrice,yhqId,payType,status,CCID,beginTime,endTime,time,updateTime,num")->where($where)->order("id desc")->select(); //echo "<pre>";var_dump($data); echo "</pre>"; //echo $yOb->getLastSql();die(); $addOb = M("address"); foreach ($data as $k => $dv) { //通过优惠券id得到优惠券码 $yOb = M("yhq"); $yId = $dv['yhqId']; $yArr = $yOb->where("id={$yId}")->select(); $data[$k]['yhqId'] = $yArr[0]['code']; //将状态翻译成文字 if ($dv['status'] == 1) { $data[$k]['status'] = "未付款"; } elseif ($dv['status'] == 2) { $data[$k]['status'] = "待充值"; } elseif ($dv['status'] == 3) { $data[$k]['status'] = "已充值"; } //将支付方式翻译成文字 if ($dv['payType'] == 1) { $data[$k]['payType'] = "支付宝"; } elseif ($dv['payType'] == 2) { $data[$k]['payType'] = "财付通"; } //将是否打折翻译成文字 if ($dv['isDiscount'] == 1) { $data[$k]['isDiscount'] = "打折"; } elseif ($dv['isDiscount'] == 0) { $data[$k]['isDiscount'] = "不打折"; } //将订单id加上单引号,以免excel由于用科学计数法将后面改成0 $data[$k]['orderId'] = "'" . $data[$k]['orderId'] . "'"; //计算出交易价格 $data[$k]['price'] = $data[$k]['price'] - $data[$k]['discount'] - $data[$k]['yhqPrice']; } import("ORG.Util.MyExcel"); $ob = new MyExcel(); ob_end_clean(); $ob->setTitle(array('ID', '订单号', '用户ID', '商品ID', '商品名称', '交易价格', '是否打折', '折扣价格', '优惠券金额', '优惠券码', '支付方式', '订单状态', '卡号', '套餐开始时间', '套餐截止时间', '订单生成时间', '订单修改时间', '购买数量'))->setFileName("订单")->dump($data, 2007); }