作者 yangfu

结算记录合约编号查询修改

package domain
import "time"
import (
"fmt"
"github.com/linmadan/egglib-go/utils/json"
"time"
)
// CreditAccount 账期结算单实体
type CreditAccount struct {
... ... @@ -83,3 +87,13 @@ func (creditAccount *CreditAccount) Update(data map[string]interface{}) error {
}
return nil
}
func ConditionInContractNumbers(numbers []string) string {
var response = make([]map[string]string, 0)
for i := range numbers {
response = append(response, map[string]string{
"cooperationContractNumber": numbers[i],
})
}
return fmt.Sprintf("account_detail <@'%v'", json.MarshalToString(response))
}
... ...
... ... @@ -2,8 +2,8 @@ package dao
import (
"fmt"
"github.com/go-pg/pg/v10"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
"time"
... ... @@ -86,7 +86,8 @@ func (dao *CreditAccountDao) DividendsStatistics(queryOptions map[string]interfa
query.Where(fmt.Sprintf(` org->>'orgId'= '%v'`, v))
}
if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 {
query.Where("cooperation_contract_number in (?)", pg.In(v))
//query.Where("cooperation_contract_number in (?)", pg.In(v))
query.Where(domain.ConditionInContractNumbers(v.([]string)))
}
query.Where("deleted_at is null")
err := query.Select(v)
... ... @@ -123,7 +124,8 @@ func (dao *CreditAccountDao) CooperationUsersDividendsStatistics(queryOptions ma
query.Where("created_at < ?", v)
}
if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 {
query.Where("cooperation_contract_number in (?)", pg.In(v))
//query.Where("cooperation_contract_number in (?)", pg.In(v))
query.Where(domain.ConditionInContractNumbers(v.([]string)))
}
query.Where("deleted_at is null")
if v, ok := queryOptions["sortByActuallyPaidAmount"]; ok {
... ...
... ... @@ -207,7 +207,7 @@ group by cooperation_contract_number
return resMap, nil
}
// getContractsDividendsEstimate 合约分红预算
// getContractsDividendsEstimate 合约分红预算 TODO:合约编号
func (ptr *CooperationStatisticsService) getContractsCreditAccount(numbers []string) (map[string]*domain.CreditAccount, error) {
var creditAccounts []*domain.CreditAccount
var resMap = make(map[string]*domain.CreditAccount)
... ...
... ... @@ -209,7 +209,8 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac
query.Where(`cooperation_contract_number = ?`, fmt.Sprintf("%s", cooperationContractNumber))
}
if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 {
query.Where("cooperation_contract_number in (?)", pg.In(v))
//query.Where("cooperation_contract_number in (?)", pg.In(v))
query.Where(domain.ConditionInContractNumbers(v.([]string)))
}
if paymentStatus, ok := queryOptions["paymentStatus"]; ok && paymentStatus.(int32) != 0 {
query.Where("payment_status = ?", paymentStatus)
... ...