| | |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.user.SysAppConfigVO; |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import cn.binarywang.wx.miniapp.api.WxMaService; |
| | |
| | | @Resource |
| | | private WxMaProperties properties; |
| | | |
| | | public WxMaService getMaService() { |
| | | @Resource |
| | | private UserService userService; |
| | | |
| | | public WxMaService getMaService(String areaCode) { |
| | | WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); |
| | | WxMaService wxMaService = new WxMaServiceImpl(); |
| | | if(StringUtils.isNotEmpty(areaCode)) { |
| | | R<SysAppConfigVO> r = userService.selectByAreaCode(areaCode); |
| | | if(R.isOk(r)) { |
| | | SysAppConfigVO sysAppConfigVO = r.getData(); |
| | | config.setAppid(sysAppConfigVO.getAppId()); |
| | | config.setSecret(sysAppConfigVO.getSecret()); |
| | | config.setMsgDataFormat(properties.getMsgDataFormat()); |
| | | wxMaService.setWxMaConfig(config); |
| | | return wxMaService; |
| | | } |
| | | } |
| | | config.setAppid(properties.getAppid()); |
| | | config.setSecret(properties.getSecret()); |
| | | config.setMsgDataFormat(properties.getMsgDataFormat()); |
| | | WxMaService wxMaService = new WxMaServiceImpl(); |
| | | wxMaService.setWxMaConfig(config); |
| | | return wxMaService; |
| | | } |