by Robin at 20240625
This commit is contained in:
parent
45d78dfd17
commit
a59a4ca43f
|
@ -253,3 +253,11 @@ const (
|
||||||
HygAgreeState_Waiting = "1" // 待生成电子签
|
HygAgreeState_Waiting = "1" // 待生成电子签
|
||||||
HygAgreeState_Success = "2" // 签约成功
|
HygAgreeState_Success = "2" // 签约成功
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
HygSingleDistribute_Success = 60 // 打款成功
|
||||||
|
HygSingleDistribute_Fail = 70 // 打款失败
|
||||||
|
HygSingleDistribute_Refunded = 75 // 已退款
|
||||||
|
HygSingleDistribute_TicketRefunding = 80 // 退票中
|
||||||
|
HygSingleDistribute_TicketRefunded = 90 // 已退票
|
||||||
|
)
|
||||||
|
|
|
@ -5368,3 +5368,18 @@ func (m *Mongo) ClearSingleDistributeLock(ctx *gin.Context, mid int64) (err erro
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Mongo) GetSingleDistributeHisById(ctx *gin.Context, id string) (*dbstruct.SingleDistributeHis, error) {
|
||||||
|
one := &dbstruct.SingleDistributeHis{}
|
||||||
|
col := m.getColSingleDistributeHis()
|
||||||
|
query := qmgo.M{
|
||||||
|
"_id": id,
|
||||||
|
"del_flag": 0,
|
||||||
|
}
|
||||||
|
err := col.Find(ctx, query).One(one)
|
||||||
|
if err == qmgo.ErrNoSuchDocuments {
|
||||||
|
err = nil
|
||||||
|
return one, err
|
||||||
|
}
|
||||||
|
return one, err
|
||||||
|
}
|
||||||
|
|
|
@ -81,3 +81,12 @@ func (p *SingleDistributeHis) ClearLock(ctx *gin.Context, mid int64) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *SingleDistributeHis) GetById(ctx *gin.Context, id string) (*dbstruct.SingleDistributeHis, error) {
|
||||||
|
list, err := p.store.GetSingleDistributeHisById(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("GetSingleDistributeHisList fail, err: %v", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return list, nil
|
||||||
|
}
|
||||||
|
|
|
@ -3799,3 +3799,33 @@ func (v *Vas) UnilaterallyWithdrawReverse(ctx *gin.Context, orderId string) (err
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 单侧提现完成
|
||||||
|
func (v *Vas) UnilaterallyWithdrawAccomplish(ctx *gin.Context, orderId string) (err error) {
|
||||||
|
|
||||||
|
// 开启事务
|
||||||
|
tx, err := v.store.VasBegin(ctx)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("vas begin fail, err: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("global err, err: %v", err)
|
||||||
|
}
|
||||||
|
errTx := v.store.DealTxCR(tx, err)
|
||||||
|
if errTx != nil {
|
||||||
|
logger.Error("DealTxCR fail, err: %v", errTx)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// 更改提现订单状态
|
||||||
|
err = v.store.UpdateWithdrawOrderStatus(ctx, tx, orderId, dbstruct.VasWithdrawOrderStatusWaitHvyogoDeal, dbstruct.VasWithdrawOrderStatusDeal)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("UpdateWithdrawOrderStatus fail, orderId: %v, err: %v", orderId, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
|
@ -4181,7 +4181,7 @@ func (s *Service) SaveSingleDistributeCallback(ctx *gin.Context, req *hvyogoprot
|
||||||
ec = errcode.ErrCodeHvyogoSrvOk
|
ec = errcode.ErrCodeHvyogoSrvOk
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// 解密AES
|
// 解密AES
|
||||||
bytes, err := hex.DecodeString(strings.ToLower(req.BusinessBody))
|
bytes, err := hex.DecodeString(strings.ToLower(req.BusinessBody))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -4204,16 +4204,21 @@ func (s *Service) SaveSingleDistributeCallback(ctx *gin.Context, req *hvyogoprot
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func () {
|
// 获取记录
|
||||||
if err != nil{
|
singleDistributeHis, err := _DefaultSingleDistributeHis.GetById(ctx, vo.RequestNo)
|
||||||
|
if err != nil {
|
||||||
}
|
logger.Error("_DefaultSingleDistributeHis GetById fail, req: %v, err: %v", util.ToJson(req), err)
|
||||||
}()
|
ec = errcode.ErrCodeSingleDistributeHisSrvFail
|
||||||
|
return
|
||||||
if vo.DistributeStatus !=
|
}
|
||||||
|
if singleDistributeHis == nil {
|
||||||
|
logger.Error("No single distribute his entity was found, req: %v", util.ToJson(req))
|
||||||
|
ec = errcode.ErrCodeSingleDistributeHisNotExist
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 更新数据
|
// 更新数据
|
||||||
err = _DefaultSingleDistributeHis.OpUpdate(ctx, &single_distribute_his_proto.OpUpdateReq{
|
_ = _DefaultSingleDistributeHis.OpUpdate(ctx, &single_distribute_his_proto.OpUpdateReq{
|
||||||
SingleDistributeHis: &dbstruct.SingleDistributeHis{
|
SingleDistributeHis: &dbstruct.SingleDistributeHis{
|
||||||
Id: goproto.String(vo.RequestNo),
|
Id: goproto.String(vo.RequestNo),
|
||||||
DistributeId: goproto.String(vo.DistributeId),
|
DistributeId: goproto.String(vo.DistributeId),
|
||||||
|
@ -4225,15 +4230,23 @@ func (s *Service) SaveSingleDistributeCallback(ctx *gin.Context, req *hvyogoprot
|
||||||
ReasonCode: goproto.String(vo.ReasonCode),
|
ReasonCode: goproto.String(vo.ReasonCode),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if err == qmgo.ErrNoSuchDocuments {
|
|
||||||
logger.Error("_DefaultSingleDistributeHis OpUpdate fail, req: %v, err: %v", util.ToJson(req), err)
|
switch vo.DistributeStatus {
|
||||||
ec = errcode.ErrCodeSingleDistributeHisNotExist
|
case consts.HygSingleDistribute_Success:
|
||||||
return
|
err = _DefaultVas.UnilaterallyWithdrawAccomplish(ctx, singleDistributeHis.GetOrderId())
|
||||||
}
|
// 因为整个打款流程已经正常结束,所以这里的err不能够令其返回2次触发回调,打印出信息即可
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("_DefaultSingleDistributeHis OpUpdate fail, req: %v, err: %v", util.ToJson(req), err)
|
logger.Error("_DefaultVas UnilaterallyWithdrawAccomplish fail, err: %v", err)
|
||||||
ec = errcode.ErrCodeSingleDistributeHisSrvFail
|
}
|
||||||
return
|
logger.Info("Single distribution accomplished, orderId :%v", singleDistributeHis.GetOrderId())
|
||||||
|
case consts.HygSingleDistribute_Fail, consts.HygSingleDistribute_Refunded, consts.HygSingleDistribute_TicketRefunded:
|
||||||
|
err = _DefaultVas.UnilaterallyWithdrawReverse(ctx, singleDistributeHis.GetOrderId())
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("_DefaultVas UnilaterallyWithdrawReverse fail, err: %v", err)
|
||||||
|
}
|
||||||
|
logger.Info("Single distribution reversed, orderId :%v", singleDistributeHis.GetOrderId())
|
||||||
|
default:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
@ -12,7 +12,7 @@ type SingleDistributeHis struct {
|
||||||
Timestamp *string `json:"timestamp" bson:"timestamp"` // 下单时间
|
Timestamp *string `json:"timestamp" bson:"timestamp"` // 下单时间
|
||||||
Remark *string `json:"remark" bson:"remark"` // 银行返回打款备注
|
Remark *string `json:"remark" bson:"remark"` // 银行返回打款备注
|
||||||
ReasonCode *string `json:"reason_code" bson:"reason_code"` // 余额不足时会返回E00001
|
ReasonCode *string `json:"reason_code" bson:"reason_code"` // 余额不足时会返回E00001
|
||||||
OrderId *string `json:"order_id" bson:""order_id` // 订单号
|
OrderId *string `json:"order_id" bson:"order_id"` // 订单号
|
||||||
Ct *int64 `json:"ct" bson:"ct"` // 创建时间
|
Ct *int64 `json:"ct" bson:"ct"` // 创建时间
|
||||||
Ut *int64 `json:"ut" bson:"ut"` // 更新时间
|
Ut *int64 `json:"ut" bson:"ut"` // 更新时间
|
||||||
DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记
|
DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记
|
||||||
|
@ -24,3 +24,10 @@ func (p *SingleDistributeHis) GetId() string {
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *SingleDistributeHis) GetOrderId() string {
|
||||||
|
if p != nil && p.OrderId != nil {
|
||||||
|
return *p.OrderId
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue