1
This commit is contained in:
parent
c9c87a87b7
commit
20cc594430
@ -34,4 +34,13 @@ public interface IBaseCardRightsService extends IService<BaseCardRights>
|
||||
* @param cardRightsVOS TODO
|
||||
**/
|
||||
void saveAndUpdate(List<CardRightsVO> cardRightsVOS);
|
||||
|
||||
/**
|
||||
* 通过会员卡id查询权益
|
||||
* @author PQZ
|
||||
* @date 16:31 2025/3/26
|
||||
* @param cardId 会员卡id
|
||||
* @return java.util.List<com.ruoyi.base.domain.BaseCardRights>
|
||||
**/
|
||||
List<BaseCardRights> queryByCardId(String cardId);
|
||||
}
|
||||
|
@ -1,18 +1,27 @@
|
||||
package com.ruoyi.base.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.base.domain.BaseCard;
|
||||
import com.ruoyi.base.vo.BaseCardVO;
|
||||
|
||||
/**
|
||||
* 会员卡Service接口
|
||||
*
|
||||
*
|
||||
* @author vinjor-m
|
||||
* @date 2025-03-17
|
||||
*/
|
||||
public interface IBaseCardService extends IService<BaseCard>
|
||||
{
|
||||
public interface IBaseCardService extends IService<BaseCard> {
|
||||
IPage<BaseCard> queryListPage(BaseCard pageReqVO, Page<BaseCard> page);
|
||||
|
||||
/**
|
||||
* 通过会员卡id查询会员及权益
|
||||
*
|
||||
* @param cardId 卡片id
|
||||
* @return com.ruoyi.base.vo.BaseCardVO
|
||||
* @author PQZ
|
||||
* @date 16:25 2025/3/26
|
||||
**/
|
||||
BaseCardVO queryByCardId(String cardId);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.ruoyi.base.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
@ -8,11 +7,10 @@ import com.ruoyi.base.domain.BaseRights;
|
||||
|
||||
/**
|
||||
* 会员权益Service接口
|
||||
*
|
||||
*
|
||||
* @author vinjor-m
|
||||
* @date 2025-03-17
|
||||
*/
|
||||
public interface IBaseRightsService extends IService<BaseRights>
|
||||
{
|
||||
public interface IBaseRightsService extends IService<BaseRights> {
|
||||
IPage<BaseRights> queryListPage(BaseRights pageReqVO, Page<BaseRights> page);
|
||||
}
|
||||
|
@ -3,7 +3,9 @@ package com.ruoyi.base.service.impl;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.base.vo.CardRightsVO;
|
||||
import com.ruoyi.common.core.domain.DlBaseEntity;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -77,4 +79,19 @@ public class BaseCardRightsServiceImpl extends ServiceImpl<BaseCardRightsMapper,
|
||||
});
|
||||
this.saveBatch(insertList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过会员卡id查询权益
|
||||
*
|
||||
* @param cardId 会员卡id
|
||||
* @return java.util.List<com.ruoyi.base.domain.BaseCardRights>
|
||||
* @author PQZ
|
||||
* @date 16:31 2025/3/26
|
||||
**/
|
||||
@Override
|
||||
public List<BaseCardRights> queryByCardId(String cardId) {
|
||||
LambdaQueryWrapper<BaseCardRights> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(BaseCardRights::getCardId,cardId).eq(DlBaseEntity::getDelFlag,0);
|
||||
return list(lambdaQueryWrapper);
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,21 @@
|
||||
package com.ruoyi.base.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mchange.v2.beans.BeansUtils;
|
||||
import com.ruoyi.base.domain.BaseCard;
|
||||
import com.ruoyi.base.domain.BaseCardRights;
|
||||
import com.ruoyi.base.mapper.BaseCardMapper;
|
||||
import com.ruoyi.base.service.IBaseCardRightsService;
|
||||
import com.ruoyi.base.service.IBaseCardService;
|
||||
import com.ruoyi.base.vo.BaseCardVO;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.base.mapper.BaseCardMapper;
|
||||
import com.ruoyi.base.domain.BaseCard;
|
||||
import com.ruoyi.base.service.IBaseCardService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会员卡Service业务层处理
|
||||
@ -22,9 +28,29 @@ public class BaseCardServiceImpl extends ServiceImpl<BaseCardMapper,BaseCard> i
|
||||
{
|
||||
@Autowired
|
||||
private BaseCardMapper baseCardMapper;
|
||||
@Resource
|
||||
private IBaseCardRightsService cardRightsService;
|
||||
|
||||
@Override
|
||||
public IPage<BaseCard> queryListPage(BaseCard pageReqVO, Page<BaseCard> page) {
|
||||
return baseCardMapper.queryListPage(pageReqVO, page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过会员卡id查询会员及权益
|
||||
*
|
||||
* @param cardId 卡片id
|
||||
* @return com.ruoyi.base.vo.BaseCardVO
|
||||
* @author PQZ
|
||||
* @date 16:25 2025/3/26
|
||||
**/
|
||||
@Override
|
||||
public BaseCardVO queryByCardId(String cardId) {
|
||||
BaseCardVO cardVO = new BaseCardVO();
|
||||
BaseCard card = getById(cardId);
|
||||
BeanUtils.copyProperties(card,cardVO);
|
||||
List<BaseCardRights> rights = cardRightsService.queryByCardId(cardId);
|
||||
cardVO.setRights(rights);
|
||||
return cardVO;
|
||||
}
|
||||
}
|
||||
|
13
ruoyi-admin/src/main/java/com/ruoyi/base/vo/BaseCardVO.java
Normal file
13
ruoyi-admin/src/main/java/com/ruoyi/base/vo/BaseCardVO.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.ruoyi.base.vo;
|
||||
|
||||
import com.ruoyi.base.domain.BaseCard;
|
||||
import com.ruoyi.base.domain.BaseCardRights;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BaseCardVO extends BaseCard {
|
||||
/**会员卡关联权益*/
|
||||
List<BaseCardRights> rights;
|
||||
}
|
@ -53,6 +53,21 @@ public class MemberOrderController extends BaseController {
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单支付回调
|
||||
*
|
||||
* @param memberOrder {@link MemberOrder}
|
||||
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||
* @author PQZ
|
||||
* @date 14:01 2025/3/26
|
||||
**/
|
||||
@Log(title = "订单支付回调", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/payCallback")
|
||||
public AjaxResult payCallback(@RequestBody MemberOrder memberOrder) {
|
||||
memberOrderService.payCallback(memberOrder.getOrderNo());
|
||||
return toAjax(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出订单列表
|
||||
|
@ -59,6 +59,10 @@ public class MemberOrder extends DlBaseEntity
|
||||
@Excel(name = "商品数量")
|
||||
private Integer goodsNum;
|
||||
|
||||
/** 商品服务周期 */
|
||||
@Excel(name = "商品服务周期")
|
||||
private String goodsCycle;
|
||||
|
||||
/** 订单总价 */
|
||||
@Excel(name = "订单总价")
|
||||
private BigDecimal goodsPrice;
|
||||
|
@ -2,6 +2,7 @@ package com.ruoyi.member.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.member.domain.MemberCard;
|
||||
import com.ruoyi.member.domain.MemberOrder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -21,6 +22,15 @@ public interface IMemberCardService extends IService<MemberCard> {
|
||||
* @author PQZ
|
||||
* @date 14:24 2025/3/21
|
||||
**/
|
||||
List<MemberCard> listByUserId(Long userId,String userType);
|
||||
List<MemberCard> listByUserId(Long userId, String userType);
|
||||
|
||||
/**
|
||||
* 会员开卡处理
|
||||
*
|
||||
* @param order 订单
|
||||
* @author PQZ
|
||||
* @date 16:18 2025/3/26
|
||||
**/
|
||||
void dealMemberCard(MemberOrder order);
|
||||
|
||||
}
|
||||
|
@ -24,4 +24,13 @@ public interface IMemberOrderService extends IService<MemberOrder> {
|
||||
* @date 15:25 2025/3/25
|
||||
**/
|
||||
IPage<MemberOrderVO> queryListPage(MemberOrderVO memberOrder, Page<MemberOrder> page);
|
||||
|
||||
/**
|
||||
* 订单支付回调
|
||||
*
|
||||
* @param orderNo 订单编号
|
||||
* @author PQZ
|
||||
* @date 14:02 2025/3/26
|
||||
**/
|
||||
void payCallback(String orderNo);
|
||||
}
|
||||
|
@ -1,16 +1,17 @@
|
||||
package com.ruoyi.member.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.member.domain.MemberPoints;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 博主积分变动明细Service接口
|
||||
*
|
||||
*
|
||||
* @author pqz
|
||||
* @date 2025-03-17
|
||||
*/
|
||||
public interface IMemberPointsService extends IService<MemberPoints>
|
||||
{
|
||||
public interface IMemberPointsService extends IService<MemberPoints> {
|
||||
|
||||
void dealMemberPoints(Long userId, List<BaseP> );
|
||||
}
|
||||
|
@ -2,26 +2,34 @@ package com.ruoyi.member.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.base.domain.BaseCard;
|
||||
import com.ruoyi.base.service.IBaseCardService;
|
||||
import com.ruoyi.base.vo.BaseCardVO;
|
||||
import com.ruoyi.common.core.domain.DlBaseEntity;
|
||||
import com.ruoyi.member.domain.MemberCard;
|
||||
import com.ruoyi.member.domain.MemberOrder;
|
||||
import com.ruoyi.member.mapper.MemberCardMapper;
|
||||
import com.ruoyi.member.service.IMemberCardService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会员开卡记录Service业务层处理
|
||||
*
|
||||
*
|
||||
* @author pqz
|
||||
* @date 2025-03-17
|
||||
*/
|
||||
@Service
|
||||
public class MemberCardServiceImpl extends ServiceImpl<MemberCardMapper,MemberCard> implements IMemberCardService
|
||||
{
|
||||
public class MemberCardServiceImpl extends ServiceImpl<MemberCardMapper, MemberCard> implements IMemberCardService {
|
||||
@Autowired
|
||||
private MemberCardMapper memberCardMapper;
|
||||
@Resource
|
||||
private IBaseCardService baseCardService;
|
||||
|
||||
|
||||
/**
|
||||
@ -33,14 +41,72 @@ public class MemberCardServiceImpl extends ServiceImpl<MemberCardMapper,MemberCa
|
||||
* @date 14:24 2025/3/21
|
||||
**/
|
||||
@Override
|
||||
public List<MemberCard> listByUserId(Long userId,String userType) {
|
||||
public List<MemberCard> listByUserId(Long userId, String userType) {
|
||||
//查询列表
|
||||
LambdaUpdateWrapper<MemberCard> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
lambdaUpdateWrapper
|
||||
.eq(DlBaseEntity::getDelFlag,0)
|
||||
.eq(MemberCard::getUserId,userId)
|
||||
.eq(MemberCard::getUserType,userType)
|
||||
.eq(DlBaseEntity::getDelFlag, 0)
|
||||
.eq(MemberCard::getUserId, userId)
|
||||
.eq(MemberCard::getUserType, userType)
|
||||
.orderByDesc(DlBaseEntity::getCreateTime);
|
||||
return list(lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员开卡处理
|
||||
*
|
||||
* @param order {@link MemberOrder}
|
||||
* @author PQZ
|
||||
* @date 16:19 2025/3/26
|
||||
**/
|
||||
@Override
|
||||
public void dealMemberCard(MemberOrder order) {
|
||||
/*1、数据初始化*/
|
||||
//查询会员卡
|
||||
BaseCardVO card = baseCardService.queryByCardId(order.getGoodsId());
|
||||
//计算到期时间
|
||||
Date startTime = new Date();
|
||||
Date endTime = getEndTime(startTime,order.getGoodsCycle());
|
||||
//初始化会员开通记录
|
||||
MemberCard memberCard = new MemberCard();
|
||||
memberCard.setUserId(order.getUserId());
|
||||
memberCard.setUserType(order.getUserType());
|
||||
memberCard.setCardId(order.getGoodsId());
|
||||
memberCard.setOrderId(order.getId());
|
||||
memberCard.setCardName(card.getCardName());
|
||||
memberCard.setStartDate(startTime);
|
||||
memberCard.setEndDate(endTime);
|
||||
/*2、处理会员权益*/
|
||||
|
||||
/*3、保存记录*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员结束时间
|
||||
*
|
||||
* @param date 当前时间
|
||||
* @param type 类型(01:1个月;02:1季度;03:1年)
|
||||
* @return java.util.Date
|
||||
* @author PQZ
|
||||
* @date 16:40 2025/3/26
|
||||
**/
|
||||
private Date getEndTime(Date date, String type) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
switch (type) {
|
||||
case "01":
|
||||
calendar.add(Calendar.MONTH, 1);
|
||||
break;
|
||||
case "02":
|
||||
calendar.add(Calendar.MONTH, 3);
|
||||
break;
|
||||
case "03":
|
||||
calendar.add(Calendar.YEAR, 1);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("无效的时间类型: " + type);
|
||||
}
|
||||
return calendar.getTime();
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,22 @@
|
||||
package com.ruoyi.member.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.core.domain.DlBaseEntity;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.member.domain.MemberOrder;
|
||||
import com.ruoyi.member.mapper.MemberOrderMapper;
|
||||
import com.ruoyi.member.service.IMemberCardService;
|
||||
import com.ruoyi.member.service.IMemberOrderService;
|
||||
import com.ruoyi.member.vo.MemberOrderVO;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 订单Service业务层处理
|
||||
@ -21,6 +29,8 @@ public class MemberOrderServiceImpl extends ServiceImpl<MemberOrderMapper,Member
|
||||
{
|
||||
@Autowired
|
||||
private MemberOrderMapper memberOrderMapper;
|
||||
@Resource
|
||||
private IMemberCardService cardService;
|
||||
|
||||
|
||||
/**
|
||||
@ -36,4 +46,28 @@ public class MemberOrderServiceImpl extends ServiceImpl<MemberOrderMapper,Member
|
||||
public IPage<MemberOrderVO> queryListPage(MemberOrderVO memberOrder, Page<MemberOrder> page) {
|
||||
return memberOrderMapper.queryListPage(memberOrder,page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单支付回调
|
||||
*
|
||||
* @param orderNo 订单编号
|
||||
* @author PQZ
|
||||
* @date 14:02 2025/3/26
|
||||
**/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@SneakyThrows
|
||||
public void payCallback(String orderNo) {
|
||||
/*1、校验数据完整性*/
|
||||
LambdaQueryWrapper<MemberOrder> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(DlBaseEntity::getDelFlag,0).eq(MemberOrder::getOrderNo,orderNo);
|
||||
MemberOrder memberOrder = getOne(lambdaQueryWrapper);
|
||||
/*2、处理不同类型*/
|
||||
if ("01".equals(memberOrder.getOrderType())) {
|
||||
cardService.dealMemberCard(memberOrder);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user