|
|
@@ -29,11 +29,15 @@ import org.dromara.common.core.enums.CardOpenEnum;
|
|
|
import org.dromara.common.core.enums.CardStatusEnum;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
+import org.dromara.common.json.utils.JsonUtils;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.dromara.common.redis.utils.RedisUtils;
|
|
|
import org.dromara.common.tenant.helper.TenantHelper;
|
|
|
import org.dromara.hotel.api.service.RemoteCardDataService;
|
|
|
+import org.springframework.cache.annotation.CachePut;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
+import org.springframework.cache.annotation.Caching;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.smartcardio.Card;
|
|
|
@@ -299,12 +303,16 @@ public class PtCardServiceImpl implements IPtCardService {
|
|
|
*/
|
|
|
@Override
|
|
|
public boolean lockCard(Long cardId) {
|
|
|
- // sendCloudConsume(baseMapper.selectVoById(cardId));
|
|
|
- return baseMapper.update(null, new LambdaUpdateWrapper<PtCard>()
|
|
|
+ int iCount = baseMapper.update(null, new LambdaUpdateWrapper<PtCard>()
|
|
|
.set(PtCard::getStatus, '2')
|
|
|
.set(PtCard::getChangeTime, DateUtil.date())
|
|
|
.eq(PtCard::getStatus, '1')
|
|
|
- .eq(PtCard::getCardId, cardId)) > 0;
|
|
|
+ .eq(PtCard::getCardId, cardId));
|
|
|
+ if (iCount > 0) {
|
|
|
+ resetCardCache(cardId);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -315,12 +323,16 @@ public class PtCardServiceImpl implements IPtCardService {
|
|
|
*/
|
|
|
@Override
|
|
|
public boolean unlockCard(Long cardId) {
|
|
|
- // sendCloudConsume(baseMapper.selectVoById(cardId));
|
|
|
- return baseMapper.update(null, new LambdaUpdateWrapper<PtCard>()
|
|
|
+ int iCount = baseMapper.update(null, new LambdaUpdateWrapper<PtCard>()
|
|
|
.set(PtCard::getStatus, '1')
|
|
|
.set(PtCard::getChangeTime, DateUtil.date())
|
|
|
.eq(PtCard::getStatus, '2')
|
|
|
- .eq(PtCard::getCardId, cardId)) > 0;
|
|
|
+ .eq(PtCard::getCardId, cardId));
|
|
|
+ if (iCount > 0) {
|
|
|
+ resetCardCache(cardId);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -648,4 +660,17 @@ public class PtCardServiceImpl implements IPtCardService {
|
|
|
)
|
|
|
));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新指定Id的卡片缓存数据
|
|
|
+ * @param cardId 卡片Id
|
|
|
+ */
|
|
|
+ private void resetCardCache(Long cardId) {
|
|
|
+ PtCardVo vo = baseMapper.selectVoById(cardId);
|
|
|
+
|
|
|
+ RedisUtils.setCacheMapValue(CacheNames.PT_USER_CARD_FACTORYID,vo.getFactoryId().toString(),JsonUtils.toJsonString(vo));
|
|
|
+ RedisUtils.setCacheMapValue(CacheNames.PT_USER_CARD_USER_ID,vo.getUserId().toString(),JsonUtils.toJsonString(vo));
|
|
|
+ RedisUtils.setCacheMapValue(CacheNames.PT_USER_CARD_NO,vo.getCardNo().toString(),JsonUtils.toJsonString(vo));
|
|
|
+ }
|
|
|
+
|
|
|
}
|