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