|
@ -26,9 +26,11 @@ import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
import com.epmet.dao.PaCustomerDao; |
|
|
import com.epmet.dao.PaCustomerDao; |
|
|
import com.epmet.dao.PaUserDao; |
|
|
import com.epmet.dao.PaUserDao; |
|
|
|
|
|
import com.epmet.dao.PaUserVisitedDao; |
|
|
import com.epmet.dao.PaUserWechatDao; |
|
|
import com.epmet.dao.PaUserWechatDao; |
|
|
import com.epmet.dto.PaCustomerDTO; |
|
|
import com.epmet.dto.PaCustomerDTO; |
|
|
import com.epmet.dto.PaUserDTO; |
|
|
import com.epmet.dto.PaUserDTO; |
|
|
|
|
|
import com.epmet.dto.PaUserVisitedDTO; |
|
|
import com.epmet.dto.PaUserWechatDTO; |
|
|
import com.epmet.dto.PaUserWechatDTO; |
|
|
import com.epmet.dto.result.CustomerUserResultDTO; |
|
|
import com.epmet.dto.result.CustomerUserResultDTO; |
|
|
import com.epmet.dto.result.SaveUserResultDTO; |
|
|
import com.epmet.dto.result.SaveUserResultDTO; |
|
@ -64,6 +66,8 @@ public class PaUserServiceImpl extends BaseServiceImpl<PaUserDao, PaUserEntity> |
|
|
private PaCustomerDao paCustomerDao; |
|
|
private PaCustomerDao paCustomerDao; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private PaUserWechatDao paUserWechatDao; |
|
|
private PaUserWechatDao paUserWechatDao; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private PaUserVisitedDao paUserVisitedDao; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PageData<PaUserDTO> page(Map<String, Object> params) { |
|
|
public PageData<PaUserDTO> page(Map<String, Object> params) { |
|
@ -127,11 +131,11 @@ public class PaUserServiceImpl extends BaseServiceImpl<PaUserDao, PaUserEntity> |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public SaveUserResultDTO saveUser(WxMpUser wxMpUser) { |
|
|
public SaveUserResultDTO saveUser(WxMpUser wxMpUser) { |
|
|
SaveUserResultDTO resultDTO = new SaveUserResultDTO(); |
|
|
SaveUserResultDTO resultDTO = new SaveUserResultDTO(); |
|
|
//1.根据openId查询user_wechat表是否存在用户信息
|
|
|
//1.根据openId查询user_wechat表是否存在用户信息(user表和user_wechat表数据时多对多关系)
|
|
|
PaUserWechatDTO wechatDTO = paUserWechatService.getWechatByOpenId(wxMpUser.getOpenId()); |
|
|
List<PaUserWechatDTO> wechatDTO = paUserWechatService.getWechatByOpenId(wxMpUser.getOpenId()); |
|
|
|
|
|
|
|
|
//2.不存在则新增用户信息,存在则更新user_wechat表信息
|
|
|
//2.不存在则新增用户信息,存在则更新user_wechat表信息
|
|
|
if (null == wechatDTO || null == wechatDTO.getId()) { |
|
|
if (null == wechatDTO || wechatDTO.size() < NumConstant.ONE) { |
|
|
//2.1、user表新增数据
|
|
|
//2.1、user表新增数据
|
|
|
PaUserEntity userEntity = new PaUserEntity(); |
|
|
PaUserEntity userEntity = new PaUserEntity(); |
|
|
baseDao.insert(userEntity); |
|
|
baseDao.insert(userEntity); |
|
@ -151,18 +155,23 @@ public class PaUserServiceImpl extends BaseServiceImpl<PaUserDao, PaUserEntity> |
|
|
|
|
|
|
|
|
resultDTO.setUserId(userEntity.getId()); |
|
|
resultDTO.setUserId(userEntity.getId()); |
|
|
} else { |
|
|
} else { |
|
|
//2.3、更新user_wechat表数据
|
|
|
//2.3、批量更新user_wechat表数据
|
|
|
PaUserWechatEntity wechatEntity = ConvertUtils.sourceToTarget(wechatDTO, PaUserWechatEntity.class); |
|
|
List<PaUserWechatEntity> wechatEntity = ConvertUtils.sourceToTarget(wechatDTO, PaUserWechatEntity.class); |
|
|
wechatEntity.setGender(wxMpUser.getSex().toString()); |
|
|
for(PaUserWechatEntity entity : wechatEntity){ |
|
|
wechatEntity.setNickname(wxMpUser.getNickname()); |
|
|
entity.setGender(wxMpUser.getSex().toString()); |
|
|
wechatEntity.setHeadImgUrl(null == wxMpUser.getHeadImgUrl() ? "" : wxMpUser.getHeadImgUrl()); |
|
|
entity.setNickname(wxMpUser.getNickname()); |
|
|
wechatEntity.setCountry(null == wxMpUser.getCountry() ? "" : wxMpUser.getCountry()); |
|
|
entity.setHeadImgUrl(null == wxMpUser.getHeadImgUrl() ? "" : wxMpUser.getHeadImgUrl()); |
|
|
wechatEntity.setProvince(null == wxMpUser.getProvince() ? "" : wxMpUser.getProvince()); |
|
|
entity.setCountry(null == wxMpUser.getCountry() ? "" : wxMpUser.getCountry()); |
|
|
wechatEntity.setCity(null == wxMpUser.getCity() ? "" : wxMpUser.getCity()); |
|
|
entity.setProvince(null == wxMpUser.getProvince() ? "" : wxMpUser.getProvince()); |
|
|
wechatEntity.setLanguage(null == wxMpUser.getLanguage() ? "" : wxMpUser.getLanguage()); |
|
|
entity.setCity(null == wxMpUser.getCity() ? "" : wxMpUser.getCity()); |
|
|
paUserWechatService.updateById(wechatEntity); |
|
|
entity.setLanguage(null == wxMpUser.getLanguage() ? "" : wxMpUser.getLanguage()); |
|
|
|
|
|
} |
|
|
|
|
|
paUserWechatService.updateBatchById(wechatEntity); |
|
|
|
|
|
|
|
|
|
|
|
//2.4、根据openid查询用户登陆访问记录表数据,按登陆时间倒序
|
|
|
|
|
|
PaUserVisitedDTO visitedDTO = paUserVisitedDao.selectByOpenId(wxMpUser.getOpenId()); |
|
|
|
|
|
|
|
|
resultDTO.setUserId(wechatDTO.getUserId()); |
|
|
resultDTO.setUserId(visitedDTO.getUserId()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//3.返回userId
|
|
|
//3.返回userId
|
|
|