新增单行文本编码器与结构化 GORM 日志,统一错误记录与请求日志策略,收紧日志文件权限并修复按天切分与压缩,支付回调参数脱敏,生产强制阿里云短信,RequestID 校验防注入,日志文案中文化。
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package order
|
|
|
|
import (
|
|
"context"
|
|
|
|
"hfb_sys/backend/internal/logging"
|
|
"hfb_sys/backend/internal/model"
|
|
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func (r *Repository) prepareRefund(order *model.RentalOrder, amountCent int64, bizType string, remark string) (*refundAction, error) {
|
|
if amountCent <= 0 {
|
|
return nil, nil
|
|
}
|
|
if r.refundStarter == nil {
|
|
return nil, ErrDependencyUnavailable
|
|
}
|
|
order.RefundStatus = refundStatusPending
|
|
order.RefundAmountCent = amountCent
|
|
order.RefundedAt = nil
|
|
return &refundAction{
|
|
OrderID: order.ID,
|
|
RefundAmountCent: amountCent,
|
|
BizType: bizType,
|
|
Remark: remark,
|
|
}, nil
|
|
}
|
|
|
|
func (r *Repository) startRefundBestEffort(ctx context.Context, action *refundAction) {
|
|
if action == nil || r.refundStarter == nil {
|
|
return
|
|
}
|
|
if _, err := r.refundStarter.StartRefund(ctx, action.OrderID, action.RefundAmountCent, action.BizType, action.Remark); err != nil {
|
|
logging.FromContext(ctx).Error("订单退款提交失败",
|
|
zap.String("module", "order"),
|
|
zap.Uint64("order_id", action.OrderID),
|
|
zap.String("biz_type", action.BizType),
|
|
zap.Int64("amount_cent", action.RefundAmountCent),
|
|
zap.Error(err),
|
|
)
|
|
}
|
|
}
|