|
@@ -1,17 +1,13 @@
|
|
|
package com.ywt.mg.services;
|
|
|
|
|
|
import com.ywt.mg.core.SqlHelper;
|
|
|
-import com.ywt.mg.core.utils.Checker;
|
|
|
-import com.ywt.mg.core.utils.FormatUtil;
|
|
|
-import com.ywt.mg.core.utils.IdCardUtil;
|
|
|
+import com.ywt.mg.core.utils.*;
|
|
|
import com.ywt.mg.domain.entities.NatOrder;
|
|
|
import com.ywt.mg.domain.entities.OrderPayment;
|
|
|
+import com.ywt.mg.domain.entities.RefundLog;
|
|
|
import com.ywt.mg.domain.models.ConstantDef;
|
|
|
import com.ywt.mg.domain.models.ExcelDataMap;
|
|
|
-import com.ywt.mg.domain.models.enums.DatePeriodEnum;
|
|
|
-import com.ywt.mg.domain.models.enums.NatOrderStatusEnum;
|
|
|
-import com.ywt.mg.domain.models.enums.PaymentStatusEnum;
|
|
|
-import com.ywt.mg.domain.models.enums.RefundStatusEnum;
|
|
|
+import com.ywt.mg.domain.models.enums.*;
|
|
|
import com.ywt.mg.domain.models.pojo.ExcelCollectPojo;
|
|
|
import com.ywt.mg.params.deposit.QueryDepositListRequest;
|
|
|
import com.ywt.mg.params.natOrder.NatOrderListRequest;
|
|
@@ -25,6 +21,7 @@ import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class NatOrderService {
|
|
@@ -49,6 +46,9 @@ public class NatOrderService {
|
|
|
@Autowired
|
|
|
private DownloadRecordService downloadRecordService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RefundLogService refundLogService;
|
|
|
+
|
|
|
|
|
|
public List<NatOrder> queryNatOrderList(NatOrderListRequest request) throws Exception {
|
|
|
Map<String, Object> map = queryNatOrderListCommon(request);
|
|
@@ -233,4 +233,98 @@ public class NatOrderService {
|
|
|
customExcelItemList.add(new ExcelCollectPojo(startColumn + 1, startRows + 3, new String[]{"实际支付金额", FormatUtil.intShrink100ToStr(payTotal - refundTotal)}));
|
|
|
return customExcelItemList;
|
|
|
}
|
|
|
+
|
|
|
+ public void downloadNatOrderBillList(int downloadRecordId, String fileName, NatOrderListRequest request) {
|
|
|
+ try {
|
|
|
+ String col0 = "交易类型*";
|
|
|
+ String col1 = "系统参考号*";
|
|
|
+ String col2 = "交易金额*";
|
|
|
+ String col3 = "交易日期*";
|
|
|
+ String col4 = "订单号";
|
|
|
+ String col5 = "类型";
|
|
|
+ String[] columns = new String[]{col0, col1, col2, col3, col4, col5};
|
|
|
+ List<NatOrder> natOrderList = queryNatOrderList(request);
|
|
|
+ ExcelDataMap map = new ExcelDataMap(columns);
|
|
|
+ if(!Checker.isNone(natOrderList)){
|
|
|
+ List<OrderPayment> orderPaymentList = orderPaymentService.getOrderPaymentListByNatOrderList(natOrderList);
|
|
|
+ // 得到退款的记录日志(需要从 refund_log 获取 refund_id 字段)
|
|
|
+ List<RefundLog> refundLogList = refundLogService.getRefundLogListByNatOrderList(natOrderList);
|
|
|
+ List<NatOrder> refundNatOrderList = getRefundNatOrderList(natOrderList);
|
|
|
+ Date billStartTime = DateUtil.stringToDate(request.getBillStartTime() + ConstantDef.BILL_TIME_START_FORMAT);
|
|
|
+ Date billEndTime = DateUtil.stringToDate(request.getBillEndTime() + ConstantDef.BILL_TIME_END_FORMAT);
|
|
|
+ for (NatOrder p : natOrderList) {
|
|
|
+ if (!Checker.isNone(p) && Checker.getIntegerValue(p.getPaymentStatus()) == PaymentStatusEnum.Success.getValue()
|
|
|
+ && Checker.getIntegerValue(p.getPaymentChannel()) == PaymentChannelEnum.WeChat.getValue()
|
|
|
+ && Checker.getIntegerValue(p.getAmount()) > 0
|
|
|
+ && !Checker.isNone(p.getPayTime())) {
|
|
|
+ // "交易类型*", "系统参考号*", "交易金额*", "交易日期*", "订单号", "类型"
|
|
|
+ Date paymentTime = Checker.getDateValue(p.getPayTime());
|
|
|
+ if (!Checker.isNone(paymentTime) && paymentTime.after(billStartTime) && paymentTime.before(billEndTime)) {
|
|
|
+ String type = ConstantDef.BILL_PAYMENT_STR;
|
|
|
+ // 交易流水号
|
|
|
+ String transactionId = orderPaymentService.getTransactionIdByOrderId(orderPaymentList, Checker.getIntegerValue(p.getOrderId()));
|
|
|
+ // 交易金额
|
|
|
+ int total = Checker.getIntegerValue(p.getAmount());
|
|
|
+ String totalStr = FormatUtil.intShrink100ToStr(total);
|
|
|
+ // 交易时间
|
|
|
+ String paymentTimeStr = FormatUtil.createTimeFormatDetail(p.getPayTime());
|
|
|
+ // 订单号
|
|
|
+ String orderNo = Checker.getStringValue(p.getOrderNo());
|
|
|
+ // 类型
|
|
|
+ String typeStr = "核酸检测缴费";
|
|
|
+
|
|
|
+ map.getStringListSafely(col0).add(type);
|
|
|
+ map.getStringListSafely(col1).add(transactionId);
|
|
|
+ map.getStringListSafely(col2).add(totalStr);
|
|
|
+ map.getStringListSafely(col3).add(paymentTimeStr);
|
|
|
+ map.getStringListSafely(col4).add(orderNo);
|
|
|
+ map.getStringListSafely(col5).add(typeStr);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (NatOrder p : refundNatOrderList) {
|
|
|
+ if (!Checker.isNone(p)
|
|
|
+ && Checker.getIntegerValue(p.getRefundStatus()) == RefundStatusEnum.SUCCESS.getValue()
|
|
|
+ && Checker.getIntegerValue(p.getAmount()) > 0) {
|
|
|
+ // "交易类型*", "系统参考号*", "交易金额*", "交易日期*", "订单号", "类型"
|
|
|
+ Date refundTime = Checker.getDateValue(p.getRefundTime());
|
|
|
+ if (!Checker.isNone(refundTime) && refundTime.after(billStartTime) && refundTime.before(billEndTime)) {
|
|
|
+ String type = ConstantDef.BILL_REFUND_STR;
|
|
|
+ String transactionId = refundLogService.getRefundIdByRefundNo(refundLogList, p.getRefundNo());
|
|
|
+ // 交易金额
|
|
|
+ int total = Checker.getIntegerValue(p.getAmount());
|
|
|
+ String totalStr = FormatUtil.intShrink100ToStr(total);
|
|
|
+ // 交易时间
|
|
|
+ String refundTimeStr = FormatUtil.createTimeFormatDetail(p.getRefundTime());
|
|
|
+ // 订单号
|
|
|
+ String orderNo = Checker.getStringValue(p.getOrderNo());
|
|
|
+ // 类型
|
|
|
+ String typeName = "核酸检测缴费";
|
|
|
+
|
|
|
+ map.getStringListSafely(col0).add(type);
|
|
|
+ map.getStringListSafely(col1).add(transactionId);
|
|
|
+ map.getStringListSafely(col2).add(totalStr);
|
|
|
+ map.getStringListSafely(col3).add(refundTimeStr);
|
|
|
+ map.getStringListSafely(col4).add(orderNo);
|
|
|
+ map.getStringListSafely(col5).add(typeName);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int size = natOrderList.size();
|
|
|
+ List<ExcelCollectPojo> itemList = new ArrayList<>();
|
|
|
+ downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<NatOrder> getRefundNatOrderList(List<NatOrder> list) {
|
|
|
+ if (!Checker.isNone(list)) {
|
|
|
+ return list.stream().filter(p -> Checker.getIntegerValue(p.getRefundStatus()) == RefundStatusEnum.SUCCESS.getValue()).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
}
|