作者 陈志颖

feat:完善账期结算查询仓储

... ... @@ -15,7 +15,7 @@ type SearchCreditAccountQuery struct {
// 页面大小
PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"`
// 账期结算单号
CreditAccountOrderNum string `cname:"账期结算单号" json:"creditAccountOrderNum"`
CreditAccountOrderNum string `cname:"账期结算单号" json:"creditAccountOrderNum,omitempty"`
// 参与人姓名
ParticipatorName string `cname:"参与人姓名" json:"participatorName,omitempty"`
// 公司ID,通过集成REST上下文获取
... ...
... ... @@ -290,10 +290,27 @@ func (creditAccountService *CreditAccountService) SearchCreditAccount(searchCred
defer func() {
_ = transactionContext.RollbackTransaction()
}()
var creditAccountRepository domain.CreditAccountRepository
if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
creditAccountRepository = value
}
if count, creditAccounts, err := creditAccountRepository.Find(tool_funs.SimpleStructToMap(searchCreditAccountQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil, nil
return map[string]interface{}{
"grid": map[string]interface{}{
"total": count,
"list": creditAccounts,
},
}, nil
}
}
// UpdateCreditAccount 更新账期结算单服务
... ...
... ... @@ -190,6 +190,15 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac
var creditAccountModels []*models.CreditAccount
creditAccounts := make([]*domain.CreditAccount, 0)
query := sqlbuilder.BuildQuery(tx.Model(&creditAccountModels), queryOptions)
if creditAccountOrderNum, ok := queryOptions["creditAccountOrderNum"]; ok && creditAccountOrderNum != "" {
query.Where("credit_account_order_num ilike ?", fmt.Sprintf("%%%s%%", creditAccountOrderNum))
}
if participatorName, ok := queryOptions["participatorName"]; ok && participatorName != "" {
query.Where(`(credit_account.participator->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", participatorName))
}
if paymentStatus, ok := queryOptions["paymentStatus"]; ok && paymentStatus.(int32) != 0 {
query.Where("payment_status = ?", paymentStatus)
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...