迁移 用户流水

This commit is contained in:
GYJ 2025-03-13 09:31:22 +08:00
parent d3efee85dd
commit fef8fc22ea
2 changed files with 26 additions and 27 deletions

View File

@ -10,7 +10,6 @@ import com.czg.mergedata.cur.entity.CurShopUserFlow;
import com.czg.mergedata.cur.entity.CurUserInfo;
import com.czg.mergedata.cur.mapper.CurOrderPaymentMapper;
import com.czg.mergedata.cur.mapper.CurShopUserFlowMapper;
import com.czg.mergedata.cur.service.CurShopIdRelationService;
import com.czg.mergedata.cur.service.CurShopUserFlowService;
import com.czg.mergedata.cur.service.CurUserInfoService;
import com.czg.mergedata.old.entity.OldShopUser;
@ -42,9 +41,6 @@ import static com.mybatisflex.core.query.QueryMethods.column;
@Service
public class CurShopUserFlowServiceImpl extends ServiceImpl<CurShopUserFlowMapper, CurShopUserFlow> implements CurShopUserFlowService {
@Resource
private CurShopIdRelationService curShopIdRelationService;
@Resource
private CurOrderPaymentMapper curOrderPaymentMapper;
@ -69,18 +65,16 @@ public class CurShopUserFlowServiceImpl extends ServiceImpl<CurShopUserFlowMappe
getMapper().truncateTable();
curOrderPaymentMapper.truncateTable();
Map<Long, Long> oldAndCurShopIdMap = curShopIdRelationService.getOldShopIdRelation();
Map<Long, ShopUserIdClass> shopUserIdClassMap = getShopUserIdClassMap();
Map<Long, ShopUserIdClass> shopUserIdClassMap = getShopUserIdClassMap(oldAndCurShopIdMap);
execUserFlow(oldAndCurShopIdMap, shopUserIdClassMap);
execUserFlow(shopUserIdClassMap);
execRefundFlow();
return CzgResult.success("迁移成功");
}
private Map<Long, ShopUserIdClass> getShopUserIdClassMap(Map<Long, Long> oldAndCurShopIdMap) {
private Map<Long, ShopUserIdClass> getShopUserIdClassMap() {
QueryWrapper queryWrapper = QueryWrapper.create().select(OldShopUser::getShopId, OldShopUser::getUserId).from(OldShopUser.class)
.and(column(OldShopUser::getIsVip).eq(1).or(column(OldShopUser::getAmount).gt(0)));
@ -91,7 +85,7 @@ public class CurShopUserFlowServiceImpl extends ServiceImpl<CurShopUserFlowMappe
for (OldShopUser oldShopUser : list) {
ShopUserIdClass shopUserIdClass = new ShopUserIdClass();
shopUserIdClass.setShopId(oldAndCurShopIdMap.get(Long.valueOf(oldShopUser.getShopId())));
shopUserIdClass.setShopId(Long.valueOf(oldShopUser.getShopId()));
shopUserIdClass.setUserId(getOldShopUserUserId(oldShopUser));
shopUserIdClassMap.put(shopUserIdClass.getUserId(), shopUserIdClass);
@ -100,11 +94,11 @@ public class CurShopUserFlowServiceImpl extends ServiceImpl<CurShopUserFlowMappe
return shopUserIdClassMap;
}
private void execUserFlow(Map<Long, Long> oldAndCurShopIdMap, Map<Long, ShopUserIdClass> shopUserIdClassMap) {
private void execUserFlow(Map<Long, ShopUserIdClass> shopUserIdClassMap) {
Page<OldShopUserFlow> page = oldShopUserFlowService.page(PageUtils.buildPage());
while (!page.getRecords().isEmpty()) {
saveUserFlow(page.getRecords(), shopUserIdClassMap, oldAndCurShopIdMap);
saveUserFlow(page.getRecords(), shopUserIdClassMap);
page = oldShopUserFlowService.page(PageUtils.buildPage(page.getPageNumber() + 1));
}
@ -182,7 +176,7 @@ public class CurShopUserFlowServiceImpl extends ServiceImpl<CurShopUserFlowMappe
}
}
private void saveUserFlow(List<OldShopUserFlow> oldShopUserFlowList, Map<Long, ShopUserIdClass> shopUserIdClassMap, Map<Long, Long> oldAndCurShopIdMap) {
private void saveUserFlow(List<OldShopUserFlow> oldShopUserFlowList, Map<Long, ShopUserIdClass> shopUserIdClassMap) {
List<CurShopUserFlow> curShopUserFlowList = new ArrayList<>();
for (OldShopUserFlow oldShopUserFlow : oldShopUserFlowList) {
@ -256,21 +250,20 @@ public class CurShopUserFlowServiceImpl extends ServiceImpl<CurShopUserFlowMappe
return curUserInfo.getId();
}
/**
* 类型
* cashIn 现金充值
* wechatIn 微信小程序充值
* alipayIn 支付宝小程序充值
* awardIn 充值奖励
* rechargeRefund 充值退款
* orderPay 订单消费
* orderRefund 订单退款
* adminIn 管理员充值
* adminOut管理员消费
*/
private ShopUserFlowBizEnum getShopUserFlowBizEnum(String type) {
/**
* 类型
* cashIn 现金充值
* wechatIn 微信小程序充值
* alipayIn 支付宝小程序充值
* awardIn 充值奖励
* rechargeRefund 充值退款
*
* orderPay 订单消费
* orderRefund 订单退款
*
* adminIn 管理员充值
* adminOut管理员消费
*/
return switch (type) {
case "scanMemberIn", "inMoneyIn" -> ShopUserFlowBizEnum.WECHAT_IN;
case "inMoneyOut", "memberReturn" -> ShopUserFlowBizEnum.RECHARGE_REFUND;

View File

@ -33,5 +33,11 @@
- tb_user_info 表
- tb_shop_user 表
### 3. 用户余额流水 支付记录
> /merge/user/userFlow
#### 执行表
- tb_shop_user_flow 表
- tb_order_payment 表