|
|
@@ -3,15 +3,20 @@ package com.kxs.lhb.basic.biz.service.impl;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
+import cn.hutool.core.util.NumberUtil;
|
|
|
+import cn.hutool.core.util.ReUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
+import com.kxs.common.core.constant.CommonConstants;
|
|
|
import com.kxs.common.excel.converters.ImportAsyncInfo;
|
|
|
import com.kxs.common.excel.vo.ErrorMessage;
|
|
|
+import com.kxs.lhb.basic.api.constant.enums.OrderStatusEnum;
|
|
|
import com.kxs.lhb.basic.api.model.LhbArea;
|
|
|
import com.kxs.lhb.basic.api.model.LhbOrder;
|
|
|
import com.kxs.lhb.basic.api.model.LhbOrderRecharge;
|
|
|
+import com.kxs.lhb.basic.api.util.TotalDateUtil;
|
|
|
import com.kxs.lhb.basic.api.vo.admin.bill.BillExcelVO;
|
|
|
import com.kxs.lhb.basic.biz.mapper.LhbOrderRechargeMapper;
|
|
|
import com.kxs.lhb.basic.biz.mq.model.params.BindNotify;
|
|
|
@@ -26,9 +31,11 @@ import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
import java.util.Set;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
@@ -50,6 +57,8 @@ public class LhbOrderRechargeServiceImpl extends MPJBaseServiceImpl<LhbOrderRech
|
|
|
|
|
|
private final LhbNotifyService notifyService;
|
|
|
|
|
|
+ private final static String REGEX = "\\d+\\.\\d+";
|
|
|
+
|
|
|
@Override
|
|
|
public void importBill(List<BillExcelVO> billExcelList, String uuid, BindingResult bindingResult) {
|
|
|
//上传内容信息
|
|
|
@@ -62,18 +71,26 @@ public class LhbOrderRechargeServiceImpl extends MPJBaseServiceImpl<LhbOrderRech
|
|
|
if (recharge != null) {
|
|
|
errorMsg.add(billExcelVO.getOrderSn() + "账单已导入!");
|
|
|
}
|
|
|
+ LhbOrder order = orderService.getOne(Wrappers.lambdaQuery(LhbOrder.class)
|
|
|
+ .eq(LhbOrder::getStatus, OrderStatusEnum.PAY.getCode())
|
|
|
+ .eq(LhbOrder::getIsAct, CommonConstants.SUCCESS)
|
|
|
+ .eq(LhbOrder::getMakeMobile, billExcelVO.getPhone()).last("limit 1"));
|
|
|
+ if (order == null) {
|
|
|
+ errorMsg.add(billExcelVO.getPhone() + "号码不存在!");
|
|
|
+ }
|
|
|
if (CollUtil.isNotEmpty(errorMsg)) {
|
|
|
ErrorMessage errorMessage = new ErrorMessage(billExcelVO.getLineNum(), errorMsg);
|
|
|
importAsyncInfo.errAdd(1);
|
|
|
importAsyncInfo.errListAdd(errorMessage);
|
|
|
importAsyncInfo.doneAdd(1);
|
|
|
- }
|
|
|
- if (CollUtil.isEmpty(errorMsg)) {
|
|
|
+ } else {
|
|
|
LhbOrderRecharge orderRecharge = new LhbOrderRecharge();
|
|
|
BeanUtils.copyProperties(billExcelVO, orderRecharge);
|
|
|
- LhbOrder order = orderService.getOne(Wrappers.lambdaQuery(LhbOrder.class).eq(LhbOrder::getMakeMobile, billExcelVO.getPhone()));
|
|
|
+ Optional<String> first = ReUtil.findAll(REGEX, billExcelVO.getBillFee(), 0).stream().findFirst();
|
|
|
+ first.ifPresent(s -> orderRecharge.setBillFee(NumberUtil.mul(new BigDecimal(s), 100)));
|
|
|
orderRecharge.setIfCode(order.getIfCode());
|
|
|
orderRecharge.setIsvNo(order.getIsvNo());
|
|
|
+ orderRecharge.setBillMonth(TotalDateUtil.getMonthNumber(billExcelVO.getBillMonth().toLocalDate()));
|
|
|
save(orderRecharge);
|
|
|
|
|
|
OrderNotify orderNotify = OrderNotify.builder()
|