@@ -45,16 +45,26 @@ func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOneNoDataNoErr(key strin | |||||
func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOne(uid, key string) (*model.MasterListCfg, error) { | func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOne(uid, key string) (*model.MasterListCfg, error) { | ||||
var cfgList model.MasterListCfg | var cfgList model.MasterListCfg | ||||
if has, err := masterListCfgDb.Db.Where("`k`=? and uid=?", key, uid).Get(&cfgList); err != nil || has == false { | |||||
has, err := masterListCfgDb.Db.Where("`k`=? and uid=?", key, uid).Get(&cfgList) | |||||
if err != nil { | |||||
return nil, logx.Error(err) | return nil, logx.Error(err) | ||||
} | } | ||||
if has == false { | |||||
cfgList = model.MasterListCfg{Uid: uid, K: key} | |||||
masterListCfgDb.Db.InsertOne(&cfgList) | |||||
} | |||||
return &cfgList, nil | return &cfgList, nil | ||||
} | } | ||||
func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOneData(uid, key string) string { | func (masterListCfgDb *MasterListCfgDb) MasterListCfgGetOneData(uid, key string) string { | ||||
var cfgList model.MasterListCfg | var cfgList model.MasterListCfg | ||||
if has, err := masterListCfgDb.Db.Where("`k`=? and uid=?", key, uid).Get(&cfgList); err != nil || has == false { | |||||
has, err := masterListCfgDb.Db.Where("`k`=? and uid=?", key, uid).Get(&cfgList) | |||||
if err != nil { | |||||
return "" | return "" | ||||
} | } | ||||
if has == false { | |||||
cfgList = model.MasterListCfg{Uid: uid, K: key} | |||||
masterListCfgDb.Db.InsertOne(&cfgList) | |||||
} | |||||
return cfgList.V | return cfgList.V | ||||
} | } | ||||
@@ -70,7 +80,7 @@ func (masterListCfgDb *MasterListCfgDb) MasterListCfgInsert(uid, key, val, memo | |||||
func (masterListCfgDb *MasterListCfgDb) MasterListCfgUpdate(uid, key, val string) bool { | func (masterListCfgDb *MasterListCfgDb) MasterListCfgUpdate(uid, key, val string) bool { | ||||
cfg := model.MasterListCfg{K: key, V: val} | cfg := model.MasterListCfg{K: key, V: val} | ||||
_, err := masterListCfgDb.Db.Where("`k`=? and uid=?", key, uid).Cols("val").Update(&cfg) | |||||
_, err := masterListCfgDb.Db.Where("`k`=? and uid=?", key, uid).Cols("v").Update(&cfg) | |||||
if err != nil { | if err != nil { | ||||
logx.Error(err) | logx.Error(err) | ||||
return false | return false | ||||
@@ -76,8 +76,9 @@ func (playletSaleOrderDb *PlayletSaleOrderDb) GetPlayletVideoOrderList(args map[ | |||||
sess = sess.And("update_time>=?", args["start_time"]) | sess = sess.And("update_time>=?", args["start_time"]) | ||||
} | } | ||||
if args["end_time"] != "" { | if args["end_time"] != "" { | ||||
sess = sess.And("update_time>=?", args["end_time"]) | |||||
sess = sess.And("update_time<=?", args["end_time"]) | |||||
} | } | ||||
if args["to_settle_time"] != "" { | if args["to_settle_time"] != "" { | ||||
sess = sess.And("create_time<?", args["to_settle_time"]) | sess = sess.And("create_time<?", args["to_settle_time"]) | ||||
} | } | ||||
@@ -1,20 +1,21 @@ | |||||
package md | package md | ||||
type PlayletVideoOrder struct { | type PlayletVideoOrder struct { | ||||
Appid int `json:"appid"` | |||||
Channel string `json:"channel"` | |||||
Appid string `json:"appid"` | |||||
OrderId string `json:"order_id"` | OrderId string `json:"order_id"` | ||||
PayDate string `json:"pay_date"` | |||||
SettleType string `json:"settle_type"` | |||||
Price int `json:"price"` | Price int `json:"price"` | ||||
Title string `json:"title"` | |||||
Status int `json:"status"` | |||||
PayDate string `json:"pay_date"` | |||||
RefundDate string `json:"refund_date"` | RefundDate string `json:"refund_date"` | ||||
SourceId string `json:"source_id"` | SourceId string `json:"source_id"` | ||||
Status int `json:"status"` | |||||
Title string `json:"title"` | |||||
SourceType string `json:"source_type"` | SourceType string `json:"source_type"` | ||||
SettleType string `json:"settle_type"` | |||||
MemberId string `json:"member_id"` | |||||
Channel string `json:"channel"` | |||||
} | } | ||||
type PlayletAdvOrder struct { | type PlayletAdvOrder struct { | ||||
Appid int `json:"appid"` | |||||
Appid string `json:"appid"` | |||||
Channel string `json:"channel"` | Channel string `json:"channel"` | ||||
CreatedTime string `json:"created_time"` | CreatedTime string `json:"created_time"` | ||||
Price int `json:"price"` | Price int `json:"price"` | ||||
@@ -198,6 +198,12 @@ func PlayletAdvOrderMonth() { | |||||
return | return | ||||
} | } | ||||
/*** | |||||
注意 广告点击pv,uv每小时统计一次,结算金额将于次日,投流平台更新数据后更新 | |||||
建议 所有统计数据:每小时在整点拉取当日统计,在次日凌晨1点后拉取一次昨日所有统计数据。金额数据, | |||||
建议在次日12:00后拉取后更新,可以将channel,source_id,created_time联合作为唯一索引, | |||||
如果遇到数据更新不及时,请联系客服。 | |||||
*/ | |||||
func getAdvOrder(uids string, arg map[string]interface{}) int { | func getAdvOrder(uids string, arg map[string]interface{}) int { | ||||
list := make([]map[string]string, 0) | list := make([]map[string]string, 0) | ||||
token := GetTpdarenToken(uids) | token := GetTpdarenToken(uids) | ||||
@@ -215,19 +221,21 @@ func getAdvOrder(uids string, arg map[string]interface{}) int { | |||||
dataList := make([]md.PlayletAdvOrder, 0) | dataList := make([]md.PlayletAdvOrder, 0) | ||||
json.Unmarshal([]byte(data), &dataList) | json.Unmarshal([]byte(data), &dataList) | ||||
sysCfgDb := db.MasterListCfgDb{} | |||||
sysCfgDb := db.SysCfgDb{} | |||||
sysCfgDb.Set() | sysCfgDb.Set() | ||||
playletKuaishouBili := sysCfgDb.MasterListCfgGetOneData(uids, "adv_kuaishou_bili") | |||||
playletDouyinBili := sysCfgDb.MasterListCfgGetOneData(uids, "adv_douyin_bili") | |||||
playletChannelBili := sysCfgDb.MasterListCfgGetOneData(uids, "adv_channel_bili") | |||||
playletKuaishouBili := sysCfgDb.SysCfgGetOneData("adv_kuaishou_bili") | |||||
playletDouyinBili := sysCfgDb.SysCfgGetOneData("adv_douyin_bili") | |||||
playletChannelBili := sysCfgDb.SysCfgGetOneData("adv_channel_bili") | |||||
var biliMap = map[string]string{ | var biliMap = map[string]string{ | ||||
"kuaishou": playletKuaishouBili, | "kuaishou": playletKuaishouBili, | ||||
"douyin": playletDouyinBili, | "douyin": playletDouyinBili, | ||||
"channel": playletChannelBili, | "channel": playletChannelBili, | ||||
} | } | ||||
zyPlayletKuaishouBili := sysCfgDb.MasterListCfgGetOneData(uids, "zy_adv_kuaishou_bili") | |||||
zyPlayletDouyinBili := sysCfgDb.MasterListCfgGetOneData(uids, "zy_adv_douyin_bili") | |||||
zyPlayletChannelBili := sysCfgDb.MasterListCfgGetOneData(uids, "zy_adv_channel_bili") | |||||
masterListCfgDb := db.MasterListCfgDb{} | |||||
masterListCfgDb.Set() | |||||
zyPlayletKuaishouBili := masterListCfgDb.MasterListCfgGetOneData(uids, "zy_adv_kuaishou_bili") | |||||
zyPlayletDouyinBili := masterListCfgDb.MasterListCfgGetOneData(uids, "zy_adv_douyin_bili") | |||||
zyPlayletChannelBili := masterListCfgDb.MasterListCfgGetOneData(uids, "zy_adv_channel_bili") | |||||
var zyBiliMap = map[string]string{ | var zyBiliMap = map[string]string{ | ||||
"kuaishou": zyPlayletKuaishouBili, | "kuaishou": zyPlayletKuaishouBili, | ||||
"douyin": zyPlayletDouyinBili, | "douyin": zyPlayletDouyinBili, | ||||
@@ -111,6 +111,7 @@ func PlayletVideoOrderYesterDay() { | |||||
"end": time.Unix(endTime, 0).Format("2006-01-02 15:04:05"), | "end": time.Unix(endTime, 0).Format("2006-01-02 15:04:05"), | ||||
"page_size": pageSize, | "page_size": pageSize, | ||||
"page_index": pageNo, | "page_index": pageNo, | ||||
"status": 2, | |||||
} | } | ||||
count := getVideoOrder(uid, arg) | count := getVideoOrder(uid, arg) | ||||
if count == 0 { | if count == 0 { | ||||
@@ -189,6 +190,11 @@ func PlayletVideoOrderMonth() { | |||||
syscfgDb.MasterListCfgUpdate(uid, key, time.Unix(endTime, 0).Format("2006-01-02 15:04:05")) | syscfgDb.MasterListCfgUpdate(uid, key, time.Unix(endTime, 0).Format("2006-01-02 15:04:05")) | ||||
return | return | ||||
} | } | ||||
/*** | |||||
注意 在选择status为2退款时,start,end的筛选字段将是退款时间,时间范围最大为30天 | |||||
建议 所有订单:实时订单,延迟最多1分钟内。退款订单:建议每日凌晨1点后拉取一次昨日退款订单。 | |||||
*/ | |||||
func getVideoOrder(uids string, arg map[string]interface{}) int { | func getVideoOrder(uids string, arg map[string]interface{}) int { | ||||
list := make([]map[string]string, 0) | list := make([]map[string]string, 0) | ||||
token := GetTpdarenToken(uids) | token := GetTpdarenToken(uids) | ||||
@@ -206,19 +212,21 @@ func getVideoOrder(uids string, arg map[string]interface{}) int { | |||||
dataList := make([]md.PlayletVideoOrder, 0) | dataList := make([]md.PlayletVideoOrder, 0) | ||||
json.Unmarshal([]byte(data), &dataList) | json.Unmarshal([]byte(data), &dataList) | ||||
sysCfgDb := db.MasterListCfgDb{} | |||||
sysCfgDb := db.SysCfgDb{} | |||||
sysCfgDb.Set() | sysCfgDb.Set() | ||||
playletKuaishouBili := sysCfgDb.MasterListCfgGetOneData(uids, "playlet_kuaishou_bili") | |||||
playletDouyinBili := sysCfgDb.MasterListCfgGetOneData(uids, "playlet_douyin_bili") | |||||
playletChannelBili := sysCfgDb.MasterListCfgGetOneData(uids, "playlet_channel_bili") | |||||
playletKuaishouBili := sysCfgDb.SysCfgGetOneData("playlet_kuaishou_bili") | |||||
playletDouyinBili := sysCfgDb.SysCfgGetOneData("playlet_douyin_bili") | |||||
playletChannelBili := sysCfgDb.SysCfgGetOneData("playlet_channel_bili") | |||||
var biliMap = map[string]string{ | var biliMap = map[string]string{ | ||||
"kuaishou": playletKuaishouBili, | "kuaishou": playletKuaishouBili, | ||||
"douyin": playletDouyinBili, | "douyin": playletDouyinBili, | ||||
"channel": playletChannelBili, | "channel": playletChannelBili, | ||||
} | } | ||||
zyPlayletKuaishouBili := sysCfgDb.MasterListCfgGetOneData(uids, "zy_playlet_kuaishou_bili") | |||||
zyPlayletDouyinBili := sysCfgDb.MasterListCfgGetOneData(uids, "zy_playlet_douyin_bili") | |||||
zyPlayletChannelBili := sysCfgDb.MasterListCfgGetOneData(uids, "zy_playlet_channel_bili") | |||||
masterListCfgDb := db.MasterListCfgDb{} | |||||
masterListCfgDb.Set() | |||||
zyPlayletKuaishouBili := masterListCfgDb.MasterListCfgGetOneData(uids, "zy_playlet_kuaishou_bili") | |||||
zyPlayletDouyinBili := masterListCfgDb.MasterListCfgGetOneData(uids, "zy_playlet_douyin_bili") | |||||
zyPlayletChannelBili := masterListCfgDb.MasterListCfgGetOneData(uids, "zy_playlet_channel_bili") | |||||
var zyBiliMap = map[string]string{ | var zyBiliMap = map[string]string{ | ||||
"kuaishou": zyPlayletKuaishouBili, | "kuaishou": zyPlayletKuaishouBili, | ||||
"douyin": zyPlayletDouyinBili, | "douyin": zyPlayletDouyinBili, | ||||