正在显示
16 个修改的文件
包含
978 行增加
和
1 行删除
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type CancelDividendsEstimateCommand struct { | ||
12 | + // 公司ID,通过集成REST上下文获取 | ||
13 | + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"` | ||
14 | + // 组织机构ID | ||
15 | + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` | ||
16 | + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | ||
17 | + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"` | ||
18 | +} | ||
19 | + | ||
20 | +func (cancelDividendsEstimateCommand *CancelDividendsEstimateCommand) Valid(validation *validation.Validation) { | ||
21 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
22 | +} | ||
23 | + | ||
24 | +func (cancelDividendsEstimateCommand *CancelDividendsEstimateCommand) ValidateCommand() error { | ||
25 | + valid := validation.Validation{} | ||
26 | + b, err := valid.Valid(cancelDividendsEstimateCommand) | ||
27 | + if err != nil { | ||
28 | + return err | ||
29 | + } | ||
30 | + if !b { | ||
31 | + elem := reflect.TypeOf(cancelDividendsEstimateCommand).Elem() | ||
32 | + for _, validErr := range valid.Errors { | ||
33 | + field, isExist := elem.FieldByName(validErr.Field) | ||
34 | + if isExist { | ||
35 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
36 | + } else { | ||
37 | + return fmt.Errorf(validErr.Message) | ||
38 | + } | ||
39 | + } | ||
40 | + } | ||
41 | + return nil | ||
42 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type CreateDividendsEstimateCommand struct { | ||
12 | + // 公司ID,通过集成REST上下文获取 | ||
13 | + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"` | ||
14 | + // 组织机构ID | ||
15 | + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` | ||
16 | + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | ||
17 | + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"` | ||
18 | +} | ||
19 | + | ||
20 | +func (createDividendsEstimateCommand *CreateDividendsEstimateCommand) Valid(validation *validation.Validation) { | ||
21 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
22 | +} | ||
23 | + | ||
24 | +func (createDividendsEstimateCommand *CreateDividendsEstimateCommand) ValidateCommand() error { | ||
25 | + valid := validation.Validation{} | ||
26 | + b, err := valid.Valid(createDividendsEstimateCommand) | ||
27 | + if err != nil { | ||
28 | + return err | ||
29 | + } | ||
30 | + if !b { | ||
31 | + elem := reflect.TypeOf(createDividendsEstimateCommand).Elem() | ||
32 | + for _, validErr := range valid.Errors { | ||
33 | + field, isExist := elem.FieldByName(validErr.Field) | ||
34 | + if isExist { | ||
35 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
36 | + } else { | ||
37 | + return fmt.Errorf(validErr.Message) | ||
38 | + } | ||
39 | + } | ||
40 | + } | ||
41 | + return nil | ||
42 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type EstimateDividendsIncentivesCommand struct { | ||
12 | + // 分红订单号/退货单号 | ||
13 | + OrderOrReturnedOrderNum string `cname:"分红订单号/退货单号" json:"orderOrReturnedOrderNum" valid:"Required"` | ||
14 | + // 合约编号 | ||
15 | + CooperationContractNumber string `cname:"合约编号" json:"cooperationContractNumber" valid:"Required"` | ||
16 | + // 公司ID,通过集成REST上下文获取 | ||
17 | + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"` | ||
18 | + // 组织机构ID | ||
19 | + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` | ||
20 | + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | ||
21 | + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"` | ||
22 | +} | ||
23 | + | ||
24 | +func (estimateDividendsIncentivesCommand *EstimateDividendsIncentivesCommand) Valid(validation *validation.Validation) { | ||
25 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
26 | +} | ||
27 | + | ||
28 | +func (estimateDividendsIncentivesCommand *EstimateDividendsIncentivesCommand) ValidateCommand() error { | ||
29 | + valid := validation.Validation{} | ||
30 | + b, err := valid.Valid(estimateDividendsIncentivesCommand) | ||
31 | + if err != nil { | ||
32 | + return err | ||
33 | + } | ||
34 | + if !b { | ||
35 | + elem := reflect.TypeOf(estimateDividendsIncentivesCommand).Elem() | ||
36 | + for _, validErr := range valid.Errors { | ||
37 | + field, isExist := elem.FieldByName(validErr.Field) | ||
38 | + if isExist { | ||
39 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
40 | + } else { | ||
41 | + return fmt.Errorf(validErr.Message) | ||
42 | + } | ||
43 | + } | ||
44 | + } | ||
45 | + return nil | ||
46 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type EstimateMoneyIncentivesCommand struct { | ||
12 | + // 共创项目合约编号 | ||
13 | + CooperationContractNumber string `cname:"共创项目合约编号" json:"cooperationContractNumber" valid:"Required"` | ||
14 | + // 分红阶段 | ||
15 | + DividendsIncentivesStage int64 `cname:"分红阶段" json:"dividendsIncentivesStage,string" valid:"Required"` | ||
16 | + // 承接人UID | ||
17 | + UndertakerUid string `cname:"承接人UID" json:"undertakerUid" valid:"Required"` | ||
18 | + // 公司ID,通过集成REST上下文获取 | ||
19 | + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"` | ||
20 | + // 组织机构ID | ||
21 | + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` | ||
22 | + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | ||
23 | + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"` | ||
24 | +} | ||
25 | + | ||
26 | +func (estimateMoneyIncentivesCommand *EstimateMoneyIncentivesCommand) Valid(validation *validation.Validation) { | ||
27 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
28 | +} | ||
29 | + | ||
30 | +func (estimateMoneyIncentivesCommand *EstimateMoneyIncentivesCommand) ValidateCommand() error { | ||
31 | + valid := validation.Validation{} | ||
32 | + b, err := valid.Valid(estimateMoneyIncentivesCommand) | ||
33 | + if err != nil { | ||
34 | + return err | ||
35 | + } | ||
36 | + if !b { | ||
37 | + elem := reflect.TypeOf(estimateMoneyIncentivesCommand).Elem() | ||
38 | + for _, validErr := range valid.Errors { | ||
39 | + field, isExist := elem.FieldByName(validErr.Field) | ||
40 | + if isExist { | ||
41 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
42 | + } else { | ||
43 | + return fmt.Errorf(validErr.Message) | ||
44 | + } | ||
45 | + } | ||
46 | + } | ||
47 | + return nil | ||
48 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type RemoveDividendsEstimateCommand struct { | ||
12 | + // 承接人分红预算记录ID | ||
13 | + DividendsEstimateId int64 `cname:"承接人分红预算记录ID" json:"dividendsEstimateId,string" valid:"Required"` | ||
14 | + // 公司ID,通过集成REST上下文获取 | ||
15 | + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"` | ||
16 | + // 组织机构ID | ||
17 | + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` | ||
18 | + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | ||
19 | + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"` | ||
20 | +} | ||
21 | + | ||
22 | +func (removeDividendsEstimateCommand *RemoveDividendsEstimateCommand) Valid(validation *validation.Validation) { | ||
23 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
24 | +} | ||
25 | + | ||
26 | +func (removeDividendsEstimateCommand *RemoveDividendsEstimateCommand) ValidateCommand() error { | ||
27 | + valid := validation.Validation{} | ||
28 | + b, err := valid.Valid(removeDividendsEstimateCommand) | ||
29 | + if err != nil { | ||
30 | + return err | ||
31 | + } | ||
32 | + if !b { | ||
33 | + elem := reflect.TypeOf(removeDividendsEstimateCommand).Elem() | ||
34 | + for _, validErr := range valid.Errors { | ||
35 | + field, isExist := elem.FieldByName(validErr.Field) | ||
36 | + if isExist { | ||
37 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
38 | + } else { | ||
39 | + return fmt.Errorf(validErr.Message) | ||
40 | + } | ||
41 | + } | ||
42 | + } | ||
43 | + return nil | ||
44 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type UpdateDividendsEstimateCommand struct { | ||
12 | + // 承接人分红预算记录ID | ||
13 | + DividendsEstimateId int64 `cname:"承接人分红预算记录ID" json:"dividendsEstimateId,string" valid:"Required"` | ||
14 | + // 公司ID,通过集成REST上下文获取 | ||
15 | + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"` | ||
16 | + // 组织机构ID | ||
17 | + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` | ||
18 | + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | ||
19 | + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"` | ||
20 | +} | ||
21 | + | ||
22 | +func (updateDividendsEstimateCommand *UpdateDividendsEstimateCommand) Valid(validation *validation.Validation) { | ||
23 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
24 | +} | ||
25 | + | ||
26 | +func (updateDividendsEstimateCommand *UpdateDividendsEstimateCommand) ValidateCommand() error { | ||
27 | + valid := validation.Validation{} | ||
28 | + b, err := valid.Valid(updateDividendsEstimateCommand) | ||
29 | + if err != nil { | ||
30 | + return err | ||
31 | + } | ||
32 | + if !b { | ||
33 | + elem := reflect.TypeOf(updateDividendsEstimateCommand).Elem() | ||
34 | + for _, validErr := range valid.Errors { | ||
35 | + field, isExist := elem.FieldByName(validErr.Field) | ||
36 | + if isExist { | ||
37 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
38 | + } else { | ||
39 | + return fmt.Errorf(validErr.Message) | ||
40 | + } | ||
41 | + } | ||
42 | + } | ||
43 | + return nil | ||
44 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type GetDividendsEstimateQuery struct { | ||
12 | + // 承接人分红预算记录ID | ||
13 | + DividendsEstimateId int64 `cname:"承接人分红预算记录ID" json:"dividendsEstimateId,string" valid:"Required"` | ||
14 | + // 公司ID,通过集成REST上下文获取 | ||
15 | + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"` | ||
16 | + // 组织机构ID | ||
17 | + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` | ||
18 | + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | ||
19 | + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"` | ||
20 | +} | ||
21 | + | ||
22 | +func (getDividendsEstimateQuery *GetDividendsEstimateQuery) Valid(validation *validation.Validation) { | ||
23 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
24 | +} | ||
25 | + | ||
26 | +func (getDividendsEstimateQuery *GetDividendsEstimateQuery) ValidateQuery() error { | ||
27 | + valid := validation.Validation{} | ||
28 | + b, err := valid.Valid(getDividendsEstimateQuery) | ||
29 | + if err != nil { | ||
30 | + return err | ||
31 | + } | ||
32 | + if !b { | ||
33 | + elem := reflect.TypeOf(getDividendsEstimateQuery).Elem() | ||
34 | + for _, validErr := range valid.Errors { | ||
35 | + field, isExist := elem.FieldByName(validErr.Field) | ||
36 | + if isExist { | ||
37 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
38 | + } else { | ||
39 | + return fmt.Errorf(validErr.Message) | ||
40 | + } | ||
41 | + } | ||
42 | + } | ||
43 | + return nil | ||
44 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type ListDividendsEstimateQuery struct { | ||
12 | + // 查询偏离量 | ||
13 | + Offset int `cname:"查询偏离量" json:"offset" valid:"Required"` | ||
14 | + // 查询限制 | ||
15 | + Limit int `cname:"查询限制" json:"limit" valid:"Required"` | ||
16 | + // 公司ID,通过集成REST上下文获取 | ||
17 | + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"` | ||
18 | + // 组织机构ID | ||
19 | + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` | ||
20 | + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | ||
21 | + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"` | ||
22 | +} | ||
23 | + | ||
24 | +func (listDividendsEstimateQuery *ListDividendsEstimateQuery) Valid(validation *validation.Validation) { | ||
25 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
26 | +} | ||
27 | + | ||
28 | +func (listDividendsEstimateQuery *ListDividendsEstimateQuery) ValidateQuery() error { | ||
29 | + valid := validation.Validation{} | ||
30 | + b, err := valid.Valid(listDividendsEstimateQuery) | ||
31 | + if err != nil { | ||
32 | + return err | ||
33 | + } | ||
34 | + if !b { | ||
35 | + elem := reflect.TypeOf(listDividendsEstimateQuery).Elem() | ||
36 | + for _, validErr := range valid.Errors { | ||
37 | + field, isExist := elem.FieldByName(validErr.Field) | ||
38 | + if isExist { | ||
39 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
40 | + } else { | ||
41 | + return fmt.Errorf(validErr.Message) | ||
42 | + } | ||
43 | + } | ||
44 | + } | ||
45 | + return nil | ||
46 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type ListDividendsIncentivesQuery struct { | ||
12 | + // 查询偏离量 | ||
13 | + Offset int `cname:"查询偏离量" json:"offset" valid:"Required"` | ||
14 | + // 查询限制 | ||
15 | + Limit int `cname:"查询限制" json:"limit" valid:"Required"` | ||
16 | + // 公司ID,通过集成REST上下文获取 | ||
17 | + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"` | ||
18 | + // 组织机构ID | ||
19 | + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` | ||
20 | + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | ||
21 | + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"` | ||
22 | +} | ||
23 | + | ||
24 | +func (listDividendsIncentivesQuery *ListDividendsIncentivesQuery) Valid(validation *validation.Validation) { | ||
25 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
26 | +} | ||
27 | + | ||
28 | +func (listDividendsIncentivesQuery *ListDividendsIncentivesQuery) ValidateQuery() error { | ||
29 | + valid := validation.Validation{} | ||
30 | + b, err := valid.Valid(listDividendsIncentivesQuery) | ||
31 | + if err != nil { | ||
32 | + return err | ||
33 | + } | ||
34 | + if !b { | ||
35 | + elem := reflect.TypeOf(listDividendsIncentivesQuery).Elem() | ||
36 | + for _, validErr := range valid.Errors { | ||
37 | + field, isExist := elem.FieldByName(validErr.Field) | ||
38 | + if isExist { | ||
39 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
40 | + } else { | ||
41 | + return fmt.Errorf(validErr.Message) | ||
42 | + } | ||
43 | + } | ||
44 | + } | ||
45 | + return nil | ||
46 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type ListMoneyIncentivesQuery struct { | ||
12 | + // 查询偏离量 | ||
13 | + Offset int `cname:"查询偏离量" json:"offset" valid:"Required"` | ||
14 | + // 查询限制 | ||
15 | + Limit int `cname:"查询限制" json:"limit" valid:"Required"` | ||
16 | + // 公司ID,通过集成REST上下文获取 | ||
17 | + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"` | ||
18 | + // 组织机构ID | ||
19 | + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` | ||
20 | + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | ||
21 | + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"` | ||
22 | +} | ||
23 | + | ||
24 | +func (listMoneyIncentivesQuery *ListMoneyIncentivesQuery) Valid(validation *validation.Validation) { | ||
25 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
26 | +} | ||
27 | + | ||
28 | +func (listMoneyIncentivesQuery *ListMoneyIncentivesQuery) ValidateQuery() error { | ||
29 | + valid := validation.Validation{} | ||
30 | + b, err := valid.Valid(listMoneyIncentivesQuery) | ||
31 | + if err != nil { | ||
32 | + return err | ||
33 | + } | ||
34 | + if !b { | ||
35 | + elem := reflect.TypeOf(listMoneyIncentivesQuery).Elem() | ||
36 | + for _, validErr := range valid.Errors { | ||
37 | + field, isExist := elem.FieldByName(validErr.Field) | ||
38 | + if isExist { | ||
39 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
40 | + } else { | ||
41 | + return fmt.Errorf(validErr.Message) | ||
42 | + } | ||
43 | + } | ||
44 | + } | ||
45 | + return nil | ||
46 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type SearchDividendsEstimateQuery struct { | ||
12 | + // 承接人分红预算单号 | ||
13 | + DividendsEstimateOrderNumber string `cname:"承接人分红预算单号" json:"dividendsEstimateOrderNumber" valid:"Required"` | ||
14 | + // 分红类型,1订单分红,2退货冲销,3金额激励 | ||
15 | + DividendsType int32 `cname:"分红类型,1订单分红,2退货冲销,3金额激励" json:"dividendsType" valid:"Required"` | ||
16 | + // 公司ID,通过集成REST上下文获取 | ||
17 | + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"` | ||
18 | + // 组织机构ID | ||
19 | + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` | ||
20 | + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | ||
21 | + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"` | ||
22 | +} | ||
23 | + | ||
24 | +func (searchDividendsEstimateQuery *SearchDividendsEstimateQuery) Valid(validation *validation.Validation) { | ||
25 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
26 | +} | ||
27 | + | ||
28 | +func (searchDividendsEstimateQuery *SearchDividendsEstimateQuery) ValidateQuery() error { | ||
29 | + valid := validation.Validation{} | ||
30 | + b, err := valid.Valid(searchDividendsEstimateQuery) | ||
31 | + if err != nil { | ||
32 | + return err | ||
33 | + } | ||
34 | + if !b { | ||
35 | + elem := reflect.TypeOf(searchDividendsEstimateQuery).Elem() | ||
36 | + for _, validErr := range valid.Errors { | ||
37 | + field, isExist := elem.FieldByName(validErr.Field) | ||
38 | + if isExist { | ||
39 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
40 | + } else { | ||
41 | + return fmt.Errorf(validErr.Message) | ||
42 | + } | ||
43 | + } | ||
44 | + } | ||
45 | + return nil | ||
46 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type SearchDividendsIncentivesQuery struct { | ||
12 | + // 合约编号 | ||
13 | + CooperationContractNumber string `cname:"合约编号" json:"cooperationContractNumber,omitempty"` | ||
14 | + // 分红订单号/退货单号 | ||
15 | + OrderOrReturnedOrderNum string `cname:"分红订单号/退货单号" json:"orderOrReturnedOrderNum,omitempty"` | ||
16 | + // 公司ID,通过集成REST上下文获取 | ||
17 | + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"` | ||
18 | + // 组织机构ID | ||
19 | + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` | ||
20 | + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | ||
21 | + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"` | ||
22 | +} | ||
23 | + | ||
24 | +func (searchDividendsIncentivesQuery *SearchDividendsIncentivesQuery) Valid(validation *validation.Validation) { | ||
25 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
26 | +} | ||
27 | + | ||
28 | +func (searchDividendsIncentivesQuery *SearchDividendsIncentivesQuery) ValidateQuery() error { | ||
29 | + valid := validation.Validation{} | ||
30 | + b, err := valid.Valid(searchDividendsIncentivesQuery) | ||
31 | + if err != nil { | ||
32 | + return err | ||
33 | + } | ||
34 | + if !b { | ||
35 | + elem := reflect.TypeOf(searchDividendsIncentivesQuery).Elem() | ||
36 | + for _, validErr := range valid.Errors { | ||
37 | + field, isExist := elem.FieldByName(validErr.Field) | ||
38 | + if isExist { | ||
39 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
40 | + } else { | ||
41 | + return fmt.Errorf(validErr.Message) | ||
42 | + } | ||
43 | + } | ||
44 | + } | ||
45 | + return nil | ||
46 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "reflect" | ||
6 | + "strings" | ||
7 | + | ||
8 | + "github.com/beego/beego/v2/core/validation" | ||
9 | +) | ||
10 | + | ||
11 | +type SearchMoneyIncentivesQuery struct { | ||
12 | + // 共创合约名称 | ||
13 | + CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName,omitempty"` | ||
14 | + // 发起部门名称 | ||
15 | + DepartmentName string `cname:"发起部门名称" json:"departmentName,omitempty"` | ||
16 | + // 公司ID,通过集成REST上下文获取 | ||
17 | + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"` | ||
18 | + // 组织机构ID | ||
19 | + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` | ||
20 | + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | ||
21 | + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"` | ||
22 | +} | ||
23 | + | ||
24 | +func (searchMoneyIncentivesQuery *SearchMoneyIncentivesQuery) Valid(validation *validation.Validation) { | ||
25 | + validation.SetError("CustomValid", "未实现的自定义认证") | ||
26 | +} | ||
27 | + | ||
28 | +func (searchMoneyIncentivesQuery *SearchMoneyIncentivesQuery) ValidateQuery() error { | ||
29 | + valid := validation.Validation{} | ||
30 | + b, err := valid.Valid(searchMoneyIncentivesQuery) | ||
31 | + if err != nil { | ||
32 | + return err | ||
33 | + } | ||
34 | + if !b { | ||
35 | + elem := reflect.TypeOf(searchMoneyIncentivesQuery).Elem() | ||
36 | + for _, validErr := range valid.Errors { | ||
37 | + field, isExist := elem.FieldByName(validErr.Field) | ||
38 | + if isExist { | ||
39 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
40 | + } else { | ||
41 | + return fmt.Errorf(validErr.Message) | ||
42 | + } | ||
43 | + } | ||
44 | + } | ||
45 | + return nil | ||
46 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/linmadan/egglib-go/core/application" | ||
6 | + "github.com/linmadan/egglib-go/utils/tool_funs" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/command" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/query" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | ||
11 | +) | ||
12 | + | ||
13 | +// DividendsEstimateService 分红预算服务 | ||
14 | +type DividendsEstimateService struct { | ||
15 | +} | ||
16 | + | ||
17 | +// CancelDividendsEstimate 取消分红预算 | ||
18 | +func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimate(cancelDividendsEstimateCommand *command.CancelDividendsEstimateCommand) (interface{}, error) { | ||
19 | + if err := cancelDividendsEstimateCommand.ValidateCommand(); err != nil { | ||
20 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
21 | + } | ||
22 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
23 | + if err != nil { | ||
24 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
25 | + } | ||
26 | + if err := transactionContext.StartTransaction(); err != nil { | ||
27 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
28 | + } | ||
29 | + defer func() { | ||
30 | + transactionContext.RollbackTransaction() | ||
31 | + }() | ||
32 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
33 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
34 | + } | ||
35 | + return nil, nil | ||
36 | +} | ||
37 | + | ||
38 | +// CreateDividendsEstimate 创建分红预算服务 | ||
39 | +func (dividendsEstimateService *DividendsEstimateService) CreateDividendsEstimate(createDividendsEstimateCommand *command.CreateDividendsEstimateCommand) (interface{}, error) { | ||
40 | + if err := createDividendsEstimateCommand.ValidateCommand(); err != nil { | ||
41 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
42 | + } | ||
43 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
44 | + if err != nil { | ||
45 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
46 | + } | ||
47 | + if err := transactionContext.StartTransaction(); err != nil { | ||
48 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
49 | + } | ||
50 | + defer func() { | ||
51 | + transactionContext.RollbackTransaction() | ||
52 | + }() | ||
53 | + newDividendsEstimate := &domain.DividendsEstimate{ | ||
54 | + //CompanyId: createDividendsEstimateCommand.CompanyId, | ||
55 | + //OrgId: createDividendsEstimateCommand.OrgId, | ||
56 | + //UserId: createDividendsEstimateCommand.UserId, | ||
57 | + } | ||
58 | + var dividendsEstimateRepository domain.DividendsEstimateRepository | ||
59 | + if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ | ||
60 | + "transactionContext": transactionContext, | ||
61 | + }); err != nil { | ||
62 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
63 | + } else { | ||
64 | + dividendsEstimateRepository = value | ||
65 | + } | ||
66 | + if dividendsEstimate, err := dividendsEstimateRepository.Save(newDividendsEstimate); err != nil { | ||
67 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
68 | + } else { | ||
69 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
70 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
71 | + } | ||
72 | + return dividendsEstimate, nil | ||
73 | + } | ||
74 | +} | ||
75 | + | ||
76 | +// EstimateDividendsIncentives 确定预算分红激励 | ||
77 | +func (dividendsEstimateService *DividendsEstimateService) EstimateDividendsIncentives(estimateDividendsIncentivesCommand *command.EstimateDividendsIncentivesCommand) (interface{}, error) { | ||
78 | + if err := estimateDividendsIncentivesCommand.ValidateCommand(); err != nil { | ||
79 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
80 | + } | ||
81 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
82 | + if err != nil { | ||
83 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
84 | + } | ||
85 | + if err := transactionContext.StartTransaction(); err != nil { | ||
86 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
87 | + } | ||
88 | + defer func() { | ||
89 | + transactionContext.RollbackTransaction() | ||
90 | + }() | ||
91 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
92 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
93 | + } | ||
94 | + return nil, nil | ||
95 | +} | ||
96 | + | ||
97 | +// EstimateMoneyIncentives 确定预算金额激励分红 | ||
98 | +func (dividendsEstimateService *DividendsEstimateService) EstimateMoneyIncentives(estimateMoneyIncentivesCommand *command.EstimateMoneyIncentivesCommand) (interface{}, error) { | ||
99 | + if err := estimateMoneyIncentivesCommand.ValidateCommand(); err != nil { | ||
100 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
101 | + } | ||
102 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
103 | + if err != nil { | ||
104 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
105 | + } | ||
106 | + if err := transactionContext.StartTransaction(); err != nil { | ||
107 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
108 | + } | ||
109 | + defer func() { | ||
110 | + transactionContext.RollbackTransaction() | ||
111 | + }() | ||
112 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
113 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
114 | + } | ||
115 | + return nil, nil | ||
116 | +} | ||
117 | + | ||
118 | +// GetDividendsEstimate 返回分红预算服务 | ||
119 | +func (dividendsEstimateService *DividendsEstimateService) GetDividendsEstimate(getDividendsEstimateQuery *query.GetDividendsEstimateQuery) (interface{}, error) { | ||
120 | + if err := getDividendsEstimateQuery.ValidateQuery(); err != nil { | ||
121 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
122 | + } | ||
123 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
124 | + if err != nil { | ||
125 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
126 | + } | ||
127 | + if err := transactionContext.StartTransaction(); err != nil { | ||
128 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
129 | + } | ||
130 | + defer func() { | ||
131 | + transactionContext.RollbackTransaction() | ||
132 | + }() | ||
133 | + var dividendsEstimateRepository domain.DividendsEstimateRepository | ||
134 | + if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ | ||
135 | + "transactionContext": transactionContext, | ||
136 | + }); err != nil { | ||
137 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
138 | + } else { | ||
139 | + dividendsEstimateRepository = value | ||
140 | + } | ||
141 | + dividendsEstimate, err := dividendsEstimateRepository.FindOne(map[string]interface{}{"dividendsEstimateId": getDividendsEstimateQuery.DividendsEstimateId}) | ||
142 | + if err != nil { | ||
143 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
144 | + } | ||
145 | + if dividendsEstimate == nil { | ||
146 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getDividendsEstimateQuery.DividendsEstimateId))) | ||
147 | + } else { | ||
148 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
149 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
150 | + } | ||
151 | + return dividendsEstimate, nil | ||
152 | + } | ||
153 | +} | ||
154 | + | ||
155 | +// ListDividendsEstimate 返回分红预算服务列表 | ||
156 | +func (dividendsEstimateService *DividendsEstimateService) ListDividendsEstimate(listDividendsEstimateQuery *query.ListDividendsEstimateQuery) (interface{}, error) { | ||
157 | + if err := listDividendsEstimateQuery.ValidateQuery(); err != nil { | ||
158 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
159 | + } | ||
160 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
161 | + if err != nil { | ||
162 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
163 | + } | ||
164 | + if err := transactionContext.StartTransaction(); err != nil { | ||
165 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
166 | + } | ||
167 | + defer func() { | ||
168 | + transactionContext.RollbackTransaction() | ||
169 | + }() | ||
170 | + var dividendsEstimateRepository domain.DividendsEstimateRepository | ||
171 | + if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ | ||
172 | + "transactionContext": transactionContext, | ||
173 | + }); err != nil { | ||
174 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
175 | + } else { | ||
176 | + dividendsEstimateRepository = value | ||
177 | + } | ||
178 | + if count, dividendsEstimates, err := dividendsEstimateRepository.Find(tool_funs.SimpleStructToMap(listDividendsEstimateQuery)); err != nil { | ||
179 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
180 | + } else { | ||
181 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
182 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
183 | + } | ||
184 | + return map[string]interface{}{ | ||
185 | + "count": count, | ||
186 | + "dividendsEstimates": dividendsEstimates, | ||
187 | + }, nil | ||
188 | + } | ||
189 | +} | ||
190 | + | ||
191 | +// ListDividendsIncentives 返回业绩激励分红 | ||
192 | +func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentives(listDividendsIncentivesQuery *query.ListDividendsIncentivesQuery) (interface{}, error) { | ||
193 | + if err := listDividendsIncentivesQuery.ValidateQuery(); err != nil { | ||
194 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
195 | + } | ||
196 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
197 | + if err != nil { | ||
198 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
199 | + } | ||
200 | + if err := transactionContext.StartTransaction(); err != nil { | ||
201 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
202 | + } | ||
203 | + defer func() { | ||
204 | + transactionContext.RollbackTransaction() | ||
205 | + }() | ||
206 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
207 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
208 | + } | ||
209 | + return nil, nil | ||
210 | +} | ||
211 | + | ||
212 | +// ListMoneyIncentives 返回金额激励分红 | ||
213 | +func (dividendsEstimateService *DividendsEstimateService) ListMoneyIncentives(listMoneyIncentivesQuery *query.ListMoneyIncentivesQuery) (interface{}, error) { | ||
214 | + if err := listMoneyIncentivesQuery.ValidateQuery(); err != nil { | ||
215 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
216 | + } | ||
217 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
218 | + if err != nil { | ||
219 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
220 | + } | ||
221 | + if err := transactionContext.StartTransaction(); err != nil { | ||
222 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
223 | + } | ||
224 | + defer func() { | ||
225 | + transactionContext.RollbackTransaction() | ||
226 | + }() | ||
227 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
228 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
229 | + } | ||
230 | + return nil, nil | ||
231 | +} | ||
232 | + | ||
233 | +// RemoveDividendsEstimate 移除分红预算服务 | ||
234 | +func (dividendsEstimateService *DividendsEstimateService) RemoveDividendsEstimate(removeDividendsEstimateCommand *command.RemoveDividendsEstimateCommand) (interface{}, error) { | ||
235 | + if err := removeDividendsEstimateCommand.ValidateCommand(); err != nil { | ||
236 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
237 | + } | ||
238 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
239 | + if err != nil { | ||
240 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
241 | + } | ||
242 | + if err := transactionContext.StartTransaction(); err != nil { | ||
243 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
244 | + } | ||
245 | + defer func() { | ||
246 | + transactionContext.RollbackTransaction() | ||
247 | + }() | ||
248 | + var dividendsEstimateRepository domain.DividendsEstimateRepository | ||
249 | + if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ | ||
250 | + "transactionContext": transactionContext, | ||
251 | + }); err != nil { | ||
252 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
253 | + } else { | ||
254 | + dividendsEstimateRepository = value | ||
255 | + } | ||
256 | + dividendsEstimate, err := dividendsEstimateRepository.FindOne(map[string]interface{}{"dividendsEstimateId": removeDividendsEstimateCommand.DividendsEstimateId}) | ||
257 | + if err != nil { | ||
258 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
259 | + } | ||
260 | + if dividendsEstimate == nil { | ||
261 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeDividendsEstimateCommand.DividendsEstimateId))) | ||
262 | + } | ||
263 | + if dividendsEstimate, err := dividendsEstimateRepository.Remove(dividendsEstimate); err != nil { | ||
264 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
265 | + } else { | ||
266 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
267 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
268 | + } | ||
269 | + return dividendsEstimate, nil | ||
270 | + } | ||
271 | +} | ||
272 | + | ||
273 | +// SearchDividendsEstimate 查询分红预算单 | ||
274 | +func (dividendsEstimateService *DividendsEstimateService) SearchDividendsEstimate(searchDividendsEstimateQuery *query.SearchDividendsEstimateQuery) (interface{}, error) { | ||
275 | + if err := searchDividendsEstimateQuery.ValidateQuery(); err != nil { | ||
276 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
277 | + } | ||
278 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
279 | + if err != nil { | ||
280 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
281 | + } | ||
282 | + if err := transactionContext.StartTransaction(); err != nil { | ||
283 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
284 | + } | ||
285 | + defer func() { | ||
286 | + transactionContext.RollbackTransaction() | ||
287 | + }() | ||
288 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
289 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
290 | + } | ||
291 | + return nil, nil | ||
292 | +} | ||
293 | + | ||
294 | +// SearchDividendsIncentives 查询业绩分红 | ||
295 | +func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncentives(searchDividendsIncentivesQuery *query.SearchDividendsIncentivesQuery) (interface{}, error) { | ||
296 | + if err := searchDividendsIncentivesQuery.ValidateQuery(); err != nil { | ||
297 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
298 | + } | ||
299 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
300 | + if err != nil { | ||
301 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
302 | + } | ||
303 | + if err := transactionContext.StartTransaction(); err != nil { | ||
304 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
305 | + } | ||
306 | + defer func() { | ||
307 | + transactionContext.RollbackTransaction() | ||
308 | + }() | ||
309 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
310 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
311 | + } | ||
312 | + return nil, nil | ||
313 | +} | ||
314 | + | ||
315 | +// SearchMoneyIncentives 查询金额激励分红 | ||
316 | +func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentives(searchMoneyIncentivesQuery *query.SearchMoneyIncentivesQuery) (interface{}, error) { | ||
317 | + if err := searchMoneyIncentivesQuery.ValidateQuery(); err != nil { | ||
318 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
319 | + } | ||
320 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
321 | + if err != nil { | ||
322 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
323 | + } | ||
324 | + if err := transactionContext.StartTransaction(); err != nil { | ||
325 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
326 | + } | ||
327 | + defer func() { | ||
328 | + transactionContext.RollbackTransaction() | ||
329 | + }() | ||
330 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
331 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
332 | + } | ||
333 | + return nil, nil | ||
334 | +} | ||
335 | + | ||
336 | +// UpdateDividendsEstimate 更新分红预算服务 | ||
337 | +func (dividendsEstimateService *DividendsEstimateService) UpdateDividendsEstimate(updateDividendsEstimateCommand *command.UpdateDividendsEstimateCommand) (interface{}, error) { | ||
338 | + if err := updateDividendsEstimateCommand.ValidateCommand(); err != nil { | ||
339 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
340 | + } | ||
341 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
342 | + if err != nil { | ||
343 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
344 | + } | ||
345 | + if err := transactionContext.StartTransaction(); err != nil { | ||
346 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
347 | + } | ||
348 | + defer func() { | ||
349 | + transactionContext.RollbackTransaction() | ||
350 | + }() | ||
351 | + var dividendsEstimateRepository domain.DividendsEstimateRepository | ||
352 | + if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ | ||
353 | + "transactionContext": transactionContext, | ||
354 | + }); err != nil { | ||
355 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
356 | + } else { | ||
357 | + dividendsEstimateRepository = value | ||
358 | + } | ||
359 | + dividendsEstimate, err := dividendsEstimateRepository.FindOne(map[string]interface{}{"dividendsEstimateId": updateDividendsEstimateCommand.DividendsEstimateId}) | ||
360 | + if err != nil { | ||
361 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
362 | + } | ||
363 | + if dividendsEstimate == nil { | ||
364 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateDividendsEstimateCommand.DividendsEstimateId))) | ||
365 | + } | ||
366 | + if err := dividendsEstimate.Update(tool_funs.SimpleStructToMap(updateDividendsEstimateCommand)); err != nil { | ||
367 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
368 | + } | ||
369 | + if dividendsEstimate, err := dividendsEstimateRepository.Save(dividendsEstimate); err != nil { | ||
370 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
371 | + } else { | ||
372 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
373 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
374 | + } | ||
375 | + return dividendsEstimate, nil | ||
376 | + } | ||
377 | +} | ||
378 | + | ||
379 | +func NewDividendsEstimateService(options map[string]interface{}) *DividendsEstimateService { | ||
380 | + newDividendsEstimateService := &DividendsEstimateService{} | ||
381 | + return newDividendsEstimateService | ||
382 | +} |
pkg/domain/order_amount_by_type.go
0 → 100644
-
请 注册 或 登录 后发表评论