| | |
| | | try { |
| | | // String openId = "oMIR-5S9rpsWAVUUrNKoVDQbn5Mw";//zj的openid |
| | | String openId = "oMIR-5dWyNyWCCKMl7-kYzvyHOjs";// lyq的openid |
| | | String accessToken = util.getAppAccessToken(); |
| | | String accessToken = util.getAccessToken(); |
| | | // sendSubscribeHDJJKS(openId,accessToken,"测试活动即将开始标题","2021-08-04 13:00:00","成都市","50");//活动即将开始 |
| | | // sendSubscribeHDQX(openId,accessToken,"取消活动测试标题","2021-08-04 13:00:00");//活动取消 |
| | | // sendSubscribeHDBG(openId,accessToken,"活动名称","2021-08-05","活动变更地址","2021-08-06","活动地址");//活动变更 |
| | |
| | | import org.apache.commons.fileupload.disk.DiskFileItemFactory; |
| | | import org.apache.http.entity.ContentType; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.data.redis.core.ValueOperations; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.Resource; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class WxXCXTempSend extends BaseController { |
| | |
| | | private static String ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential"; |
| | | private static String APP_IMAGE_URL = "https://www.psciio.com//idcard/8fa82cfba258498eab2fa818220fb592.jpg"; |
| | | private static String APP_IMAGE_NAME = "5.jpg"; |
| | | @Autowired |
| | | private StringRedisTemplate redisTemplate; |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | private static WxXCXTempSend wxXCXTempSend; |
| | | /** |
| | | * url转变为 MultipartFile对象 |
| | | * |
| | |
| | | * @return |
| | | */ |
| | | public String getAccessToken() throws Exception { |
| | | // String accessToken = ; |
| | | // Boolean aBoolean = redisTemplate.hasKey(SecurityConstants.APPLETS_ACCESS_TOKEN); |
| | | // ValueOperations<String, String> valueOperations = redisTemplate.opsForValue(); |
| | | // if(aBoolean){ |
| | | // Long expireTime = Long.parseLong(valueOperations.get(SecurityConstants.APPLETS_ACCESS_TOKEN_TIME)); |
| | | // if(expireTime <= System.currentTimeMillis()){ |
| | | // redisTemplate.delete(SecurityConstants.APPLETS_ACCESS_TOKEN);//如果过期则删除 |
| | | // redisTemplate.delete(SecurityConstants.APPLETS_ACCESS_TOKEN_TIME);//如果过期则删除 |
| | | // |
| | | // valueOperations.set(SecurityConstants.APPLETS_ACCESS_TOKEN, accessToken); |
| | | // valueOperations.set(SecurityConstants.APPLETS_ACCESS_TOKEN_TIME, System.currentTimeMillis() + 1100000 + ""); |
| | | // }else{ |
| | | // accessToken = valueOperations.get(SecurityConstants.APPLETS_ACCESS_TOKEN); |
| | | // } |
| | | // }else{ |
| | | // accessToken = getAppAccessToken(); |
| | | // valueOperations.set(SecurityConstants.APPLETS_ACCESS_TOKEN, accessToken); |
| | | // valueOperations.set(SecurityConstants.APPLETS_ACCESS_TOKEN_TIME, System.currentTimeMillis() + 1100000 + ""); |
| | | // } |
| | | return getAppAccessToken(); |
| | | String accessToken = ""; |
| | | Boolean aBoolean = wxXCXTempSend.redisTemplate.hasKey(SecurityConstants.APPLETS_ACCESS_TOKEN); |
| | | ValueOperations<String, String> valueOperations = wxXCXTempSend.redisTemplate.opsForValue(); |
| | | if(aBoolean){ |
| | | Long expireTime = Long.parseLong(valueOperations.get(SecurityConstants.APPLETS_ACCESS_TOKEN_TIME)); |
| | | if(expireTime <= System.currentTimeMillis()){ |
| | | wxXCXTempSend.redisTemplate.delete(SecurityConstants.APPLETS_ACCESS_TOKEN);//如果过期则删除 |
| | | wxXCXTempSend.redisTemplate.delete(SecurityConstants.APPLETS_ACCESS_TOKEN_TIME);//如果过期则删除 |
| | | |
| | | valueOperations.set(SecurityConstants.APPLETS_ACCESS_TOKEN, accessToken); |
| | | valueOperations.set(SecurityConstants.APPLETS_ACCESS_TOKEN_TIME, System.currentTimeMillis() + 1100000 + ""); |
| | | }else{ |
| | | accessToken = valueOperations.get(SecurityConstants.APPLETS_ACCESS_TOKEN); |
| | | } |
| | | }else{ |
| | | accessToken = getAppAccessToken(); |
| | | valueOperations.set(SecurityConstants.APPLETS_ACCESS_TOKEN, accessToken); |
| | | valueOperations.set(SecurityConstants.APPLETS_ACCESS_TOKEN_TIME, System.currentTimeMillis() + 1100000 + ""); |
| | | } |
| | | return accessToken; |
| | | } |
| | | |
| | | public String getAppAccessToken() throws Exception { |
| | |
| | | return null; |
| | | } |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | wxXCXTempSend = this; |
| | | wxXCXTempSend.redisTemplate = this.redisTemplate; |
| | | } |
| | | |
| | | } |
| | |
| | | if (!ObjectUtils.isEmpty(activitySignVOS)) { |
| | | try { |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | String accessToken = util.getAppAccessToken(); |
| | | String accessToken = util.getAccessToken(); |
| | | // 遍历参与活动人员列表 |
| | | activitySignVOS.forEach(activitySignVO1 -> { |
| | | Long aLong = activitySignVO1.getId(); |
| | |
| | | result += "…"; |
| | | } |
| | | R<SysTemplateConfigVO> sysTemplateConfigVO=userService.selectTemplate(this.getAreaCode(),4); |
| | | WxUtil.sendSubscribeSHZT(openid, util.getAppAccessToken(), "微心愿", |
| | | WxUtil.sendSubscribeSHZT(openid, util.getAccessToken(), "微心愿", |
| | | DateUtils.format(comActMicroWishVO1.getExamineAt(), DateUtils.ymdhms_format), |
| | | result,sysTemplateConfigVO.getData().getTemplateId()); |
| | | } catch (Exception e) { |
| | |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | R<SysTemplateConfigVO> sysTemplateConfigVO=userService.selectTemplate(this.getAreaCode(),4); |
| | | try { |
| | | WxUtil.sendSubscribeSHZT(openid, util.getAppAccessToken(), "微心愿", |
| | | WxUtil.sendSubscribeSHZT(openid, util.getAccessToken(), "微心愿", |
| | | DateUtils.format(comActMicroWishVO1.getExamineAt(), DateUtils.ymdhms_format), |
| | | "审核通过",sysTemplateConfigVO.getData().getTemplateId()); |
| | | } catch (Exception e) { |
| | |
| | | result = result.substring(0, 4); |
| | | result += "…"; |
| | | } |
| | | WxUtil.sendSubscribeSHZT(openid, util.getAppAccessToken(), "随手拍", |
| | | WxUtil.sendSubscribeSHZT(openid, util.getAccessToken(), "随手拍", |
| | | DateUtils.format(comActEasyPhotoVO1.getExamineAt(), DateUtils.ymdhms_format), result,sysTemplateConfigVO.getData().getTemplateId()); |
| | | } catch (Exception e) { |
| | | log.error("消息推送失败,失败原因:" + e.getMessage()); |
| | |
| | | String openid = userResult.getData().toString(); |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | try { |
| | | WxUtil.sendSubscribeSHZT(openid, util.getAppAccessToken(), "随手拍", |
| | | WxUtil.sendSubscribeSHZT(openid, util.getAccessToken(), "随手拍", |
| | | DateUtils.format(comActEasyPhotoVO1.getExamineAt(), DateUtils.ymdhms_format), "审核通过",sysTemplateConfigVO.getData().getTemplateId()); |
| | | } catch (Exception e) { |
| | | log.error("消息推送失败,失败原因:" + e.getMessage()); |
| | |
| | | R<SysTemplateConfigVO> sysTemplateConfigVO=userService.selectTemplate(this.getAreaCode(),5); |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | try { |
| | | WxUtil.sendSubscribeRZSH(openid, util.getAppAccessToken(), "志愿者认证", |
| | | WxUtil.sendSubscribeRZSH(openid, util.getAccessToken(), "志愿者认证", |
| | | DateUtils.format(comMngVolunteerMngVO1.getCreateAt(), DateUtils.ymdhms_format), "审核通过",sysTemplateConfigVO.getData().getTemplateId()); |
| | | } catch (Exception e) { |
| | | log.error("消息推送失败,失败原因:" + e.getMessage()); |
| | |
| | | R<SysTemplateConfigVO> sysTemplateConfigVO=userService.selectTemplate(this.getAreaCode(),5); |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | try { |
| | | WxUtil.sendSubscribeRZSH(openid, util.getAppAccessToken(), "志愿者认证", |
| | | WxUtil.sendSubscribeRZSH(openid, util.getAccessToken(), "志愿者认证", |
| | | DateUtils.format(comMngVolunteerMngVO1.getCreateAt(), DateUtils.ymdhms_format), |
| | | "审核驳回,驳回原因:" + comMngVolunteerMngVO1.getRejectReson(),sysTemplateConfigVO.getData().getTemplateId()); |
| | | } catch (Exception e) { |
| | |
| | | R<SysTemplateConfigVO> sysTemplateConfigVO=userService.selectTemplate(this.getAreaCode(),5); |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | try { |
| | | WxUtil.sendSubscribeRZSH(openid, util.getAppAccessToken(), "党员认证", |
| | | WxUtil.sendSubscribeRZSH(openid, util.getAccessToken(), "党员认证", |
| | | DateUtils.format(vo1.getCreateAt(), DateUtils.ymdhms_format), "审核通过",sysTemplateConfigVO.getData().getTemplateId()); |
| | | } catch (Exception e) { |
| | | log.error("消息推送失败,失败原因:" + e.getMessage()); |
| | |
| | | R<SysTemplateConfigVO> sysTemplateConfigVO=userService.selectTemplate(this.getAreaCode(),5); |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | try { |
| | | WxUtil.sendSubscribeRZSH(openid, util.getAppAccessToken(), "党员认证", |
| | | WxUtil.sendSubscribeRZSH(openid, util.getAccessToken(), "党员认证", |
| | | DateUtils.format(vo1.getCreateAt(), DateUtils.ymdhms_format), |
| | | "审核驳回,驳回原因:" + partyBuildingMemberVO.getRefuseReason(),sysTemplateConfigVO.getData().getTemplateId()); |
| | | } catch (Exception e) { |
| | |
| | | String openid = userResult.getData().toString(); |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | try { |
| | | WxUtil.sendSubscribeSHZT(openid, util.getAppAccessToken(), "房屋租售", |
| | | WxUtil.sendSubscribeSHZT(openid, util.getAccessToken(), "房屋租售", |
| | | DateUtils.format(nowDate, DateUtils.ymdhms_format), "审核通过",sysTemplateConfigVO.getData().getTemplateId()); |
| | | } catch (Exception e) { |
| | | log.error("消息推送失败,失败原因:" + e.getMessage()); |
| | |
| | | result = result.substring(0, 4); |
| | | result += "…"; |
| | | } |
| | | WxUtil.sendSubscribeSHZT(openid, util.getAppAccessToken(), "房屋租售", |
| | | WxUtil.sendSubscribeSHZT(openid, util.getAccessToken(), "房屋租售", |
| | | DateUtils.format(nowDate, DateUtils.ymdhms_format), result,sysTemplateConfigVO.getData().getTemplateId()); |
| | | } catch (Exception e) { |
| | | log.error("消息推送失败,失败原因:" + e.getMessage()); |
| | |
| | | try { |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | R<SysTemplateConfigVO> sysTemplateConfigVO=userService.selectTemplate(eldersAuthFeedbackAddDTO.getAreaCode(),5); |
| | | String accessToken = util.getAppAccessToken(); |
| | | String accessToken = util.getAccessToken(); |
| | | WxUtil.sendSubscribeRZSH(openid, accessToken, "高龄认证", |
| | | DateUtils.format(eldersAuthDO.getCreateAt(), DateUtils.ymdhms_format), |
| | | eldersAuthFeedbackAddDTO.getFeedBack(),sysTemplateConfigVO.getData().getTemplateId()); |
| | |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | String accessToken = null; |
| | | try { |
| | | accessToken = util.getXQAppAccessToken(); |
| | | accessToken = util.getAccessToken(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | String accessToken = null; |
| | | try { |
| | | accessToken = util.getXQAppAccessToken(); |
| | | accessToken = util.getAccessToken(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | String accessToken = null; |
| | | try { |
| | | accessToken = util.getXQAppAccessToken(); |
| | | accessToken = util.getAccessToken(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | if (!activitySignVOS.isEmpty()) { |
| | | try { |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | String accessToken = util.getAppAccessToken(); |
| | | String accessToken = util.getAccessToken(); |
| | | ComActDO comActDO=comActDAO.selectById(comActActivityDO.getCommunityId()); |
| | | R<SysTemplateConfigVO> r=userService.selectTemplate(comActDO.getAreaCode(),1); |
| | | activitySignVOS.forEach(activitySignVO1 -> { |
| | |
| | | if (!actActivityList.isEmpty()) { |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | try { |
| | | String accessToken = util.getAppAccessToken(); |
| | | String accessToken = util.getAccessToken(); |
| | | actActivityList.forEach(actActivity -> { |
| | | ComActDO comActDO=comActDAO.selectById(actActivity.getCommunityId()); |
| | | R<SysTemplateConfigVO> r=userService.selectTemplate(comActDO.getAreaCode(),9); |
| | |
| | | SysTemplateConfig sysTemplateConfig=sysTemplateConfigDao.selectOne(new QueryWrapper<SysTemplateConfig>().lambda().eq(SysTemplateConfig::getAreaCode, grantRewardDTO.getAreaCode()).eq(SysTemplateConfig::getType,7)); |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | try { |
| | | WxUtil.sendSubscribeJLDZ(openid, util.getAppAccessToken(), "随手拍有奖活动", |
| | | WxUtil.sendSubscribeJLDZ(openid, util.getAccessToken(), "随手拍有奖活动", |
| | | grantRewardDTO.getAmount(), activityType,sysTemplateConfig.getTemplateId()); |
| | | } catch (Exception e) { |
| | | log.error("消息推送失败,失败原因:" + e.getMessage()); |
| | |
| | | ComActDO comActDO=comActDAO.selectById(comActMessageBackVO.getCommunityId()); |
| | | R<SysTemplateConfigVO> r=userService.selectTemplate(comActDO.getAreaCode(),2); |
| | | try { |
| | | WxUtil.sendSubscribeLYHF(openid, util.getAppAccessToken(), comActMessageBackVO.getUserName(), |
| | | WxUtil.sendSubscribeLYHF(openid, util.getAccessToken(), comActMessageBackVO.getUserName(), |
| | | DateUtils.format(new Date(), DateUtils.ymdhms_format), comActMessageBackVO.getMsgContent(),r.getData().getTemplateId()); |
| | | } catch (Exception e) { |
| | | log.error("消息推送失败,失败原因:" + e.getMessage()); |
| | |
| | | if (map != null) { |
| | | String openid = map.get("openid"); |
| | | try { |
| | | WxUtil.sendSubscribeYYTX(openid, util.getAppAccessToken(), "预约成功", |
| | | WxUtil.sendSubscribeYYTX(openid, util.getAccessToken(), "预约成功", |
| | | reserveDO.getTitle(), reserveRecordDO.getName(), makeHandleDTO.getMakeTime(),sysTemplateConfigVO.getData().getTemplateId()); |
| | | } catch (Exception e) { |
| | | log.error("消息推送失败,失败原因:" + e.getMessage()); |
| | |
| | | if (map != null) { |
| | | String openid = map.get("openid"); |
| | | try { |
| | | WxUtil.sendSubscribeYYTX(openid, util.getAppAccessToken(), "预约失败", |
| | | WxUtil.sendSubscribeYYTX(openid, util.getAccessToken(), "预约失败", |
| | | reserveDO.getTitle(), reserveRecordDO.getName(), DateUtils.format(reserveRecordDO.getReserveTime(),DateUtils.ymdhms_format),sysTemplateConfigVO.getData().getTemplateId()); |
| | | } catch (Exception e) { |
| | | log.error("消息推送失败,失败原因:" + e.getMessage()); |
| | |
| | | SysTemplateConfig sysTemplateConfig=sysTemplateConfigDao.selectOne(new QueryWrapper<SysTemplateConfig>().lambda().eq(SysTemplateConfig::getAreaCode, comActDO.getAreaCode()).eq(SysTemplateConfig::getType,7)); |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | try { |
| | | WxUtil.sendSubscribeJLDZ(openid, util.getAppAccessToken(), "随手拍有奖活动", |
| | | WxUtil.sendSubscribeJLDZ(openid, util.getAccessToken(), "随手拍有奖活动", |
| | | amount.setScale(2, RoundingMode.HALF_UP), activityTypeName,sysTemplateConfig.getTemplateId()); |
| | | } catch (Exception e) { |
| | | log.error("消息推送失败,失败原因:" + e.getMessage()); |
| | |
| | | String openid = map.get("openid"); |
| | | try { |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | String accessToken = util.getAppAccessToken(); |
| | | String accessToken = util.getAccessToken(); |
| | | R<SysTemplateConfigVO> sysTemplateConfigVO=userService.selectTemplate(areaCode,5); |
| | | WxUtil.sendSubscribeRZSH(openid, accessToken, name, |
| | | DateUtils.format(new Date(), DateUtils.ymdhms_format), |
| | |
| | | String openid = map.get("openid"); |
| | | try { |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | String accessToken = util.getAppAccessToken(); |
| | | String accessToken = util.getAccessToken(); |
| | | R<SysTemplateConfigVO> sysTemplateConfigVO=userService.selectTemplate(areaCode,5); |
| | | WxUtil.sendSubscribeRZSH(openid, accessToken, name, |
| | | DateUtils.format(new Date(), DateUtils.ymdhms_format), |
| | |
| | | String accessToken; |
| | | { |
| | | try { |
| | | accessToken = wxXCXTempSend.getXQAppAccessToken(); |
| | | accessToken = wxXCXTempSend.getAccessToken(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | (select count(id) from com_mng_population where village_id = cmb.village_id and floor = cmb.`name`) as populationNum |
| | | FROM |
| | | com_mng_building AS cmb |
| | | LEFT JOIN com_mng_village AS cmv ON cmv.village_id = cmb.village_id |
| | | inner JOIN com_mng_village AS cmv ON cmv.village_id = cmb.village_id |
| | | <where> |
| | | <if test="pageBuildingListDto.communityId != null"> |
| | | and cmb.act_id = #{pageBuildingListDto.communityId} |
| | |
| | | // 实名认证成功推送订阅消息给用户 |
| | | try { |
| | | WxXCXTempSend util = new WxXCXTempSend(); |
| | | String accessToken = util.getAppAccessToken(); |
| | | String accessToken = util.getAccessToken(); |
| | | SysTemplateConfig sysTemplateConfig=sysTemplateConfigDao.selectOne(new QueryWrapper<SysTemplateConfig>().lambda().eq(SysTemplateConfig::getAreaCode, loginUserInfoVO.getComActVO()).eq(SysTemplateConfig::getType,5)); |
| | | // 用户实名认证推送消息 |
| | | WxUtil.sendSubscribeRZSH(user.getOpenid(), accessToken, "实名认证", |