Browse Source

广告

master
huangjiajun 2 days ago
parent
commit
5d9a7e0c3a
1 changed files with 69 additions and 13 deletions
  1. +69
    -13
      app/svc/advertising/svc_list.go

+ 69
- 13
app/svc/advertising/svc_list.go View File

@@ -7,6 +7,7 @@ import (
"applet/app/utils"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
"fmt"
"github.com/gin-gonic/gin"
"strings"
)
@@ -73,30 +74,29 @@ func VisitList(c *gin.Context) {
}
req.Platform = strings.ReplaceAll(req.Platform, " ", "")
req.Type = strings.ReplaceAll(req.Type, " ", "")
NewAdvertisingCallbackDb := implement.NewAdvertisingCallbackDb(db.Db)
notice, total, _ := NewAdvertisingCallbackDb.FindAdvertisingCallbackAndTotal(req.Page, req.Limit, req.Amount, uid, req.StartTime, req.EndTime, req.Platform, req.Type)
resp.Total = total
notice := FindAdvertisingCallback(req.Page, req.Limit, req.Amount, uid, req.StartTime, req.EndTime, req.Platform, req.Type)
resp.Total = FindAdvertisingCallbackAndTotal(req.Page, req.Limit, req.Amount, uid, req.StartTime, req.EndTime, req.Platform, req.Type)
if notice != nil {
for _, v := range *notice {
for _, v := range notice {
userDb := implement.NewUserDb(db.Db)
users, _ := userDb.UserGetOneByParams(map[string]interface{}{
"key": "id",
"value": v.Uid,
"value": v["uid"],
})
phone := ""
if users != nil {
phone = users.Phone
}
tmp := md.AdvertisingVisitList{
Id: utils.IntToStr(v.Id),
Uid: utils.IntToStr(v.Uid),
Id: v["id"],
Uid: v["uid"],
Phone: phone,
Ecpm: v.Amount,
Integral: v.Integral,
Platform: v.Platform,
PhonePlatform: v.PhonePlatform,
Type: v.Type,
Time: v.CreateAt.Format("2006-01-02 15:04:05"),
Ecpm: v["amount"],
Integral: v["integral"],
Platform: v["platform"],
PhonePlatform: v["phone_platform"],
Type: v["type"],
Time: v["create_at"],
}
noticeList = append(noticeList, tmp)
}
@@ -105,6 +105,62 @@ func VisitList(c *gin.Context) {
e.OutSuc(c, resp, nil)
return
}
func FindAdvertisingCallback(page, limit, amount, uid, startTime, endTime, platform, types string) []map[string]string {
sql := `SELECT * FROM advertising_callback where %s %s order by id desc`
where := "1=1"
if amount != "" {
where += " and CONVERT(amount, FLOAT)<=" + amount
}
if uid != "" {
where += " and uid=" + uid
}
if platform != "" {
where += " and platform='" + platform + "'"
}
if types != "" {
where += " and type='" + types + "'"
}
if startTime != "" {
where += " and create_at>='" + startTime + "'"
}
if endTime != "" {
where += " and create_at<='" + endTime + "'"
}
start := (utils.StrToInt(page) - 1) * utils.StrToInt(limit)
limits := " limit " + utils.IntToStr(start) + "," + limit
sql = fmt.Sprintf(sql, where, limits)
nativeString, _ := db.QueryNativeString(db.Db, sql)
return nativeString
}
func FindAdvertisingCallbackAndTotal(page, limit, amount, uid, startTime, endTime, platform, types string) int64 {
sql := `SELECT COUNT(*) as count FROM advertising_callback where %s`
where := "1=1"
if amount != "" {
where += " and CONVERT(amount, FLOAT)<=" + amount
}
if uid != "" {
where += " and uid=" + uid
}
if platform != "" {
where += " and platform='" + platform + "'"
}
if types != "" {
where += " and type='" + types + "'"
}
if startTime != "" {
where += " and create_at>='" + startTime + "'"
}
if endTime != "" {
where += " and create_at<='" + endTime + "'"
}
sql = fmt.Sprintf(sql, where)
nativeString, _ := db.QueryNativeString(db.Db, sql)
count := "0"
if len(nativeString) > 0 {
count = nativeString[0]["count"]
}
return utils.StrToInt64(count)
}
func Del(c *gin.Context) {
var req *md.ArticleCateDelReq
if err := c.ShouldBindJSON(&req); err != nil {


Loading…
Cancel
Save