| | |
| | | package com.matrix.system.shopXcx.api.action; |
| | | |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplate; |
| | | import com.matrix.component.redis.RedisUserLoginUtils; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.matrix.component.tools.AES; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import com.matrix.system.common.init.UserCacheManager; |
| | | import com.matrix.system.hive.bean.SysVipInfo; |
| | | import com.matrix.system.hive.dao.SysVipInfoDao; |
| | | import com.matrix.system.shopXcx.api.pojo.BindingPhoneNumberPOJO; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * @author jiangyouyao |
| | |
| | | private SysVipInfoDao sysVipInfoDao; |
| | | |
| | | @Autowired |
| | | private RedisUserLoginUtils redisUserLoginUtils; |
| | | private UserCacheManager userCacheManager; |
| | | |
| | | @Autowired |
| | | private RabiitMqTemplate mqTemplate; |
| | | |
| | | @Value("${evn}") |
| | | private String evn; |
| | |
| | | if (StringUtils.isBlank(bindingPhoneNumber.getPhoneNumber())) { |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "手机号码不能为空"); |
| | | } |
| | | //验证通过将手机号加入相应的用户数据中 |
| | | SysVipInfo sysVipInfo = new SysVipInfo(); |
| | | SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class); |
| | | sysVipInfo.setId(loginUser.getId()); |
| | | if(loginUser.getShopId()==null){ |
| | | sysVipInfo.setShopId(bindingPhoneNumber.getShopId()); |
| | | SysVipInfo loginUser = userCacheManager.getLoginUser(); |
| | | |
| | | |
| | | SysVipInfo oldeUser = sysVipInfoDao.selectByPhone(bindingPhoneNumber.getPhoneNumber(), loginUser.getCompanyId()); |
| | | if(oldeUser!=null && !Objects.equals(oldeUser.getId(),loginUser.getId())){ |
| | | oldeUser.setIsSales(loginUser.getIsSales()); |
| | | oldeUser.setOpenId(loginUser.getOpenId()); |
| | | oldeUser.setSessionKey(loginUser.getSessionKey()); |
| | | oldeUser.setPhoto(loginUser.getPhoto()); |
| | | oldeUser.setNickName(loginUser.getNickName()); |
| | | oldeUser.setAvatarUrl(loginUser.getAvatarUrl()); |
| | | sysVipInfoDao.update(oldeUser); |
| | | LogUtil.info("绑定手机号码删除老会员openId。。"+ JSON.toJSONString(loginUser)); |
| | | // sysVipInfoDao.deleteLogicByIds(Arrays.asList(loginUser.getId())); |
| | | loginUser.setOpenId("--"); |
| | | loginUser.setPhone("--"); |
| | | sysVipInfoDao.update(loginUser); |
| | | String token = userCacheManager.saveUserInfo(oldeUser); |
| | | AjaxResult result = AjaxResult.buildSuccessInstance("绑定成功"); |
| | | result.putInMap("token",token); |
| | | result.putInMap("userInfo",oldeUser); |
| | | return result; |
| | | }else{ |
| | | |
| | | //验证通过将手机号加入相应的用户数据中 |
| | | SysVipInfo sysVipInfo = new SysVipInfo(); |
| | | |
| | | sysVipInfo.setId(loginUser.getId()); |
| | | if(loginUser.getShopId()==null){ |
| | | sysVipInfo.setShopId(bindingPhoneNumber.getShopId()); |
| | | } |
| | | sysVipInfo.setPhone(bindingPhoneNumber.getPhoneNumber()); |
| | | sysVipInfoDao.update(sysVipInfo); |
| | | return new AjaxResult(AjaxResult.STATUS_SUCCESS, "绑定成功"); |
| | | } |
| | | sysVipInfo.setPhone(bindingPhoneNumber.getPhoneNumber()); |
| | | sysVipInfoDao.update(sysVipInfo); |
| | | return new AjaxResult(AjaxResult.STATUS_SUCCESS, "绑定成功"); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | @RequestMapping(value = "/deciphering") |
| | | public @ResponseBody |
| | | AjaxResult deciphering(@RequestBody DataDecipheringVo dataDecipheringVo) { |
| | | SysVipInfo loginUser = redisUserLoginUtils.getLoginUser(SysVipInfo.class); |
| | | SysVipInfo loginUser = userCacheManager.getLoginUser(); |
| | | String session_key = loginUser.getSessionKey(); |
| | | LogUtil.debug(dataDecipheringVo.toString()); |
| | | String jsonResult = AES.wxDecrypt(dataDecipheringVo.getEncryptedData(), session_key, dataDecipheringVo.getIv()); |