MallConfiguration.java
2.16 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 com.diligrp.cashier.mall;
import com.diligrp.cashier.mall.client.RtMallHttpClient;
import com.diligrp.cashier.mall.property.RtMallDynamicProperty;
import com.diligrp.cashier.shared.mybatis.MybatisMapperSupport;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.CustomExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import java.util.HashMap;
import java.util.Map;
@Configuration
@ComponentScan("com.diligrp.cashier.mall")
@MapperScan(basePackages = {"com.diligrp.cashier.mall.dao"}, markerInterface = MybatisMapperSupport.class)
public class MallConfiguration {
/**
* 创建大润发HTTP客户端
* 用于调用大润发订单详情接口
*/
@Bean
public RtMallHttpClient rtMallHttpClient(@Value("${rtmall.api.url:https://em-shop.feiniugo.com/api/externalapi/scanbuy/process}") String apiUrl,
RtMallDynamicProperty rtMallDynamicProperty) {
RtMallDynamicProperty.AppSecretDynamicProperty config = rtMallDynamicProperty.getAppSecrets().getFirst();
return new RtMallHttpClient(apiUrl, config.getAppKey(), config.getAppSecret());
}
@Bean
public Queue queue() {
return new Queue(MallConstants.CASHIER_MALL_CALLBACK_RETRY_QUEUE, true, false, false);
}
@Bean
public CustomExchange customExchange() {
Map<String, Object> args = new HashMap<>();
args.put("x-delayed-type", "direct");
return new CustomExchange(MallConstants.CASHIER_MALL_CALLBACK_RETRY_EXCHANGE, MallConstants.EXCHANGE_TYPE, true, false, args);
}
@Bean
public Binding binding(Queue queue, CustomExchange customExchange) {
return BindingBuilder.bind(queue)
.to(customExchange)
.with(MallConstants.CASHIER_MALL_CALLBACK_RETRY_QUEUE)
.noargs();
}
}