forked from all_user/stat_center
Initial commit
This commit is contained in:
@@ -0,0 +1,240 @@
|
||||
package channelApi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"stat/api/proto"
|
||||
"stat/common/stdLog"
|
||||
"stat/common/utils"
|
||||
"stat/models/adminMod"
|
||||
"stat/service/channelSer"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 渠道管理
|
||||
// @Summary 分组分页获取渠道管理
|
||||
// @Description 分组分页获取渠道管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.ChannelInfoSearch true "参数列表"
|
||||
// @Success 200 {object} proto.ChannelInfoSearchResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/channelInfo/list [POST]
|
||||
func GetChannelInfo(ctx *gin.Context) {
|
||||
var req = &proto.ChannelInfoSearch{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
resp, serr := channelSer.SearchChannelInfo(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 渠道管理
|
||||
// @Summary 分组分页获取渠道列表导出
|
||||
// @Description 分组分页获取渠道列表导出
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.ChannelInfoSearch true "参数列表"
|
||||
// @Success 200 {object} proto.ChannelInfoSearchResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/channelInfo/export [POST]
|
||||
func GetChannelInfoExport(ctx *gin.Context) {
|
||||
var req = &proto.ChannelInfoSearch{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
fPath, serr := channelSer.SearchChannelInfoExport(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
ctx.Writer.WriteHeader(http.StatusOK)
|
||||
ctx.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filepath.Base(fPath)))
|
||||
ctx.Header("Content-Type", "application/octet-stream")
|
||||
ctx.File(fPath)
|
||||
}
|
||||
|
||||
// @Tags 渠道管理
|
||||
// @Summary 添加一个渠道管理
|
||||
// @Description 添加一个渠道管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.ChannelInfoAdd true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/channelInfo/add [POST]
|
||||
func AddOneChannelInfo(ctx *gin.Context) {
|
||||
var req = &proto.ChannelInfoAdd{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil || account == "" {
|
||||
stdLog.ServerJSON(ctx, stdLog.NoToken, err)
|
||||
return
|
||||
}
|
||||
|
||||
adminInfo, err := adminMod.FindOneByAccount(ctx, account)
|
||||
if err != nil || adminInfo.Account == "" {
|
||||
stdLog.ServerJSON(ctx, stdLog.AdminAccountNotExists, err)
|
||||
return
|
||||
}
|
||||
|
||||
resp, serr := channelSer.AddChannelInfo(ctx, adminInfo.Name, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 渠道管理
|
||||
// @Summary 删除一个渠道管理
|
||||
// @Description 删除一个渠道管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.ChannelInfoDelete true "参数列表"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/channelInfo/del [POST]
|
||||
func DelOneChannelInfo(ctx *gin.Context) {
|
||||
var req = &proto.ChannelInfoDelete{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
serr := channelSer.DelChannelInfo(ctx, req.ID)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 渠道管理
|
||||
// @Summary 更新一个渠道管理
|
||||
// @Description 更新一个渠道管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.ChannelInfoUpdate true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/channelInfo/update [POST]
|
||||
func UpdateOneChannelInfo(ctx *gin.Context) {
|
||||
var req = &proto.ChannelInfoUpdate{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, nil)
|
||||
return
|
||||
}
|
||||
serr := channelSer.UpdateChannelInfo(ctx, req.ID, *req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 渠道管理
|
||||
// @Summary 获取用户信息
|
||||
// @Description 获取用户信息
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.UserInfoSearch true "参数列表"
|
||||
// @Success 200 {object} registermod.RegisterMod "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/user/info [POST]
|
||||
func SearchUserInfo(ctx *gin.Context) {
|
||||
var req = &proto.UserInfoSearch{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
resp, serr := channelSer.SearchUserInfo(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 渠道管理
|
||||
// @Summary 更新一个渠道管理的所有者
|
||||
// @Description 更新一个渠道管理的所有者
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.ChannelOwnerUpdate true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/channelInfo/owner/update [POST]
|
||||
func UpdateOneChannelOwner(ctx *gin.Context) {
|
||||
var req = &proto.ChannelOwnerUpdate{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil || account == "" {
|
||||
stdLog.ServerJSON(ctx, stdLog.NoToken, err)
|
||||
return
|
||||
}
|
||||
|
||||
adminInfo, err := adminMod.FindOneByAccount(ctx, account)
|
||||
if err != nil || adminInfo.Account == "" {
|
||||
stdLog.ServerJSON(ctx, stdLog.AdminAccountNotExists, err)
|
||||
return
|
||||
}
|
||||
|
||||
serr := channelSer.UpdateOneChannelOwner(ctx, adminInfo.Name, adminInfo.Account, *req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 渠道管理
|
||||
// @Summary 渠道所有者变更信息
|
||||
// @Description 渠道所有者变更信息
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.ChannelOwnerChangeInfoSearch true "参数列表"
|
||||
// @Success 200 {object} proto.ChannelOwnerChangeInfoSearchResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/channelInfo/ownerchange/list [POST]
|
||||
func SearchChannelOwnerChange(ctx *gin.Context) {
|
||||
var req = &proto.ChannelOwnerChangeInfoSearch{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
resp, serr := channelSer.SearchChannelOwnerChangeInfo(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package channelApi
|
||||
|
||||
import (
|
||||
"stat/api/proto"
|
||||
"stat/common/stdLog"
|
||||
"stat/service/channelSer"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 渠道管理
|
||||
// @Summary 获取渠道扣量规则列表
|
||||
// @Description 获取渠道扣量规则列表
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.ChannelDeductionRuleSearch true "参数列表"
|
||||
// @Success 200 {object} proto.ChannelDeductionRuleSearchResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/channelRule/list [POST]
|
||||
func GetChannelDeductionRule(ctx *gin.Context) {
|
||||
var req = &proto.ChannelDeductionRuleSearch{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
resp, serr := channelSer.SearchChannelDeductionRule(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 渠道管理
|
||||
// @Summary 添加一个渠道管理
|
||||
// @Description 添加一个渠道管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.ChannelDeductionRuleAdd true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/channelRule/add [POST]
|
||||
func AddOneChannelDeductionRule(ctx *gin.Context) {
|
||||
var req = &proto.ChannelDeductionRuleAdd{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
resp, serr := channelSer.AddChannelDeductionRule(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 渠道管理
|
||||
// @Summary 删除一个渠道管理
|
||||
// @Description 删除一个渠道管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.ChannelDeductionRuleDelete true "参数列表"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/channelRule/del [POST]
|
||||
func DelOneChannelDeductionRule(ctx *gin.Context) {
|
||||
var req = &proto.ChannelDeductionRuleDelete{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
serr := channelSer.DelChannelDeductionRule(ctx, req.ID)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 渠道管理
|
||||
// @Summary 更新一个渠道管理
|
||||
// @Description 更新一个渠道管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.ChannelDeductionRuleUpdate true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/channelRule/update [POST]
|
||||
func UpdateOneChannelDeductionRule(ctx *gin.Context) {
|
||||
var req = &proto.ChannelDeductionRuleUpdate{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, nil)
|
||||
return
|
||||
}
|
||||
serr := channelSer.UpdateChannelDeductionRule(ctx, req.ID, *req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,364 @@
|
||||
package channelApi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"stat/api/proto"
|
||||
"stat/common/stdLog"
|
||||
"stat/common/utils"
|
||||
"stat/middleware/define"
|
||||
"stat/service/channelSer"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 渠道结算
|
||||
// @Summary 分组分页获取渠道结算
|
||||
// @Description 分组分页获取渠道结算
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.SettlementInfoSearch true "参数列表"
|
||||
// @Success 200 {object} proto.SettlementInfoSearchResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/settlementinfo/list [POST]
|
||||
func GetSearchSettlementInfo(ctx *gin.Context) {
|
||||
var req = &proto.SettlementInfoSearch{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
resp, serr := channelSer.SearchSettlementInfo(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 渠道结算
|
||||
// @Summary 分组分页获取渠道结算申请表(渠道账号看的)
|
||||
// @Description 分组分页获取渠道结算申请表(渠道账号看的)
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.GetApplyFormReq true "参数列表"
|
||||
// @Success 200 {object} proto.GetApplyFormResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/agent/channel/applies [POST]
|
||||
func GetApplyForm(ctx *gin.Context) {
|
||||
var req = &proto.GetApplyFormReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, err.Error())
|
||||
}
|
||||
accType, err := utils.GetAccountType(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, err.Error())
|
||||
}
|
||||
if accType != define.Channel {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, fmt.Errorf("代理账号才可以查看"))
|
||||
}
|
||||
resp, serr := channelSer.SearchApplyForm(ctx, req, account)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 渠道结算
|
||||
// @Summary 获取结算申请人名字列表
|
||||
// @Description 获取结算申请人名字列表
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.GetSettlementApplicantListReq true "参数列表"
|
||||
// @Success 200 {object} proto.GetSettlementApplicantListResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/settlementinfo/applicant/list [POST]
|
||||
func GetSettlementApplicantList(ctx *gin.Context) {
|
||||
var req = &proto.GetSettlementApplicantListReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
resp, serr := channelSer.GetSettlementApplicantList(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 渠道结算
|
||||
// @Summary 分组分页获取渠道结算已删除列表
|
||||
// @Description 分组分页获取渠道结算已删除列表
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.SettlementInfoSearch true "参数列表"
|
||||
// @Success 200 {object} proto.SettlementInfoSearchResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/settlementinfo/deleted/list [POST]
|
||||
func GetSearchDeletedSettlementInfo(ctx *gin.Context) {
|
||||
var req = &proto.SettlementInfoSearch{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
resp, serr := channelSer.SearchDeletedSettlementInfo(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 渠道结算
|
||||
// @Summary 分组分页获取渠道结算导出
|
||||
// @Description 分组分页获取渠道结算导出
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.SettlementInfoSearch true "参数列表"
|
||||
// @Success 200 {object} proto.SettlementInfoSearchResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/settlementinfo/export [POST]
|
||||
func GetSearchSettlementInfoExport(ctx *gin.Context) {
|
||||
var req = &proto.SettlementInfoSearch{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
fPath, serr := channelSer.SearchSettlementInfoExport(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
ctx.Writer.WriteHeader(http.StatusOK)
|
||||
ctx.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filepath.Base(fPath)))
|
||||
ctx.Header("Content-Type", "application/octet-stream")
|
||||
ctx.File(fPath)
|
||||
}
|
||||
|
||||
// @Tags 渠道结算
|
||||
// @Summary 分组分页获取渠道结算申请表导出
|
||||
// @Description 分组分页获取渠道结算申请表导出
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.SettlementInfoSearch true "参数列表"
|
||||
// @Success 200 {object} proto.SettlementInfoSearchResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/settlementinfo/v2/export [POST]
|
||||
func GetSearchSettlementInfoApplyExport(ctx *gin.Context) {
|
||||
var req = &proto.SettlementInfoSearch{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
fPath, serr := channelSer.SearchSettlementInfoApplyExport(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
ctx.Writer.WriteHeader(http.StatusOK)
|
||||
ctx.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filepath.Base(fPath)))
|
||||
ctx.Header("Content-Type", "application/octet-stream")
|
||||
ctx.File(fPath)
|
||||
}
|
||||
|
||||
// @Tags 渠道结算
|
||||
// @Summary 添加一个渠道结算
|
||||
// @Description 添加一个渠道结算
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.SettlementInfoAdd true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/settlementinfo/add [POST]
|
||||
func AddOneSettlementInfo(ctx *gin.Context) {
|
||||
var req = &proto.SettlementInfoAdd{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
serr := channelSer.AddSettlementInfo(ctx, req)
|
||||
if serr != nil {
|
||||
if serr.Error() == "重复结算" {
|
||||
stdLog.ServerJSON(ctx, stdLog.SettlementDouble, serr.Error())
|
||||
} else {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 渠道结算
|
||||
// @Summary 添加一个渠道结算2
|
||||
// @Description 添加一个渠道结算2
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.SettlementInfoAdd true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/settlementinfo/v2/add [POST]
|
||||
func AddOneSettlementInfo2(ctx *gin.Context) {
|
||||
var req = &proto.SettlementInfoAdd2{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, err.Error())
|
||||
}
|
||||
accType, err := utils.GetAccountType(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, err.Error())
|
||||
}
|
||||
|
||||
serr := channelSer.AddSettlementInfo2(ctx, req, accType, account)
|
||||
if serr != nil {
|
||||
if serr.Error() == "重复结算" {
|
||||
stdLog.ServerJSON(ctx, stdLog.SettlementDouble, serr.Error())
|
||||
} else {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 渠道结算
|
||||
// @Summary 更新一个渠道结算
|
||||
// @Description 更新一个渠道结算
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.SettlementInfoUpdate true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/settlementinfo/update [POST]
|
||||
func UpdateOneSettlementInfo(ctx *gin.Context) {
|
||||
var req = &proto.SettlementInfoUpdate{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, nil)
|
||||
return
|
||||
}
|
||||
serr := channelSer.UpdateSettlementInfo(ctx, *req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 渠道结算
|
||||
// @Summary 更新一个渠道结算2
|
||||
// @Description 更新一个渠道结算2
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.SettlementInfoUpdate true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/settlementinfo/v2/update [POST]
|
||||
func UpdateOneSettlementInfo2(ctx *gin.Context) {
|
||||
var req = &proto.SettlementInfoUpdate2{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, nil)
|
||||
return
|
||||
}
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, err.Error())
|
||||
}
|
||||
accType, err := utils.GetAccountType(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, err.Error())
|
||||
}
|
||||
serr := channelSer.UpdateSettlementInfo2(ctx, *req, accType, account)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 渠道结算
|
||||
// @Summary 删除一个渠道结算项
|
||||
// @Description 删除一个渠道结算(只有特定状态的结算项可以删除)
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.SettlementInfoDelete true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/settlementinfo/v2/del [POST]
|
||||
func DelOneSettlementInfo(ctx *gin.Context) {
|
||||
var req = &proto.SettlementInfoDelete{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, nil)
|
||||
return
|
||||
}
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, err.Error())
|
||||
}
|
||||
accType, err := utils.GetAccountType(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, err.Error())
|
||||
}
|
||||
serr := channelSer.DeleteSettlementInfo(ctx, *req, accType, account)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 渠道结算
|
||||
// @Summary 查看渠道结算项的详情
|
||||
// @Description 查看渠道结算项的详情
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.SettlementInfoDetail true "参数列表"
|
||||
// @Success 200 {object} proto.SettlementInfoDetailResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/settlementinfo/v2/detail [POST]
|
||||
func DetailOneSettlementInfo(ctx *gin.Context) {
|
||||
var req = proto.SettlementInfoDetail{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, nil)
|
||||
return
|
||||
}
|
||||
resp, serr := channelSer.DetailSettlementInfo(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
package channelApi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"stat/api/proto"
|
||||
"stat/common/stdLog"
|
||||
"stat/service/channelSer"
|
||||
"stat/service/statSer"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 渠道管理
|
||||
// @Summary 获取渠道统计列表
|
||||
// @Description 获取渠道统计列表
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.ChannelStatSearch true "参数列表"
|
||||
// @Success 200 {object} proto.ChannelStatSearchResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/channelStat/list [POST]
|
||||
func GetChannelStat(ctx *gin.Context) {
|
||||
var req = &proto.ChannelStatSearch{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
resp, serr := channelSer.SearchChannelStat(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 渠道同时段对比
|
||||
// @Summary 渠道同时段对比
|
||||
// @Description 渠道同时段对比
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.SearchChannelStatComparedReq true "参数列表"
|
||||
// @Success 200 {object} proto.SearchChannelStatComparedResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/channelStat/compare/list [POST]
|
||||
func SearchChannelStatCompared(ctx *gin.Context) {
|
||||
var req = &proto.SearchChannelStatComparedReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
resp, serr := channelSer.SearchChannelStatCompared(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 渠道结算
|
||||
// @Summary 获取渠道统计信息
|
||||
// @Description 获取渠道统计信息
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.ChannelStatSettlementSearch true "参数列表"
|
||||
// @Success 200 {object} proto.ChannelStatSettlementSearchResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/channelStat/settlement/list [POST]
|
||||
func GetChannelSettlementStat(ctx *gin.Context) {
|
||||
var req = &proto.ChannelStatSettlementSearch{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
resp, serr := channelSer.SearchChannelSettlementStat(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 渠道结算
|
||||
// @Summary 获取渠道统计信息v2
|
||||
// @Description 获取渠道统计信息v2
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.ChannelStatSettlementSearch true "参数列表"
|
||||
// @Success 200 {object} proto.ChannelStatSettlementSearchResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/channelStat/settlement/v2/list [POST]
|
||||
func GetChannelSettlementStat2(ctx *gin.Context) {
|
||||
var req = &proto.ChannelStatSettlementSearch2{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
resp, serr := channelSer.SearchChannelSettlementStat2(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 渠道结算
|
||||
// @Summary 对结算页用户选择的结算项目进行计算
|
||||
// @Description 对结算页用户选择的结算项目进行计算
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.SettlementCalcReq true "参数列表"
|
||||
// @Success 200 {object} proto.SettlementCalcResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/channelStat/settlement/v2/calc [POST]
|
||||
func GetChannelSettlementCalc(ctx *gin.Context) {
|
||||
var req = &proto.SettlementCalcReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
resp, serr := channelSer.ChannelSettlementCalc(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 渠道管理
|
||||
// @Summary 分组分页获取渠道结算表
|
||||
// @Description 分组分页获取渠道结算表
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.ChannelSettlementSearch true "参数列表"
|
||||
// @Success 200 {object} proto.ChannelSettlementSearchResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/channelSettlement/list [POST]
|
||||
func GetChannelSettlement(ctx *gin.Context) {
|
||||
var req = &proto.ChannelSettlementSearch{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
resp, serr := channelSer.SearchChannelSettlement(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 日常统计
|
||||
// @Summary 渠道统计导出
|
||||
// @Description 渠道统计导出
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param param body proto.ChannelStatExportReq true "参数列表"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/channelStat/export [POST]
|
||||
func ListChannelStatExport(ctx *gin.Context) {
|
||||
param := proto.ChannelStatExportReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
fPath, serr := statSer.ChannelStatExport(ctx, param)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
ctx.Writer.WriteHeader(http.StatusOK)
|
||||
ctx.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filepath.Base(fPath)))
|
||||
ctx.Header("Content-Type", "application/octet-stream")
|
||||
ctx.File(fPath)
|
||||
}
|
||||
Reference in New Issue
Block a user