| | |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import cn.binarywang.wx.miniapp.config.WxMaConfig; |
| | | import cn.binarywang.wx.miniapp.config.impl.WxMaRedisBetterConfigImpl; |
| | | import cn.binarywang.wx.miniapp.config.impl.WxMaRedisConfigImpl; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | 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 me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps; |
| | | import me.chanjar.weixin.common.redis.WxRedisOps; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import cn.binarywang.wx.miniapp.api.WxMaService; |
| | |
| | | @Resource |
| | | private WxMaProperties properties; |
| | | |
| | | public WxMaService getMaService() { |
| | | @Resource |
| | | private WxH5Properties wxH5Properties; |
| | | |
| | | @Resource |
| | | private WxMaRHProperties wxMaRHProperties; |
| | | |
| | | @Resource |
| | | private StringRedisTemplate stringRedisTemplate; |
| | | |
| | | @Resource |
| | | private UserService userService; |
| | | |
| | | public WxMaService getMaService(String appid) { |
| | | WxRedisOps redisOps = new RedisTemplateWxRedisOps(stringRedisTemplate); |
| | | WxMaRedisBetterConfigImpl config = new WxMaRedisBetterConfigImpl(redisOps, "access_token"); |
| | | if(StringUtils.isNotEmpty(appid)){ |
| | | R<SysAppConfigVO> r=userService.selectByAppid(appid); |
| | | if(R.isOk(r)){ |
| | | SysAppConfigVO sysAppConfigVO= r.getData(); |
| | | config.setAppid(sysAppConfigVO.getAppId()); |
| | | config.setSecret(sysAppConfigVO.getSecret()); |
| | | config.setMsgDataFormat(properties.getMsgDataFormat()); |
| | | } |
| | | } |
| | | else{ |
| | | config.setAppid(properties.getAppid()); |
| | | config.setSecret(properties.getSecret()); |
| | | config.setMsgDataFormat(properties.getMsgDataFormat()); |
| | | } |
| | | WxMaService wxMaService = new WxMaServiceImpl(); |
| | | wxMaService.setWxMaConfig(config); |
| | | return wxMaService; |
| | | } |
| | | |
| | | public WxMaService getMaH5Service() { |
| | | WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); |
| | | config.setAppid(properties.getAppid()); |
| | | config.setSecret(properties.getSecret()); |
| | | config.setMsgDataFormat(properties.getMsgDataFormat()); |
| | | config.setAppid(wxH5Properties.getAppid()); |
| | | config.setSecret(wxH5Properties.getSecret()); |
| | | config.setMsgDataFormat(wxH5Properties.getMsgDataFormat()); |
| | | WxMaService wxMaService = new WxMaServiceImpl(); |
| | | wxMaService.setWxMaConfig(config); |
| | | return wxMaService; |
| | | } |
| | | |
| | | public WxMaService getMaRhService() { |
| | | WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); |
| | | config.setAppid(wxMaRHProperties.getAppid()); |
| | | config.setSecret(wxMaRHProperties.getSecret()); |
| | | config.setMsgDataFormat(wxMaRHProperties.getMsgDataFormat()); |
| | | WxMaService wxMaService = new WxMaServiceImpl(); |
| | | wxMaService.setWxMaConfig(config); |
| | | return wxMaService; |