MktRpcService.java
1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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<Boolean> 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;
}
}