@@ -1,32 +0,0 @@ | |||
package enum | |||
type AliyunOss int32 | |||
const ( | |||
AliyunOssEndpoint = 1 | |||
AliyunOssBucketName = 2 | |||
AliyunOssBucketScheme = 3 | |||
AliyunOssAccessKeyID = 4 | |||
AliyunOssAccessKeySecret = 5 | |||
AliyunOssDomain = 6 | |||
) | |||
func (gt AliyunOss) String() string { | |||
switch gt { | |||
case AliyunOssEndpoint: | |||
return "oss_endpoint" | |||
case AliyunOssBucketName: | |||
return "oss_bucket_name" | |||
case AliyunOssBucketScheme: | |||
return "oss_bucket_scheme" | |||
case AliyunOssAccessKeyID: | |||
return "oss_access_key_id" | |||
case AliyunOssAccessKeySecret: | |||
return "oss_access_key_secret" | |||
case AliyunOssDomain: | |||
return "oss_domain" | |||
default: | |||
return "未知" | |||
} | |||
} |
@@ -9,6 +9,7 @@ import ( | |||
"applet/app/utils" | |||
"applet/app/utils/cache" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" | |||
enum2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" | |||
"github.com/aliyun/aliyun-oss-go-sdk/oss" | |||
"github.com/gin-gonic/gin" | |||
) | |||
@@ -136,11 +137,11 @@ func GetOssUrl(c *gin.Context) { | |||
for _, cfg := range *sysCfgs { | |||
cfgMap[cfg.Key] = cfg.Val | |||
} | |||
endpoint := cfgMap[enum.AliyunOss(enum.AliyunOssEndpoint).String()] | |||
bucketName := cfgMap[enum.AliyunOss(enum.AliyunOssBucketName).String()] | |||
objectName := cfgMap[enum.AliyunOss(enum.AliyunOssBucketScheme).String()] | |||
accessKeyID := cfgMap[enum.AliyunOss(enum.AliyunOssAccessKeyID).String()] | |||
accessKeySecret := cfgMap[enum.AliyunOss(enum.AliyunOssAccessKeySecret).String()] | |||
endpoint := cfgMap[enum2.AliyunOss(enum2.AliyunOssEndpoint).String()] | |||
bucketName := cfgMap[enum2.AliyunOss(enum2.AliyunOssBucketName).String()] | |||
objectName := cfgMap[enum2.AliyunOss(enum2.AliyunOssBucketScheme).String()] | |||
accessKeyID := cfgMap[enum2.AliyunOss(enum2.AliyunOssAccessKeyID).String()] | |||
accessKeySecret := cfgMap[enum2.AliyunOss(enum2.AliyunOssAccessKeySecret).String()] | |||
client, err := oss.New(endpoint, accessKeyID, accessKeySecret) | |||
if err != nil { | |||
@@ -398,7 +398,7 @@ func GetFundDataList(c *gin.Context) { | |||
} | |||
fundDataDb := implement.NewEggEnergyFundDataDb(db.Db) | |||
fundDataList, total, err := fundDataDb.EggEnergyFundDataFindAndCount(req.Page, req.Limit, req.Limit, req.StartAt, req.EndAt) | |||
fundDataList, total, err := fundDataDb.EggEnergyFundDataFindAndCount(req.Page, req.Limit, req.Kind, req.StartAt, req.EndAt) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
@@ -0,0 +1,152 @@ | |||
package egg_energy | |||
import ( | |||
"applet/app/db" | |||
"applet/app/e" | |||
md "applet/app/md/institutional_management/egg_energy" | |||
"applet/app/utils/cache" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||
enum2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" | |||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/enum" | |||
"github.com/gin-gonic/gin" | |||
"time" | |||
) | |||
// SetVideoReward | |||
// @Summary 制度中心-蛋蛋能量-激励视频(设置) | |||
// @Tags 蛋蛋能量 | |||
// @Description 激励视频(设置) | |||
// @Accept json | |||
// @Produce json | |||
// @param Authorization header string true "验证参数Bearer和token空格拼接" | |||
// @param req body md.SetVideoRewardReq true "落地页不填页大小默认20条数据" | |||
// @Success 200 {string} "success" | |||
// @Failure 400 {object} md.Response "具体错误" | |||
// @Router /api/institutionalManagement/eggEnergy/platformRevenue/SetVideoReward [post] | |||
func SetVideoReward(c *gin.Context) { | |||
var req *md.SetVideoRewardReq | |||
if err1 := c.ShouldBindJSON(&req); err1 != nil { | |||
e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error()) | |||
return | |||
} | |||
conn := cache.GetPool().Get() | |||
cfgDb := implement.NewSysCfgDb(db.Db, conn) | |||
cfgDb.SysCfgInsert(enum2.VideoReward(enum2.VideoRewardUnitPrice).String(), req.UnitPrice, "激励视频单价") | |||
cfgDb.SysCfgInsert(enum2.VideoReward(enum2.VideoRewardUnitPrice).String(), req.ECMP, "当前 ecmp 值") | |||
e.OutSuc(c, "success", nil) | |||
} | |||
// ListPlatformRevenue | |||
// @Summary 制度中心-蛋蛋能量-平台营收数据(获取) | |||
// @Tags 蛋蛋能量 | |||
// @Description 平台营收数据(获取) | |||
// @Accept json | |||
// @Produce json | |||
// @param Authorization header string true "验证参数Bearer和token空格拼接" | |||
// @Param req body md.ListPlatformRevenueReq true "分页信息必填" | |||
// @Success 200 {object} md.ListPlatformRevenueResp "具体数据" | |||
// @Failure 400 {object} md.Response "具体错误" | |||
// @Router /api/institutionalManagement/eggEnergy/globalData/fundDataList [post] | |||
func ListPlatformRevenue(c *gin.Context) { | |||
var req *md.ListPlatformRevenueReq | |||
if err1 := c.ShouldBindJSON(&req); err1 != nil { | |||
e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error()) | |||
return | |||
} | |||
var kindList = []map[string]interface{}{ | |||
{ | |||
"name": enum.PlatformRevenueDataKind.String(enum.AppOpenAds), | |||
"value": enum.AppOpenAds, | |||
}, | |||
{ | |||
"name": enum.PlatformRevenueDataKind.String(enum.BannerAds), | |||
"value": enum.BannerAds, | |||
}, | |||
{ | |||
"name": enum.PlatformRevenueDataKind.String(enum.InFeedAds), | |||
"value": enum.InFeedAds, | |||
}, | |||
{ | |||
"name": enum.PlatformRevenueDataKind.String(enum.InterstitialAds), | |||
"value": enum.InterstitialAds, | |||
}, | |||
} | |||
platformRevenueDataDb := implement.NewPlatformRevenueDataDb(db.Db) | |||
platformRevenueDataList, total, err := platformRevenueDataDb.PlatformRevenueDataFindAndCount(req.Page, req.Limit, req.StartAt, req.EndAt, req.Kind) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
list := make([]md.PlatformRevenueDataNode, len(platformRevenueDataList)) | |||
for i, platformRevenueData := range platformRevenueDataList { | |||
list[i].Kind = platformRevenueData.Kind | |||
list[i].TotalAmount = platformRevenueData.TotalAmount | |||
list[i].Hours = platformRevenueData.Hours | |||
list[i].Memo = platformRevenueData.Memo | |||
list[i].BalanceTimes = platformRevenueData.BalanceTimes | |||
list[i].BalanceAmount = platformRevenueData.BalanceAmount | |||
list[i].CreateAt = platformRevenueData.CreateAt | |||
list[i].SystemID = platformRevenueData.Id | |||
} | |||
resp := md.ListPlatformRevenueResp{ | |||
KindList: kindList, | |||
Paginate: md.Paginate{ | |||
Limit: req.Limit, | |||
Page: req.Page, | |||
Total: total, | |||
}, | |||
List: list, | |||
} | |||
e.OutSuc(c, resp, nil) | |||
} | |||
// AddPlatformRevenue | |||
// @Summary 制度中心-蛋蛋能量-平台营收数据(新增) | |||
// @Tags 蛋蛋能量 | |||
// @Description 平台营收数据(新增) | |||
// @Accept json | |||
// @Produce json | |||
// @param Authorization header string true "验证参数Bearer和token空格拼接" | |||
// @Param req body md.AddPlatformRevenueReq true "数据种类、金额、时长(最长24h)、执行次数必填,备注选填" | |||
// @Success 200 {int} "插入数据 id" | |||
// @Failure 400 {object} md.Response "具体错误" | |||
// @Router /api/institutionalManagement/eggEnergy/platformRevenue/PlatformRevenueAdd [post] | |||
func AddPlatformRevenue(c *gin.Context) { | |||
var req *md.AddPlatformRevenueReq | |||
if err1 := c.ShouldBindJSON(&req); err1 != nil { | |||
e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error()) | |||
return | |||
} | |||
platformRevenueDataDb := implement.NewPlatformRevenueDataDb(db.Db) | |||
now := time.Now() | |||
hour := now.Hour() | |||
if req.Hours > 24 { | |||
hour = 24 | |||
} | |||
m := model.PlatformRevenueData{ | |||
Kind: req.Kind, | |||
TotalAmount: req.TotalAmount, | |||
BalanceAmount: req.TotalAmount, | |||
Hours: hour, | |||
BalanceTimes: req.Times, | |||
Memo: req.Memo, | |||
CreateAt: now, | |||
UpdateAt: now, | |||
} | |||
id, err := platformRevenueDataDb.PlatformRevenueDataInsert(&m) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, id, nil) | |||
} |
@@ -3,10 +3,10 @@ package aliyun | |||
import ( | |||
"applet/app/db" | |||
"applet/app/e" | |||
"applet/app/enum" | |||
md "applet/app/md/setCenter/oss/aliyun" | |||
"applet/app/utils/cache" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" | |||
enum2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" | |||
"github.com/gin-gonic/gin" | |||
) | |||
@@ -32,34 +32,34 @@ func GetBasic(c *gin.Context) { | |||
for _, cfg := range *sysCfg { | |||
cfgMap[cfg.Key] = cfg.Val | |||
} | |||
endpoint, ok := cfgMap[enum.AliyunOss(enum.AliyunOssEndpoint).String()] | |||
endpoint, ok := cfgMap[enum2.AliyunOss(enum2.AliyunOssEndpoint).String()] | |||
if !ok { | |||
sysCfgDb.SysCfgInsert(enum.AliyunOss(enum.AliyunOssEndpoint).String(), "", "oss地域节点") | |||
sysCfgDb.SysCfgInsert(enum2.AliyunOss(enum2.AliyunOssEndpoint).String(), "", "oss地域节点") | |||
endpoint = "" | |||
} | |||
bucketName, ok := cfgMap[enum.AliyunOss(enum.AliyunOssBucketName).String()] | |||
bucketName, ok := cfgMap[enum2.AliyunOss(enum2.AliyunOssBucketName).String()] | |||
if !ok { | |||
sysCfgDb.SysCfgInsert(enum.AliyunOss(enum.AliyunOssBucketName).String(), "", "oss存储桶名称") | |||
sysCfgDb.SysCfgInsert(enum2.AliyunOss(enum2.AliyunOssBucketName).String(), "", "oss存储桶名称") | |||
bucketName = "" | |||
} | |||
bucketScheme, ok := cfgMap[enum.AliyunOss(enum.AliyunOssBucketScheme).String()] | |||
bucketScheme, ok := cfgMap[enum2.AliyunOss(enum2.AliyunOssBucketScheme).String()] | |||
if !ok { | |||
sysCfgDb.SysCfgInsert(enum.AliyunOss(enum.AliyunOssBucketScheme).String(), "", "oss上传方式") | |||
sysCfgDb.SysCfgInsert(enum2.AliyunOss(enum2.AliyunOssBucketScheme).String(), "", "oss上传方式") | |||
bucketScheme = "" | |||
} | |||
accessKeyID, ok := cfgMap[enum.AliyunOss(enum.AliyunOssAccessKeyID).String()] | |||
accessKeyID, ok := cfgMap[enum2.AliyunOss(enum2.AliyunOssAccessKeyID).String()] | |||
if !ok { | |||
sysCfgDb.SysCfgInsert(enum.AliyunOss(enum.AliyunOssAccessKeyID).String(), "", "oss访问秘钥id") | |||
sysCfgDb.SysCfgInsert(enum2.AliyunOss(enum2.AliyunOssAccessKeyID).String(), "", "oss访问秘钥id") | |||
accessKeyID = "" | |||
} | |||
accessKeySecret, ok := cfgMap[enum.AliyunOss(enum.AliyunOssAccessKeySecret).String()] | |||
accessKeySecret, ok := cfgMap[enum2.AliyunOss(enum2.AliyunOssAccessKeySecret).String()] | |||
if !ok { | |||
sysCfgDb.SysCfgInsert(enum.AliyunOss(enum.AliyunOssAccessKeySecret).String(), "", "oss访问秘钥") | |||
sysCfgDb.SysCfgInsert(enum2.AliyunOss(enum2.AliyunOssAccessKeySecret).String(), "", "oss访问秘钥") | |||
accessKeySecret = "" | |||
} | |||
domain, ok := cfgMap[enum.AliyunOss(enum.AliyunOssDomain).String()] | |||
domain, ok := cfgMap[enum2.AliyunOss(enum2.AliyunOssDomain).String()] | |||
if !ok { | |||
sysCfgDb.SysCfgInsert(enum.AliyunOss(enum.AliyunOssDomain).String(), "", "oss域名") | |||
sysCfgDb.SysCfgInsert(enum2.AliyunOss(enum2.AliyunOssDomain).String(), "", "oss域名") | |||
domain = "" | |||
} | |||
@@ -97,22 +97,22 @@ func SetBasic(c *gin.Context) { | |||
cfgDb := implement.NewSysCfgDb(db.Db, redisConn) | |||
if req.OssAccessKeyId != "" { | |||
cfgDb.SysCfgUpdate(enum.AliyunOss(enum.AliyunOssAccessKeyID).String(), req.OssAccessKeyId) | |||
cfgDb.SysCfgUpdate(enum2.AliyunOss(enum2.AliyunOssAccessKeyID).String(), req.OssAccessKeyId) | |||
} | |||
if req.OssAccessKeySecret != "" { | |||
cfgDb.SysCfgUpdate(enum.AliyunOss(enum.AliyunOssAccessKeySecret).String(), req.OssAccessKeySecret) | |||
cfgDb.SysCfgUpdate(enum2.AliyunOss(enum2.AliyunOssAccessKeySecret).String(), req.OssAccessKeySecret) | |||
} | |||
if req.OssBucketScheme != "" { | |||
cfgDb.SysCfgUpdate(enum.AliyunOss(enum.AliyunOssBucketScheme).String(), req.OssBucketScheme) | |||
cfgDb.SysCfgUpdate(enum2.AliyunOss(enum2.AliyunOssBucketScheme).String(), req.OssBucketScheme) | |||
} | |||
if req.OssObjectDomain != "" { | |||
cfgDb.SysCfgUpdate(enum.AliyunOss(enum.AliyunOssDomain).String(), req.OssObjectDomain) | |||
cfgDb.SysCfgUpdate(enum2.AliyunOss(enum2.AliyunOssDomain).String(), req.OssObjectDomain) | |||
} | |||
if req.OssBucketName != "" { | |||
cfgDb.SysCfgUpdate(enum.AliyunOss(enum.AliyunOssBucketName).String(), req.OssBucketName) | |||
cfgDb.SysCfgUpdate(enum2.AliyunOss(enum2.AliyunOssBucketName).String(), req.OssBucketName) | |||
} | |||
if req.OssEndpoint != "" { | |||
cfgDb.SysCfgUpdate(enum.AliyunOss(enum.AliyunOssEndpoint).String(), req.OssEndpoint) | |||
cfgDb.SysCfgUpdate(enum2.AliyunOss(enum2.AliyunOssEndpoint).String(), req.OssEndpoint) | |||
} | |||
e.OutSuc(c, "success", nil) | |||
} |
@@ -0,0 +1,41 @@ | |||
package md | |||
import "time" | |||
type SetVideoRewardReq struct { | |||
UnitPrice string `json:"unit_price,required"` // 单价 | |||
ECMP string `json:"ecmp,required"` // 当前 Ecmp 值 | |||
} | |||
type ListPlatformRevenueReq struct { | |||
Kind int `json:"kind"` // 数据类型 | |||
StartAt string `json:"start_at" example:"开始时间"` | |||
EndAt string `json:"end_at" example:"结束时间"` | |||
Page int `json:"page,required"` // 页数 | |||
Limit int `json:"limit,required" ` // 每页大小 | |||
} | |||
type PlatformRevenueDataNode struct { | |||
SystemID int `json:"system_id"` | |||
Kind int `json:"kind" ` // 种类(1:开屏广告 2:banner 广告 3:信息流广告 4:插屏广告) | |||
TotalAmount string `json:"total_amount" ` // 金额 | |||
BalanceAmount string `json:"balance_amount" ` // 余额 | |||
Hours int `json:"hours" ` // 时长 | |||
BalanceTimes int `json:"balance_times" ` // 剩余执行次数 | |||
Memo string `json:"memo" ` // 备注 | |||
CreateAt time.Time `json:"create_at" ` // 创建时间 | |||
} | |||
type ListPlatformRevenueResp struct { | |||
KindList []map[string]interface{} `json:"kind_list"` // 类型列表 | |||
Paginate Paginate `json:"paginate"` // 分页数据 | |||
List []PlatformRevenueDataNode `json:"list"` // 数据列表 | |||
} | |||
type AddPlatformRevenueReq struct { | |||
Kind int `json:"kind,required"` // 种类(1:开屏广告 2:banner 广告 3:信息流广告 4:插屏广告) | |||
TotalAmount string `json:"total_amount,required"` // 金额 | |||
Hours int `json:"hours,required"` // 时长(小时) | |||
Times int `json:"times,required"` // 剩余执行次数 | |||
Memo string `json:"memo" example:"备注"` | |||
} |
@@ -121,6 +121,12 @@ func rInstitutionalManagement(r *gin.RouterGroup) { //制度管理 | |||
rEggGlobalData.POST("/fundDataRecordList", egg_energy.GetFundDataRecordList) | |||
rEggGlobalData.POST("/fundDataAdd", egg_energy.AddFundData) | |||
} | |||
rPlatformRevenue := rEggEnergy.Group("/platformRevenue") | |||
{ | |||
rPlatformRevenue.POST("/SetVideoReward", egg_energy.SetVideoReward) | |||
rPlatformRevenue.POST("/PlatformRevenueList", egg_energy.ListPlatformRevenue) | |||
rPlatformRevenue.POST("/PlatformRevenueAdd", egg_energy.AddPlatformRevenue) | |||
} | |||
} | |||
} | |||