diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/order/PaidMemberOrderController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/order/PaidMemberOrderController.java index 3dcf866..ea85d49 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/order/PaidMemberOrderController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/order/PaidMemberOrderController.java @@ -41,7 +41,7 @@ public class PaidMemberOrderController { @PostMapping("/create") @Operation(summary = "创建付费会员订单") @PreAuthorize("@ss.hasPermission('member:paid-member-order:create')") - public CommonResult createPaidMemberOrder(@Valid @RequestBody PaidMemberOrderSaveReqVO createReqVO) { + public CommonResult createPaidMemberOrder(@Valid @RequestBody PaidMemberOrderSaveReqVO createReqVO) { return success(paidMemberOrderService.createPaidMemberOrder(createReqVO)); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/type/AppMemberCardTypeController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/type/AppMemberCardTypeController.java index d009e45..907f4d1 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/type/AppMemberCardTypeController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/type/AppMemberCardTypeController.java @@ -34,11 +34,15 @@ public class AppMemberCardTypeController { @GetMapping("/list") @Operation(summary = "获得会员卡类型列表") - public CommonResult> list() { + public CommonResult> list(@RequestParam(value = "name", required = false) String name) { /** 查询状态为启用的会员卡类型列表 */ MemberUserDO memberUserDO = userService.getUser(getLoginUserId()); /** 根据用户查询是否有试用会员的类型列表 */ List list = cardService.getCardTypeList(memberUserDO.getActivate()); + if(!name.isEmpty()){ + //根据用户查询是否有有效期会员的类型列表 + list = cardService.getCardTypeList2(memberUserDO.getActivate(),name); + } return success(MemberCardTypeConvert.INSTANCE.convertList(list)); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/order/PaidMemberOrderDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/order/PaidMemberOrderDO.java index 7d6005f..2a1054a 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/order/PaidMemberOrderDO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/order/PaidMemberOrderDO.java @@ -32,7 +32,7 @@ public class PaidMemberOrderDO extends TenantBaseDO { * 编号 */ @TableId - private Integer id; + private Long id; /** * 用户UID */ diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/membercardtype/PaidMemberCardTypeMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/membercardtype/PaidMemberCardTypeMapper.java index 963f291..6ec9dbe 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/membercardtype/PaidMemberCardTypeMapper.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/membercardtype/PaidMemberCardTypeMapper.java @@ -38,4 +38,7 @@ public interface PaidMemberCardTypeMapper extends BaseMapperX getCardTypeList (Integer activate); + /** + * 根据用户是否使用有效期会员 + * 查询会员类型列表 + * @param activate + * @return + */ + List getCardTypeList2 (Integer activate,String name); + + /** * 根据会员卡名查询 diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/membercardtype/PaidMemberCardTypeServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/membercardtype/PaidMemberCardTypeServiceImpl.java index 4f7fa3c..273370c 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/membercardtype/PaidMemberCardTypeServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/membercardtype/PaidMemberCardTypeServiceImpl.java @@ -92,6 +92,20 @@ public class PaidMemberCardTypeServiceImpl implements PaidMemberCardTypeService return list; } + @Override + public List getCardTypeList2(Integer activate,String name) { + List list = new ArrayList<>(); + Integer status = 1; + if (activate == 2){ + list = cardMapper.selectList(new LambdaQueryWrapperX() + .eqIfPresent(PaidMemberCardTypeDO::getStatus,status) + .neIfPresent(PaidMemberCardTypeDO::getName,name) + .neIfPresent(PaidMemberCardTypeDO::getName,"试用") + .orderByAsc(PaidMemberCardTypeDO::getId)); + } + return list; + } + @Override public PaidMemberCardTypeDO selectByName(String cardName) { diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/order/PaidMemberOrderService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/order/PaidMemberOrderService.java index 62c9384..be1e653 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/order/PaidMemberOrderService.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/order/PaidMemberOrderService.java @@ -23,7 +23,7 @@ public interface PaidMemberOrderService { * @param createReqVO 创建信息 * @return 编号 */ - Integer createPaidMemberOrder(@Valid PaidMemberOrderSaveReqVO createReqVO); + Long createPaidMemberOrder(@Valid PaidMemberOrderSaveReqVO createReqVO); /** * 更新付费会员订单 diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/order/PaidMemberOrderServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/order/PaidMemberOrderServiceImpl.java index 7312a9d..16d56d5 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/order/PaidMemberOrderServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/order/PaidMemberOrderServiceImpl.java @@ -46,7 +46,7 @@ public class PaidMemberOrderServiceImpl implements PaidMemberOrderService { private PaidMemberUserService paidMemberUserService; @Override - public Integer createPaidMemberOrder(PaidMemberOrderSaveReqVO createReqVO) { + public Long createPaidMemberOrder(PaidMemberOrderSaveReqVO createReqVO) { // 插入 PaidMemberOrderDO paidMemberOrder = BeanUtils.toBean(createReqVO, PaidMemberOrderDO.class); paidMemberOrderMapper.insert(paidMemberOrder); diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/member/AppPaidMembeOrderController.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/member/AppPaidMembeOrderController.java index 3f14799..97abc0b 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/member/AppPaidMembeOrderController.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/member/AppPaidMembeOrderController.java @@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; //import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; import cn.iocoder.yudao.module.member.controller.admin.user.vo.PaidMemberUserSaveReqVO; import cn.iocoder.yudao.module.member.convert.order.PaidMemberOrderConvert; import cn.iocoder.yudao.module.member.dal.dataobject.order.PaidMemberOrderDO; @@ -14,10 +15,13 @@ 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.notify.dto.PayOrderNotifyReqDTO; import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; import cn.iocoder.yudao.module.pay.controller.app.member.vo.AppPaidMemberOrderReqVO; import cn.iocoder.yudao.module.pay.controller.app.member.vo.AppPaidMemberOrderRespVO; +import cn.iocoder.yudao.module.pay.controller.app.member.vo.AppPaidMemeberOrderReqDto; 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.service.order.PayOrderService; @@ -30,17 +34,23 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.annotation.security.PermitAll; 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.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.PAID_MEMBER_ORDER_NOT_EXISTS; +import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.WALLET_BALANCE_NOT_ENOUGH; +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 @@ -67,6 +77,9 @@ public class AppPaidMembeOrderController { @Resource private PaidMemberCardTypeService cardService; + @Resource + private PayWalletService payWalletService; + @PostMapping("/create") @Operation(summary = "创建会员支付记录(发起支付)") @@ -112,7 +125,7 @@ public class AppPaidMembeOrderController { // PayWalletDO walletDO = memberWalletService.getOrCreateWallet(getLoginUserId(),getLoginUserType()); //订单对象赋值 PaidMemberOrderDO paidMemberOrderDO = PaidMemberOrderConvert.INSTANCE.convert(getLoginUserId(), - reqVO.getCardName(),reqVO.getType(),reqVO.getPrice(),payTime,deadlineDay,cardExpirationTime,originalPrice); + reqVO.getCardName(),reqVO.getType(),payPrice,payTime,deadlineDay,cardExpirationTime,originalPrice); paidMemberOrderService1.createOrder(paidMemberOrderDO); Long payOrderId = payOrderService01.createOrder(new PayOrderCreateReqDTO() .setAppId(1L).setUserIp(getClientIP()) @@ -123,6 +136,41 @@ public class AppPaidMembeOrderController { paidMemberOrderDO.setPayOrderId(payOrderId); userService1.updateUserDo(memberUserDO); paidMemberOrderService1.updateOrder(paidMemberOrderDO); - return success(PayMemberOrderConvert.INSTANCE.convert(paidMemberOrderDO)); + return success(PayMemberOrderConvert.INSTANCE.convert(paidMemberOrderDO.getId(),paidMemberOrderDO.getPayOrderId() + ,paidMemberOrderDO.getCardExpirationTime(),memberUserDO.getActivate())); } + + @PostMapping("/update") + @Operation(summary = "更新会员订单未支付为已支付") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob + public CommonResult updatePaidMemberOrder(@Valid @RequestBody AppPaidMemeberOrderReqDto notifyReqDTO){ + //获取订单记录 + PaidMemberOrderDO paidMemberOrderDO = paidMemberOrderService1.getPaidMemeberOrder(Long.valueOf(notifyReqDTO.getMerchantOrderId())); + if(paidMemberOrderDO == null){ + log.error("[updatePaidMemberOrder],updateReqVO({}) 付费会员订单不存在."); + throw exception(PAID_MEMBER_ORDER_NOT_EXISTS); + } + BigDecimal decimalprice = paidMemberOrderDO.getPrice(); + Integer price = decimalprice.multiply(new BigDecimal("100")).intValue(); +// 校验钱包充值是否可以支付 + PayWalletDO walletDO = payWalletService.getOrCreateWallet(WebFrameworkUtils.getLoginUserId(),getLoginUserType()); + if(walletDO == null){ + log.error("[updatePaidMemberOrder],updateReqVO({}) 用户钱包不存在."); + throw exception(WALLET_NOT_FOUND); + } + if(walletDO.getBalance()