|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.fuint.common.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
@ -7,13 +8,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.fuint.common.Constants;
|
|
|
|
|
import com.fuint.common.dto.*;
|
|
|
|
|
import com.fuint.common.enums.*;
|
|
|
|
|
import com.fuint.common.excelDto.UserOrderExcelDto;
|
|
|
|
|
import com.fuint.common.param.OrderListParam;
|
|
|
|
|
import com.fuint.common.param.SettlementParam;
|
|
|
|
|
import com.fuint.common.service.*;
|
|
|
|
|
import com.fuint.common.util.CommonUtil;
|
|
|
|
|
import com.fuint.common.util.DateUtil;
|
|
|
|
|
import com.fuint.common.util.SeqUtil;
|
|
|
|
|
import com.fuint.common.util.TokenUtil;
|
|
|
|
|
import com.fuint.common.util.*;
|
|
|
|
|
import com.fuint.framework.annoation.OperationServiceLog;
|
|
|
|
|
import com.fuint.framework.exception.BusinessCheckException;
|
|
|
|
|
import com.fuint.framework.pagination.PaginationResponse;
|
|
|
|
@ -30,14 +29,20 @@ import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
|
|
import org.springframework.core.env.Environment;
|
|
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.ResourceUtils;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import weixin.popular.util.JsonUtil;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -169,6 +174,11 @@ public class OrderServiceImpl extends ServiceImpl<MtOrderMapper, MtOrder> implem
|
|
|
|
|
* */
|
|
|
|
|
private PaymentService paymentService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 系统环境变量
|
|
|
|
|
* */
|
|
|
|
|
private Environment env;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取用户订单列表
|
|
|
|
|
* @param orderListParam
|
|
|
|
@ -2116,4 +2126,153 @@ public class OrderServiceImpl extends ServiceImpl<MtOrderMapper, MtOrder> implem
|
|
|
|
|
public List<MtOrder> getTobeCommissionOrderList(String dateTime) {
|
|
|
|
|
return mtOrderMapper.getTobeCommissionOrderList(dateTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存文件
|
|
|
|
|
*
|
|
|
|
|
* @param file excel文件
|
|
|
|
|
* @param request
|
|
|
|
|
* */
|
|
|
|
|
public String saveExcelFile(MultipartFile file, HttpServletRequest request) throws Exception {
|
|
|
|
|
String fileName = file.getOriginalFilename();
|
|
|
|
|
|
|
|
|
|
String imageName = fileName.substring(fileName.lastIndexOf("."));
|
|
|
|
|
String pathRoot = env.getProperty("images.root");
|
|
|
|
|
if (pathRoot == null || StringUtil.isEmpty(pathRoot)) {
|
|
|
|
|
pathRoot = ResourceUtils.getURL("classpath:").getPath();
|
|
|
|
|
}
|
|
|
|
|
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
|
|
|
|
|
|
|
String filePath = "/static/uploadFiles/"+ DateUtil.formatDate(new Date(), "yyyyMMdd")+"/";
|
|
|
|
|
String path = filePath + uuid + imageName;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
File tempFile = new File(pathRoot + path);
|
|
|
|
|
if (!tempFile.getParentFile().exists()) {
|
|
|
|
|
tempFile.getParentFile().mkdirs();
|
|
|
|
|
}
|
|
|
|
|
CommonUtil.saveMultipartFile(file, pathRoot + path);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
//empty
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导入订单列表
|
|
|
|
|
*
|
|
|
|
|
* @param file excel文件
|
|
|
|
|
* @param operator 操作者
|
|
|
|
|
* */
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
@OperationServiceLog(description = "导入订单列表")
|
|
|
|
|
public String importSendCoupon(MultipartFile file, String operator, String filePath) throws BusinessCheckException {
|
|
|
|
|
String originalFileName = file.getOriginalFilename();
|
|
|
|
|
boolean isExcel2003 = XlsUtil.isExcel2003(originalFileName);
|
|
|
|
|
boolean isExcel2007 = XlsUtil.isExcel2007(originalFileName);
|
|
|
|
|
|
|
|
|
|
if (!isExcel2003 && !isExcel2007) {
|
|
|
|
|
logger.error("importSendCouponController->uploadFile:{}", "文件类型不正确");
|
|
|
|
|
throw new BusinessCheckException("文件类型不正确");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<List<String>> content = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
content = XlsUtil.readExcelContent(file.getInputStream(), isExcel2003, 1, null, null, null);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
logger.error("CouponGroupServiceImpl->parseExcelContent{}", e);
|
|
|
|
|
throw new BusinessCheckException("导入失败"+e.getMessage());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StringBuffer errorMsg = new StringBuffer();
|
|
|
|
|
StringBuffer errorMsgNoGroup = new StringBuffer();
|
|
|
|
|
StringBuffer errorMsgNoNum = new StringBuffer();
|
|
|
|
|
StringBuffer errorMsgNoRegister = new StringBuffer();
|
|
|
|
|
|
|
|
|
|
List<MtOrder> rows = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < content.size(); i++) {
|
|
|
|
|
List<Integer> groupIdArr = new ArrayList<>();
|
|
|
|
|
List<Integer> numArr = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
List<String> rowContent = content.get(i);
|
|
|
|
|
MtOrder order = new MtOrder();
|
|
|
|
|
String type = rowContent.get(0);
|
|
|
|
|
if(StringUtil.isNotEmpty(type)){
|
|
|
|
|
String keyName = OrderTypeEnum.getKeyName(type);
|
|
|
|
|
if(StringUtil.isNotEmpty(keyName)){
|
|
|
|
|
type = keyName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
order.setType(type);
|
|
|
|
|
String payType = rowContent.get(1);
|
|
|
|
|
if(StringUtil.isNotEmpty(payType)){
|
|
|
|
|
String keyName = PayTypeEnum.getKeyName(payType);
|
|
|
|
|
if(StringUtil.isNotEmpty(keyName)){
|
|
|
|
|
payType = keyName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
order.setPayType(payType);
|
|
|
|
|
String orderMode = rowContent.get(2);
|
|
|
|
|
if(StringUtil.isNotEmpty(orderMode)){
|
|
|
|
|
String keyName = OrderModeEnum.getKeyName(orderMode);
|
|
|
|
|
if(StringUtil.isNotEmpty(keyName)){
|
|
|
|
|
orderMode = keyName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
order.setOrderMode(orderMode);
|
|
|
|
|
String orderSn = rowContent.get(3);
|
|
|
|
|
order.setOrderSn(orderSn);
|
|
|
|
|
String merchantName = rowContent.get(4);
|
|
|
|
|
// order.setMerchantId();
|
|
|
|
|
String storeName = rowContent.get(5);
|
|
|
|
|
if(StringUtil.isNotEmpty(storeName)){
|
|
|
|
|
StoreDto storeDto = storeService.queryStoreByName(storeName);
|
|
|
|
|
if(ObjectUtil.isNotEmpty(storeDto)){
|
|
|
|
|
order.setStoreId(storeDto.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String userName = rowContent.get(6);
|
|
|
|
|
String isVisitor = rowContent.get(7);
|
|
|
|
|
order.setIsVisitor(isVisitor);
|
|
|
|
|
String amount = rowContent.get(8);
|
|
|
|
|
if(StringUtil.isNotEmpty(amount)){
|
|
|
|
|
order.setAmount(new BigDecimal(amount));
|
|
|
|
|
}
|
|
|
|
|
String payAmount = rowContent.get(9);
|
|
|
|
|
if(StringUtil.isNotEmpty(payAmount)){
|
|
|
|
|
order.setPayAmount(new BigDecimal(payAmount));
|
|
|
|
|
}
|
|
|
|
|
String usePoint = rowContent.get(10);
|
|
|
|
|
if(StringUtil.isNotEmpty(usePoint)){
|
|
|
|
|
order.setUsePoint(Integer.valueOf(usePoint));
|
|
|
|
|
}
|
|
|
|
|
String pointAmount = rowContent.get(11);
|
|
|
|
|
if(StringUtil.isNotEmpty(pointAmount)){
|
|
|
|
|
order.setPointAmount(new BigDecimal(pointAmount));
|
|
|
|
|
}
|
|
|
|
|
String discount = rowContent.get(12);
|
|
|
|
|
if(StringUtil.isNotEmpty(discount)){
|
|
|
|
|
order.setDiscount(new BigDecimal(discount));
|
|
|
|
|
}
|
|
|
|
|
String deliveryFee = rowContent.get(13);
|
|
|
|
|
if(StringUtil.isNotEmpty(deliveryFee)){
|
|
|
|
|
order.setDeliveryFee(new BigDecimal(deliveryFee));
|
|
|
|
|
}
|
|
|
|
|
String payTime = rowContent.get(14);
|
|
|
|
|
String staffName = rowContent.get(15);
|
|
|
|
|
// order.setStaffId();
|
|
|
|
|
mtOrderMapper.insert(order);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 导入批次
|
|
|
|
|
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
|
|
|
|
|
|
|
return uuid;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|