PointsOperationServiceImpl.java
3.13 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.topdraw.business.process.service.impl;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.points.available.domain.PointsAvailable;
import com.topdraw.business.module.points.available.service.PointsAvailableService;
import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO;
import com.topdraw.business.module.points.detail.domain.PointsDetail;
import com.topdraw.business.module.points.detail.service.PointsDetailService;
import com.topdraw.business.process.service.PointsOperationService;
import com.topdraw.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
/**
*
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
@Slf4j
public class PointsOperationServiceImpl implements PointsOperationService {
@Autowired
private PointsDetailService pointsDetailService;
@Autowired
private PointsAvailableService pointsAvailableService;
@Autowired
private MemberService memberService;
@Autowired
ThreadPoolTaskExecutor threadPoolTaskExecutor;
public void asyncMemberPoint(Member member) {
log.info("修改会员积分,参数 =>> {}", member);
String code = member.getCode();
if (StringUtils.isBlank(code)) {
log.error("修改会员积分失败,参数错误,会员code为空");
return;
}
MemberDTO memberDTO = this.memberService.findByCode(code);
if (Objects.nonNull(memberDTO.getId())) {
member.setId(memberDTO.getId());
this.memberService.doUpdateMemberPoints(member);
}
}
public void asyncPointsAvailable(PointsAvailable pointsAvailable) {
String memberCode = pointsAvailable.getMemberCode();
MemberDTO memberDTO = this.memberService.findByCode(memberCode);
if (Objects.nonNull(memberDTO.getId())) {
pointsAvailable.setMemberId(memberDTO.getId());
this.pointsAvailableService.create4Custom(pointsAvailable);
}
}
public void asyncPointsDetail(PointsDetail pointsDetail) {
String memberCode = pointsDetail.getMemberCode();
MemberDTO memberDTO = this.memberService.findByCode(memberCode);
if (Objects.nonNull(memberDTO.getId())) {
pointsDetail.setMemberId(memberDTO.getId());
this.pointsDetailService.create4Custom(pointsDetail);
}
}
public void asyncDeletePointsAvailable(PointsAvailable pointsAvailable) {
String code = pointsAvailable.getCode();
PointsAvailableDTO pointsAvailableDTO = this.pointsAvailableService.getByCode(code);
this.pointsAvailableService.delete(pointsAvailableDTO.getId());
}
}