|
@@ -14,6 +14,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.kxs.common.core.exception.GlobalCustomerException;
|
|
import com.kxs.common.core.exception.GlobalCustomerException;
|
|
|
import com.kxs.common.mq.handlers.IMQSender;
|
|
import com.kxs.common.mq.handlers.IMQSender;
|
|
|
|
|
+import com.kxs.product.api.model.KxsGdOrder;
|
|
|
import com.kxs.product.api.model.KxsGdReport;
|
|
import com.kxs.product.api.model.KxsGdReport;
|
|
|
import com.kxs.product.api.req.gd.GdQueryCardOrderReq;
|
|
import com.kxs.product.api.req.gd.GdQueryCardOrderReq;
|
|
|
import com.kxs.product.api.res.gd.GdCommRes;
|
|
import com.kxs.product.api.res.gd.GdCommRes;
|
|
@@ -22,13 +23,16 @@ import com.kxs.product.api.amqp.rabbit.RabbitGdActQueueMQ;
|
|
|
import com.kxs.product.biz.config.RsaProperties;
|
|
import com.kxs.product.biz.config.RsaProperties;
|
|
|
import com.kxs.product.biz.constant.enums.GdReportEnum;
|
|
import com.kxs.product.biz.constant.enums.GdReportEnum;
|
|
|
import com.kxs.product.biz.mapper.KxsGdReportMapper;
|
|
import com.kxs.product.biz.mapper.KxsGdReportMapper;
|
|
|
|
|
+import com.kxs.product.biz.service.KxsGdOrderService;
|
|
|
import com.kxs.product.biz.service.KxsGdService;
|
|
import com.kxs.product.biz.service.KxsGdService;
|
|
|
import com.kxs.product.biz.util.GdRsaUtils;
|
|
import com.kxs.product.biz.util.GdRsaUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -51,6 +55,8 @@ public class KxsGdServiceImpl implements KxsGdService {
|
|
|
|
|
|
|
|
private final IMQSender mqSender;
|
|
private final IMQSender mqSender;
|
|
|
|
|
|
|
|
|
|
+ private final KxsGdOrderService gdOrderService;
|
|
|
|
|
+
|
|
|
@Async("getAsyncExecutor")
|
|
@Async("getAsyncExecutor")
|
|
|
@Override
|
|
@Override
|
|
|
public void checkGdAsyncData(String startTime, String endTime) {
|
|
public void checkGdAsyncData(String startTime, String endTime) {
|
|
@@ -91,6 +97,7 @@ public class KxsGdServiceImpl implements KxsGdService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void checkGdAsyncData(Map<String, Object> param) {
|
|
public void checkGdAsyncData(Map<String, Object> param) {
|
|
|
|
|
|
|
|
JSONArray dataList = JSON.parseArray(param.get("data").toString());
|
|
JSONArray dataList = JSON.parseArray(param.get("data").toString());
|
|
@@ -106,49 +113,81 @@ public class KxsGdServiceImpl implements KxsGdService {
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
throw new GlobalCustomerException("广电接收激活数据验证签名失败");
|
|
throw new GlobalCustomerException("广电接收激活数据验证签名失败");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
for (Object obj : dataList) {
|
|
for (Object obj : dataList) {
|
|
|
JSONObject orderData = JSON.parseObject(obj.toString());
|
|
JSONObject orderData = JSON.parseObject(obj.toString());
|
|
|
- //订单流转接口,暂不处理
|
|
|
|
|
- if (!orderData.containsKey("status") || !orderData.containsKey("mobile")) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- //1 订单生成2 订单正在运行3 待发货4 配送中5 订单成功结束6 已激活成功11 办理失败12 拒签13 订单取消中14 订单取消
|
|
|
|
|
- int status = orderData.getInteger("status");
|
|
|
|
|
- if(status != 6){
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- String gdMobile = orderData.getString("mobile");
|
|
|
|
|
- if(StrUtil.isBlank(gdMobile)){
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- KxsGdReport kxsGdReport = kxsGdReportMapper.selectOne(Wrappers.<KxsGdReport>lambdaQuery()
|
|
|
|
|
- .eq(KxsGdReport::getIsCheck, GdReportEnum.CHECK_NO.getType())
|
|
|
|
|
- .eq(KxsGdReport::getGdMobile, gdMobile));
|
|
|
|
|
- if (kxsGdReport == null) {
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ //订单信息
|
|
|
|
|
+ if("1".equals(param.get("type").toString())){
|
|
|
|
|
+
|
|
|
|
|
+ KxsGdOrder kxsGdOrder = gdOrderService.getOne(Wrappers.<KxsGdOrder>lambdaQuery().eq(KxsGdOrder::getOrderNo, orderData.getString("orderNo")));
|
|
|
|
|
+ if(kxsGdOrder == null){
|
|
|
|
|
+ kxsGdOrder = new KxsGdOrder();
|
|
|
|
|
+ }
|
|
|
|
|
+ kxsGdOrder.setIccid(orderData.getString("iccid"));
|
|
|
|
|
+ kxsGdOrder.setFirstRechargeAmount(new BigDecimal(orderData.getString("firstRechargeAmount")));
|
|
|
|
|
+ kxsGdOrder.setProductName(orderData.getString("productName"));
|
|
|
|
|
+ kxsGdOrder.setProvince(orderData.getString("province"));
|
|
|
|
|
+ kxsGdOrder.setCity(orderData.getString("city"));
|
|
|
|
|
+ kxsGdOrder.setUserName(orderData.getString("userName"));
|
|
|
|
|
+ kxsGdOrder.setGdMobile(orderData.getString("mobile"));
|
|
|
|
|
+ kxsGdOrder.setOrderNo(orderData.getString("orderNo"));
|
|
|
|
|
+ kxsGdOrder.setErpName(orderData.getString("logisticsCompany"));
|
|
|
|
|
+ kxsGdOrder.setErpNo(orderData.getString("logisticsNo"));
|
|
|
|
|
+ kxsGdOrder.setIdcardNo(orderData.getString("idcardNo"));
|
|
|
|
|
+ kxsGdOrder.setReceiveName(orderData.getString("receiveName"));
|
|
|
|
|
+ kxsGdOrder.setReceiveMobile(orderData.getString("receiveMobile"));
|
|
|
|
|
+ kxsGdOrder.setAddress(orderData.getString("receiveAddress"));
|
|
|
|
|
+ kxsGdOrder.setAddressDetail(orderData.getString("receiveAddressDetail"));
|
|
|
|
|
+ kxsGdOrder.setCreateTime(LocalDateTimeUtil.parse(orderData.getString("createTime"), DatePattern.NORM_DATETIME_PATTERN));
|
|
|
|
|
+ gdOrderService.saveOrUpdate(kxsGdOrder);
|
|
|
}
|
|
}
|
|
|
|
|
+ //激活状态
|
|
|
|
|
+ if("2".equals(param.get("type").toString())){
|
|
|
|
|
+ String orderNo = orderData.getString("orderNo");
|
|
|
|
|
+ //1 订单生成2 订单正在运行3 待发货4 配送中5 订单成功结束6 已激活成功11 办理失败12 拒签13 订单取消中14 订单取消
|
|
|
|
|
+ String status = orderData.getString("status");
|
|
|
|
|
+ KxsGdOrder kxsGdOrder = gdOrderService.getOne(Wrappers.<KxsGdOrder>lambdaQuery().eq(KxsGdOrder::getOrderNo, orderNo));
|
|
|
|
|
+ if (kxsGdOrder == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ kxsGdOrder.setStatus(Integer.valueOf(status));
|
|
|
|
|
+ gdOrderService.updateById(kxsGdOrder);
|
|
|
|
|
+ //激活成功
|
|
|
|
|
+ if("6".equals(status)){
|
|
|
|
|
+ KxsGdReport kxsGdReport = kxsGdReportMapper.selectOne(Wrappers.<KxsGdReport>lambdaQuery()
|
|
|
|
|
+ .eq(KxsGdReport::getIsCheck, GdReportEnum.CHECK_NO.getType())
|
|
|
|
|
+ .eq(KxsGdReport::getGdMobile, kxsGdOrder.getGdMobile()));
|
|
|
|
|
+ if (kxsGdReport == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ kxsGdReport.setStatus(GdReportEnum.CHECK_SUC.getType());
|
|
|
|
|
+ kxsGdReportMapper.updateById(kxsGdReport);
|
|
|
|
|
+ toSendMq(kxsGdOrder, kxsGdReport.getGdSn());
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- RabbitGdActQueueMQ.MsgEntity msgEntity = new RabbitGdActQueueMQ.MsgEntity();
|
|
|
|
|
- msgEntity.setPosSn(orderData.getString("iccid"));
|
|
|
|
|
- msgEntity.setPhoneNo(orderData.getString("mobile"));
|
|
|
|
|
- msgEntity.setProductName(orderData.getString("productName"));
|
|
|
|
|
- msgEntity.setActivationStatusName("已激活");
|
|
|
|
|
- msgEntity.setPromotionName(orderData.getString("offerName"));
|
|
|
|
|
- msgEntity.setProvince(orderData.getString("province"));
|
|
|
|
|
- msgEntity.setCity(orderData.getString("city"));
|
|
|
|
|
- msgEntity.setOrderCreateTime(orderData.getString("createTime"));
|
|
|
|
|
- msgEntity.setActivationTime(LocalDateTimeUtil.format(LocalDateTime.now(), DatePattern.NORM_DATETIME_PATTERN));
|
|
|
|
|
-
|
|
|
|
|
- mqSender.send(RabbitGdActQueueMQ.build(msgEntity));
|
|
|
|
|
-
|
|
|
|
|
- kxsGdReportMapper.update(null, Wrappers.<KxsGdReport>lambdaUpdate().eq(KxsGdReport::getId, kxsGdReport.getId())
|
|
|
|
|
- .set(KxsGdReport::getIsCheck, GdReportEnum.CHECK_SUC.getType())
|
|
|
|
|
- .set(KxsGdReport::getGdMobile, gdMobile));
|
|
|
|
|
- log.info("发送电渠广电激活数据{}", kxsGdReport.getGdSn()
|
|
|
|
|
- + "," + kxsGdReport.getGdMobile());
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void toSendMq(KxsGdOrder order, String sn){
|
|
|
|
|
+ RabbitGdActQueueMQ.MsgEntity msgEntity = new RabbitGdActQueueMQ.MsgEntity();
|
|
|
|
|
+ msgEntity.setPosSn(sn);
|
|
|
|
|
+ msgEntity.setPhoneNo(order.getGdMobile());
|
|
|
|
|
+ msgEntity.setProductName(order.getProductName());
|
|
|
|
|
+ msgEntity.setActivationStatusName("已激活");
|
|
|
|
|
+ msgEntity.setPromotionName(order.getProductName());
|
|
|
|
|
+ msgEntity.setProvince(order.getProvince());
|
|
|
|
|
+ msgEntity.setCity(order.getCity());
|
|
|
|
|
+ msgEntity.setInitialChargeAmount(order.getFirstRechargeAmount());
|
|
|
|
|
+ msgEntity.setOrderCreateTime(LocalDateTimeUtil.format(order.getCreateTime(), DatePattern.NORM_DATETIME_PATTERN));
|
|
|
|
|
+ msgEntity.setActivationTime(LocalDateTimeUtil.format(LocalDateTime.now(), DatePattern.NORM_DATETIME_PATTERN));
|
|
|
|
|
+
|
|
|
|
|
+ mqSender.send(RabbitGdActQueueMQ.build(msgEntity));
|
|
|
|
|
+
|
|
|
|
|
+ log.info("发送电渠广电激活数据{}", sn
|
|
|
|
|
+ + "," + order.getGdMobile());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
public List<GdQueryOrderRes.GdQueryOrder> queryCardOrders(String startTime, String endTime, int pageNo, int pageSize) {
|
|
public List<GdQueryOrderRes.GdQueryOrder> queryCardOrders(String startTime, String endTime, int pageNo, int pageSize) {
|
|
|
|
|
|