Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
d60d77e4d4
@ -1,6 +1,7 @@
|
||||
package com.ruoyi.base.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.base.domain.BaseCardRights;
|
||||
@ -11,24 +12,34 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 会员卡权益Mapper接口
|
||||
*
|
||||
*
|
||||
* @author vinjor-m
|
||||
* @date 2025-03-17
|
||||
*/
|
||||
@Mapper
|
||||
public interface BaseCardRightsMapper extends BaseMapper<BaseCardRights>
|
||||
{
|
||||
public interface BaseCardRightsMapper extends BaseMapper<BaseCardRights> {
|
||||
IPage<BaseCardRights> queryListPage(@Param("entity") BaseCardRights entity, Page<BaseCardRights> page);
|
||||
|
||||
/**
|
||||
* 查询会员卡权益
|
||||
*
|
||||
* @param cardId 会员卡id
|
||||
* @param userType 用户类型
|
||||
* @return java.util.List<com.ruoyi.base.domain.BaseCardRights>
|
||||
* @author vinjor-M
|
||||
* @date 15:24 2025/3/18
|
||||
* @param cardId 会员卡id
|
||||
* @param userType 用户类型
|
||||
* @return java.util.List<com.ruoyi.base.domain.BaseCardRights>
|
||||
**/
|
||||
**/
|
||||
List<CardRightsVO> getByIdAndType(@Param("cardId") String cardId, @Param("userType") String userType);
|
||||
|
||||
int removeByCardId(@Param("cardId") String cardId);
|
||||
|
||||
/**
|
||||
* 通过会员卡id查询会员卡权益
|
||||
*
|
||||
* @param cardId 会员卡id
|
||||
* @return java.util.List<com.ruoyi.base.vo.CardRightsVO>
|
||||
* @author PQZ
|
||||
* @date 10:36 2025/3/27
|
||||
**/
|
||||
List<CardRightsVO> queryByCardId(@Param("cardId") String cardId);
|
||||
}
|
||||
|
@ -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<CardRightsVO> 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,17 @@ 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<CardRightsVO> queryByCardId(String cardId) {
|
||||
return baseCardRightsMapper.queryByCardId(cardId);
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,22 @@
|
||||
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 com.ruoyi.base.vo.CardRightsVO;
|
||||
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 +29,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<CardRightsVO> 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<CardRightsVO> rights;
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package com.ruoyi.base.vo;
|
||||
|
||||
import com.ruoyi.base.domain.BaseCardRights;
|
||||
import com.ruoyi.base.domain.BaseRights;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出订单列表
|
||||
|
@ -29,7 +29,7 @@ public class MemberCoupon extends DlBaseEntity
|
||||
private String id;
|
||||
|
||||
/** 用户id */
|
||||
private String userId;
|
||||
private Long userId;
|
||||
|
||||
/** 类型(1-增加|2-扣减) */
|
||||
@Excel(name = "类型", readConverterExp = "1=-增加|2-扣减")
|
||||
@ -44,7 +44,7 @@ public class MemberCoupon extends DlBaseEntity
|
||||
|
||||
/** 剩余 */
|
||||
@Excel(name = "剩余")
|
||||
private Long balance;
|
||||
private Integer balance;
|
||||
|
||||
/** 备注 */
|
||||
@Excel(name = "备注")
|
||||
|
@ -59,6 +59,10 @@ public class MemberOrder extends DlBaseEntity
|
||||
@Excel(name = "商品数量")
|
||||
private Integer goodsNum;
|
||||
|
||||
/** 商品服务周期 */
|
||||
@Excel(name = "商品服务周期")
|
||||
private String goodsCycle;
|
||||
|
||||
/** 订单总价 */
|
||||
@Excel(name = "订单总价")
|
||||
private BigDecimal goodsPrice;
|
||||
|
@ -30,7 +30,7 @@ public class MemberRights extends DlBaseEntity
|
||||
|
||||
/** 用户id */
|
||||
@Excel(name = "用户id")
|
||||
private String userId;
|
||||
private Long userId;
|
||||
|
||||
/** 用户类型(数据字典:dl_user_type) */
|
||||
@Excel(name = "用户类型", readConverterExp = "数=据字典:dl_user_type")
|
||||
@ -54,10 +54,10 @@ public class MemberRights extends DlBaseEntity
|
||||
|
||||
/** 权益值(权益类型为是否时:0代表不支持,1代表支持;权益类型为数量限制时:0代表不限制,其他数字代表具体限制数量) */
|
||||
@Excel(name = "权益值(权益类型为是否时:0代表不支持,1代表支持;权益类型为数量限制时:0代表不限制,其他数字代表具体限制数量)")
|
||||
private Long rightsValue;
|
||||
private Integer rightsValue;
|
||||
|
||||
/** 剩余值 */
|
||||
@Excel(name = "剩余值")
|
||||
private Long remaining;
|
||||
private Integer remaining;
|
||||
|
||||
}
|
||||
|
@ -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 com.ruoyi.member.domain.MemberRights;
|
||||
import com.ruoyi.member.vo.MemberRightsVO;
|
||||
import com.ruoyi.member.vo.ViewRightsVO;
|
||||
@ -25,7 +26,16 @@ 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);
|
||||
|
||||
/**
|
||||
* 查当前会员权益列表
|
||||
|
@ -1,16 +1,34 @@
|
||||
package com.ruoyi.member.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.member.domain.MemberCoupon;
|
||||
import com.ruoyi.member.domain.MemberOrder;
|
||||
|
||||
/**
|
||||
* 用户通告券变动记录Service接口
|
||||
*
|
||||
*
|
||||
* @author vinjor-m
|
||||
* @date 2025-03-17
|
||||
*/
|
||||
public interface IMemberCouponService extends IService<MemberCoupon>
|
||||
{
|
||||
public interface IMemberCouponService extends IService<MemberCoupon> {
|
||||
|
||||
/**
|
||||
* @param order 订单
|
||||
* @author PQZ
|
||||
* @date 15:02 2025/3/28
|
||||
**/
|
||||
void dealMemberCoupon(MemberOrder order);
|
||||
|
||||
/**
|
||||
* 保存通告券变动记录
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param type 变动类型(1增加2减少)
|
||||
* @param noticeId 通告id
|
||||
* @param couponNum 变动数量
|
||||
* @author PQZ
|
||||
* @date 15:19 2025/3/28
|
||||
**/
|
||||
void saveCoupon(Long userId, String type, String noticeId, Integer couponNum);
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -1,16 +1,27 @@
|
||||
package com.ruoyi.member.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.base.vo.CardRightsVO;
|
||||
import com.ruoyi.member.domain.MemberCard;
|
||||
import com.ruoyi.member.domain.MemberRights;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会员权益(定时任务重置剩余值),用户id、会员卡id、权益对应1Service接口
|
||||
*
|
||||
*
|
||||
* @author pqz
|
||||
* @date 2025-03-17
|
||||
*/
|
||||
public interface IMemberRightsService extends IService<MemberRights>
|
||||
{
|
||||
public interface IMemberRightsService extends IService<MemberRights> {
|
||||
|
||||
/**
|
||||
* 处理会员权益
|
||||
*
|
||||
* @param userId 用户表id
|
||||
* @param rights 权益
|
||||
* @author PQZ
|
||||
* @date 15:45 2025/3/27
|
||||
**/
|
||||
void dealRights(Long userId, String userType,List<CardRightsVO> rights);
|
||||
}
|
||||
|
@ -1,36 +1,49 @@
|
||||
package com.ruoyi.member.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.common.utils.SecurityUtils;
|
||||
import com.ruoyi.constant.DictConstants;
|
||||
import com.ruoyi.member.domain.MemberCard;
|
||||
import com.ruoyi.member.domain.MemberOrder;
|
||||
import com.ruoyi.member.domain.MemberRights;
|
||||
import com.ruoyi.member.mapper.MemberCardMapper;
|
||||
import com.ruoyi.member.mapper.MemberRightsMapper;
|
||||
import com.ruoyi.member.service.IMemberCardService;
|
||||
import com.ruoyi.member.service.IMemberRightsService;
|
||||
import com.ruoyi.member.vo.MemberRightsVO;
|
||||
import com.ruoyi.member.vo.ViewRightsVO;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
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;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 会员开卡记录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;
|
||||
@Autowired
|
||||
private IMemberRightsService rightsService;
|
||||
@Autowired
|
||||
private MemberRightsMapper memberRightsMapper;
|
||||
|
||||
@ -44,17 +57,108 @@ 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());
|
||||
//查询当前时间是否存在有效会员卡
|
||||
List<MemberCard> cardList = checkMemberCard(order.getGoodsId(), order.getUserId());
|
||||
|
||||
/*2、计算到期时间*/
|
||||
Date startTime;
|
||||
Date endTime;
|
||||
if (cardList.isEmpty()){
|
||||
//计算到期时间
|
||||
startTime = new Date();
|
||||
endTime = getEndTime(startTime, order.getGoodsCycle());
|
||||
//新增时需要处理会员权益
|
||||
rightsService.dealRights(order.getUserId(),order.getUserType(),card.getRights());
|
||||
} else {
|
||||
startTime = cardList.get(0).getEndDate();
|
||||
endTime = getEndTime(startTime,order.getGoodsCycle());
|
||||
}
|
||||
|
||||
/*3、保存会员开卡记录*/
|
||||
//初始化会员开通记录
|
||||
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);
|
||||
save(memberCard);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询会员卡开卡记录
|
||||
*
|
||||
* @param cardId 卡id
|
||||
* @param userId 用户id
|
||||
* @return java.util.List<com.ruoyi.member.domain.MemberCard>
|
||||
* @author PQZ
|
||||
* @date 16:09 2025/3/27
|
||||
**/
|
||||
private List<MemberCard> checkMemberCard(String cardId, Long userId) {
|
||||
Date time = new Date();
|
||||
LambdaQueryWrapper<MemberCard> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper
|
||||
.eq(MemberCard::getCardId, cardId)
|
||||
.eq(MemberCard::getUserId, userId)
|
||||
.eq(DlBaseEntity::getDelFlag, 0)
|
||||
.lt(MemberCard::getStartDate, time)
|
||||
.ge(MemberCard::getEndDate, time);
|
||||
return list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员结束时间
|
||||
*
|
||||
* @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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查当前会员权益列表
|
||||
*
|
||||
@ -64,50 +168,49 @@ public class MemberCardServiceImpl extends ServiceImpl<MemberCardMapper,MemberCa
|
||||
* @date 11:26 2025/3/26
|
||||
**/
|
||||
@Override
|
||||
public Map<String, Map<String,ViewRightsVO>> selectMemberRights(Long userId, String userType) {
|
||||
Map<String, Map<String,ViewRightsVO>> rtnMap = new HashMap<>();
|
||||
public Map<String, Map<String, ViewRightsVO>> selectMemberRights(Long userId, String userType) {
|
||||
Map<String, Map<String, ViewRightsVO>> rtnMap = new HashMap<>();
|
||||
//当前时间
|
||||
String nowDate = DateUtil.formatDate(new Date());
|
||||
if(null==userId){
|
||||
if (null == userId) {
|
||||
userId = SecurityUtils.getUserId();
|
||||
}
|
||||
List<MemberCard> cardList = memberCardMapper.selectCardIdByUserId(userId,userType,nowDate);
|
||||
if(cardList.isEmpty()){
|
||||
List<MemberCard> cardList = memberCardMapper.selectCardIdByUserId(userId, userType, nowDate);
|
||||
if (cardList.isEmpty()) {
|
||||
//未开通任何会员卡
|
||||
rtnMap.put("tgz",new HashMap<>());
|
||||
rtnMap.put("bz",new HashMap<>());
|
||||
}else{
|
||||
rtnMap.put("tgz", new HashMap<>());
|
||||
rtnMap.put("bz", new HashMap<>());
|
||||
} else {
|
||||
//开通会员卡了,根据会员卡id,查询出所有权益
|
||||
List<MemberRights> memberRightsList = memberRightsMapper.selectUserRightsByCardIds(cardList.stream().map(MemberCard::getCardId).collect(Collectors.toList()), userId);
|
||||
//通告主权益
|
||||
Map<String,ViewRightsVO> tgzRightsMap = new HashMap<>();
|
||||
Map<String, ViewRightsVO> tgzRightsMap = new HashMap<>();
|
||||
//博主权益
|
||||
Map<String,ViewRightsVO> bzRightsMap = new HashMap<>();
|
||||
Map<String, ViewRightsVO> bzRightsMap = new HashMap<>();
|
||||
memberRightsList.forEach(item -> {
|
||||
if (DictConstants.USER_TYPE_TGZ.equals(item.getUserType())) {
|
||||
//通告主
|
||||
this.checkRights(tgzRightsMap,item);
|
||||
this.checkRights(tgzRightsMap, item);
|
||||
} else if (DictConstants.USER_TYPE_BZ.equals(item.getUserType())) {
|
||||
//博主
|
||||
this.checkRights(bzRightsMap,item);
|
||||
this.checkRights(bzRightsMap, item);
|
||||
}
|
||||
});
|
||||
rtnMap.put("tgz",tgzRightsMap);
|
||||
rtnMap.put("bz",bzRightsMap);
|
||||
rtnMap.put("tgz", tgzRightsMap);
|
||||
rtnMap.put("bz", bzRightsMap);
|
||||
}
|
||||
return rtnMap;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param memberRightsMap 会员权益map
|
||||
* @param item 这个权益
|
||||
* @author vinjor-M
|
||||
* @date 14:19 2025/3/26
|
||||
* @param memberRightsMap 会员权益map
|
||||
* @param item 这个权益
|
||||
**/
|
||||
private void checkRights(Map<String, ViewRightsVO> memberRightsMap, MemberRights item){
|
||||
**/
|
||||
private void checkRights(Map<String, ViewRightsVO> memberRightsMap, MemberRights item) {
|
||||
ViewRightsVO newRights = new ViewRightsVO();
|
||||
BeanUtils.copyProperties(item,newRights);
|
||||
BeanUtils.copyProperties(item, newRights);
|
||||
if (memberRightsMap.containsKey(item.getRightsCode())) {
|
||||
//有这个权益了
|
||||
ViewRightsVO oldRights = memberRightsMap.get(item.getRightsCode());
|
||||
|
@ -1,13 +1,18 @@
|
||||
package com.ruoyi.member.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.base.domain.BaseCoupon;
|
||||
import com.ruoyi.base.service.IBaseCouponService;
|
||||
import com.ruoyi.common.core.domain.DlBaseEntity;
|
||||
import com.ruoyi.member.domain.MemberCoupon;
|
||||
import com.ruoyi.member.domain.MemberOrder;
|
||||
import com.ruoyi.member.mapper.MemberCouponMapper;
|
||||
import com.ruoyi.member.service.IMemberCouponService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.member.mapper.MemberCouponMapper;
|
||||
import com.ruoyi.member.domain.MemberCoupon;
|
||||
import com.ruoyi.member.service.IMemberCouponService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户通告券变动记录Service业务层处理
|
||||
@ -20,6 +25,62 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper,Memb
|
||||
{
|
||||
@Autowired
|
||||
private MemberCouponMapper memberCouponMapper;
|
||||
@Autowired
|
||||
private IBaseCouponService baseCouponService;
|
||||
|
||||
|
||||
/**
|
||||
* @param order 订单
|
||||
* @author PQZ
|
||||
* @date 15:02 2025/3/28
|
||||
**/
|
||||
@Override
|
||||
public void dealMemberCoupon(MemberOrder order) {
|
||||
BaseCoupon coupon = baseCouponService.getById(order.getGoodsId());
|
||||
saveCoupon(order.getUserId(), "2",null,coupon.getCouponNum());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存通告券变动记录
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param type 变动类型(1增加2减少)
|
||||
* @param noticeId 通告id
|
||||
* @param couponNum 变动数量
|
||||
* @author PQZ
|
||||
* @date 15:19 2025/3/28
|
||||
**/
|
||||
@Override
|
||||
public void saveCoupon(Long userId, String type, String noticeId, Integer couponNum) {
|
||||
//查询当前用户最新变动记录
|
||||
LambdaQueryWrapper<MemberCoupon> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper
|
||||
.eq(MemberCoupon::getUserId,userId)
|
||||
.eq(DlBaseEntity::getDelFlag,0)
|
||||
.orderByDesc(DlBaseEntity::getCreateTime);
|
||||
List<MemberCoupon> list = list(lambdaQueryWrapper);
|
||||
MemberCoupon memberCoupon = new MemberCoupon();
|
||||
memberCoupon.setUserId(userId);
|
||||
memberCoupon.setType(type);
|
||||
memberCoupon.setNoticeId(noticeId);
|
||||
memberCoupon.setCouponNum(couponNum);
|
||||
//如果无记录则为初始新增
|
||||
if (list.isEmpty()) {
|
||||
memberCoupon.setBalance(couponNum);
|
||||
} else {
|
||||
//如果有记录则取最新记录中的剩余值进行计算后得出新值
|
||||
Integer oldBalance = list.get(0).getBalance();
|
||||
Integer newBalance;
|
||||
if ("1".equals(type)) {
|
||||
newBalance = oldBalance + couponNum;
|
||||
} else {
|
||||
newBalance = oldBalance - couponNum;
|
||||
}
|
||||
memberCoupon.setBalance(newBalance);
|
||||
}
|
||||
save(memberCoupon);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,24 @@
|
||||
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.IMemberCouponService;
|
||||
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;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 订单Service业务层处理
|
||||
@ -21,6 +31,10 @@ public class MemberOrderServiceImpl extends ServiceImpl<MemberOrderMapper,Member
|
||||
{
|
||||
@Autowired
|
||||
private MemberOrderMapper memberOrderMapper;
|
||||
@Resource
|
||||
private IMemberCardService cardService;
|
||||
@Resource
|
||||
private IMemberCouponService couponService;
|
||||
|
||||
|
||||
/**
|
||||
@ -36,4 +50,33 @@ 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 {
|
||||
couponService.dealMemberCoupon(memberOrder);
|
||||
}
|
||||
/*3、处理订单表数据*/
|
||||
memberOrder.setPayTime(new Date());
|
||||
memberOrder.setIsPay(1);
|
||||
memberOrder.setPayWay("02");
|
||||
updateById(memberOrder);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,25 +1,52 @@
|
||||
package com.ruoyi.member.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.base.vo.CardRightsVO;
|
||||
import com.ruoyi.member.domain.MemberCard;
|
||||
import com.ruoyi.member.domain.MemberRights;
|
||||
import com.ruoyi.member.mapper.MemberRightsMapper;
|
||||
import com.ruoyi.member.service.IMemberRightsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.member.mapper.MemberRightsMapper;
|
||||
import com.ruoyi.member.domain.MemberRights;
|
||||
import com.ruoyi.member.service.IMemberRightsService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会员权益(定时任务重置剩余值),用户id、会员卡id、权益对应1Service业务层处理
|
||||
*
|
||||
*
|
||||
* @author pqz
|
||||
* @date 2025-03-17
|
||||
*/
|
||||
@Service
|
||||
public class MemberRightsServiceImpl extends ServiceImpl<MemberRightsMapper,MemberRights> implements IMemberRightsService
|
||||
{
|
||||
public class MemberRightsServiceImpl extends ServiceImpl<MemberRightsMapper, MemberRights> implements IMemberRightsService {
|
||||
@Autowired
|
||||
private MemberRightsMapper memberRightsMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 处理会员权益
|
||||
*
|
||||
* @param userId 用户表id
|
||||
* @param rights 权益
|
||||
* @author PQZ
|
||||
* @date 15:45 2025/3/27
|
||||
**/
|
||||
@Override
|
||||
public void dealRights(Long userId, String userType, List<CardRightsVO> rights) {
|
||||
List<MemberRights> saveList = new ArrayList<>();
|
||||
rights.forEach(item -> {
|
||||
MemberRights memberRights = new MemberRights();
|
||||
memberRights.setUserId(userId);
|
||||
memberRights.setUserType(userType);
|
||||
memberRights.setCardId(item.getCardId());
|
||||
memberRights.setRightsCode(item.getCode());
|
||||
memberRights.setRightsType(item.getRightsType());
|
||||
memberRights.setRightsCycle(item.getRightsCycle());
|
||||
memberRights.setRightsValue(item.getRightsValue());
|
||||
memberRights.setRemaining(item.getRightsValue());
|
||||
saveList.add(memberRights);
|
||||
});
|
||||
saveBatch(saveList);
|
||||
}
|
||||
}
|
||||
|
@ -48,5 +48,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND dbr.id IS NOT NULL
|
||||
ORDER BY dbr.sort,dbr.create_time
|
||||
</select>
|
||||
<select id="queryByCardId" resultType="com.ruoyi.base.vo.CardRightsVO">
|
||||
SELECT
|
||||
dbr.*,
|
||||
dbcr.card_id,
|
||||
dbcr.rights_value
|
||||
FROM
|
||||
dl_base_rights dbr
|
||||
LEFT JOIN dl_base_card_rights dbcr ON dbr.id = dbcr.rights_id
|
||||
AND dbcr.del_flag = 0
|
||||
WHERE
|
||||
dbr.del_flag = 0
|
||||
AND dbcr.card_id = #{cardId}
|
||||
ORDER BY dbr.sort,dbr.create_time
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -49,5 +49,6 @@
|
||||
<if test="entity.isPay != null "> and is_pay = #{entity.isPay}</if>
|
||||
<if test="entity.isRefund != null "> and is_refund = #{entity.isRefund}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user