first commit
This commit is contained in:
153
api/controller/payController.go
Normal file
153
api/controller/payController.go
Normal file
@@ -0,0 +1,153 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"xiawan/wx/api/req"
|
||||
"xiawan/wx/api/service"
|
||||
"xiawan/wx/api/vo"
|
||||
"xiawan/wx/clientsdk/baseinfo"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GetBandCardListApi 获取银行卡信息
|
||||
func GetBandCardListApi(ctx *gin.Context) {
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
//确保每次都有Key
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
|
||||
result := service.GetBandCardListService(queryKey)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GeneratePayQCodeApi 生成自定义收款二维码
|
||||
func GeneratePayQCodeApi(ctx *gin.Context) {
|
||||
reqModel := new(req.GeneratePayQCodeModel)
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
//确保每次都有Key
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
result := service.GeneratePayQCodeService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// CollectMoneyApi 确定收款
|
||||
func CollectMoneyApi(ctx *gin.Context) {
|
||||
reqModel := new(req.CollectmoneyModel)
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
//确保每次都有Key
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
result := service.CollectMoneyService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// WXCreateRedPacketApi 创建红包
|
||||
func WXCreateRedPacketApi(ctx *gin.Context) {
|
||||
reqModel := new(baseinfo.RedPacket)
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
//确保每次都有Key
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
result := service.WXCreateRedPacketService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// OpenRedEnvelopesApi 拆红包
|
||||
func OpenRedEnvelopesApi(ctx *gin.Context) {
|
||||
reqModel := new(baseinfo.HongBaoItem)
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
//确保每次都有Key
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
result := service.OpenRedEnvelopesService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// QueryRedEnvelopesDetailApi 查看红包详情
|
||||
func QueryRedEnvelopesDetailApi(ctx *gin.Context) {
|
||||
reqModel := new(baseinfo.HongBaoItem)
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
//确保每次都有Key
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
result := service.QueryRedEnvelopesDetailService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// GetRedPacketListApi 查看红包领取列表
|
||||
func GetRedPacketListApi(ctx *gin.Context) {
|
||||
reqModel := new(baseinfo.GetRedPacketList)
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
//确保每次都有Key
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
result := service.GetRedPacketListService(queryKey, *reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// CreatePreTransferApi 创建转账
|
||||
func CreatePreTransferApi(ctx *gin.Context) {
|
||||
reqModel := new(req.CreatePreTransfer)
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
//确保每次都有Key
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
result := service.CreatePreTransferService(queryKey, reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// ConfirmPreTransferApi 确认转账(客户端版本过低会无法转账)
|
||||
func ConfirmPreTransferApi(ctx *gin.Context) {
|
||||
reqModel := new(req.ConfirmPreTransfer)
|
||||
queryKey, isExist := ctx.GetQuery("key")
|
||||
if !isExist || strings.Trim(queryKey, "") == "" || strings.Trim(queryKey, "") == "null" {
|
||||
//确保每次都有Key
|
||||
ctx.JSON(http.StatusOK, vo.NewFailUUId(""))
|
||||
return
|
||||
}
|
||||
if !validateData(ctx, &reqModel) {
|
||||
return
|
||||
}
|
||||
result := service.ConfirmPreTransferService(queryKey, reqModel)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
Reference in New Issue
Block a user