Order订单待测试
This commit is contained in:
@@ -13,6 +13,9 @@ import (
|
||||
"fusenapi/server/home-user-auth/internal/svc"
|
||||
"fusenapi/server/home-user-auth/internal/types"
|
||||
|
||||
"github.com/stripe/stripe-go/v74"
|
||||
"github.com/stripe/stripe-go/v74/client"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -104,27 +107,40 @@ func (l *UserOderDeleteLogic) UserOderDelete(req *types.RequestOrderId, userinfo
|
||||
CreatedAt: &CreatedAt,
|
||||
}
|
||||
|
||||
mFsRefund := gmodel.NewFsRefundReasonModel(l.svcCtx.MysqlConn)
|
||||
|
||||
err = refund.Save()
|
||||
mFsRefundReason := gmodel.NewFsRefundReasonModel(l.svcCtx.MysqlConn)
|
||||
err = mFsRefundReason.Create(l.ctx, refund)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatus(basic.CodeDbSqlErr)
|
||||
}
|
||||
|
||||
// 退款
|
||||
// 调用第三方接口发起退款
|
||||
config := GetStripeConfig()
|
||||
|
||||
config := &stripe.BackendConfig{
|
||||
MaxNetworkRetries: stripe.Int64(0), // Zero retries
|
||||
}
|
||||
|
||||
sc := &client.API{}
|
||||
sc.Init(l.svcCtx.Config.Stripe.SK, &stripe.Backends{
|
||||
API: stripe.GetBackendWithConfig(stripe.APIBackend, config),
|
||||
Uploads: stripe.GetBackendWithConfig(stripe.UploadsBackend, config),
|
||||
})
|
||||
// ['order_number' => $order->sn, 'is_refund' => 0, 'pay_status' => 1]
|
||||
pay := gmodel.NewFsPayModel(l.svcCtx.MysqlConn)
|
||||
|
||||
// 查询支付信息
|
||||
pays, err := Pay.Find(db.Where("order_number = ? AND is_refund = ? AND pay_status = ?", order.SN, 0, 1))
|
||||
pays, err := pay.GetOrderPayList(l.ctx, *order.Sn, 1, 0)
|
||||
for _, pay := range pays {
|
||||
stripe := stripe.New(config.SK)
|
||||
_, err := stripe.Refunds.Create(stripe.RefundParams{
|
||||
sc.Refunds.New(&stripe.RefundParams{
|
||||
PaymentIntent: pay.TradeNo,
|
||||
})
|
||||
}
|
||||
|
||||
if err == nil && err == nil {
|
||||
return ResponseSuccess(200, "Cancel successfully", order)
|
||||
}
|
||||
return ResponseError(500, "Cancellation failure")
|
||||
// if err == nil && err == nil {
|
||||
// return ResponseSuccess(200, "Cancel successfully", order)
|
||||
// }
|
||||
// return ResponseError(500, "Cancellation failure")
|
||||
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user