f
This commit is contained in:
@@ -151,7 +151,7 @@ func (l *PaymentCheckLogic) PaymentCheck(req *types.PaymentCheckReq) (resp *type
|
||||
|
||||
if newPayStatus != yunyinOrder.PayStatus {
|
||||
yunyinOrder.PayStatus = newPayStatus
|
||||
if updateYunyinErr := l.svcCtx.YunyinSignPayOrderModel.Update(l.ctx, yunyinOrder); updateYunyinErr != nil {
|
||||
if _, updateYunyinErr := l.svcCtx.YunyinSignPayOrderModel.Update(l.ctx, nil, yunyinOrder); updateYunyinErr != nil {
|
||||
logx.Errorf("更新云印签订单支付状态失败: %v", updateYunyinErr)
|
||||
} else {
|
||||
logx.Infof("成功更新云印签订单支付状态,订单ID: %s, 新支付状态: %d", order.Id, newPayStatus)
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/google/uuid"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/redis/go-redis/v9"
|
||||
@@ -140,8 +141,21 @@ func (l *PaymentLogic) Payment(req *types.PaymentReq) (resp *types.PaymentResp,
|
||||
|
||||
// 查询用户是否有未完成的签署(待签署且待支付)
|
||||
var yunYinSignPayResult *service.CreateYunYinSignPayOrderResult
|
||||
unfinishedOrder, findUnfinishedErr := l.svcCtx.YunyinSignPayOrderModel.FindUnfinishedByUserId(l.ctx, userID)
|
||||
if findUnfinishedErr == nil && unfinishedOrder != nil {
|
||||
// 使用 SelectBuilder 查询未完成的签署订单(del_state 由系统自动处理)
|
||||
unfinishedBuilder := l.svcCtx.YunyinSignPayOrderModel.SelectBuilder().
|
||||
Where(squirrel.Eq{
|
||||
"user_id": userID,
|
||||
"sign_status": 0, // 待签署
|
||||
"pay_status": 0, // 待支付
|
||||
}).
|
||||
OrderBy("create_time DESC").
|
||||
Limit(1)
|
||||
unfinishedOrders, findUnfinishedErr := l.svcCtx.YunyinSignPayOrderModel.FindAll(l.ctx, unfinishedBuilder, "")
|
||||
var unfinishedOrder *model.YunyinSignPayOrder
|
||||
if findUnfinishedErr == nil && len(unfinishedOrders) > 0 {
|
||||
unfinishedOrder = unfinishedOrders[0]
|
||||
}
|
||||
if unfinishedOrder != nil {
|
||||
// 复用未完成的签署,只获取新的支付链接
|
||||
logx.Infof("复用未完成的云印签签署,任务ID: %s, 参与者ID: %s", unfinishedOrder.TaskId, unfinishedOrder.ParticipantId)
|
||||
|
||||
@@ -382,7 +396,7 @@ func (l *PaymentLogic) QueryOrderPayment(req *types.PaymentReq, session sqlx.Ses
|
||||
Version: 0,
|
||||
}
|
||||
|
||||
_, insertYunYinErr := l.svcCtx.YunyinSignPayOrderModel.InsertWithSession(l.ctx, session, &yunyinSignPayOrder)
|
||||
_, insertYunYinErr := l.svcCtx.YunyinSignPayOrderModel.Insert(l.ctx, session, &yunyinSignPayOrder)
|
||||
if insertYunYinErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "生成订单, 保存云印签订单失败: %+v", insertYunYinErr)
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ func (l *YunYinSignPayCallbackLogic) YunYinSignPayCallback(w http.ResponseWriter
|
||||
// 更新支付状态为已支付(1)
|
||||
if yunyinOrder.PayStatus != 1 {
|
||||
yunyinOrder.PayStatus = 1
|
||||
if updateYunyinErr := l.svcCtx.YunyinSignPayOrderModel.Update(l.ctx, yunyinOrder); updateYunyinErr != nil {
|
||||
if _, updateYunyinErr := l.svcCtx.YunyinSignPayOrderModel.Update(l.ctx, nil, yunyinOrder); updateYunyinErr != nil {
|
||||
logx.Errorf("云印签回调,更新云印签订单支付状态失败,订单ID: %s, 错误: %v", order.Id, updateYunyinErr)
|
||||
} else {
|
||||
logx.Infof("云印签回调,成功更新云印签订单支付状态,订单ID: %s", order.Id)
|
||||
|
||||
@@ -100,7 +100,7 @@ func (l *YunYinSignPayRefundLogic) YunYinSignPayRefund(req *types.YunYinSignPayR
|
||||
yunyinOrder.PayStatus = 2
|
||||
}
|
||||
// 部分退款保持已支付状态(1),但可以通过其他字段记录退款金额
|
||||
if updateYunyinErr := l.svcCtx.YunyinSignPayOrderModel.Update(l.ctx, yunyinOrder); updateYunyinErr != nil {
|
||||
if _, updateYunyinErr := l.svcCtx.YunyinSignPayOrderModel.Update(l.ctx, nil, yunyinOrder); updateYunyinErr != nil {
|
||||
logx.Errorf("更新云印签订单状态失败: %v", updateYunyinErr)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user