Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…
…ion-cooperation into dev
正在显示
22 个修改的文件
包含
171 行增加
和
16 行删除
@@ -92,6 +92,7 @@ func (cooperationModeService *CooperationModeService) CreateCooperationMode(crea | @@ -92,6 +92,7 @@ func (cooperationModeService *CooperationModeService) CreateCooperationMode(crea | ||
92 | } else { | 92 | } else { |
93 | cooperationModeDao = value | 93 | cooperationModeDao = value |
94 | } | 94 | } |
95 | + | ||
95 | // 校验共创模式编码唯一性 | 96 | // 校验共创模式编码唯一性 |
96 | numberAvailable, _ := cooperationModeDao.CheckModeNumberAvailable(map[string]interface{}{ | 97 | numberAvailable, _ := cooperationModeDao.CheckModeNumberAvailable(map[string]interface{}{ |
97 | "companyId": createCooperationModeCommand.CompanyId, | 98 | "companyId": createCooperationModeCommand.CompanyId, |
@@ -231,6 +232,8 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo | @@ -231,6 +232,8 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo | ||
231 | defer func() { | 232 | defer func() { |
232 | _ = transactionContext.RollbackTransaction() | 233 | _ = transactionContext.RollbackTransaction() |
233 | }() | 234 | }() |
235 | + | ||
236 | + // 共创模式仓储初始化 | ||
234 | var cooperationModeRepository domain.CooperationModeRepository | 237 | var cooperationModeRepository domain.CooperationModeRepository |
235 | if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{ | 238 | if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{ |
236 | "transactionContext": transactionContext, | 239 | "transactionContext": transactionContext, |
@@ -239,6 +242,18 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo | @@ -239,6 +242,18 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo | ||
239 | } else { | 242 | } else { |
240 | cooperationModeRepository = value | 243 | cooperationModeRepository = value |
241 | } | 244 | } |
245 | + | ||
246 | + // 共创模式DAO初始化 | ||
247 | + var cooperationModeDao *dao.CooperationModeDao | ||
248 | + if value, err := factory.CreateCooperationModeDao(map[string]interface{}{ | ||
249 | + "transactionContext": transactionContext, | ||
250 | + }); err != nil { | ||
251 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
252 | + } else { | ||
253 | + cooperationModeDao = value | ||
254 | + } | ||
255 | + | ||
256 | + // 获取共创模式 | ||
242 | cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeId": removeCooperationModeCommand.CooperationModeId}) | 257 | cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeId": removeCooperationModeCommand.CooperationModeId}) |
243 | if err != nil { | 258 | if err != nil { |
244 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在") | 259 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在") |
@@ -246,13 +261,25 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo | @@ -246,13 +261,25 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo | ||
246 | if cooperationMode == nil { | 261 | if cooperationMode == nil { |
247 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCooperationModeCommand.CooperationModeId, 10))) | 262 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCooperationModeCommand.CooperationModeId, 10))) |
248 | } | 263 | } |
249 | - if cooperationMode, err := cooperationModeRepository.Remove(cooperationMode); err != nil { | 264 | + |
265 | + // 校验共创模式是否可以删除 | ||
266 | + deleteAvailable, _ := cooperationModeDao.CheckModeIsDeleteAvailable(map[string]interface{}{ | ||
267 | + "companyId": removeCooperationModeCommand.CompanyId, | ||
268 | + "orgId": removeCooperationModeCommand.OrgId, | ||
269 | + "cooperationModeNumber": cooperationMode.CooperationModeNumber, | ||
270 | + }) | ||
271 | + if !deleteAvailable { | ||
272 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "当前共创模式存在业务数据,不可删除") | ||
273 | + } | ||
274 | + | ||
275 | + // 移除共创模式 | ||
276 | + if cooperationModeRemoved, err := cooperationModeRepository.Remove(cooperationMode); err != nil { | ||
250 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 277 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
251 | } else { | 278 | } else { |
252 | if err := transactionContext.CommitTransaction(); err != nil { | 279 | if err := transactionContext.CommitTransaction(); err != nil { |
253 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 280 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
254 | } | 281 | } |
255 | - return cooperationMode, nil | 282 | + return cooperationModeRemoved, nil |
256 | } | 283 | } |
257 | } | 284 | } |
258 | 285 | ||
@@ -271,6 +298,8 @@ func (cooperationModeService *CooperationModeService) BatchRemoveCooperationMode | @@ -271,6 +298,8 @@ func (cooperationModeService *CooperationModeService) BatchRemoveCooperationMode | ||
271 | defer func() { | 298 | defer func() { |
272 | _ = transactionContext.RollbackTransaction() | 299 | _ = transactionContext.RollbackTransaction() |
273 | }() | 300 | }() |
301 | + | ||
302 | + // 共创模式仓储初始化 | ||
274 | var cooperationModeRepository domain.CooperationModeRepository | 303 | var cooperationModeRepository domain.CooperationModeRepository |
275 | if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{ | 304 | if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{ |
276 | "transactionContext": transactionContext, | 305 | "transactionContext": transactionContext, |
@@ -279,13 +308,41 @@ func (cooperationModeService *CooperationModeService) BatchRemoveCooperationMode | @@ -279,13 +308,41 @@ func (cooperationModeService *CooperationModeService) BatchRemoveCooperationMode | ||
279 | } else { | 308 | } else { |
280 | cooperationModeRepository = value | 309 | cooperationModeRepository = value |
281 | } | 310 | } |
282 | - cooperationModeIds, _ := utils.SliceAtoi(batchRemoveCooperationModeCommand.CooperationModeIds) | 311 | + |
312 | + // 共创模式ID列表类型转换 | ||
313 | + cooperationModeIds, err := utils.SliceAtoi(batchRemoveCooperationModeCommand.CooperationModeIds) | ||
314 | + if err != nil { | ||
315 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式类型错误") | ||
316 | + } | ||
317 | + | ||
318 | + // 共创模式DAO初始化 | ||
319 | + var cooperationModeDao *dao.CooperationModeDao | ||
320 | + if value, err := factory.CreateCooperationModeDao(map[string]interface{}{ | ||
321 | + "transactionContext": transactionContext, | ||
322 | + }); err != nil { | ||
323 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
324 | + } else { | ||
325 | + cooperationModeDao = value | ||
326 | + } | ||
327 | + | ||
328 | + // 获取共创模式 | ||
283 | if count, cooperationModes, err := cooperationModeRepository.Find(map[string]interface{}{ | 329 | if count, cooperationModes, err := cooperationModeRepository.Find(map[string]interface{}{ |
284 | "cooperationModeIds": cooperationModeIds, | 330 | "cooperationModeIds": cooperationModeIds, |
285 | }); err != nil { | 331 | }); err != nil { |
286 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 332 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
287 | } else { | 333 | } else { |
288 | if count > 0 { | 334 | if count > 0 { |
335 | + for _, cooperationMode := range cooperationModes { | ||
336 | + // 校验共创模式是否可以删除 | ||
337 | + deleteAvailable, _ := cooperationModeDao.CheckModeIsDeleteAvailable(map[string]interface{}{ | ||
338 | + "companyId": batchRemoveCooperationModeCommand.CompanyId, | ||
339 | + "orgId": batchRemoveCooperationModeCommand.OrgId, | ||
340 | + "cooperationModeNumber": cooperationMode.CooperationModeNumber, | ||
341 | + }) | ||
342 | + if !deleteAvailable { | ||
343 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "所选共创模式存在业务数据,不可删除") | ||
344 | + } | ||
345 | + } | ||
289 | if cooperationMode, err := cooperationModeRepository.BatchRemove(cooperationModes); err != nil { | 346 | if cooperationMode, err := cooperationModeRepository.BatchRemove(cooperationModes); err != nil { |
290 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 347 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
291 | } else { | 348 | } else { |
@@ -195,6 +195,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | @@ -195,6 +195,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | ||
195 | UpdatedAt: time.Time{}, | 195 | UpdatedAt: time.Time{}, |
196 | DeletedAt: time.Time{}, | 196 | DeletedAt: time.Time{}, |
197 | CreatedAt: time.Now(), | 197 | CreatedAt: time.Now(), |
198 | + ApplicantCount: 0, | ||
198 | } | 199 | } |
199 | var cooperationProjectRepository domain.CooperationProjectRepository | 200 | var cooperationProjectRepository domain.CooperationProjectRepository |
200 | if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ | 201 | if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ |
@@ -653,6 +653,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -653,6 +653,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
653 | CreatedAt: time.Now(), | 653 | CreatedAt: time.Now(), |
654 | DeletedAt: time.Time{}, | 654 | DeletedAt: time.Time{}, |
655 | UpdatedAt: time.Time{}, | 655 | UpdatedAt: time.Time{}, |
656 | + OrderGoodId: orderGood.OrderGoodId, | ||
657 | + OrderGoodAmount: orderGood.OrderGoodAmount, | ||
656 | } | 658 | } |
657 | dividendsEstimates = append(dividendsEstimates, dividendsEstimate) | 659 | dividendsEstimates = append(dividendsEstimates, dividendsEstimate) |
658 | } | 660 | } |
@@ -696,6 +698,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -696,6 +698,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
696 | CreatedAt: time.Now(), | 698 | CreatedAt: time.Now(), |
697 | DeletedAt: time.Time{}, | 699 | DeletedAt: time.Time{}, |
698 | UpdatedAt: time.Time{}, | 700 | UpdatedAt: time.Time{}, |
701 | + OrderGoodId: orderGood.OrderGoodId, | ||
702 | + OrderGoodAmount: orderGood.OrderGoodAmount, | ||
699 | } | 703 | } |
700 | dividendsEstimates = append(dividendsEstimates, dividendsEstimate) | 704 | dividendsEstimates = append(dividendsEstimates, dividendsEstimate) |
701 | } | 705 | } |
@@ -11,6 +11,8 @@ import ( | @@ -11,6 +11,8 @@ import ( | ||
11 | type GetDividendsOrderQuery struct { | 11 | type GetDividendsOrderQuery struct { |
12 | // 分红订单ID | 12 | // 分红订单ID |
13 | DividendsOrderId int64 `cname:"分红订单ID" json:"dividendsOrderId" valid:"Required"` | 13 | DividendsOrderId int64 `cname:"分红订单ID" json:"dividendsOrderId" valid:"Required"` |
14 | + // 分红订单编号 | ||
15 | + DividendsOrderNumber string `cname:"分红订单编号" json:"dividendsOrderNumber,omitempty"` | ||
14 | // 公司ID,通过集成REST上下文获取 | 16 | // 公司ID,通过集成REST上下文获取 |
15 | CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"` | 17 | CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"` |
16 | // 组织机构ID | 18 | // 组织机构ID |
@@ -41,7 +41,7 @@ type CreateDividendsReturnedOrderCommand struct { | @@ -41,7 +41,7 @@ type CreateDividendsReturnedOrderCommand struct { | ||
41 | // 退货日期 | 41 | // 退货日期 |
42 | DividendsReturnedDate time.Time `cname:"退货日期" json:"dividendsReturnedDate" valid:"Required"` | 42 | DividendsReturnedDate time.Time `cname:"退货日期" json:"dividendsReturnedDate" valid:"Required"` |
43 | // 订单日期 | 43 | // 订单日期 |
44 | - OrderTime time.Time `cname:"订单日期" json:"orderTime" valid:"Required"` | 44 | + OrderTime string `cname:"订单日期" json:"orderTime" valid:"Required"` |
45 | // 退货区域名称 | 45 | // 退货区域名称 |
46 | RegionName string `cname:"退货区域名称" json:"regionName,omitempty"` | 46 | RegionName string `cname:"退货区域名称" json:"regionName,omitempty"` |
47 | // 订单产品列表 | 47 | // 订单产品列表 |
@@ -5,7 +5,6 @@ import ( | @@ -5,7 +5,6 @@ import ( | ||
5 | "github.com/beego/beego/v2/core/validation" | 5 | "github.com/beego/beego/v2/core/validation" |
6 | "reflect" | 6 | "reflect" |
7 | "strings" | 7 | "strings" |
8 | - "time" | ||
9 | ) | 8 | ) |
10 | 9 | ||
11 | type UpdateDividendsReturnedOrderCommand struct { | 10 | type UpdateDividendsReturnedOrderCommand struct { |
@@ -24,7 +23,7 @@ type UpdateDividendsReturnedOrderCommand struct { | @@ -24,7 +23,7 @@ type UpdateDividendsReturnedOrderCommand struct { | ||
24 | // 退货区域 | 23 | // 退货区域 |
25 | RegionName string `cname:"退货区域" json:"regionName,omitempty"` | 24 | RegionName string `cname:"退货区域" json:"regionName,omitempty"` |
26 | // 订单时间 | 25 | // 订单时间 |
27 | - OrderTime time.Time `cname:"订单日期" json:"orderTime" valid:"Required"` | 26 | + OrderTime string `cname:"订单日期" json:"orderTime" valid:"Required"` |
28 | // 订单产品列表 | 27 | // 订单产品列表 |
29 | OrderGoods []*OrderGoods `cname:"订单产品列表" json:"orderGoods,omitempty"` | 28 | OrderGoods []*OrderGoods `cname:"订单产品列表" json:"orderGoods,omitempty"` |
30 | // 公司ID,通过集成REST上下文获取 | 29 | // 公司ID,通过集成REST上下文获取 |
@@ -99,15 +99,25 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide | @@ -99,15 +99,25 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide | ||
99 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 99 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
100 | } | 100 | } |
101 | 101 | ||
102 | + // 订单时间转换 | ||
103 | + orderTimeInt, err := strconv.ParseInt(createDividendsReturnedOrderCommand.OrderTime, 10, 64) | ||
104 | + if err != nil { | ||
105 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间错误") | ||
106 | + } | ||
107 | + orderTime := utils.TransformTimestampToTime(orderTimeInt) | ||
108 | + | ||
102 | // 校验分红退货单编号是否唯一 | 109 | // 校验分红退货单编号是否唯一 |
103 | - //numberAvailable, _ := dividendsReturnedOrderDao.CheckDividendsReturnedOrderNumberAvailable(map[string]interface{}{ | ||
104 | - // "companyId": createDividendsOrderCommand.CompanyId, | ||
105 | - // "orgId": createDividendsOrderCommand.OrgId, | ||
106 | - // "dividendsReturnedOrderNumber": dividendsReturnedOrderNumber, | ||
107 | - //}) | ||
108 | - //if !numberAvailable { | ||
109 | - // return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增分红订单异常") | ||
110 | - //} | 110 | + numberAvailable, err := dividendsReturnedOrderDao.CheckDividendsReturnedOrderNumberAvailable(map[string]interface{}{ |
111 | + "companyId": createDividendsReturnedOrderCommand.CompanyId, | ||
112 | + "orgId": createDividendsReturnedOrderCommand.OrgId, | ||
113 | + "dividendsReturnedOrderNumber": dividendsReturnedOrderNumber, | ||
114 | + }) | ||
115 | + if err != nil { | ||
116 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, err.Error()) | ||
117 | + } | ||
118 | + if !numberAvailable { | ||
119 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红退货单号已存在") | ||
120 | + } | ||
111 | 121 | ||
112 | // 获取分红退货单产品 | 122 | // 获取分红退货单产品 |
113 | var orderGoods []*domain.OrderGood | 123 | var orderGoods []*domain.OrderGood |
@@ -152,6 +162,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide | @@ -152,6 +162,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide | ||
152 | UpdatedAt: time.Time{}, | 162 | UpdatedAt: time.Time{}, |
153 | Operator: operator, | 163 | Operator: operator, |
154 | OperateTime: time.Now(), | 164 | OperateTime: time.Now(), |
165 | + OrderTime: orderTime, | ||
155 | } | 166 | } |
156 | 167 | ||
157 | var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository | 168 | var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository |
@@ -563,6 +574,13 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide | @@ -563,6 +574,13 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide | ||
563 | } | 574 | } |
564 | dividendsReturnedDate := utils.TransformTimestampToTime(dividendsReturnedDateInt) | 575 | dividendsReturnedDate := utils.TransformTimestampToTime(dividendsReturnedDateInt) |
565 | 576 | ||
577 | + // 订单时间转换 | ||
578 | + orderTimeInt, err := strconv.ParseInt(updateDividendsReturnedOrderCommand.OrderTime, 10, 64) | ||
579 | + if err != nil { | ||
580 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间错误") | ||
581 | + } | ||
582 | + orderTime := utils.TransformTimestampToTime(orderTimeInt) | ||
583 | + | ||
566 | // 获取分红退货单 | 584 | // 获取分红退货单 |
567 | dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderId": updateDividendsReturnedOrderCommand.DividendsReturnedOrderId}) | 585 | dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderId": updateDividendsReturnedOrderCommand.DividendsReturnedOrderId}) |
568 | if err != nil { | 586 | if err != nil { |
@@ -607,6 +625,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide | @@ -607,6 +625,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide | ||
607 | dividendsReturnedOrder.DividendsReturnedDate = dividendsReturnedDate | 625 | dividendsReturnedOrder.DividendsReturnedDate = dividendsReturnedDate |
608 | dividendsReturnedOrder.DividendsReturnedOrderRefund = dividendsReturnedOrderAmount | 626 | dividendsReturnedOrder.DividendsReturnedOrderRefund = dividendsReturnedOrderAmount |
609 | dividendsReturnedOrder.Goods = orderGoods | 627 | dividendsReturnedOrder.Goods = orderGoods |
628 | + dividendsReturnedOrder.OrderTime = orderTime | ||
610 | 629 | ||
611 | // 保存分红退货单更新 | 630 | // 保存分红退货单更新 |
612 | if dividendsReturnedOrderSaved, err := dividendsReturnedOrderRepository.Save(dividendsReturnedOrder); err != nil { | 631 | if dividendsReturnedOrderSaved, err := dividendsReturnedOrderRepository.Save(dividendsReturnedOrder); err != nil { |
@@ -7,4 +7,8 @@ type AccountDetail struct { | @@ -7,4 +7,8 @@ type AccountDetail struct { | ||
7 | DividendsType int32 `json:"dividendsType"` | 7 | DividendsType int32 `json:"dividendsType"` |
8 | // 分红金额 | 8 | // 分红金额 |
9 | DividendsAmount float64 `json:"dividendsAmount"` | 9 | DividendsAmount float64 `json:"dividendsAmount"` |
10 | + // 产品ID | ||
11 | + OrderGoodId int64 `json:"orderGoodId"` | ||
12 | + // 订单产品金额 | ||
13 | + OrderGoodAmount float64 `json:"orderGoodAmount"` | ||
10 | } | 14 | } |
@@ -42,6 +42,8 @@ type CooperationProject struct { | @@ -42,6 +42,8 @@ type CooperationProject struct { | ||
42 | DeletedAt time.Time `json:"deletedAt"` | 42 | DeletedAt time.Time `json:"deletedAt"` |
43 | // 创建时间 | 43 | // 创建时间 |
44 | CreatedAt time.Time `json:"createdAt"` | 44 | CreatedAt time.Time `json:"createdAt"` |
45 | + // 共创申请人计数 | ||
46 | + ApplicantCount int32 `json:"applicantCount"` | ||
45 | } | 47 | } |
46 | 48 | ||
47 | type CooperationProjectRepository interface { | 49 | type CooperationProjectRepository interface { |
@@ -26,6 +26,8 @@ type CreditAccount struct { | @@ -26,6 +26,8 @@ type CreditAccount struct { | ||
26 | ParticipateType string `json:"participateType"` | 26 | ParticipateType string `json:"participateType"` |
27 | // 结算明细 | 27 | // 结算明细 |
28 | AccountDetail []*AccountDetail `json:"accountDetail"` | 28 | AccountDetail []*AccountDetail `json:"accountDetail"` |
29 | + // 产品金额统计 | ||
30 | + GoodAmountCount float64 `json:"goodAmountCount"` | ||
29 | // 支付凭证附件 | 31 | // 支付凭证附件 |
30 | PaymentDocumentAttachments []*Attachment `json:"paymentDocumentAttachments"` | 32 | PaymentDocumentAttachments []*Attachment `json:"paymentDocumentAttachments"` |
31 | // 数据所属组织机构 | 33 | // 数据所属组织机构 |
@@ -61,6 +61,10 @@ type DividendsEstimate struct { | @@ -61,6 +61,10 @@ type DividendsEstimate struct { | ||
61 | DeletedAt time.Time `json:"deletedAt"` | 61 | DeletedAt time.Time `json:"deletedAt"` |
62 | // 更新时间 | 62 | // 更新时间 |
63 | UpdatedAt time.Time `json:"updatedAt"` | 63 | UpdatedAt time.Time `json:"updatedAt"` |
64 | + // 订单产品ID | ||
65 | + OrderGoodId int64 `json:"orderGoodId"` | ||
66 | + // 订单产品金额 | ||
67 | + OrderGoodAmount float64 `json:"orderGoodAmount"` | ||
64 | } | 68 | } |
65 | 69 | ||
66 | type DividendsEstimateRepository interface { | 70 | type DividendsEstimateRepository interface { |
@@ -49,6 +49,24 @@ func (dao *CooperationModeDao) CheckModeNumberAvailable(queryOptions map[string] | @@ -49,6 +49,24 @@ func (dao *CooperationModeDao) CheckModeNumberAvailable(queryOptions map[string] | ||
49 | return !ok, err | 49 | return !ok, err |
50 | } | 50 | } |
51 | 51 | ||
52 | +// CheckModeIsDeleteAvailable 校验模式是否有项目数据关联 | ||
53 | +func (dao *CooperationModeDao) CheckModeIsDeleteAvailable(queryOptions map[string]interface{}) (bool, error) { | ||
54 | + tx := dao.transactionContext.PgTx | ||
55 | + var cooperationProjectModels []*models.CooperationProject | ||
56 | + query := tx.Model(&cooperationProjectModels) | ||
57 | + if cooperationModeNumber, ok := queryOptions["cooperationModeNumber"]; ok && cooperationModeNumber != "" { | ||
58 | + query = query.Where("cooperation_mode_number = ?", cooperationModeNumber) | ||
59 | + } | ||
60 | + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { | ||
61 | + query = query.Where(`cooperation_project.company @> '{"companyId":"?"}'`, companyId) | ||
62 | + } | ||
63 | + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { | ||
64 | + query = query.Where(`cooperation_project.org @> '{"orgId":"?"}'`, orgId) | ||
65 | + } | ||
66 | + ok, err := query.Exists() | ||
67 | + return !ok, err | ||
68 | +} | ||
69 | + | ||
52 | // UpdateCooperationModeSlice 更新多个共创模式 | 70 | // UpdateCooperationModeSlice 更新多个共创模式 |
53 | func (dao *CooperationModeDao) UpdateCooperationModeSlice(modeIds []int64, status int32) ([]*domain.CooperationMode, error) { | 71 | func (dao *CooperationModeDao) UpdateCooperationModeSlice(modeIds []int64, status int32) ([]*domain.CooperationMode, error) { |
54 | tx := dao.transactionContext.PgTx | 72 | tx := dao.transactionContext.PgTx |
@@ -35,7 +35,25 @@ func (dao *DividendsReturnedOrderDao) GenerateDividendsReturnedOrderNumber() (st | @@ -35,7 +35,25 @@ func (dao *DividendsReturnedOrderDao) GenerateDividendsReturnedOrderNumber() (st | ||
35 | } | 35 | } |
36 | } | 36 | } |
37 | 37 | ||
38 | -// CalculateDividendsOrderAmount 计算分红订单金额 | 38 | +// CheckDividendsReturnedOrderNumberAvailable 校验分红订单是否唯一 |
39 | +func (dao *DividendsReturnedOrderDao) CheckDividendsReturnedOrderNumberAvailable(queryOptions map[string]interface{}) (bool, error) { | ||
40 | + tx := dao.transactionContext.PgTx | ||
41 | + var dividendsReturnedOrderModels []*models.DividendsReturnedOrder | ||
42 | + query := tx.Model(÷ndsReturnedOrderModels) | ||
43 | + if dividendsOrderNumber, ok := queryOptions["dividendsReturnedOrderNumber"]; ok && dividendsOrderNumber != "" { | ||
44 | + query = query.Where("dividends_returned_order_number = ?", dividendsOrderNumber) | ||
45 | + } | ||
46 | + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { | ||
47 | + query = query.Where(`dividends_returned_order.company @> '{"companyId":"?"}'`, companyId) | ||
48 | + } | ||
49 | + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { | ||
50 | + query = query.Where(`dividends_returned_order.org @> '{"orgId":"?"}'`, orgId) | ||
51 | + } | ||
52 | + ok, err := query.Exists() | ||
53 | + return !ok, err | ||
54 | +} | ||
55 | + | ||
56 | +// CalculateDividendsReturnedOrderAmount 计算分红订单金额 | ||
39 | func (dao *DividendsReturnedOrderDao) CalculateDividendsReturnedOrderAmount(queryOptions map[string]interface{}) (float64, error) { | 57 | func (dao *DividendsReturnedOrderDao) CalculateDividendsReturnedOrderAmount(queryOptions map[string]interface{}) (float64, error) { |
40 | tx := dao.transactionContext.PgTx | 58 | tx := dao.transactionContext.PgTx |
41 | var dividendsOrderModel = new(models.DividendsReturnedOrder) | 59 | var dividendsOrderModel = new(models.DividendsReturnedOrder) |
@@ -45,4 +45,6 @@ type CooperationProject struct { | @@ -45,4 +45,6 @@ type CooperationProject struct { | ||
45 | DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"` | 45 | DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"` |
46 | // 创建时间 | 46 | // 创建时间 |
47 | CreatedAt time.Time `comment:"创建时间"` | 47 | CreatedAt time.Time `comment:"创建时间"` |
48 | + // 申请人统计 | ||
49 | + ApplicantCount int32 `comment:"申请人统计"` | ||
48 | } | 50 | } |
@@ -29,6 +29,8 @@ type CreditAccount struct { | @@ -29,6 +29,8 @@ type CreditAccount struct { | ||
29 | ParticipateType string `comment:"参与类型,承接人,推荐人,业务员"` | 29 | ParticipateType string `comment:"参与类型,承接人,推荐人,业务员"` |
30 | // 结算明细 | 30 | // 结算明细 |
31 | AccountDetail []*domain.AccountDetail `comment:"结算明细"` | 31 | AccountDetail []*domain.AccountDetail `comment:"结算明细"` |
32 | + // 产品金额统计 | ||
33 | + GoodAmountCount float64 `comment:"产品金额统计"` | ||
32 | // 支付凭证附件 | 34 | // 支付凭证附件 |
33 | PaymentDocumentAttachments []*domain.Attachment `comment:"支付凭证附件"` | 35 | PaymentDocumentAttachments []*domain.Attachment `comment:"支付凭证附件"` |
34 | // 数据所属组织机构 | 36 | // 数据所属组织机构 |
@@ -41,5 +41,6 @@ func TransformToCooperationProjectDomainModelFromPgModels( | @@ -41,5 +41,6 @@ func TransformToCooperationProjectDomainModelFromPgModels( | ||
41 | UpdatedAt: cooperationProjectModel.UpdatedAt, | 41 | UpdatedAt: cooperationProjectModel.UpdatedAt, |
42 | DeletedAt: cooperationProjectModel.DeletedAt, | 42 | DeletedAt: cooperationProjectModel.DeletedAt, |
43 | CreatedAt: cooperationProjectModel.CreatedAt, | 43 | CreatedAt: cooperationProjectModel.CreatedAt, |
44 | + ApplicantCount: cooperationProjectModel.ApplicantCount, | ||
44 | }, nil | 45 | }, nil |
45 | } | 46 | } |
@@ -18,6 +18,7 @@ func TransformToCreditAccountDomainModelFromPgModels(creditAccountModel *models. | @@ -18,6 +18,7 @@ func TransformToCreditAccountDomainModelFromPgModels(creditAccountModel *models. | ||
18 | Participator: creditAccountModel.Participator, | 18 | Participator: creditAccountModel.Participator, |
19 | ParticipateType: creditAccountModel.ParticipateType, | 19 | ParticipateType: creditAccountModel.ParticipateType, |
20 | AccountDetail: creditAccountModel.AccountDetail, | 20 | AccountDetail: creditAccountModel.AccountDetail, |
21 | + GoodAmountCount: creditAccountModel.GoodAmountCount, | ||
21 | PaymentDocumentAttachments: creditAccountModel.PaymentDocumentAttachments, | 22 | PaymentDocumentAttachments: creditAccountModel.PaymentDocumentAttachments, |
22 | Org: creditAccountModel.Org, | 23 | Org: creditAccountModel.Org, |
23 | Company: creditAccountModel.Company, | 24 | Company: creditAccountModel.Company, |
@@ -172,6 +172,9 @@ func (repository *CooperationModeRepository) Find(queryOptions map[string]interf | @@ -172,6 +172,9 @@ func (repository *CooperationModeRepository) Find(queryOptions map[string]interf | ||
172 | var cooperationModeModels []*models.CooperationMode | 172 | var cooperationModeModels []*models.CooperationMode |
173 | cooperationModes := make([]*domain.CooperationMode, 0) | 173 | cooperationModes := make([]*domain.CooperationMode, 0) |
174 | query := sqlbuilder.BuildQuery(tx.Model(&cooperationModeModels), queryOptions) | 174 | query := sqlbuilder.BuildQuery(tx.Model(&cooperationModeModels), queryOptions) |
175 | + if cooperationModeIds, ok := queryOptions["cooperationModeIds"]; ok && len(cooperationModeIds.([]int64)) > 0 { | ||
176 | + query.Where("cooperation_mode_id in (?)", pg.In(cooperationModeIds)) | ||
177 | + } | ||
175 | if cooperationModeName, ok := queryOptions["cooperationModeName"]; ok && cooperationModeName != "" { | 178 | if cooperationModeName, ok := queryOptions["cooperationModeName"]; ok && cooperationModeName != "" { |
176 | query.Where("cooperation_mode_name like ?", fmt.Sprintf("%%%s%%", cooperationModeName)) | 179 | query.Where("cooperation_mode_name like ?", fmt.Sprintf("%%%s%%", cooperationModeName)) |
177 | } | 180 | } |
@@ -47,6 +47,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | @@ -47,6 +47,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | ||
47 | "updated_at", | 47 | "updated_at", |
48 | "deleted_at", | 48 | "deleted_at", |
49 | "created_at", | 49 | "created_at", |
50 | + "applicant_count", | ||
50 | } | 51 | } |
51 | insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields) | 52 | insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields) |
52 | insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields) | 53 | insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields) |
@@ -82,6 +83,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | @@ -82,6 +83,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | ||
82 | &cooperationProject.UpdatedAt, | 83 | &cooperationProject.UpdatedAt, |
83 | &cooperationProject.DeletedAt, | 84 | &cooperationProject.DeletedAt, |
84 | &cooperationProject.CreatedAt, | 85 | &cooperationProject.CreatedAt, |
86 | + &cooperationProject.ApplicantCount, | ||
85 | ), | 87 | ), |
86 | fmt.Sprintf("INSERT INTO cooperation_projects (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), | 88 | fmt.Sprintf("INSERT INTO cooperation_projects (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), |
87 | cooperationProject.CooperationProjectId, | 89 | cooperationProject.CooperationProjectId, |
@@ -103,6 +105,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | @@ -103,6 +105,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | ||
103 | cooperationProject.UpdatedAt, | 105 | cooperationProject.UpdatedAt, |
104 | nil, | 106 | nil, |
105 | cooperationProject.CreatedAt, | 107 | cooperationProject.CreatedAt, |
108 | + cooperationProject.ApplicantCount, | ||
106 | ); err != nil { | 109 | ); err != nil { |
107 | return cooperationProject, err | 110 | return cooperationProject, err |
108 | } | 111 | } |
@@ -128,6 +131,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | @@ -128,6 +131,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | ||
128 | &cooperationProject.UpdatedAt, | 131 | &cooperationProject.UpdatedAt, |
129 | &cooperationProject.DeletedAt, | 132 | &cooperationProject.DeletedAt, |
130 | &cooperationProject.CreatedAt, | 133 | &cooperationProject.CreatedAt, |
134 | + &cooperationProject.ApplicantCount, | ||
131 | ), | 135 | ), |
132 | fmt.Sprintf("UPDATE cooperation_projects SET %s WHERE cooperation_project_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), | 136 | fmt.Sprintf("UPDATE cooperation_projects SET %s WHERE cooperation_project_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), |
133 | cooperationProject.CooperationProjectId, | 137 | cooperationProject.CooperationProjectId, |
@@ -149,6 +153,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | @@ -149,6 +153,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | ||
149 | cooperationProject.UpdatedAt, | 153 | cooperationProject.UpdatedAt, |
150 | nil, | 154 | nil, |
151 | cooperationProject.CreatedAt, | 155 | cooperationProject.CreatedAt, |
156 | + cooperationProject.ApplicantCount, | ||
152 | cooperationProject.Identify(), | 157 | cooperationProject.Identify(), |
153 | ); err != nil { | 158 | ); err != nil { |
154 | return cooperationProject, err | 159 | return cooperationProject, err |
@@ -181,6 +186,7 @@ func (repository *CooperationProjectRepository) UpdateMany(cooperationProjects [ | @@ -181,6 +186,7 @@ func (repository *CooperationProjectRepository) UpdateMany(cooperationProjects [ | ||
181 | UpdatedAt: time.Now(), | 186 | UpdatedAt: time.Now(), |
182 | DeletedAt: cooperationProject.DeletedAt, | 187 | DeletedAt: cooperationProject.DeletedAt, |
183 | CreatedAt: cooperationProject.CreatedAt, | 188 | CreatedAt: cooperationProject.CreatedAt, |
189 | + ApplicantCount: cooperationProject.ApplicantCount, | ||
184 | }) | 190 | }) |
185 | } | 191 | } |
186 | if _, err := tx.Model(&cooperationProjectModels).WherePK().Update(); err != nil { | 192 | if _, err := tx.Model(&cooperationProjectModels).WherePK().Update(); err != nil { |
@@ -38,6 +38,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | @@ -38,6 +38,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | ||
38 | "participator", | 38 | "participator", |
39 | "participate_type", | 39 | "participate_type", |
40 | "account_detail", | 40 | "account_detail", |
41 | + "good_amount_count", | ||
41 | "payment_document_attachments", | 42 | "payment_document_attachments", |
42 | "org", | 43 | "org", |
43 | "company", | 44 | "company", |
@@ -74,6 +75,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | @@ -74,6 +75,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | ||
74 | &creditAccount.Participator, | 75 | &creditAccount.Participator, |
75 | &creditAccount.ParticipateType, | 76 | &creditAccount.ParticipateType, |
76 | &creditAccount.AccountDetail, | 77 | &creditAccount.AccountDetail, |
78 | + &creditAccount.GoodAmountCount, | ||
77 | &creditAccount.PaymentDocumentAttachments, | 79 | &creditAccount.PaymentDocumentAttachments, |
78 | &creditAccount.Org, | 80 | &creditAccount.Org, |
79 | &creditAccount.Company, | 81 | &creditAccount.Company, |
@@ -96,6 +98,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | @@ -96,6 +98,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | ||
96 | creditAccount.Participator, | 98 | creditAccount.Participator, |
97 | creditAccount.ParticipateType, | 99 | creditAccount.ParticipateType, |
98 | creditAccount.AccountDetail, | 100 | creditAccount.AccountDetail, |
101 | + creditAccount.GoodAmountCount, | ||
99 | creditAccount.PaymentDocumentAttachments, | 102 | creditAccount.PaymentDocumentAttachments, |
100 | creditAccount.Org, | 103 | creditAccount.Org, |
101 | creditAccount.Company, | 104 | creditAccount.Company, |
@@ -122,6 +125,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | @@ -122,6 +125,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | ||
122 | &creditAccount.Participator, | 125 | &creditAccount.Participator, |
123 | &creditAccount.ParticipateType, | 126 | &creditAccount.ParticipateType, |
124 | &creditAccount.AccountDetail, | 127 | &creditAccount.AccountDetail, |
128 | + &creditAccount.GoodAmountCount, | ||
125 | &creditAccount.PaymentDocumentAttachments, | 129 | &creditAccount.PaymentDocumentAttachments, |
126 | &creditAccount.Org, | 130 | &creditAccount.Org, |
127 | &creditAccount.Company, | 131 | &creditAccount.Company, |
@@ -144,6 +148,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | @@ -144,6 +148,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco | ||
144 | creditAccount.Participator, | 148 | creditAccount.Participator, |
145 | creditAccount.ParticipateType, | 149 | creditAccount.ParticipateType, |
146 | creditAccount.AccountDetail, | 150 | creditAccount.AccountDetail, |
151 | + creditAccount.GoodAmountCount, | ||
147 | creditAccount.PaymentDocumentAttachments, | 152 | creditAccount.PaymentDocumentAttachments, |
148 | creditAccount.Org, | 153 | creditAccount.Org, |
149 | creditAccount.Company, | 154 | creditAccount.Company, |
@@ -367,7 +367,10 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte | @@ -367,7 +367,10 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte | ||
367 | dividendsOrderModel := new(models.DividendsOrder) | 367 | dividendsOrderModel := new(models.DividendsOrder) |
368 | query := sqlbuilder.BuildQuery(tx.Model(dividendsOrderModel), queryOptions) | 368 | query := sqlbuilder.BuildQuery(tx.Model(dividendsOrderModel), queryOptions) |
369 | query.SetWhereByQueryOption("dividends_order.dividends_order_id = ?", "dividendsOrderId") | 369 | query.SetWhereByQueryOption("dividends_order.dividends_order_id = ?", "dividendsOrderId") |
370 | - query.SetWhereByQueryOption("dividends_order.dividends_order_number = ?", "dividendsOrderNumber") | 370 | + //query.SetWhereByQueryOption("dividends_order.dividends_order_number = ?", "dividendsOrderNumber") |
371 | + if dividendsOrderNumber, ok := queryOptions["dividendsOrderNumber"]; ok && dividendsOrderNumber != "" { | ||
372 | + query.Where("dividends_order.dividends_order_number = ?", dividendsOrderNumber) | ||
373 | + } | ||
371 | if err := query.First(); err != nil { | 374 | if err := query.First(); err != nil { |
372 | if err.Error() == "pg: no rows in result set" { | 375 | if err.Error() == "pg: no rows in result set" { |
373 | return nil, fmt.Errorf("没有此资源") | 376 | return nil, fmt.Errorf("没有此资源") |
@@ -61,6 +61,8 @@ func (controller *DividendsOrderController) GetDividendsOrder() { | @@ -61,6 +61,8 @@ func (controller *DividendsOrderController) GetDividendsOrder() { | ||
61 | getDividendsOrderQuery.UserBaseId = header.UserBaseId | 61 | getDividendsOrderQuery.UserBaseId = header.UserBaseId |
62 | dividendsOrderId, _ := controller.GetInt64(":dividendsOrderId") | 62 | dividendsOrderId, _ := controller.GetInt64(":dividendsOrderId") |
63 | getDividendsOrderQuery.DividendsOrderId = dividendsOrderId | 63 | getDividendsOrderQuery.DividendsOrderId = dividendsOrderId |
64 | + dividendsOrderNumber := controller.GetString("dividendsOrderNumber") | ||
65 | + getDividendsOrderQuery.DividendsOrderNumber = dividendsOrderNumber | ||
64 | data, err := dividendsOrderService.GetDividendsOrder(getDividendsOrderQuery) | 66 | data, err := dividendsOrderService.GetDividendsOrder(getDividendsOrderQuery) |
65 | controller.Response(data, err) | 67 | controller.Response(data, err) |
66 | } | 68 | } |
-
请 注册 或 登录 后发表评论