This commit is contained in:
PQZ 2025-03-31 18:12:10 +08:00
parent 63b4f6147d
commit 4eeab0fa44
4 changed files with 32 additions and 18 deletions

View File

@ -31,11 +31,15 @@ public interface IMemberCardService extends IService<MemberCard> {
/**
* 会员开卡处理
*
* @param order 订单
* @param userId 用户id
* @param userType 用户类型
* @param cardId 卡id
* @param cycle 时间
* @param orderId 订单id
* @author PQZ
* @date 16:18 2025/3/26
* @date 18:06 2025/3/31
**/
void dealMemberCard(MemberOrder order);
void dealMemberCard(Long userId, String userType, String cardId, String cycle, String orderId);
/**
* 查当前会员权益列表

View File

@ -72,39 +72,43 @@ public class MemberCardServiceImpl extends ServiceImpl<MemberCardMapper, MemberC
/**
* 会员开卡处理
*
* @param order {@link MemberOrder}
* @param userId 用户id
* @param userType 用户类型
* @param cardId 卡id
* @param cycle 时间
* @param orderId 订单id
* @author PQZ
* @date 16:19 2025/3/26
* @date 18:06 2025/3/31
**/
@Override
public void dealMemberCard(MemberOrder order) {
public void dealMemberCard(Long userId, String userType, String cardId, String cycle, String orderId) {
/*1、数据初始化*/
//查询会员卡
BaseCardVO card = baseCardService.queryByCardId(order.getGoodsId());
BaseCardVO card = baseCardService.queryByCardId(cardId);
//查询当前时间是否存在有效会员卡
List<MemberCard> cardList = checkMemberCard(order.getGoodsId(), order.getUserId());
List<MemberCard> cardList = checkMemberCard(cardId, userId);
/*2、计算到期时间*/
Date startTime;
Date endTime;
if (cardList.isEmpty()){
if (cardList.isEmpty()) {
//计算到期时间
startTime = new Date();
endTime = getEndTime(startTime, order.getGoodsCycle());
endTime = getEndTime(startTime, cycle);
//新增时需要处理会员权益
rightsService.dealRights(order.getUserId(),order.getUserType(),card.getRights());
rightsService.dealRights(userId, userType, card.getRights());
} else {
startTime = cardList.get(0).getEndDate();
endTime = getEndTime(startTime,order.getGoodsCycle());
endTime = getEndTime(startTime, cycle);
}
/*3、保存会员开卡记录*/
//初始化会员开通记录
MemberCard memberCard = new MemberCard();
memberCard.setUserId(order.getUserId());
memberCard.setUserType(order.getUserType());
memberCard.setCardId(order.getGoodsId());
memberCard.setOrderId(order.getId());
memberCard.setUserId(userId);
memberCard.setUserType(userType);
memberCard.setCardId(cardId);
memberCard.setOrderId(orderId);
memberCard.setCardName(card.getCardName());
memberCard.setStartDate(startTime);
memberCard.setEndDate(endTime);
@ -154,6 +158,9 @@ public class MemberCardServiceImpl extends ServiceImpl<MemberCardMapper, MemberC
case "03":
calendar.add(Calendar.YEAR, 1);
break;
case "04":
calendar.add(Calendar.YEAR, 100);
break;
default:
throw new IllegalArgumentException("无效的时间类型: " + type);
}
@ -228,7 +235,7 @@ public class MemberCardServiceImpl extends ServiceImpl<MemberCardMapper, MemberC
if (memberCards.isEmpty()) {
return 0;
} else {
return rightsService.getReport(memberCards.get(0).getUserId(),memberCards.get(0).getCardId());
return rightsService.getReport(memberCards.get(0).getUserId(), memberCards.get(0).getCardId());
}
}

View File

@ -68,7 +68,7 @@ public class MemberOrderServiceImpl extends ServiceImpl<MemberOrderMapper,Member
MemberOrder memberOrder = getOne(lambdaQueryWrapper);
/*2、处理不同类型订单*/
if ("01".equals(memberOrder.getOrderType())) {
cardService.dealMemberCard(memberOrder);
cardService.dealMemberCard(memberOrder.getUserId(),memberOrder.getUserType(),memberOrder.getGoodsId(),memberOrder.getGoodsCycle(),memberOrder.getId());
} else {
couponService.dealMemberCoupon(memberOrder);
}

View File

@ -152,6 +152,9 @@ public class MemberUserServiceImpl extends ServiceImpl<MemberUserMapper, MemberU
//插入用户扩展信息表数据
this.save(new MemberUser(DictConstants.USER_TYPE_TGZ,user,dlRightsConfig.getAddNotice()));
this.save(new MemberUser(DictConstants.USER_TYPE_BZ,user,null));
//开通会员卡
cardService.dealMemberCard(user.getUserId(),"01","67def5ba1e4c60754e68defb3fb027a5","04",null);
cardService.dealMemberCard(user.getUserId(),"02","7530cf7b7a5d0100a7b41605d1642ef1","04",null);
}else {
//,查到了
if(!"0".equals(wxUser.getStatus())){