迁移 商品
This commit is contained in:
parent
b81294a493
commit
267d054451
File diff suppressed because one or more lines are too long
|
|
@ -18,8 +18,8 @@ public class CodeGen {
|
|||
private final static String DATABASE = "czg_cashier";
|
||||
private final static String OLD_DATABASE = "fycashier_test";
|
||||
|
||||
private final static boolean isOldVersion = false;
|
||||
// private final static boolean isOldVersion = true;
|
||||
// private final static boolean isOldVersion = false;
|
||||
private final static boolean isOldVersion = true;
|
||||
|
||||
public static void main(String[] args) {
|
||||
//配置数据源
|
||||
|
|
@ -81,7 +81,7 @@ public class CodeGen {
|
|||
//设置表前缀和只生成哪些表,setGenerateTable 未配置时,生成所有表
|
||||
globalConfig.getStrategyConfig()
|
||||
.setTablePrefix("tb_")
|
||||
.setGenerateTable("tb_shop_prod_category");
|
||||
.setGenerateTable("tb_product");
|
||||
|
||||
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.CurProductService;
|
||||
import com.czg.mergedata.cur.service.CurShopProdCategoryService;
|
||||
import com.czg.mergedata.cur.service.CurShopProdSpecService;
|
||||
import com.czg.mergedata.cur.service.CurShopProdUnitService;
|
||||
|
|
@ -24,6 +25,9 @@ public class ProductController {
|
|||
@Resource
|
||||
private CurShopProdCategoryService curShopProdCategoryService;
|
||||
|
||||
@Resource
|
||||
private CurProductService curProductService;
|
||||
|
||||
@RequestMapping("/mergeUnit")
|
||||
public CzgResult<String> mergeUnit() {
|
||||
return curShopProdUnitService.mergeProductUnit();
|
||||
|
|
@ -39,4 +43,9 @@ public class ProductController {
|
|||
return curShopProdCategoryService.mergeData();
|
||||
}
|
||||
|
||||
@RequestMapping("/mergeProduct")
|
||||
public CzgResult<String> mergeProduct() {
|
||||
return curProductService.mergeData();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
package com.czg.mergedata.controller;
|
||||
|
||||
import com.czg.mergedata.cur.mapper.CurProductMapper;
|
||||
import com.czg.mergedata.old.entity.OldMerchantAccount;
|
||||
import com.czg.mergedata.old.service.OldMerchantAccountService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
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;
|
||||
|
||||
|
|
@ -18,10 +20,20 @@ public class TestServiceController {
|
|||
@Resource
|
||||
private OldMerchantAccountService oldMerchantAccountService;
|
||||
|
||||
@Resource
|
||||
private CurProductMapper curProductMapper;
|
||||
|
||||
@RequestMapping("/oldMerchantAccount")
|
||||
public Object getOldMerchantAccount() {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.in(OldMerchantAccount::getShopId, Arrays.asList(1, 2, 3, 4, 5));
|
||||
return oldMerchantAccountService.list(queryWrapper);
|
||||
}
|
||||
|
||||
@GetMapping("/truncate")
|
||||
public Object truncate() {
|
||||
curProductMapper.truncateTable();
|
||||
|
||||
return "success";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,193 @@
|
|||
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.sql.Time;
|
||||
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-17
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_product")
|
||||
public class CurProduct implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 商品分类
|
||||
*/
|
||||
private Long categoryId;
|
||||
|
||||
/**
|
||||
* 商品规格
|
||||
*/
|
||||
private Long specId;
|
||||
|
||||
/**
|
||||
* 单位id
|
||||
*/
|
||||
private Long unitId;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 短标题--促销语
|
||||
*/
|
||||
private String shortTitle;
|
||||
|
||||
/**
|
||||
* 商品类型 single-单规格商品 sku-多规格商品 package-套餐商品 weight-称重商品 coupon-团购券
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 0 固定套餐 1可选套餐
|
||||
*/
|
||||
private Integer groupType;
|
||||
|
||||
/**
|
||||
* 包装费
|
||||
*/
|
||||
private BigDecimal packFee;
|
||||
|
||||
/**
|
||||
* 商品封面图
|
||||
*/
|
||||
private String coverImg;
|
||||
|
||||
/**
|
||||
* 商品图片(第一张为缩略图,其他为详情)
|
||||
*/
|
||||
private String images;
|
||||
|
||||
/**
|
||||
* 套餐内容
|
||||
*/
|
||||
private String groupSnap;
|
||||
|
||||
/**
|
||||
* 库存警戒线
|
||||
*/
|
||||
private Integer warnLine;
|
||||
|
||||
/**
|
||||
* 称重 价格/千克
|
||||
*/
|
||||
private BigDecimal weight;
|
||||
|
||||
/**
|
||||
* 是否允许临时改价
|
||||
*/
|
||||
private Integer isAllowTempModifyPrice;
|
||||
|
||||
/**
|
||||
* 周 数组 'Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday'
|
||||
*/
|
||||
private String days;
|
||||
|
||||
/**
|
||||
* 可用开始时间
|
||||
*/
|
||||
private Time startTime;
|
||||
|
||||
/**
|
||||
* 可用结束时间
|
||||
*/
|
||||
private Time endTime;
|
||||
|
||||
/**
|
||||
* 规格选详情
|
||||
*/
|
||||
private String selectSpecInfo;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 是否热销
|
||||
*/
|
||||
private Integer isHot;
|
||||
|
||||
/**
|
||||
* 是否开启库存
|
||||
*/
|
||||
private Integer isStock;
|
||||
|
||||
/**
|
||||
* 是否售罄
|
||||
*/
|
||||
private Integer isSoldStock;
|
||||
|
||||
/**
|
||||
* 团购卷分类,可有多个分类
|
||||
*/
|
||||
private String groupCategoryId;
|
||||
|
||||
/**
|
||||
* 商品级库存数量
|
||||
*/
|
||||
private Integer stockNumber;
|
||||
|
||||
/**
|
||||
* 是否上架
|
||||
*/
|
||||
private Boolean isSale;
|
||||
|
||||
/**
|
||||
* 退款是否退回库存
|
||||
*/
|
||||
private Boolean isRefundStock;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*/
|
||||
private Integer isDel;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.czg.mergedata.cur.mapper;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.cur.entity.CurProduct;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 商品 映射层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
@UseDataSource("ds1")
|
||||
public interface CurProductMapper extends BaseMapper<CurProduct> {
|
||||
|
||||
@Select("truncate tb_product")
|
||||
void truncateTable();
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.czg.mergedata.cur.mapper;
|
|||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.cur.entity.CurShopProdCategory;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 商品分类 映射层。
|
||||
|
|
@ -13,4 +14,6 @@ import com.czg.mergedata.cur.entity.CurShopProdCategory;
|
|||
@UseDataSource("ds1")
|
||||
public interface CurShopProdCategoryMapper extends BaseMapper<CurShopProdCategory> {
|
||||
|
||||
@Select("truncate tb_shop_prod_category ")
|
||||
void truncateTable();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.czg.mergedata.cur.mapper;
|
|||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.cur.entity.CurShopProdSpec;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 商品规格 映射层。
|
||||
|
|
@ -13,4 +14,6 @@ import com.czg.mergedata.cur.entity.CurShopProdSpec;
|
|||
@UseDataSource("ds1")
|
||||
public interface CurShopProdSpecMapper extends BaseMapper<CurShopProdSpec> {
|
||||
|
||||
@Select("truncate tb_shop_prod_spec ")
|
||||
void truncateTable();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.czg.mergedata.cur.mapper;
|
|||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.cur.entity.CurShopProdUnit;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 商品单位 映射层。
|
||||
|
|
@ -13,4 +14,6 @@ import com.czg.mergedata.cur.entity.CurShopProdUnit;
|
|||
@UseDataSource("ds1")
|
||||
public interface CurShopProdUnitMapper extends BaseMapper<CurShopProdUnit> {
|
||||
|
||||
@Select("truncate tb_shop_prod_unit")
|
||||
void truncateTable();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
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.CurProduct;
|
||||
|
||||
/**
|
||||
* 商品 服务层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
public interface CurProductService extends IService<CurProduct> {
|
||||
CzgResult<String> mergeData();
|
||||
}
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
package com.czg.mergedata.cur.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.mergedata.common.resp.CzgResult;
|
||||
import com.czg.mergedata.common.utils.PageUtils;
|
||||
import com.czg.mergedata.cur.entity.CurProduct;
|
||||
import com.czg.mergedata.cur.mapper.CurProductMapper;
|
||||
import com.czg.mergedata.cur.service.CurProductService;
|
||||
import com.czg.mergedata.cur.service.CurShopIdRelationService;
|
||||
import com.czg.mergedata.old.entity.OldProduct;
|
||||
import com.czg.mergedata.old.service.OldProductService;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.row.Db;
|
||||
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.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商品 服务层实现。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
@Service
|
||||
public class CurProductServiceImpl extends ServiceImpl<CurProductMapper, CurProduct> implements CurProductService {
|
||||
|
||||
@Resource
|
||||
private CurShopIdRelationService curShopIdRelationService;
|
||||
|
||||
@Resource
|
||||
private OldProductService oldProductService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<String> mergeData() {
|
||||
getMapper().truncateTable();
|
||||
|
||||
Map<Long, Long> oldAndCurShopIdMap = curShopIdRelationService.getOldShopIdRelation();
|
||||
|
||||
execProduct(oldAndCurShopIdMap);
|
||||
|
||||
return CzgResult.success("迁移成功");
|
||||
}
|
||||
|
||||
private void execProduct(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
Page<OldProduct> page = oldProductService.page(PageUtils.buildPage());
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
saveProduct(page.getRecords(), oldAndCurShopIdMap);
|
||||
|
||||
page = oldProductService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void saveProduct(List<OldProduct> products, Map<Long, Long> oldAndCurShopIdMap) {
|
||||
List<CurProduct> productList = new ArrayList<>();
|
||||
|
||||
for (OldProduct oldProduct : products) {
|
||||
CurProduct curProduct = new CurProduct();
|
||||
|
||||
curProduct.setId(Long.valueOf(oldProduct.getId()));
|
||||
curProduct.setCategoryId(StrUtil.isBlank(oldProduct.getCategoryId()) ? null : Long.valueOf(oldProduct.getCategoryId()));
|
||||
curProduct.setSpecId(oldProduct.getSpecId() == null ? null : Long.valueOf(oldProduct.getSpecId()));
|
||||
curProduct.setShopId(oldAndCurShopIdMap.get(Long.valueOf(oldProduct.getShopId())));
|
||||
curProduct.setName(oldProduct.getName());
|
||||
curProduct.setShortTitle(oldProduct.getShortTitle());
|
||||
curProduct.setType(getProductType(oldProduct));
|
||||
curProduct.setGroupType(oldProduct.getGroupType());
|
||||
curProduct.setPackFee(oldProduct.getPackFee());
|
||||
curProduct.setCoverImg(oldProduct.getCoverImg());
|
||||
curProduct.setImages(oldProduct.getImages());
|
||||
curProduct.setGroupSnap(oldProduct.getGroupSnap());
|
||||
curProduct.setWarnLine(oldProduct.getWarnLine());
|
||||
curProduct.setWeight(oldProduct.getWeight());
|
||||
curProduct.setIsAllowTempModifyPrice(oldProduct.getIsTempPrice());
|
||||
curProduct.setDays(oldProduct.getDays());
|
||||
curProduct.setStartTime(oldProduct.getStartTime());
|
||||
curProduct.setEndTime(oldProduct.getEndTime());
|
||||
curProduct.setSelectSpecInfo(getSelectSpecInfo(oldProduct.getSelectSpec()));
|
||||
curProduct.setSort(oldProduct.getSort());
|
||||
curProduct.setIsHot(oldProduct.getIsHot());
|
||||
curProduct.setIsStock(oldProduct.getIsStock());
|
||||
curProduct.setIsSoldStock(oldProduct.getIsPauseSale());
|
||||
curProduct.setGroupCategoryId(oldProduct.getGroupCategoryId());
|
||||
curProduct.setStockNumber(oldProduct.getStockNumber());
|
||||
curProduct.setIsRefundStock(oldProduct.getIsRefundStock());
|
||||
curProduct.setCreateTime(DateUtil.toLocalDateTime(oldProduct.getCreatedAt() == null ? new Date() : new Date(oldProduct.getCreatedAt())));
|
||||
curProduct.setIsDel(oldProduct.getIsDel());
|
||||
|
||||
productList.add(curProduct);
|
||||
}
|
||||
|
||||
System.out.println("oldProductList size: " + products.size() + " curProductList size: " + productList.size());
|
||||
|
||||
saveBatch(productList);
|
||||
}
|
||||
|
||||
private String getProductType(OldProduct oldProduct) {
|
||||
String type = oldProduct.getType();
|
||||
if (!"normal".equals(type)) {
|
||||
return type;
|
||||
}
|
||||
|
||||
String typeEnum = oldProduct.getTypeEnum();
|
||||
if ("sku".equals(typeEnum)) {
|
||||
return "sku";
|
||||
}
|
||||
return "single";
|
||||
}
|
||||
|
||||
private String getSelectSpecInfo(String specInfo) {
|
||||
if (StrUtil.isBlank(specInfo)) {
|
||||
return "{}";
|
||||
}
|
||||
|
||||
JSONArray specInfoArray = JSONArray.parseArray(specInfo);
|
||||
|
||||
if (specInfoArray.isEmpty()) {
|
||||
return "{}";
|
||||
}
|
||||
|
||||
JSONObject item = new JSONObject();
|
||||
specInfoArray.forEach(spec -> {
|
||||
JSONObject specJson = JSONObject.parseObject(spec.toString());
|
||||
|
||||
String key = specJson.getString("name");
|
||||
JSONArray specResult = specJson.getJSONArray("selectSpecResult");
|
||||
item.put(key, specResult);
|
||||
});
|
||||
|
||||
return item.toJSONString();
|
||||
}
|
||||
}
|
||||
|
|
@ -39,6 +39,8 @@ public class CurShopProdCategoryServiceImpl extends ServiceImpl<CurShopProdCateg
|
|||
@Override
|
||||
@Transactional
|
||||
public CzgResult<String> mergeData() {
|
||||
getMapper().truncateTable();
|
||||
|
||||
Map<Long, Long> oldAndCurShopIdMap = curShopIdRelationService.getOldShopIdRelation();
|
||||
|
||||
execMergeCategory(oldAndCurShopIdMap);
|
||||
|
|
@ -48,7 +50,7 @@ public class CurShopProdCategoryServiceImpl extends ServiceImpl<CurShopProdCateg
|
|||
private void execMergeCategory(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
Page<OldShopCategory> page = oldShopCategoryService.page(PageUtils.buildPage());
|
||||
|
||||
while (page.hasNext() || page.getPageNumber() == 1) {
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
saveCategory(page.getRecords(), oldAndCurShopIdMap);
|
||||
|
||||
page = oldShopCategoryService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ public class CurShopProdSpecServiceImpl extends ServiceImpl<CurShopProdSpecMappe
|
|||
@Override
|
||||
@Transactional
|
||||
public CzgResult<String> mergeProductSpec() {
|
||||
getMapper().truncateTable();
|
||||
Map<Long, Long> oldAndCurShopIdMap = curShopIdRelationService.getOldShopIdRelation();
|
||||
|
||||
mergeProductSpec(oldAndCurShopIdMap);
|
||||
|
|
@ -47,7 +48,7 @@ public class CurShopProdSpecServiceImpl extends ServiceImpl<CurShopProdSpecMappe
|
|||
private void mergeProductSpec(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
Page<OldProductSpec> page = oldProductSpecService.page(PageUtils.buildPage());
|
||||
|
||||
while (page.hasNext() || page.getPageNumber() == 1) {
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
saveProdSpec(page.getRecords(), oldAndCurShopIdMap);
|
||||
|
||||
page = oldProductSpecService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ public class CurShopProdUnitServiceImpl extends ServiceImpl<CurShopProdUnitMappe
|
|||
@Override
|
||||
@Transactional
|
||||
public CzgResult<String> mergeProductUnit() {
|
||||
getMapper().truncateTable();
|
||||
|
||||
Map<Long, Long> oldAndCurShopIdMap = curShopIdRelationService.getOldShopIdRelation();
|
||||
|
||||
mergeUnit(oldAndCurShopIdMap);
|
||||
|
|
@ -47,7 +49,7 @@ public class CurShopProdUnitServiceImpl extends ServiceImpl<CurShopProdUnitMappe
|
|||
private void mergeUnit(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
Page<OldShopUnit> page = oldShopUnitService.page(PageUtils.buildPage());
|
||||
|
||||
while (page.hasNext() || page.getPageNumber() == 1) {
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
saveUnitInfo(page.getRecords(), oldAndCurShopIdMap);
|
||||
page = oldShopUnitService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class CurShopUserServiceImpl extends ServiceImpl<CurShopUserMapper, CurSh
|
|||
|
||||
Page<OldUserInfo> page = oldUserInfoService.page(PageUtils.buildPage(), queryWrapper);
|
||||
|
||||
while (page.hasNext() || page.getPageNumber() == 1) {
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
saveCurUserInfo(page.getRecords());
|
||||
|
||||
page = oldUserInfoService.page(PageUtils.buildPage(page.getPageNumber() + 1), queryWrapper);
|
||||
|
|
@ -72,7 +72,7 @@ public class CurShopUserServiceImpl extends ServiceImpl<CurShopUserMapper, CurSh
|
|||
private void execShopUser(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
Page<OldShopUser> page = oldShopUserService.page(PageUtils.buildPage());
|
||||
|
||||
while (page.hasNext() || page.getPageNumber() == 1) {
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
saveCurShopUser(page.getRecords(), oldAndCurShopIdMap);
|
||||
|
||||
page = oldShopUserService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public class CurSysUserServiceImpl extends ServiceImpl<CurSysUserMapper, CurSysU
|
|||
|
||||
long startUserId = 100L;
|
||||
|
||||
while (page.hasNext() || page.getPageNumber() == 1) {
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
List<OldSysUser> oldSysUsers = page.getRecords();
|
||||
List<CurSysUser> curSysUsers = saveOldUser(oldSysUsers, startUserId);
|
||||
sysUserList.addAll(curSysUsers);
|
||||
|
|
@ -113,7 +113,7 @@ public class CurSysUserServiceImpl extends ServiceImpl<CurSysUserMapper, CurSysU
|
|||
queryWrapper.gt(OldShopInfo::getId, 1);
|
||||
Page<OldShopInfo> page = oldShopInfoService.page(PageUtils.buildPage(), queryWrapper);
|
||||
|
||||
while (page.hasNext() || page.getPageNumber() == 1) {
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
List<OldShopInfo> oldShopInfos = page.getRecords();
|
||||
|
||||
List<CurShopInfo> curShopInfos = saveOldShopInfo(oldShopInfos, orginAccountAndShopIdMap, oldAndCurShopIdMap, curAndOldShopIdMap);
|
||||
|
|
@ -130,7 +130,7 @@ public class CurSysUserServiceImpl extends ServiceImpl<CurSysUserMapper, CurSysU
|
|||
private void execStaffInfo(Map<Long, Long> oldAndCurShopIdMap, Map<Long, Long> curAndOldShopIdMap) {
|
||||
Page<OldPlussShopStaff> page = oldStaffService.page(PageUtils.buildPage());
|
||||
|
||||
while (page.hasNext() || page.getPageNumber() == 1) {
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
List<OldPlussShopStaff> oldShopStaffs = page.getRecords();
|
||||
saveOldStaffInfo(oldShopStaffs, oldAndCurShopIdMap, curAndOldShopIdMap);
|
||||
page = oldStaffService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,239 @@
|
|||
package com.czg.mergedata.old.entity;
|
||||
|
||||
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.sql.Time;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 实体类。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_product")
|
||||
public class OldProduct implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 商品分类
|
||||
*/
|
||||
private String categoryId;
|
||||
|
||||
/**
|
||||
* 商品规格
|
||||
*/
|
||||
private Integer specId;
|
||||
|
||||
private String shopId;
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 短标题--促销语
|
||||
*/
|
||||
private String shortTitle;
|
||||
|
||||
/**
|
||||
* 普通商品 normal 套餐商品 package 称重商品 weigh 团购券 coupon
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 包装费
|
||||
*/
|
||||
private BigDecimal packFee;
|
||||
|
||||
/**
|
||||
* 商品最低价
|
||||
*/
|
||||
private BigDecimal lowPrice;
|
||||
|
||||
/**
|
||||
* 单位Id
|
||||
*/
|
||||
private Integer unitId;
|
||||
|
||||
/**
|
||||
* 商品封面图
|
||||
*/
|
||||
private String coverImg;
|
||||
|
||||
/**
|
||||
* 商品图片(第一张为缩略图,其他为详情)
|
||||
*/
|
||||
private String images;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 0--待审核 1审核通过 -1审核失败 -2违规下架
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 审核失败原因
|
||||
*/
|
||||
private String failMsg;
|
||||
|
||||
/**
|
||||
* 是否热销
|
||||
*/
|
||||
private Integer isHot;
|
||||
|
||||
/**
|
||||
* 计量商品 normal
|
||||
称重商品 weight
|
||||
多规格商品 sku
|
||||
套餐商品 group
|
||||
时价商品 currentPrice
|
||||
*/
|
||||
private String typeEnum;
|
||||
|
||||
/**
|
||||
* 是否回收站 0-否,1回收站
|
||||
*/
|
||||
private Integer isDel;
|
||||
|
||||
/**
|
||||
* 是否开启库存
|
||||
*/
|
||||
private Integer isStock;
|
||||
|
||||
/**
|
||||
* 是否暂停销售
|
||||
*/
|
||||
private Integer isPauseSale;
|
||||
|
||||
private Long createdAt;
|
||||
|
||||
private Long updatedAt;
|
||||
|
||||
/**
|
||||
* 0 固定套餐 1可选套餐
|
||||
*/
|
||||
private Integer groupType;
|
||||
|
||||
/**
|
||||
* 套餐内容
|
||||
*/
|
||||
private String groupSnap;
|
||||
|
||||
/**
|
||||
* 规格详情
|
||||
*/
|
||||
private String specInfo;
|
||||
|
||||
/**
|
||||
* 已选择的规格
|
||||
*/
|
||||
private String selectSpec;
|
||||
|
||||
/**
|
||||
* 已选规格表格头部
|
||||
*/
|
||||
private String specTableHeaders;
|
||||
|
||||
/**
|
||||
* 团购卷分类,可有多个分类
|
||||
*/
|
||||
private String groupCategoryId;
|
||||
|
||||
/**
|
||||
* 销量
|
||||
*/
|
||||
private Integer realSalesNumber;
|
||||
|
||||
/**
|
||||
* 商品级库存数量
|
||||
*/
|
||||
private Integer stockNumber;
|
||||
|
||||
/**
|
||||
* 是否上架
|
||||
*/
|
||||
private Boolean isGrounding;
|
||||
|
||||
/**
|
||||
* 退款是否退回库存
|
||||
*/
|
||||
private Boolean isRefundStock;
|
||||
|
||||
/**
|
||||
* 库存警戒线
|
||||
*/
|
||||
private Integer warnLine;
|
||||
|
||||
/**
|
||||
* 堂食 table 自取 dine 配送 delivery 快递 express
|
||||
*/
|
||||
private String showType;
|
||||
|
||||
/**
|
||||
* 称重 价格/千克
|
||||
*/
|
||||
private BigDecimal weight;
|
||||
|
||||
/**
|
||||
* 是否允许临时改价
|
||||
*/
|
||||
private Integer isTempPrice;
|
||||
|
||||
/**
|
||||
* 日销售上限
|
||||
*/
|
||||
private Integer dayLimit;
|
||||
|
||||
/**
|
||||
* 每单销售上限
|
||||
*/
|
||||
private Integer singleOrderLimit;
|
||||
|
||||
/**
|
||||
* 每人销售上限
|
||||
*/
|
||||
private Integer singlePeopleLimit;
|
||||
|
||||
/**
|
||||
* 周 数组 'Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday'
|
||||
*/
|
||||
private String days;
|
||||
|
||||
/**
|
||||
* 可用开始时间
|
||||
*/
|
||||
private Time startTime;
|
||||
|
||||
/**
|
||||
* 可用结束时间
|
||||
*/
|
||||
private Time endTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.czg.mergedata.old.mapper;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.old.entity.OldProduct;
|
||||
|
||||
/**
|
||||
* 映射层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
@UseDataSource("ds2")
|
||||
public interface OldProductMapper extends BaseMapper<OldProduct> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.czg.mergedata.old.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.old.entity.OldProduct;
|
||||
|
||||
/**
|
||||
* 服务层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
public interface OldProductService extends IService<OldProduct> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.czg.mergedata.old.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.old.entity.OldProduct;
|
||||
import com.czg.mergedata.old.mapper.OldProductMapper;
|
||||
import com.czg.mergedata.old.service.OldProductService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 服务层实现。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
@Service
|
||||
public class OldProductServiceImpl extends ServiceImpl<OldProductMapper, OldProduct> implements OldProductService{
|
||||
|
||||
}
|
||||
|
|
@ -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.CurProductMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -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.old.mapper.OldProductMapper">
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue