by Robin at 20240625
This commit is contained in:
parent
a59a4ca43f
commit
294f637de0
|
@ -261,3 +261,11 @@ const (
|
|||
HygSingleDistribute_TicketRefunding = 80 // 退票中
|
||||
HygSingleDistribute_TicketRefunded = 90 // 已退票
|
||||
)
|
||||
|
||||
const (
|
||||
HygSingleDistributeFinalState_Success = 0 // 打款成功
|
||||
HygSingleDistributeFinalState_OrderStatusSwitchFail = 1 // 打款成功,订单状态翻转失败
|
||||
HygSingleDistributeFinalState_Reversed = 2 // 打款失败,已冲正
|
||||
HygSingleDistributeFinalState_ReversalFailed = 3 // 打款失败,冲正失败
|
||||
HygSingleDistributeFinalState_Unhandleable = 4 // 无法处理的下发打款状态
|
||||
)
|
||||
|
|
|
@ -218,6 +218,7 @@ var ErrCodeMsgMap = map[ErrCode]string{
|
|||
ErrCodeSingleDistributeHisSrvFail: "慧用工下发打款历史表服务错误",
|
||||
ErrCodeSingleDistributeHisNotExist: "慧用工下发打款历史表不存在",
|
||||
ErrCodeCurrentSingleDistributeNotTerminated: "当前慧用工下发打款申请尚未结束",
|
||||
ErrCodeUnhandleableSingleDistributeStatus: "无法处理的下发打款状态",
|
||||
|
||||
ErrCodeHvyogoSrvFail: "慧用工接口服务错误",
|
||||
}
|
||||
|
@ -524,6 +525,7 @@ const (
|
|||
ErrCodeSingleDistributeHisSrvFail ErrCode = -42001 // 慧用工下发打款历史表服务错误
|
||||
ErrCodeSingleDistributeHisNotExist ErrCode = -42002 // 慧用工下发打款历史表不存在
|
||||
ErrCodeCurrentSingleDistributeNotTerminated ErrCode = -42003 // 当前慧用工下发打款申请尚未结束
|
||||
ErrCodeUnhandleableSingleDistributeStatus ErrCode = -42004 // 无法处理的下发打款状态
|
||||
|
||||
// Media: 60xxx
|
||||
ErrCodeMediaSrvOk ErrCode = ErrCodeOk
|
||||
|
|
|
@ -4218,7 +4218,7 @@ func (s *Service) SaveSingleDistributeCallback(ctx *gin.Context, req *hvyogoprot
|
|||
}
|
||||
|
||||
// 更新数据
|
||||
_ = _DefaultSingleDistributeHis.OpUpdate(ctx, &single_distribute_his_proto.OpUpdateReq{
|
||||
err = _DefaultSingleDistributeHis.OpUpdate(ctx, &single_distribute_his_proto.OpUpdateReq{
|
||||
SingleDistributeHis: &dbstruct.SingleDistributeHis{
|
||||
Id: goproto.String(vo.RequestNo),
|
||||
DistributeId: goproto.String(vo.DistributeId),
|
||||
|
@ -4230,23 +4230,57 @@ func (s *Service) SaveSingleDistributeCallback(ctx *gin.Context, req *hvyogoprot
|
|||
ReasonCode: goproto.String(vo.ReasonCode),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("_DefaultSingleDistributeHis OpUpdate fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
}
|
||||
|
||||
var (
|
||||
finalStatus int64
|
||||
)
|
||||
|
||||
defer func() {
|
||||
// 仅针对未发生错误的情况将该用户的下发打款锁解开
|
||||
if err == nil {
|
||||
err1 := _DefaultSingleDistributeHis.ClearLock(ctx, singleDistributeHis.GetMid())
|
||||
if err1 != nil {
|
||||
logger.Error("_DefaultSingleDistributeHis ClearLock fail, err: %v", err)
|
||||
}
|
||||
}
|
||||
err = _DefaultSingleDistributeHis.OpUpdate(ctx, &single_distribute_his_proto.OpUpdateReq{
|
||||
SingleDistributeHis: &dbstruct.SingleDistributeHis{
|
||||
Id: goproto.String(vo.RequestNo),
|
||||
FinalStatus: goproto.Int64(finalStatus),
|
||||
ErrorDesc: goproto.String(err.Error()),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("_DefaultSingleDistributeHis OpUpdate fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
}
|
||||
}()
|
||||
|
||||
switch vo.DistributeStatus {
|
||||
case consts.HygSingleDistribute_Success:
|
||||
finalStatus = consts.HygSingleDistributeFinalState_Success
|
||||
err = _DefaultVas.UnilaterallyWithdrawAccomplish(ctx, singleDistributeHis.GetOrderId())
|
||||
// 因为整个打款流程已经正常结束,所以这里的err不能够令其返回2次触发回调,打印出信息即可
|
||||
// 因为整个打款流程已经正常结束,所以这里的err不能够令其返回慧用工触发2次回调,打印出信息即可
|
||||
if err != nil {
|
||||
finalStatus = consts.HygSingleDistributeFinalState_OrderStatusSwitchFail
|
||||
logger.Error("_DefaultVas UnilaterallyWithdrawAccomplish fail, err: %v", err)
|
||||
}
|
||||
logger.Info("Single distribution accomplished, orderId :%v", singleDistributeHis.GetOrderId())
|
||||
case consts.HygSingleDistribute_Fail, consts.HygSingleDistribute_Refunded, consts.HygSingleDistribute_TicketRefunded:
|
||||
finalStatus = consts.HygSingleDistributeFinalState_Reversed
|
||||
err = _DefaultVas.UnilaterallyWithdrawReverse(ctx, singleDistributeHis.GetOrderId())
|
||||
// 因为整个打款流程已经正常结束,所以这里的err不能够令其返回慧用工触发2次回调,打印出信息即可
|
||||
if err != nil {
|
||||
finalStatus = consts.HygSingleDistributeFinalState_ReversalFailed
|
||||
logger.Error("_DefaultVas UnilaterallyWithdrawReverse fail, err: %v", err)
|
||||
}
|
||||
logger.Info("Single distribution reversed, orderId :%v", singleDistributeHis.GetOrderId())
|
||||
default:
|
||||
|
||||
finalStatus = consts.HygSingleDistributeFinalState_Unhandleable
|
||||
err = fmt.Errorf("unhandleable single distribute status")
|
||||
ec = errcode.ErrCodeUnhandleableSingleDistributeStatus
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -13,6 +13,8 @@ type SingleDistributeHis struct {
|
|||
Remark *string `json:"remark" bson:"remark"` // 银行返回打款备注
|
||||
ReasonCode *string `json:"reason_code" bson:"reason_code"` // 余额不足时会返回E00001
|
||||
OrderId *string `json:"order_id" bson:"order_id"` // 订单号
|
||||
FinalStatus *int64 `json:"final_status" bson:"final_status"` // 终态状态
|
||||
ErrorDesc *string `json:"error_desc" bson:"error_desc"` // 错误描述
|
||||
Ct *int64 `json:"ct" bson:"ct"` // 创建时间
|
||||
Ut *int64 `json:"ut" bson:"ut"` // 更新时间
|
||||
DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记
|
||||
|
@ -25,6 +27,13 @@ func (p *SingleDistributeHis) GetId() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (p *SingleDistributeHis) GetMid() int64 {
|
||||
if p != nil && p.OrderId != nil {
|
||||
return *p.Mid
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (p *SingleDistributeHis) GetOrderId() string {
|
||||
if p != nil && p.OrderId != nil {
|
||||
return *p.OrderId
|
||||
|
|
Loading…
Reference in New Issue