41 lines
1.4 KiB
Go
41 lines
1.4 KiB
Go
package controller
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
commonHttp "slogan-agent/common"
|
|
"slogan-agent/styleagent/model/dto"
|
|
"slogan-agent/styleagent/service"
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
)
|
|
|
|
// OrderCreate 下单 → 返回支付 URL
|
|
func (c *member) OrderCreate(ctx context.Context, req *dto.MemberOrderCreateReq) (res *dto.MemberOrderCreateRes, err error) {
|
|
return service.PaymentOrderService.CreateMemberOrder(ctx, commonHttp.GetUserId(g.RequestFromCtx(ctx)), req.PlanId)
|
|
}
|
|
|
|
// OrderStatus 订单状态(App 轮询)
|
|
func (c *member) OrderStatus(ctx context.Context, req *dto.MemberOrderStatusReq) (res *dto.MemberOrderStatusRes, err error) {
|
|
return service.PaymentOrderService.OrderStatus(ctx, req.OrderNo)
|
|
}
|
|
|
|
// Notify 虎皮棋支付回调:验签/幂等开通在 service,此处仅做 HTTP 协议职责——读取回调参数、
|
|
// 直接写裸文本响应体(虎皮棋要求字面 "success",不走统一 JSON 包装,属"直接写响应体"例外)
|
|
func (c *member) Notify(ctx context.Context, req *dto.MemberNotifyReq) (res *dto.MemberNotifyRes, err error) {
|
|
r := g.RequestFromCtx(ctx)
|
|
body := r.GetBodyString()
|
|
remoteIP := r.GetClientIp()
|
|
|
|
params := make(map[string]string)
|
|
for k, v := range r.GetRequestMap() {
|
|
params[k] = fmt.Sprint(v)
|
|
}
|
|
text := service.PaymentOrderService.HandleNotify(ctx, params, body, remoteIP)
|
|
|
|
r.Response.Write(text)
|
|
r.ExitAll()
|
|
return nil, nil
|
|
}
|