package cn.fw.valhalla.rpc.mkt; import cn.fw.data.base.domain.common.Message; import cn.fw.mkt.sdk.ActivityApi; import cn.fw.mkt.sdk.param.AfterSaleArchivesDto; import cn.fw.valhalla.common.constant.RedisKey; import cn.fw.valhalla.rpc.mkt.dto.QualificationDTO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import static cn.fw.common.businessvalidator.Validator.BV; /** * 市场活动rpc * * @author : kurisu * @version : 1.0 * @className : MktRpcService * @description : 市场活动rpc * @date : 2023-03-25 17:05 */ @Slf4j @Service @RequiredArgsConstructor public class MktRpcService { private final ActivityApi activityApi; /** * 查询活动资格 * * @param dto * @return */ @Cacheable(cacheNames = RedisKey.MKT_QUA, key = "#dto.getArchiveId()+':'+#dto.getActivityNo()", condition = "null != #result") public Boolean queryQualifications(final QualificationDTO dto) { if (dto == null) { return Boolean.FALSE; } try { AfterSaleArchivesDto archivesDto = new AfterSaleArchivesDto(); BeanUtils.copyProperties(dto, archivesDto); final Message msg = activityApi.afterSaleSignUpJudge(archivesDto); boolean success = msg.isSuccess(); BV.isTrue(success, () -> String.format("调用活动系统失败:%s", msg.getResult())); return Boolean.TRUE.equals(msg.getData()); } catch (Exception e) { log.warn("查询活动资格失败: {}", e.getMessage()); } return null; } }