Merge pull request '修改支付状态' (#60) from khy1 into master
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #60
This commit is contained in:
commit
5177793676
@ -41,7 +41,7 @@ public class PaidMemberOrderController {
|
|||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建付费会员订单")
|
@Operation(summary = "创建付费会员订单")
|
||||||
@PreAuthorize("@ss.hasPermission('member:paid-member-order:create')")
|
@PreAuthorize("@ss.hasPermission('member:paid-member-order:create')")
|
||||||
public CommonResult<Integer> createPaidMemberOrder(@Valid @RequestBody PaidMemberOrderSaveReqVO createReqVO) {
|
public CommonResult<Long> createPaidMemberOrder(@Valid @RequestBody PaidMemberOrderSaveReqVO createReqVO) {
|
||||||
return success(paidMemberOrderService.createPaidMemberOrder(createReqVO));
|
return success(paidMemberOrderService.createPaidMemberOrder(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,11 +34,15 @@ public class AppMemberCardTypeController {
|
|||||||
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@Operation(summary = "获得会员卡类型列表")
|
@Operation(summary = "获得会员卡类型列表")
|
||||||
public CommonResult<List<AppMemberCardTypeRespVO>> list() {
|
public CommonResult<List<AppMemberCardTypeRespVO>> list(@RequestParam(value = "name", required = false) String name) {
|
||||||
/** 查询状态为启用的会员卡类型列表 */
|
/** 查询状态为启用的会员卡类型列表 */
|
||||||
MemberUserDO memberUserDO = userService.getUser(getLoginUserId());
|
MemberUserDO memberUserDO = userService.getUser(getLoginUserId());
|
||||||
/** 根据用户查询是否有试用会员的类型列表 */
|
/** 根据用户查询是否有试用会员的类型列表 */
|
||||||
List<PaidMemberCardTypeDO> list = cardService.getCardTypeList(memberUserDO.getActivate());
|
List<PaidMemberCardTypeDO> list = cardService.getCardTypeList(memberUserDO.getActivate());
|
||||||
|
if(!name.isEmpty()){
|
||||||
|
//根据用户查询是否有有效期会员的类型列表
|
||||||
|
list = cardService.getCardTypeList2(memberUserDO.getActivate(),name);
|
||||||
|
}
|
||||||
return success(MemberCardTypeConvert.INSTANCE.convertList(list));
|
return success(MemberCardTypeConvert.INSTANCE.convertList(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ public class PaidMemberOrderDO extends TenantBaseDO {
|
|||||||
* 编号
|
* 编号
|
||||||
*/
|
*/
|
||||||
@TableId
|
@TableId
|
||||||
private Integer id;
|
private Long id;
|
||||||
/**
|
/**
|
||||||
* 用户UID
|
* 用户UID
|
||||||
*/
|
*/
|
||||||
|
@ -38,4 +38,7 @@ public interface PaidMemberCardTypeMapper extends BaseMapperX<PaidMemberCardType
|
|||||||
.neIfPresent(PaidMemberCardTypeDO::getName,"试用")
|
.neIfPresent(PaidMemberCardTypeDO::getName,"试用")
|
||||||
.orderByAsc(PaidMemberCardTypeDO::getId));
|
.orderByAsc(PaidMemberCardTypeDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -62,6 +62,15 @@ public interface PaidMemberCardTypeService {
|
|||||||
*/
|
*/
|
||||||
List<PaidMemberCardTypeDO> getCardTypeList (Integer activate);
|
List<PaidMemberCardTypeDO> getCardTypeList (Integer activate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户是否使用有效期会员
|
||||||
|
* 查询会员类型列表
|
||||||
|
* @param activate
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<PaidMemberCardTypeDO> getCardTypeList2 (Integer activate,String name);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据会员卡名查询
|
* 根据会员卡名查询
|
||||||
|
@ -92,6 +92,20 @@ public class PaidMemberCardTypeServiceImpl implements PaidMemberCardTypeService
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PaidMemberCardTypeDO> getCardTypeList2(Integer activate,String name) {
|
||||||
|
List<PaidMemberCardTypeDO> list = new ArrayList<>();
|
||||||
|
Integer status = 1;
|
||||||
|
if (activate == 2){
|
||||||
|
list = cardMapper.selectList(new LambdaQueryWrapperX<PaidMemberCardTypeDO>()
|
||||||
|
.eqIfPresent(PaidMemberCardTypeDO::getStatus,status)
|
||||||
|
.neIfPresent(PaidMemberCardTypeDO::getName,name)
|
||||||
|
.neIfPresent(PaidMemberCardTypeDO::getName,"试用")
|
||||||
|
.orderByAsc(PaidMemberCardTypeDO::getId));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PaidMemberCardTypeDO selectByName(String cardName) {
|
public PaidMemberCardTypeDO selectByName(String cardName) {
|
||||||
|
@ -23,7 +23,7 @@ public interface PaidMemberOrderService {
|
|||||||
* @param createReqVO 创建信息
|
* @param createReqVO 创建信息
|
||||||
* @return 编号
|
* @return 编号
|
||||||
*/
|
*/
|
||||||
Integer createPaidMemberOrder(@Valid PaidMemberOrderSaveReqVO createReqVO);
|
Long createPaidMemberOrder(@Valid PaidMemberOrderSaveReqVO createReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新付费会员订单
|
* 更新付费会员订单
|
||||||
|
@ -46,7 +46,7 @@ public class PaidMemberOrderServiceImpl implements PaidMemberOrderService {
|
|||||||
private PaidMemberUserService paidMemberUserService;
|
private PaidMemberUserService paidMemberUserService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer createPaidMemberOrder(PaidMemberOrderSaveReqVO createReqVO) {
|
public Long createPaidMemberOrder(PaidMemberOrderSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
PaidMemberOrderDO paidMemberOrder = BeanUtils.toBean(createReqVO, PaidMemberOrderDO.class);
|
PaidMemberOrderDO paidMemberOrder = BeanUtils.toBean(createReqVO, PaidMemberOrderDO.class);
|
||||||
paidMemberOrderMapper.insert(paidMemberOrder);
|
paidMemberOrderMapper.insert(paidMemberOrder);
|
||||||
|
@ -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.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
//import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
//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.controller.admin.user.vo.PaidMemberUserSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.member.convert.order.PaidMemberOrderConvert;
|
import cn.iocoder.yudao.module.member.convert.order.PaidMemberOrderConvert;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.order.PaidMemberOrderDO;
|
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.order.PaidMemberOrderService;
|
||||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||||
import cn.iocoder.yudao.module.member.service.user.PaidMemberUserService;
|
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.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.AppPaidMemberOrderReqVO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.app.member.vo.AppPaidMemberOrderRespVO;
|
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.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.PayWalletDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
|
||||||
import cn.iocoder.yudao.module.pay.service.order.PayOrderService;
|
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 org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.annotation.security.PermitAll;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.LocalDateTime;
|
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.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime;
|
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.common.util.servlet.ServletUtils.getClientIP;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
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.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 - 会员支出")
|
@Tag(name = "用户 APP - 会员支出")
|
||||||
@RestController
|
@RestController
|
||||||
@ -67,6 +77,9 @@ public class AppPaidMembeOrderController {
|
|||||||
@Resource
|
@Resource
|
||||||
private PaidMemberCardTypeService cardService;
|
private PaidMemberCardTypeService cardService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PayWalletService payWalletService;
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建会员支付记录(发起支付)")
|
@Operation(summary = "创建会员支付记录(发起支付)")
|
||||||
@ -112,7 +125,7 @@ public class AppPaidMembeOrderController {
|
|||||||
// PayWalletDO walletDO = memberWalletService.getOrCreateWallet(getLoginUserId(),getLoginUserType());
|
// PayWalletDO walletDO = memberWalletService.getOrCreateWallet(getLoginUserId(),getLoginUserType());
|
||||||
//订单对象赋值
|
//订单对象赋值
|
||||||
PaidMemberOrderDO paidMemberOrderDO = PaidMemberOrderConvert.INSTANCE.convert(getLoginUserId(),
|
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);
|
paidMemberOrderService1.createOrder(paidMemberOrderDO);
|
||||||
Long payOrderId = payOrderService01.createOrder(new PayOrderCreateReqDTO()
|
Long payOrderId = payOrderService01.createOrder(new PayOrderCreateReqDTO()
|
||||||
.setAppId(1L).setUserIp(getClientIP())
|
.setAppId(1L).setUserIp(getClientIP())
|
||||||
@ -123,6 +136,41 @@ public class AppPaidMembeOrderController {
|
|||||||
paidMemberOrderDO.setPayOrderId(payOrderId);
|
paidMemberOrderDO.setPayOrderId(payOrderId);
|
||||||
userService1.updateUserDo(memberUserDO);
|
userService1.updateUserDo(memberUserDO);
|
||||||
paidMemberOrderService1.updateOrder(paidMemberOrderDO);
|
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<Boolean> 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()<price){
|
||||||
|
log.error("[updatePaidMemberOrder],updateReqVO({}) 钱包余额不足.");
|
||||||
|
throw exception(WALLET_BALANCE_NOT_ENOUGH);
|
||||||
|
}
|
||||||
|
PayOrderDO payOrderDO = payOrderService01.getOrder(notifyReqDTO.getPayOrderId());
|
||||||
|
//更新订单支付状态为已支付
|
||||||
|
paidMemberOrderDO.setPaid(true);
|
||||||
|
paidMemberOrderDO.setPayChannel(payOrderDO.getChannelCode());
|
||||||
|
paidMemberOrderService1.updateOrder(paidMemberOrderDO);
|
||||||
|
//扣减钱包余额
|
||||||
|
PayWalletTransactionDO payWalletTransactionDO = payWalletService.reduceWalletBalance
|
||||||
|
(walletDO.getId(),notifyReqDTO.getPayOrderId(),PAYMENT,price);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,12 @@ package cn.iocoder.yudao.module.pay.controller.app.member.vo;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
@Schema(description = "用户 APP - 会员支付 Resp VO")
|
@Schema(description = "用户 APP - 会员支付 Resp VO")
|
||||||
@Data
|
@Data
|
||||||
public class AppPaidMemberOrderRespVO {
|
public class AppPaidMemberOrderRespVO {
|
||||||
@ -15,6 +18,11 @@ public class AppPaidMemberOrderRespVO {
|
|||||||
@Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "o100")
|
@Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "o100")
|
||||||
private Long payOrderId;
|
private Long payOrderId;
|
||||||
|
|
||||||
@Schema(description = "到期时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "到期时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-11-22 09:30:05")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
private LocalDateTime cardExpirationTime;
|
private LocalDateTime cardExpirationTime;
|
||||||
|
|
||||||
|
@Schema(description = "会员类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "0:未开通,1:试用,2:有效,3:永久")
|
||||||
|
private Integer activate;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
package cn.iocoder.yudao.module.pay.controller.app.member.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 付费会员支付单的通知 Request DTO
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class AppPaidMemeberOrderReqDto {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商户订单编号
|
||||||
|
*/
|
||||||
|
@NotEmpty(message = "商户订单号不能为空")
|
||||||
|
private String merchantOrderId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付订单编号
|
||||||
|
*/
|
||||||
|
@NotNull(message = "支付订单编号不能为空")
|
||||||
|
private Long payOrderId;
|
||||||
|
|
||||||
|
}
|
@ -6,10 +6,12 @@ import cn.iocoder.yudao.module.pay.controller.app.member.vo.AppPaidMemberOrderRe
|
|||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface PayMemberOrderConvert {
|
public interface PayMemberOrderConvert {
|
||||||
|
|
||||||
PayMemberOrderConvert INSTANCE = Mappers.getMapper(PayMemberOrderConvert.class);
|
PayMemberOrderConvert INSTANCE = Mappers.getMapper(PayMemberOrderConvert.class);
|
||||||
|
|
||||||
AppPaidMemberOrderRespVO convert(PaidMemberOrderDO bean);
|
AppPaidMemberOrderRespVO convert(Long id, Long payOrderId, LocalDateTime cardExpirationTime, Integer activate);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user