正在显示
4 个修改的文件
包含
84 行增加
和
30 行删除
@@ -9,59 +9,84 @@ import ( | @@ -9,59 +9,84 @@ import ( | ||
9 | "github.com/beego/beego/v2/core/validation" | 9 | "github.com/beego/beego/v2/core/validation" |
10 | ) | 10 | ) |
11 | 11 | ||
12 | +// CreateDividendsIncentivesRulesCommand 业绩分红激励规则 | ||
12 | type CreateDividendsIncentivesRulesCommand struct { | 13 | type CreateDividendsIncentivesRulesCommand struct { |
13 | - DividendsIncentivesRuleId string `cname:"分红激励规则ID" json:"dividendsIncentivesRuleId"` | ||
14 | - CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber"` | ||
15 | - ReferrerPercentage float64 `cname:"推荐人抽成" json:"referrerPercentage"` | ||
16 | - SalesmanPercentage float64 `cname:"业务员抽成" json:"salesmanPercentage"` | ||
17 | - DividendsIncentivesPercentage float64 `cname:"分红规则激励百分点" json:"dividendsIncentivesPercentage"` | ||
18 | - DividendsIncentivesStage int32 `cname:"分红激励阶段" json:"dividendsIncentivesStage"` | ||
19 | - DividendsIncentivesStageEnd time.Time `cname:"业绩分红阶段结束时间" json:"dividendsIncentivesStageEnd"` | 14 | + // 分红激励规则ID |
15 | + DividendsIncentivesRuleId string `cname:"分红激励规则ID" json:"dividendsIncentivesRuleId,omitempty"` | ||
16 | + // 共创合约编号 | ||
17 | + CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber,omitempty"` | ||
18 | + // 推荐人抽成 | ||
19 | + ReferrerPercentage float64 `cname:"推荐人抽成" json:"referrerPercentage"` | ||
20 | + // 业务员抽成 | ||
21 | + SalesmanPercentage float64 `cname:"业务员抽成" json:"salesmanPercentage"` | ||
22 | + // 分红规则激励百分点 | ||
23 | + DividendsIncentivesPercentage float64 `cname:"分红规则激励百分点" json:"dividendsIncentivesPercentage"` | ||
24 | + // 分红激励阶段 | ||
25 | + DividendsIncentivesStage int32 `cname:"分红激励阶段" json:"dividendsIncentivesStage"` | ||
26 | + // 业绩分红阶段开始时间 | ||
20 | DividendsIncentivesStageStart time.Time `cname:"业绩分红阶段开始时间" json:"dividendsIncentivesStageStart"` | 27 | DividendsIncentivesStageStart time.Time `cname:"业绩分红阶段开始时间" json:"dividendsIncentivesStageStart"` |
28 | + // 业绩分红阶段结束时间 | ||
29 | + DividendsIncentivesStageEnd time.Time `cname:"业绩分红阶段结束时间" json:"dividendsIncentivesStageEnd"` | ||
21 | } | 30 | } |
22 | 31 | ||
32 | +// CreateMoneyIncentivesRulesCommand 金额激励规则 | ||
23 | type CreateMoneyIncentivesRulesCommand struct { | 33 | type CreateMoneyIncentivesRulesCommand struct { |
24 | - MoneyIncentivesRuleId string `cname:"金额激励规则ID" json:"moneyIncentivesRuleId"` | ||
25 | - CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber"` | ||
26 | - MoneyIncentivesAmount float64 `cname:"激励金额" json:"moneyIncentivesAmount"` | ||
27 | - MoneyIncentivesStage int32 `cname:"金额激励阶段" json:"moneyIncentivesStage"` | ||
28 | - MoneyIncentivesStageEnd time.Time `cname:"" json:"moneyIncentivesStageEnd"` | ||
29 | - MoneyIncentivesStageStart time.Time `cname:"金额激励时间" json:"moneyIncentivesStageStart"` | ||
30 | - MoneyIncentivesTime time.Time `cname:"" json:"moneyIncentivesTime"` | ||
31 | - ReferrerPercentage float64 `cname:"推荐人抽成" json:"referrerPercentage"` | ||
32 | - SalesmanPercentage float64 `cname:"业务员抽成" json:"salesmanPercentage"` | 34 | + // 金额激励规则ID |
35 | + MoneyIncentivesRuleId string `cname:"金额激励规则ID" json:"moneyIncentivesRuleId"` | ||
36 | + // 共创合约编号 | ||
37 | + CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber"` | ||
38 | + // 激励金额 | ||
39 | + MoneyIncentivesAmount float64 `cname:"激励金额" json:"moneyIncentivesAmount"` | ||
40 | + // 金额激励阶段 | ||
41 | + MoneyIncentivesStage int32 `cname:"金额激励阶段" json:"moneyIncentivesStage"` | ||
42 | + // 金额激励结束时间 | ||
43 | + MoneyIncentivesStageEnd time.Time `cname:"金额激励结束时间" json:"moneyIncentivesStageEnd"` | ||
44 | + // 金额激励开始时间 | ||
45 | + MoneyIncentivesStageStart time.Time `cname:"金额激励开始时间" json:"moneyIncentivesStageStart"` | ||
46 | + // 金额激励时间 | ||
47 | + MoneyIncentivesTime time.Time `cname:"金额激励时间" json:"moneyIncentivesTime"` | ||
48 | + // 推荐人抽成 | ||
49 | + ReferrerPercentage float64 `cname:"推荐人抽成" json:"referrerPercentage"` | ||
50 | + // 业务员抽成 | ||
51 | + SalesmanPercentage float64 `cname:"业务员抽成" json:"salesmanPercentage"` | ||
33 | } | 52 | } |
34 | 53 | ||
54 | +// CreateUndertakersCommand 承接人 | ||
35 | type CreateUndertakersCommand struct { | 55 | type CreateUndertakersCommand struct { |
36 | - UndertakerId string `cname:"承接人ID" json:"undertakerId"` | ||
37 | - UserId string `cname:"承接人UID" json:"userId"` | 56 | + // 承接人ID |
57 | + UndertakerId string `cname:"承接人ID" json:"undertakerId"` | ||
58 | + // 承接人用户ID | ||
59 | + UserId string `cname:"承接人UID" json:"userId"` | ||
60 | + // 附件 | ||
38 | ContractAttachment []struct { | 61 | ContractAttachment []struct { |
62 | + // 文件类型 | ||
39 | FileType string `cname:"文件类型" json:"fileType"` | 63 | FileType string `cname:"文件类型" json:"fileType"` |
40 | - Name string `cname:"文件名称" json:"name"` | ||
41 | - Url string `cname:"文件路径" json:"url"` | ||
42 | - FileSize int64 `cname:"文件大小" json:"fileSize"` | 64 | + // 文件名称 |
65 | + Name string `cname:"文件名称" json:"name"` | ||
66 | + // 文件路径 | ||
67 | + Url string `cname:"文件路径" json:"url"` | ||
68 | + // 文件大小 | ||
69 | + FileSize int64 `cname:"文件大小" json:"fileSize"` | ||
43 | } `cname:"附件" json:"contractAttachment"` | 70 | } `cname:"附件" json:"contractAttachment"` |
71 | + // 推荐人用户ID | ||
44 | ReferrerId string `cname:"推荐UID" json:"referrerId"` | 72 | ReferrerId string `cname:"推荐UID" json:"referrerId"` |
73 | + // 业务员用户ID | ||
45 | SalesmanId string `cname:"业务员UID" json:"salesmanId"` | 74 | SalesmanId string `cname:"业务员UID" json:"salesmanId"` |
46 | } | 75 | } |
47 | 76 | ||
48 | -type CreateRelevantPeopleCommand struct { | ||
49 | - UserId string `cname:"相关人UID" json:"userId"` | ||
50 | -} | ||
51 | - | ||
52 | type CreateCooperationContractCommand struct { | 77 | type CreateCooperationContractCommand struct { |
53 | // 共创合约描述 | 78 | // 共创合约描述 |
54 | CooperationContractDescription string `cname:"共创合约描述" json:"cooperationContractDescription" valid:"Required"` | 79 | CooperationContractDescription string `cname:"共创合约描述" json:"cooperationContractDescription" valid:"Required"` |
55 | // 共创项目编号 | 80 | // 共创项目编号 |
56 | - CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber" valid:"Required"` | ||
57 | - // 共创合约发起部门编码 | 81 | + CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber,omitempty"` |
82 | + // 共创合约发起部门ID | ||
58 | DepartmentId string `cname:"共创合约发起部门ID" json:"departmentId" valid:"Required"` | 83 | DepartmentId string `cname:"共创合约发起部门ID" json:"departmentId" valid:"Required"` |
59 | // 共创合约承接对象,1员工,2共创用户,3公开 | 84 | // 共创合约承接对象,1员工,2共创用户,3公开 |
60 | CooperationContractUndertakerTypes []int32 `cname:"共创合约承接对象" json:"cooperationContractUndertakerTypes" valid:"Required"` | 85 | CooperationContractUndertakerTypes []int32 `cname:"共创合约承接对象" json:"cooperationContractUndertakerTypes" valid:"Required"` |
61 | // 共创合约名称 | 86 | // 共创合约名称 |
62 | CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName" valid:"Required"` | 87 | CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName" valid:"Required"` |
63 | // 共创模式编码 | 88 | // 共创模式编码 |
64 | - CooperationModeNumber string `cname:"共创模式编码" json:"cooperationModeNumber" valid:"Required"` | 89 | + CooperationModeNumber string `cname:"共创模式编码" json:"cooperationModeNumber,omitempty"` |
65 | // 共创合约发起人uid | 90 | // 共创合约发起人uid |
66 | SponsorUid string `cname:"共创合约发起人uid" json:"sponsorUid,omitempty"` | 91 | SponsorUid string `cname:"共创合约发起人uid" json:"sponsorUid,omitempty"` |
67 | // 业绩分红激励规则列表 | 92 | // 业绩分红激励规则列表 |
@@ -94,6 +94,26 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | @@ -94,6 +94,26 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | ||
94 | organization = data | 94 | organization = data |
95 | } | 95 | } |
96 | 96 | ||
97 | + // 部门REST服务初始化 | ||
98 | + var departmentService service.DepartmentService | ||
99 | + if value, err := factory.CreateDepartmentService(map[string]interface{}{}); err != nil { | ||
100 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
101 | + } else { | ||
102 | + departmentService = value | ||
103 | + } | ||
104 | + | ||
105 | + // 获取部门 | ||
106 | + var department *domain.Department | ||
107 | + departmentId, err := strconv.ParseInt(createCooperationContractCommand.DepartmentId, 10, 64) | ||
108 | + if err != nil { | ||
109 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
110 | + } | ||
111 | + if data, err := departmentService.DepartmentFrom(createCooperationContractCommand.CompanyId, departmentId); err != nil { | ||
112 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
113 | + } else { | ||
114 | + department = data | ||
115 | + } | ||
116 | + | ||
97 | // 共创合约DAO初始化 | 117 | // 共创合约DAO初始化 |
98 | var cooperationContractDao *dao.CooperationContractDao | 118 | var cooperationContractDao *dao.CooperationContractDao |
99 | if value, err := factory.CreateCooperationContractDao(map[string]interface{}{ | 119 | if value, err := factory.CreateCooperationContractDao(map[string]interface{}{ |
@@ -103,11 +123,13 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | @@ -103,11 +123,13 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | ||
103 | } else { | 123 | } else { |
104 | cooperationContractDao = value | 124 | cooperationContractDao = value |
105 | } | 125 | } |
126 | + | ||
106 | // 生成共创合约编号 | 127 | // 生成共创合约编号 |
107 | contractNumber, err2 := cooperationContractDao.GenerateContractNumber() | 128 | contractNumber, err2 := cooperationContractDao.GenerateContractNumber() |
108 | if err2 != nil { | 129 | if err2 != nil { |
109 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err2.Error()) | 130 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err2.Error()) |
110 | } | 131 | } |
132 | + | ||
111 | // 校验共创合约编号是否唯一 | 133 | // 校验共创合约编号是否唯一 |
112 | numberAvailable, _ := cooperationContractDao.CheckContractNumberAvailable(map[string]interface{}{ | 134 | numberAvailable, _ := cooperationContractDao.CheckContractNumberAvailable(map[string]interface{}{ |
113 | "companyId": createCooperationContractCommand.CompanyId, | 135 | "companyId": createCooperationContractCommand.CompanyId, |
@@ -122,7 +144,10 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | @@ -122,7 +144,10 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | ||
122 | var undertakers []*domain.Undertaker | 144 | var undertakers []*domain.Undertaker |
123 | for _, undertaker := range createCooperationContractCommand.Undertakers { | 145 | for _, undertaker := range createCooperationContractCommand.Undertakers { |
124 | var undertakerDomain *domain.Undertaker | 146 | var undertakerDomain *domain.Undertaker |
125 | - undertakerUid, _ := strconv.ParseInt(undertaker.UserId, 10, 64) | 147 | + undertakerUid, err := strconv.ParseInt(undertaker.UserId, 10, 64) |
148 | + if err != nil { | ||
149 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人UID错误") | ||
150 | + } | ||
126 | if data, err := userService.UndertakerFrom(createCooperationContractCommand.CompanyId, createCooperationContractCommand.OrgId, undertakerUid); err != nil { | 151 | if data, err := userService.UndertakerFrom(createCooperationContractCommand.CompanyId, createCooperationContractCommand.OrgId, undertakerUid); err != nil { |
127 | log.Logger.Error(err.Error()) | 152 | log.Logger.Error(err.Error()) |
128 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 153 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -268,6 +293,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | @@ -268,6 +293,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | ||
268 | Status: 1, | 293 | Status: 1, |
269 | Org: organization, | 294 | Org: organization, |
270 | Company: company, | 295 | Company: company, |
296 | + Department: department, | ||
271 | Operator: operator, | 297 | Operator: operator, |
272 | DividendsIncentivesRules: dividendsIncentivesRules, | 298 | DividendsIncentivesRules: dividendsIncentivesRules, |
273 | MoneyIncentivesRules: moneyIncentivesRules, | 299 | MoneyIncentivesRules: moneyIncentivesRules, |
@@ -150,6 +150,9 @@ func (repository *CooperationModeRepository) FindOne(queryOptions map[string]int | @@ -150,6 +150,9 @@ func (repository *CooperationModeRepository) FindOne(queryOptions map[string]int | ||
150 | cooperationModeModel := new(models.CooperationMode) | 150 | cooperationModeModel := new(models.CooperationMode) |
151 | query := sqlbuilder.BuildQuery(tx.Model(cooperationModeModel), queryOptions) | 151 | query := sqlbuilder.BuildQuery(tx.Model(cooperationModeModel), queryOptions) |
152 | query.SetWhereByQueryOption("cooperation_mode.cooperation_mode_id = ?", "cooperationModeId") | 152 | query.SetWhereByQueryOption("cooperation_mode.cooperation_mode_id = ?", "cooperationModeId") |
153 | + if cooperationModeNumber, ok := queryOptions["cooperationModeNumber"]; ok && cooperationModeNumber != "" { | ||
154 | + query.Where("cooperation_mode_number = ?", cooperationModeNumber) | ||
155 | + } | ||
153 | if err := query.First(); err != nil { | 156 | if err := query.First(); err != nil { |
154 | if err.Error() == "pg: no rows in result set" { | 157 | if err.Error() == "pg: no rows in result set" { |
155 | return nil, fmt.Errorf("没有此资源") | 158 | return nil, fmt.Errorf("没有此资源") |
@@ -272,7 +272,7 @@ func (repository *DividendsReturnedOrderRepository) Remove(dividendsReturnedOrde | @@ -272,7 +272,7 @@ func (repository *DividendsReturnedOrderRepository) Remove(dividendsReturnedOrde | ||
272 | } else { | 272 | } else { |
273 | // 删除分红退货单产品 | 273 | // 删除分红退货单产品 |
274 | var orderGoodModels []*models.OrderGood | 274 | var orderGoodModels []*models.OrderGood |
275 | - if _, err := tx.Model(&orderGoodModels).Where("dividends_returned_order_number = ?", dividendsReturnedOrder.DividendsOrderNumber).Delete(); err != nil { | 275 | + if _, err := tx.Model(&orderGoodModels).Where("dividends_returned_order_number = ?", dividendsReturnedOrder.DividendsReturnedOrderNumber).Delete(); err != nil { |
276 | return nil, err | 276 | return nil, err |
277 | } | 277 | } |
278 | } | 278 | } |
-
请 注册 或 登录 后发表评论