| | |
| | | import cc.mrbird.febs.common.controller.BaseController; |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.common.enumerates.OrderDeliveryStateEnum; |
| | | import cc.mrbird.febs.common.enumerates.OrderStatusEnum; |
| | | 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.DeliverGoodsDto; |
| | | import cc.mrbird.febs.mall.dto.clothes.AdminClothesDeliverGoodsDto; |
| | | import cc.mrbird.febs.mall.dto.clothes.AdminClothesOrderListDto; |
| | | import cc.mrbird.febs.mall.dto.clothes.AdminClothesRefundOrderDto; |
| | | import cc.mrbird.febs.mall.dto.clothes.AdminClothesTypeInfoDto; |
| | | import cc.mrbird.febs.mall.dto.memberLevel.AdminMemberLabelAddDto; |
| | | import cc.mrbird.febs.mall.dto.memberLevel.AdminMemberLabelDto; |
| | | import cc.mrbird.febs.mall.dto.memberLevel.AdminMemberLabelUpdateDto; |
| | | import cc.mrbird.febs.mall.entity.*; |
| | | import cc.mrbird.febs.mall.service.ClothesTypeService; |
| | | import cc.mrbird.febs.mall.vo.clothes.AdminClothesTypeInfoVo; |
| | | import cc.mrbird.febs.mall.vo.memberLevel.AdminMemberLabelSetDto; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | 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.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | |
| | | public class AdminClothesTypeController extends BaseController { |
| | | |
| | | private final ClothesTypeService clothesTypeService; |
| | | |
| | | /** |
| | | * 订单列表 |
| | | * |
| | | * @param dto |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @GetMapping("orderList") |
| | | public FebsResponse getOrderList(AdminClothesOrderListDto dto, QueryRequest request) { |
| | | String startTime = dto.getStartTime(); |
| | | String endTime = dto.getEndTime(); |
| | | if(StrUtil.isNotBlank(startTime) && StrUtil.isNotBlank(endTime)){ |
| | | DateTime dateStartTime= DateUtil.parseDate(startTime); |
| | | DateTime dateEndTime = DateUtil.parseDate(endTime); |
| | | int compare = DateUtil.compare(dateStartTime, dateEndTime); |
| | | if(compare >= 0){ |
| | | return new FebsResponse().fail().message("请输入正确的开始时间和结束时间"); |
| | | } |
| | | } |
| | | Map<String, Object> data = getDataTable(clothesTypeService.getOrderListInPage(dto, request)); |
| | | return new FebsResponse().success().data(data); |
| | | } |
| | | |
| | | /** |
| | | * 订单列表-发货 |
| | | */ |
| | | @PostMapping("deliverGoods") |
| | | @ControllerEndpoint(operation = "订单列表-发货", exceptionMessage = "操作失败") |
| | | public FebsResponse deliverGoods(AdminClothesDeliverGoodsDto dto) { |
| | | |
| | | return clothesTypeService.deliverGoods(dto); |
| | | } |
| | | |
| | | /** |
| | | * 订单列表-修改物流编号 |
| | | */ |
| | | @PostMapping("deliverGoodsUpdate") |
| | | @ControllerEndpoint(operation = "订单列表-修改物流编号", exceptionMessage = "操作失败") |
| | | public FebsResponse deliverGoodsUpdate(@Valid AdminClothesDeliverGoodsDto dto) { |
| | | |
| | | return clothesTypeService.deliverGoodsUpdate(dto); |
| | | } |
| | | |
| | | /** |
| | | * 订单列表-仅退款 |
| | | */ |
| | | |
| | | @GetMapping("refundOrder/{id}") |
| | | @ControllerEndpoint(operation = "订单列表-仅退款", exceptionMessage = "仅退款") |
| | | public FebsResponse refundOrder(@NotNull(message = "{required}") @PathVariable Long id) { |
| | | AdminClothesRefundOrderDto dto = new AdminClothesRefundOrderDto(); |
| | | dto.setId(id); |
| | | return clothesTypeService.refundOrder(dto); |
| | | } |
| | | |
| | | @GetMapping("confirmOrder/{ids}") |
| | | @ControllerEndpoint(operation = "订单列表-确认收货", exceptionMessage = "操作失败") |
| | | public FebsResponse confirmOrder(@NotBlank(message = "{required}") @PathVariable String ids){ |
| | | List<String> List = StrUtil.splitTrim(ids, ","); |
| | | for(String id : List){ |
| | | long orderId = Long.parseLong(id); |
| | | clothesTypeService.confirmOrder(orderId); |
| | | } |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @GetMapping("exportOrderList/{ids}") |
| | | @ControllerEndpoint(operation = "订单列表", exceptionMessage = "导出失败") |
| | | public FebsResponse exportOrderList(@NotBlank(message = "{required}") @PathVariable String ids, HttpServletResponse response) throws IOException { |
| | | List<String> List = StrUtil.splitTrim(ids, ","); |
| | | if(CollUtil.isNotEmpty( List)){ |
| | | ArrayList<Long> orderIds = new ArrayList<>(); |
| | | for (String id : List){ |
| | | long orderId = Long.parseLong(id); |
| | | orderIds.add(orderId); |
| | | } |
| | | if(CollUtil.isNotEmpty(orderIds)){ |
| | | |
| | | clothesTypeService.exportOrderList(orderIds,response); |
| | | } |
| | | } |
| | | 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 = "/home/javaweb/webresource/clothes/"; |
| | | |
| | | 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 orderIdNoIndex = -1; |
| | | int expressNoIndex = -1; |
| | | int expressComIndex = -1; |
| | | int expressCodeIndex = -1; |
| | | for (int i = 1; i < dataList.size(); i++) { |
| | | List<Object> objects = dataList.get(i); |
| | | |
| | | String orderId = ""; |
| | | String expressNo = ""; |
| | | String expressCode = ""; |
| | | String expressCom = ""; |
| | | for (int j = 0; j < objects.size(); j++) { |
| | | Object obj = objects.get(j); |
| | | if ("订单ID".equals(obj)) { |
| | | orderIdNoIndex = j; |
| | | } |
| | | if ("物流单号".equals(obj)) { |
| | | expressNoIndex = j; |
| | | } |
| | | |
| | | if ("物流公司".equals(obj)) { |
| | | expressComIndex = j; |
| | | } |
| | | |
| | | if ("物流公司码".equals(obj)) { |
| | | expressCodeIndex = j; |
| | | } |
| | | |
| | | if (j == orderIdNoIndex) { |
| | | orderId = (String) objects.get(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)) { |
| | | AdminClothesDeliverGoodsDto dto = new AdminClothesDeliverGoodsDto(); |
| | | dto.setId(Long.parseLong(orderId)); |
| | | dto.setExpressCom(expressCom); |
| | | dto.setExpressCode(expressCode); |
| | | dto.setExpressNo(expressNo); |
| | | clothesTypeService.deliverGoodsImport(dto); |
| | | } |
| | | } |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | /** |
| | | * 分类列表 |
| | | * @return |