diff --git a/buyer-api/src/main/java/cn/lili/controller/other/AppVersionBuyerController.java b/buyer-api/src/main/java/cn/lili/controller/other/AppVersionBuyerController.java index 48e1051b..9c5473a7 100644 --- a/buyer-api/src/main/java/cn/lili/controller/other/AppVersionBuyerController.java +++ b/buyer-api/src/main/java/cn/lili/controller/other/AppVersionBuyerController.java @@ -39,7 +39,7 @@ public class AppVersionBuyerController { return ResultUtil.data(appVersionService.getAppVersion(appType)); } - @ApiOperation(value = "获取版本号") + @ApiOperation(value = "获取版本号列表") @ApiImplicitParam(name = "appType", value = "app类型", required = true, paramType = "path") @GetMapping("/appVersion/{type}") public ResultMessage> appVersion(PageVO pageVO, @PathVariable String appType) { diff --git a/config/application.yml b/config/application.yml index f047b72f..30affa8b 100644 --- a/config/application.yml +++ b/config/application.yml @@ -249,7 +249,7 @@ lili: # jwt 细节设定 jwt-setting: # token过期时间(分钟) - tokenExpireTime: 1 + tokenExpireTime: 30 # 使用Spring @Cacheable注解失效时间 cache: diff --git a/consumer/src/main/resources/application.yml b/consumer/src/main/resources/application.yml index 6f2f7746..0e110495 100644 --- a/consumer/src/main/resources/application.yml +++ b/consumer/src/main/resources/application.yml @@ -46,7 +46,7 @@ spring: open-in-view: false # Redis redis: - host: 127.0.0.1 + host: 192.168.0.116 port: 6379 password: lilishop lettuce: diff --git a/framework/pom.xml b/framework/pom.xml index f9842efd..4873ab05 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -45,8 +45,8 @@ 2.3.1 1.21 1.2 - 5.0.0 - 5.0.0 + 4.1.2 + 4.1.2 6.6 3.4.1 1.7.28 diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dto/ExcelDTO.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dto/ExcelDTO.java new file mode 100644 index 00000000..4a4745d3 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dto/ExcelDTO.java @@ -0,0 +1,21 @@ +package cn.lili.modules.order.order.entity.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author liushuai(liushuai711 @ gmail.com) + * @version v4.1 + * @Description: + * @since 2021/6/13 2:37 下午 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ExcelDTO { + + private String sn; + private String logisticsName; + private String logisticsNo; +} diff --git a/framework/src/main/java/cn/lili/modules/order/order/service/OrderService.java b/framework/src/main/java/cn/lili/modules/order/order/service/OrderService.java index c32f916e..083c7281 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/service/OrderService.java +++ b/framework/src/main/java/cn/lili/modules/order/order/service/OrderService.java @@ -14,6 +14,7 @@ import cn.lili.modules.statistics.model.dto.StatisticsQueryParam; import cn.lili.modules.system.entity.vo.Traces; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.util.List; @@ -195,11 +196,20 @@ public interface OrderService extends IService { */ void agglomeratePintuanOrder(String pintuanId, String parentOrderSn); + /** + * 获取待发货订单编号列表 + * + * @param response + * @param logisticsName 店铺已选择物流公司列表 + * @return 待发货订单编号列表 + */ + void getBatchDeliverList(HttpServletResponse response, List logisticsName); + /** * 订单批量发货 * - * @param list 批量发货列表 + * @param files 文件 */ - void batchDeliver(List list); + void batchDeliver(MultipartFile files); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java index 1411afbf..4e091eab 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/OrderServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.json.JSONUtil; +import cn.hutool.poi.excel.ExcelReader; import cn.hutool.poi.excel.ExcelUtil; import cn.hutool.poi.excel.ExcelWriter; import cn.lili.common.aop.syslog.annotation.SystemLogPoint; @@ -69,11 +70,13 @@ import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -501,11 +504,61 @@ public class OrderServiceImpl extends ServiceImpl implements } @Override - public void batchDeliver(List list) { + public void getBatchDeliverList(HttpServletResponse response, List logisticsName) { + ExcelWriter writer = ExcelUtil.getWriter(); + writer.addHeaderAlias("sn", "订单号"); + writer.addHeaderAlias("logisticsName", "物流公司"); + writer.addHeaderAlias("logisticsNo", "物流单号"); + + ExcelDTO excelDTO=new ExcelDTO("asd","2","3"); + List list = new ArrayList<>(); + list.add(excelDTO); + writer.write(list,true); + //存放下拉列表 + String[] logiList = logisticsName.toArray(new String[]{}); + CellRangeAddressList cellRangeAddressList = new CellRangeAddressList(2, 2, 2, 3); +// writer.addSelect(cellRangeAddressList, logiList); + response.setContentType("application/vnd.ms-excel;charset=utf-8"); + String name = "XXX国际贸易公司"; + response.setHeader("Content-Disposition", "attachment;filename="+name+".xls"); + ServletOutputStream out = null; + try { + out = response.getOutputStream(); + writer.flush(out, true); + } catch (IOException e) { + log.error("获取待发货订单编号列表错误",e); + } finally { + writer.close(); + } + IoUtil.close(out); + } + + @Override + public void batchDeliver(MultipartFile files) { + + InputStream inputStream = null; + List orderBatchDeliverDTOList = new ArrayList<>(); + try { + inputStream = files.getInputStream(); + // 2.应用HUtool ExcelUtil获取ExcelReader指定输入流和sheet + ExcelReader excelReader = ExcelUtil.getReader(inputStream); + // 可以加上表头验证 + // 3.读取第二行到最后一行数据 + List> read = excelReader.read(1, excelReader.getRowCount()); + for (List objects : read) { + OrderBatchDeliverDTO orderBatchDeliverDTO = new OrderBatchDeliverDTO(); + orderBatchDeliverDTO.setOrderSn(objects.get(0).toString()); + orderBatchDeliverDTO.setLogisticsName(objects.get(1).toString()); + orderBatchDeliverDTO.setLogisticsNo(objects.get(2).toString()); + orderBatchDeliverDTOList.add(orderBatchDeliverDTO); + } + }catch (Exception e){ + throw new ServiceException("文件读取失败"); + } //循环检查是否符合规范 - checkBatchDeliver(list); + checkBatchDeliver(orderBatchDeliverDTOList); //订单批量发货 - for (OrderBatchDeliverDTO orderBatchDeliverDTO : list) { + for (OrderBatchDeliverDTO orderBatchDeliverDTO : orderBatchDeliverDTOList) { this.delivery(orderBatchDeliverDTO.getOrderSn(), orderBatchDeliverDTO.getLogisticsNo(), orderBatchDeliverDTO.getLogisticsId()); } } diff --git a/seller-api/src/main/java/cn/lili/controller/trade/OrderStoreController.java b/seller-api/src/main/java/cn/lili/controller/trade/OrderStoreController.java index 9383e92d..bcc7670e 100644 --- a/seller-api/src/main/java/cn/lili/controller/trade/OrderStoreController.java +++ b/seller-api/src/main/java/cn/lili/controller/trade/OrderStoreController.java @@ -22,6 +22,7 @@ import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -50,12 +51,16 @@ public class OrderStoreController { */ @Autowired private OrderService orderService; - /** * 订单价格 */ @Autowired private OrderPriceService orderPriceService; + /** + * 物流公司 + */ + @Autowired + private StoreLogisticsService storeLogisticsService; @ApiOperation(value = "查询订单列表") @@ -141,30 +146,24 @@ public class OrderStoreController { return ResultUtil.data(orderService.getTraces(orderSn)); } + @ApiOperation(value = "下载待发货的订单列表") + @GetMapping(value = "/downLoadDeliverExcel") + public ResultMessage downLoadDeliverExcel() { + HttpServletResponse response = ThreadContextHolder.getHttpResponse(); + //获取店铺已经选择物流公司列表 + List logisticsName = storeLogisticsService.getStoreSelectedLogisticsName(); + //下载订单批量发货Excel + this.orderService.getBatchDeliverList(response,logisticsName); + + return ResultUtil.success(ResultCode.SUCCESS); + + } + + @PostMapping(value = "/batchDeliver", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @ApiOperation(value = "上传文件进行订单批量发货") - @ApiImplicitParam(name = "file", value = "订单列表", required = true, dataType = "file", paramType = "query") - @PostMapping(value = "/batchDeliver") - public void batchDeliver(@RequestParam MultipartFile file) { - InputStream inputStream = null; - try { - inputStream = file.getInputStream(); - // 2.应用HUtool ExcelUtil获取ExcelReader指定输入流和sheet - ExcelReader excelReader = ExcelUtil.getReader(inputStream); - // 可以加上表头验证 - // 3.读取第二行到最后一行数据 - List> read = excelReader.read(1, excelReader.getRowCount()); - List orderBatchDeliverDTOList=new ArrayList<>(); - for (List objects : read) { - OrderBatchDeliverDTO orderBatchDeliverDTO=new OrderBatchDeliverDTO(); - orderBatchDeliverDTO.setOrderSn(objects.get(0).toString()); - orderBatchDeliverDTO.setLogisticsName(objects.get(1).toString()); - orderBatchDeliverDTO.setLogisticsNo(objects.get(2).toString()); - orderBatchDeliverDTOList.add(orderBatchDeliverDTO); - } - orderService.batchDeliver(orderBatchDeliverDTOList); - } catch (Exception e) { - log.error("上传文件进行订单批量发货错误",e); - } + public ResultMessage batchDeliver(@RequestPart("files") MultipartFile files) { + orderService.batchDeliver(files); + return ResultUtil.success(ResultCode.SUCCESS); } @ApiOperation(value = "查询订单导出列表")