|
|
<?php
|
|
|
/**
|
|
|
* Created by PhpStorm.
|
|
|
* User: 29925
|
|
|
* Date: 2018/8/16
|
|
|
* Time: 14:14
|
|
|
*/
|
|
|
|
|
|
namespace app\admin\controller;
|
|
|
|
|
|
use app\admin\model\OrderModel;
|
|
|
use cmf\controller\AdminBaseController;
|
|
|
use think\Db;
|
|
|
|
|
|
class OrderController extends AdminBaseController
|
|
|
{
|
|
|
|
|
|
protected $decto_array;
|
|
|
protected $bin_array;
|
|
|
|
|
|
protected $table;
|
|
|
protected $order_model;
|
|
|
protected $option_table;
|
|
|
protected $sort_model;
|
|
|
protected $order_sort_table;
|
|
|
public function _initialize()
|
|
|
{
|
|
|
$this->decto_array = [ 'A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'E' => 4, 'F' => 5, 'G' => 6, 'H' => 7, 'I' => 8, 'J' => 9, 'K' => 10, 'L' => 11, 'M' => 12, 'N' => 13, 'O' => 14, 'P' => 15, 'Q' => 16, 'R' => 17, 'S' => 18, 'T' => 19, 'U' => 20, 'V' => 21, 'W' => 22, 'X' => 23, 'Y' => 24, 'Z' => 25 ];
|
|
|
$this->bin_array = [ 'A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'E' => 4, 'F' => 5, 'G' => 6, 'H' => 7, 'I' => 8, 'J' => 9, 'K' => 10, 'L' => 11, 'M' => 12, 'N' => 13, 'O' => 14, 'P' => 15, 'Q' => 16, 'R' => 17, 'S' => 18, 'T' => 19, 'U' => 20, 'V' => 21, 'W' => 22, 'X' => 23, 'Y' => 24, 'Z' => 25 ];
|
|
|
|
|
|
$this->table = 'Order';
|
|
|
$this->order_model = new OrderModel();
|
|
|
$this->option_table = 'OrderOption';
|
|
|
$this->order_sort_table = 'OrderSort';
|
|
|
|
|
|
// 订单字段类型定义
|
|
|
$this->sort_model[1] = '<div class="text_item form_options" data-validate="{validate}">
|
|
|
<p class="text_tit"><span class=" _validate">{name}</span>{must}</p>
|
|
|
<input type="text" name="" id="" value="{value}" class="baby_input" placeholder="请输入{name}" />
|
|
|
</div>';
|
|
|
$this->sort_model[2] = '<div class="text_item form_options" data-validate="{validate}">
|
|
|
<p class="text_tit"><span class=" _validate">{name}</span>{must}</p>
|
|
|
<input type="number" name="" id="" value="{value}" class="baby_input" placeholder="请输入{name}" />
|
|
|
</div>';
|
|
|
$this->sort_model[3] = '<div class="text_item form_options" data-validate="{validate}">
|
|
|
<p class="text_tit"><span class=" _validate">{name}</span>{must}</p>
|
|
|
<input type="number" maxlength="11" name="" id="" value="{value}" class="baby_input" placeholder="请输入{name}" />
|
|
|
</div>';
|
|
|
$this->sort_model[4] = '<div class="write_tit form_options" data-validate="{validate}">
|
|
|
<p class="tit"><span class=" _validate">{name}</span></p>
|
|
|
<div class="flex_style">
|
|
|
{options}
|
|
|
</div>
|
|
|
</div>';
|
|
|
$this->sort_model[5] = '<div class="text_item form_options" data-validate="{validate}">
|
|
|
<p class="text_tit"><span class=" _validate">{name}</span>{must}</p>
|
|
|
<input type="text" name="" id="" value="{value}" class="baby_input" placeholder="请输入{name}" />
|
|
|
</div>';
|
|
|
$this->sort_model[6] = '<div class="text_item form_options" data-validate="{validate}">
|
|
|
<p class="text_tit"><span class=" _validate">{name}</span>{must}</p>
|
|
|
<textarea class="baby_input">{value}</textarea>
|
|
|
</div>';
|
|
|
$this->sort_model[7] = '<div class="text_item form_options" data-validate="{validate}">
|
|
|
<p class="text_tit"><span class=" _validate">{name}</span>{must}</p>
|
|
|
<input type="text" name="" id="product" value="{value}" class="baby_input" placeholder="请选择{name}" />
|
|
|
<img src="__TMPL__/public/mobile/images/youjiantou.png" class="jiantou" />
|
|
|
</div>';
|
|
|
$this->sort_model[8] = '<div class="write_wrap" style="margin: 0;" data-validate="{validate}">
|
|
|
<p class="text_tit" style="line-height: 0.6rem;"><span class=" _validate">{name}</span>{must}</p>
|
|
|
</div>
|
|
|
<div class="up_wrap form_options">
|
|
|
<div class="up_pic">
|
|
|
<i class="iconfont icon-msnui-cloud-upload"></i>
|
|
|
<p class="click_up">点击上传</p>
|
|
|
</div>
|
|
|
</div>';
|
|
|
$this->sort_model[10] = '<div class="text_item no_margin form_options" data-validate="{validate}">
|
|
|
<p class="text_tit"><span class=" _validate">{name}</span>{must}</p>
|
|
|
<input type="text" name="" id="birthday" readonly="readonly" value="{value}" class="baby_input" placeholder="请选择{name}" />
|
|
|
<img src="__TMPL__/public/mobile/images/youjiantou.png" class="jiantou" />
|
|
|
</div>';
|
|
|
$this->sort_model[11] = '<div class="text_item form_options" data-validate="{validate}">
|
|
|
<p class="text_tit"><span class=" _validate">{name}</span>{must}</p>
|
|
|
<weui-distpicker province="广东省" city="广州市" area="海珠区"></weui-distpicker>
|
|
|
<input type="text" name="" id="address" readonly="readonly" value="{value}" class="baby_input" placeholder="请输入{name}" />
|
|
|
<img src="__TMPL__/public/mobile/images/youjiantou.png" class="jiantou" />
|
|
|
</div>';
|
|
|
$this->sort_model[12] = '<div class="text_item form_options" data-validate="{validate}" data-type="12">
|
|
|
<p class="text_tit"><span class=" _validate">{name}</span>{must}</p>
|
|
|
<input type="text" name="" id="" value="{value}" class="baby_input" placeholder="请输入{name}" />
|
|
|
</div>';
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 电子订单列表
|
|
|
* @adminMenu(
|
|
|
* 'name' => '电子订单列表',
|
|
|
* 'parent' => 'admin/OrderOption/default',
|
|
|
* 'display'=> true,
|
|
|
* 'hasView'=> true,
|
|
|
* 'order' => 10000,
|
|
|
* 'icon' => '',
|
|
|
* 'remark' => '电子订单列表',
|
|
|
* 'param' => ''
|
|
|
* )
|
|
|
*/
|
|
|
public function index() {
|
|
|
$param = $this->request->param();
|
|
|
// 查询条件处理
|
|
|
$where = [
|
|
|
'delete_time'=>0
|
|
|
];
|
|
|
if(isset($param['keyword'])) {
|
|
|
$where['order_sn|sort_name|user_login|number'] = ['like','%'.$param['keyword'].'%'];
|
|
|
}
|
|
|
if(!empty($param['sort_id'])) {
|
|
|
$where['sort_id'] = $param['sort_id'];
|
|
|
}
|
|
|
if(isset($param['status']) && $param['status'] >= 0) {
|
|
|
$where['status'] = $param['status'];
|
|
|
}
|
|
|
if(isset($param['is_excel']) && $param['is_excel'] >= 0) {
|
|
|
$where['is_excel'] = $param['is_excel'];
|
|
|
}
|
|
|
if(isset($param['is_over']) && $param['is_over'] >= 0) {
|
|
|
if($param['is_over'] == 0) {
|
|
|
$where['over_time'] = ['egt',time()];
|
|
|
}
|
|
|
if($param['is_over'] == 1) {
|
|
|
$where['over_time'] = ['lt',time()];
|
|
|
}
|
|
|
}
|
|
|
$startTime = empty($param['start_time']) ? 0 : strtotime($param['start_time']);
|
|
|
$endTime = empty($param['end_time']) ? 0 : strtotime($param['end_time']);
|
|
|
if (!empty($startTime) && !empty($endTime)) {
|
|
|
$where['create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
|
|
|
} else {
|
|
|
if (!empty($startTime)) {
|
|
|
$where['create_time'] = ['>= time', $startTime];
|
|
|
}
|
|
|
if (!empty($endTime)) {
|
|
|
$where['create_time'] = ['<= time', $endTime];
|
|
|
}
|
|
|
}
|
|
|
$list = $this->singleData('order_view',$where,2,[],10);
|
|
|
$list->appends($param);
|
|
|
$this->assign('list',$list->items());
|
|
|
$this->assign('page',$list->render());
|
|
|
$this->assign('keyword',isset($param['keyword']) ? $param['keyword'] : '');
|
|
|
$this->assign('sort_id',isset($param['sort_id']) ? $param['sort_id'] : '');
|
|
|
$this->assign('status',isset($param['status']) ? $param['status'] : '');
|
|
|
$this->assign('is_excel',isset($param['is_excel']) ? $param['is_excel'] : '');
|
|
|
$this->assign('is_over',isset($param['is_over']) ? $param['is_over'] : '');
|
|
|
$this->assign('start_time',isset($param['start_time']) ? $param['start_time'] : '');
|
|
|
$this->assign('end_time',isset($param['end_time']) ? $param['end_time'] : '');
|
|
|
// 订单类型查询
|
|
|
$sortList = $this->singleData($this->order_sort_table,['delete_time'=>0],1);
|
|
|
$this->assign('sortList',$sortList);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 电子订单列表(表单类型下)
|
|
|
* @adminMenu(
|
|
|
* 'name' => '电子订单列表',
|
|
|
* 'parent' => 'admin/OrderSort/index',
|
|
|
* 'display'=> false,
|
|
|
* 'hasView'=> false,
|
|
|
* 'order' => 1,
|
|
|
* 'icon' => '',
|
|
|
* 'remark' => '电子订单列表(表单类型下)',
|
|
|
* 'param' => ''
|
|
|
* )
|
|
|
*/
|
|
|
public function index_sort() {
|
|
|
$param = $this->request->param();
|
|
|
$where = [
|
|
|
'delete_time'=>0
|
|
|
];
|
|
|
if(empty($param['sort_id'])) {
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
$where['sort_id'] = $param['sort_id'];
|
|
|
if(isset($param['status']) && $param['status'] >= 0) {
|
|
|
$where['status'] = $param['status'];
|
|
|
}
|
|
|
if(isset($param['is_excel']) && $param['is_excel'] >= 0) {
|
|
|
$where['is_excel'] = $param['is_excel'];
|
|
|
}
|
|
|
if(isset($param['is_over']) && $param['is_over'] >= 0) {
|
|
|
if($param['is_over'] == 0) {
|
|
|
$where['over_time'] = ['egt',time()];
|
|
|
}
|
|
|
if($param['is_over'] == 1) {
|
|
|
$where['over_time'] = ['lt',time()];
|
|
|
}
|
|
|
}
|
|
|
$startTime = empty($filter['start_time']) ? 0 : strtotime($filter['start_time']);
|
|
|
$endTime = empty($filter['end_time']) ? 0 : strtotime($filter['end_time']);
|
|
|
if (!empty($startTime) && !empty($endTime)) {
|
|
|
$where['create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
|
|
|
} else {
|
|
|
if (!empty($startTime)) {
|
|
|
$where['create_time'] = ['>= time', $startTime];
|
|
|
}
|
|
|
if (!empty($endTime)) {
|
|
|
$where['create_time'] = ['<= time', $endTime];
|
|
|
}
|
|
|
}
|
|
|
$list = $this->singleData('order_view',$where,2,[],10);
|
|
|
$list->appends($param);
|
|
|
$this->assign('list',$list->items());
|
|
|
$this->assign('page',$list->render());
|
|
|
$this->assign('keyword',isset($param['keyword']) ? $param['keyword'] : '');
|
|
|
$this->assign('status',isset($param['status']) ? $param['status'] : '');
|
|
|
$this->assign('is_excel',isset($param['is_excel']) ? $param['is_excel'] : '');
|
|
|
$this->assign('is_over',isset($param['is_over']) ? $param['is_over'] : '');
|
|
|
$this->assign('start_time',isset($param['start_time']) ? $param['start_time'] : '');
|
|
|
$this->assign('end_time',isset($param['end_time']) ? $param['end_time'] : '');
|
|
|
$this->assign('sort_id',$param['sort_id']);
|
|
|
// 订单类型
|
|
|
$sortList = $this->singleData($this->order_sort_table,['delete_time'=>0],1);
|
|
|
$this->assign('sortList',$sortList);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 电子订单列表(销售人员下)
|
|
|
* @adminMenu(
|
|
|
* 'name' => '电子订单列表',
|
|
|
* 'parent' => 'admin/OrderSort/index',
|
|
|
* 'display'=> false,
|
|
|
* 'hasView'=> false,
|
|
|
* 'order' => 2,
|
|
|
* 'icon' => '',
|
|
|
* 'remark' => '电子订单列表(销售人员下)',
|
|
|
* 'param' => ''
|
|
|
* )
|
|
|
*/
|
|
|
public function index_sales() {
|
|
|
$param = $this->request->param();
|
|
|
$where = [
|
|
|
'delete_time'=>0
|
|
|
];
|
|
|
if(empty($param['user_id'])) {
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
$where['user_id'] = $param['user_id'];
|
|
|
if(isset($param['keyword'])) {
|
|
|
$where['order_sn|sort_name|user_login|number'] = ['like','%'.$param['keyword'].'%'];
|
|
|
}
|
|
|
if(!empty($param['sort_id'])) {
|
|
|
$where['sort_id'] = $param['sort_id'];
|
|
|
}
|
|
|
if(isset($param['status']) && $param['status'] >= 0) {
|
|
|
$where['status'] = $param['status'];
|
|
|
}
|
|
|
if(isset($param['is_excel']) && $param['is_excel'] >= 0) {
|
|
|
$where['is_excel'] = $param['is_excel'];
|
|
|
}
|
|
|
if(isset($param['is_over']) && $param['is_over'] >= 0) {
|
|
|
if($param['is_over'] == 0) {
|
|
|
$where['over_time'] = ['egt',time()];
|
|
|
}
|
|
|
if($param['is_over'] == 1) {
|
|
|
$where['over_time'] = ['lt',time()];
|
|
|
}
|
|
|
}
|
|
|
$startTime = empty($filter['start_time']) ? 0 : strtotime($filter['start_time']);
|
|
|
$endTime = empty($filter['end_time']) ? 0 : strtotime($filter['end_time']);
|
|
|
if (!empty($startTime) && !empty($endTime)) {
|
|
|
$where['create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
|
|
|
} else {
|
|
|
if (!empty($startTime)) {
|
|
|
$where['create_time'] = ['>= time', $startTime];
|
|
|
}
|
|
|
if (!empty($endTime)) {
|
|
|
$where['create_time'] = ['<= time', $endTime];
|
|
|
}
|
|
|
}
|
|
|
$list = $this->singleData('order_view',$where,2,[],10);
|
|
|
$list->appends($param);
|
|
|
$this->assign('list',$list->items());
|
|
|
$this->assign('page',$list->render());
|
|
|
$this->assign('keyword',isset($param['keyword']) ? $param['keyword'] : '');
|
|
|
$this->assign('sort_id',isset($param['sort_id']) ? $param['sort_id'] : '');
|
|
|
$this->assign('status',isset($param['status']) ? $param['status'] : '');
|
|
|
$this->assign('is_excel',isset($param['is_excel']) ? $param['is_excel'] : '');
|
|
|
$this->assign('is_over',isset($param['is_over']) ? $param['is_over'] : '');
|
|
|
$this->assign('start_time',isset($param['start_time']) ? $param['start_time'] : '');
|
|
|
$this->assign('end_time',isset($param['end_time']) ? $param['end_time'] : '');
|
|
|
$this->assign('user_id',$param['user_id']);
|
|
|
// 订单类型
|
|
|
$sortList = $this->singleData($this->order_sort_table,['delete_time'=>0],1);
|
|
|
$this->assign('sortList',$sortList);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 用户数据导出
|
|
|
* @adminMenu(
|
|
|
* 'name' => '用户数据导出',
|
|
|
* 'parent' => 'index',
|
|
|
* 'display'=> false,
|
|
|
* 'hasView'=> false,
|
|
|
* 'order' => 3,
|
|
|
* 'icon' => '',
|
|
|
* 'remark' => '用户数据导出',
|
|
|
* 'param' => ''
|
|
|
* )
|
|
|
*/
|
|
|
public function excel()
|
|
|
{
|
|
|
$param = $this->request->param();
|
|
|
// 进行查询条件的处理
|
|
|
$where = [
|
|
|
'delete_time'=>0
|
|
|
];
|
|
|
if(!empty($param['ids'])) {
|
|
|
$where['id'] = ['in',$param['ids']];
|
|
|
}
|
|
|
if(isset($param['keyword'])) {
|
|
|
$where['order_sn|sort_name|user_login|number'] = ['like','%'.$param['keyword'].'%'];
|
|
|
}
|
|
|
if(!empty($param['sort_id'])) {
|
|
|
$where['sort_id'] = $param['sort_id'];
|
|
|
}
|
|
|
if(isset($param['status']) && $param['status'] >= 0) {
|
|
|
$where['status'] = $param['status'];
|
|
|
}
|
|
|
if(isset($param['is_excel']) && $param['is_excel'] >= 0) {
|
|
|
$where['is_excel'] = $param['is_excel'];
|
|
|
}
|
|
|
if(isset($param['is_over']) && $param['is_over'] >= 0) {
|
|
|
if($param['is_over'] == 0) {
|
|
|
$where['over_time'] = ['egt',time()];
|
|
|
}
|
|
|
if($param['is_over'] == 1) {
|
|
|
$where['over_time'] = ['lt',time()];
|
|
|
}
|
|
|
}
|
|
|
$startTime = empty($param['start_time']) ? 0 : strtotime($param['start_time']);
|
|
|
$endTime = empty($param['end_time']) ? 0 : strtotime($param['end_time']);
|
|
|
if (!empty($startTime) && !empty($endTime)) {
|
|
|
$where['create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
|
|
|
} else {
|
|
|
if (!empty($startTime)) {
|
|
|
$where['create_time'] = ['>= time', $startTime];
|
|
|
}
|
|
|
if (!empty($endTime)) {
|
|
|
$where['create_time'] = ['<= time', $endTime];
|
|
|
}
|
|
|
}
|
|
|
// 查询数据并导出
|
|
|
$list = $this->singleData('order_view',$where,1);
|
|
|
$this->expList($list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 数字转字母 (类似于Excel列标)
|
|
|
* @param Int $index 索引值
|
|
|
* @param Int $start 字母起始值
|
|
|
* @return String 返回字母
|
|
|
*/
|
|
|
private function IntToChr($index, $start = 65) {
|
|
|
$str = '';
|
|
|
if (floor($index / 26) > 0) {
|
|
|
$str .= $this->IntToChr(floor($index / 26)-1);
|
|
|
}
|
|
|
return $str . chr($index % 26 + $start);
|
|
|
}
|
|
|
|
|
|
// 数据导出
|
|
|
private function expList($array)
|
|
|
{
|
|
|
// 获取可显示的字段列表
|
|
|
$option_list = $this->singleData($this->option_table,['delete_time'=>0],1);
|
|
|
|
|
|
//导出Excel
|
|
|
$objPHPExcel = new \PHPExcel();
|
|
|
|
|
|
// 设置单元格宽度
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25);
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(20);
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(15);
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(15);
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(20);
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(20);
|
|
|
// 设置水平居中
|
|
|
$objPHPExcel->getDefaultStyle()->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
// 设置垂直居中
|
|
|
$objPHPExcel->getDefaultStyle()->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
|
|
|
//Add some data
|
|
|
$objPHPExcel->setActiveSheetIndex(0)
|
|
|
->setCellValue('A1', 'ID')
|
|
|
->setCellValue('B1', '订单号')
|
|
|
->setCellValue('C1', '订单类型')
|
|
|
->setCellValue('D1', '销售用户名')
|
|
|
->setCellValue('E1', '订单确认码')
|
|
|
->setCellValue('F1', '订单状态')
|
|
|
->setCellValue('G1', '收集状态')
|
|
|
->setCellValue('H1', '发布时间')
|
|
|
->setCellValue('I1', '失效时间');
|
|
|
|
|
|
// 设置表单字段的单元格宽度及第一行文字
|
|
|
$option_id_array = [];
|
|
|
foreach ($option_list as $k=>$v) {
|
|
|
$column = $this->IntToChr($k+10);
|
|
|
$objPHPExcel->getActiveSheet()->getColumnDimension($column)->setWidth(20);
|
|
|
$objPHPExcel->setActiveSheetIndex(0)
|
|
|
->setCellValue($column.'1', $v['name']);
|
|
|
$option_id_array[$k] = $v['id'];
|
|
|
}
|
|
|
|
|
|
$i = 2;
|
|
|
|
|
|
// 循环到导出数据
|
|
|
foreach ($array as $v) {
|
|
|
$status = '未支付';
|
|
|
if($v['status'] == 1) {
|
|
|
$status = '已支付';
|
|
|
}
|
|
|
$is_stop = '收集中';
|
|
|
if($v['is_stop'] == 1) {
|
|
|
$is_stop = '已停止';
|
|
|
}
|
|
|
$objPHPExcel->setActiveSheetIndex(0)
|
|
|
->setCellValue('A' . $i, $v['id'])
|
|
|
->setCellValueExplicit('B' . $i, $v['order_sn'],\PHPExcel_Cell_DataType::TYPE_STRING)
|
|
|
// ->setCellValueExplicit('B' . $i, $v['order_sn'],\PHPExcel_Cell_DataType::TYPE_STRING)
|
|
|
->setCellValue('C' . $i, $v['sort_name'])
|
|
|
->setCellValue('D' . $i, $v['user_login'])
|
|
|
->setCellValue('E' . $i, $v['number'])
|
|
|
->setCellValue('F' . $i, $status)
|
|
|
->setCellValue('G' . $i, $is_stop)
|
|
|
->setCellValue('H' . $i, date('Y-m-d H:i',$v['create_time']))
|
|
|
->setCellValue('I' . $i, date('Y-m-d H:i',$v['over_time']));
|
|
|
$v['options'] = json_decode($v['options'],true);
|
|
|
foreach ($v['options'] as $ks=>$vs) {
|
|
|
// $where = [
|
|
|
// 'id' => $vs['id']
|
|
|
// ];
|
|
|
// $vs['cell'] = Db::name('OrderOption')->where($where)->value('cell');
|
|
|
$key = array_search($vs['id'], $option_id_array);
|
|
|
$vs['cell'] = $this->IntToChr($key+10);
|
|
|
if($vs['cell']) {
|
|
|
if($vs['type'] == 3) {
|
|
|
// 纯数字字段转化为字符串格式,防止以科学计数法进行显示
|
|
|
$objPHPExcel->setActiveSheetIndex(0)
|
|
|
->setCellValueExplicit($vs['cell'] . $i, $vs['user_choose'],\PHPExcel_Cell_DataType::TYPE_STRING);
|
|
|
} elseif($vs['type'] == 8) {
|
|
|
// 导出图片格式,高度自适应
|
|
|
$filePath = './upload/'.$vs['user_choose'];
|
|
|
if(!empty($vs['user_choose']) && file_exists($filePath)) {
|
|
|
$image = \think\Image::open('./upload/'.$vs['user_choose']);
|
|
|
// 返回图片的宽度
|
|
|
$width = $image->width();
|
|
|
// 返回图片的高度
|
|
|
$height = $image->height();
|
|
|
$default = $height/($width/100);
|
|
|
//设置默认行高(通过图片缩放比例计算高度)
|
|
|
$objPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight($default);
|
|
|
// 图片生成
|
|
|
$objDrawing[$i] = new \PHPExcel_Worksheet_Drawing();
|
|
|
$objDrawing[$i]->setPath($filePath);
|
|
|
// 设置宽度
|
|
|
$objDrawing[$i]->setWidth(100); //照片宽度
|
|
|
/*设置图片要插入的单元格*/
|
|
|
$objDrawing[$i]->setCoordinates($vs['cell'].$i);
|
|
|
// 图片偏移距离
|
|
|
$objDrawing[$i]->setOffsetX(12);
|
|
|
$objDrawing[$i]->setOffsetY(12);
|
|
|
$objDrawing[$i]->setWorksheet($objPHPExcel->getActiveSheet());
|
|
|
}
|
|
|
} else {
|
|
|
$objPHPExcel->setActiveSheetIndex(0)
|
|
|
->setCellValue($vs['cell'] . $i, $vs['user_choose']);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
$i++;
|
|
|
Db::name('Order')->where(['order_sn'=>$v['order_sn']])->update(['is_excel'=>1,'excel_time'=>time()]);
|
|
|
}
|
|
|
|
|
|
$filename = '订单数据导出'. date('Y-m-d').'.xls';
|
|
|
ob_end_clean();
|
|
|
header("Content-type:application/vnd.ms-excel;charset=UTF-8");
|
|
|
header('Content-Type: application/vnd.ms-excel');
|
|
|
header('Content-Disposition: attachment;filename="' . $filename . '"');
|
|
|
header('Cache-Control: max-age=0');
|
|
|
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
|
|
$objWriter->save('php://output');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 编辑订单
|
|
|
* @adminMenu(
|
|
|
* 'name' => '编辑订单',
|
|
|
* 'parent' => 'index',
|
|
|
* 'display'=> false,
|
|
|
* 'hasView'=> false,
|
|
|
* 'order' => 4,
|
|
|
* 'icon' => '',
|
|
|
* 'remark' => '编辑订单',
|
|
|
* 'param' => ''
|
|
|
* )
|
|
|
*/
|
|
|
public function edit() {
|
|
|
$id = $this->request->param('id',0,'intval');
|
|
|
if(!$id) {
|
|
|
$this->error('参数错误');
|
|
|
}
|
|
|
$where = [
|
|
|
'id' => $id,
|
|
|
'delete_time'=>0
|
|
|
];
|
|
|
$info = Db::name('order_view')->where($where)->find();
|
|
|
$info['options'] = json_decode($info['options'],true);
|
|
|
foreach ($info['options'] as $k=>$v) {
|
|
|
$optionsInfo = $this->singleData($this->option_table,['id'=>$v['id']]);
|
|
|
$v['name'] = $optionsInfo['name'];
|
|
|
$v['html'] = $this->form_model($v);
|
|
|
$info['group'][] = $v;
|
|
|
}
|
|
|
$this->assign($info);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
// 处理订单模型数据
|
|
|
private function form_model($formData) {
|
|
|
$html = $this->sort_model[$formData['type']];
|
|
|
$html = str_replace('{name}',$formData['name'],$html);
|
|
|
if($formData['checked'] == 1) {
|
|
|
$html = str_replace('{must}','*',$html);
|
|
|
$html = str_replace('{validate}',1,$html);
|
|
|
} else {
|
|
|
$html = str_replace('{must}','',$html);
|
|
|
$html = str_replace('{validate}',0,$html);
|
|
|
}
|
|
|
if(!empty($formData['values']) && $formData['values'] != null) {
|
|
|
$array = explode(',',$formData['values']);
|
|
|
$options = '';
|
|
|
foreach ($array as $k=>$v) {
|
|
|
$active = isset($formData['user_choose'])?($formData['user_choose']==$v?'active':''):($k==0?'active':'');
|
|
|
$options .= '<p class="order_style '.$active.'">'.$v.'</p>';
|
|
|
}
|
|
|
$html = str_replace('{options}',$options,$html);
|
|
|
}
|
|
|
if(!empty($formData['user_choose'])) {
|
|
|
$html = str_replace('{value}',$formData['user_choose'],$html);
|
|
|
} else {
|
|
|
$html = str_replace('{value}','',$html);
|
|
|
}
|
|
|
return $html;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改订单收集状态
|
|
|
* @adminMenu(
|
|
|
* 'name' => '修改订单收集状态',
|
|
|
* 'parent' => 'index',
|
|
|
* 'display'=> false,
|
|
|
* 'hasView'=> false,
|
|
|
* 'order' => 5,
|
|
|
* 'icon' => '',
|
|
|
* 'remark' => '修改订单收集状态',
|
|
|
* 'param' => ''
|
|
|
* )
|
|
|
*/
|
|
|
public function stop()
|
|
|
{
|
|
|
$param = $this->request->param();
|
|
|
$msg = '';
|
|
|
|
|
|
if (isset($param['ids']) && isset($param["is_stop"])) {
|
|
|
$stop = $param["is_stop"];
|
|
|
$ids = $this->request->param('ids/a');
|
|
|
|
|
|
$this->order_model->where(['id' => ['in', $ids]])->update(['is_stop' => $stop, 'update_time' => time()]);
|
|
|
|
|
|
if($stop == 0) {
|
|
|
$msg = "开启收集成功!";
|
|
|
}
|
|
|
if($stop == 1) {
|
|
|
$msg = "停止收集成功!";
|
|
|
}
|
|
|
$this->success($msg, '');
|
|
|
|
|
|
}
|
|
|
if (isset($param['id']) && isset($param["is_stop"])) {
|
|
|
$stop = $param["is_stop"];
|
|
|
$id = $this->request->param('id');
|
|
|
|
|
|
$this->order_model->where(['id' => $id])->update(['is_stop' => $stop, 'update_time' => time()]);
|
|
|
|
|
|
if($stop == 0) {
|
|
|
$msg = "开启收集成功!";
|
|
|
}
|
|
|
if($stop == 1) {
|
|
|
$msg = "停止收集成功!";
|
|
|
}
|
|
|
$this->success($msg,'');
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除订单
|
|
|
* @adminMenu(
|
|
|
* 'name' => '删除订单',
|
|
|
* 'parent' => 'index',
|
|
|
* 'display'=> false,
|
|
|
* 'hasView'=> false,
|
|
|
* 'order' => 6,
|
|
|
* 'icon' => '',
|
|
|
* 'remark' => '删除订单',
|
|
|
* 'param' => ''
|
|
|
* )
|
|
|
*/
|
|
|
public function delete() {
|
|
|
$id = $this->request->param('id',0,'intval');
|
|
|
$ids = $this->request->param('ids/a');
|
|
|
if(isset($id)) {
|
|
|
$result = $this->order_model->where(['id'=>$id])->update(['delete_time'=>time()]);
|
|
|
}
|
|
|
if(isset($ids)) {
|
|
|
$result = $this->order_model->where(['id'=>['in',$ids]])->update(['delete_time'=>time()]);
|
|
|
}
|
|
|
if(!$result) {
|
|
|
$this->error('删除失败');
|
|
|
}
|
|
|
$this->success('删除成功');
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|