|
|
@@ -1,13 +1,21 @@
|
|
|
package com.zhongshu.card.server.core.service.payment;
|
|
|
|
|
|
import com.github.microservice.models.hxz.base.HxzBaseResult;
|
|
|
+import com.github.microservice.net.ResultContent;
|
|
|
+import com.zhongshu.card.client.model.payment.RequestInfoSaveParam;
|
|
|
import com.zhongshu.card.client.utils.type.payment.RequestType;
|
|
|
+import com.zhongshu.card.server.core.dao.org.UserCountDao;
|
|
|
import com.zhongshu.card.server.core.dao.payment.RequestInfoDao;
|
|
|
+import com.zhongshu.card.server.core.domain.org.UserAccount;
|
|
|
import com.zhongshu.card.server.core.domain.payment.RequestInfo;
|
|
|
import com.zhongshu.card.server.core.httpRequest.apiConf.APIResponseModel;
|
|
|
import com.zhongshu.card.client.utils.DateUtils;
|
|
|
+import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
+import com.zhongshu.card.server.core.util.CommonUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.Date;
|
|
|
@@ -23,6 +31,37 @@ public class RequestInfoService {
|
|
|
@Autowired
|
|
|
RequestInfoDao requestInfoDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ UserCountDao userCountDao;
|
|
|
+
|
|
|
+ private static Long ttlTime = 30 * 24 * 60 * 60 * 1000L;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存请求数据
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Async
|
|
|
+ public ResultContent saveRequestInfo(RequestInfoSaveParam param) {
|
|
|
+ RequestInfo requestInfo = new RequestInfo();
|
|
|
+ BeanUtils.copyProperties(param, requestInfo);
|
|
|
+ requestInfo.setTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
|
+ Long ttl = param.getTTL();
|
|
|
+ if (CommonUtil.longIsEmpty(ttl)) {
|
|
|
+ ttl = ttlTime;
|
|
|
+ }
|
|
|
+ requestInfo.setTTL(new Date(System.currentTimeMillis() + ttlTime));
|
|
|
+ if (StringUtils.isNotEmpty(param.getUserId())) {
|
|
|
+ UserAccount userAccount = userCountDao.findTopByUserId(param.getUserId());
|
|
|
+ if (userAccount != null) {
|
|
|
+ requestInfo.setUserName(userAccount.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ requestInfoDao.save(requestInfo);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 添加 HXZ 请求日志
|
|
|
*
|
|
|
@@ -38,13 +77,14 @@ public class RequestInfoService {
|
|
|
requestInfo.setMsg(response.getMsg());
|
|
|
requestInfo.setTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
|
requestInfo.setRequestType(RequestType.HXZ);
|
|
|
- requestInfo.setTTL(new Date(System.currentTimeMillis() + 30 * 24 * 60 * 60 * 1000L));
|
|
|
+ requestInfo.setTTL(new Date(System.currentTimeMillis() + ttlTime));
|
|
|
requestInfoDao.save(requestInfo);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加IOT平台访问日志
|
|
|
+ *
|
|
|
* @param param
|
|
|
* @param response
|
|
|
* @return
|
|
|
@@ -58,7 +98,7 @@ public class RequestInfoService {
|
|
|
requestInfo.setMsg(response.getMsg());
|
|
|
requestInfo.setTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
|
requestInfo.setRequestType(RequestType.IotCenter);
|
|
|
- requestInfo.setTTL(new Date(System.currentTimeMillis() + 30 * 24 * 60 * 60 * 1000L));
|
|
|
+ requestInfo.setTTL(new Date(System.currentTimeMillis() + ttlTime));
|
|
|
requestInfo.setMillis(response.getMillis());
|
|
|
requestInfoDao.save(requestInfo);
|
|
|
return true;
|