fix:修复上传

This commit is contained in:
Hiven 2023-08-10 14:58:33 +08:00
parent db5b576799
commit 5f1a07f737
5 changed files with 16 additions and 13 deletions

View File

@ -76,16 +76,17 @@ func (l *UserOrderCancelLogic) UserOrderCancel(req *types.UserOrderCancelReq, us
var nowTime = time.Now().Unix()
var payList []handlers.PayInfo
// 事务处理
err = orderModel.Trans(l.ctx, func(ctx context.Context, connGorm *gorm.DB) (err error) {
ctx := l.ctx
err = l.svcCtx.MysqlConn.Transaction(func(tx *gorm.DB) error {
// 修改订单信息
orderModelTS := gmodel.NewFsOrderModel(connGorm)
orderModelTS := gmodel.NewFsOrderModel(tx)
err = orderModelTS.Update(ctx, orderInfo)
if err != nil {
return err
}
// 新增退款记录
var isRefund int64 = 0
refundReasonModelTS := gmodel.NewFsRefundReasonModel(connGorm)
refundReasonModelTS := gmodel.NewFsRefundReasonModel(tx)
refundReasonModelTS.CreateOrUpdate(ctx, &gmodel.FsRefundReason{
IsRefund: &isRefund,
RefundReasonId: &req.RefundReasonId,
@ -95,7 +96,7 @@ func (l *UserOrderCancelLogic) UserOrderCancel(req *types.UserOrderCancelReq, us
})
// 退款申请
// 退款申请--查询支付信息
fsPayModelTS := gmodel.NewFsPayModel(connGorm)
fsPayModelTS := gmodel.NewFsPayModel(tx)
rbFsPay := fsPayModelTS.RowSelectBuilder(nil).Where("order_number = ?", orderInfo.Sn).Where("pay_status =?", constants.PAYSTATUS_SUCCESS).Where("is_refund =?", 0)
payInfoList, err := fsPayModelTS.FindAll(ctx, rbFsPay, nil, "")
if err != nil {

View File

@ -107,7 +107,8 @@ func (l *OrderPaymentIntentLogic) OrderPaymentIntent(req *types.OrderPaymentInte
var resData types.OrderPaymentIntentRes
// 事务处理
err = orderModel.Trans(l.ctx, func(ctx context.Context, connGorm *gorm.DB) error {
ctx := l.ctx
err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
// 支付记录--处理 //支付记录改为一条订单多条,分首款尾款
var payStatus int64 = 0
var orderSource int64 = 1

View File

@ -153,13 +153,13 @@ func (l *StripeWebhookLogic) HandlePayEventCreate(fsPayEvent *gmodel.FsPayEvent)
func (l *StripeWebhookLogic) HandleChargeRefunded(chargeRefunded *stripe.Charge) (err error) {
// 退款成功
if chargeRefunded.Status == "succeeded" {
orderModel := gmodel.NewFsOrderModel(l.svcCtx.MysqlConn)
err = orderModel.Trans(l.ctx, func(ctx context.Context, connGorm *gorm.DB) (err error) {
ctx := l.ctx
err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
// 查询支付记录
payModelT := gmodel.NewFsPayModel(connGorm)
payModelTRSB := payModelT.RowSelectBuilder(nil)
payModelTRSB1 := payModelTRSB.Where("trade_no = ?", chargeRefunded.PaymentIntent.ID).Where("pay_status = ?", constants.PAYSTATUS_SUCCESS).Where("is_refund = ?", 0)
payInfo, err := payModelT.FindOneByQuery(l.ctx, payModelTRSB1, nil)
payInfo, err := payModelT.FindOneByQuery(ctx, payModelTRSB1, nil)
if err != nil {
return err
}
@ -295,7 +295,8 @@ func (l *StripeWebhookLogic) HandlePaymentIntentSucceeded(paymentIntent *stripe.
}
}
err = orderModel.Trans(l.ctx, func(ctx context.Context, connGorm *gorm.DB) (err error) {
ctx := l.ctx
err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
// 更新支付信息
payModelT := gmodel.NewFsPayModel(connGorm)
*payInfo.PayStatus = 1

View File

@ -64,8 +64,8 @@ func (l *UploadCallbackLogic) UploadCallback(req *types.UploadCallbackReq, useri
bucketName = basic.StorageBucketName
}
resourceModel := gmodel.NewFsResourceModel(l.svcCtx.MysqlConn)
err := resourceModel.Trans(l.ctx, func(ctx context.Context, connGorm *gorm.DB) (err error) {
ctx := l.ctx
err := l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
resourceModelTS := gmodel.NewFsResourceModel(l.svcCtx.MysqlConn)
resourceInfo, err := resourceModelTS.FindOneById(ctx, req.ResourceId)
if err != nil {

View File

@ -163,8 +163,8 @@ func (upload *Upload) UploadFileByByte(req *UploadBaseReq) (*UploadBaseRes, erro
var resourceId string = req.FileHash
var uploadBaseRes = UploadBaseRes{}
resourceModel := gmodel.NewFsResourceModel(upload.MysqlConn)
err := resourceModel.Trans(upload.Ctx, func(ctx context.Context, connGorm *gorm.DB) error {
ctx := upload.Ctx
err := upload.MysqlConn.Transaction(func(connGorm *gorm.DB) error {
resourceModelTS := gmodel.NewFsResourceModel(connGorm)
resourceInfo, err := resourceModelTS.FindOneById(ctx, resourceId)
if err == nil && resourceInfo.ResourceId != "" {