Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加 userId 到 PayOrderDO #555

Open
wants to merge 11 commits into
base: master-jdk17
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ default ProductSkuUpdateStockReqDTO convertNegative(List<TradeOrderItemDO> list)
default PayOrderCreateReqDTO convert(TradeOrderDO order, List<TradeOrderItemDO> orderItems,
TradeOrderProperties orderProperties) {
PayOrderCreateReqDTO createReqDTO = new PayOrderCreateReqDTO()
.setAppKey(orderProperties.getPayAppKey()).setUserIp(order.getUserIp());
.setAppKey(orderProperties.getPayAppKey()).setUserIp(order.getUserIp())
.setUserId(order.getUserId());
// 商户相关字段
createReqDTO.setMerchantOrderId(String.valueOf(order.getId()));
String subject = orderItems.get(0).getSpuName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public class PayOrderCreateReqDTO implements Serializable {
@NotEmpty(message = "用户 IP 不能为空")
private String userIp;


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1、可以搞成非必传
2、建议 userType 也存储

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userType 有必要记录么? 🤔
除了管理员使用管理端测试支付的时候会产生零星的几个交易订单以为, 其他的应该都是会员产生的了吧?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

现有业务如此,但是有可能 admin 卖租户套餐,类似这种业务哈。

@NotNull(message = "用户编号不能为空")
private Long userId;

// ========== 商户相关字段 ==========

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package cn.iocoder.yudao.module.pay.controller.admin.order.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import jakarta.validation.constraints.NotNull;
import java.time.LocalDateTime;

import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
Expand All @@ -21,6 +22,10 @@ public class PayOrderBaseVO {
@NotNull(message = "应用编号不能为空")
private Long appId;

@Schema(description = "用户编号", example = "1024")
@NotNull(message = "用户编号不能为空")
DevDengChao marked this conversation as resolved.
Show resolved Hide resolved
private Long userId;

@Schema(description = "渠道编号", example = "2048")
private Long channelId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public class PayOrderExportReqVO {
@Schema(description = "应用编号", example = "1024")
private Long appId;

@Schema(description = "用户编号", example = "1024")
private Long userId;

@Schema(description = "渠道编码", example = "wx_app")
private String channelCode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class PayOrderPageReqVO extends PageParam {
@Schema(description = "应用编号", example = "1024")
private Long appId;

@Schema(description = "用户编号", example = "1024")
private Long userId;

@Schema(description = "渠道编码", example = "wx_app")
private String channelCode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ public class PayOrderDO extends BaseDO {
private Long id;
/**
* 应用编号
*
* <p>
* 关联 {@link PayAppDO#getId()}
*/
private Long appId;
/**
* 渠道编号
*
* <p>
* 关联 {@link PayChannelDO#getId()}
*/
private Long channelId;
/**
* 渠道编码
*
* <p>
* 枚举 {@link PayChannelEnum}
*/
private String channelCode;
Expand All @@ -53,7 +53,7 @@ public class PayOrderDO extends BaseDO {

/**
* 商户订单编号
*
* <p>
* 例如说,内部系统 A 的订单号,需要保证每个 PayAppDO 唯一
*/
private String merchantOrderId;
Expand All @@ -78,7 +78,7 @@ public class PayOrderDO extends BaseDO {
private Integer price;
/**
* 渠道手续费,单位:百分比
*
* <p>
* 冗余 {@link PayChannelDO#getFeeRate()}
*/
private Double channelFeeRate;
Expand All @@ -88,14 +88,18 @@ public class PayOrderDO extends BaseDO {
private Integer channelFeePrice;
/**
* 支付状态
*
* <p>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这种换行,不加哈。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 这个是 IDEA 格式化代码的时候自动加上去的...
我手动删掉以后再执行格式代码又会加上, 确定要删掉么?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

去掉哈。

ps:代码不要批量格式化。。。最好是自己写出来,就是标准的哈。

* 枚举 {@link PayOrderStatusEnum}
*/
private Integer status;
/**
* 用户 IP
*/
private String userIp;
/**
* 用户编号
*/
private Long userId;
/**
* 订单失效时间
*/
Expand All @@ -106,13 +110,13 @@ public class PayOrderDO extends BaseDO {
private LocalDateTime successTime;
/**
* 支付成功的订单拓展单编号
*
* <p>
* 关联 {@link PayOrderExtensionDO#getId()}
*/
private Long extensionId;
/**
* 支付成功的外部订单号
*
* <p>
* 关联 {@link PayOrderExtensionDO#getNo()}
*/
private String no;
Expand All @@ -126,7 +130,7 @@ public class PayOrderDO extends BaseDO {
// ========== 渠道相关字段 ==========
/**
* 渠道用户编号
*
* <p>
* 例如说,微信 openid、支付宝账号
*/
private String channelUserId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public interface PayOrderMapper extends BaseMapperX<PayOrderDO> {
default PageResult<PayOrderDO> selectPage(PayOrderPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<PayOrderDO>()
.eqIfPresent(PayOrderDO::getAppId, reqVO.getAppId())
.eqIfPresent(PayOrderDO::getUserId, reqVO.getUserId())
.eqIfPresent(PayOrderDO::getChannelCode, reqVO.getChannelCode())
.likeIfPresent(PayOrderDO::getMerchantOrderId, reqVO.getMerchantOrderId())
.likeIfPresent(PayOrderDO::getChannelOrderNo, reqVO.getChannelOrderNo())
Expand All @@ -30,6 +31,7 @@ default PageResult<PayOrderDO> selectPage(PayOrderPageReqVO reqVO) {
default List<PayOrderDO> selectList(PayOrderExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<PayOrderDO>()
.eqIfPresent(PayOrderDO::getAppId, reqVO.getAppId())
.eqIfPresent(PayOrderDO::getUserId, reqVO.getUserId())
.eqIfPresent(PayOrderDO::getChannelCode, reqVO.getChannelCode())
.likeIfPresent(PayOrderDO::getMerchantOrderId, reqVO.getMerchantOrderId())
.likeIfPresent(PayOrderDO::getChannelOrderNo, reqVO.getChannelOrderNo())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public Long createDemoOrder(Long userId, PayDemoOrderCreateReqVO createReqVO) {
// 2.1 创建支付单
Long payOrderId = payOrderApi.createOrder(new PayOrderCreateReqDTO()
.setAppKey(PAY_APP_KEY).setUserIp(getClientIP()) // 支付应用
.setUserId(userId)
.setMerchantOrderId(demoOrder.getId().toString()) // 业务的订单编号
.setSubject(spuName).setBody("").setPrice(price) // 价格信息
.setExpireTime(addTime(Duration.ofHours(2L)))); // 支付的过期时间
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, S
// 2.1 创建支付单
Long payOrderId = payOrderService.createOrder(new PayOrderCreateReqDTO()
.setAppKey(payProperties.getWalletPayAppKey()).setUserIp(userIp)
.setUserId(userId)
.setMerchantOrderId(recharge.getId().toString()) // 业务的订单编号
.setSubject(WALLET_RECHARGE_ORDER_SUBJECT).setBody("")
.setPrice(recharge.getPayPrice())
Expand Down
Loading