|
|
@ -12,8 +12,11 @@ import com.ccsens.ptos_tall.persist.dao.SysUserDao; |
|
|
|
import com.ccsens.ptos_tall.persist.dao.WxOfficialDao; |
|
|
|
import com.ccsens.ptos_tall.persist.mapper.WxOfficialUserMapper; |
|
|
|
import com.ccsens.ptos_tall.util.PtOsConstant; |
|
|
|
import com.ccsens.util.CodeEnum; |
|
|
|
import com.ccsens.util.RedisKeyManager; |
|
|
|
import com.ccsens.util.RedisUtil; |
|
|
|
import com.ccsens.util.WebConstant; |
|
|
|
import com.ccsens.util.exception.BaseException; |
|
|
|
import com.ccsens.wechatutil.bean.dto.wxmini.NoticeDto; |
|
|
|
import com.ccsens.wechatutil.bean.dto.wxofficial.WxQrCodeDto; |
|
|
|
import com.ccsens.wechatutil.bean.po.WxOauth2UserInfo; |
|
|
@ -54,7 +57,7 @@ public class WxUserService implements IWxUserService { |
|
|
|
private RedisUtil redisUtil; |
|
|
|
|
|
|
|
@Override |
|
|
|
public UserVo.AttentionOfficial createQrCode(String equipmentId, String appId, String secret) { |
|
|
|
public UserVo.AttentionOfficial createQrCode(String equipmentId, String appId, String secret,Byte type) { |
|
|
|
//如果设备id不为空则查找设备对应的公众号的信息
|
|
|
|
if(StrUtil.isNotBlank(equipmentId)){ |
|
|
|
//通过设备id查找公众号信息
|
|
|
@ -71,7 +74,7 @@ public class WxUserService implements IWxUserService { |
|
|
|
} |
|
|
|
//生成二维码
|
|
|
|
String eventKey = UUID.randomUUID().toString(); |
|
|
|
WxQrCodeVo.QrCodeUrl url = OfficialQrCodeUtil.send(new WxQrCodeDto.Create(7*24*60*60L, OfficialQrCodeUtil.QR_STR_SCENE, |
|
|
|
WxQrCodeVo.QrCodeUrl url = OfficialQrCodeUtil.send(new WxQrCodeDto.Create(7*24*60*60L, type == 0 ? OfficialQrCodeUtil.QR_STR_SCENE : OfficialQrCodeUtil.QR_LIMIT_STR_SCENE, |
|
|
|
null, eventKey), appId, secret); |
|
|
|
String qrCodeUrl = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + url.getTicket(); |
|
|
|
UserVo.AttentionOfficial attentionOfficial = new UserVo.AttentionOfficial(); |
|
|
@ -120,10 +123,16 @@ public class WxUserService implements IWxUserService { |
|
|
|
tokenBean.setId(userSign.getUserId()); |
|
|
|
tokenBean.setPhone(userSign.getPhone()); |
|
|
|
tokenBean.setAvatarUrl(userSign.getAvatarUrl()); |
|
|
|
log.info("生成token成功"); |
|
|
|
//根据eventKey更新redis内的用户关注信息
|
|
|
|
String key = PtOsConstant.OFFICIAL_EVENT_KEY + notice.getEventKey(); |
|
|
|
String eventKey = notice.getEventKey(); |
|
|
|
if (notice.getEventKey().startsWith(PtOsConstant.EVENT_KEY_PREFIX)) { |
|
|
|
eventKey = eventKey.substring(PtOsConstant.EVENT_KEY_PREFIX.length()); |
|
|
|
} |
|
|
|
String key = PtOsConstant.OFFICIAL_EVENT_KEY + eventKey; |
|
|
|
long seconds = 60L * 100L; |
|
|
|
redisUtil.set(key,tokenBean,seconds); |
|
|
|
log.info("存reids--key:{}",key); |
|
|
|
break; |
|
|
|
case "unsubscribe": |
|
|
|
//用openId查找用户
|
|
|
|