迁移 普通用户
This commit is contained in:
parent
d75630b812
commit
d3efee85dd
|
|
@ -1,22 +0,0 @@
|
|||
package com.czg.mergedata.controller;
|
||||
|
||||
import com.czg.mergedata.common.resp.CzgResult;
|
||||
import com.czg.mergedata.cur.service.CurShopUserService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author GYJoker
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("shopUser")
|
||||
public class ShopUserController {
|
||||
@Resource
|
||||
private CurShopUserService curShopUserService;
|
||||
|
||||
@RequestMapping("mergeShopUser")
|
||||
public CzgResult<String> mergeShopUser() {
|
||||
return curShopUserService.mergeShopUser();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.czg.mergedata.controller;
|
|||
|
||||
import com.czg.mergedata.common.resp.CzgResult;
|
||||
import com.czg.mergedata.cur.service.CurShopUserFlowService;
|
||||
import com.czg.mergedata.cur.service.CurShopUserService;
|
||||
import com.czg.mergedata.cur.service.CurSysUserService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
|
@ -21,11 +22,19 @@ public class UserController {
|
|||
@Resource
|
||||
private CurShopUserFlowService curShopUserFlowService;
|
||||
|
||||
@Resource
|
||||
private CurShopUserService curShopUserService;
|
||||
|
||||
@RequestMapping("/mergeShopInfo")
|
||||
public CzgResult<String> mergeShopInfo() {
|
||||
return curSysUserService.mergeShopInfo();
|
||||
}
|
||||
|
||||
@RequestMapping("mergeShopUser")
|
||||
public CzgResult<String> mergeShopUser() {
|
||||
return curShopUserService.mergeShopUser();
|
||||
}
|
||||
|
||||
@GetMapping("/userFlow")
|
||||
public CzgResult<String> userFlow() {
|
||||
return curShopUserFlowService.mergeData();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import com.czg.mergedata.cur.entity.CurShopUser;
|
|||
import com.czg.mergedata.cur.entity.CurUserInfo;
|
||||
import com.czg.mergedata.cur.mapper.CurShopUserMapper;
|
||||
import com.czg.mergedata.cur.mapper.CurUserInfoMapper;
|
||||
import com.czg.mergedata.cur.service.CurShopIdRelationService;
|
||||
import com.czg.mergedata.cur.service.CurShopUserService;
|
||||
import com.czg.mergedata.cur.service.CurUserInfoService;
|
||||
import com.czg.mergedata.old.entity.OldShopUser;
|
||||
|
|
@ -23,7 +22,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商户储值会员 服务层实现。
|
||||
|
|
@ -34,9 +32,6 @@ import java.util.Map;
|
|||
@Service
|
||||
public class CurShopUserServiceImpl extends ServiceImpl<CurShopUserMapper, CurShopUser> implements CurShopUserService {
|
||||
|
||||
@Resource
|
||||
private CurShopIdRelationService curShopIdRelationService;
|
||||
|
||||
@Resource
|
||||
private CurUserInfoMapper curUserInfoMapper;
|
||||
|
||||
|
|
@ -55,10 +50,8 @@ public class CurShopUserServiceImpl extends ServiceImpl<CurShopUserMapper, CurSh
|
|||
getMapper().truncateTable();
|
||||
curUserInfoMapper.truncateTable();
|
||||
|
||||
Map<Long, Long> oldAndCurShopIdMap = curShopIdRelationService.getOldShopIdRelation();
|
||||
|
||||
execUserInfo();
|
||||
execShopUser(oldAndCurShopIdMap);
|
||||
execShopUser();
|
||||
|
||||
return CzgResult.success("处理成功");
|
||||
}
|
||||
|
|
@ -76,11 +69,11 @@ public class CurShopUserServiceImpl extends ServiceImpl<CurShopUserMapper, CurSh
|
|||
}
|
||||
}
|
||||
|
||||
private void execShopUser(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void execShopUser() {
|
||||
Page<OldShopUser> page = oldShopUserService.page(PageUtils.buildPage());
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
saveCurShopUser(page.getRecords(), oldAndCurShopIdMap);
|
||||
saveCurShopUser(page.getRecords());
|
||||
|
||||
page = oldShopUserService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
|
|
@ -113,13 +106,12 @@ public class CurShopUserServiceImpl extends ServiceImpl<CurShopUserMapper, CurSh
|
|||
curUserInfoService.saveBatch(curShopUserList);
|
||||
}
|
||||
|
||||
private void saveCurShopUser(List<OldShopUser> oldShopUserList, Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void saveCurShopUser(List<OldShopUser> oldShopUserList) {
|
||||
List<CurShopUser> curShopUserList = oldShopUserList.stream().map(oldShopUser -> {
|
||||
CurShopUser curShopUser = new CurShopUser();
|
||||
curShopUser.setId(Long.valueOf(oldShopUser.getId()));
|
||||
Long shopId = oldAndCurShopIdMap.get(Long.valueOf(oldShopUser.getId()));
|
||||
curShopUser.setShopId(shopId == null ? 1L : shopId);
|
||||
curShopUser.setUserId(Long.valueOf(oldShopUser.getId()));
|
||||
curShopUser.setShopId(Long.valueOf(oldShopUser.getShopId()));
|
||||
curShopUser.setUserId(Long.valueOf(oldShopUser.getUserId()));
|
||||
curShopUser.setAccountPoints(oldShopUser.getAccountPoints());
|
||||
curShopUser.setAmount(oldShopUser.getAmount());
|
||||
curShopUser.setConsumeAmount(oldShopUser.getConsumeAmount());
|
||||
|
|
|
|||
16
收银机数据迁移关系.md
16
收银机数据迁移关系.md
|
|
@ -19,5 +19,19 @@
|
|||
|
||||
## 接口执行顺序
|
||||
|
||||
1. 迁移系统用户
|
||||
### 1. 迁移系统用户
|
||||
> /merge/user/mergeShopInfo
|
||||
#### 执行表
|
||||
- sys_user 表
|
||||
- tb_shop_info 表
|
||||
- tb_shop_staff 表
|
||||
- staff_id_relation 表
|
||||
|
||||
### 2. 用户
|
||||
> /merge/user/mergeShopUser
|
||||
#### 执行表
|
||||
- tb_user_info 表
|
||||
- tb_shop_user 表
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue