用户余额流水迁移
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package com.czg.mergedata.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
|
||||
@Getter
|
||||
public enum ShopUserFlowBizEnum {
|
||||
// 会员充值
|
||||
CASH_IN("cashIn", "会员充值"),
|
||||
// 重置奖励
|
||||
AWARD_IN("awardIn", "充值奖励"),
|
||||
// 微信小程序充值
|
||||
WECHAT_IN("wechatIn", "微信小程序充值"),
|
||||
// 支付宝小程序重置
|
||||
ALIPAY_IN("alipayIn", "支付宝小程序充值"),
|
||||
// 订单支付奖励
|
||||
ORDER_PAY("orderPay", "订单支付奖励"),
|
||||
// 订单退款
|
||||
ORDER_REFUND("orderRefund", "订单退款"),
|
||||
// 充值退款
|
||||
RECHARGE_REFUND("rechargeRefund", "充值退款"),
|
||||
// 管理员手动增减余额
|
||||
ADMIN_IN("adminIn", "管理员手动增减余额"),
|
||||
//管理员退款充值
|
||||
// ADMIN_REFUND("adminRefund"),
|
||||
//adminOut
|
||||
ADMIN_OUT("adminOut", "管理员退款充值"),
|
||||
//adminInOut
|
||||
// ADMIN_IN_OUT("adminInOut"),
|
||||
NOT_FOUND("notFound", "未找到"),
|
||||
;
|
||||
private final String code;
|
||||
private final String msg;
|
||||
|
||||
ShopUserFlowBizEnum(String code, String msg) {
|
||||
this.msg = msg;
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class CodeGen {
|
||||
//设置表前缀和只生成哪些表,setGenerateTable 未配置时,生成所有表
|
||||
globalConfig.getStrategyConfig()
|
||||
.setTablePrefix("tb_")
|
||||
.setGenerateTable("tb_call_config", "tb_call_queue", "tb_call_table");
|
||||
.setGenerateTable("tb_shop_user_flow", "tb_order_payment");
|
||||
|
||||
EntityConfig entityConfig = globalConfig.getEntityConfig();
|
||||
if (isOldVersion) {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.czg.mergedata.controller;
|
||||
|
||||
import com.czg.mergedata.common.resp.CzgResult;
|
||||
import com.czg.mergedata.cur.service.CurShopUserFlowService;
|
||||
import com.czg.mergedata.cur.service.CurSysUserService;
|
||||
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;
|
||||
|
||||
@@ -16,8 +18,16 @@ public class UserController {
|
||||
@Resource
|
||||
private CurSysUserService curSysUserService;
|
||||
|
||||
@Resource
|
||||
private CurShopUserFlowService curShopUserFlowService;
|
||||
|
||||
@RequestMapping("/mergeShopInfo")
|
||||
public CzgResult<String> mergeShopInfo() {
|
||||
return curSysUserService.mergeShopInfo();
|
||||
}
|
||||
|
||||
@GetMapping("/userFlow")
|
||||
public CzgResult<String> userFlow() {
|
||||
return curShopUserFlowService.mergeData();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 支付详情 实体类。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_order_payment")
|
||||
public class CurOrderPayment implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 店铺Id
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 来源Id 订单Id或 会员充值时为 会员Id
|
||||
*/
|
||||
private Long sourceId;
|
||||
|
||||
/**
|
||||
* 支付方式:order,refund, memberIn,memberRefund
|
||||
*/
|
||||
private String payType;
|
||||
|
||||
/**
|
||||
* 支付单号 唯一 自己系统的 mchOrderNo
|
||||
*/
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 微信或支付宝支付条码
|
||||
*/
|
||||
private String authCode;
|
||||
|
||||
/**
|
||||
* 金额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
/**
|
||||
* 三方支付单号 返回结果的 payOrderId
|
||||
*/
|
||||
private String tradeNumber;
|
||||
|
||||
private LocalDateTime payTime;
|
||||
|
||||
/**
|
||||
* 支付相应结果 json
|
||||
*/
|
||||
private String respJson;
|
||||
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 用户余额流水 实体类。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_shop_user_flow")
|
||||
public class CurShopUserFlow implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 操作金额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
/**
|
||||
* 用户余额
|
||||
*/
|
||||
private BigDecimal balance;
|
||||
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
private BigDecimal refundAmount;
|
||||
|
||||
/**
|
||||
* 类型:cashIn 会员充值,awardIn 充值奖励,wechatIn 微信小程序充值,alipayIn 支付宝小程序充值,orderPay 订单消费,orderRefund 订单退款,rechargeRefund 充值退款 adminIn 管理员充值
|
||||
adminRefund 管理员退款充值 adminOut管理员消费 adminInOut管理员充值扣除
|
||||
*/
|
||||
private String bizCode;
|
||||
|
||||
/**
|
||||
* 关联id,
|
||||
订单支付/订单退款/霸王餐时 订单id
|
||||
支付/退款 tb_order_payment.id
|
||||
|
||||
*/
|
||||
private Long relationId;
|
||||
|
||||
/**
|
||||
* 充值记录Id 退款使用
|
||||
*/
|
||||
private Long rechargeId;
|
||||
|
||||
private String remark;
|
||||
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.czg.mergedata.cur.mapper;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.cur.entity.CurOrderPayment;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 支付详情 映射层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@UseDataSource("ds1")
|
||||
public interface CurOrderPaymentMapper extends BaseMapper<CurOrderPayment> {
|
||||
@Select("truncate tb_order_payment")
|
||||
void truncateTable();
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.czg.mergedata.cur.mapper;
|
||||
|
||||
import com.mybatisflex.annotation.UseDataSource;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.mergedata.cur.entity.CurShopUserFlow;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 用户余额流水 映射层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@UseDataSource("ds1")
|
||||
public interface CurShopUserFlowMapper extends BaseMapper<CurShopUserFlow> {
|
||||
@Select("truncate tb_shop_user_flow")
|
||||
void truncateTable();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.czg.mergedata.cur.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.cur.entity.CurOrderPayment;
|
||||
|
||||
/**
|
||||
* 支付详情 服务层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
public interface CurOrderPaymentService extends IService<CurOrderPayment> {
|
||||
|
||||
}
|
||||
@@ -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.CurShopUserFlow;
|
||||
|
||||
/**
|
||||
* 用户余额流水 服务层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
public interface CurShopUserFlowService extends IService<CurShopUserFlow> {
|
||||
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.CurOrderPayment;
|
||||
import com.czg.mergedata.cur.mapper.CurOrderPaymentMapper;
|
||||
import com.czg.mergedata.cur.service.CurOrderPaymentService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 支付详情 服务层实现。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@Service
|
||||
public class CurOrderPaymentServiceImpl extends ServiceImpl<CurOrderPaymentMapper, CurOrderPayment> implements CurOrderPaymentService{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
package com.czg.mergedata.cur.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.generator.SnowflakeGenerator;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czg.mergedata.common.enums.ShopUserFlowBizEnum;
|
||||
import com.czg.mergedata.common.resp.CzgResult;
|
||||
import com.czg.mergedata.common.utils.PageUtils;
|
||||
import com.czg.mergedata.cur.entity.CurOrderPayment;
|
||||
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;
|
||||
import com.czg.mergedata.old.entity.OldShopUserFlow;
|
||||
import com.czg.mergedata.old.service.OldShopUserFlowService;
|
||||
import com.czg.mergedata.old.service.OldShopUserService;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.Data;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mybatisflex.core.query.QueryMethods.column;
|
||||
|
||||
/**
|
||||
* 用户余额流水 服务层实现。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@Service
|
||||
public class CurShopUserFlowServiceImpl extends ServiceImpl<CurShopUserFlowMapper, CurShopUserFlow> implements CurShopUserFlowService {
|
||||
|
||||
@Resource
|
||||
private CurShopIdRelationService curShopIdRelationService;
|
||||
|
||||
@Resource
|
||||
private CurOrderPaymentMapper curOrderPaymentMapper;
|
||||
|
||||
@Resource
|
||||
private OldShopUserService oldShopUserService;
|
||||
|
||||
@Resource
|
||||
private CurUserInfoService curUserInfoService;
|
||||
|
||||
@Resource
|
||||
private OldShopUserFlowService oldShopUserFlowService;
|
||||
|
||||
@Data
|
||||
static class ShopUserIdClass {
|
||||
private Long shopId;
|
||||
private Long userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<String> mergeData() {
|
||||
getMapper().truncateTable();
|
||||
curOrderPaymentMapper.truncateTable();
|
||||
|
||||
Map<Long, Long> oldAndCurShopIdMap = curShopIdRelationService.getOldShopIdRelation();
|
||||
|
||||
Map<Long, ShopUserIdClass> shopUserIdClassMap = getShopUserIdClassMap(oldAndCurShopIdMap);
|
||||
|
||||
execUserFlow(oldAndCurShopIdMap, shopUserIdClassMap);
|
||||
|
||||
execRefundFlow();
|
||||
|
||||
return CzgResult.success("迁移成功");
|
||||
}
|
||||
|
||||
private Map<Long, ShopUserIdClass> getShopUserIdClassMap(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create().select(OldShopUser::getShopId, OldShopUser::getUserId).from(OldShopUser.class)
|
||||
.and(column(OldShopUser::getIsVip).eq(1).or(column(OldShopUser::getAmount).gt(0)));
|
||||
|
||||
List<OldShopUser> list = oldShopUserService.list(queryWrapper);
|
||||
|
||||
Map<Long, ShopUserIdClass> shopUserIdClassMap = new HashMap<>();
|
||||
|
||||
for (OldShopUser oldShopUser : list) {
|
||||
ShopUserIdClass shopUserIdClass = new ShopUserIdClass();
|
||||
|
||||
shopUserIdClass.setShopId(oldAndCurShopIdMap.get(Long.valueOf(oldShopUser.getShopId())));
|
||||
shopUserIdClass.setUserId(getOldShopUserUserId(oldShopUser));
|
||||
|
||||
shopUserIdClassMap.put(shopUserIdClass.getUserId(), shopUserIdClass);
|
||||
}
|
||||
|
||||
return shopUserIdClassMap;
|
||||
}
|
||||
|
||||
private void execUserFlow(Map<Long, Long> oldAndCurShopIdMap, Map<Long, ShopUserIdClass> shopUserIdClassMap) {
|
||||
Page<OldShopUserFlow> page = oldShopUserFlowService.page(PageUtils.buildPage());
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
saveUserFlow(page.getRecords(), shopUserIdClassMap, oldAndCurShopIdMap);
|
||||
|
||||
page = oldShopUserFlowService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void execRefundFlow() {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select()
|
||||
.from(CurShopUserFlow.class)
|
||||
.isNotNull(CurShopUserFlow::getRemark)
|
||||
.ne(CurShopUserFlow::getRemark, "");
|
||||
|
||||
List<CurShopUserFlow> list = list(queryWrapper);
|
||||
|
||||
List<CurShopUserFlow> rechargeList = new ArrayList<>();
|
||||
List<CurShopUserFlow> refundList = new ArrayList<>();
|
||||
|
||||
for (CurShopUserFlow curShopUserFlow : list) {
|
||||
String remark = curShopUserFlow.getRemark();
|
||||
|
||||
if (remark.length() > 10) {
|
||||
// 创建 支付记录,回填 relationId
|
||||
rechargeList.add(curShopUserFlow);
|
||||
} else {
|
||||
// 创建退款记录 ,回填 relationId 退款金额 充值记录 id
|
||||
refundList.add(curShopUserFlow);
|
||||
}
|
||||
}
|
||||
|
||||
for (CurShopUserFlow curShopUserFlow : rechargeList) {
|
||||
CurOrderPayment curOrderPayment = new CurOrderPayment();
|
||||
curOrderPayment.setShopId(curShopUserFlow.getShopId());
|
||||
curOrderPayment.setSourceId(curShopUserFlow.getId());
|
||||
curOrderPayment.setPayType("memberIn");
|
||||
curOrderPayment.setOrderNo(curShopUserFlow.getRemark());
|
||||
curOrderPayment.setAmount(curShopUserFlow.getAmount());
|
||||
curOrderPayment.setPayTime(curShopUserFlow.getCreateTime());
|
||||
curOrderPayment.setRespJson("{}");
|
||||
|
||||
curOrderPaymentMapper.insert(curOrderPayment);
|
||||
|
||||
curShopUserFlow.setRelationId(curOrderPayment.getId());
|
||||
updateById(curShopUserFlow);
|
||||
}
|
||||
|
||||
for (CurShopUserFlow curShopUserFlow : refundList) {
|
||||
Long rechargeId = Long.valueOf(curShopUserFlow.getRemark());
|
||||
|
||||
CurShopUserFlow rechargeFlow = getById(rechargeId);
|
||||
|
||||
if (rechargeFlow == null) {
|
||||
System.out.println("rechargeFlow is null");
|
||||
continue;
|
||||
}
|
||||
|
||||
BigDecimal refundAmount = curShopUserFlow.getAmount().negate();
|
||||
BigDecimal curRefundAmount =rechargeFlow.getRefundAmount() == null ? BigDecimal.ZERO : rechargeFlow.getRefundAmount();
|
||||
rechargeFlow.setRefundAmount(curRefundAmount.add(refundAmount));
|
||||
updateById(rechargeFlow);
|
||||
|
||||
CurOrderPayment curOrderPayment = new CurOrderPayment();
|
||||
curOrderPayment.setShopId(curShopUserFlow.getShopId());
|
||||
curOrderPayment.setSourceId(curShopUserFlow.getId());
|
||||
curOrderPayment.setPayType("memberRefund");
|
||||
curOrderPayment.setOrderNo(String.valueOf(new SnowflakeGenerator().next()));
|
||||
curOrderPayment.setAmount(curShopUserFlow.getAmount());
|
||||
curOrderPayment.setPayTime(curShopUserFlow.getCreateTime());
|
||||
curOrderPayment.setRespJson("{}");
|
||||
|
||||
curOrderPaymentMapper.insert(curOrderPayment);
|
||||
|
||||
curShopUserFlow.setRelationId(curOrderPayment.getId());
|
||||
curShopUserFlow.setRechargeId(rechargeId);
|
||||
updateById(curShopUserFlow);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveUserFlow(List<OldShopUserFlow> oldShopUserFlowList, Map<Long, ShopUserIdClass> shopUserIdClassMap, Map<Long, Long> oldAndCurShopIdMap) {
|
||||
List<CurShopUserFlow> curShopUserFlowList = new ArrayList<>();
|
||||
|
||||
for (OldShopUserFlow oldShopUserFlow : oldShopUserFlowList) {
|
||||
CurShopUserFlow curShopUserFlow = new CurShopUserFlow();
|
||||
|
||||
ShopUserIdClass shopUserIdClass = getShopUserIdClass(oldShopUserFlow.getShopUserId(), shopUserIdClassMap);
|
||||
if (shopUserIdClass == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
curShopUserFlow.setId(Long.valueOf(oldShopUserFlow.getId()));
|
||||
curShopUserFlow.setUserId(shopUserIdClass.getUserId());
|
||||
curShopUserFlow.setShopId(shopUserIdClass.getShopId());
|
||||
curShopUserFlow.setAmount(oldShopUserFlow.getAmount());
|
||||
curShopUserFlow.setBalance(oldShopUserFlow.getBalance());
|
||||
curShopUserFlow.setCreateTime(oldShopUserFlow.getCreateTime());
|
||||
|
||||
ShopUserFlowBizEnum flowBizEnum = getShopUserFlowBizEnum(oldShopUserFlow.getBizCode());
|
||||
curShopUserFlow.setBizCode(flowBizEnum.getCode());
|
||||
|
||||
if ("-".equals(oldShopUserFlow.getType())) {
|
||||
curShopUserFlow.setAmount(curShopUserFlow.getAmount().multiply(new BigDecimal(-1)));
|
||||
}
|
||||
|
||||
curShopUserFlow.setCreateTime(oldShopUserFlow.getCreateTime());
|
||||
curShopUserFlow.setRemark(oldShopUserFlow.getRemark());
|
||||
|
||||
curShopUserFlowList.add(curShopUserFlow);
|
||||
}
|
||||
|
||||
saveBatch(curShopUserFlowList);
|
||||
}
|
||||
|
||||
private ShopUserIdClass getShopUserIdClass(Integer shopUserId, Map<Long, ShopUserIdClass> shopUserIdClassMap) {
|
||||
ShopUserIdClass shopUserIdClass = shopUserIdClassMap.get(Long.valueOf(shopUserId));
|
||||
|
||||
if (shopUserIdClass == null) {
|
||||
OldShopUser byId = oldShopUserService.getById(shopUserId);
|
||||
if (byId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
shopUserIdClass = new ShopUserIdClass();
|
||||
shopUserIdClass.setShopId(Long.valueOf(byId.getShopId()));
|
||||
shopUserIdClass.setUserId(getOldShopUserUserId(byId));
|
||||
shopUserIdClassMap.put(Long.valueOf(byId.getShopId()), shopUserIdClass);
|
||||
}
|
||||
|
||||
return shopUserIdClass;
|
||||
}
|
||||
|
||||
private Long getOldShopUserUserId(OldShopUser oldShopUser) {
|
||||
if (oldShopUser == null) {
|
||||
return 0L;
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(oldShopUser.getUserId())) {
|
||||
return Long.valueOf(oldShopUser.getUserId());
|
||||
}
|
||||
|
||||
CurUserInfo curUserInfo = new CurUserInfo();
|
||||
curUserInfo.setHeadImg(oldShopUser.getHeadImg());
|
||||
curUserInfo.setNickName(oldShopUser.getName());
|
||||
curUserInfo.setPayPwd(oldShopUser.getTelephone());
|
||||
curUserInfo.setBirthDay(oldShopUser.getBirthDay());
|
||||
curUserInfo.setSex(oldShopUser.getSex());
|
||||
curUserInfo.setStatus(oldShopUser.getStatus());
|
||||
|
||||
curUserInfoService.save(curUserInfo);
|
||||
|
||||
return curUserInfo.getId();
|
||||
}
|
||||
|
||||
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;
|
||||
case "scanMemberAwardIn" -> ShopUserFlowBizEnum.AWARD_IN;
|
||||
case "cashMemberIn" -> ShopUserFlowBizEnum.CASH_IN;
|
||||
case "accountReturnPay", "consumeIn", "vipCardCash" -> ShopUserFlowBizEnum.ORDER_REFUND;
|
||||
case "accountPay", "accountGroupPay", "consumeOut" -> ShopUserFlowBizEnum.ORDER_PAY;
|
||||
default -> ShopUserFlowBizEnum.NOT_FOUND;
|
||||
};
|
||||
}
|
||||
}
|
||||
107
src/main/java/com/czg/mergedata/old/entity/OldOrderPayment.java
Normal file
107
src/main/java/com/czg/mergedata/old/entity/OldOrderPayment.java
Normal file
@@ -0,0 +1,107 @@
|
||||
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.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 订单支付展示 实体类。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_order_payment")
|
||||
public class OldOrderPayment implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 支付方式Id
|
||||
*/
|
||||
private String payTypeId;
|
||||
|
||||
/**
|
||||
* 实际支付金额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
private BigDecimal paidAmount;
|
||||
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
private BigDecimal hasRefundAmount;
|
||||
|
||||
/**
|
||||
* 支付方式名称
|
||||
*/
|
||||
private String payName;
|
||||
|
||||
/**
|
||||
* 支付方式
|
||||
*/
|
||||
private String payType;
|
||||
|
||||
/**
|
||||
* 收款
|
||||
*/
|
||||
private BigDecimal received;
|
||||
|
||||
/**
|
||||
* 找零
|
||||
*/
|
||||
private BigDecimal changeFee;
|
||||
|
||||
/**
|
||||
* 商户Id
|
||||
*/
|
||||
private String merchantId;
|
||||
|
||||
/**
|
||||
* 店铺Id
|
||||
*/
|
||||
private String shopId;
|
||||
|
||||
/**
|
||||
* 结算单号
|
||||
*/
|
||||
private String billingId;
|
||||
|
||||
private String orderId;
|
||||
|
||||
private String authCode;
|
||||
|
||||
private String refundable;
|
||||
|
||||
private Long createdAt;
|
||||
|
||||
private Long updatedAt;
|
||||
|
||||
private String tradeNumber;
|
||||
|
||||
/**
|
||||
* 会员Id
|
||||
*/
|
||||
private String memberId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.czg.mergedata.old.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;
|
||||
|
||||
/**
|
||||
* 实体类。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_shop_user_flow")
|
||||
public class OldShopUserFlow implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Integer id;
|
||||
|
||||
private Integer shopUserId;
|
||||
|
||||
private BigDecimal amount;
|
||||
|
||||
private BigDecimal balance;
|
||||
|
||||
private String bizCode;
|
||||
|
||||
private String bizName;
|
||||
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
private String type;
|
||||
|
||||
private String isReturn;
|
||||
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -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.OldOrderPayment;
|
||||
|
||||
/**
|
||||
* 订单支付展示 映射层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@UseDataSource("ds2")
|
||||
public interface OldOrderPaymentMapper extends BaseMapper<OldOrderPayment> {
|
||||
|
||||
}
|
||||
@@ -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.OldShopUserFlow;
|
||||
|
||||
/**
|
||||
* 映射层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@UseDataSource("ds2")
|
||||
public interface OldShopUserFlowMapper extends BaseMapper<OldShopUserFlow> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.czg.mergedata.old.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.old.entity.OldOrderPayment;
|
||||
|
||||
/**
|
||||
* 订单支付展示 服务层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
public interface OldOrderPaymentService extends IService<OldOrderPayment> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.czg.mergedata.old.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.mergedata.old.entity.OldShopUserFlow;
|
||||
|
||||
/**
|
||||
* 服务层。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
public interface OldShopUserFlowService extends IService<OldShopUserFlow> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.czg.mergedata.old.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.old.entity.OldOrderPayment;
|
||||
import com.czg.mergedata.old.mapper.OldOrderPaymentMapper;
|
||||
import com.czg.mergedata.old.service.OldOrderPaymentService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 订单支付展示 服务层实现。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@Service
|
||||
public class OldOrderPaymentServiceImpl extends ServiceImpl<OldOrderPaymentMapper, OldOrderPayment> implements OldOrderPaymentService{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.czg.mergedata.old.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.old.entity.OldShopUserFlow;
|
||||
import com.czg.mergedata.old.mapper.OldShopUserFlowMapper;
|
||||
import com.czg.mergedata.old.service.OldShopUserFlowService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 服务层实现。
|
||||
*
|
||||
* @author mac
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@Service
|
||||
public class OldShopUserFlowServiceImpl extends ServiceImpl<OldShopUserFlowMapper, OldShopUserFlow> implements OldShopUserFlowService{
|
||||
|
||||
}
|
||||
7
src/main/resources/mapper/cur/OrderPaymentMapper.xml
Normal file
7
src/main/resources/mapper/cur/OrderPaymentMapper.xml
Normal file
@@ -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.CurOrderPaymentMapper">
|
||||
|
||||
</mapper>
|
||||
7
src/main/resources/mapper/cur/ShopUserFlowMapper.xml
Normal file
7
src/main/resources/mapper/cur/ShopUserFlowMapper.xml
Normal file
@@ -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.CurShopUserFlowMapper">
|
||||
|
||||
</mapper>
|
||||
7
src/main/resources/mapper/old/OrderPaymentMapper.xml
Normal file
7
src/main/resources/mapper/old/OrderPaymentMapper.xml
Normal file
@@ -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.OldOrderPaymentMapper">
|
||||
|
||||
</mapper>
|
||||
7
src/main/resources/mapper/old/ShopUserFlowMapper.xml
Normal file
7
src/main/resources/mapper/old/ShopUserFlowMapper.xml
Normal file
@@ -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.OldShopUserFlowMapper">
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user