Compare commits

..

No commits in common. "dbf38c1aa4c303eef5d97e2b109cb42fccec30aa" and "9fcf547417f236078a9f10990aa5b021a744bb63" have entirely different histories.

12 changed files with 49 additions and 147 deletions

View File

@ -68,9 +68,8 @@ public interface ErrorCodeConstants {
ErrorCode CARD_NOT_EXISTS = new ErrorCode(1_004_020_000, "会员卡类型不存在");
ErrorCode MEMBER_USER_NOT_EXISTS = new ErrorCode(1_004_021_000, "会员不存在");
ErrorCode PAID_MEMBER_ORDER_NOT_EXISTS = new ErrorCode(1_004_022_000, "付费会员订单不存在");
ErrorCode PAID_MEMBER_USER_ORDER_NO_NOT_EXISTS = new ErrorCode(1_004_023_000, "生成会员订单号失败,请重新提交");
ErrorCode PAID_MEMBER_USER_NOT_OPEN = new ErrorCode(1_004_021_000, "会员未开通");
ErrorCode PAID_MEMBER_USER_PASSED = new ErrorCode(1_004_021_000, "会员已过期");
}

View File

@ -101,6 +101,4 @@ public class PaidMemberUserSaveReqVO {
@Schema(description = "订单号", requiredMode = Schema.RequiredMode.REQUIRED)
private String orderNo;
@Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED)
private Long payOrderId;
}

View File

@ -41,7 +41,7 @@ public class AppMemberCardTypeController {
List<PaidMemberCardTypeDO> list = cardService.getCardTypeList(memberUserDO.getActivate());
if(name != null){
//根据用户查询是否有有效期会员的类型列表
list = cardService.getCardTypeValidList(memberUserDO.getActivate(),name);
list = cardService.getCardTypeList2(memberUserDO.getActivate(),name);
}
return success(MemberCardTypeConvert.INSTANCE.convertList(list));
}

View File

@ -145,12 +145,6 @@ public class PaidMemberUserDO extends TenantBaseDO {
* 订单号
*/
private String orderNo;
/**
* 支付订单编号
*
* 关联 {@link PayOrderDO#getId()}
*/
private Long payOrderId;
}

View File

@ -68,7 +68,7 @@ public interface PaidMemberCardTypeService {
* @param activate
* @return
*/
List<PaidMemberCardTypeDO> getCardTypeValidList (Integer activate,String name);
List<PaidMemberCardTypeDO> getCardTypeList2 (Integer activate,String name);

View File

@ -91,7 +91,7 @@ public class PaidMemberCardTypeServiceImpl implements PaidMemberCardTypeService
}
@Override
public List<PaidMemberCardTypeDO> getCardTypeValidList(Integer activate,String name) {
public List<PaidMemberCardTypeDO> getCardTypeList2(Integer activate,String name) {
List<PaidMemberCardTypeDO> list = new ArrayList<>();
Integer status = 1;
if (activate == 2){

View File

@ -50,24 +50,12 @@ public interface PaidMemberUserService {
*/
PaidMemberUserDO getMemberUser(Long id);
// /**
// * 判断是否为会员
// */
// PaidMemberUserDO isValidPaidMember(Integer activate,LocalDateTime cardExpirationTime);
int getPriceByTtype(Integer activate, String cardName);
LocalDateTime getDeadLineDay(String cardName);
PaidMemberUserDO getPaidMemberUserByOrderNo(String orderNO);
/**
* 更新会员
*
* @param updateReqVO 更新信息
*/
void update(@Valid PaidMemberUserDO updateReqVO);
// /**
// * 获得会员分页

View File

@ -23,7 +23,6 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.member.dal.mysql.user.PaidMemberUserMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
/**
@ -42,11 +41,12 @@ public class PaidMemberUserServiceImpl implements PaidMemberUserService {
private PaidMemberCardTypeService memberCardTypeService;
@Override
public Long createMemberUser(PaidMemberUserSaveReqVO createReqVO) {
// 插入
PaidMemberUserDO memberUser = BeanUtils.toBean(createReqVO, PaidMemberUserDO.class);
String prefix = String.valueOf('m');
memberUser.setOrderNo(generate(prefix));
if(getPaidMemberUserByOrderNo(memberUser.getOrderNo()) != null){
throw exception(PAID_MEMBER_USER_ORDER_NO_NOT_EXISTS);
}
@ -55,10 +55,10 @@ public class PaidMemberUserServiceImpl implements PaidMemberUserService {
return memberUser.getId();
}
// public String generate(String prefix){
// String no = prefix + DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN);
// return no;
// }
public String generate(String prefix){
String no = prefix + DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN);
return no;
}
@Override
public void updateMemberUser(PaidMemberUserSaveReqVO updateReqVO) {
@ -89,20 +89,6 @@ public class PaidMemberUserServiceImpl implements PaidMemberUserService {
return paidMemberUserMapper.selectById(id);
}
// @Override
// public PaidMemberUserDO isValidPaidMember(Integer activate, LocalDateTime cardExpirationTime) {
// if (activate == 0){
// throw exception(PAID_MEMBER_USER_NOT_OPEN);
// } else if (activate != 0 && cardExpirationTime.isBefore(LocalDateTime.now())) {
// throw exception(PAID_MEMBER_USER_PASSED);
// }else {
// //当前用户为会员
// List<PaidMemberUserDO> list = paidMemberUserMapper.selectList(PaidMemberUserDO::getUid,getLoginUserId(),
// )
// }
// return null;
// }
@Override
public int getPriceByTtype(Integer activate, String cardName) {
int price = 0;
@ -122,19 +108,17 @@ public class PaidMemberUserServiceImpl implements PaidMemberUserService {
public LocalDateTime getDeadLineDay(String cardName) {
LocalDateTime now = LocalDateTime.now();
LocalDateTime deadlineDay;
//判断是否具有过期时间该操作为续费
if (cardName.equals("试用")){
deadlineDay = now.plus(1, ChronoUnit.DAYS);
} else if (cardName.equals("月卡")) {
deadlineDay = now.plus(1,ChronoUnit.MONTHS);
} else if (cardName.equals("季卡")) {
deadlineDay = now.plus(3,ChronoUnit.MONTHS);
} else if (cardName.equals("年卡")) {
deadlineDay = now.plus(1,ChronoUnit.YEARS);
} else {
//永久设置为一个非常远的的日期
deadlineDay = LocalDateTime.of(9999,12,31,23,59,59);
}
if (cardName.equals("试用")){
deadlineDay = now.plus(1, ChronoUnit.DAYS);
} else if (cardName.equals("月卡")) {
deadlineDay = now.plus(1,ChronoUnit.MONTHS);
} else if (cardName.equals("季卡")) {
deadlineDay = now.plus(3,ChronoUnit.MONTHS);
} else if (cardName.equals("年卡")) {
deadlineDay = now.plus(1,ChronoUnit.YEARS);
} else {
deadlineDay = null;
}
return deadlineDay;
}
@ -144,12 +128,6 @@ public class PaidMemberUserServiceImpl implements PaidMemberUserService {
return paidMemberUserDO;
}
@Override
public void update(PaidMemberUserDO updateReqVO) {
// 校验存在
validateMemberUserExists(updateReqVO.getId());
paidMemberUserMapper.updateById(updateReqVO);
}
// @Override
// public PageResult<PaidMemberUserDO> getMemberUserPage(PaidMemberUserPageReqVO pageReqVO) {
// return memberUserMapper.selectPage(pageReqVO);

View File

@ -13,7 +13,6 @@ import cn.iocoder.yudao.module.member.service.membercardtype.PaidMemberCardTypeS
import cn.iocoder.yudao.module.member.service.order.PaidMemberOrderService;
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
import cn.iocoder.yudao.module.member.service.user.PaidMemberUserService;
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
import cn.iocoder.yudao.module.pay.controller.app.member.vo.AppPaidMemberCreateReqVO;
import cn.iocoder.yudao.module.pay.controller.app.member.vo.AppPaidMemberCreateRespVO;
import cn.iocoder.yudao.module.pay.controller.app.member.vo.AppPaidMemeberOrderReqDto;
@ -21,7 +20,6 @@ import cn.iocoder.yudao.module.pay.convert.member.PayMemberOrderConvert;
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO;
import cn.iocoder.yudao.module.pay.service.order.PayOrderService;
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService;
import io.swagger.v3.oas.annotations.Operation;
@ -35,14 +33,11 @@ import javax.annotation.Resource;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.time.Duration;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime;
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
import static cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum.WALLET;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserType;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.MEMBER_USER_NOT_EXISTS;
@ -50,7 +45,6 @@ import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.WALLET_BALANC
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.WALLET_NOT_FOUND;
import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.PAYMENT;
@Tag(name = "用户 APP - 会员支付")
@RestController
@RequestMapping("/pay/member")
@ -58,12 +52,6 @@ import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.PAYM
@Slf4j
public class AppPaidMembeController {
/**
* 会员支付的 no 前缀
* */
private static final String PAID_MEMBER_NO_PREFIX = "M";
private static final String PAID_MEMBER_USER_SUBJECT = "会员支付购卡";
@Resource
private MemberUserService memberUserService;
@ -76,12 +64,6 @@ public class AppPaidMembeController {
@Resource
private PayWalletService payWalletService;
@Resource
private PayNoRedisDAO noRedisDAO;
@Resource
private PayOrderService payOrderService;
@PostMapping("/create")
@Operation(summary = "创建会员支付记录(发起支付)")
public CommonResult<AppPaidMemberCreateRespVO> createcard(@Valid @RequestBody AppPaidMemberCreateReqVO reqVO) {
@ -94,7 +76,6 @@ public class AppPaidMembeController {
PaidMemberUserSaveReqVO paidMemberUserSaveReqVO = new PaidMemberUserSaveReqVO();
//初始化支付金额,单位为分
int price = 0;
Long payOrderId = null;
if(reqVO.getCardName().equals("试用")){
BeanUtils.copyProperties(memberUserDO,paidMemberUserSaveReqVO);
paidMemberUserSaveReqVO.setId(null);
@ -111,8 +92,6 @@ public class AppPaidMembeController {
//获取试用类型的过期时间
LocalDateTime cardExpirationTime = paidMemberUserService.getDeadLineDay(reqVO.getCardName());
paidMemberUserSaveReqVO.setCardExpirationTime(cardExpirationTime);
//设置会员订单号
paidMemberUserSaveReqVO.setOrderNo(noRedisDAO.generate(PAID_MEMBER_NO_PREFIX));
//新增会员订单记录
Long id = paidMemberUserService.createMemberUser(paidMemberUserSaveReqVO);
//查询新增的会员订单记录
@ -131,69 +110,37 @@ public class AppPaidMembeController {
String deadlineDay = memberCardService.selectByName(reqVO.getCardName()).getVid();
paidMemberUserSaveReqVO.setDeadlineDay(deadlineDay);
paidMemberUserSaveReqVO.setPrice(price);
//设置会员订单号
paidMemberUserSaveReqVO.setOrderNo(noRedisDAO.generate(PAID_MEMBER_NO_PREFIX));
paidMemberUserSaveReqVO.setPayType("钱包支付");
//新增会员订单记录
Long id = paidMemberUserService.createMemberUser(paidMemberUserSaveReqVO);
//查询新增的会员订单记录
paidMemberUserDO = paidMemberUserService.getMemberUser(id);
// 创建支付订单号
payOrderId = payOrderService.createOrder(new PayOrderCreateReqDTO()
.setAppId(1L).setUserIp(getClientIP())
.setMerchantOrderId(""+paidMemberUserDO.getId())
.setSubject(PAID_MEMBER_USER_SUBJECT).setBody("")
.setPrice(paidMemberUserDO.getPrice())
.setExpireTime(addTime(Duration.ofHours(2L)))); // TODO @芋艿支付超时时间
paidMemberUserDO.setPayOrderId(payOrderId);
//跟新支付订单号进付费会员表里
paidMemberUserService.update(paidMemberUserDO);
}
return success(PayMemberOrderConvert.INSTANCE.convert(paidMemberUserDO.getId(),payOrderId
return success(PayMemberOrderConvert.INSTANCE.convert(paidMemberUserDO.getId(),paidMemberUserDO.getOrderNo()
,paidMemberUserDO.getCardExpirationTime(),memberUserDO.getActivate()));
}
@PostMapping("/update")
@Operation(summary = "更新会员订单未支付为已支付") // pay-module 支付服务进行回调可见 PayNotifyJob
public CommonResult<Boolean> updatePaidMemberUser(@Valid @RequestBody AppPaidMemeberOrderReqDto notifyReqDTO){
//获取当前登录用户信息,并判断用户是否为会员
MemberUserDO memberUserDO = memberUserService.getUser(getLoginUserId());
//获取订单记录
PaidMemberUserDO paidMemberUserDO = paidMemberUserService.getMemberUser(notifyReqDTO.getId());
// 获取当前用户钱包信息
PayWalletDO walletDO = payWalletService.getOrCreateWallet(WebFrameworkUtils.getLoginUserId(),getLoginUserType());
// 扣减钱包余额
payWalletService.reduceWalletBalance
(walletDO.getId(),notifyReqDTO.getId(),PAYMENT,paidMemberUserDO.getPrice());
//获取支付时间
LocalDateTime payTime = LocalDateTime.now();
paidMemberUserDO.setPayTime(payTime);
//更新会员订单支付状态为已支付
paidMemberUserDO.setPaid(true);
//获取试用类型的过期时间
LocalDateTime cardExpirationTime = paidMemberUserService.getDeadLineDay(notifyReqDTO.getCardName());
paidMemberUserDO.setCardExpirationTime(cardExpirationTime);
paidMemberUserDO.setPayChannel(notifyReqDTO.getPayChannel());
if (notifyReqDTO.getPayChannel().equals("wallet")){
paidMemberUserDO.setPayType("余额");
} else if(notifyReqDTO.getPayChannel().startsWith("wx")){
paidMemberUserDO.setPayType("微信");
} else if (notifyReqDTO.getPayChannel().startsWith("alipay")) {
paidMemberUserDO.setPayType("支付宝");
} else {
paidMemberUserDO.setPayType("模拟支付");
}
//更新会员订单
paidMemberUserService.update(paidMemberUserDO);
//设置个人信息的会员状态0未开通1试用2有效期3永久
if(notifyReqDTO.getCardName().equals("永久")){
memberUserDO.setActivate(3);
}else {
memberUserDO.setActivate(2);
}
//更新用户会员状态
memberUserService.updateUserDo(memberUserDO);
return success(true);
}
// @PostMapping("/update")
// @Operation(summary = "更新会员订单未支付为已支付") // pay-module 支付服务进行回调可见 PayNotifyJob
// public CommonResult<Boolean> updatePaidMemberUser(@Valid @RequestBody AppPaidMemeberOrderReqDto notifyReqDTO){
// //获取订单记录
// PaidMemberUserDO paidMemberUserDO = paidMemberUserService.getMemberUser(notifyReqDTO.getId());
//// 校验钱包充值是否可以支付
// PayWalletDO walletDO = payWalletService.getOrCreateWallet(WebFrameworkUtils.getLoginUserId(),getLoginUserType());
// if(walletDO.getBalance()<paidMemberUserDO.getPrice()){
// log.error("[updatePaidMemberOrder]updateReqVO({}) 钱包余额不足.");
// throw exception(WALLET_BALANCE_NOT_ENOUGH);
// }
//// 扣减钱包余额
// PayWalletTransactionDO payWalletTransactionDO = payWalletService.reduceWalletBalance
// (walletDO.getId(),notifyReqDTO.getPayOrderId(),PAYMENT,price);
//
//// //更新订单支付状态为已支付
//// paidMemberOrderDO.setPaid(true);
//// paidMemberOrderDO.setPayChannel(payOrderDO.getChannelCode());
//// paidMemberOrderService1.updateOrder(paidMemberOrderDO);
// return success(true);
// }
}

View File

@ -15,11 +15,11 @@ public class AppPaidMemberCreateRespVO {
@Schema(description = "会员支付编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long id;
@Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "o100")
private Long payOrderId;
// @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "o100")
// private Long payOrderId;
// @Schema(description = "会员订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "m100")
// private String orderNo;
@Schema(description = "会员订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "m100")
private String orderNo;
@Schema(description = "到期时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-11-22 09:30:05")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)

View File

@ -22,8 +22,6 @@ public class AppPaidMemeberOrderReqDto {
@Schema(description = "会员支付编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long id;
@Schema(description = "会员卡名称", example = "试用")
private String cardName;
@Schema(description = "支付渠道", example = "公众号,mini-小程序h5-网页支付,wechatIos-微信IoswechatAndroid-微信Android,alipay-支付包alipayApp-支付宝App,give-平台赠送")
private String payChannel;

View File

@ -13,5 +13,5 @@ public interface PayMemberOrderConvert {
PayMemberOrderConvert INSTANCE = Mappers.getMapper(PayMemberOrderConvert.class);
AppPaidMemberCreateRespVO convert(Long id, Long payOrderId, LocalDateTime cardExpirationTime, Integer activate);
AppPaidMemberCreateRespVO convert(Long id, String orderNo, LocalDateTime cardExpirationTime, Integer activate);
}