You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1015 B
50 lines
1015 B
package profit |
|
|
|
import ( |
|
"fmt" |
|
"github.com/gin-gonic/gin" |
|
"github.com/liangdas/mqant/log" |
|
"server/common" |
|
"server/db" |
|
"server/modules/backend/app" |
|
utils "server/modules/backend/util" |
|
"server/modules/backend/values" |
|
) |
|
|
|
func EditProfit(c *gin.Context) { |
|
a := app.NewApp(c) |
|
defer func() { |
|
a.Response() |
|
}() |
|
|
|
req := new(values.EditProfitReq) |
|
if !a.S(req) { |
|
return |
|
} |
|
|
|
for i := 0; i < len(req.List); i++ { |
|
var data common.ESIncomeStatistics |
|
|
|
if req.List[i].Period != nil { |
|
data.Period = *req.List[i].Period |
|
} |
|
|
|
if req.List[i].Investment != nil { |
|
data.Investment = *req.List[i].Investment |
|
} |
|
|
|
if req.List[i].Channel != nil { |
|
data.Channel = *req.List[i].Channel |
|
} |
|
|
|
data.Time, _ = utils.GetQueryUnix(req.List[i].Start, req.List[i].Start) |
|
|
|
id := fmt.Sprintf("%d_%s", req.List[i].Channel, req.List[i].Start) |
|
_, err := db.ES().Upsert(common.ESIndexBackIncomeStatistics, id, &data, &data) |
|
if err != nil { |
|
log.Error("err:%v", err) |
|
a.Code = values.CodeRetry |
|
return |
|
} |
|
} |
|
}
|
|
|