|
@@ -1,14 +1,36 @@
|
|
package com.kxs.lhb.basic.biz.service.impl;
|
|
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.StrUtil;
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
-import com.github.yulichang.toolkit.JoinWrappers;
|
|
|
|
-import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
|
|
|
+import com.kxs.common.excel.converters.ImportAsyncInfo;
|
|
|
|
+import com.kxs.common.excel.vo.ErrorMessage;
|
|
|
|
+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.vo.admin.bill.BillExcelVO;
|
|
import com.kxs.lhb.basic.biz.mapper.LhbOrderRechargeMapper;
|
|
import com.kxs.lhb.basic.biz.mapper.LhbOrderRechargeMapper;
|
|
|
|
+import com.kxs.lhb.basic.biz.mq.model.params.BindNotify;
|
|
|
|
+import com.kxs.lhb.basic.biz.mq.model.params.OrderNotify;
|
|
|
|
+import com.kxs.lhb.basic.biz.service.LhbNotifyService;
|
|
import com.kxs.lhb.basic.biz.service.LhbOrderRechargeService;
|
|
import com.kxs.lhb.basic.biz.service.LhbOrderRechargeService;
|
|
|
|
+import com.kxs.lhb.basic.biz.service.LhbOrderService;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
-import com.kxs.lhb.basic.api.model.LhbOrderRecharge;
|
|
|
|
|
|
+import org.springframework.validation.BindingResult;
|
|
|
|
+
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
+import java.util.HashSet;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Set;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -22,4 +44,51 @@ import com.kxs.lhb.basic.api.model.LhbOrderRecharge;
|
|
@Slf4j
|
|
@Slf4j
|
|
public class LhbOrderRechargeServiceImpl extends MPJBaseServiceImpl<LhbOrderRechargeMapper, LhbOrderRecharge> implements LhbOrderRechargeService {
|
|
public class LhbOrderRechargeServiceImpl extends MPJBaseServiceImpl<LhbOrderRechargeMapper, LhbOrderRecharge> implements LhbOrderRechargeService {
|
|
|
|
|
|
|
|
+ private final RedisTemplate<String, Object> redisTemplate;
|
|
|
|
+
|
|
|
|
+ private final LhbOrderService orderService;
|
|
|
|
+
|
|
|
|
+ private final LhbNotifyService notifyService;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void importBill(List<BillExcelVO> billExcelList, String uuid, BindingResult bindingResult) {
|
|
|
|
+ //上传内容信息
|
|
|
|
+ ImportAsyncInfo importAsyncInfo = new ImportAsyncInfo();
|
|
|
|
+ importAsyncInfo.setTotality(billExcelList.size());
|
|
|
|
+
|
|
|
|
+ for (BillExcelVO billExcelVO : billExcelList) {
|
|
|
|
+ Set<String> errorMsg = new HashSet<>();
|
|
|
|
+ LhbOrderRecharge recharge = getOne(Wrappers.lambdaQuery(LhbOrderRecharge.class).eq(LhbOrderRecharge::getOrderSn, billExcelVO.getOrderSn()));
|
|
|
|
+ if (recharge != null) {
|
|
|
|
+ errorMsg.add(billExcelVO.getOrderSn() + "账单已导入!");
|
|
|
|
+ }
|
|
|
|
+ if (CollUtil.isNotEmpty(errorMsg)) {
|
|
|
|
+ ErrorMessage errorMessage = new ErrorMessage(billExcelVO.getLineNum(), errorMsg);
|
|
|
|
+ importAsyncInfo.errAdd(1);
|
|
|
|
+ importAsyncInfo.errListAdd(errorMessage);
|
|
|
|
+ importAsyncInfo.doneAdd(1);
|
|
|
|
+ }
|
|
|
|
+ if (CollUtil.isEmpty(errorMsg)) {
|
|
|
|
+ LhbOrderRecharge orderRecharge = new LhbOrderRecharge();
|
|
|
|
+ BeanUtils.copyProperties(billExcelVO, orderRecharge);
|
|
|
|
+ LhbOrder order = orderService.getOne(Wrappers.lambdaQuery(LhbOrder.class).eq(LhbOrder::getMakeMobile, billExcelVO.getPhone()));
|
|
|
|
+ orderRecharge.setIfCode(order.getIfCode());
|
|
|
|
+ orderRecharge.setIsvNo(order.getIsvNo());
|
|
|
|
+ save(orderRecharge);
|
|
|
|
+
|
|
|
|
+ OrderNotify orderNotify = OrderNotify.builder()
|
|
|
|
+ .mobile(order.getMakeMobile())
|
|
|
|
+ .isvNo(order.getIsvNo())
|
|
|
|
+ .amount(orderRecharge.getBillFee())
|
|
|
|
+ .month(orderRecharge.getBillMonth())
|
|
|
|
+ .build();
|
|
|
|
+ notifyService.orderPush(orderNotify, order.getIsvNo());
|
|
|
|
+
|
|
|
|
+ importAsyncInfo.sucAdd(1);
|
|
|
|
+ importAsyncInfo.doneAdd(1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ redisTemplate.opsForValue().set(uuid, JSON.toJSONString(importAsyncInfo), 15, TimeUnit.MINUTES);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|