|
@@ -3,11 +3,11 @@ package com.tzld.piaoquan.risk.control.service.impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.annotation.JSONField;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
+import com.tzld.piaoquan.risk.control.config.LoginUserContext;
|
|
|
import com.tzld.piaoquan.risk.control.dao.mapper.UserBaseMapper;
|
|
|
import com.tzld.piaoquan.risk.control.model.po.UserBase;
|
|
|
import com.tzld.piaoquan.risk.control.model.po.UserBaseExample;
|
|
|
import com.tzld.piaoquan.risk.control.model.qywx.QwCallBackWrapperData;
|
|
|
-import com.tzld.piaoquan.risk.control.model.qywx.QwNeedVerifyModel;
|
|
|
import com.tzld.piaoquan.risk.control.service.qywx.Constant;
|
|
|
import lombok.Data;
|
|
|
import lombok.NoArgsConstructor;
|
|
@@ -101,7 +101,7 @@ public class QywxUserDataService {
|
|
|
private String jobPosition;
|
|
|
}
|
|
|
|
|
|
- public void processUserData(String originalJson) {
|
|
|
+ public void loginSuccess(String originalJson) {
|
|
|
// 1. 解析外层数据
|
|
|
QwCallBackWrapperData wrapperData = JSON.parseObject(originalJson, QwCallBackWrapperData.class);
|
|
|
if (StringUtils.isEmpty(wrapperData.getJson())) {
|
|
@@ -126,6 +126,7 @@ public class QywxUserDataService {
|
|
|
userBase.setCorpName(data.corpName);
|
|
|
userBase.setUnionid(data.unionId);
|
|
|
userBase.setPosition(data.jobPosition);
|
|
|
+ Long userId = LoginUserContext.getUserId();
|
|
|
|
|
|
// 时间处理(优先使用Create_time)
|
|
|
Long createTime = data.createTime2 != null && data.createTime2 > 0 ? data.createTime2 : data.createTime1;
|
|
@@ -139,6 +140,22 @@ public class QywxUserDataService {
|
|
|
int deletedCount = userBaseMapper.deleteByExample(deleteExample);
|
|
|
log.info("Deleted {} old records for vid: {}", deletedCount, data.vid);
|
|
|
|
|
|
+ // 查询是否已存在
|
|
|
+ UserBaseExample example = new UserBaseExample();
|
|
|
+ example.createCriteria().andUuidEqualTo(envelop.getUuid());
|
|
|
+ List<UserBase> existUsers = userBaseMapper.selectByExample(example);
|
|
|
+ if (!existUsers.isEmpty()) {
|
|
|
+ UserBase existUser = existUsers.get(0);
|
|
|
+ userBase.setId(existUser.getId());
|
|
|
+ userBase.setCreateUser(userId);
|
|
|
+ userBase.setUpdateUser(userId);
|
|
|
+ userBase.setCreateTime(existUser.getCreateTime());
|
|
|
+ userBaseMapper.updateByPrimaryKeySelective(userBase);
|
|
|
+ } else {
|
|
|
+ userBase.setCreateUser(userId);
|
|
|
+ userBase.setUpdateUser(userId);
|
|
|
+ userBaseMapper.insertSelective(userBase);
|
|
|
+ }
|
|
|
// 3. 插入新记录
|
|
|
userBaseMapper.insertSelective(userBase);
|
|
|
log.info("Inserted new record for vid: {}", data.vid);
|