credit_account.go
3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package domain
import (
"bytes"
"fmt"
"time"
)
// CreditAccount 账期结算单实体
type CreditAccount struct {
// 账期结算单ID
CreditAccountId int64 `json:"creditAccountId,string"`
// 账期结算实付金额
ActuallyPaidAmount float64 `json:"actuallyPaidAmount"`
// 账期结算单号
CreditAccountOrderNum string `json:"creditAccountOrderNum"`
// 账期结算支付状态,1待支付,2已支付
PaymentStatus int32 `json:"paymentStatus"`
// 共创账期结算支付时间
PaymentTime time.Time `json:"paymentTime"`
// 账期结算金额
SettlementAmount float64 `json:"settlementAmount"`
// 共创账期结算时间
SettlementTime time.Time `json:"settlementTime"`
// 关联共创合约编号
CooperationContractNumber string `json:"cooperationContractNumber"`
// 参与人uid,包括承接人、推荐人、关联业务员
Participator *Participator `json:"participator"`
// 参与类型
ParticipateType string `json:"participateType"`
// 结算明细
AccountDetail []*AccountDetail `json:"accountDetail"`
// 产品金额统计
GoodAmountCount float64 `json:"goodAmountCount"`
// 支付凭证附件
PaymentDocumentAttachments []*Attachment `json:"paymentDocumentAttachments"`
// 数据所属组织机构
Org *Org `json:"org"`
// 公司
Company *Company `json:"company"`
// 操作人
Operator *User `json:"operator"`
// 操作时间
OperateTime time.Time `json:"operateTime"`
// 创建时间
CreatedAt time.Time `json:"createdAt"`
// 删除时间
DeletedAt time.Time `json:"deletedAt"`
// 更新时间
UpdatedAt time.Time `json:"updatedAt"`
//备注
Remarks string `json:"remarks"`
}
type CreditAccountRepository interface {
Save(creditAccount *CreditAccount) (*CreditAccount, error)
Remove(creditAccount *CreditAccount) (*CreditAccount, error)
FindOne(queryOptions map[string]interface{}) (*CreditAccount, error)
Find(queryOptions map[string]interface{}) (int64, []*CreditAccount, error)
}
func (creditAccount *CreditAccount) Identify() interface{} {
if creditAccount.CreditAccountId == 0 {
return nil
}
return creditAccount.CreditAccountId
}
func (creditAccount *CreditAccount) Update(data map[string]interface{}) error {
if actuallyPaidAmount, ok := data["actuallyPaidAmount"]; ok {
creditAccount.ActuallyPaidAmount = actuallyPaidAmount.(float64)
}
if creditAccountOrderNum, ok := data["creditAccountOrderNum"]; ok {
creditAccount.CreditAccountOrderNum = creditAccountOrderNum.(string)
}
if paymentStatus, ok := data["paymentStatus"]; ok {
creditAccount.PaymentStatus = paymentStatus.(int32)
}
if paymentDocumentAttachments, ok := data["paymentDocumentAttachments"]; ok {
creditAccount.PaymentDocumentAttachments = paymentDocumentAttachments.([]*Attachment)
}
if remarks, ok := data["remarks"]; ok {
creditAccount.Remarks = remarks.(string)
}
if actuallyPaidAmount, ok := data["actuallyPaidAmount"]; ok {
creditAccount.ActuallyPaidAmount = actuallyPaidAmount.(float64)
}
creditAccount.UpdatedAt = time.Now()
return nil
}
func ConditionInContractNumbers(numbers []string) string {
var sqlBuilder = bytes.NewBuffer(nil)
l := len(numbers)
for i := range numbers {
sqlBuilder.WriteString(fmt.Sprintf(`account_detail @> '[{"cooperationContractNumber":"%v"}]' `, numbers[i]))
if i < (l - 1) {
sqlBuilder.WriteString(" OR ")
}
}
return sqlBuilder.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))
}
func ConditionInDividendsEstimateOrderIds(ids []int64) string {
var sqlBuilder = bytes.NewBuffer(nil)
l := len(ids)
for i := range ids {
sqlBuilder.WriteString(fmt.Sprintf(`account_detail @> '[{"dividendsEstimateOrderId":%v}]' `, ids[i]))
if i < (l - 1) {
sqlBuilder.WriteString(" OR ")
}
}
return sqlBuilder.String()
}