|
@@ -1,6 +1,7 @@
|
|
|
package com.txz.mall.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
@@ -19,9 +20,9 @@ import com.txz.mall.core.ResultCode;
|
|
|
import com.txz.mall.core.ServiceException;
|
|
|
import com.txz.mall.dubbo.client.CifAccountDubboServiceClient;
|
|
|
import com.txz.mall.dubbo.client.CifUserDubboServiceClient;
|
|
|
-import com.txz.mall.enums.OrderStatusEnum;
|
|
|
import com.txz.mall.model.*;
|
|
|
import com.txz.mall.service.*;
|
|
|
+import com.txz.mall.util.EasyExcelUtil;
|
|
|
import com.txz.mall.util.OrderUtils;
|
|
|
import dto.*;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -31,12 +32,15 @@ import org.apache.commons.lang3.StringEscapeUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+import po.OrderDeliveryPO;
|
|
|
import po.StoreProductPO;
|
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
|
import tk.mybatis.mapper.entity.Example;
|
|
|
import vo.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.net.URLEncoder;
|
|
@@ -71,13 +75,13 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
int type = 2;
|
|
|
// 全部订单
|
|
|
|
|
|
- response.setAll(getCount(OrderStatusEnum.ALL.getKey(), type));
|
|
|
- // 未支付订单
|
|
|
- response.setUnPaid(getCount(OrderStatusEnum.UNPAID.getKey(), type));
|
|
|
- // 待发货订单
|
|
|
- response.setNotShipped(getCount(OrderStatusEnum.WAIT_DELIVER.getKey(), type));
|
|
|
- // 待收货订单
|
|
|
- response.setSpike(getCount(OrderStatusEnum.WAIT_RECEIVER.getKey(), type));
|
|
|
+// response.setAll(getCount(OrderStatusEnum.ALL.getKey(), type));
|
|
|
+// // 未支付订单
|
|
|
+// response.setUnPaid(getCount(OrderStatusEnum.UNPAID.getKey(), type));
|
|
|
+// // 待发货订单
|
|
|
+// response.setNotShipped(getCount(OrderStatusEnum.WAIT_DELIVER.getKey(), type));
|
|
|
+// // 待收货订单
|
|
|
+// response.setSpike(getCount(OrderStatusEnum.WAIT_RECEIVER.getKey(), type));
|
|
|
// // 待评价订单
|
|
|
// response.setBargain(getCount(Constants.ORDER_STATUS_BARGAIN, type));
|
|
|
// // 交易完成订单
|
|
@@ -237,7 +241,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void exportFile(HttpServletResponse response) {
|
|
|
+ public void exportFile(StoreOrderDTO dto, HttpServletResponse response) {
|
|
|
OutputStream outputStream;
|
|
|
try {
|
|
|
outputStream = response.getOutputStream();
|
|
@@ -246,7 +250,12 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
String fileName = URLEncoder.encode("导出订单", "UTF-8").replaceAll("\\+", "%20");
|
|
|
response.setHeader(
|
|
|
"Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
|
|
- List<StoreProductPO> list = new ArrayList<>();
|
|
|
+ List<StoreOrderVO> voList = orderList(dto);
|
|
|
+ List<StoreProductPO> list = voList.stream().map(vo -> {
|
|
|
+ StoreProductPO po = new StoreProductPO();
|
|
|
+ BeanUtils.copyProperties(vo, po);
|
|
|
+ return po;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
EasyExcel.write(outputStream, StoreProductPO.class).sheet("导出订单").doWrite(list);
|
|
|
} catch (Exception e) {
|
|
|
throw new ServiceException("模板下载失败, 请联系管理员");
|
|
@@ -1006,13 +1015,13 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
return;
|
|
|
}
|
|
|
switch (status) {
|
|
|
- case Constants.ORDER_STATUS_ALL:
|
|
|
- break;
|
|
|
- case Constants.ORDER_STATUS_UNPAID:
|
|
|
- criteria.andEqualTo("paid", 0);
|
|
|
- criteria.andEqualTo("status", 0);
|
|
|
- criteria.andEqualTo("isDelete", 0);
|
|
|
- break;
|
|
|
+// case Constants.ORDER_STATUS_ALL:
|
|
|
+// break;
|
|
|
+// case Constants.ORDER_STATUS_UNPAID:
|
|
|
+// criteria.andEqualTo("paid", 0);
|
|
|
+// criteria.andEqualTo("status", 0);
|
|
|
+// criteria.andEqualTo("isDelete", 0);
|
|
|
+// break;
|
|
|
// case Constants.ORDER_STATUS_WAIT_DELIVER:
|
|
|
// criteria.andEqualTo("paid", 1);
|
|
|
// criteria.andEqualTo("status", 0);
|
|
@@ -1293,15 +1302,19 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
@Override
|
|
|
public void refund(Long id) {
|
|
|
StoreOrder storeOrder = findById(id);
|
|
|
- if (storeOrder.getPaid().equals(OrderStatusEnum.UNPAID.getKey())) {
|
|
|
+ if (storeOrder.getPaid().equals(Constants.ORDER_STATUS_H5_UNPAID)) {
|
|
|
throw new ServiceException("当前状态不支持退款");
|
|
|
}
|
|
|
+ storeOrder.setRefundStatus(1);
|
|
|
+ update(storeOrder);
|
|
|
+
|
|
|
+// accountDubboServiceClient.refund(id.toString(), storeOrder.getOrderId(), storeOrder.getPayPrice());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void close(Long id) {
|
|
|
StoreOrder storeOrder = findById(id);
|
|
|
-// storeOrder.setStatus(OrderStatusEnum.CLOSE.getKey());
|
|
|
+ storeOrder.setStatus(Constants.ORDER_STATUS_H5_CLOSE);
|
|
|
// update(storeOrder);
|
|
|
}
|
|
|
|
|
@@ -1309,13 +1322,52 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
|
|
|
public void cancel(Long id) {
|
|
|
StoreOrder storeOrder = findById(id);
|
|
|
if (storeOrder.getPaid().equals(0)) {
|
|
|
- storeOrder.setStatus(OrderStatusEnum.CANCEL.getKey());
|
|
|
+ storeOrder.setStatus(Constants.ORDER_STATUS_H5_CANCEL);
|
|
|
update(storeOrder);
|
|
|
} else {
|
|
|
throw new ServiceException("当前状态不支持取消");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void exportDelivery(HttpServletResponse response) {
|
|
|
+ OutputStream outputStream;
|
|
|
+ try {
|
|
|
+ outputStream = response.getOutputStream();
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ String fileName = URLEncoder.encode("导出订单", "UTF-8").replaceAll("\\+", "%20");
|
|
|
+ response.setHeader(
|
|
|
+ "Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
|
|
+ ArrayList<OrderDeliveryPO> list = new ArrayList<>();
|
|
|
+ EasyExcel.write(outputStream, OrderDeliveryPO.class).sheet("导出发货模版").doWrite(list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new ServiceException("模板下载失败, 请联系管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void importDelivery(MultipartFile file) {
|
|
|
+ String name = file.getOriginalFilename();
|
|
|
+ String suffix = FileUtil.extName(name);
|
|
|
+ log.info("获取到的文件名为----->{},后缀为----->{},入参------->{}", name, suffix);
|
|
|
+ if ("xlsx".equals(suffix) || "xls".equals(suffix)) {
|
|
|
+ throw new ServiceException("请传入xlsx或xls文档格式文件");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ List<OrderDeliveryPO> list = EasyExcelUtil.syncReadModel(file.getInputStream(),
|
|
|
+ OrderDeliveryPO.class,
|
|
|
+ 0,
|
|
|
+ 1);
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(list)) {
|
|
|
+ throw new ServiceException("请填写内容后再提交!");
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 校验商品库存(生成订单)
|
|
|
*
|