Merge branch 'dev-chenzhiying' into dev
正在显示
14 个修改的文件
包含
297 行增加
和
220 行删除
@@ -308,7 +308,11 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | @@ -308,7 +308,11 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | ||
308 | } else { | 308 | } else { |
309 | cooperationModeRepository = value | 309 | cooperationModeRepository = value |
310 | } | 310 | } |
311 | - cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeNumber": createCooperationContractCommand.CooperationModeNumber}) | 311 | + cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{ |
312 | + "companyId": createCooperationContractCommand.CompanyId, | ||
313 | + "orgId": createCooperationContractCommand.OrgId, | ||
314 | + "cooperationModeNumber": createCooperationContractCommand.CooperationModeNumber, | ||
315 | + }) | ||
312 | if err != nil { | 316 | if err != nil { |
313 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在") | 317 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在") |
314 | } | 318 | } |
@@ -752,29 +752,30 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -752,29 +752,30 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
752 | countDividendsEstimate = countDividendsEstimate + 1 | 752 | countDividendsEstimate = countDividendsEstimate + 1 |
753 | 753 | ||
754 | dividendsEstimate = &domain.DividendsEstimate{ | 754 | dividendsEstimate = &domain.DividendsEstimate{ |
755 | - DividendsEstimateId: 0, | ||
756 | - DividendsAccountStatus: domain.TO_BE_ACCOUNT, | ||
757 | - DividendsAmount: dividendsEstimateDetail.DividendsAmount, | ||
758 | - DividendsEstimateOrderNumber: dividendsEstimateOrderNumber, | ||
759 | - DividendsEstimateTime: time.Now(), | ||
760 | - DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType, | ||
761 | - DividendsType: domain.ORDER_DIVIDENDS, | ||
762 | - DividendsTypeName: "订单分红", | ||
763 | - OrderOrReturnedOrderNum: orderGood.DividendsOrderNumber, | ||
764 | - CooperationContractNumber: orderGood.CooperationContractNumber, | ||
765 | - DividendsUser: dividendsEstimateDetail.DividendsUser, | ||
766 | - DividendsStage: dividendsEstimateDetail.DividendsStage, | ||
767 | - Org: organization, | ||
768 | - Company: company, | ||
769 | - Operator: operator, | ||
770 | - OperateTime: time.Time{}, | ||
771 | - IsCanceled: false, | ||
772 | - CreatedAt: time.Now(), | ||
773 | - DeletedAt: time.Time{}, | ||
774 | - UpdatedAt: time.Time{}, | ||
775 | - OrderGoodId: orderGood.OrderGoodId, | ||
776 | - OrderGoodAmount: orderGood.OrderGoodAmount, | ||
777 | - PaymentStatus: int32(1), | 755 | + DividendsEstimateId: 0, |
756 | + DividendsAccountStatus: domain.TO_BE_ACCOUNT, | ||
757 | + DividendsAmount: dividendsEstimateDetail.DividendsAmount, | ||
758 | + DividendsEstimateOrderNumber: dividendsEstimateOrderNumber, | ||
759 | + DividendsEstimateTime: time.Now(), | ||
760 | + DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType, | ||
761 | + DividendsType: domain.ORDER_DIVIDENDS, | ||
762 | + DividendsTypeName: "订单分红", | ||
763 | + OrderOrReturnedOrderNum: orderGood.DividendsOrderNumber, | ||
764 | + CooperationContractNumber: orderGood.CooperationContractNumber, | ||
765 | + DividendsUser: dividendsEstimateDetail.DividendsUser, | ||
766 | + DividendsStage: dividendsEstimateDetail.DividendsStage, | ||
767 | + Org: organization, | ||
768 | + Company: company, | ||
769 | + Operator: operator, | ||
770 | + OperateTime: time.Time{}, | ||
771 | + IsCanceled: false, | ||
772 | + CreatedAt: time.Now(), | ||
773 | + DeletedAt: time.Time{}, | ||
774 | + UpdatedAt: time.Time{}, | ||
775 | + OrderGoodId: orderGood.OrderGoodId, | ||
776 | + OrderGoodAmount: orderGood.OrderGoodAmount, | ||
777 | + PaymentStatus: int32(1), | ||
778 | + CooperationContractUndertakerId: dividendsEstimateDetail.CooperationContractUndertakerId, | ||
778 | } | 779 | } |
779 | 780 | ||
780 | dividendsEstimates = append(dividendsEstimates, dividendsEstimate) | 781 | dividendsEstimates = append(dividendsEstimates, dividendsEstimate) |
@@ -806,29 +807,30 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -806,29 +807,30 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
806 | countDividendsEstimate = countDividendsEstimate + 1 | 807 | countDividendsEstimate = countDividendsEstimate + 1 |
807 | 808 | ||
808 | dividendsEstimate = &domain.DividendsEstimate{ | 809 | dividendsEstimate = &domain.DividendsEstimate{ |
809 | - DividendsEstimateId: 0, | ||
810 | - DividendsAccountStatus: domain.TO_BE_ACCOUNT, | ||
811 | - DividendsAmount: dividendsReturnedEstimateDetail.DividendsAmount, | ||
812 | - DividendsEstimateOrderNumber: dividendsEstimateOrderNumber, | ||
813 | - DividendsEstimateTime: time.Now(), | ||
814 | - DividendsParticipateType: dividendsReturnedEstimateDetail.DividendsParticipateType, | ||
815 | - DividendsType: domain.RETURN_WRITE_OFF, | ||
816 | - DividendsTypeName: "退货冲销", | ||
817 | - OrderOrReturnedOrderNum: orderGood.DividendsReturnedOrderNumber, | ||
818 | - CooperationContractNumber: orderGood.CooperationContractNumber, | ||
819 | - DividendsUser: dividendsReturnedEstimateDetail.DividendsUser, | ||
820 | - DividendsStage: dividendsReturnedEstimateDetail.DividendsStage, | ||
821 | - Org: organization, | ||
822 | - Company: company, | ||
823 | - Operator: operator, | ||
824 | - OperateTime: time.Time{}, | ||
825 | - IsCanceled: false, | ||
826 | - CreatedAt: time.Now(), | ||
827 | - DeletedAt: time.Time{}, | ||
828 | - UpdatedAt: time.Time{}, | ||
829 | - OrderGoodId: orderGood.OrderGoodId, | ||
830 | - OrderGoodAmount: orderGood.OrderGoodAmount, | ||
831 | - PaymentStatus: int32(1), | 810 | + DividendsEstimateId: 0, |
811 | + DividendsAccountStatus: domain.TO_BE_ACCOUNT, | ||
812 | + DividendsAmount: dividendsReturnedEstimateDetail.DividendsAmount, | ||
813 | + DividendsEstimateOrderNumber: dividendsEstimateOrderNumber, | ||
814 | + DividendsEstimateTime: time.Now(), | ||
815 | + DividendsParticipateType: dividendsReturnedEstimateDetail.DividendsParticipateType, | ||
816 | + DividendsType: domain.RETURN_WRITE_OFF, | ||
817 | + DividendsTypeName: "退货冲销", | ||
818 | + OrderOrReturnedOrderNum: orderGood.DividendsReturnedOrderNumber, | ||
819 | + CooperationContractNumber: orderGood.CooperationContractNumber, | ||
820 | + DividendsUser: dividendsReturnedEstimateDetail.DividendsUser, | ||
821 | + DividendsStage: dividendsReturnedEstimateDetail.DividendsStage, | ||
822 | + Org: organization, | ||
823 | + Company: company, | ||
824 | + Operator: operator, | ||
825 | + OperateTime: time.Time{}, | ||
826 | + IsCanceled: false, | ||
827 | + CreatedAt: time.Now(), | ||
828 | + DeletedAt: time.Time{}, | ||
829 | + UpdatedAt: time.Time{}, | ||
830 | + OrderGoodId: orderGood.OrderGoodId, | ||
831 | + OrderGoodAmount: orderGood.OrderGoodAmount, | ||
832 | + PaymentStatus: int32(1), | ||
833 | + CooperationContractUndertakerId: dividendsReturnedEstimateDetail.CooperationContractUndertakerId, | ||
832 | } | 834 | } |
833 | 835 | ||
834 | dividendsEstimates = append(dividendsEstimates, dividendsEstimate) | 836 | dividendsEstimates = append(dividendsEstimates, dividendsEstimate) |
@@ -1148,27 +1150,28 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives | @@ -1148,27 +1150,28 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives | ||
1148 | dividendsAmount, _ := decimal.NewFromFloatWithExponent(dividendsEstimateDetail.DividendsAmount, -2).Float64() | 1150 | dividendsAmount, _ := decimal.NewFromFloatWithExponent(dividendsEstimateDetail.DividendsAmount, -2).Float64() |
1149 | 1151 | ||
1150 | dividendsEstimate := &domain.DividendsEstimate{ | 1152 | dividendsEstimate := &domain.DividendsEstimate{ |
1151 | - DividendsEstimateId: 0, | ||
1152 | - DividendsAccountStatus: domain.TO_BE_ACCOUNT, | ||
1153 | - DividendsAmount: dividendsAmount, | ||
1154 | - DividendsEstimateOrderNumber: dividendsEstimateOrderNumber, | ||
1155 | - DividendsEstimateTime: time.Now(), | ||
1156 | - DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType, | ||
1157 | - DividendsType: domain.MONEY_INCENTIVES, | ||
1158 | - DividendsTypeName: "金额激励", | ||
1159 | - OrderOrReturnedOrderNum: "", | ||
1160 | - CooperationContractNumber: cooperationContract.CooperationContractNumber, | ||
1161 | - DividendsUser: dividendsEstimateDetail.DividendsUser, | ||
1162 | - DividendsStage: dividendsEstimateDetail.DividendsStage, | ||
1163 | - Org: organization, | ||
1164 | - Company: company, | ||
1165 | - Operator: nil, | ||
1166 | - OperateTime: time.Time{}, | ||
1167 | - IsCanceled: false, | ||
1168 | - CreatedAt: time.Now(), | ||
1169 | - DeletedAt: time.Time{}, | ||
1170 | - UpdatedAt: time.Time{}, | ||
1171 | - PaymentStatus: int32(1), | 1153 | + DividendsEstimateId: 0, |
1154 | + DividendsAccountStatus: domain.TO_BE_ACCOUNT, | ||
1155 | + DividendsAmount: dividendsAmount, | ||
1156 | + DividendsEstimateOrderNumber: dividendsEstimateOrderNumber, | ||
1157 | + DividendsEstimateTime: time.Now(), | ||
1158 | + DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType, | ||
1159 | + DividendsType: domain.MONEY_INCENTIVES, | ||
1160 | + DividendsTypeName: "金额激励", | ||
1161 | + OrderOrReturnedOrderNum: "", | ||
1162 | + CooperationContractNumber: cooperationContract.CooperationContractNumber, | ||
1163 | + DividendsUser: dividendsEstimateDetail.DividendsUser, | ||
1164 | + DividendsStage: dividendsEstimateDetail.DividendsStage, | ||
1165 | + Org: organization, | ||
1166 | + Company: company, | ||
1167 | + Operator: nil, | ||
1168 | + OperateTime: time.Time{}, | ||
1169 | + IsCanceled: false, | ||
1170 | + CreatedAt: time.Now(), | ||
1171 | + DeletedAt: time.Time{}, | ||
1172 | + UpdatedAt: time.Time{}, | ||
1173 | + PaymentStatus: int32(1), | ||
1174 | + CooperationContractUndertakerId: dividendsEstimateDetail.CooperationContractUndertakerId, | ||
1172 | } | 1175 | } |
1173 | 1176 | ||
1174 | dividendsEstimates = append(dividendsEstimates, dividendsEstimate) | 1177 | dividendsEstimates = append(dividendsEstimates, dividendsEstimate) |
@@ -145,6 +145,10 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD | @@ -145,6 +145,10 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD | ||
145 | } | 145 | } |
146 | } | 146 | } |
147 | 147 | ||
148 | + log.Logger.Info("查询到的合约", map[string]interface{}{ | ||
149 | + "cooperationContractsMap": cooperationContractsMap, | ||
150 | + }) | ||
151 | + | ||
148 | // 订单时间转换 | 152 | // 订单时间转换 |
149 | orderTimeInt, err := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64) | 153 | orderTimeInt, err := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64) |
150 | if err != nil { | 154 | if err != nil { |
@@ -163,9 +167,14 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD | @@ -163,9 +167,14 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD | ||
163 | ruleMatchedFlag := false | 167 | ruleMatchedFlag := false |
164 | if orderGood.CooperationContractNumber != "" { | 168 | if orderGood.CooperationContractNumber != "" { |
165 | // 校验共创合约激励类型是否正确 | 169 | // 校验共创合约激励类型是否正确 |
166 | - if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 { | ||
167 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单产品不能关联金额激励规则") | 170 | + if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { |
171 | + if cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 { | ||
172 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单产品不能关联金额激励规则") | ||
173 | + } | ||
174 | + } else { | ||
175 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在") | ||
168 | } | 176 | } |
177 | + | ||
169 | // 校验产品关联合约的激励规则是否匹配订单时间 | 178 | // 校验产品关联合约的激励规则是否匹配订单时间 |
170 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { | 179 | if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { |
171 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { | 180 | for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { |
@@ -43,6 +43,8 @@ type DividendsEstimate struct { | @@ -43,6 +43,8 @@ type DividendsEstimate struct { | ||
43 | OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum"` | 43 | OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum"` |
44 | // 共创项目合约编号,自生成,生成规则:XM+6位年月日+#+3位流水,例XM210601#001 | 44 | // 共创项目合约编号,自生成,生成规则:XM+6位年月日+#+3位流水,例XM210601#001 |
45 | CooperationContractNumber string `json:"cooperationContractNumber"` | 45 | CooperationContractNumber string `json:"cooperationContractNumber"` |
46 | + // 共创合约承接人id | ||
47 | + CooperationContractUndertakerId int64 `json:"cooperationContractUndertakerId"` | ||
46 | // 分红用户(共创参与) | 48 | // 分红用户(共创参与) |
47 | DividendsUser *User `json:"dividendsUser"` | 49 | DividendsUser *User `json:"dividendsUser"` |
48 | // 分红阶段 | 50 | // 分红阶段 |
@@ -8,13 +8,14 @@ import ( | @@ -8,13 +8,14 @@ import ( | ||
8 | ) | 8 | ) |
9 | 9 | ||
10 | type DividendsEstimateDetail struct { | 10 | type DividendsEstimateDetail struct { |
11 | - DividendsUser *domain.User `json:"dividendsUser"` // 共创参与(分红用户) | ||
12 | - DividendsParticipateType int32 `json:"dividendsParticipateType"` // 参与类型 1承接人,2推荐人,3关联业务员 | ||
13 | - DividendsStage int32 `json:"dividendsStage"` // 分红阶段 | ||
14 | - DividendsAmount float64 `json:"dividendsAmount"` // 分红金额 | ||
15 | - OrderOrReturnedOrderNumber string `json:"orderOrReturnedOrderNumber"` // 分红订单号或退货单号 | ||
16 | - IsSuccessfully bool `json:"isSuccessfully"` // 是否预算成功 | ||
17 | - Reason string `json:"reason"` // 错误原因 | 11 | + DividendsUser *domain.User `json:"dividendsUser"` // 共创参与(分红用户) |
12 | + DividendsParticipateType int32 `json:"dividendsParticipateType"` // 参与类型 1承接人,2推荐人,3关联业务员 | ||
13 | + DividendsStage int32 `json:"dividendsStage"` // 分红阶段 | ||
14 | + DividendsAmount float64 `json:"dividendsAmount"` // 分红金额 | ||
15 | + OrderOrReturnedOrderNumber string `json:"orderOrReturnedOrderNumber"` // 分红订单号或退货单号 | ||
16 | + IsSuccessfully bool `json:"isSuccessfully"` // 是否预算成功 | ||
17 | + Reason string `json:"reason"` // 错误原因 | ||
18 | + CooperationContractUndertakerId int64 `json:"cooperationContractUndertakerId"` // 承接人记录ID | ||
18 | } | 19 | } |
19 | 20 | ||
20 | // GenerateSpecificDividendsEstimateNumber 批量生成自定义分红预算单号 | 21 | // GenerateSpecificDividendsEstimateNumber 批量生成自定义分红预算单号 |
@@ -2,7 +2,7 @@ package domain | @@ -2,7 +2,7 @@ package domain | ||
2 | 2 | ||
3 | // Undertaker 共创合约承接方值对象 | 3 | // Undertaker 共创合约承接方值对象 |
4 | type Undertaker struct { | 4 | type Undertaker struct { |
5 | - // 承接人id | 5 | + // 承接人记录ID |
6 | UndertakerId int64 `json:"undertakerId,string"` | 6 | UndertakerId int64 `json:"undertakerId,string"` |
7 | // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | 7 | // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 |
8 | UserId int64 `json:"userId,string"` | 8 | UserId int64 `json:"userId,string"` |
@@ -20,6 +20,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -20,6 +20,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
20 | var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储 | 20 | var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储 |
21 | var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储 | 21 | var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储 |
22 | var orderGoodRepository domain.OrderGoodRepository // 订单产品仓储 | 22 | var orderGoodRepository domain.OrderGoodRepository // 订单产品仓储 |
23 | + //var cooperationContactRepository domain.CooperationContractRepository // 合约仓储 | ||
23 | 24 | ||
24 | // 分红预算单仓储初始化 | 25 | // 分红预算单仓储初始化 |
25 | if repo, err := repository.NewDividendsEstimateRepository(domainService.transactionContext); err != nil { | 26 | if repo, err := repository.NewDividendsEstimateRepository(domainService.transactionContext); err != nil { |
@@ -49,6 +50,13 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -49,6 +50,13 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
49 | orderGoodRepository = repo | 50 | orderGoodRepository = repo |
50 | } | 51 | } |
51 | 52 | ||
53 | + // 共创合约仓储初始化 | ||
54 | + //if repo, err := repository.NewCooperationContractRepository(domainService.transactionContext); err != nil { | ||
55 | + // return nil, err | ||
56 | + //} else { | ||
57 | + // cooperationContactRepository = repo | ||
58 | + //} | ||
59 | + | ||
52 | // 获取分红预算单 | 60 | // 获取分红预算单 |
53 | if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{ | 61 | if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{ |
54 | "dividendsEstimateIds": dividendsEstimateIds, | 62 | "dividendsEstimateIds": dividendsEstimateIds, |
@@ -61,18 +69,16 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -61,18 +69,16 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
61 | for _, dividendsEstimate := range dividendsEstimates { | 69 | for _, dividendsEstimate := range dividendsEstimates { |
62 | if dividendsEstimate.DividendsType == 1 || dividendsEstimate.DividendsType == 2 { // 1.订单分红 2.退货冲销 | 70 | if dividendsEstimate.DividendsType == 1 || dividendsEstimate.DividendsType == 2 { // 1.订单分红 2.退货冲销 |
63 | // 自定义查询 | 71 | // 自定义查询 |
64 | - queryOptions := make(map[string]interface{}) | ||
65 | - | ||
66 | - queryOptions = map[string]interface{}{ | ||
67 | - "companyId": dividendsEstimate.Company.CompanyId, | ||
68 | - "orgId": dividendsEstimate.Org.OrgId, | ||
69 | - "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum, | ||
70 | - "dividendsParticipateTypes": []int32{1, 2, 3}, | ||
71 | - "offsetLimit": false, | ||
72 | - "dividendsStage": dividendsEstimate.DividendsStage, | ||
73 | - "dividendsTypes": []int32{1, 2}, | ||
74 | - } | ||
75 | 72 | ||
73 | + //queryOptions := map[string]interface{}{ | ||
74 | + // "companyId": dividendsEstimate.Company.CompanyId, | ||
75 | + // "orgId": dividendsEstimate.Org.OrgId, | ||
76 | + // "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum, | ||
77 | + // "dividendsParticipateTypes": []int32{1, 2, 3}, | ||
78 | + // "offsetLimit": false, | ||
79 | + // "dividendsStage": dividendsEstimate.DividendsStage, | ||
80 | + // "dividendsTypes": []int32{1, 2}, | ||
81 | + //} | ||
76 | //参与分红类型,1承接人,2推荐人,3关联业务员 | 82 | //参与分红类型,1承接人,2推荐人,3关联业务员 |
77 | //if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单 | 83 | //if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单 |
78 | // queryOptions = map[string]interface{}{ | 84 | // queryOptions = map[string]interface{}{ |
@@ -107,7 +113,17 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -107,7 +113,17 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
107 | //} | 113 | //} |
108 | 114 | ||
109 | // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单 | 115 | // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单 |
110 | - if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil { | 116 | + if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{ |
117 | + "companyId": dividendsEstimate.Company.CompanyId, | ||
118 | + "orgId": dividendsEstimate.Org.OrgId, | ||
119 | + "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum, | ||
120 | + "dividendsParticipateTypes": []int32{1, 2, 3}, | ||
121 | + "cooperationContractNumber": dividendsEstimate.CooperationContractNumber, | ||
122 | + "offsetLimit": false, | ||
123 | + "dividendsStage": dividendsEstimate.DividendsStage, | ||
124 | + "dividendsTypes": []int32{1, 2}, | ||
125 | + "orderGoodId": dividendsEstimate.OrderGoodId, | ||
126 | + }); err2 != nil { | ||
111 | return nil, err2 | 127 | return nil, err2 |
112 | } else { | 128 | } else { |
113 | if countRelative > 0 { | 129 | if countRelative > 0 { |
@@ -125,19 +141,27 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -125,19 +141,27 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
125 | } | 141 | } |
126 | } | 142 | } |
127 | } else if dividendsEstimate.DividendsType == 3 { // 3.金额激励 | 143 | } else if dividendsEstimate.DividendsType == 3 { // 3.金额激励 |
128 | - // 自定义查询 | ||
129 | - queryOptions := make(map[string]interface{}) | ||
130 | 144 | ||
131 | - queryOptions = map[string]interface{}{ | ||
132 | - "companyId": dividendsEstimate.Company.CompanyId, | ||
133 | - "orgId": dividendsEstimate.Org.OrgId, | ||
134 | - "cooperationContractNumber": dividendsEstimate.CooperationContractNumber, | ||
135 | - "dividendsParticipateTypes": []int32{1, 2, 3}, | ||
136 | - "offsetLimit": false, | ||
137 | - "dividendsStage": dividendsEstimate.DividendsStage, | ||
138 | - "dividendsType": int32(3), | ||
139 | - } | 145 | + // 查询合约 |
146 | + //cooperationContract, err3 := cooperationContactRepository.FindOne(map[string]interface{}{ | ||
147 | + // "companyId": dividendsEstimate.Company.CompanyId, | ||
148 | + // "orgId": dividendsEstimate.Org.OrgId, | ||
149 | + // "cooperationContractNumber": dividendsEstimate.CooperationContractNumber, | ||
150 | + //}) | ||
151 | + //if err3 != nil { | ||
152 | + // return nil, err3 | ||
153 | + //} | ||
140 | 154 | ||
155 | + // 自定义查询 | ||
156 | + //queryOptions := map[string]interface{}{ | ||
157 | + // "companyId": dividendsEstimate.Company.CompanyId, | ||
158 | + // "orgId": dividendsEstimate.Org.OrgId, | ||
159 | + // "cooperationContractNumber": dividendsEstimate.CooperationContractNumber, | ||
160 | + // "dividendsParticipateTypes": []int32{1, 2, 3}, | ||
161 | + // "offsetLimit": false, | ||
162 | + // "dividendsStage": dividendsEstimate.DividendsStage, | ||
163 | + // "dividendsType": int32(3), | ||
164 | + //} | ||
141 | //参与分红类型,1承接人,2推荐人,3关联业务员 | 165 | //参与分红类型,1承接人,2推荐人,3关联业务员 |
142 | //if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单 | 166 | //if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单 |
143 | // queryOptions = map[string]interface{}{ | 167 | // queryOptions = map[string]interface{}{ |
@@ -172,7 +196,16 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -172,7 +196,16 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
172 | //} | 196 | //} |
173 | 197 | ||
174 | // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单 | 198 | // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单 |
175 | - if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil { | 199 | + if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{ |
200 | + "companyId": dividendsEstimate.Company.CompanyId, | ||
201 | + "orgId": dividendsEstimate.Org.OrgId, | ||
202 | + "cooperationContractNumber": dividendsEstimate.CooperationContractNumber, | ||
203 | + "cooperationContractUndertakerId": dividendsEstimate.CooperationContractUndertakerId, | ||
204 | + "dividendsParticipateTypes": []int32{1, 2, 3}, | ||
205 | + "offsetLimit": false, | ||
206 | + "dividendsStage": dividendsEstimate.DividendsStage, | ||
207 | + "dividendsType": int32(3), | ||
208 | + }); err2 != nil { | ||
176 | return nil, err2 | 209 | return nil, err2 |
177 | } else { | 210 | } else { |
178 | if countRelative > 0 { | 211 | if countRelative > 0 { |
@@ -180,9 +213,9 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -180,9 +213,9 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
180 | dividendsEstimatesRelative[i].IsCanceled = true | 213 | dividendsEstimatesRelative[i].IsCanceled = true |
181 | dividendsEstimatesRelative[i].Operator = operator | 214 | dividendsEstimatesRelative[i].Operator = operator |
182 | } | 215 | } |
183 | - dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative) | ||
184 | - if err3 != nil { | ||
185 | - return nil, err3 | 216 | + dividendsEstimatesRelativeCanceled, err4 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative) |
217 | + if err4 != nil { | ||
218 | + return nil, err4 | ||
186 | } | 219 | } |
187 | dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...) | 220 | dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...) |
188 | } | 221 | } |
@@ -243,11 +243,12 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -243,11 +243,12 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
243 | Status: undertaker.Status, | 243 | Status: undertaker.Status, |
244 | Company: undertaker.Company, | 244 | Company: undertaker.Company, |
245 | }, | 245 | }, |
246 | - DividendsParticipateType: domain.UNDERTAKER, | ||
247 | - DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, | ||
248 | - DividendsAmount: undertakerDividendsAmount, | ||
249 | - OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber, | ||
250 | - IsSuccessfully: true, | 246 | + DividendsParticipateType: domain.UNDERTAKER, |
247 | + DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, | ||
248 | + DividendsAmount: undertakerDividendsAmount, | ||
249 | + OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber, | ||
250 | + IsSuccessfully: true, | ||
251 | + CooperationContractUndertakerId: undertaker.UndertakerId, | ||
251 | }) | 252 | }) |
252 | } | 253 | } |
253 | 254 | ||
@@ -269,11 +270,12 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -269,11 +270,12 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
269 | UserPhone: undertaker.Referrer.UserPhone, | 270 | UserPhone: undertaker.Referrer.UserPhone, |
270 | Company: undertaker.Referrer.Company, | 271 | Company: undertaker.Referrer.Company, |
271 | }, | 272 | }, |
272 | - DividendsParticipateType: domain.REFERRER, | ||
273 | - DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, | ||
274 | - DividendsAmount: referrerDividendsAmount, | ||
275 | - OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber, | ||
276 | - IsSuccessfully: true, | 273 | + DividendsParticipateType: domain.REFERRER, |
274 | + DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, | ||
275 | + DividendsAmount: referrerDividendsAmount, | ||
276 | + OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber, | ||
277 | + IsSuccessfully: true, | ||
278 | + CooperationContractUndertakerId: undertaker.UndertakerId, | ||
277 | }) | 279 | }) |
278 | } | 280 | } |
279 | } | 281 | } |
@@ -295,11 +297,12 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -295,11 +297,12 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
295 | UserPhone: undertaker.Salesman.UserPhone, | 297 | UserPhone: undertaker.Salesman.UserPhone, |
296 | Company: undertaker.Salesman.Company, | 298 | Company: undertaker.Salesman.Company, |
297 | }, | 299 | }, |
298 | - DividendsParticipateType: domain.SALESMAN, | ||
299 | - DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, | ||
300 | - DividendsAmount: salesmanDividendsAmount, | ||
301 | - OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber, | ||
302 | - IsSuccessfully: true, | 300 | + DividendsParticipateType: domain.SALESMAN, |
301 | + DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, | ||
302 | + DividendsAmount: salesmanDividendsAmount, | ||
303 | + OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber, | ||
304 | + IsSuccessfully: true, | ||
305 | + CooperationContractUndertakerId: undertaker.UndertakerId, | ||
303 | }) | 306 | }) |
304 | } | 307 | } |
305 | } | 308 | } |
@@ -364,11 +367,12 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -364,11 +367,12 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
364 | Status: undertaker.Status, | 367 | Status: undertaker.Status, |
365 | Company: undertaker.Company, | 368 | Company: undertaker.Company, |
366 | }, | 369 | }, |
367 | - DividendsParticipateType: domain.UNDERTAKER, | ||
368 | - DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, | ||
369 | - DividendsAmount: -undertakerDividendsAmount, | ||
370 | - OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber, | ||
371 | - IsSuccessfully: true, | 370 | + DividendsParticipateType: domain.UNDERTAKER, |
371 | + DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, | ||
372 | + DividendsAmount: -undertakerDividendsAmount, | ||
373 | + OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber, | ||
374 | + IsSuccessfully: true, | ||
375 | + CooperationContractUndertakerId: undertaker.UndertakerId, | ||
372 | }) | 376 | }) |
373 | } | 377 | } |
374 | 378 | ||
@@ -390,11 +394,12 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -390,11 +394,12 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
390 | UserPhone: undertaker.Referrer.UserPhone, | 394 | UserPhone: undertaker.Referrer.UserPhone, |
391 | Company: undertaker.Referrer.Company, | 395 | Company: undertaker.Referrer.Company, |
392 | }, | 396 | }, |
393 | - DividendsParticipateType: domain.REFERRER, | ||
394 | - DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, | ||
395 | - DividendsAmount: -referrerDividendsAmount, | ||
396 | - OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber, | ||
397 | - IsSuccessfully: true, | 397 | + DividendsParticipateType: domain.REFERRER, |
398 | + DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, | ||
399 | + DividendsAmount: -referrerDividendsAmount, | ||
400 | + OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber, | ||
401 | + IsSuccessfully: true, | ||
402 | + CooperationContractUndertakerId: undertaker.UndertakerId, | ||
398 | }) | 403 | }) |
399 | } | 404 | } |
400 | } | 405 | } |
@@ -417,11 +422,12 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -417,11 +422,12 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
417 | UserPhone: undertaker.Salesman.UserPhone, | 422 | UserPhone: undertaker.Salesman.UserPhone, |
418 | Company: undertaker.Salesman.Company, | 423 | Company: undertaker.Salesman.Company, |
419 | }, | 424 | }, |
420 | - DividendsParticipateType: domain.SALESMAN, | ||
421 | - DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, | ||
422 | - DividendsAmount: -salesmanDividendsAmount, | ||
423 | - OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber, | ||
424 | - IsSuccessfully: true, | 425 | + DividendsParticipateType: domain.SALESMAN, |
426 | + DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, | ||
427 | + DividendsAmount: -salesmanDividendsAmount, | ||
428 | + OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsReturnedOrderNumber, | ||
429 | + IsSuccessfully: true, | ||
430 | + CooperationContractUndertakerId: undertaker.UndertakerId, | ||
425 | }) | 431 | }) |
426 | } | 432 | } |
427 | 433 |
@@ -64,7 +64,6 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | @@ -64,7 +64,6 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | ||
64 | return nil, fmt.Errorf("承接人 " + undertaker.UserName + " 已分红") | 64 | return nil, fmt.Errorf("承接人 " + undertaker.UserName + " 已分红") |
65 | } else { | 65 | } else { |
66 | undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Float64() | 66 | undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Float64() |
67 | - //Mul(decimal.NewFromFloat(1).Sub(decimal.NewFromFloat(moneyIncentivesRuleMatched.SalesmanPercentage).Add(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage)).Div(decimal.NewFromFloat(100)))).Float64() | ||
68 | dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ | 67 | dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ |
69 | DividendsUser: &domain.User{ | 68 | DividendsUser: &domain.User{ |
70 | UserId: undertaker.UserId, | 69 | UserId: undertaker.UserId, |
@@ -80,9 +79,10 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | @@ -80,9 +79,10 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | ||
80 | Status: undertaker.Status, | 79 | Status: undertaker.Status, |
81 | Company: undertaker.Company, | 80 | Company: undertaker.Company, |
82 | }, | 81 | }, |
83 | - DividendsParticipateType: 1, | ||
84 | - DividendsStage: stage, | ||
85 | - DividendsAmount: undertakerDividendsAmount, | 82 | + DividendsParticipateType: 1, |
83 | + DividendsStage: stage, | ||
84 | + DividendsAmount: undertakerDividendsAmount, | ||
85 | + CooperationContractUndertakerId: undertaker.UndertakerId, | ||
86 | }) | 86 | }) |
87 | } | 87 | } |
88 | 88 | ||
@@ -114,9 +114,10 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | @@ -114,9 +114,10 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | ||
114 | UserPhone: undertaker.Salesman.UserPhone, | 114 | UserPhone: undertaker.Salesman.UserPhone, |
115 | Company: undertaker.Salesman.Company, | 115 | Company: undertaker.Salesman.Company, |
116 | }, | 116 | }, |
117 | - DividendsParticipateType: 3, | ||
118 | - DividendsStage: stage, | ||
119 | - DividendsAmount: undertakerDividendsAmount, | 117 | + DividendsParticipateType: 3, |
118 | + DividendsStage: stage, | ||
119 | + DividendsAmount: undertakerDividendsAmount, | ||
120 | + CooperationContractUndertakerId: undertaker.UndertakerId, | ||
120 | }) | 121 | }) |
121 | } | 122 | } |
122 | 123 | ||
@@ -150,9 +151,10 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | @@ -150,9 +151,10 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | ||
150 | UserPhone: undertaker.Referrer.UserPhone, | 151 | UserPhone: undertaker.Referrer.UserPhone, |
151 | Company: undertaker.Referrer.Company, | 152 | Company: undertaker.Referrer.Company, |
152 | }, | 153 | }, |
153 | - DividendsParticipateType: 2, | ||
154 | - DividendsStage: stage, | ||
155 | - DividendsAmount: undertakerDividendsAmount, | 154 | + DividendsParticipateType: 2, |
155 | + DividendsStage: stage, | ||
156 | + DividendsAmount: undertakerDividendsAmount, | ||
157 | + CooperationContractUndertakerId: undertaker.UndertakerId, | ||
156 | }) | 158 | }) |
157 | } | 159 | } |
158 | } | 160 | } |
@@ -29,6 +29,8 @@ type DividendsEstimate struct { | @@ -29,6 +29,8 @@ type DividendsEstimate struct { | ||
29 | OrderOrReturnedOrderNum string `comment:"分红订单号或退货单号"` | 29 | OrderOrReturnedOrderNum string `comment:"分红订单号或退货单号"` |
30 | // 共创项目合约编号 | 30 | // 共创项目合约编号 |
31 | CooperationContractNumber string `comment:"共创项目合约编号"` | 31 | CooperationContractNumber string `comment:"共创项目合约编号"` |
32 | + // 共创合约承接人id | ||
33 | + CooperationContractUndertakerId int64 `comment:"共创合约承接人ID"` | ||
32 | // 分红用户 | 34 | // 分红用户 |
33 | DividendsUser *domain.User `comment:"分红用户"` | 35 | DividendsUser *domain.User `comment:"分红用户"` |
34 | // 分红阶段 | 36 | // 分红阶段 |
@@ -42,7 +44,7 @@ type DividendsEstimate struct { | @@ -42,7 +44,7 @@ type DividendsEstimate struct { | ||
42 | // 操作时间 | 44 | // 操作时间 |
43 | OperateTime time.Time `comment:"操作时间"` | 45 | OperateTime time.Time `comment:"操作时间"` |
44 | // 取消状态 | 46 | // 取消状态 |
45 | - IsCanceled bool `comment:"取消状态" pg:",use_zero,default:false"` | 47 | + IsCanceled bool `comment:"取消状态" pg:",use_zero"` |
46 | // 产品ID | 48 | // 产品ID |
47 | OrderGoodId int64 `comment:"产品ID"` | 49 | OrderGoodId int64 `comment:"产品ID"` |
48 | // 创建时间 | 50 | // 创建时间 |
@@ -9,27 +9,28 @@ import ( | @@ -9,27 +9,28 @@ import ( | ||
9 | func TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel *models.DividendsEstimate) (*domain.DividendsEstimate, error) { | 9 | func TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel *models.DividendsEstimate) (*domain.DividendsEstimate, error) { |
10 | dividendsAmount, _ := decimal.NewFromFloatWithExponent(dividendsEstimateModel.DividendsAmount, -2).Float64() | 10 | dividendsAmount, _ := decimal.NewFromFloatWithExponent(dividendsEstimateModel.DividendsAmount, -2).Float64() |
11 | return &domain.DividendsEstimate{ | 11 | return &domain.DividendsEstimate{ |
12 | - DividendsEstimateId: dividendsEstimateModel.DividendsEstimateId, | ||
13 | - DividendsAccountStatus: dividendsEstimateModel.DividendsAccountStatus, | ||
14 | - PaymentStatus: dividendsEstimateModel.PaymentStatus, | ||
15 | - DividendsAmount: dividendsAmount, | ||
16 | - DividendsEstimateOrderNumber: dividendsEstimateModel.DividendsEstimateOrderNumber, | ||
17 | - DividendsEstimateTime: dividendsEstimateModel.DividendsEstimateTime, | ||
18 | - DividendsParticipateType: dividendsEstimateModel.DividendsParticipateType, | ||
19 | - DividendsType: dividendsEstimateModel.DividendsType, | ||
20 | - DividendsTypeName: dividendsEstimateModel.DividendsTypeName, | ||
21 | - OrderOrReturnedOrderNum: dividendsEstimateModel.OrderOrReturnedOrderNum, | ||
22 | - CooperationContractNumber: dividendsEstimateModel.CooperationContractNumber, | ||
23 | - DividendsUser: dividendsEstimateModel.DividendsUser, | ||
24 | - DividendsStage: dividendsEstimateModel.DividendsStage, | ||
25 | - Org: dividendsEstimateModel.Org, | ||
26 | - Company: dividendsEstimateModel.Company, | ||
27 | - Operator: dividendsEstimateModel.Operator, | ||
28 | - OperateTime: dividendsEstimateModel.OperateTime, | ||
29 | - IsCanceled: dividendsEstimateModel.IsCanceled, | ||
30 | - OrderGoodId: dividendsEstimateModel.OrderGoodId, | ||
31 | - CreatedAt: dividendsEstimateModel.CreatedAt, | ||
32 | - DeletedAt: dividendsEstimateModel.DeletedAt, | ||
33 | - UpdatedAt: dividendsEstimateModel.UpdatedAt, | 12 | + DividendsEstimateId: dividendsEstimateModel.DividendsEstimateId, |
13 | + DividendsAccountStatus: dividendsEstimateModel.DividendsAccountStatus, | ||
14 | + PaymentStatus: dividendsEstimateModel.PaymentStatus, | ||
15 | + DividendsAmount: dividendsAmount, | ||
16 | + DividendsEstimateOrderNumber: dividendsEstimateModel.DividendsEstimateOrderNumber, | ||
17 | + DividendsEstimateTime: dividendsEstimateModel.DividendsEstimateTime, | ||
18 | + DividendsParticipateType: dividendsEstimateModel.DividendsParticipateType, | ||
19 | + DividendsType: dividendsEstimateModel.DividendsType, | ||
20 | + DividendsTypeName: dividendsEstimateModel.DividendsTypeName, | ||
21 | + OrderOrReturnedOrderNum: dividendsEstimateModel.OrderOrReturnedOrderNum, | ||
22 | + CooperationContractNumber: dividendsEstimateModel.CooperationContractNumber, | ||
23 | + CooperationContractUndertakerId: dividendsEstimateModel.CooperationContractUndertakerId, | ||
24 | + DividendsUser: dividendsEstimateModel.DividendsUser, | ||
25 | + DividendsStage: dividendsEstimateModel.DividendsStage, | ||
26 | + Org: dividendsEstimateModel.Org, | ||
27 | + Company: dividendsEstimateModel.Company, | ||
28 | + Operator: dividendsEstimateModel.Operator, | ||
29 | + OperateTime: dividendsEstimateModel.OperateTime, | ||
30 | + IsCanceled: dividendsEstimateModel.IsCanceled, | ||
31 | + OrderGoodId: dividendsEstimateModel.OrderGoodId, | ||
32 | + CreatedAt: dividendsEstimateModel.CreatedAt, | ||
33 | + DeletedAt: dividendsEstimateModel.DeletedAt, | ||
34 | + UpdatedAt: dividendsEstimateModel.UpdatedAt, | ||
34 | }, nil | 35 | }, nil |
35 | } | 36 | } |
@@ -824,13 +824,13 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -824,13 +824,13 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
824 | } | 824 | } |
825 | } | 825 | } |
826 | // 返回新增的合约 | 826 | // 返回新增的合约 |
827 | - cooperationContractSaved, err := repository.FindOne(map[string]interface{}{ | ||
828 | - "cooperationContractId": cooperationContract.CooperationContractId, | ||
829 | - }) | ||
830 | - if err != nil { | ||
831 | - return nil, err | ||
832 | - } | ||
833 | - return cooperationContractSaved, nil | 827 | + //cooperationContractSaved, err := repository.FindOne(map[string]interface{}{ |
828 | + // "cooperationContractId": cooperationContract.CooperationContractId, | ||
829 | + //}) | ||
830 | + //if err != nil { | ||
831 | + // return nil, err | ||
832 | + //} | ||
833 | + return cooperationContract, nil | ||
834 | } | 834 | } |
835 | 835 | ||
836 | func (repository *CooperationContractRepository) UpdateOne(cooperationContract *domain.CooperationContract) (*domain.CooperationContract, error) { | 836 | func (repository *CooperationContractRepository) UpdateOne(cooperationContract *domain.CooperationContract) (*domain.CooperationContract, error) { |
@@ -48,6 +48,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | @@ -48,6 +48,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | ||
48 | "created_at", | 48 | "created_at", |
49 | "deleted_at", | 49 | "deleted_at", |
50 | "updated_at", | 50 | "updated_at", |
51 | + "cooperation_contract_undertaker_id", | ||
51 | } | 52 | } |
52 | insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields) | 53 | insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields) |
53 | insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields) | 54 | insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields) |
@@ -86,6 +87,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | @@ -86,6 +87,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | ||
86 | ÷ndsEstimate.CreatedAt, | 87 | ÷ndsEstimate.CreatedAt, |
87 | ÷ndsEstimate.DeletedAt, | 88 | ÷ndsEstimate.DeletedAt, |
88 | ÷ndsEstimate.UpdatedAt, | 89 | ÷ndsEstimate.UpdatedAt, |
90 | + ÷ndsEstimate.CooperationContractUndertakerId, | ||
89 | ), | 91 | ), |
90 | fmt.Sprintf("INSERT INTO dividends_estimates (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), | 92 | fmt.Sprintf("INSERT INTO dividends_estimates (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), |
91 | dividendsEstimate.DividendsEstimateId, | 93 | dividendsEstimate.DividendsEstimateId, |
@@ -110,6 +112,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | @@ -110,6 +112,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | ||
110 | dividendsEstimate.CreatedAt, | 112 | dividendsEstimate.CreatedAt, |
111 | nil, | 113 | nil, |
112 | dividendsEstimate.UpdatedAt, | 114 | dividendsEstimate.UpdatedAt, |
115 | + dividendsEstimate.CooperationContractUndertakerId, | ||
113 | ); err != nil { | 116 | ); err != nil { |
114 | return dividendsEstimate, err | 117 | return dividendsEstimate, err |
115 | } | 118 | } |
@@ -138,6 +141,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | @@ -138,6 +141,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | ||
138 | ÷ndsEstimate.CreatedAt, | 141 | ÷ndsEstimate.CreatedAt, |
139 | ÷ndsEstimate.DeletedAt, | 142 | ÷ndsEstimate.DeletedAt, |
140 | ÷ndsEstimate.UpdatedAt, | 143 | ÷ndsEstimate.UpdatedAt, |
144 | + ÷ndsEstimate.CooperationContractUndertakerId, | ||
141 | ), | 145 | ), |
142 | fmt.Sprintf("UPDATE dividends_estimates SET %s WHERE dividends_estimate_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), | 146 | fmt.Sprintf("UPDATE dividends_estimates SET %s WHERE dividends_estimate_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), |
143 | dividendsEstimate.DividendsEstimateId, | 147 | dividendsEstimate.DividendsEstimateId, |
@@ -162,6 +166,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | @@ -162,6 +166,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di | ||
162 | dividendsEstimate.CreatedAt, | 166 | dividendsEstimate.CreatedAt, |
163 | nil, | 167 | nil, |
164 | dividendsEstimate.UpdatedAt, | 168 | dividendsEstimate.UpdatedAt, |
169 | + dividendsEstimate.CooperationContractUndertakerId, | ||
165 | dividendsEstimate.Identify(), | 170 | dividendsEstimate.Identify(), |
166 | ); err != nil { | 171 | ); err != nil { |
167 | return dividendsEstimate, err | 172 | return dividendsEstimate, err |
@@ -183,28 +188,29 @@ func (repository *DividendsEstimateRepository) SaveMany(dividendsEstimates []*do | @@ -183,28 +188,29 @@ func (repository *DividendsEstimateRepository) SaveMany(dividendsEstimates []*do | ||
183 | } | 188 | } |
184 | } | 189 | } |
185 | dividendsEstimateModels = append(dividendsEstimateModels, &models.DividendsEstimate{ | 190 | dividendsEstimateModels = append(dividendsEstimateModels, &models.DividendsEstimate{ |
186 | - DividendsEstimateId: dividendsEstimate.DividendsEstimateId, | ||
187 | - DividendsAccountStatus: dividendsEstimate.DividendsAccountStatus, | ||
188 | - PaymentStatus: dividendsEstimate.PaymentStatus, | ||
189 | - DividendsAmount: dividendsEstimate.DividendsAmount, | ||
190 | - DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber, | ||
191 | - DividendsEstimateTime: dividendsEstimate.DividendsEstimateTime, | ||
192 | - DividendsParticipateType: dividendsEstimate.DividendsParticipateType, | ||
193 | - DividendsType: dividendsEstimate.DividendsType, | ||
194 | - DividendsTypeName: dividendsEstimate.DividendsTypeName, | ||
195 | - OrderOrReturnedOrderNum: dividendsEstimate.OrderOrReturnedOrderNum, | ||
196 | - CooperationContractNumber: dividendsEstimate.CooperationContractNumber, | ||
197 | - DividendsUser: dividendsEstimate.DividendsUser, | ||
198 | - DividendsStage: dividendsEstimate.DividendsStage, | ||
199 | - Org: dividendsEstimate.Org, | ||
200 | - Company: dividendsEstimate.Company, | ||
201 | - Operator: dividendsEstimate.Operator, | ||
202 | - OperateTime: dividendsEstimate.OperateTime, | ||
203 | - IsCanceled: dividendsEstimate.IsCanceled, | ||
204 | - OrderGoodId: dividendsEstimate.OrderGoodId, | ||
205 | - CreatedAt: dividendsEstimate.CreatedAt, | ||
206 | - DeletedAt: dividendsEstimate.DeletedAt, | ||
207 | - UpdatedAt: dividendsEstimate.UpdatedAt, | 191 | + DividendsEstimateId: dividendsEstimate.DividendsEstimateId, |
192 | + DividendsAccountStatus: dividendsEstimate.DividendsAccountStatus, | ||
193 | + PaymentStatus: dividendsEstimate.PaymentStatus, | ||
194 | + DividendsAmount: dividendsEstimate.DividendsAmount, | ||
195 | + DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber, | ||
196 | + DividendsEstimateTime: dividendsEstimate.DividendsEstimateTime, | ||
197 | + DividendsParticipateType: dividendsEstimate.DividendsParticipateType, | ||
198 | + DividendsType: dividendsEstimate.DividendsType, | ||
199 | + DividendsTypeName: dividendsEstimate.DividendsTypeName, | ||
200 | + OrderOrReturnedOrderNum: dividendsEstimate.OrderOrReturnedOrderNum, | ||
201 | + CooperationContractNumber: dividendsEstimate.CooperationContractNumber, | ||
202 | + DividendsUser: dividendsEstimate.DividendsUser, | ||
203 | + DividendsStage: dividendsEstimate.DividendsStage, | ||
204 | + Org: dividendsEstimate.Org, | ||
205 | + Company: dividendsEstimate.Company, | ||
206 | + Operator: dividendsEstimate.Operator, | ||
207 | + OperateTime: dividendsEstimate.OperateTime, | ||
208 | + IsCanceled: dividendsEstimate.IsCanceled, | ||
209 | + OrderGoodId: dividendsEstimate.OrderGoodId, | ||
210 | + CreatedAt: dividendsEstimate.CreatedAt, | ||
211 | + DeletedAt: dividendsEstimate.DeletedAt, | ||
212 | + UpdatedAt: dividendsEstimate.UpdatedAt, | ||
213 | + CooperationContractUndertakerId: dividendsEstimate.CooperationContractUndertakerId, | ||
208 | }) | 214 | }) |
209 | } | 215 | } |
210 | if len(dividendsEstimateModels) > 0 { | 216 | if len(dividendsEstimateModels) > 0 { |
@@ -229,28 +235,29 @@ func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []* | @@ -229,28 +235,29 @@ func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []* | ||
229 | var dividendsEstimateModels []*models.DividendsEstimate | 235 | var dividendsEstimateModels []*models.DividendsEstimate |
230 | for _, dividendsEstimate := range dividendsEstimates { | 236 | for _, dividendsEstimate := range dividendsEstimates { |
231 | dividendsEstimateModels = append(dividendsEstimateModels, &models.DividendsEstimate{ | 237 | dividendsEstimateModels = append(dividendsEstimateModels, &models.DividendsEstimate{ |
232 | - DividendsEstimateId: dividendsEstimate.DividendsEstimateId, | ||
233 | - DividendsAccountStatus: dividendsEstimate.DividendsAccountStatus, | ||
234 | - PaymentStatus: dividendsEstimate.PaymentStatus, | ||
235 | - DividendsAmount: dividendsEstimate.DividendsAmount, | ||
236 | - DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber, | ||
237 | - DividendsEstimateTime: dividendsEstimate.DividendsEstimateTime, | ||
238 | - DividendsParticipateType: dividendsEstimate.DividendsParticipateType, | ||
239 | - DividendsType: dividendsEstimate.DividendsType, | ||
240 | - DividendsTypeName: dividendsEstimate.DividendsTypeName, | ||
241 | - OrderOrReturnedOrderNum: dividendsEstimate.OrderOrReturnedOrderNum, | ||
242 | - CooperationContractNumber: dividendsEstimate.CooperationContractNumber, | ||
243 | - DividendsUser: dividendsEstimate.DividendsUser, | ||
244 | - DividendsStage: dividendsEstimate.DividendsStage, | ||
245 | - Org: dividendsEstimate.Org, | ||
246 | - Company: dividendsEstimate.Company, | ||
247 | - Operator: dividendsEstimate.Operator, | ||
248 | - OperateTime: dividendsEstimate.OperateTime, | ||
249 | - IsCanceled: dividendsEstimate.IsCanceled, | ||
250 | - OrderGoodId: dividendsEstimate.OrderGoodId, | ||
251 | - CreatedAt: dividendsEstimate.CreatedAt, | ||
252 | - DeletedAt: dividendsEstimate.DeletedAt, | ||
253 | - UpdatedAt: time.Now(), | 238 | + DividendsEstimateId: dividendsEstimate.DividendsEstimateId, |
239 | + DividendsAccountStatus: dividendsEstimate.DividendsAccountStatus, | ||
240 | + PaymentStatus: dividendsEstimate.PaymentStatus, | ||
241 | + DividendsAmount: dividendsEstimate.DividendsAmount, | ||
242 | + DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber, | ||
243 | + DividendsEstimateTime: dividendsEstimate.DividendsEstimateTime, | ||
244 | + DividendsParticipateType: dividendsEstimate.DividendsParticipateType, | ||
245 | + DividendsType: dividendsEstimate.DividendsType, | ||
246 | + DividendsTypeName: dividendsEstimate.DividendsTypeName, | ||
247 | + OrderOrReturnedOrderNum: dividendsEstimate.OrderOrReturnedOrderNum, | ||
248 | + CooperationContractNumber: dividendsEstimate.CooperationContractNumber, | ||
249 | + DividendsUser: dividendsEstimate.DividendsUser, | ||
250 | + DividendsStage: dividendsEstimate.DividendsStage, | ||
251 | + Org: dividendsEstimate.Org, | ||
252 | + Company: dividendsEstimate.Company, | ||
253 | + Operator: dividendsEstimate.Operator, | ||
254 | + OperateTime: dividendsEstimate.OperateTime, | ||
255 | + IsCanceled: dividendsEstimate.IsCanceled, | ||
256 | + OrderGoodId: dividendsEstimate.OrderGoodId, | ||
257 | + CreatedAt: dividendsEstimate.CreatedAt, | ||
258 | + DeletedAt: dividendsEstimate.DeletedAt, | ||
259 | + UpdatedAt: time.Now(), | ||
260 | + CooperationContractUndertakerId: dividendsEstimate.CooperationContractUndertakerId, | ||
254 | }) | 261 | }) |
255 | } | 262 | } |
256 | if _, err := tx.Model(÷ndsEstimateModels).WherePK().Update(); err != nil { | 263 | if _, err := tx.Model(÷ndsEstimateModels).WherePK().Update(); err != nil { |
@@ -325,6 +332,9 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte | @@ -325,6 +332,9 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte | ||
325 | if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 { | 332 | if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 { |
326 | query.Where("cooperation_contract_number in (?)", pg.In(v)) | 333 | query.Where("cooperation_contract_number in (?)", pg.In(v)) |
327 | } | 334 | } |
335 | + if cooperationContractUndertakerId, ok := queryOptions["cooperationContractUndertakerId"]; ok && cooperationContractUndertakerId.(int64) != 0 { | ||
336 | + query.Where("cooperation_contract_undertaker_id = ?", cooperationContractUndertakerId) | ||
337 | + } | ||
328 | if dividendsParticipateType, ok := queryOptions["dividendsParticipateType"]; ok && dividendsParticipateType.(int32) != 0 { | 338 | if dividendsParticipateType, ok := queryOptions["dividendsParticipateType"]; ok && dividendsParticipateType.(int32) != 0 { |
329 | query.Where("dividends_participate_type = ?", dividendsParticipateType) | 339 | query.Where("dividends_participate_type = ?", dividendsParticipateType) |
330 | } | 340 | } |
@@ -340,6 +350,10 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte | @@ -340,6 +350,10 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte | ||
340 | if dividendsUserId, ok := queryOptions["dividendsUserId"]; ok && dividendsUserId.(int64) != 0 { | 350 | if dividendsUserId, ok := queryOptions["dividendsUserId"]; ok && dividendsUserId.(int64) != 0 { |
341 | query.Where(`dividends_user @> '{"userId":"?"}'`, dividendsUserId) | 351 | query.Where(`dividends_user @> '{"userId":"?"}'`, dividendsUserId) |
342 | } | 352 | } |
353 | + if dividendsUserIds, ok := queryOptions["dividendsUserIds"]; ok && len(dividendsUserIds.([]int64)) > 0 { | ||
354 | + newDividendsUserIds := utils.SliceItoa(dividendsUserIds.([]int64)) | ||
355 | + query.Where("dividends_user->>'userId' in (?)", pg.In(newDividendsUserIds)) | ||
356 | + } | ||
343 | if userBaseId, ok := queryOptions["userBaseId"]; ok && userBaseId.(int64) != 0 { | 357 | if userBaseId, ok := queryOptions["userBaseId"]; ok && userBaseId.(int64) != 0 { |
344 | query.Where(`dividends_user @> '{"userBaseId":"?"}'`, userBaseId) | 358 | query.Where(`dividends_user @> '{"userBaseId":"?"}'`, userBaseId) |
345 | } | 359 | } |
@@ -45,7 +45,7 @@ func (serviceGateway *httplibBaseServiceGateway) createRequest(url string, metho | @@ -45,7 +45,7 @@ func (serviceGateway *httplibBaseServiceGateway) createRequest(url string, metho | ||
45 | case "head": | 45 | case "head": |
46 | request = httplib.Head(url) | 46 | request = httplib.Head(url) |
47 | break | 47 | break |
48 | - default: | 48 | + : |
49 | request = httplib.Get(url) | 49 | request = httplib.Get(url) |
50 | } | 50 | } |
51 | return request.SetTimeout(serviceGateway.connectTimeout, serviceGateway.readWriteTimeout) | 51 | return request.SetTimeout(serviceGateway.connectTimeout, serviceGateway.readWriteTimeout) |
-
请 注册 或 登录 后发表评论