使用记录查询条件
This commit is contained in:
parent
6c5ae80059
commit
76390c3f66
@ -224,39 +224,39 @@ func GetUsedRecord(req *bundle.GetUsedRecordListReq) (data []model.CostLogPo, to
|
|||||||
Select("ccl.*,cwl.cost_type").
|
Select("ccl.*,cwl.cost_type").
|
||||||
Joins("left join cast_work_log cwl on cwl.work_uuid = ccl.work_uuid")
|
Joins("left join cast_work_log cwl on cwl.work_uuid = ccl.work_uuid")
|
||||||
if req.WorkTitle != "" {
|
if req.WorkTitle != "" {
|
||||||
session = session.Where("work_title like ?", "%"+req.WorkTitle+"%")
|
session = session.Where("ccl.work_title like ?", "%"+req.WorkTitle+"%")
|
||||||
}
|
}
|
||||||
if req.Platform != 0 {
|
if req.Platform != 0 {
|
||||||
session = session.Where(fmt.Sprintf("JSON_CONTAINS(platform_ids,'%d')", req.Platform))
|
session = session.Where(fmt.Sprintf("JSON_CONTAINS(ccl.platform_ids,'%d')", req.Platform))
|
||||||
}
|
}
|
||||||
if req.Account != "" {
|
if req.Account != "" {
|
||||||
session = session.Where(fmt.Sprintf(`JSON_CONTAINS(media_names,'"%s"')`, req.Account))
|
session = session.Where(fmt.Sprintf(`JSON_CONTAINS(ccl.media_names,'"%s"')`, req.Account))
|
||||||
}
|
}
|
||||||
if req.SubmitTimeEnd != 0 {
|
if req.SubmitTimeEnd != 0 {
|
||||||
session = session.Where("submit_time <= ?", time.UnixMilli(req.SubmitTimeEnd))
|
session = session.Where("ccl.submit_time <= ?", time.UnixMilli(req.SubmitTimeEnd))
|
||||||
}
|
}
|
||||||
if req.SubmitTimeStart != 0 {
|
if req.SubmitTimeStart != 0 {
|
||||||
session = session.Where("submit_time >= ?", time.UnixMilli(req.SubmitTimeStart))
|
session = session.Where("ccl.submit_time >= ?", time.UnixMilli(req.SubmitTimeStart))
|
||||||
}
|
}
|
||||||
if req.CostType != 0 {
|
if req.CostType != 0 {
|
||||||
session = session.Where("cwl.cost_type = ?", req.CostType)
|
session = session.Where("cwl.cost_type = ?", req.CostType)
|
||||||
}
|
}
|
||||||
if req.User != "" {
|
if req.User != "" {
|
||||||
if utils.IsPhoneNumber(req.User) {
|
if utils.IsPhoneNumber(req.User) {
|
||||||
session = session.Where("artist_phone = ?", req.User)
|
session = session.Where("ccl.artist_phone = ?", req.User)
|
||||||
} else {
|
} else {
|
||||||
session = session.Where("artist_name like ?", "%"+req.User+"%")
|
session = session.Where("ccl.artist_name like ?", "%"+req.User+"%")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if req.Operator != "" {
|
if req.Operator != "" {
|
||||||
if utils.IsPhoneNumber(req.Operator) {
|
if utils.IsPhoneNumber(req.Operator) {
|
||||||
session = session.Where("operator_phone = ?", req.Operator)
|
session = session.Where("ccl.operator_phone = ?", req.Operator)
|
||||||
} else {
|
} else {
|
||||||
session = session.Where("operator_name like ?", "%"+req.Operator+"%")
|
session = session.Where("ccl.operator_name like ?", "%"+req.Operator+"%")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if req.Type != 0 {
|
if req.Type != 0 {
|
||||||
session = session.Where("work_category = ?", req.Type)
|
session = session.Where("ccl.work_category = ?", req.Type)
|
||||||
}
|
}
|
||||||
if err = session.Count(&total).Error; err != nil {
|
if err = session.Count(&total).Error; err != nil {
|
||||||
return
|
return
|
||||||
@ -264,7 +264,7 @@ func GetUsedRecord(req *bundle.GetUsedRecordListReq) (data []model.CostLogPo, to
|
|||||||
if req.Page != 0 && req.PageSize != 0 {
|
if req.Page != 0 && req.PageSize != 0 {
|
||||||
session = session.Offset(int(req.Page-1) * int(req.PageSize)).Limit(int(req.PageSize))
|
session = session.Offset(int(req.Page-1) * int(req.PageSize)).Limit(int(req.PageSize))
|
||||||
}
|
}
|
||||||
err = session.Order("updated_at desc").Find(&data).Error
|
err = session.Order("ccl.updated_at desc").Find(&data).Error
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user