|
|
|
@@ -1,25 +1,30 @@ |
|
|
|
package com.simple.service.impl; |
|
|
|
|
|
|
|
import cn.afterturn.easypoi.excel.ExcelExportUtil; |
|
|
|
import cn.afterturn.easypoi.excel.entity.ExportParams; |
|
|
|
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.simple.common.ErrorCode; |
|
|
|
import com.simple.common.IdWorker; |
|
|
|
import com.simple.common.Result; |
|
|
|
import com.simple.common.ResultData; |
|
|
|
import com.simple.domain.po.*; |
|
|
|
import com.simple.domain.vo.WxCouponOrderBVo; |
|
|
|
import com.simple.domain.vo.WxCouponOrderCVo; |
|
|
|
import com.simple.enums.EnumCouponOrderStatus; |
|
|
|
import com.simple.enums.EnumCouponStatus; |
|
|
|
import com.simple.exception.MallinkException; |
|
|
|
import com.simple.mapper.*; |
|
|
|
import com.simple.service.WxCouponOrderService; |
|
|
|
import org.apache.log4j.Logger; |
|
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
|
import org.aspectj.apache.bcel.classfile.ConstantString; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.*; |
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
@@ -206,6 +211,66 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { |
|
|
|
return new ResultData(PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findListOfAdmin(wxCouponOrder))); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void exportData(HttpServletRequest request, HttpServletResponse response, String tenantId) { |
|
|
|
WxCouponOrder wxCouponOrder = new WxCouponOrder(); |
|
|
|
wxCouponOrder.setTenantId(tenantId); |
|
|
|
List<WxCouponOrder> list = wxCouponOrderMapper.findList(wxCouponOrder); |
|
|
|
|
|
|
|
String filepath="./uploads/"; |
|
|
|
File savefile = new File(filepath); |
|
|
|
if (!savefile.exists()) { |
|
|
|
savefile.mkdirs(); |
|
|
|
} |
|
|
|
|
|
|
|
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), WxCouponOrder.class, list); |
|
|
|
FileOutputStream fos = null; |
|
|
|
try { |
|
|
|
String filename=UUID.randomUUID()+".xlsx"; |
|
|
|
filepath=filepath+filename; |
|
|
|
fos = new FileOutputStream(filepath); |
|
|
|
workbook.write(fos); |
|
|
|
fos.close(); |
|
|
|
downFile(filepath,filename,response,request); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void downFile(String filePath,String filename, HttpServletResponse response, |
|
|
|
HttpServletRequest req) throws IOException { |
|
|
|
try { |
|
|
|
response.reset(); |
|
|
|
response.setContentType("bin"); |
|
|
|
String agent = req.getHeader("user-agent"); |
|
|
|
if (agent.contains("Firefox")) { |
|
|
|
response.setHeader("Content-disposition", |
|
|
|
"attachment; filename=" |
|
|
|
+ new String(filename.getBytes("GB2312"), |
|
|
|
"ISO-8859-1")); |
|
|
|
} else { |
|
|
|
response |
|
|
|
.setHeader("Content-disposition", |
|
|
|
"attachment; filename=" |
|
|
|
+ java.net.URLEncoder.encode(filename, |
|
|
|
"UTF-8")); |
|
|
|
} |
|
|
|
// 循环取出流中的数据 |
|
|
|
byte[] b = new byte[1024]; |
|
|
|
int len; |
|
|
|
InputStream inStream = new FileInputStream(filePath); |
|
|
|
while ((len = inStream.read(b)) > 0) |
|
|
|
response.getOutputStream().write(b, 0, len); |
|
|
|
inStream.close(); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) |
|
|
|
public ResultData verify(Long couponOrderId, Long bUserId) { |
|
|
|
|