diff --git a/.gitea/workflows/docker.yml b/.gitea/workflows/docker.yml index 4cfa1c1..0ef9071 100644 --- a/.gitea/workflows/docker.yml +++ b/.gitea/workflows/docker.yml @@ -21,7 +21,7 @@ env: SSH_PASSWORD: ${{ github.ref_name == 'main' && vars.SSH_PASSWORD || vars.DEV_SSH_PASSWORD }} # TG通知 TG_BOT_TOKEN: 8114337882:AAHkEx03HSu7RxN4IHBJJEnsK9aPPzNLIk0 - TG_CHAT_ID: "-49402438031" + TG_CHAT_ID: "-4940243803" # Go构建变量 SERVICE: vpn SERVICE_STYLE: vpn diff --git a/apis/types.api b/apis/types.api index 8f60427..f2fd38f 100644 --- a/apis/types.api +++ b/apis/types.api @@ -405,6 +405,7 @@ type ( CouponDiscount int64 `json:"coupon_discount"` Commission int64 `json:"commission,omitempty"` Payment PaymentMethod `json:"payment"` + Method string `json:"method"` FeeAmount int64 `json:"fee_amount"` TradeNo string `json:"trade_no"` Status uint8 `json:"status"` diff --git a/internal/logic/admin/order/createOrderLogic.go b/internal/logic/admin/order/createOrderLogic.go index 32abeaf..cb1c82f 100644 --- a/internal/logic/admin/order/createOrderLogic.go +++ b/internal/logic/admin/order/createOrderLogic.go @@ -45,7 +45,7 @@ func (l *CreateOrderLogic) CreateOrder(req *types.CreateOrderRequest) error { Coupon: req.Coupon, CouponDiscount: req.CouponDiscount, PaymentId: req.PaymentId, - Method: paymentMethod.Token, + Method: normalizeOrderMethod("", paymentMethod.Platform), FeeAmount: req.FeeAmount, TradeNo: req.TradeNo, Status: req.Status, diff --git a/internal/logic/admin/order/getOrderListLogic.go b/internal/logic/admin/order/getOrderListLogic.go index cdf9da6..22c04b2 100644 --- a/internal/logic/admin/order/getOrderListLogic.go +++ b/internal/logic/admin/order/getOrderListLogic.go @@ -35,6 +35,15 @@ func (l *GetOrderListLogic) GetOrderList(req *types.GetOrderListRequest) (resp * resp = &types.GetOrderListResponse{} resp.List = make([]types.Order, 0) tool.DeepCopy(&resp.List, list) + for index := range resp.List { + resp.List[index].Method = normalizeOrderMethod(resp.List[index].Method, resp.List[index].Payment.Platform) + if resp.List[index].Payment.Platform == "" { + resp.List[index].Payment.Platform = resp.List[index].Method + } + if resp.List[index].Payment.Name == "" { + resp.List[index].Payment.Name = resp.List[index].Method + } + } resp.Total = total return } diff --git a/internal/logic/admin/order/method.go b/internal/logic/admin/order/method.go new file mode 100644 index 0000000..5f281e9 --- /dev/null +++ b/internal/logic/admin/order/method.go @@ -0,0 +1,30 @@ +package order + +import ( + "strings" + + paymentPlatform "github.com/perfect-panel/server/pkg/payment" +) + +func canonicalOrderMethod(method string) string { + method = strings.TrimSpace(method) + if method == "" { + return "" + } + + platform := paymentPlatform.ParsePlatform(method) + if platform == paymentPlatform.UNSUPPORTED { + return "" + } + return platform.String() +} + +func normalizeOrderMethod(orderMethod string, paymentMethod string) string { + if method := canonicalOrderMethod(paymentMethod); method != "" { + return method + } + if method := canonicalOrderMethod(orderMethod); method != "" { + return method + } + return "unknown" +} diff --git a/internal/logic/public/user/bindEmailWithVerificationLogic.go b/internal/logic/public/user/bindEmailWithVerificationLogic.go index f2b910c..c6cef3d 100644 --- a/internal/logic/public/user/bindEmailWithVerificationLogic.go +++ b/internal/logic/public/user/bindEmailWithVerificationLogic.go @@ -112,20 +112,26 @@ func (l *BindEmailWithVerificationLogic) BindEmailWithVerification(req *types.Bi return nil, errors.Wrapf(xerr.NewErrCode(xerr.FamilyAlreadyBound), "email already bound to current user") } - mergeHelper := newAccountMergeHelper(l.ctx, l.svcCtx) - if _, err = mergeHelper.mergeIntoOwner(existingMethod.UserId, u.Id, "bind_email_with_verification"); err != nil { + if err = familyHelper.validateJoinFamily(existingMethod.UserId, u.Id); err != nil { return nil, err } - token, err := l.refreshBindSessionToken(existingMethod.UserId) + joinResult, err := familyHelper.joinFamily(existingMethod.UserId, u.Id, "bind_email_with_verification") + if err != nil { + return nil, err + } + token, err := l.refreshBindSessionToken(u.Id) if err != nil { return nil, err } return &types.BindEmailWithVerificationResponse{ - Success: true, - Message: "email bound successfully", - Token: token, - UserId: existingMethod.UserId, + Success: true, + Message: "joined family successfully", + Token: token, + UserId: u.Id, + FamilyJoined: true, + FamilyId: joinResult.FamilyId, + OwnerUserId: joinResult.OwnerUserId, }, nil } diff --git a/internal/types/types.go b/internal/types/types.go index 7eeca2c..2dd1684 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -1433,6 +1433,7 @@ type Order struct { CouponDiscount int64 `json:"coupon_discount"` Commission int64 `json:"commission,omitempty"` Payment PaymentMethod `json:"payment"` + Method string `json:"method"` FeeAmount int64 `json:"fee_amount"` TradeNo string `json:"trade_no"` Status uint8 `json:"status"`