| @@ -7,6 +7,7 @@ import com.iformall.domain.dto.WxCUserBasicInfoDto; | |||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.mapper.WxCUserMapper; | import com.iformall.mapper.WxCUserMapper; | ||||
| import com.iformall.service.WxCUserService; | import com.iformall.service.WxCUserService; | ||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -41,7 +42,17 @@ public class WxCUserServiceImpl implements WxCUserService { | |||||
| int ret = 0; | int ret = 0; | ||||
| Date curr = new Date(); | Date curr = new Date(); | ||||
| if (user.getId() == null) { | if (user.getId() == null) { | ||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| // 检查用户是否已有同一微信开放平台账号 | |||||
| if(StringUtils.isNotBlank(user.getUnionId()) && StringUtils.isNotBlank(user.getOpenAppId())) { | |||||
| WxCUser oldUser = wxCUserMapper.findByUnionId(user); | |||||
| if(oldUser != null) { | |||||
| // 已有,更新 | |||||
| user.setId(oldUser.getId()); | |||||
| // TODO 是否其他信息需要更新 | |||||
| ret = wxCUserMapper.updateByPrimaryKeySelective(user); | |||||
| return ret; | |||||
| } | |||||
| } | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| user.setId(idWorker.nextId()); | user.setId(idWorker.nextId()); | ||||
| user.setLoginCount(1); | user.setLoginCount(1); | ||||