Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…
…ion-cooperation into dev
正在显示
4 个修改的文件
包含
44 行增加
和
30 行删除
@@ -138,6 +138,26 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | @@ -138,6 +138,26 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | ||
138 | department = data | 138 | department = data |
139 | } | 139 | } |
140 | 140 | ||
141 | + // 共创项目仓储初始化 | ||
142 | + var cooperationProjectRepository domain.CooperationProjectRepository | ||
143 | + if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ | ||
144 | + "transactionContext": transactionContext, | ||
145 | + }); err != nil { | ||
146 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
147 | + } else { | ||
148 | + cooperationProjectRepository = value | ||
149 | + } | ||
150 | + | ||
151 | + // 共创项目DAO初始化 | ||
152 | + var cooperationProjectDao *dao.CooperationProjectDao | ||
153 | + if value, err := factory.CreateCooperationProjectDao(map[string]interface{}{ | ||
154 | + "transactionContext": transactionContext, | ||
155 | + }); err != nil { | ||
156 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
157 | + } else { | ||
158 | + cooperationProjectDao = value | ||
159 | + } | ||
160 | + | ||
141 | // 查找共创模式 | 161 | // 查找共创模式 |
142 | var cooperationModeRepository domain.CooperationModeRepository | 162 | var cooperationModeRepository domain.CooperationModeRepository |
143 | if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{ | 163 | if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{ |
@@ -147,22 +167,17 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | @@ -147,22 +167,17 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | ||
147 | } else { | 167 | } else { |
148 | cooperationModeRepository = value | 168 | cooperationModeRepository = value |
149 | } | 169 | } |
150 | - cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeNumber": createCooperationProjectCommand.CooperationModeNumber}) | 170 | + cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{ |
171 | + "companyId": createCooperationProjectCommand.CompanyId, | ||
172 | + "orgId": createCooperationProjectCommand.OrgId, | ||
173 | + "cooperationModeNumber": createCooperationProjectCommand.CooperationModeNumber, | ||
174 | + }) | ||
151 | if err != nil { | 175 | if err != nil { |
152 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在") | 176 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在") |
153 | } | 177 | } |
154 | if cooperationMode == nil { | 178 | if cooperationMode == nil { |
155 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createCooperationProjectCommand.CooperationModeNumber)) | 179 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createCooperationProjectCommand.CooperationModeNumber)) |
156 | } else { | 180 | } else { |
157 | - // 共创项目DAO初始化 | ||
158 | - var cooperationProjectDao *dao.CooperationProjectDao | ||
159 | - if value, err := factory.CreateCooperationProjectDao(map[string]interface{}{ | ||
160 | - "transactionContext": transactionContext, | ||
161 | - }); err != nil { | ||
162 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
163 | - } else { | ||
164 | - cooperationProjectDao = value | ||
165 | - } | ||
166 | // 生成共创项目编号 | 181 | // 生成共创项目编号 |
167 | projectNumber, err2 := cooperationProjectDao.GenerateProjectNumber(map[string]interface{}{ | 182 | projectNumber, err2 := cooperationProjectDao.GenerateProjectNumber(map[string]interface{}{ |
168 | "companyId": createCooperationProjectCommand.CompanyId, | 183 | "companyId": createCooperationProjectCommand.CompanyId, |
@@ -172,21 +187,27 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | @@ -172,21 +187,27 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | ||
172 | } | 187 | } |
173 | 188 | ||
174 | // 校验共创项目编号是否唯一 | 189 | // 校验共创项目编号是否唯一 |
175 | - numberAvailable, _ := cooperationProjectDao.CheckProjectNumberAvailable(map[string]interface{}{ | 190 | + numberAvailable, err := cooperationProjectDao.CheckProjectNumberAvailable(map[string]interface{}{ |
176 | "companyId": createCooperationProjectCommand.CompanyId, | 191 | "companyId": createCooperationProjectCommand.CompanyId, |
177 | "orgId": createCooperationProjectCommand.OrgId, | 192 | "orgId": createCooperationProjectCommand.OrgId, |
178 | "cooperationProjectNumber": projectNumber, | 193 | "cooperationProjectNumber": projectNumber, |
179 | }) | 194 | }) |
195 | + if err != nil { | ||
196 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
197 | + } | ||
180 | if !numberAvailable { | 198 | if !numberAvailable { |
181 | return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增共创项目异常") | 199 | return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增共创项目异常") |
182 | } | 200 | } |
183 | 201 | ||
184 | // 校验共创项目名称是否唯一 | 202 | // 校验共创项目名称是否唯一 |
185 | - nameAvailable, _ := cooperationProjectDao.CheckProjectNameAvailable(map[string]interface{}{ | 203 | + nameAvailable, err := cooperationProjectDao.CheckProjectNameAvailable(map[string]interface{}{ |
186 | "companyId": createCooperationProjectCommand.CompanyId, | 204 | "companyId": createCooperationProjectCommand.CompanyId, |
187 | "orgId": createCooperationProjectCommand.OrgId, | 205 | "orgId": createCooperationProjectCommand.OrgId, |
188 | "cooperationProjectName": createCooperationProjectCommand.CooperationProjectName, | 206 | "cooperationProjectName": createCooperationProjectCommand.CooperationProjectName, |
189 | }) | 207 | }) |
208 | + if err != nil { | ||
209 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
210 | + } | ||
190 | if !nameAvailable { | 211 | if !nameAvailable { |
191 | return nil, application.ThrowError(application.TRANSACTION_ERROR, "共创项目名称重复") | 212 | return nil, application.ThrowError(application.TRANSACTION_ERROR, "共创项目名称重复") |
192 | } | 213 | } |
@@ -212,14 +233,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | @@ -212,14 +233,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | ||
212 | CreatedAt: time.Now(), | 233 | CreatedAt: time.Now(), |
213 | ApplicantCount: 0, | 234 | ApplicantCount: 0, |
214 | } | 235 | } |
215 | - var cooperationProjectRepository domain.CooperationProjectRepository | ||
216 | - if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ | ||
217 | - "transactionContext": transactionContext, | ||
218 | - }); err != nil { | ||
219 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
220 | - } else { | ||
221 | - cooperationProjectRepository = value | ||
222 | - } | 236 | + |
223 | if cooperationProject, err := cooperationProjectRepository.Save(newCooperationProject); err != nil { | 237 | if cooperationProject, err := cooperationProjectRepository.Save(newCooperationProject); err != nil { |
224 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 238 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
225 | } else { | 239 | } else { |
@@ -169,8 +169,8 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD | @@ -169,8 +169,8 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD | ||
169 | // 校验产品关联合约的激励规则是否匹配订单时间 | 169 | // 校验产品关联合约的激励规则是否匹配订单时间 |
170 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { | 170 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { |
171 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { | 171 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { |
172 | - if !((orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && | ||
173 | - (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd))) { | 172 | + if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && |
173 | + (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) { | ||
174 | ruleMatchedFlag = true | 174 | ruleMatchedFlag = true |
175 | break | 175 | break |
176 | } | 176 | } |
@@ -755,8 +755,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD | @@ -755,8 +755,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD | ||
755 | // 校验产品关联合约的激励规则是否匹配订单时间 | 755 | // 校验产品关联合约的激励规则是否匹配订单时间 |
756 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { | 756 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { |
757 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { | 757 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { |
758 | - if !((orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && | ||
759 | - (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd))) { | 758 | + if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && |
759 | + (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) { | ||
760 | ruleMatchedFlag = true | 760 | ruleMatchedFlag = true |
761 | break | 761 | break |
762 | } | 762 | } |
@@ -1207,8 +1207,8 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD | @@ -1207,8 +1207,8 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD | ||
1207 | // 校验产品关联合约的激励规则是否匹配订单时间 | 1207 | // 校验产品关联合约的激励规则是否匹配订单时间 |
1208 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { | 1208 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { |
1209 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { | 1209 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { |
1210 | - if !((orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && | ||
1211 | - (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd))) { | 1210 | + if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && |
1211 | + (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) { | ||
1212 | ruleMatchedFlag = true | 1212 | ruleMatchedFlag = true |
1213 | break | 1213 | break |
1214 | } | 1214 | } |
@@ -176,7 +176,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide | @@ -176,7 +176,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide | ||
176 | // 校验产品关联合约的激励规则是否匹配订单时间 | 176 | // 校验产品关联合约的激励规则是否匹配订单时间 |
177 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { | 177 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { |
178 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { | 178 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { |
179 | - if !(orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && | 179 | + if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && |
180 | (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) { | 180 | (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) { |
181 | ruleMatchedFlag = true | 181 | ruleMatchedFlag = true |
182 | break | 182 | break |
@@ -1179,8 +1179,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide | @@ -1179,8 +1179,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide | ||
1179 | // 校验产品关联合约的激励规则是否匹配订单时间 | 1179 | // 校验产品关联合约的激励规则是否匹配订单时间 |
1180 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { | 1180 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { |
1181 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { | 1181 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { |
1182 | - if !((orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && | ||
1183 | - (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd))) { | 1182 | + if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && |
1183 | + (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) { | ||
1184 | ruleMatchedFlag = true | 1184 | ruleMatchedFlag = true |
1185 | break | 1185 | break |
1186 | } | 1186 | } |
@@ -118,7 +118,7 @@ func (dao *CooperationProjectDao) CheckProjectNameAvailable(queryOptions map[str | @@ -118,7 +118,7 @@ func (dao *CooperationProjectDao) CheckProjectNameAvailable(queryOptions map[str | ||
118 | if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { | 118 | if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { |
119 | query = query.Where(`cooperation_project.org @> '{"orgId":"?"}'`, orgId) | 119 | query = query.Where(`cooperation_project.org @> '{"orgId":"?"}'`, orgId) |
120 | } | 120 | } |
121 | - query.Where("cooperation_project.status = ?", 1) | 121 | + query.Where("cooperation_project.status = ?", 1) |
122 | ok, err := query.Exists() | 122 | ok, err := query.Exists() |
123 | return !ok, err | 123 | return !ok, err |
124 | } | 124 | } |
-
请 注册 或 登录 后发表评论