作者 yangfu

统计修改

... ... @@ -36,6 +36,10 @@ type SearchCreditAccountQuery struct {
BeginTime time.Time `json:"beginTime"`
// 账期创建-结束时间
EndTime time.Time `json:"endTime"`
// 账期创建-开始时间
PaymentBeginTime time.Time `json:"paymentBeginTime"`
// 账期创建-结束时间
PaymentEndTime time.Time `json:"paymentEndTime"`
// 合约编号列表
CooperationContractNumbers []string `json:"cooperationContractNumbers"`
}
... ...
... ... @@ -85,6 +85,12 @@ func (dao *CreditAccountDao) DividendsStatistics(queryOptions map[string]interfa
if v, ok := queryOptions["orgId"]; ok && v.(int64) > 0 {
query.Where(fmt.Sprintf(` org->>'orgId'= '%v'`, v))
}
if v, ok := queryOptions["paymentBeginTime"]; ok && !(v.(time.Time).IsZero()) {
query.Where(`payment_time>=? `, queryOptions["paymentBeginTime"])
}
if v, ok := queryOptions["paymentEndTime"]; ok && !(v.(time.Time).IsZero()) {
query.Where(`payment_time<? `, queryOptions["paymentEndTime"])
}
if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 {
//query.Where("cooperation_contract_number in (?)", pg.In(v))
query.Where(domain.ConditionInContractNumbers(v.([]string)))
... ... @@ -173,6 +179,12 @@ func (dao *CreditAccountDao) CooperationCompanyDividendsStatistics(queryOptions
if v, ok := queryOptions["endTime"]; ok && !v.(time.Time).IsZero() {
query.Where("created_at < ?", v)
}
if v, ok := queryOptions["paymentBeginTime"]; ok && !(v.(time.Time).IsZero()) {
query.Where(`payment_time>=? `, queryOptions["paymentBeginTime"])
}
if v, ok := queryOptions["paymentEndTime"]; ok && !(v.(time.Time).IsZero()) {
query.Where(`payment_time<? `, queryOptions["paymentEndTime"])
}
query.Where("deleted_at is null")
if v, ok := queryOptions["sortByActuallyPaidAmount"]; ok {
vInt := v.(int)
... ...
... ... @@ -668,15 +668,15 @@ func (ptr *CooperationStatisticsService) PaymentHistoryHistogramStatistics(query
if !request.BeginTime.IsZero() && request.BeginTime.AddDate(0, 3, 0).Before(request.EndTime) {
queryItems, xAxisData = histogramStatisticsByYear(request.BeginTime)
} else {
queryItems, xAxisData = histogramStatisticsByMonth()
queryItems, xAxisData = histogramStatisticsByMonth(request.BeginTime)
}
for i := range queryItems {
item := queryItems[i]
if len(contractNumbers) == 0 && request.UserId > 0 { //没有相关的合约 查看分红预算单为空
continue
}
queryOptions["beginTime"] = item.BeginTime
queryOptions["endTime"] = item.EndTime
queryOptions["paymentBeginTime"] = item.BeginTime
queryOptions["paymentEndTime"] = item.EndTime
if err := creditAccountDao.DividendsStatistics(queryOptions, dividends); err != nil {
return nil, err
}
... ... @@ -697,9 +697,9 @@ type queryItem struct {
EndTime time.Time
}
func histogramStatisticsByMonth() ([]queryItem, []string) {
func histogramStatisticsByMonth(start time.Time) ([]queryItem, []string) {
ret := make([]queryItem, 0)
year, month := time.Now().Year(), time.Now().Month()
year, month := start.Year(), start.Month()
var beginTime = time.Date(year, month, 1, 0, 0, 0, 0, time.Local)
var endTime time.Time
var increaseDay = 5
... ...
... ... @@ -150,8 +150,8 @@ func (ptr *CooperationStatisticsService) PersonCompanyPaymentHistoryStatistics(q
UserBaseId int64 `json:"userBaseId" valid:"Required"`
OrgId int64 `json:"orgId" valid:"Required"`
SortByActuallyPaidAmount int `json:"sortByActuallyPaidAmount" valid:"Required"`
BeginTime time.Time `json:"beginTime"`
EndTime time.Time `json:"endTime"`
BeginTime time.Time `json:"paymentBeginTime"`
EndTime time.Time `json:"paymentEndTime"`
}{}
if err := LoadQueryObject(queryOptions, &request); err != nil {
return nil, err
... ...
... ... @@ -583,6 +583,10 @@ func (ptr *CooperationStatisticsService) CreditAccountStatistics(queryOptions ma
UserBaseId int64 `json:"userBaseId"`
BeginTime time.Time `json:"beginTime"`
EndTime time.Time `json:"endTime"`
// 支付开始时间
PaymentBeginTime time.Time `json:"paymentBeginTime"`
// 支付结束时间
PaymentEndTime time.Time `json:"paymentEndTime"`
// 合约编号列表
CooperationContractNumbers []string `json:"cooperationContractNumbers"`
}{}
... ...
... ... @@ -7,10 +7,10 @@ import (
"github.com/go-pg/pg/v10/orm"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
"github.com/linmadan/egglib-go/persistent/pg/comment"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
rawlog "log"
)
var DB *pg.DB
... ... @@ -51,7 +51,7 @@ func init() {
if err != nil {
panic(err)
}
comment.AddComments(DB, model)
//comment.AddComments(DB, model)
}
}
}
... ... @@ -68,6 +68,11 @@ func (hook SqlGeneratePrintHook) AfterQuery(c context.Context, q *pg.QueryEvent)
if err != nil {
return err
}
log.Logger.Debug(string(sqlStr))
if constant.LOG_FRAMEWORK == "logrus" {
rawlog.Println(string(sqlStr))
} else {
log.Logger.Debug(string(sqlStr))
}
return nil
}
... ...
... ... @@ -234,6 +234,12 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac
if v, ok := queryOptions["endTime"]; ok && !(v.(time.Time).IsZero()) {
query.Where(`created_at<? `, queryOptions["endTime"])
}
if v, ok := queryOptions["paymentBeginTime"]; ok && !(v.(time.Time).IsZero()) {
query.Where(`payment_time>=? `, queryOptions["paymentBeginTime"])
}
if v, ok := queryOptions["paymentEndTime"]; ok && !(v.(time.Time).IsZero()) {
query.Where(`payment_time<? `, queryOptions["paymentEndTime"])
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...