f
This commit is contained in:
@@ -179,14 +179,19 @@ func (l *AdminRefundOrderLogic) handleYunYinSignPayRefund(order *model.Order, re
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "AdminRefundOrder, 云印签支付服务未启用")
|
||||
}
|
||||
|
||||
// 查询云印签订单获取参与方ID
|
||||
// 查询云印签订单获取参与方ID(如果存在)
|
||||
var participateId int64
|
||||
yunyinOrder, err := l.svcCtx.YunyinSignPayOrderModel.FindOneByOrderId(l.ctx, order.Id)
|
||||
if err != nil {
|
||||
// 如果查询不到云印签订单记录,可能是历史订单或数据不一致,使用订单号退款
|
||||
if errors.Is(err, model.ErrNotFound) {
|
||||
logx.Infof("未找到云印签订单记录,将使用订单号退款,订单ID: %s, 订单号: %s", order.Id, order.OrderNo)
|
||||
participateId = 0 // 使用订单号退款
|
||||
} else {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "AdminRefundOrder, 查询云印签订单失败, 订单ID: %s, 错误: %v", order.Id, err)
|
||||
}
|
||||
|
||||
} else {
|
||||
// 获取参与方ID(ParticipantId 是 string 类型,需要转换为 int64)
|
||||
var participateId int64
|
||||
if yunyinOrder.ParticipantId != "" {
|
||||
// 尝试将字符串转换为int64
|
||||
if _, parseErr := fmt.Sscanf(yunyinOrder.ParticipantId, "%d", &participateId); parseErr != nil {
|
||||
@@ -196,6 +201,7 @@ func (l *AdminRefundOrderLogic) handleYunYinSignPayRefund(order *model.Order, re
|
||||
logx.Infof("成功解析参与方ID,订单ID: %s, ParticipantId: %s, participateId: %d", order.Id, yunyinOrder.ParticipantId, participateId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 调用云印签退款接口
|
||||
refundErr := l.svcCtx.YunYinSignPayService.RefundPayeeBill(
|
||||
@@ -223,11 +229,13 @@ func (l *AdminRefundOrderLogic) handleYunYinSignPayRefund(order *model.Order, re
|
||||
var orderStatus string
|
||||
if isFullRefund {
|
||||
orderStatus = model.OrderStatusRefunded
|
||||
// 更新云印签订单表的支付状态为已退款(2)
|
||||
// 如果存在云印签订单记录,更新支付状态为已退款(2)
|
||||
if yunyinOrder != nil {
|
||||
yunyinOrder.PayStatus = 2
|
||||
if _, updateErr := l.svcCtx.YunyinSignPayOrderModel.Update(l.ctx, nil, yunyinOrder); updateErr != nil {
|
||||
logx.Errorf("更新云印签订单状态失败: %v", updateErr)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 部分退款保持已支付状态
|
||||
orderStatus = model.OrderStatusPaid
|
||||
|
||||
@@ -694,9 +694,7 @@ func (y *YunYinSignPayService) CreateYunYinSignPayOrder(ctx context.Context, use
|
||||
|
||||
// 2. 构建参与者列表
|
||||
logx.Infof("[云印签API] CreateYunYinSignPayOrder: 步骤3-构建参与者列表,订单号: %s", outTradeNo)
|
||||
// 签署方2使用固定的手机号和姓名
|
||||
fixedMobile := "18888888888"
|
||||
fixedName := "李"
|
||||
// 使用传入的用户手机号和姓名
|
||||
participantList := []ParticipantInfo{
|
||||
// 签署方1:我方
|
||||
{
|
||||
@@ -705,11 +703,11 @@ func (y *YunYinSignPayService) CreateYunYinSignPayOrder(ctx context.Context, use
|
||||
PsnName: y.config.Name,
|
||||
ParticipantCorpName: y.config.CorpName,
|
||||
},
|
||||
// 签署方2:用户(支付方)- 使用固定的手机号和姓名
|
||||
// 签署方2:用户(支付方)- 使用传入的用户手机号和姓名
|
||||
{
|
||||
ParticipantFlag: "签署方2",
|
||||
PsnAccount: fixedMobile, // 固定手机号
|
||||
PsnName: fixedName, // 固定姓名
|
||||
PsnAccount: userMobile, // 使用传入的用户手机号
|
||||
PsnName: userName, // 使用传入的用户姓名
|
||||
PayeeContractFlag: 1,
|
||||
Payee: &PayeeInfo{
|
||||
Amount: amount, // 金额根据订单动态
|
||||
@@ -718,7 +716,7 @@ func (y *YunYinSignPayService) CreateYunYinSignPayOrder(ctx context.Context, use
|
||||
},
|
||||
}
|
||||
logx.Infof("[云印签API] CreateYunYinSignPayOrder: 参与者列表构建完成,订单号: %s, 签署方1: %s(%s), 签署方2: %s(%s), 金额: %.2f",
|
||||
outTradeNo, y.config.Name, y.config.Mobile, fixedName, fixedMobile, amount)
|
||||
outTradeNo, y.config.Name, y.config.Mobile, userName, userMobile, amount)
|
||||
|
||||
// 3. 发起签署流程
|
||||
logx.Infof("[云印签API] CreateYunYinSignPayOrder: 步骤4-发起签署流程,订单号: %s, 模板ID: %s", outTradeNo, y.config.TemplateID)
|
||||
@@ -736,7 +734,7 @@ func (y *YunYinSignPayService) CreateYunYinSignPayOrder(ctx context.Context, use
|
||||
}
|
||||
startSignFlowReq := &StartSignFlowRequest{
|
||||
TemplateID: templateID, // 模板ID(int64类型)
|
||||
FlowType: 2, // 2-临时签署流程(签署方二信息可为占位符)
|
||||
FlowType: 0, // 0-正常签署流程(签署方信息需准确完整)
|
||||
SourceOrderCode: outTradeNo, // 来源订单号
|
||||
ParticipantList: participantList,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user