正在显示
6 个修改的文件
包含
51 行增加
和
3 行删除
@@ -2,6 +2,7 @@ package command | @@ -2,6 +2,7 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | ||
5 | "reflect" | 6 | "reflect" |
6 | "strings" | 7 | "strings" |
7 | 8 | ||
@@ -9,10 +10,14 @@ import ( | @@ -9,10 +10,14 @@ import ( | ||
9 | ) | 10 | ) |
10 | 11 | ||
11 | type PayCreditAccountCommand struct { | 12 | type PayCreditAccountCommand struct { |
13 | + // 账期结算单ID | ||
14 | + CreditAccountId string `cname:"账期结算单ID" json:"creditAccountId" valid:"Required"` | ||
12 | // 账期结算实付金额 | 15 | // 账期结算实付金额 |
13 | ActuallyPaidAmount float64 `cname:"账期结算实付金额" json:"actuallyPaidAmount" valid:"Required"` | 16 | ActuallyPaidAmount float64 `cname:"账期结算实付金额" json:"actuallyPaidAmount" valid:"Required"` |
14 | // 备注 | 17 | // 备注 |
15 | Remarks string `cname:"备注" json:"remarks" valid:"Required"` | 18 | Remarks string `cname:"备注" json:"remarks" valid:"Required"` |
19 | + // 支付凭证附件 | ||
20 | + PaymentDocumentAttachment *domain.Attachment `cname:"支付凭证附件" json:"paymentDocumentAttachment" valid:"Required"` | ||
16 | // 公司ID,通过集成REST上下文获取 | 21 | // 公司ID,通过集成REST上下文获取 |
17 | CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"` | 22 | CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"` |
18 | // 组织机构ID | 23 | // 组织机构ID |
@@ -229,10 +229,34 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco | @@ -229,10 +229,34 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco | ||
229 | defer func() { | 229 | defer func() { |
230 | _ = transactionContext.RollbackTransaction() | 230 | _ = transactionContext.RollbackTransaction() |
231 | }() | 231 | }() |
232 | + // 参数类型转换 | ||
233 | + creditAccountId, _ := strconv.ParseInt(payCreditAccountCommand.CreditAccountId, 10, 64) | ||
234 | + var creditAccountRepository domain.CreditAccountRepository | ||
235 | + if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{ | ||
236 | + "transactionContext": transactionContext, | ||
237 | + }); err != nil { | ||
238 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
239 | + } else { | ||
240 | + creditAccountRepository = value | ||
241 | + } | ||
242 | + creditAccount, err := creditAccountRepository.FindOne(map[string]interface{}{"creditAccountId": creditAccountId}) | ||
243 | + if err != nil { | ||
244 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
245 | + } | ||
246 | + if creditAccount == nil { | ||
247 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(creditAccountId, 10))) | ||
248 | + } | ||
249 | + if err := creditAccount.Update(tool_funs.SimpleStructToMap(payCreditAccountCommand)); err != nil { | ||
250 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
251 | + } | ||
252 | + if creditAccount, err := creditAccountRepository.Save(creditAccount); err != nil { | ||
253 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
254 | + } else { | ||
232 | if err := transactionContext.CommitTransaction(); err != nil { | 255 | if err := transactionContext.CommitTransaction(); err != nil { |
233 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 256 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
234 | } | 257 | } |
235 | - return nil, nil | 258 | + return creditAccount, nil |
259 | + } | ||
236 | } | 260 | } |
237 | 261 | ||
238 | // RemoveCreditAccount 移除账期结算单服务 | 262 | // RemoveCreditAccount 移除账期结算单服务 |
@@ -42,6 +42,8 @@ type CreditAccount struct { | @@ -42,6 +42,8 @@ type CreditAccount struct { | ||
42 | DeletedAt time.Time `json:"deletedAt"` | 42 | DeletedAt time.Time `json:"deletedAt"` |
43 | // 更新时间 | 43 | // 更新时间 |
44 | UpdatedAt time.Time `json:"updatedAt"` | 44 | UpdatedAt time.Time `json:"updatedAt"` |
45 | + //备注 | ||
46 | + Remarks string `json:"remarks"` | ||
45 | } | 47 | } |
46 | 48 | ||
47 | type CreditAccountRepository interface { | 49 | type CreditAccountRepository interface { |
@@ -68,5 +70,14 @@ func (creditAccount *CreditAccount) Update(data map[string]interface{}) error { | @@ -68,5 +70,14 @@ func (creditAccount *CreditAccount) Update(data map[string]interface{}) error { | ||
68 | if paymentStatus, ok := data["paymentStatus"]; ok { | 70 | if paymentStatus, ok := data["paymentStatus"]; ok { |
69 | creditAccount.PaymentStatus = paymentStatus.(int32) | 71 | creditAccount.PaymentStatus = paymentStatus.(int32) |
70 | } | 72 | } |
73 | + if paymentDocumentAttachment, ok := data["paymentDocumentAttachment"]; ok { | ||
74 | + creditAccount.PaymentDocumentAttachment = paymentDocumentAttachment.(*Attachment) | ||
75 | + } | ||
76 | + if remarks, ok := data["remarks"]; ok { | ||
77 | + creditAccount.Remarks = remarks.(string) | ||
78 | + } | ||
79 | + if actuallyPaidAmount, ok := data["actuallyPaidAmount"]; ok { | ||
80 | + creditAccount.ActuallyPaidAmount = actuallyPaidAmount.(float64) | ||
81 | + } | ||
71 | return nil | 82 | return nil |
72 | } | 83 | } |
@@ -45,4 +45,6 @@ type CreditAccount struct { | @@ -45,4 +45,6 @@ type CreditAccount struct { | ||
45 | DeletedAt time.Time `comment:"删除时间"` | 45 | DeletedAt time.Time `comment:"删除时间"` |
46 | // 更新时间 | 46 | // 更新时间 |
47 | UpdatedAt time.Time `comment:"更新时间"` | 47 | UpdatedAt time.Time `comment:"更新时间"` |
48 | + // 备注 | ||
49 | + Remarks string `comment:"备注"` | ||
48 | } | 50 | } |
@@ -26,5 +26,6 @@ func TransformToCreditAccountDomainModelFromPgModels(creditAccountModel *models. | @@ -26,5 +26,6 @@ func TransformToCreditAccountDomainModelFromPgModels(creditAccountModel *models. | ||
26 | CreatedAt: creditAccountModel.CreatedAt, | 26 | CreatedAt: creditAccountModel.CreatedAt, |
27 | DeletedAt: creditAccountModel.DeletedAt, | 27 | DeletedAt: creditAccountModel.DeletedAt, |
28 | UpdatedAt: creditAccountModel.UpdatedAt, | 28 | UpdatedAt: creditAccountModel.UpdatedAt, |
29 | + Remarks: creditAccountModel.Remarks, | ||
29 | }, nil | 30 | }, nil |
30 | } | 31 | } |
@@ -46,6 +46,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | @@ -46,6 +46,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | ||
46 | "created_at", | 46 | "created_at", |
47 | "deleted_at", | 47 | "deleted_at", |
48 | "updated_at", | 48 | "updated_at", |
49 | + "remarks", | ||
49 | } | 50 | } |
50 | insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields) | 51 | insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields) |
51 | insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields) | 52 | insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields) |
@@ -81,6 +82,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | @@ -81,6 +82,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | ||
81 | &creditAccount.CreatedAt, | 82 | &creditAccount.CreatedAt, |
82 | &creditAccount.DeletedAt, | 83 | &creditAccount.DeletedAt, |
83 | &creditAccount.UpdatedAt, | 84 | &creditAccount.UpdatedAt, |
85 | + &creditAccount.Remarks, | ||
84 | ), | 86 | ), |
85 | fmt.Sprintf("INSERT INTO credit_accounts (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), | 87 | fmt.Sprintf("INSERT INTO credit_accounts (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), |
86 | creditAccount.CreditAccountId, | 88 | creditAccount.CreditAccountId, |
@@ -100,8 +102,9 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | @@ -100,8 +102,9 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | ||
100 | creditAccount.Operator, | 102 | creditAccount.Operator, |
101 | creditAccount.OperateTime, | 103 | creditAccount.OperateTime, |
102 | creditAccount.CreatedAt, | 104 | creditAccount.CreatedAt, |
103 | - creditAccount.DeletedAt, | 105 | + nil, |
104 | creditAccount.UpdatedAt, | 106 | creditAccount.UpdatedAt, |
107 | + creditAccount.Remarks, | ||
105 | ); err != nil { | 108 | ); err != nil { |
106 | return creditAccount, err | 109 | return creditAccount, err |
107 | } | 110 | } |
@@ -127,6 +130,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | @@ -127,6 +130,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | ||
127 | &creditAccount.CreatedAt, | 130 | &creditAccount.CreatedAt, |
128 | &creditAccount.DeletedAt, | 131 | &creditAccount.DeletedAt, |
129 | &creditAccount.UpdatedAt, | 132 | &creditAccount.UpdatedAt, |
133 | + &creditAccount.Remarks, | ||
130 | ), | 134 | ), |
131 | fmt.Sprintf("UPDATE credit_accounts SET %s WHERE credit_account_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), | 135 | fmt.Sprintf("UPDATE credit_accounts SET %s WHERE credit_account_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), |
132 | creditAccount.CreditAccountId, | 136 | creditAccount.CreditAccountId, |
@@ -146,8 +150,9 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | @@ -146,8 +150,9 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | ||
146 | creditAccount.Operator, | 150 | creditAccount.Operator, |
147 | creditAccount.OperateTime, | 151 | creditAccount.OperateTime, |
148 | creditAccount.CreatedAt, | 152 | creditAccount.CreatedAt, |
149 | - creditAccount.DeletedAt, | 153 | + nil, |
150 | creditAccount.UpdatedAt, | 154 | creditAccount.UpdatedAt, |
155 | + creditAccount.Remarks, | ||
151 | creditAccount.Identify(), | 156 | creditAccount.Identify(), |
152 | ); err != nil { | 157 | ); err != nil { |
153 | return creditAccount, err | 158 | return creditAccount, err |
-
请 注册 或 登录 后发表评论