|
|
@@ -1,12 +1,20 @@
|
|
|
package com.sckw.payment.service;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.sckw.core.common.enums.NumberConstant;
|
|
|
+import com.sckw.core.utils.IdWorker;
|
|
|
+import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.payment.dao.KwpWalletRelationMapper;
|
|
|
import com.sckw.payment.model.KwpWalletRelation;
|
|
|
-import jakarta.annotation.Resource;
|
|
|
+import com.sckw.payment.model.dto.WalletRelationDto;
|
|
|
+import com.sckw.redis.constant.RedisConstant;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
@@ -15,9 +23,10 @@ import java.util.Objects;
|
|
|
*/
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
+@RequiredArgsConstructor
|
|
|
public class KwpWalletRelationService {
|
|
|
- @Resource
|
|
|
- private KwpWalletRelationMapper relationMapper;
|
|
|
+ private final KwpWalletRelationMapper relationMapper;
|
|
|
+ private final RedisTemplate<String, Object> redisTemplate;
|
|
|
|
|
|
/**
|
|
|
* 根据企业id查询中台用户
|
|
|
@@ -29,12 +38,38 @@ public class KwpWalletRelationService {
|
|
|
if (Objects.isNull(entId)) {
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
- KwpWalletRelation kwpWalletRelation = relationMapper.selectOne(new LambdaQueryWrapper<KwpWalletRelation>().eq(KwpWalletRelation::getEntId, entId).eq(KwpWalletRelation::getDelFlag, 0).last("limit 1"));
|
|
|
+ String uid = (String) redisTemplate.opsForHash().get(RedisConstant.WALLET, String.valueOf(entId));
|
|
|
+ if (StringUtils.isNotBlank(uid)) {
|
|
|
+ return uid;
|
|
|
+ }
|
|
|
+ KwpWalletRelation kwpWalletRelation = relationMapper.selectOne(new LambdaQueryWrapper<KwpWalletRelation>()
|
|
|
+ .eq(KwpWalletRelation::getEntId, entId)
|
|
|
+ .eq(KwpWalletRelation::getDelFlag, 0).last("limit 1"));
|
|
|
if (Objects.isNull(kwpWalletRelation)) {
|
|
|
return null;
|
|
|
}
|
|
|
- return kwpWalletRelation.getUid();
|
|
|
+ uid = kwpWalletRelation.getUid();
|
|
|
+ redisTemplate.opsForHash().put(RedisConstant.WALLET, String.valueOf(entId), uid);
|
|
|
+ return uid;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存关联信息
|
|
|
+ *
|
|
|
+ * @param walletRelationDto 企业关联钱包信息
|
|
|
+ */
|
|
|
+ public void save(WalletRelationDto walletRelationDto) {
|
|
|
+ KwpWalletRelation kwpWalletRelation = new KwpWalletRelation();
|
|
|
+ kwpWalletRelation.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
+ kwpWalletRelation.setEntId(walletRelationDto.entId());
|
|
|
+ kwpWalletRelation.setUid(walletRelationDto.uid());
|
|
|
+ kwpWalletRelation.setStatus(0);
|
|
|
+ kwpWalletRelation.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ kwpWalletRelation.setCreateTime(new Date());
|
|
|
+ kwpWalletRelation.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ kwpWalletRelation.setUpdateTime(new Date());
|
|
|
+ kwpWalletRelation.setDelFlag(0);
|
|
|
+ relationMapper.insert(kwpWalletRelation);
|
|
|
}
|
|
|
|
|
|
|