迁移 积分相关
This commit is contained in:
@@ -2,19 +2,17 @@ package com.czg.mergedata.cur.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 积分基本设置 实体类。
|
||||
*
|
||||
@@ -31,15 +29,10 @@ public class CurPointsBasicSetting implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
@Id
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,19 +63,19 @@ public class CurPointsExchangeRecord implements Serializable {
|
||||
private String goodsImageUrl;
|
||||
|
||||
/**
|
||||
* 领取方式 self-自取 post-邮寄
|
||||
* 领取方式 self-自取 post-邮寄
|
||||
*/
|
||||
private String pickupMethod;
|
||||
|
||||
/**
|
||||
* 会员id
|
||||
*/
|
||||
private Long memberId;
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 会员名称
|
||||
*/
|
||||
private String memberName;
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
|
||||
@@ -4,12 +4,14 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import com.czg.mergedata.common.resp.CzgResult;
|
||||
import com.czg.mergedata.common.utils.PageUtils;
|
||||
import com.czg.mergedata.cur.entity.CurMemberPointsLog;
|
||||
import com.czg.mergedata.cur.entity.CurPointsBasicSetting;
|
||||
import com.czg.mergedata.cur.entity.CurPointsExchangeRecord;
|
||||
import com.czg.mergedata.cur.entity.CurPointsGoodsSetting;
|
||||
import com.czg.mergedata.cur.mapper.CurMemberPointsLogMapper;
|
||||
import com.czg.mergedata.cur.mapper.CurPointsBasicSettingMapper;
|
||||
import com.czg.mergedata.cur.mapper.CurPointsExchangeRecordMapper;
|
||||
import com.czg.mergedata.cur.mapper.CurPointsGoodsSettingMapper;
|
||||
import com.czg.mergedata.cur.service.CurShopIdRelationService;
|
||||
import com.czg.mergedata.cur.service.CurPointsBasicSettingService;
|
||||
import com.czg.mergedata.old.entity.OldMemberPointsLog;
|
||||
import com.czg.mergedata.old.entity.OldPointsBasicSetting;
|
||||
import com.czg.mergedata.old.entity.OldPointsExchangeRecord;
|
||||
@@ -20,16 +22,12 @@ import com.czg.mergedata.old.service.OldPointsExchangeRecordService;
|
||||
import com.czg.mergedata.old.service.OldPointsGoodsSettingService;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.cur.entity.CurPointsBasicSetting;
|
||||
import com.czg.mergedata.cur.mapper.CurPointsBasicSettingMapper;
|
||||
import com.czg.mergedata.cur.service.CurPointsBasicSettingService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 积分基本设置 服务层实现。
|
||||
@@ -40,9 +38,6 @@ import java.util.Map;
|
||||
@Service
|
||||
public class CurPointsBasicSettingServiceImpl extends ServiceImpl<CurPointsBasicSettingMapper, CurPointsBasicSetting> implements CurPointsBasicSettingService {
|
||||
|
||||
@Resource
|
||||
private CurShopIdRelationService curShopIdRelationService;
|
||||
|
||||
@Resource
|
||||
private CurPointsExchangeRecordMapper curPointsExchangeRecordMapper;
|
||||
|
||||
@@ -72,56 +67,54 @@ public class CurPointsBasicSettingServiceImpl extends ServiceImpl<CurPointsBasic
|
||||
curPointsGoodsSettingMapper.truncateTable();
|
||||
curMemberPointsLogMapper.truncateTable();
|
||||
|
||||
Map<Long, Long> oldAndCurShopIdMap = curShopIdRelationService.getOldShopIdRelation();
|
||||
|
||||
execPointsBasicSetting(oldAndCurShopIdMap);
|
||||
execPointsExchangeRecord(oldAndCurShopIdMap);
|
||||
execPointsGoodsSetting(oldAndCurShopIdMap);
|
||||
execMemberPointsLog(oldAndCurShopIdMap);
|
||||
execPointsBasicSetting();
|
||||
execPointsExchangeRecord();
|
||||
execPointsGoodsSetting();
|
||||
execMemberPointsLog();
|
||||
|
||||
return CzgResult.success("迁移成功");
|
||||
}
|
||||
|
||||
private void execPointsBasicSetting(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void execPointsBasicSetting() {
|
||||
Page<OldPointsBasicSetting> page = oldPointsBasicSettingService.page(PageUtils.buildPage());
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
savePointsBasicSetting(page.getRecords(), oldAndCurShopIdMap);
|
||||
savePointsBasicSetting(page.getRecords());
|
||||
|
||||
page = oldPointsBasicSettingService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void execPointsExchangeRecord(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void execPointsExchangeRecord() {
|
||||
Page<OldPointsExchangeRecord> page = oldPointsExchangeRecordService.page(PageUtils.buildPage());
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
savePointsExchangeRecord(page.getRecords(), oldAndCurShopIdMap);
|
||||
savePointsExchangeRecord(page.getRecords());
|
||||
page = oldPointsExchangeRecordService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void execPointsGoodsSetting(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void execPointsGoodsSetting() {
|
||||
Page<OldPointsGoodsSetting> page = oldPointsGoodsSettingService.page(PageUtils.buildPage());
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
savePointsGoodsSetting(page.getRecords(), oldAndCurShopIdMap);
|
||||
savePointsGoodsSetting(page.getRecords());
|
||||
page = oldPointsGoodsSettingService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void execMemberPointsLog(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void execMemberPointsLog() {
|
||||
Page<OldMemberPointsLog> page = oldMemberPointsLogService.page(PageUtils.buildPage());
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
saveMemberPointsLog(page.getRecords(), oldAndCurShopIdMap);
|
||||
saveMemberPointsLog(page.getRecords());
|
||||
page = oldMemberPointsLogService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void savePointsBasicSetting(List<OldPointsBasicSetting> oldPointsBasicSettingList, Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void savePointsBasicSetting(List<OldPointsBasicSetting> oldPointsBasicSettingList) {
|
||||
List<CurPointsBasicSetting> curPointsBasicSettingList = new ArrayList<>();
|
||||
for (OldPointsBasicSetting oldPointsBasicSetting : oldPointsBasicSettingList) {
|
||||
CurPointsBasicSetting curPointsBasicSetting = BeanUtil.toBean(oldPointsBasicSetting, CurPointsBasicSetting.class);
|
||||
|
||||
curPointsBasicSetting.setShopId(oldAndCurShopIdMap.get(oldPointsBasicSetting.getShopId()));
|
||||
curPointsBasicSetting.setShopId(oldPointsBasicSetting.getShopId());
|
||||
|
||||
curPointsBasicSettingList.add(curPointsBasicSetting);
|
||||
}
|
||||
@@ -129,36 +122,37 @@ public class CurPointsBasicSettingServiceImpl extends ServiceImpl<CurPointsBasic
|
||||
saveBatch(curPointsBasicSettingList);
|
||||
}
|
||||
|
||||
private void savePointsExchangeRecord(List<OldPointsExchangeRecord> oldPointsExchangeRecordList, Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void savePointsExchangeRecord(List<OldPointsExchangeRecord> oldPointsExchangeRecordList) {
|
||||
List<CurPointsExchangeRecord> curPointsExchangeRecordList = new ArrayList<>();
|
||||
|
||||
for (OldPointsExchangeRecord oldPointsExchangeRecord : oldPointsExchangeRecordList) {
|
||||
CurPointsExchangeRecord curPointsExchangeRecord = BeanUtil.toBean(oldPointsExchangeRecord, CurPointsExchangeRecord.class);
|
||||
curPointsExchangeRecord.setShopId(oldAndCurShopIdMap.get(oldPointsExchangeRecord.getShopId()));
|
||||
curPointsExchangeRecord.setUserId(oldPointsExchangeRecord.getMemberId());
|
||||
curPointsExchangeRecord.setNickName(oldPointsExchangeRecord.getMemberName());
|
||||
curPointsExchangeRecordList.add(curPointsExchangeRecord);
|
||||
}
|
||||
|
||||
curPointsExchangeRecordMapper.insertBatch(curPointsExchangeRecordList);
|
||||
}
|
||||
|
||||
private void savePointsGoodsSetting(List<OldPointsGoodsSetting> oldPointsGoodsSettingList, Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void savePointsGoodsSetting(List<OldPointsGoodsSetting> oldPointsGoodsSettingList) {
|
||||
List<CurPointsGoodsSetting> curPointsGoodsSettingList = new ArrayList<>();
|
||||
|
||||
for (OldPointsGoodsSetting oldPointsGoodsSetting : oldPointsGoodsSettingList) {
|
||||
CurPointsGoodsSetting curPointsGoodsSetting = BeanUtil.toBean(oldPointsGoodsSetting, CurPointsGoodsSetting.class);
|
||||
curPointsGoodsSetting.setShopId(oldAndCurShopIdMap.get(oldPointsGoodsSetting.getShopId()));
|
||||
curPointsGoodsSetting.setShopId(oldPointsGoodsSetting.getShopId());
|
||||
curPointsGoodsSettingList.add(curPointsGoodsSetting);
|
||||
}
|
||||
|
||||
curPointsGoodsSettingMapper.insertBatch(curPointsGoodsSettingList);
|
||||
}
|
||||
|
||||
private void saveMemberPointsLog(List<OldMemberPointsLog> oldMemberPointsLogList, Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void saveMemberPointsLog(List<OldMemberPointsLog> oldMemberPointsLogList) {
|
||||
List<CurMemberPointsLog> curMemberPointsLogs = new ArrayList<>();
|
||||
|
||||
for (OldMemberPointsLog oldMemberPointsLog : oldMemberPointsLogList) {
|
||||
CurMemberPointsLog memberPointsLog = BeanUtil.toBean(oldMemberPointsLog, CurMemberPointsLog.class);
|
||||
memberPointsLog.setShopId(oldAndCurShopIdMap.get(oldMemberPointsLog.getShopId()));
|
||||
memberPointsLog.setUserId(oldMemberPointsLog.getMemberId());
|
||||
curMemberPointsLogs.add(memberPointsLog);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user