123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555 |
- package http
- import (
- "time"
- "go-common/app/job/main/growup/conf"
- "go-common/library/log"
- bm "go-common/library/net/http/blademaster"
- )
- func execAvRatio(c *bm.Context) {
- log.Info("begin update av charge ratio")
- v := new(struct {
- Date string `form:"date" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- t, err := time.Parse("2006-01-02", v.Date)
- if err != nil {
- log.Error("execAvRatio date error!date:%s", v.Date)
- return
- }
- log.Info("ratio,hour:%d, num:%d, sleep:%d", conf.Conf.Ratio.Hour, conf.Conf.Ratio.Num, conf.Conf.Ratio.Sleep)
- for {
- rows, _ := svr.DeleteAvRatio(c, conf.Conf.Ratio.Num)
- time.Sleep(time.Duration(conf.Conf.Ratio.Sleep) * time.Millisecond)
- if rows == 0 {
- break
- }
- }
- err = svr.ExecRatioForHTTP(c, t.Year(), int(t.Month()), t.Day())
- if err != nil {
- log.Error("Exec avRatio from http error!(%v)", err)
- } else {
- log.Info("Exec avRatio from http succeed!")
- }
- c.JSON(nil, err)
- }
- func execIncome(c *bm.Context) {
- log.Info("begin update up income")
- v := new(struct {
- Date string `form:"date" validate:"required" `
- })
- if err := c.Bind(v); err != nil {
- return
- }
- t, err := time.Parse("2006-01-02", v.Date)
- if err != nil {
- log.Error("execIncome date error!date:%s", v.Date)
- return
- }
- log.Info("income,hour:%d, num:%d, sleep:%d", conf.Conf.Income.Hour, conf.Conf.Income.Num, conf.Conf.Income.Sleep)
- err = svr.ExecIncomeForHTTP(c, t.Year(), int(t.Month()), t.Day())
- if err != nil {
- log.Error("ExecIncomeForHTTP error!(%v)", err)
- } else {
- log.Info("Exec Income from http succeed!")
- }
- c.JSON(nil, err)
- }
- func getUpIncomeStatis(c *bm.Context) {
- log.Info("begin calculate up income statis")
- v := new(struct {
- Date string `form:"date" validate:"required"`
- HasWithdraw int `form:"has_withdraw"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- err := svr.GetUpIncomeStatis(c, v.Date, v.HasWithdraw)
- if err != nil {
- log.Error("(job growup svr.GetUpIncomeStatis error(%v)", err)
- }
- c.JSON(nil, err)
- }
- func getAvIncomeStatis(c *bm.Context) {
- v := new(struct {
- Date string `form:"date" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- err := svr.GetAvIncomeStatis(c, v.Date)
- if err != nil {
- log.Error("(job growup svr.GetAvIncomeStatis error(%v)", err)
- }
- c.JSON(nil, err)
- }
- func updateTagIncome(c *bm.Context) {
- log.Info("begin fix tag income")
- v := new(struct {
- Date string `form:"date" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- err := svr.UpdateTagIncome(c, v.Date)
- if err != nil {
- log.Error("(job growup svr.UpdateTagIncome error(%v)", err)
- }
- c.JSON(nil, err)
- }
- func fixUpIncome(c *bm.Context) {
- log.Info("begin fix up income from tag")
- v := new(struct {
- Date string `form:"date" validate:"required"`
- TagID int64 `form:"tag_id" validate:"required"`
- AddCount int `form:"add_count" validate:"required"`
- TotalIncome int `form:"total_income" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- err := svr.FixUpIncome(c, v.Date, v.TagID, v.AddCount, v.TotalIncome)
- if err != nil {
- log.Error("(job growup svr.FixUpIncome error(%v)", err)
- }
- c.JSON(nil, err)
- }
- func fixIncome(c *bm.Context) {
- log.Info("begin fix income")
- err := svr.FixIncome(c)
- if err != nil {
- log.Error("(job growup svr.FixIncome error(%v)", err)
- }
- c.JSON(nil, err)
- }
- func fixUpAvStatis(c *bm.Context) {
- log.Info("begin fix up av statis")
- v := new(struct {
- Count int `form:"count" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- err := svr.FixUpAvStatis(c, v.Count)
- if err != nil {
- log.Error("(job growup svr.FixUpAvStatis error(%v)", err)
- }
- c.JSON(nil, err)
- }
- func updateWithdraw(c *bm.Context) {
- v := new(struct {
- OldDate string `form:"old_date" validate:"required"`
- NewDate string `form:"new_date" validate:"required"`
- Count int64 `form:"count" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- err := svr.UpdateWithdraw(c, v.OldDate, v.NewDate, v.Count)
- if err != nil {
- log.Error("(svr.UpdateWithdraw error(%v)", err)
- }
- c.JSON(nil, err)
- }
- func creativeIncome(c *bm.Context) {
- v := new(struct {
- Date string `form:"date" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- date, err := time.ParseInLocation("2006-01-02", v.Date, time.Local)
- if err != nil {
- log.Error("time.Parse date(%s) error", v.Date)
- c.JSON(nil, err)
- return
- }
- log.Info("start run %s income", v.Date)
- err = incomeSrv.RunAndSendMail(c, date)
- if err != nil {
- log.Error("incomeSrv.Run error(%v)", err)
- } else {
- log.Info("run %s income success", v.Date)
- }
- c.JSON(nil, err)
- }
- func creativeCharge(c *bm.Context) {
- v := new(struct {
- Date string `form:"date" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- date, err := time.ParseInLocation("2006-01-02", v.Date, time.Local)
- if err != nil {
- log.Error("time.Parse date(%s) error", v.Date)
- c.JSON(nil, err)
- return
- }
- log.Info("start run %s charge", v.Date)
- err = chargeSrv.RunAndSendMail(c, date)
- if err != nil {
- log.Error("chargeSrv.RunAndSendMail error(%v)", err)
- } else {
- log.Info("run %s charge success", v.Date)
- }
- c.JSON(nil, err)
- }
- func creativeStatis(c *bm.Context) {
- v := new(struct {
- Date string `form:"date" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- date, err := time.ParseInLocation("2006-01-02", v.Date, time.Local)
- if err != nil {
- log.Error("time.Parse date(%s) error", v.Date)
- c.JSON(nil, err)
- return
- }
- log.Info("start run %s statis", v.Date)
- err = incomeSrv.RunStatis(c, date)
- if err != nil {
- log.Error("incomeSrv.RunStatis error(%v)", err)
- } else {
- log.Info("run %s statis success", v.Date)
- }
- c.JSON(nil, err)
- }
- func creativeBill(c *bm.Context) {
- v := new(struct {
- StartDate string `form:"start_date" validate:"required"`
- EndDate string `form:"end_date" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- start, err := time.ParseInLocation("2006-01-02", v.StartDate, time.Local)
- if err != nil {
- log.Error("time.Parse date(%s) error", v.StartDate)
- c.JSON(nil, err)
- return
- }
- end, err := time.ParseInLocation("2006-01-02", v.EndDate, time.Local)
- if err != nil {
- log.Error("time.Parse date(%s) error", v.EndDate)
- c.JSON(nil, err)
- return
- }
- if err = svr.CreativeUpBill(c, start, end); err != nil {
- log.Error("svr.CreativeUpBill error(%v)", err)
- }
- c.JSON(nil, err)
- }
- func creativeBudget(c *bm.Context) {
- v := new(struct {
- Date string `form:"date" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- date, err := time.ParseInLocation("2006-01-02", v.Date, time.Local)
- if err != nil {
- log.Error("time.Parse date(%s) error", v.Date)
- c.JSON(nil, err)
- return
- }
- err = svr.CreativeBudget(c, date)
- if err != nil {
- log.Error("svr.CreativeBudget error(%v)", err)
- }
- c.JSON(nil, err)
- }
- func creativeActivity(c *bm.Context) {
- v := new(struct {
- Date string `form:"date" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- date, err := time.ParseInLocation("2006-01-02", v.Date, time.Local)
- if err != nil {
- log.Error("time.Parse date(%s) error", v.Date)
- c.JSON(nil, err)
- return
- }
- err = svr.CreativeActivity(c, date)
- if err != nil {
- log.Error("svr.CreativeActivity error(%v)", err)
- }
- c.JSON(nil, err)
- }
- func updateUpInfoVideo(c *bm.Context) {
- err := svr.UpdateUpInfo(c)
- if err != nil {
- log.Error("svr.UpdateUpInfo error(%v)", err)
- } else {
- log.Info("run %s UpdateUpInfo success", time.Now().Format("2006-01-02"))
- }
- c.JSON(nil, err)
- }
- func fixTagAdjust(c *bm.Context) {
- v := new(struct {
- ID int64 `form:"id" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- err := svr.UpdateTagAdjust(c, v.ID)
- if err != nil {
- log.Error("svr.UpdateTagAdjust error(%v)", err)
- }
- c.JSON(nil, err)
- }
- func fixAccountType(c *bm.Context) {
- v := new(struct {
- MID int64 `form:"mid" validate:"required"`
- AccountType int `form:"account_type" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- err := svr.UpdateAccountType(c, v.MID, v.AccountType)
- if err != nil {
- log.Error("svr.UpdateAccountType error!(%v)", err)
- }
- c.JSON(nil, err)
- }
- func syncBGM(c *bm.Context) {
- err := incomeSrv.SyncBgmInfo(c)
- if err != nil {
- log.Error("svr.SyncBgmInfo error!(%v)", err)
- }
- c.JSON(nil, err)
- }
- func fixUpAccount(c *bm.Context) {
- v := new(struct {
- MID int64 `form:"mid"`
- TotalIncome int64 `form:"total_income"`
- UnwithdrawIncome int64 `form:"unwithdraw_income"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- err := svr.UpdateUpAccountMoney(c, v.MID, v.TotalIncome, v.UnwithdrawIncome)
- if err != nil {
- log.Error("svr.UpdateUpAccountMoney error!(%v)", err)
- }
- c.JSON(nil, err)
- }
- func fixBaseIncome(c *bm.Context) {
- v := new(struct {
- MID int64 `form:"mid" validate:"required"`
- Base int64 `form:"base" validate:"required"`
- Date string `form:"date" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- err := svr.FixBaseIncome(c, v.Base, v.MID, v.Date)
- if err != nil {
- log.Error("svr.FixBaseIncome error!(%v)", err)
- }
- c.JSON(nil, err)
- }
- func fixAvBreach(c *bm.Context) {
- v := new(struct {
- MID int64 `form:"mid" validate:"required"`
- Date string `form:"date" validate:"required"`
- Count int `form:"count" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- err := svr.FixAvBreach(c, v.MID, v.Date, v.Count)
- if err != nil {
- log.Error("svr.FixAvBreach error!(%v)", err)
- }
- c.JSON(nil, err)
- }
- func fixUpTotalIncome(c *bm.Context) {
- v := new(struct {
- Table string `form:"table" validate:"required"`
- Date string `form:"date" validate:"required"`
- Count int `form:"count" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- err := svr.FixUpTotalIncome(c, v.Table, v.Date, v.Count)
- if err != nil {
- log.Error("svr.FixUpTotalIncome error!(%v)", err)
- }
- c.JSON(nil, err)
- }
- func syncUpPGC(c *bm.Context) {
- err := svr.SyncUpPGC(c)
- if err != nil {
- log.Error("svr.SyncUpPGC error!(%v)", err)
- }
- c.JSON(nil, err)
- }
- func syncAvBaseIncome(c *bm.Context) {
- v := new(struct {
- Table string `form:"table" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- err := svr.SyncAvBaseIncome(c, v.Table)
- if err != nil {
- log.Error("svr.SyncAvBaseIncome error!(%v)", err)
- }
- c.JSON(nil, err)
- }
- func updateColumnTag(c *bm.Context) {
- v := new(struct {
- Table string `form:"table" validate:"required"`
- New int `form:"new" validate:"required"`
- Old string `form:"old" validate:"required"`
- Count int64 `form:"count" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- err := svr.UpdateColumnTag(c, v.Table, v.Old, v.New, v.Count)
- if err != nil {
- log.Error("svr.UpdateColumnTag error!(%v)", err)
- }
- c.JSON(nil, err)
- }
- func syncCreditScore(c *bm.Context) {
- err := svr.SyncCreditScore(c)
- if err != nil {
- log.Error("svr.SyncCreditScore error!(%v)", err)
- }
- c.JSON(nil, err)
- }
- func calBgmStatis(c *bm.Context) {
- err := svr.FixBgmIncomeStatis(c)
- if err != nil {
- log.Error("svr.FixBgmIncomeStatis error!(%v)", err)
- }
- c.JSON(nil, err)
- }
- func calBgmBaseIncome(c *bm.Context) {
- v := new(struct {
- MID int64 `form:"mid" validate:"required"`
- Date string `form:"date" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- err := svr.FixBgmBaseIncome(c, v.MID, v.Date)
- if err != nil {
- log.Error("svr.FixBgmIncomeStatis error!(%v)", err)
- }
- c.JSON(nil, err)
- }
- func updateBusinessIncome(c *bm.Context) {
- v := new(struct {
- Date string `form:"date" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- err := incomeSrv.UpdateBusinessIncome(c, v.Date)
- if err != nil {
- log.Error("svr.FixBusinessIncome error!(%v)", err)
- }
- c.JSON(nil, err)
- }
- func delDataLimit(c *bm.Context) {
- v := new(struct {
- Table string `form:"table" validate:"required"`
- Count int64 `form:"count" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- err := svr.DelDataLimit(c, v.Table, v.Count)
- if err != nil {
- log.Error("svr.DelDataLimit error(%v)", err)
- }
- c.JSON(nil, err)
- }
- func autoBreach(c *bm.Context) {
- v := new(struct {
- Date string `form:"date" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- _, err := svr.AutoBreach(c, v.Date)
- if err != nil {
- log.Error("svr.AutoBreach error(%v)", err)
- }
- c.JSON(nil, err)
- }
- func autoPunish(c *bm.Context) {
- _, err := svr.AutoPunish(c)
- if err != nil {
- log.Error("svr.AutoPunish error(%v)", err)
- }
- c.JSON(nil, err)
- }
- func autoExamination(c *bm.Context) {
- _, err := svr.AutoExamination(c)
- if err != nil {
- log.Error("svr.AutoExamination error(%v)", err)
- }
- c.JSON(nil, err)
- }
- func syncUpAccount(c *bm.Context) {
- err := svr.SyncUpAccount(c)
- if err != nil {
- log.Error("svr.SyncUpAccount error(%v)", err)
- }
- c.JSON(nil, err)
- }
|