package com.neusoft.smart.pos.utils;

import com.neusoft.smart.pos.dto.member.response.DetailedMemberResponse;
import com.neusoft.smart.pos.framework.utils.SpringUtils;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * POS使用会员Redis工具类
 */
public class PosMemberRedisUtils {
	
	private static final String REDIS_TEMPLATE = "redisTemplate";
	
	public static RedisTemplate getRedisTemplate() {
		return SpringUtils.getBean(REDIS_TEMPLATE, RedisTemplate.class);
	}
	
	/**
	 * 通过卡读取的hidCode 获取会员详情
	 *
	 * @param cardHidCode
	 * @return
	 */
	public static DetailedMemberResponse getMemberByCardHidCode(String cardHidCode) {
		DetailedMemberResponse detailedMemberResponse = (DetailedMemberResponse) getRedisTemplate().opsForValue().get(cardHidCode);
		if (null == detailedMemberResponse) {
			return null;
		}
		return detailedMemberResponse;
	}
}
