| | |
| | | import com.taoke.autopay.service.WxUserService; |
| | | import com.taoke.autopay.service.WxUserSettingService; |
| | | import com.taoke.autopay.utils.StringUtil; |
| | | import com.taoke.autopay.utils.WxApiUtil; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public WxUserInfo login(String openid) { |
| | | public WxUserInfo login(WxApiUtil.WXUserInfo wxUserInfo) { |
| | | // 查询用户是否存在 |
| | | WxUserInfoMapper.DaoQuery query = new WxUserInfoMapper.DaoQuery(); |
| | | query.openId = openid; |
| | | query.openId = wxUserInfo.getOpenid(); |
| | | query.count = 1; |
| | | query.start = 0; |
| | | List<WxUserInfo> list = wxUserInfoMapper.list(query); |
| | | if (list.size() == 0) { |
| | | // 没有数据,需要注册 |
| | | WxUserInfo user = new WxUserInfo(); |
| | | user.setOpenId(openid); |
| | | user.setOpenId(wxUserInfo.getOpenid()); |
| | | user.setNickName(wxUserInfo.getNickname()); |
| | | user.setPortrait(wxUserInfo.getHeadimgurl()); |
| | | user.setLoginTime(new Date()); |
| | | user.setCreateTime(new Date()); |
| | | wxUserInfoMapper.insertSelective(user); |
| | |
| | | } else { |
| | | WxUserInfo update = new WxUserInfo(); |
| | | update.setId(list.get(0).getId()); |
| | | update.setNickName(wxUserInfo.getNickname()); |
| | | update.setPortrait(wxUserInfo.getHeadimgurl()); |
| | | update.setLoginTime(new Date()); |
| | | update.setUpdateTime(new Date()); |
| | | wxUserInfoMapper.updateByPrimaryKeySelective(update); |