Pu Zhibing
2025-03-18 f615ec5c9239327740948501627545f8e78e2a9e
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
package com.ruoyi.order.event;
 
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.model.AppUser;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
 
@RequiredArgsConstructor
@Component
@Slf4j
public class PayEventListener {
    private final AppUserClient appUserClient;
 
    /**
     * 检查会员等级变更
     */
    @Async
    @EventListener(PayEvent.class)
    public void checkVipChange(PayEvent event) {
        String source = (String) event.getSource();
        AppUser appUsers = JSONObject.parseObject(source, AppUser.class);
        appUserClient.vipConsumption(appUsers.getId());
    }
 
    /**
     * 积分变更
     */
    @Async
    @EventListener(PayEvent.class)
    public void checkCouponChange(PayEvent event) {
        // TODO
    }
 
}