|
|
@@ -4,9 +4,6 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
-import org.dromara.backstage.api.RemoteCardService;
|
|
|
-import org.dromara.backstage.api.RemoteUserAccountService;
|
|
|
import org.dromara.backstage.api.domain.vo.RemoteCardVo;
|
|
|
import org.dromara.backstage.api.domain.vo.RemoteUserAccountVo;
|
|
|
import org.dromara.common.core.api.ReturnResult;
|
|
|
@@ -24,7 +21,6 @@ import org.dromara.server.consume.domain.vo.PtBagVo;
|
|
|
import org.dromara.server.consume.domain.vo.yc.BagInfo;
|
|
|
import org.dromara.server.consume.domain.vo.yc.CardBagInfo;
|
|
|
import org.dromara.server.consume.service.IPtBagService;
|
|
|
-import org.dromara.system.api.RemoteDeptService;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -44,41 +40,32 @@ import java.util.Objects;
|
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
|
public class CardBusiness {
|
|
|
- @DubboReference
|
|
|
- private final RemoteUserAccountService remoteUserAccountService;
|
|
|
- @DubboReference
|
|
|
- private final RemoteDeptService remoteDeptService;
|
|
|
- @DubboReference
|
|
|
- private final RemoteCardService remoteCardService;
|
|
|
-
|
|
|
private final IPtBagService ptBagService;
|
|
|
|
|
|
public ReturnResult getCardBagsByCardNo(Long cardNo) {
|
|
|
// RemoteCardVo remoteCardVo = remoteCardService.queryCardByCardNo(cardNo);
|
|
|
String strCardNo = String.valueOf(cardNo);
|
|
|
- RemoteCardVo remoteCardVo = JsonUtils.parseObject(RedisUtils.getCacheMapValue(CacheNames.PT_USER_CARD_NO, strCardNo).toString(), RemoteCardVo.class);
|
|
|
- if (ObjectUtil.isEmpty(remoteCardVo)) {
|
|
|
- ErrorResult result = new ErrorResult();
|
|
|
- result.setStatusCode(HttpStatus.NOT_FOUND.value());
|
|
|
- result.setMessage("获取卡片信息失败");
|
|
|
- result.getErrors()
|
|
|
- .add(new ErrorInfo(1, "获取卡片信息失败", ApiErrorTypeConstants.NOT_FOUND, "流水号为[" + cardNo + "]的卡片不存在!"));
|
|
|
-
|
|
|
- return ReturnResult.failure(ResultCodeEnum.DATA_NOT_FOUND, result);
|
|
|
+ ErrorResult errorResult = createErrorResult(cardNo);
|
|
|
+ if (RedisUtils.getCacheMapValue(CacheNames.PT_USER_CARD_NO, strCardNo) != null) {
|
|
|
+ RemoteCardVo remoteCardVo = JsonUtils.parseObject(RedisUtils.getCacheMapValue(CacheNames.PT_USER_CARD_NO, strCardNo).toString(), RemoteCardVo.class);
|
|
|
+ if (remoteCardVo == null) {
|
|
|
+ return ReturnResult.failure(ResultCodeEnum.DATA_NOT_FOUND, errorResult);
|
|
|
+ }
|
|
|
+ return ReturnResult.success(this.setCardBagInfo(remoteCardVo));
|
|
|
+ } else {
|
|
|
+ return ReturnResult.failure(ResultCodeEnum.DATA_NOT_FOUND, errorResult);
|
|
|
}
|
|
|
- return ReturnResult.success(this.setCardBagInfo(remoteCardVo));
|
|
|
}
|
|
|
|
|
|
private Object setCardBagInfo(RemoteCardVo remoteCardVo) {
|
|
|
CardBagInfo cardBagInfo = new CardBagInfo();
|
|
|
// RemoteUserAccountVo userAccountVo = remoteUserAccountService.getUserAccountVoById(remoteCardVo.getUserId());
|
|
|
String strUserId = String.valueOf(remoteCardVo.getUserId());
|
|
|
- RemoteUserAccountVo userAccountVo = RedisUtils.getCacheMapValue(CacheNames.PT_USER_ACCOUNT_ID, strUserId);
|
|
|
+ RemoteUserAccountVo userAccountVo = RedisUtils.getCacheMapValue(CacheNames.PT_USER_ACCOUNT_ID, strUserId);
|
|
|
PtBagBo bagBo = new PtBagBo();
|
|
|
bagBo.setUserId(remoteCardVo.getUserId());
|
|
|
List<PtBagVo> bagVos = ptBagService.queryList(bagBo);
|
|
|
- PtBagVo bagVo = null;
|
|
|
- BagInfo bagInfo = null;
|
|
|
+ BagInfo bagInfo;
|
|
|
for (PtBagVo vo : bagVos) {
|
|
|
bagInfo = new BagInfo();
|
|
|
bagInfo.setBagid(Integer.valueOf(vo.getBagCode()));
|
|
|
@@ -131,4 +118,14 @@ public class CardBusiness {
|
|
|
|
|
|
return cardBagInfo;
|
|
|
}
|
|
|
+
|
|
|
+ private ErrorResult createErrorResult(Long cardNo) {
|
|
|
+ ErrorResult result = new ErrorResult();
|
|
|
+ result.setStatusCode(HttpStatus.NOT_FOUND.value());
|
|
|
+ result.setMessage("获取卡片信息失败");
|
|
|
+ result.getErrors()
|
|
|
+ .add(new ErrorInfo(1, "获取卡片信息失败", ApiErrorTypeConstants.NOT_FOUND, "流水号为[" + cardNo + "]的卡片不存在!"));
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|