Merge branch 'mall-amz' of http://120.27.238.55:7000/r/xc-mall into mall-amz
4 files added
13 files modified
| | |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | |
| | | <!--excel读取 --> |
| | | <dependency> |
| | | <groupId>org.apache.commons</groupId> |
| | | <artifactId>commons-csv</artifactId> |
| | | <version>1.5</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi-ooxml</artifactId> |
| | | <version>3.8</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi</artifactId> |
| | | <version>3.8</version> |
| | | </dependency> |
| | | |
| | | <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas --> |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi-ooxml-schemas</artifactId> |
| | | <version>3.8</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
New file |
| | |
| | | package cc.mrbird.febs.common.utils.excl; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 定义表格的数据对象 |
| | | * @author JIANGYOUYAO |
| | | * @email 935090232@qq.com |
| | | * @date 2017年12月20日 |
| | | */ |
| | | public class ExcelSheetPO { |
| | | |
| | | /** |
| | | * sheet的名称 |
| | | */ |
| | | private String sheetName; |
| | | |
| | | |
| | | /** |
| | | * 表格标题 |
| | | */ |
| | | private String title; |
| | | |
| | | /** |
| | | * 头部标题集合 |
| | | */ |
| | | private String[] headers; |
| | | |
| | | /** |
| | | * 数据集合 |
| | | */ |
| | | private List<List<Object>> dataList; |
| | | |
| | | public String getTitle() { |
| | | return title; |
| | | } |
| | | |
| | | public void setTitle(String title) { |
| | | this.title = title; |
| | | } |
| | | |
| | | public String[] getHeaders() { |
| | | return headers; |
| | | } |
| | | |
| | | public void setHeaders(String[] headers) { |
| | | this.headers = headers; |
| | | } |
| | | |
| | | public List<List<Object>> getDataList() { |
| | | return dataList; |
| | | } |
| | | |
| | | public void setDataList(List<List<Object>> dataList) { |
| | | this.dataList = dataList; |
| | | } |
| | | |
| | | public String getSheetName() { |
| | | return sheetName; |
| | | } |
| | | |
| | | public void setSheetName(String sheetName) { |
| | | this.sheetName = sheetName; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.common.utils.excl; |
| | | |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.apache.commons.lang.ArrayUtils; |
| | | import org.apache.poi.hssf.usermodel.HSSFCellStyle; |
| | | import org.apache.poi.hssf.usermodel.HSSFDateUtil; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.apache.poi.ss.util.CellRangeAddress; |
| | | import org.apache.poi.ss.util.WorkbookUtil; |
| | | import org.apache.poi.xssf.streaming.SXSSFWorkbook; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | |
| | | import java.io.*; |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * excel工具类 提供读取和写入excel的功能 |
| | | * |
| | | * @author JIANGYOUYAO |
| | | * @email 935090232@qq.com |
| | | * @date 2017年12月20日 |
| | | */ |
| | | public class ExcelUtil { |
| | | |
| | | /** |
| | | * 标题样式 |
| | | */ |
| | | private final static String STYLE_HEADER = "header"; |
| | | /** |
| | | * 表头样式 |
| | | */ |
| | | private final static String STYLE_TITLE = "title"; |
| | | /** |
| | | * 数据样式 |
| | | */ |
| | | private final static String STYLE_DATA = "data"; |
| | | |
| | | private static String getFileExtName(File file) { |
| | | String fileName = file.getName(); |
| | | String prefix = fileName.substring(fileName.lastIndexOf(".") ); |
| | | return prefix; |
| | | } |
| | | |
| | | /** |
| | | * 读取excel文件里面的内容 支持日期,数字,字符,函数公式,布尔类型 |
| | | * |
| | | * @param file |
| | | * @param rowCount |
| | | * @param columnCount |
| | | * @return |
| | | * @throws FileNotFoundException |
| | | * @throws IOException |
| | | * @author JIANGYOUYAO |
| | | * @email 935090232@qq.com |
| | | * @date 2017年12月20日 |
| | | */ |
| | | public static List<ExcelSheetPO> readExcel(File file, Integer rowCount, Integer columnCount) |
| | | throws FileNotFoundException, IOException { |
| | | |
| | | // 根据后缀名称判断excel的版本 |
| | | String extName = getFileExtName(file); |
| | | Workbook wb = null; |
| | | if (ExcelVersion.V2003.getSuffix().equals(extName)) { |
| | | wb = new HSSFWorkbook(new FileInputStream(file)); |
| | | |
| | | } else if (ExcelVersion.V2007.getSuffix().equals(extName)) { |
| | | wb = new XSSFWorkbook(new FileInputStream(file)); |
| | | |
| | | } else { |
| | | // 无效后缀名称,这里之能保证excel的后缀名称,不能保证文件类型正确,不过没关系,在创建Workbook的时候会校验文件格式 |
| | | throw new IllegalArgumentException("Invalid excel version"); |
| | | } |
| | | // 开始读取数据 |
| | | List<ExcelSheetPO> sheetPOs = new ArrayList<>(); |
| | | // 解析sheet |
| | | for (int i = 0; i < wb.getNumberOfSheets(); i++) { |
| | | Sheet sheet = wb.getSheetAt(i); |
| | | List<List<Object>> dataList = new ArrayList<>(); |
| | | ExcelSheetPO sheetPO = new ExcelSheetPO(); |
| | | sheetPO.setSheetName(sheet.getSheetName()); |
| | | sheetPO.setDataList(dataList); |
| | | int readRowCount = 0; |
| | | if (rowCount == null || rowCount > sheet.getPhysicalNumberOfRows()) { |
| | | readRowCount = sheet.getPhysicalNumberOfRows(); |
| | | } else { |
| | | readRowCount = rowCount; |
| | | } |
| | | // 解析sheet 的行 |
| | | for (int j = sheet.getFirstRowNum(); j < readRowCount; j++) { |
| | | Row row = sheet.getRow(j); |
| | | if (row == null) { |
| | | continue; |
| | | } |
| | | if (row.getFirstCellNum() < 0) { |
| | | continue; |
| | | } |
| | | int readColumnCount = 0; |
| | | if (columnCount == null || columnCount > row.getLastCellNum()) { |
| | | readColumnCount = (int) row.getLastCellNum(); |
| | | } else { |
| | | readColumnCount = columnCount; |
| | | } |
| | | List<Object> rowValue = new LinkedList<Object>(); |
| | | // 解析sheet 的列 |
| | | for (int k = 0; k < readColumnCount; k++) { |
| | | Cell cell = row.getCell(k); |
| | | rowValue.add(getCellValue(wb, cell)); |
| | | } |
| | | dataList.add(rowValue); |
| | | } |
| | | sheetPOs.add(sheetPO); |
| | | } |
| | | return sheetPOs; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | private static Object getCellValue(Workbook wb, Cell cell) { |
| | | Object columnValue = null; |
| | | if (cell != null) { |
| | | // 格式化 number |
| | | DecimalFormat df = new DecimalFormat("0"); |
| | | // String |
| | | // 字符 |
| | | // 格式化日期字符串 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // 格式化数字 |
| | | DecimalFormat nf = new DecimalFormat("0.00"); |
| | | switch (cell.getCellType()) { |
| | | case Cell.CELL_TYPE_STRING: |
| | | columnValue = cell.getStringCellValue(); |
| | | break; |
| | | case Cell.CELL_TYPE_NUMERIC: |
| | | if ("@".equals(cell.getCellStyle().getDataFormatString())) { |
| | | columnValue = df.format(cell.getNumericCellValue()); |
| | | } else if ("General".equals(cell.getCellStyle().getDataFormatString())) { |
| | | columnValue = nf.format(cell.getNumericCellValue()); |
| | | } else { |
| | | columnValue = sdf.format(HSSFDateUtil.getJavaDate(cell.getNumericCellValue())); |
| | | } |
| | | break; |
| | | case Cell.CELL_TYPE_BOOLEAN: |
| | | columnValue = cell.getBooleanCellValue(); |
| | | break; |
| | | case Cell.CELL_TYPE_BLANK: |
| | | columnValue = ""; |
| | | break; |
| | | case Cell.CELL_TYPE_FORMULA: |
| | | // 格式单元格 |
| | | FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator(); |
| | | evaluator.evaluateFormulaCell(cell); |
| | | CellValue cellValue = evaluator.evaluate(cell); |
| | | columnValue = cellValue.getNumberValue(); |
| | | break; |
| | | default: |
| | | columnValue = cell.toString(); |
| | | } |
| | | } |
| | | return columnValue; |
| | | } |
| | | |
| | | /** |
| | | * 在硬盘上写入excel文件 |
| | | * |
| | | * @param version |
| | | * @param excelSheets |
| | | * @param filePath |
| | | * @throws IOException |
| | | * @author JIANGYOUYAO |
| | | * @email 935090232@qq.com |
| | | * @date 2017年12月20日 |
| | | */ |
| | | public static void createWorkbookAtDisk(ExcelVersion version, List<ExcelSheetPO> excelSheets, String filePath) |
| | | throws IOException { |
| | | FileOutputStream fileOut = new FileOutputStream(filePath); |
| | | createWorkbookAtOutStream(version, excelSheets, fileOut, true); |
| | | } |
| | | |
| | | /** |
| | | * 把excel表格写入输出流中 |
| | | * |
| | | * @param version |
| | | * @param excelSheets |
| | | * @param outStream |
| | | * @param closeStream 是否关闭输出流 |
| | | * @throws IOException |
| | | * @author JIANGYOUYAO |
| | | * @email 935090232@qq.com |
| | | * @date 2017年12月20日 |
| | | */ |
| | | public static void createWorkbookAtOutStream(ExcelVersion version, List<ExcelSheetPO> excelSheets, |
| | | OutputStream outStream, boolean closeStream) throws IOException { |
| | | if (CollectionUtils.isNotEmpty(excelSheets)) { |
| | | Workbook wb = createWorkBook(version, excelSheets); |
| | | wb.write(outStream); |
| | | if (closeStream) { |
| | | outStream.close(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private static Workbook createWorkBook(ExcelVersion version, List<ExcelSheetPO> excelSheets) { |
| | | Workbook wb = getWorkbookInstance(version); |
| | | for (int i = 0; i < excelSheets.size(); i++) { |
| | | ExcelSheetPO excelSheetPO = excelSheets.get(i); |
| | | if (excelSheetPO.getSheetName() == null) { |
| | | excelSheetPO.setSheetName("sheet" + i); |
| | | } |
| | | // 过滤特殊字符 |
| | | Sheet tempSheet = wb.createSheet(WorkbookUtil.createSafeSheetName(excelSheetPO.getSheetName())); |
| | | buildSheetData(wb, tempSheet, excelSheetPO, version); |
| | | } |
| | | return wb; |
| | | } |
| | | |
| | | private static void buildSheetData(Workbook wb, Sheet sheet, ExcelSheetPO excelSheetPO, ExcelVersion version) { |
| | | sheet.setDefaultRowHeight((short) 400); |
| | | sheet.setDefaultColumnWidth((short) 10); |
| | | createTitle(sheet, excelSheetPO, wb, version); |
| | | createHeader(sheet, excelSheetPO, wb, version); |
| | | createBody(sheet, excelSheetPO, wb, version); |
| | | } |
| | | |
| | | private static void createBody(Sheet sheet, ExcelSheetPO excelSheetPO, Workbook wb, ExcelVersion version) { |
| | | List<List<Object>> dataList = excelSheetPO.getDataList(); |
| | | for (int i = 0; i < dataList.size() && i < version.getMaxRow(); i++) { |
| | | List<Object> values = dataList.get(i); |
| | | Row row = sheet.createRow(2 + i); |
| | | for (int j = 0; j < values.size() && j < version.getMaxColumn(); j++) { |
| | | Cell cell = row.createCell(j); |
| | | Object value = values.get(j); |
| | | if (value == null) { |
| | | value = ""; |
| | | } |
| | | cell.setCellValue(String.valueOf(value)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private static void createHeader(Sheet sheet, ExcelSheetPO excelSheetPO, Workbook wb, ExcelVersion version) { |
| | | String[] headers = excelSheetPO.getHeaders(); |
| | | Row row = sheet.createRow(1); |
| | | for (int i = 0; i < headers.length && i < version.getMaxColumn(); i++) { |
| | | Cell cellHeader = row.createCell(i); |
| | | cellHeader.setCellStyle(getStyle(STYLE_HEADER, wb)); |
| | | cellHeader.setCellValue(headers[i]); |
| | | } |
| | | |
| | | } |
| | | |
| | | private static void createTitle(Sheet sheet, ExcelSheetPO excelSheetPO, Workbook wb, ExcelVersion version) { |
| | | Row titleRow = sheet.createRow(0); |
| | | Cell titleCel = titleRow.createCell(0); |
| | | titleCel.setCellValue(excelSheetPO.getTitle()); |
| | | titleCel.setCellStyle(getStyle(STYLE_TITLE, wb)); |
| | | // 限制最大列数 |
| | | if (ArrayUtil.isNotEmpty(excelSheetPO.getHeaders())) { |
| | | int column = excelSheetPO.getHeaders().length > version.getMaxColumn() ? version.getMaxColumn() |
| | | : excelSheetPO.getHeaders().length; |
| | | sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, column - 1)); |
| | | } |
| | | |
| | | } |
| | | |
| | | private static CellStyle getStyle(String type, Workbook wb) { |
| | | |
| | | HashMap<String, CellStyle> cellStyleMap = new HashMap<>(); |
| | | if (cellStyleMap.containsKey(type)) { |
| | | return cellStyleMap.get(type); |
| | | } |
| | | // 生成一个样式 |
| | | CellStyle style = wb.createCellStyle(); |
| | | // style.setBorderBottom(HSSFCellStyle.BORDER_THIN); |
| | | // style.setBorderLeft(HSSFCellStyle.BORDER_THIN); |
| | | // style.setBorderRight(HSSFCellStyle.BORDER_THIN); |
| | | // style.setBorderTop(HSSFCellStyle.BORDER_THIN); |
| | | style.setWrapText(true); |
| | | |
| | | if (STYLE_HEADER == type) { |
| | | style.setAlignment(HSSFCellStyle.ALIGN_CENTER); |
| | | Font font = wb.createFont(); |
| | | font.setFontHeightInPoints((short) 16); |
| | | font.setBoldweight(Font.BOLDWEIGHT_BOLD); |
| | | style.setFont(font); |
| | | } else if (STYLE_TITLE == type) { |
| | | style.setAlignment(HSSFCellStyle.ALIGN_CENTER); |
| | | Font font = wb.createFont(); |
| | | font.setFontHeightInPoints((short) 18); |
| | | font.setBoldweight(Font.BOLDWEIGHT_BOLD); |
| | | style.setFont(font); |
| | | } else if (STYLE_DATA == type) { |
| | | style.setAlignment(HSSFCellStyle.ALIGN_LEFT); |
| | | Font font = wb.createFont(); |
| | | font.setFontHeightInPoints((short) 12); |
| | | style.setFont(font); |
| | | } |
| | | cellStyleMap.put(type, style); |
| | | return style; |
| | | } |
| | | |
| | | private static Workbook getWorkbookInstance(ExcelVersion version) { |
| | | switch (version) { |
| | | case V2003: |
| | | return new HSSFWorkbook(); |
| | | case V2007: |
| | | return new XSSFWorkbook(); |
| | | case V_BIGDATA: |
| | | return new SXSSFWorkbook(2000); |
| | | default: |
| | | throw new IllegalArgumentException("param is not defind"); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.common.utils.excl; |
| | | |
| | | /** |
| | | * excel版本枚举 |
| | | * |
| | | * @author JIANGYOUYAO |
| | | * @email 935090232@qq.com |
| | | * @date 2017年12月20日 |
| | | */ |
| | | public enum ExcelVersion { |
| | | |
| | | /** |
| | | * 虽然V2007版本支持最大支持1048575 * 16383 , |
| | | * V2003版支持65535*255 |
| | | * 但是在实际应用中如果使用如此庞大的对象集合会导致内存溢出, |
| | | * 因此这里限制最大为10000*100,如果还要加大建议先通过单元测试进行性能测试。 |
| | | * 1000*100 全部导出预计时间为27s左右 |
| | | */ |
| | | V2003(".xls", 65535, 100), V2007(".xlsx", 65535, 100), V_BIGDATA(".xlsx", 5048576, 16384); |
| | | |
| | | private String suffix; |
| | | |
| | | private int maxRow; |
| | | |
| | | private int maxColumn; |
| | | |
| | | ExcelVersion(String suffix, int maxRow, int maxColumn) { |
| | | this.suffix = suffix; |
| | | this.maxRow = maxRow; |
| | | this.maxColumn = maxColumn; |
| | | } |
| | | |
| | | public String getSuffix() { |
| | | return this.suffix; |
| | | } |
| | | |
| | | public int getMaxRow() { |
| | | return maxRow; |
| | | } |
| | | |
| | | |
| | | public int getMaxColumn() { |
| | | return maxColumn; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.common.utils.excl; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | public class ResponseHeadUtil { |
| | | |
| | | /** |
| | | * 设置文件头部 |
| | | * @param response |
| | | */ |
| | | public static HttpServletResponse setExcelHead(HttpServletResponse response) { |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setHeader("content-type", "application/octet-stream;charset=UTF-8"); |
| | | response.setContentType("application/octet-stream;charset=UTF-8"); |
| | | return response; |
| | | } |
| | | |
| | | } |
| | |
| | | import cc.mrbird.febs.generator.mapper.GeneratorConfigMapper; |
| | | import cc.mrbird.febs.generator.service.IGeneratorConfigService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.utils.excl.ExcelSheetPO; |
| | | import cc.mrbird.febs.common.utils.excl.ExcelUtil; |
| | | import cc.mrbird.febs.common.utils.excl.ExcelVersion; |
| | | import cc.mrbird.febs.common.utils.excl.ResponseHeadUtil; |
| | | import cc.mrbird.febs.mall.dto.*; |
| | | import cc.mrbird.febs.mall.entity.*; |
| | | import cc.mrbird.febs.mall.mapper.MallOrderRefundOperationMapper; |
| | |
| | | import cc.mrbird.febs.mall.vo.AdminAddAddressTreeVo; |
| | | import cc.mrbird.febs.mall.vo.AdminMallOrderRefundAddressVo; |
| | | import cc.mrbird.febs.system.entity.Dept; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.io.*; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | |
| | | /** |
| | | * 订单列表 |
| | | * |
| | | * @param mallOrderInfo |
| | | * @param request |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 订单列表-取消订单 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 订单退款-列表 |
| | | * |
| | | * @param mallOrderRefundDto |
| | | * @param request |
| | | * @return |
| | |
| | | * 订单退款-详情 |
| | | */ |
| | | @GetMapping("/seeRefund") |
| | | public FebsResponse seeRefund(QueryRequest request, MallOrderRefund mallOrderRefund,Integer parentId) { |
| | | if(parentId==null){ |
| | | ViewMallOrderController.idFromRefund=0; |
| | | public FebsResponse seeRefund(QueryRequest request, MallOrderRefund mallOrderRefund, Integer parentId) { |
| | | if (parentId == null) { |
| | | ViewMallOrderController.idFromRefund = 0; |
| | | } |
| | | mallOrderRefund.setId(ViewMallOrderController.idFromRefund); |
| | | Map<String, Object> dataTable = getDataTable(adminMallOrderService.seeRefund(request, mallOrderRefund)); |
| | |
| | | |
| | | /** |
| | | * 订单退款-同意 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 订单退款-拒绝 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 订单退款-退款确认 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 订单退款地址-列表 |
| | | * |
| | | * @param mallOrderRefundAddressDto |
| | | * @param request |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 订单退款地址-删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | */ |
| | | @GetMapping("addAddress/tree") |
| | | @ControllerEndpoint(exceptionMessage = "获取地址失败") |
| | | public List<AdminAddAddressTreeVo> getRefundAddress(){ |
| | | public List<AdminAddAddressTreeVo> getRefundAddress() { |
| | | return adminMallOrderService.getRefundAddress(); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 商家支付方式-列表 |
| | | * |
| | | * @param payMethodDto |
| | | * @param request |
| | | * @return |
| | |
| | | return adminMallOrderService.payMethodEdit(payMethodEditDto); |
| | | } |
| | | |
| | | @GetMapping("exportOrderList") |
| | | @ControllerEndpoint(operation = "订单列表", exceptionMessage = "导出失败") |
| | | public FebsResponse exportOrderList(MallOrderInfo mallOrderInfo, HttpServletResponse response) throws IOException { |
| | | |
| | | List<ExcelSheetPO> res = new ArrayList<>(); |
| | | ExcelSheetPO orderSheet = new ExcelSheetPO(); |
| | | String title = "订单列表"; |
| | | orderSheet.setSheetName(title); |
| | | orderSheet.setTitle(title); |
| | | String[] header = {"订单编号", "订单金额", "下单时间", "配送方式", "收货姓名", "收货电话", "收货地址", "商品名称", "订单状态", "物流单号", "物流公司", "物流公司码"}; |
| | | orderSheet.setHeaders(header); |
| | | |
| | | QueryRequest request = new QueryRequest(); |
| | | request.setPageNum(1); |
| | | request.setPageSize(9999); |
| | | List<MallOrderInfo> dataList = adminMallOrderService.findOrderListInPage(mallOrderInfo, request).getRecords(); |
| | | List<List<Object>> list = new ArrayList<>(); |
| | | if (dataList.size() > 0) { |
| | | for (MallOrderInfo item : dataList) { |
| | | List<Object> temp = new ArrayList<>(); |
| | | temp.add(item.getOrderNo()); |
| | | temp.add(item.getAmount()); |
| | | temp.add(DateUtil.format(item.getOrderTime(), "yyyy-MM-dd HH:mm:ss")); |
| | | temp.add("快递配送"); |
| | | temp.add(item.getName()); |
| | | temp.add(item.getPhone()); |
| | | temp.add(item.getAddress()); |
| | | if (CollUtil.isNotEmpty(item.getItems())) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | |
| | | for (MallOrderItem itemItem : item.getItems()) { |
| | | if (StrUtil.isNotBlank(sb)) { |
| | | sb.append(";" + itemItem.getGoodsName() + "*" + itemItem.getCnt()); |
| | | } else { |
| | | sb.append(itemItem.getGoodsName() + "*" + itemItem.getCnt()); |
| | | } |
| | | } |
| | | temp.add(sb.toString()); |
| | | } else { |
| | | temp.add(""); |
| | | } |
| | | |
| | | temp.add(item.getStatus()); |
| | | list.add(temp); |
| | | } |
| | | } |
| | | orderSheet.setDataList(list); |
| | | res.add(orderSheet); |
| | | response = ResponseHeadUtil.setExcelHead(response); |
| | | response.setHeader("Content-Disposition", |
| | | "attachment;filename=" + URLEncoder.encode(title + DateUtil.format(new Date(), "yyyyMMDDHHmmss") + ".xlsx".trim(), "UTF-8")); |
| | | OutputStream os = response.getOutputStream(); |
| | | ExcelUtil.createWorkbookAtOutStream(ExcelVersion.V2007, res, os, true); |
| | | return null; |
| | | } |
| | | |
| | | @PostMapping(value = "/importDeliver") |
| | | @ControllerEndpoint(operation = "导入发货", exceptionMessage = "导入失败") |
| | | public FebsResponse importDeliver(@RequestBody MultipartFile file) throws IOException { |
| | | if (file.isEmpty()) { |
| | | return new FebsResponse().fail(); |
| | | } |
| | | |
| | | String fileName = file.getOriginalFilename(); |
| | | String dirPath = "/Users/helius/Documents/"; |
| | | |
| | | File saveFile = new File(new File(dirPath).getAbsolutePath() + File.separator + fileName); |
| | | if (!saveFile.exists()) { |
| | | if (!saveFile.getParentFile().exists()) { |
| | | saveFile.getParentFile().mkdirs(); |
| | | } |
| | | } |
| | | |
| | | file.transferTo(saveFile); |
| | | |
| | | List<ExcelSheetPO> data = ExcelUtil.readExcel(saveFile, null, null); |
| | | if (CollUtil.isEmpty(data)) { |
| | | return new FebsResponse().fail(); |
| | | } |
| | | |
| | | List<List<Object>> dataList = data.get(0).getDataList(); |
| | | |
| | | int expressNoIndex = -1; |
| | | int expressComIndex = -1; |
| | | int expressCodeIndex = -1; |
| | | for (int i = 1; i < dataList.size(); i++) { |
| | | List<Object> objects = dataList.get(i); |
| | | |
| | | String expressNo = ""; |
| | | String expressCode = ""; |
| | | String expressCom = ""; |
| | | for (int j = 0; j < objects.size(); j++) { |
| | | Object obj = objects.get(j); |
| | | if ("物流单号".equals(obj)) { |
| | | expressNoIndex = j; |
| | | } |
| | | |
| | | if ("物流公司".equals(obj)) { |
| | | expressComIndex = j; |
| | | } |
| | | |
| | | if ("物流公司码".equals(obj)) { |
| | | expressCodeIndex = j; |
| | | } |
| | | |
| | | if (j == expressNoIndex) { |
| | | expressNo = (String) objects.get(j); |
| | | } |
| | | |
| | | if (j == expressComIndex) { |
| | | expressCom = (String) objects.get(j); |
| | | } |
| | | |
| | | if (j == expressCodeIndex) { |
| | | expressCode = (String) objects.get(j);; |
| | | } |
| | | |
| | | } |
| | | |
| | | if (StrUtil.isNotBlank(expressNo) && StrUtil.isNotBlank(expressCode) && StrUtil.isNotBlank(expressCom)) { |
| | | String orderNo = (String) objects.get(0); |
| | | |
| | | DeliverGoodsDto deliverGoods = new DeliverGoodsDto(); |
| | | deliverGoods.setOrderNo(orderNo); |
| | | deliverGoods.setExpressCom(expressCom); |
| | | deliverGoods.setExpressCode(expressCode); |
| | | deliverGoods.setExpressNo(expressNo); |
| | | adminMallOrderService.deliverGoodsByOrderNo(deliverGoods); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | private String expressCom; |
| | | |
| | | private String expressCode; |
| | | |
| | | private String orderNo; |
| | | |
| | | } |
| | |
| | | private String expressNo; |
| | | |
| | | private String expressCom; |
| | | |
| | | private String expressCode; |
| | | } |
| | |
| | | **/ |
| | | public interface MallOrderInfoMapper extends BaseMapper<MallOrderInfo> { |
| | | |
| | | IPage<MallOrderInfo> selectInPage(@Param("record") MallOrderInfo mallOrderInfo, IPage<MallOrderInfo> page); |
| | | |
| | | MallOrderInfo selectOrderByMemberIdAndId(@Param("memberId") Long memberId, @Param("id") Long id); |
| | | |
| | | IPage<AdminMallOrderInfoVo> selectOrderListInPage(Page<AdminMallOrderInfoVo> page, @Param("record") MallOrderInfoDto mallOrderInfo); |
| | |
| | | BigDecimal selectTotalAmount(@Param("memberId") Long memberId); |
| | | |
| | | BigDecimal selectTotalAmountForDate(@Param("date") Date date, @Param("member") Long memberId); |
| | | |
| | | MallOrderInfo selectByOrderNo(@Param("orderNo") String orderNo); |
| | | } |
| | |
| | | |
| | | public interface IAdminMallOrderService extends IService<MallOrderInfo> { |
| | | |
| | | IPage<MallOrderInfo> findOrderListInPage(MallOrderInfo mallOrderInfo, QueryRequest request); |
| | | |
| | | IPage<AdminMallOrderInfoVo> getOrderListInPage(MallOrderInfoDto mallOrderInfo, QueryRequest request); |
| | | |
| | | AdminMallOrderVo getMallOrderInfoById(long id); |
| | | |
| | | FebsResponse deliverGoods(DeliverGoodsDto deliverGoodsDto); |
| | | |
| | | void deliverGoodsByOrderNo(DeliverGoodsDto deliverGoodsDto); |
| | | |
| | | AdminOrderDetailVo getMallOrderDetailById(long id); |
| | | |
| | | IPage<AdminMallOrderRefundVo> getRefundListInPage(MallOrderRefundDto mallOrderRefundDto, QueryRequest request); |
| | |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | |
| | | @Override |
| | | public IPage<MallOrderInfo> findOrderListInPage(MallOrderInfo mallOrderInfo, QueryRequest request) { |
| | | Page<MallOrderInfo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | return this.baseMapper.selectInPage(mallOrderInfo, page); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<AdminMallOrderInfoVo> getOrderListInPage(MallOrderInfoDto mallOrderInfo, QueryRequest request) { |
| | | Page<AdminMallOrderInfoVo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | IPage<AdminMallOrderInfoVo> adminMallOrderInfoVos = this.baseMapper.selectOrderListInPage(page, mallOrderInfo); |
| | |
| | | return adminMallMemberPaymentVo; |
| | | } |
| | | |
| | | @Override |
| | | public void deliverGoodsByOrderNo(DeliverGoodsDto deliverGoodsDto) { |
| | | MallOrderInfo mallOrderInfo = mallOrderInfoMapper.selectByOrderNo(deliverGoodsDto.getOrderNo()); |
| | | if (mallOrderInfo == null) { |
| | | return; |
| | | } |
| | | |
| | | MallExpressInfo mallExpressInfo = new MallExpressInfo(); |
| | | mallExpressInfo.setMemberId(mallOrderInfo.getMemberId()); |
| | | mallExpressInfo.setOrderId(mallOrderInfo.getId()); |
| | | mallExpressInfo.setExpressNo(deliverGoodsDto.getExpressNo()); |
| | | mallExpressInfo.setExpressCom(deliverGoodsDto.getExpressCom()); |
| | | mallExpressInfo.setExpressCode(deliverGoodsDto.getExpressCode()); |
| | | mallExpressInfoMapper.insert(mallExpressInfo); |
| | | |
| | | mallOrderInfo.setStatus(3); |
| | | mallOrderInfoMapper.updateById(mallOrderInfo); |
| | | } |
| | | } |
| | |
| | | import cc.mrbird.febs.monitor.entity.ActiveUser; |
| | | import cc.mrbird.febs.monitor.service.ISessionService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | |
| | | List<ActiveUser> list = sessionService.list(username); |
| | | Map<String, Object> data = new HashMap<>(2); |
| | | data.put("rows", list); |
| | | data.put("total", CollectionUtils.size(list)); |
| | | data.put("total", list.size()); |
| | | return new FebsResponse().success().data(data); |
| | | } |
| | | |
| | |
| | | import com.wuwenze.poi.pojo.ExcelErrorField; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cc.mrbird.febs.mall.mapper.MallOrderInfoMapper"> |
| | | |
| | | <select id="selectInPage" resultMap="OrderInfoMap"> |
| | | select |
| | | a.*, |
| | | b.id item_id, |
| | | b.order_id, |
| | | b.goods_id, |
| | | b.sku_id, |
| | | b.goods_name, |
| | | b.style_name, |
| | | b.sku_name, |
| | | b.sku_image, |
| | | b.cnt, |
| | | b.price, |
| | | b.amount |
| | | from mall_order_info a |
| | | inner join mall_order_item b on a.id=b.order_id |
| | | <where> |
| | | a.del_flag=2 |
| | | <if test="record.status == 4 and record.status != 0"> |
| | | and a.status in (5,6) |
| | | </if> |
| | | <if test="record.status != 4 and record.status != 0 and record.status != 5"> |
| | | and a.status = #{record.status} |
| | | </if> |
| | | <if test="record.status == 5"> |
| | | and a.status = 7 |
| | | </if> |
| | | <if test="record.memberId != null"> |
| | | and a.member_id=#{record.memberId} |
| | | </if> |
| | | <if test="record.orderType != null"> |
| | | and a.order_type=#{record.orderType} |
| | | </if> |
| | | </where> |
| | | order by a.created_time desc |
| | | </select> |
| | | |
| | | <select id="selectOrderByMemberIdAndId" resultType="cc.mrbird.febs.mall.entity.MallOrderInfo"> |
| | | select * from mall_order_info where member_id=#{memberId} and id=#{id} |
| | | </select> |
| | |
| | | and date_format(a.receving_time, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d') |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="selectByOrderNo" resultType="cc.mrbird.febs.mall.entity.MallOrderInfo"> |
| | | select * from mall_order_info where order_no=#{orderNo} |
| | | </select> |
| | | </mapper> |
| | |
| | | <a lay-event="edit" shiro:hasPermission="user:update"><i |
| | | class="layui-icon febs-edit-area febs-blue"></i></a> |
| | | </script> |
| | | <script type="text/html" id="tableToolBar"> |
| | | <div class="layui-btn-container"> |
| | | <button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" lay-event="exportDeliver">导出未发货订单</button> |
| | | <button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" id="importDeliver" lay-event="importDeliver">导入发货</button> |
| | | </div> |
| | | </script> |
| | | <!-- 表格操作栏 end --> |
| | | <script data-th-inline="none" type="text/javascript"> |
| | | // 引入组件并初始化 |
| | | layui.use([ 'jquery', 'form', 'table', 'febs'], function () { |
| | | layui.use([ 'jquery', 'form', 'table', 'febs', 'upload'], function () { |
| | | var $ = layui.jquery, |
| | | febs = layui.febs, |
| | | form = layui.form, |
| | | table = layui.table, |
| | | upload = layui.upload, |
| | | $view = $('#febs-order'), |
| | | $query = $view.find('#query'), |
| | | $reset = $view.find('#reset'), |
| | |
| | | |
| | | // 表格初始化 |
| | | initTable(); |
| | | |
| | | table.on('toolbar(orderTable)', function(obj){ |
| | | var event = obj.event; |
| | | |
| | | if (event == 'exportDeliver') { |
| | | window.location.href = ctx + "admin/order/exportOrderList?orderType=1&status=2"; |
| | | } |
| | | }); |
| | | |
| | | upload.render({ |
| | | elem: '#importDeliver' |
| | | ,url: 'admin/order/importDeliver' //此处配置你自己的上传接口即可 |
| | | ,accept: 'file' //普通文件 |
| | | ,done: function(res){ |
| | | console.log("123"); |
| | | } |
| | | }); |
| | | |
| | | // 初始化表格操作栏各个按钮功能 |
| | | table.on('tool(orderTable)', function (obj) { |
| | |
| | | elem: $view.find('table'), |
| | | id: 'orderTable', |
| | | url: ctx + 'admin/order/orderList?orderType=1', |
| | | defaultToolbar: [], |
| | | toolbar: '#tableToolBar', |
| | | cols: [[ |
| | | {field: 'orderNo', title: '订单编号', minWidth: 200,align:'left'}, |
| | | {field: 'memberName', title: '购买人', minWidth: 120,align:'left'}, |
| | |
| | | {field: 'memberBindPhone', title: '联系方式', minWidth: 120,align:'left'}, |
| | | {field: 'amount', title: '订单金额', minWidth: 120,align:'left'}, |
| | | {field: 'orderTime', title: '下单时间', minWidth: 200,align:'left'}, |
| | | {field: 'payMethod', title: '支付方式', minWidth: 120,align:'left'}, |
| | | {field: 'payTime', title: '支付时间', minWidth: 200,align:'left'}, |
| | | {field: 'payOrderNo', title: '支付订单号', minWidth: 200,align:'left'}, |
| | | {field: 'payImage', title: '支付凭证', |
| | | templet: function (d) { |
| | | return '<a lay-event="seePayImage"><img id="seePayImage'+d.id+'" src="'+d.payImage+'" alt=""></a>'; |
| | | }, minWidth: 100,align:'center'}, |
| | | {field: 'status', title: '状态', |
| | | templet: function (d) { |
| | | if (d.status === 1) { |
| | |
| | | return '' |
| | | } |
| | | }, minWidth: 80,align:'center'}, |
| | | {title: '操作', |
| | | templet: function (d) { |
| | | // if(d.payMethod === '支付宝支付' || d.payMethod === '微信支付'){ |
| | | // if (d.status === 2) { |
| | | // return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="deliverGoods" shiro:hasPermission="user:update">发货</button>' |
| | | // +'<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="cancelOrder" shiro:hasPermission="user:update">取消订单</button>' |
| | | // +'<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="seeOrder" shiro:hasPermission="user:update">详情</button>' |
| | | // }else{ |
| | | // return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="seeOrder" shiro:hasPermission="user:update">详情</button>' |
| | | // } |
| | | // }else{ |
| | | if (d.status === 2) { |
| | | return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="deliverGoods" shiro:hasPermission="user:update">发货</button>' |
| | | +'<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="seeOrder" shiro:hasPermission="user:update">详情</button>' |
| | | }else{ |
| | | return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="seeOrder" shiro:hasPermission="user:update">详情</button>' |
| | | } |
| | | // } |
| | | },minWidth: 300,align:'center'} |
| | | {field: 'payMethod', title: '支付方式', minWidth: 120,align:'left'}, |
| | | {field: 'payTime', title: '支付时间', minWidth: 200,align:'left'}, |
| | | {field: 'payOrderNo', title: '支付订单号', minWidth: 200,align:'left'}, |
| | | {title: '操作', |
| | | templet: function (d) { |
| | | if (d.status === 2) { |
| | | return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="deliverGoods" shiro:hasPermission="user:update">发货</button>' |
| | | +'<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="seeOrder" shiro:hasPermission="user:update">详情</button>' |
| | | }else{ |
| | | return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="seeOrder" shiro:hasPermission="user:update">详情</button>' |
| | | } |
| | | // } |
| | | },minWidth: 200,align:'center', fixed:'right'} |
| | | ]] |
| | | }); |
| | | } |
| | |
| | | <a lay-event="edit" shiro:hasPermission="user:update"><i |
| | | class="layui-icon febs-edit-area febs-blue"></i></a> |
| | | </script> |
| | | <script type="text/html" id="tableToolBar"> |
| | | <div class="layui-btn-container"> |
| | | <button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" lay-event="exportDeliver">导出未发货订单</button> |
| | | <button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" id="importDeliver" lay-event="importDeliver">导入发货</button> |
| | | </div> |
| | | </script> |
| | | <!-- 表格操作栏 end --> |
| | | <script data-th-inline="none" type="text/javascript"> |
| | | // 引入组件并初始化 |
| | |
| | | |
| | | // 表格初始化 |
| | | initTable(); |
| | | |
| | | table.on('toolbar(orderTable)', function(obj){ |
| | | var event = obj.event; |
| | | |
| | | if (event == 'exportDeliver') { |
| | | window.location.href = ctx + "admin/order/exportOrderList?orderType=2&status=2"; |
| | | } |
| | | }); |
| | | |
| | | // 初始化表格操作栏各个按钮功能 |
| | | table.on('tool(orderTable)', function (obj) { |
| | |
| | | elem: $view.find('table'), |
| | | id: 'orderTable', |
| | | url: ctx + 'admin/order/orderList?orderType=2', |
| | | defaultToolbar: [], |
| | | toolbar: '#tableToolBar', |
| | | cols: [[ |
| | | {field: 'orderNo', title: '订单编号', minWidth: 200,align:'left'}, |
| | | {field: 'memberName', title: '购买人', minWidth: 120,align:'left'}, |