AppIdUtil.java
1.64 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
package cn.com.glsx.entmicro.util;
import cn.com.glsx.entmicro.service.EntmicroStaffService;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
/**
* @Author yelq
* @Version 1.0
* @Description: 获取appId
* @Date 2023/9/25 15:25
*/
@Slf4j
@Component
public class AppIdUtil {
@Autowired
private Environment environment;
@Autowired
private EntmicroStaffService entmicroStaffService;
/**
* 获取配置门店的appid
*
* @param merchantId
* @return
*/
public String getAppId(Integer merchantId) {
if (merchantId == null) {
return null;
}
String appid = environment.getProperty("wechat.miniprogram.url.link.appId." + merchantId);
if (appid == null) {
Integer supMerchantNo = entmicroStaffService.findSupMerchantNo(merchantId);
if (supMerchantNo == null) {
log.error("查询授权商户号失败!请联系管理员。cn.com.glsx.entmicro.util.AppIdUtil.getAppId==============");
throw new RpcServiceException("查询授权商户号失败!请联系管理员。");
}
appid = environment.getProperty("wechat.miniprogram.url.link.appId." + supMerchantNo);
}
return appid;
}
/**
* 获取默认配置的appId
*
* @return
*/
public String getDefaultAppId() {
return environment.getProperty("wechat.miniprogram.url.link.appId", "");
}
}