package com.sinata.modular.system.controller;
|
|
import com.sinata.core.base.controller.BaseController;
|
import com.sinata.core.util.DateUtils2;
|
import com.sinata.core.util.ExcelExportUtil;
|
import org.springframework.stereotype.Controller;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.sinata.core.common.constant.factory.PageFactory;
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import com.sinata.modular.system.model.MyUserSubstanceCoupon;
|
import com.sinata.modular.system.service.IMyUserSubstanceCouponService;
|
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Map;
|
import org.springframework.util.StringUtils;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
/**
|
* 实物优惠券信息控制器
|
* @author goku
|
*/
|
@Controller
|
@RequestMapping("/myUserSubstanceCoupon")
|
public class MyUserSubstanceCouponController extends BaseController {
|
|
private String PREFIX = "/system/myUserSubstanceCoupon/";
|
|
@Autowired
|
private IMyUserSubstanceCouponService myUserSubstanceCouponService;
|
|
/**
|
* 跳转到实物优惠券信息首页
|
*/
|
@RequestMapping("")
|
public String index() {
|
return PREFIX + "myUserSubstanceCoupon.html";
|
}
|
|
|
/**
|
* 获取实物优惠券信息列表
|
*/
|
@ResponseBody
|
@RequestMapping(value = "/list")
|
public Object list(String beginTime, String endTime, String condition) {
|
Page<Map<String, Object>> page = new PageFactory().defaultPage();
|
Wrapper wrapper = new EntityWrapper<MyUserSubstanceCoupon>().orderBy("id", false);
|
|
// 时间搜索
|
if(!StringUtils.isEmpty(beginTime)) {
|
wrapper.ge("create_time", beginTime + " 00:00:00");
|
}
|
if(!StringUtils.isEmpty(endTime)) {
|
wrapper.le("create_time", endTime + " 23:59:59");
|
}
|
if(!StringUtils.isEmpty(condition)) {
|
wrapper.like("real_name", "%" +condition+ "%");
|
}
|
|
// 查询数据列表
|
List<Map<String, Object>> list = myUserSubstanceCouponService.selectMapsPage(page, wrapper).getRecords();
|
|
page.setRecords(list);
|
return super.packForBT(page);
|
}
|
|
@ResponseBody
|
@RequestMapping(value = "/export")
|
public void export(String beginTime, String endTime, String condition, Integer status, HttpServletResponse response) {
|
Page<Map<String, Object>> page = new PageFactory().defaultPage(999999,0);
|
Wrapper wrapper = new EntityWrapper<MyUserSubstanceCoupon>().orderBy("id", false);
|
|
// 时间搜索
|
if(!StringUtils.isEmpty(beginTime)) {
|
wrapper.ge("create_time", beginTime + " 00:00:00");
|
}
|
if(!StringUtils.isEmpty(endTime)) {
|
wrapper.le("create_time", endTime + " 23:59:59");
|
}
|
if(!StringUtils.isEmpty(condition)) {
|
wrapper.like("real_name", "%" +condition+ "%");
|
}
|
|
// 查询数据列表
|
List<Map<String, Object>> list = myUserSubstanceCouponService.selectMapsPage(page, wrapper).getRecords();
|
|
// 表格数据【封装】
|
List<List<Object>> dataList = new ArrayList<>();
|
|
// 头部列【封装】
|
List<Object> shellList = new ArrayList<>();
|
shellList.add("申请时间");
|
shellList.add("申请人姓名");
|
shellList.add("收件人姓名");
|
shellList.add("收件人电话");
|
shellList.add("收件人地址");
|
dataList.add(shellList);
|
|
// 详细数据列【封装】
|
for (Map<String, Object> map : list) {
|
shellList = new ArrayList<>();
|
shellList.add(DateUtils2.getTime((Date) map.get("createTime")));
|
shellList.add( map.get("realName")+"");
|
shellList.add( map.get("takeName")+"");
|
shellList.add( map.get("takePhone")+"");
|
shellList.add( map.get("takeAddress")+"");
|
dataList.add( shellList);
|
}
|
try {
|
// 调用工具类进行导出
|
ExcelExportUtil.easySheet("导出数据"+ DateUtils2.formatDate(new Date(), "YYYYMMddHHmmSS"), "导出数据", dataList, response);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
|
}
|