迁移 优惠券 团购券 活动
This commit is contained in:
parent
f6d6b51bd7
commit
b1fa1cc8bc
|
|
@ -81,7 +81,7 @@ public class CodeGen {
|
|||
//设置表前缀和只生成哪些表,setGenerateTable 未配置时,生成所有表
|
||||
globalConfig.getStrategyConfig()
|
||||
.setTablePrefix("tb_")
|
||||
.setGenerateTable("staff_id_relation");
|
||||
.setGenerateTable("tb_shop_activate_coupon_record");
|
||||
|
||||
EntityConfig entityConfig = globalConfig.getEntityConfig();
|
||||
if (isOldVersion) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.czg.mergedata.controller;
|
||||
|
||||
import com.czg.mergedata.common.resp.CzgResult;
|
||||
import com.czg.mergedata.cur.service.CurCouponCategoryService;
|
||||
import com.czg.mergedata.cur.service.CurShopActivateService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
|
@ -17,8 +18,16 @@ public class ActivateController {
|
|||
@Resource
|
||||
private CurShopActivateService curShopActivateService;
|
||||
|
||||
@Resource
|
||||
private CurCouponCategoryService curCouponCategoryService;
|
||||
|
||||
@GetMapping("/mergeActivate")
|
||||
public CzgResult<String> mergeActivate() {
|
||||
return curShopActivateService.mergeData();
|
||||
}
|
||||
|
||||
@GetMapping("/group")
|
||||
public CzgResult<String> mergeCategory() {
|
||||
return curCouponCategoryService.mergeData();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
package com.czg.mergedata.controller;
|
||||
|
||||
import com.czg.mergedata.common.resp.CzgResult;
|
||||
import com.czg.mergedata.cur.service.CurCouponCategoryService;
|
||||
import com.czg.mergedata.cur.service.CurShopCouponService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author GYJoker
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/coupon")
|
||||
public class CouponController {
|
||||
@Resource
|
||||
private CurCouponCategoryService curCouponCategoryService;
|
||||
|
||||
@Resource
|
||||
private CurShopCouponService curShopCouponService;
|
||||
|
||||
@GetMapping("/category")
|
||||
public CzgResult<String> mergeCategory() {
|
||||
return curCouponCategoryService.mergeData();
|
||||
}
|
||||
|
||||
@GetMapping("/shopCoupon")
|
||||
public CzgResult<String> mergeShopCoupon() {
|
||||
return curShopCouponService.mergeData();
|
||||
}
|
||||
}
|
||||
|
|
@ -57,14 +57,9 @@ public class CurShopActivate implements Serializable {
|
|||
private Integer isGiftCoupon;
|
||||
|
||||
/**
|
||||
* 优惠卷id
|
||||
* 优惠卷信息{卷id:数量}
|
||||
*/
|
||||
private Long couponId;
|
||||
|
||||
/**
|
||||
* 优惠卷数量
|
||||
*/
|
||||
private Integer num;
|
||||
private String coupons;
|
||||
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
|
|
|||
|
|
@ -16,17 +16,17 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 活动商品赠送记录表 实体类。
|
||||
* 活动赠送优惠券记录表 实体类。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-18
|
||||
* @since 2025-03-13
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_shop_activate_in_record")
|
||||
public class CurShopActivateInRecord implements Serializable {
|
||||
@Table("tb_shop_activate_coupon_record")
|
||||
public class CurShopActivateCouponRecord implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
@ -35,9 +35,9 @@ public class CurShopActivateInRecord implements Serializable {
|
|||
private Long id;
|
||||
|
||||
/**
|
||||
* 会员id
|
||||
* 用户id
|
||||
*/
|
||||
private Long vipUserId;
|
||||
private Long shopUserId;
|
||||
|
||||
/**
|
||||
* 卷Id (校验是否可用)
|
||||
|
|
@ -69,16 +69,6 @@ public class CurShopActivateInRecord implements Serializable {
|
|||
*/
|
||||
private BigDecimal discountAmount;
|
||||
|
||||
/**
|
||||
* 赠送数量
|
||||
*/
|
||||
private Integer num;
|
||||
|
||||
/**
|
||||
* 未使用数量
|
||||
*/
|
||||
private Integer overNum;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
|
|
@ -89,6 +79,9 @@ public class CurShopActivateInRecord implements Serializable {
|
|||
*/
|
||||
private Long sourceActId;
|
||||
|
||||
/**
|
||||
* 来源流水Id
|
||||
*/
|
||||
private Long sourceFlowId;
|
||||
|
||||
/**
|
||||
|
|
@ -111,4 +104,16 @@ public class CurShopActivateInRecord implements Serializable {
|
|||
|
||||
private String source;
|
||||
|
||||
/**
|
||||
* 0未使用
|
||||
1已使用
|
||||
2已过期
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 使用记录Id (订单Id)
|
||||
*/
|
||||
private Long targetId;
|
||||
|
||||
}
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
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.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 活动赠送商品使用记录表 实体类。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_shop_activate_out_record")
|
||||
public class CurShopActivateOutRecord implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 订单id
|
||||
*/
|
||||
private Long orderId;
|
||||
|
||||
/**
|
||||
* 商品赠送Id tb_shop_activate_in_record的id
|
||||
*/
|
||||
private Long giveId;
|
||||
|
||||
/**
|
||||
* 会员id
|
||||
*/
|
||||
private Long vipUserId;
|
||||
|
||||
/**
|
||||
* 1-满减 2-商品
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 使用数量
|
||||
*/
|
||||
private Integer useNum;
|
||||
|
||||
/**
|
||||
* 退单量
|
||||
*/
|
||||
private Integer refNum;
|
||||
|
||||
/**
|
||||
* 新建: create, 完成: closed, 取消:cancel,
|
||||
*/
|
||||
private String status;
|
||||
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
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.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 活动赠送商品表 实体类。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_shop_coupon_product")
|
||||
public class CurShopCouponProduct implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 活动Id
|
||||
*/
|
||||
private Long couponId;
|
||||
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
private Integer num;
|
||||
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.czg.mergedata.cur.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.cur.entity.CurShopActivateCouponRecord;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 活动赠送优惠券记录表 映射层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-03-13
|
||||
*/
|
||||
public interface CurShopActivateCouponRecordMapper extends BaseMapper<CurShopActivateCouponRecord> {
|
||||
|
||||
@Select("truncate tb_shop_activate_coupon_record")
|
||||
void truncateTable();
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
package com.czg.mergedata.cur.mapper;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.cur.entity.CurShopActivateInRecord;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 活动商品赠送记录表 映射层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
@UseDataSource("ds1")
|
||||
public interface CurShopActivateInRecordMapper extends BaseMapper<CurShopActivateInRecord> {
|
||||
|
||||
@Select("truncate tb_shop_activate_in_record")
|
||||
void truncateTable();
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
package com.czg.mergedata.cur.mapper;
|
||||
|
||||
import com.czg.mergedata.cur.entity.CurShopActivateOutRecord;
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 活动赠送商品使用记录表 映射层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
@UseDataSource("ds1")
|
||||
public interface CurShopActivateOutRecordMapper extends BaseMapper<CurShopActivateOutRecord> {
|
||||
|
||||
@Select("truncate tb_shop_activate_out_record")
|
||||
void truncateTable();
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
package com.czg.mergedata.cur.mapper;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.cur.entity.CurShopCouponProduct;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 活动赠送商品表 映射层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
@UseDataSource("ds1")
|
||||
public interface CurShopCouponProductMapper extends BaseMapper<CurShopCouponProduct> {
|
||||
@Select("truncate tb_shop_coupon_product")
|
||||
void truncateTable();
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.czg.mergedata.cur.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.cur.entity.CurShopActivateCouponRecord;
|
||||
|
||||
/**
|
||||
* 活动赠送优惠券记录表 服务层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-03-13
|
||||
*/
|
||||
public interface CurShopActivateCouponRecordService extends IService<CurShopActivateCouponRecord> {
|
||||
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package com.czg.mergedata.cur.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.cur.entity.CurShopActivateInRecord;
|
||||
|
||||
/**
|
||||
* 活动商品赠送记录表 服务层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
public interface CurShopActivateInRecordService extends IService<CurShopActivateInRecord> {
|
||||
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package com.czg.mergedata.cur.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.cur.entity.CurShopActivateOutRecord;
|
||||
|
||||
/**
|
||||
* 活动赠送商品使用记录表 服务层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
public interface CurShopActivateOutRecordService extends IService<CurShopActivateOutRecord> {
|
||||
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package com.czg.mergedata.cur.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.cur.entity.CurShopCouponProduct;
|
||||
|
||||
/**
|
||||
* 活动赠送商品表 服务层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
public interface CurShopCouponProductService extends IService<CurShopCouponProduct> {
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
package com.czg.mergedata.cur.service;
|
||||
|
||||
import com.czg.mergedata.common.resp.CzgResult;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.cur.entity.CurShopCoupon;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
/**
|
||||
* 优惠券 服务层。
|
||||
|
|
@ -11,6 +10,4 @@ import com.czg.mergedata.cur.entity.CurShopCoupon;
|
|||
* @since 2025-02-18
|
||||
*/
|
||||
public interface CurShopCouponService extends IService<CurShopCoupon> {
|
||||
|
||||
CzgResult<String> mergeData();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.czg.mergedata.cur.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.cur.entity.CurShopActivateCouponRecord;
|
||||
import com.czg.mergedata.cur.mapper.CurShopActivateCouponRecordMapper;
|
||||
import com.czg.mergedata.cur.service.CurShopActivateCouponRecordService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 活动赠送优惠券记录表 服务层实现。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-03-13
|
||||
*/
|
||||
@Service
|
||||
public class CurShopActivateCouponRecordServiceImpl extends ServiceImpl<CurShopActivateCouponRecordMapper, CurShopActivateCouponRecord> implements CurShopActivateCouponRecordService{
|
||||
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
package com.czg.mergedata.cur.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.cur.entity.CurShopActivateInRecord;
|
||||
import com.czg.mergedata.cur.mapper.CurShopActivateInRecordMapper;
|
||||
import com.czg.mergedata.cur.service.CurShopActivateInRecordService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 活动商品赠送记录表 服务层实现。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
@Service
|
||||
public class CurShopActivateInRecordServiceImpl extends ServiceImpl<CurShopActivateInRecordMapper, CurShopActivateInRecord> implements CurShopActivateInRecordService{
|
||||
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
package com.czg.mergedata.cur.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.cur.entity.CurShopActivateOutRecord;
|
||||
import com.czg.mergedata.cur.mapper.CurShopActivateOutRecordMapper;
|
||||
import com.czg.mergedata.cur.service.CurShopActivateOutRecordService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 活动赠送商品使用记录表 服务层实现。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
@Service
|
||||
public class CurShopActivateOutRecordServiceImpl extends ServiceImpl<CurShopActivateOutRecordMapper, CurShopActivateOutRecord> implements CurShopActivateOutRecordService{
|
||||
|
||||
}
|
||||
|
|
@ -4,27 +4,20 @@ 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.CurShopActivate;
|
||||
import com.czg.mergedata.cur.entity.CurShopActivateInRecord;
|
||||
import com.czg.mergedata.cur.entity.CurShopActivateOutRecord;
|
||||
import com.czg.mergedata.cur.mapper.CurShopActivateInRecordMapper;
|
||||
import com.czg.mergedata.cur.mapper.CurShopActivateCouponRecordMapper;
|
||||
import com.czg.mergedata.cur.mapper.CurShopActivateMapper;
|
||||
import com.czg.mergedata.cur.mapper.CurShopActivateOutRecordMapper;
|
||||
import com.czg.mergedata.cur.mapper.CurShopCouponMapper;
|
||||
import com.czg.mergedata.cur.service.CurShopActivateService;
|
||||
import com.czg.mergedata.cur.service.CurShopIdRelationService;
|
||||
import com.czg.mergedata.old.entity.OldActivate;
|
||||
import com.czg.mergedata.old.entity.OldActivateInRecord;
|
||||
import com.czg.mergedata.old.entity.OldActivateOutRecord;
|
||||
import com.czg.mergedata.old.service.OldActivateInRecordService;
|
||||
import com.czg.mergedata.old.service.OldActivateOutRecordService;
|
||||
import com.czg.mergedata.old.service.OldActivateService;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 活动 服务层实现。
|
||||
|
|
@ -33,102 +26,48 @@ import java.util.Map;
|
|||
* @since 2025-02-18
|
||||
*/
|
||||
@Service
|
||||
public class CurShopActivateServiceImpl extends ServiceImpl<CurShopActivateMapper, CurShopActivate> implements CurShopActivateService{
|
||||
public class CurShopActivateServiceImpl extends ServiceImpl<CurShopActivateMapper, CurShopActivate> implements CurShopActivateService {
|
||||
|
||||
@Resource
|
||||
private CurShopIdRelationService curShopIdRelationService;
|
||||
private CurShopCouponMapper curShopCouponMapper;
|
||||
|
||||
@Resource
|
||||
private CurShopActivateOutRecordMapper curShopActivateOutRecordMapper;
|
||||
|
||||
@Resource
|
||||
private CurShopActivateInRecordMapper curShopActivateInRecordMapper;
|
||||
private CurShopActivateCouponRecordMapper curShopActivateCouponRecordMapper;
|
||||
|
||||
@Resource
|
||||
private OldActivateService oldActivateService;
|
||||
|
||||
@Resource
|
||||
private OldActivateInRecordService oldActivateInRecordService;
|
||||
|
||||
@Resource
|
||||
private OldActivateOutRecordService oldActivateOutRecordService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<String> mergeData() {
|
||||
curShopActivateOutRecordMapper.truncateTable();
|
||||
curShopActivateInRecordMapper.truncateTable();
|
||||
getMapper().truncateTable();
|
||||
curShopActivateCouponRecordMapper.truncateTable();
|
||||
curShopCouponMapper.truncateTable();
|
||||
|
||||
Map<Long, Long> oldAndCurShopIdMap = curShopIdRelationService.getOldShopIdRelation();
|
||||
|
||||
execActivate(oldAndCurShopIdMap);
|
||||
execActivateOutRecord(oldAndCurShopIdMap);
|
||||
execActivateInRecord(oldAndCurShopIdMap);
|
||||
execActivate();
|
||||
|
||||
return CzgResult.success("迁移成功");
|
||||
}
|
||||
|
||||
private void execActivate(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void execActivate() {
|
||||
Page<OldActivate> page = oldActivateService.page(PageUtils.buildPage());
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
saveActivate(page.getRecords(), oldAndCurShopIdMap);
|
||||
saveActivate(page.getRecords());
|
||||
|
||||
page = oldActivateService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void execActivateOutRecord(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
Page<OldActivateOutRecord> page = oldActivateOutRecordService.page(PageUtils.buildPage());
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
saveActivateOutRecord(page.getRecords(), oldAndCurShopIdMap);
|
||||
page = oldActivateOutRecordService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void execActivateInRecord(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
Page<OldActivateInRecord> page = oldActivateInRecordService.page(PageUtils.buildPage());
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
saveActivateInRecord(page.getRecords(), oldAndCurShopIdMap);
|
||||
page = oldActivateInRecordService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void saveActivate(List<OldActivate> oldActivateList, Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void saveActivate(List<OldActivate> oldActivateList) {
|
||||
List<CurShopActivate> curShopActivates = new ArrayList<>();
|
||||
|
||||
for (OldActivate oldActivate : oldActivateList) {
|
||||
CurShopActivate bean = BeanUtil.toBean(oldActivate, CurShopActivate.class);
|
||||
bean.setShopId(oldAndCurShopIdMap.get(Long.valueOf(oldActivate.getShopId())));
|
||||
curShopActivates.add(bean);
|
||||
}
|
||||
|
||||
saveBatch(curShopActivates);
|
||||
}
|
||||
|
||||
private void saveActivateOutRecord(List<OldActivateOutRecord> oldActivateOutRecordList, Map<Long, Long> oldAndCurShopIdMap) {
|
||||
List<CurShopActivateOutRecord> curShopActivateOutRecords = new ArrayList<>();
|
||||
|
||||
for (OldActivateOutRecord oldActivateOutRecord : oldActivateOutRecordList) {
|
||||
CurShopActivateOutRecord bean = BeanUtil.toBean(oldActivateOutRecord, CurShopActivateOutRecord.class);
|
||||
bean.setShopId(oldAndCurShopIdMap.get(Long.valueOf(oldActivateOutRecord.getShopId())));
|
||||
curShopActivateOutRecords.add(bean);
|
||||
}
|
||||
|
||||
curShopActivateOutRecordMapper.insertBatch(curShopActivateOutRecords);
|
||||
}
|
||||
|
||||
private void saveActivateInRecord(List<OldActivateInRecord> oldActivateInRecordList, Map<Long, Long> oldAndCurShopIdMap) {
|
||||
List<CurShopActivateInRecord> curShopActivateInRecords = new ArrayList<>();
|
||||
|
||||
for (OldActivateInRecord oldActivateInRecord : oldActivateInRecordList) {
|
||||
CurShopActivateInRecord bean = BeanUtil.toBean(oldActivateInRecord, CurShopActivateInRecord.class);
|
||||
bean.setShopId(oldAndCurShopIdMap.get(Long.valueOf(oldActivateInRecord.getShopId())));
|
||||
curShopActivateInRecords.add(bean);
|
||||
}
|
||||
|
||||
curShopActivateInRecordMapper.insertBatch(curShopActivateInRecords);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
package com.czg.mergedata.cur.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.cur.entity.CurShopCouponProduct;
|
||||
import com.czg.mergedata.cur.mapper.CurShopCouponProductMapper;
|
||||
import com.czg.mergedata.cur.service.CurShopCouponProductService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 活动赠送商品表 服务层实现。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
@Service
|
||||
public class CurShopCouponProductServiceImpl extends ServiceImpl<CurShopCouponProductMapper, CurShopCouponProduct> implements CurShopCouponProductService{
|
||||
|
||||
}
|
||||
|
|
@ -1,27 +1,10 @@
|
|||
package com.czg.mergedata.cur.service.impl;
|
||||
|
||||
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.CurShopCouponProduct;
|
||||
import com.czg.mergedata.cur.mapper.CurShopCouponProductMapper;
|
||||
import com.czg.mergedata.cur.service.CurShopIdRelationService;
|
||||
import com.czg.mergedata.old.entity.OldCouponProduct;
|
||||
import com.czg.mergedata.old.entity.OldShopCoupon;
|
||||
import com.czg.mergedata.old.service.OldCouponProductService;
|
||||
import com.czg.mergedata.old.service.OldShopCouponService;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.cur.entity.CurShopCoupon;
|
||||
import com.czg.mergedata.cur.mapper.CurShopCouponMapper;
|
||||
import com.czg.mergedata.cur.service.CurShopCouponService;
|
||||
import jakarta.annotation.Resource;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 优惠券 服务层实现。
|
||||
|
|
@ -30,76 +13,7 @@ import java.util.Map;
|
|||
* @since 2025-02-18
|
||||
*/
|
||||
@Service
|
||||
public class CurShopCouponServiceImpl extends ServiceImpl<CurShopCouponMapper, CurShopCoupon> implements CurShopCouponService{
|
||||
public class CurShopCouponServiceImpl extends ServiceImpl<CurShopCouponMapper, CurShopCoupon> implements CurShopCouponService {
|
||||
|
||||
@Resource
|
||||
private CurShopIdRelationService curShopIdRelationService;
|
||||
|
||||
@Resource
|
||||
private CurShopCouponProductMapper curShopCouponProductMapper;
|
||||
|
||||
@Resource
|
||||
private OldShopCouponService oldShopCouponService;
|
||||
|
||||
@Resource
|
||||
private OldCouponProductService oldCouponProductService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<String> mergeData() {
|
||||
getMapper().truncateTable();
|
||||
curShopCouponProductMapper.truncateTable();
|
||||
|
||||
Map<Long, Long> oldAndCurShopIdMap = curShopIdRelationService.getOldShopIdRelation();
|
||||
|
||||
execShopCoupon(oldAndCurShopIdMap);
|
||||
execShopCouponProduct();
|
||||
|
||||
return CzgResult.success("迁移成功");
|
||||
}
|
||||
|
||||
private void execShopCoupon(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
Page<OldShopCoupon> page = oldShopCouponService.page(PageUtils.buildPage());
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
saveShopCoupon(page.getRecords(), oldAndCurShopIdMap);
|
||||
page = oldShopCouponService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void execShopCouponProduct() {
|
||||
Page<OldCouponProduct> page = oldCouponProductService.page(PageUtils.buildPage());
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
saveShopCouponProduct(page.getRecords());
|
||||
page = oldCouponProductService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void saveShopCoupon(List<OldShopCoupon> oldShopCouponList, Map<Long, Long> oldAndCurShopIdMap) {
|
||||
List<CurShopCoupon> curShopCoupons = new ArrayList<>();
|
||||
|
||||
for (OldShopCoupon oldShopCoupon : oldShopCouponList) {
|
||||
CurShopCoupon bean = BeanUtil.toBean(oldShopCoupon, CurShopCoupon.class);
|
||||
|
||||
Long curShopId = oldAndCurShopIdMap.get(Long.valueOf(oldShopCoupon.getShopId()));
|
||||
bean.setShopId(curShopId);
|
||||
|
||||
curShopCoupons.add(bean);
|
||||
}
|
||||
|
||||
saveBatch(curShopCoupons);
|
||||
}
|
||||
|
||||
private void saveShopCouponProduct(List<OldCouponProduct> oldCouponProductList) {
|
||||
List<CurShopCouponProduct> curShopCouponProducts = new ArrayList<>();
|
||||
|
||||
for (OldCouponProduct oldCouponProduct : oldCouponProductList) {
|
||||
CurShopCouponProduct bean = BeanUtil.toBean(oldCouponProduct, CurShopCouponProduct.class);
|
||||
|
||||
curShopCouponProducts.add(bean);
|
||||
}
|
||||
|
||||
curShopCouponProductMapper.insertBatch(curShopCouponProducts);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.mergedata.cur.mapper.CurShopActivateCouponRecordMapper">
|
||||
|
||||
</mapper>
|
||||
15
收银机数据迁移关系.md
15
收银机数据迁移关系.md
|
|
@ -47,5 +47,20 @@
|
|||
- tb_points_goods_setting 表
|
||||
- tb_member_points_log 表
|
||||
|
||||
### 5. 活动
|
||||
> /merge/activate/mergeActivate
|
||||
>
|
||||
> 线上暂时没用使用优惠券,清空记录不迁移
|
||||
#### 执行表
|
||||
- tb_shop_activate 表
|
||||
- tb_shop_activate_coupon_record 表
|
||||
- tb_shop_coupon 表
|
||||
|
||||
### 6. 团购优惠券
|
||||
> /merge/activate/group
|
||||
#### 执行表
|
||||
- tb_coupon_category 表
|
||||
- tb_group_order_coupon 表
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue