jiangping
2024-09-27 04b4bddaac0a222760113899568d20b45af701f4
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
package com.doumee.core.wx;
 
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.config.mybatis.SpringUtils;
import com.doumee.core.utils.Constants;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
 
import javax.annotation.PostConstruct;
 
/**
 * 微信小程序组件
 */
@Configuration
public class WxMiniConfig {
    /********客户端 微信小程序服务**********/
    public static WxMaService wxCustomerService;
    /********员工端 微信小程序服务**********/
    public static WxMaService wxPersonnelService;
 
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
 
    public static WxMiniConfig me() {
        return SpringUtils.get().getBean(WxMiniConfig.class);
    }
 
    @PostConstruct
    void init() {
        this.load_WxCustomerService();
        this.load_WxPersonnelService();
    }
    /**
     * 初始化微信小程序
     */
    public void load_WxCustomerService() {
        WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
        config.setAppid(StringUtils.trimToNull(systemDictDataBiz.queryByCode(Constants.WX_MINI_CONFIG,Constants.WX_APPID_CUSTOMER).getCode()));
        config.setSecret(StringUtils.trimToNull(systemDictDataBiz.queryByCode(Constants.WX_MINI_CONFIG,Constants.WX_SECRET_CUSTOMER).getCode()));
        config.setMsgDataFormat("JSON");
        WxMaService wxMaService = new WxMaServiceImpl();
        wxMaService.setWxMaConfig(config);
        this.wxCustomerService = wxMaService;
    }
 
 
 
    public void load_WxPersonnelService() {
        WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
        config.setAppid(StringUtils.trimToNull(systemDictDataBiz.queryByCode(Constants.WX_MINI_CONFIG,Constants.WX_APPID_PERSONNEL).getCode()));
        config.setSecret(StringUtils.trimToNull(systemDictDataBiz.queryByCode(Constants.WX_MINI_CONFIG,Constants.WX_SECRET_PERSONNEL).getCode()));
        config.setMsgDataFormat("JSON");
        WxMaService wxMaService = new WxMaServiceImpl();
        wxMaService.setWxMaConfig(config);
        this.wxPersonnelService = wxMaService;
    }
}