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