|
@@ -16,10 +16,13 @@ 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.KxsGdOrder;
|
|
|
import com.kxs.product.api.model.KxsGdReport;
|
|
import com.kxs.product.api.model.KxsGdReport;
|
|
|
|
|
+import com.kxs.product.api.req.gd.GdCommonReq;
|
|
|
import com.kxs.product.api.req.gd.GdQueryCardOrderReq;
|
|
import com.kxs.product.api.req.gd.GdQueryCardOrderReq;
|
|
|
|
|
+import com.kxs.product.api.req.gd.GdSimOrderReq;
|
|
|
import com.kxs.product.api.res.gd.GdCommRes;
|
|
import com.kxs.product.api.res.gd.GdCommRes;
|
|
|
import com.kxs.product.api.res.gd.GdQueryOrderRes;
|
|
import com.kxs.product.api.res.gd.GdQueryOrderRes;
|
|
|
import com.kxs.product.api.amqp.rabbit.RabbitGdActQueueMQ;
|
|
import com.kxs.product.api.amqp.rabbit.RabbitGdActQueueMQ;
|
|
|
|
|
+import com.kxs.product.api.res.gd.GdSimOrderRes;
|
|
|
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;
|
|
@@ -32,12 +35,8 @@ import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
-import java.io.BufferedReader;
|
|
|
|
|
-import java.io.FileReader;
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.Optional;
|
|
import java.util.Optional;
|
|
@@ -68,7 +67,17 @@ public class KxsGdServiceImpl implements KxsGdService {
|
|
|
int pageSize = 50;
|
|
int pageSize = 50;
|
|
|
|
|
|
|
|
do {
|
|
do {
|
|
|
- List<GdQueryOrderRes.GdQueryOrder> list = this.queryCardOrders(startTime, endTime, pageNo, pageSize);
|
|
|
|
|
|
|
+ GdQueryCardOrderReq req = GdQueryCardOrderReq.builder()
|
|
|
|
|
+ .queryBeginTime(startTime)
|
|
|
|
|
+ .queryEndTime(endTime)
|
|
|
|
|
+ .pageNo(String.valueOf(pageNo))
|
|
|
|
|
+ .pageSize(String.valueOf(pageSize)).build();
|
|
|
|
|
+ String response = sendToGd("/ycsim-business/openapi/query_card_order_info", req);
|
|
|
|
|
+ GdCommRes<GdQueryOrderRes> commRes = JSONUtil.toBean(response, new TypeReference<>() {}, true);
|
|
|
|
|
+ if(commRes.getResultCode() != 1){
|
|
|
|
|
+ throw new GlobalCustomerException(commRes.getErrorDesc());
|
|
|
|
|
+ }
|
|
|
|
|
+ List<GdQueryOrderRes.GdQueryOrder> list = commRes.getData().getRecords();
|
|
|
if (list.isEmpty()) {
|
|
if (list.isEmpty()) {
|
|
|
pageNo = -1;
|
|
pageNo = -1;
|
|
|
} else {
|
|
} else {
|
|
@@ -100,9 +109,57 @@ public class KxsGdServiceImpl implements KxsGdService {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onlineSimOrder(List<String> orderNos) {
|
|
|
|
|
+ GdSimOrderReq req = GdSimOrderReq.builder()
|
|
|
|
|
+ .orderNos(JSON.toJSONString(orderNos))
|
|
|
|
|
+ .build();
|
|
|
|
|
+ String response = sendToGd("/ycsim-agent-service/openapi/online_sim_order/get_order_info", req);
|
|
|
|
|
+ GdCommRes<List<GdSimOrderRes>> commRes = JSONUtil.toBean(response, new TypeReference<GdCommRes<List<GdSimOrderRes>>>() {}, true);
|
|
|
|
|
+ if(commRes.getResultCode() != 1){
|
|
|
|
|
+ throw new GlobalCustomerException(commRes.getErrorDesc());
|
|
|
|
|
+ }
|
|
|
|
|
+ List<GdSimOrderRes> list = commRes.getData();
|
|
|
|
|
+ for (GdSimOrderRes res : list) {
|
|
|
|
|
+ KxsGdOrder kxsGdOrder = gdOrderService.getOne(Wrappers.<KxsGdOrder>lambdaQuery().eq(KxsGdOrder::getOrderNo, res.getOrderNo()));
|
|
|
|
|
+ if(kxsGdOrder == null){
|
|
|
|
|
+ kxsGdOrder = new KxsGdOrder();
|
|
|
|
|
+ }
|
|
|
|
|
+ kxsGdOrder.setIccid(res.getIccid());
|
|
|
|
|
+ kxsGdOrder.setFirstRechargeAmount(new BigDecimal(res.getFirstRechargeAmount()));
|
|
|
|
|
+ kxsGdOrder.setProductName(res.getProductName());
|
|
|
|
|
+ kxsGdOrder.setProvince(res.getProvince());
|
|
|
|
|
+ kxsGdOrder.setCity(res.getCity());
|
|
|
|
|
+ kxsGdOrder.setUserName(res.getUserName());
|
|
|
|
|
+ kxsGdOrder.setGdMobile(res.getMobile());
|
|
|
|
|
+ kxsGdOrder.setOrderNo(res.getOrderNo());
|
|
|
|
|
+ kxsGdOrder.setStatus(Integer.valueOf(res.getStatus()));
|
|
|
|
|
+ kxsGdOrder.setIdcardNo(res.getIdcardNo());
|
|
|
|
|
+ kxsGdOrder.setReceiveName(res.getReceiveName());
|
|
|
|
|
+ kxsGdOrder.setReceiveMobile(res.getReceiveMobile());
|
|
|
|
|
+ kxsGdOrder.setAddress(res.getReceiveAddress());
|
|
|
|
|
+ kxsGdOrder.setAddressDetail(res.getReceiveAddressDetail());
|
|
|
|
|
+ kxsGdOrder.setCreateTime(LocalDateTimeUtil.parse(res.getCreateTime(), DatePattern.NORM_DATETIME_PATTERN));
|
|
|
|
|
+ gdOrderService.saveOrUpdate(kxsGdOrder);
|
|
|
|
|
+ if("6".equals(res.getStatus())){
|
|
|
|
|
+ KxsGdReport kxsGdReport = kxsGdReportMapper.selectOne(Wrappers.<KxsGdReport>lambdaQuery()
|
|
|
|
|
+ .eq(KxsGdReport::getStatus, GdReportEnum.REPORT.getType())
|
|
|
|
|
+ .eq(KxsGdReport::getIsCheck, GdReportEnum.CHECK_NO.getType())
|
|
|
|
|
+ .eq(KxsGdReport::getGdMobile, kxsGdOrder.getGdMobile()));
|
|
|
|
|
+ if (kxsGdReport == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ kxsGdReport.setIsCheck(GdReportEnum.CHECK_SUC.getType());
|
|
|
|
|
+ kxsGdReportMapper.updateById(kxsGdReport);
|
|
|
|
|
+ toSendMq(kxsGdOrder, kxsGdReport.getGdSn());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void checkGdAsyncData(Map<String, Object> param) {
|
|
|
|
|
|
|
+ public void acceptGdActData(Map<String, Object> param) {
|
|
|
|
|
|
|
|
JSONArray dataList = JSON.parseArray(param.get("data").toString());
|
|
JSONArray dataList = JSON.parseArray(param.get("data").toString());
|
|
|
if(dataList.isEmpty()){
|
|
if(dataList.isEmpty()){
|
|
@@ -178,6 +235,7 @@ public class KxsGdServiceImpl implements KxsGdService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
private void toSendMq(KxsGdOrder order, String sn){
|
|
private void toSendMq(KxsGdOrder order, String sn){
|
|
|
RabbitGdActQueueMQ.MsgEntity msgEntity = new RabbitGdActQueueMQ.MsgEntity();
|
|
RabbitGdActQueueMQ.MsgEntity msgEntity = new RabbitGdActQueueMQ.MsgEntity();
|
|
|
msgEntity.setPosSn(sn);
|
|
msgEntity.setPosSn(sn);
|
|
@@ -197,38 +255,26 @@ public class KxsGdServiceImpl implements KxsGdService {
|
|
|
+ "," + order.getGdMobile());
|
|
+ "," + order.getGdMobile());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- public List<GdQueryOrderRes.GdQueryOrder> queryCardOrders(String startTime, String endTime, int pageNo, int pageSize) {
|
|
|
|
|
-
|
|
|
|
|
|
|
+ private String sendToGd(String uri, GdCommonReq req){
|
|
|
try {
|
|
try {
|
|
|
- String url = "https://" + rsaProperties.getGd().getUrl() + "/ycsim-business/openapi/query_card_order_info";
|
|
|
|
|
|
|
+
|
|
|
|
|
+ String url = "https://" + rsaProperties.getGd().getUrl() + uri;
|
|
|
|
|
|
|
|
long timestamp = System.currentTimeMillis() / 1000;
|
|
long timestamp = System.currentTimeMillis() / 1000;
|
|
|
|
|
+ req.setTimestamp(timestamp);
|
|
|
|
|
+ req.setBrhNo(rsaProperties.getGd().getBrhNo());
|
|
|
|
|
|
|
|
- GdQueryCardOrderReq req = GdQueryCardOrderReq.builder()
|
|
|
|
|
- .queryBeginTime(startTime)
|
|
|
|
|
- .queryEndTime(endTime)
|
|
|
|
|
- .brhNo(rsaProperties.getGd().getBrhNo())
|
|
|
|
|
- .pageNo(String.valueOf(pageNo))
|
|
|
|
|
- .pageSize(String.valueOf(pageSize))
|
|
|
|
|
- .timestamp(String.valueOf(timestamp)).build();
|
|
|
|
|
String sign = GdRsaUtils.rsa256Sign(BeanUtil.beanToMap(req), rsaProperties.getGd().getPrivateKey());
|
|
String sign = GdRsaUtils.rsa256Sign(BeanUtil.beanToMap(req), rsaProperties.getGd().getPrivateKey());
|
|
|
req.setSign(sign);
|
|
req.setSign(sign);
|
|
|
- boolean b = GdRsaUtils.checkSign(BeanUtil.beanToMap(req), rsaProperties.getGd().getPublicKey());
|
|
|
|
|
- String body = JSONUtil.toJsonStr(req);
|
|
|
|
|
|
|
+ String body = JSON.toJSONString(req);
|
|
|
String response = HttpRequest.post(url)
|
|
String response = HttpRequest.post(url)
|
|
|
.header(Header.CONTENT_TYPE, "application/json")
|
|
.header(Header.CONTENT_TYPE, "application/json")
|
|
|
.body(body)
|
|
.body(body)
|
|
|
.timeout(50000)//超时,毫秒
|
|
.timeout(50000)//超时,毫秒
|
|
|
.execute().body();
|
|
.execute().body();
|
|
|
Optional.ofNullable(response).orElseThrow(() -> new GlobalCustomerException("调用接口失败"));
|
|
Optional.ofNullable(response).orElseThrow(() -> new GlobalCustomerException("调用接口失败"));
|
|
|
- GdCommRes<GdQueryOrderRes> commRes = JSONUtil.toBean(response, new TypeReference<GdCommRes<GdQueryOrderRes>>() {
|
|
|
|
|
- }, true);
|
|
|
|
|
- if (commRes.getResultCode() == 1) {
|
|
|
|
|
- return commRes.getData().getRecords();
|
|
|
|
|
- } else {
|
|
|
|
|
- throw new GlobalCustomerException(commRes.getErrorDesc());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return response;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("请求广电接口报错:{}", e.getLocalizedMessage());
|
|
log.error("请求广电接口报错:{}", e.getLocalizedMessage());
|