Pu Zhibing
1 天以前 878ac7cc8e1951bbc7b27619c4e7ece1e3d331ff
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
package com.ruoyi.order.util.kuaishou;
 
import com.kuaishou.locallife.open.api.KsLocalLifeApiException;
import com.kuaishou.locallife.open.api.client.KsLocalLifeAccessTokenClient;
import com.kuaishou.locallife.open.api.common.utils.GsonUtils;
import com.kuaishou.locallife.open.api.domain.locallife_order.OpenApiQueryOrderDetailInfoV1;
import com.kuaishou.locallife.open.api.request.locallife_order.GoodlifeV2TradeOrderDetailRequest;
import com.kuaishou.locallife.open.api.response.locallife_order.GoodlifeV2TradeOrderDetailResponse;
import com.ruoyi.common.redis.service.RedisService;
import lombok.extern.slf4j.Slf4j;
 
/**
 * 快手订单工具类
 * @author zhibing.pu
 * @Date 2025/6/11 18:58
 */
@Slf4j
public class OrderUtil {
    
    
    /**
     * 查询订单详情
     *
     * @return
     */
    public static OpenApiQueryOrderDetailInfoV1 queryOrderInfo(RedisService redisService, String order_id) {
        //判断token是否过期
        Object ks_access_token = redisService.getCacheObject("ks_access_token");
        if(null == ks_access_token){
            //刷新token
            com.ruoyi.order.util.kuaishou.ClientTokenUtil.refreshToken(redisService);
            ks_access_token = redisService.getCacheObject("ks_access_token");
        }
        String access_token = ks_access_token.toString();
        KsLocalLifeAccessTokenClient client = KsLocalLifeAccessTokenClient.Builder.newBuilder()
                .setAccessToken(access_token)
                .build();
        GoodlifeV2TradeOrderDetailRequest request = new GoodlifeV2TradeOrderDetailRequest();
        request.setOrder_id(order_id);
        try {
            GoodlifeV2TradeOrderDetailResponse response = client.execute(request);
            log.info("【快手】查询详情返回结果:{}", GsonUtils.toJSON(response));
            if(0 != response.getData().getError_code()){
                log.error("【快手】查询详情失败");
                return null;
            }
            return response.getData();
        } catch (KsLocalLifeApiException e) {
            log.error("查询详情失败:{}", e.getMessage());
            e.printStackTrace();
        }
        return null;
    }
    
    
}