syntax = "v1"

info (
	title:   "支付服务"
	desc:    "支付服务"
	version: "v1"
)

@server (
	prefix: api/v1
	group:  pay
)
service main {
	// 微信支付回调
	@handler WechatPayCallback
	post /pay/wechat/callback

	// 支付宝支付回调
	@handler AlipayCallback
	post /pay/alipay/callback

	// 微信退款回调
	@handler WechatPayRefundCallback
	post /pay/wechat/refund_callback

	// 易支付回调
	@handler EasyPayCallback
	get /pay/easypay/callback

	// 云印签支付回调
	@handler YunYinSignPayCallback
	post /pay/yunyinsign/callback
}

@server (
	prefix:     api/v1
	group:      pay
	jwt:        JwtAuth
	middleware: AuthInterceptor
)
service main {
	// 支付
	@handler Payment
	post /pay/payment (PaymentReq) returns (PaymentResp)

	@handler IapCallback
	post /pay/iap_callback (IapCallbackReq)

	@handler PaymentCheck
	post /pay/check (PaymentCheckReq) returns (PaymentCheckResp)

	// 云印签退款
	@handler YunYinSignPayRefund
	post /pay/yunyinsign/refund (YunYinSignPayRefundReq) returns (YunYinSignPayRefundResp)
}

type (
	PaymentReq {
		Id        string `json:"id"`
		PayMethod string `json:"pay_method"` // 支付方式: wechat, alipay, easypay_alipay, appleiap, yunyinSignPay, yunyinSignPay_wechat, yunyinSignPay_alipay, test(仅开发环境), test_empty(仅开发环境-空报告模式)
		// 系统简化：移除 agent_vip, agent_upgrade 支付类型
		PayType   string `json:"pay_type" validate:"required,oneof=query"`
	}
	PaymentResp {
		PrepayData interface{} `json:"prepay_data"`
		PrepayId   string      `json:"prepay_id"`
		OrderNo    string      `json:"order_no"`
	}
	PaymentCheckReq {
		OrderNo string `json:"order_no" validate:"required"`
	}
	PaymentCheckResp {
		Type   string `json:"type"`
		Status string `json:"status"`
	}
)

type (
	IapCallbackReq {
		OrderID            string `json:"order_id" validate:"required"`
		TransactionReceipt string `json:"transaction_receipt" validate:"required"`
	}
	YunYinSignPayRefundReq {
		OrderNo       string  `json:"order_no"`                 // 订单号（sourceOrderCode），与 participate_id 二选一
		ParticipateId int64   `json:"participate_id,omitempty"` // 参与方ID，与 order_no 二选一
		RefundAmount  float64 `json:"refund_amount" validate:"required,gt=0"` // 退款金额，必须大于0
		RefundReason  string  `json:"refund_reason,omitempty"` // 退款原因
	}
	YunYinSignPayRefundResp {
		Success bool   `json:"success"`
		Message string `json:"message"`
	}
)

