作者 yangfu

Merge branch 'test' of http://gitlab.fjmaimaimai.com/allied-creation/allied-crea…

…tion-cooperation into test
... ... @@ -281,8 +281,22 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
cooperationApplicationRepository = value
}
var getCooperationProjectQuerySpecific *query.GetCooperationProjectQuery
if getCooperationProjectQuery.CooperationProjectId != 0 { // 根据ID查询
getCooperationProjectQuerySpecific = &query.GetCooperationProjectQuery{
CooperationProjectId: getCooperationProjectQuery.CooperationProjectId,
CooperationProjectNumber: "",
CompanyId: 0,
OrgId: 0,
UserId: 0,
UserBaseId: 0,
}
} else if getCooperationProjectQuery.CooperationProjectNumber != "" { // 根据编号查询
getCooperationProjectQuerySpecific = getCooperationProjectQuery
}
// 获取共创项目
cooperationProject, err := cooperationProjectRepository.FindOne(tool_funs.SimpleStructToMap(getCooperationProjectQuery))
cooperationProject, err := cooperationProjectRepository.FindOne(tool_funs.SimpleStructToMap(getCooperationProjectQuerySpecific))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -306,8 +320,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
gotUser, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
"cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
"user": true,
"companyId": getCooperationProjectQuery.CompanyId,
"orgId": getCooperationProjectQuery.OrgId,
"companyId": cooperationProject.Company.CompanyId,
"orgId": cooperationProject.Org.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -320,8 +334,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
gotPartner, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
"cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
"partner": true,
"companyId": getCooperationProjectQuery.CompanyId,
"orgId": getCooperationProjectQuery.OrgId,
"companyId": cooperationProject.Company.CompanyId,
"orgId": cooperationProject.Org.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -337,6 +351,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
// 返回所有员工类型的申请通过人
applicants := make([]*domain.User, 0)
// 获取当前项目的所有申请
if countApplication, cooperationApplications, err := cooperationApplicationRepository.Find(map[string]interface{}{
"cooperationProjectNumberExact": cooperationProject.CooperationProjectNumber,
... ...
... ... @@ -157,6 +157,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
OrderGoodAmount: dividendsEstimate.OrderGoodAmount,
CooperationContractNumber: dividendsEstimate.CooperationContractNumber,
})
settlementAmount = settlementAmount + dividendsEstimate.DividendsAmount
goodAmountCount = goodAmountCount + dividendsEstimate.OrderGoodAmount
... ...
... ... @@ -30,6 +30,10 @@ type SearchMoneyIncentivesEstimateQuery struct {
PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"`
// 激励方式
IncentivesType int32 `cname:"激励方式" json:"incentivesType,omitempty"`
// 合约状态,1正常,2暂停
Status int32 `cname:"合约状态" json:"status,omitempty"`
// 查询限制
OffsetLimit bool `json:"offsetLimit,omitempty"`
}
func (searchMoneyIncentivesEstimateQuery *SearchMoneyIncentivesEstimateQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -1380,6 +1380,8 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
// 查找共创合约
searchMoneyIncentivesEstimateQuery.IncentivesType = 2
searchMoneyIncentivesEstimateQuery.Status = 1
searchMoneyIncentivesEstimateQuery.OffsetLimit = false
if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(searchMoneyIncentivesEstimateQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -1387,15 +1389,19 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
for _, cooperationContract := range cooperationContracts {
// 阶段承接人map
stageUndertakerMap := make(map[int32][]*domain.Undertaker)
// 阶段承接人列表
stageAndUndertaker := make([]*dto.StageAndUndertaker, 0)
// 初始化阶段承接人map
for _, rule := range cooperationContract.MoneyIncentivesRules {
stageUndertakerMap[rule.MoneyIncentivesStage] = make([]*domain.Undertaker, 0)
}
log.Logger.Info("阶段承接人map初始化", map[string]interface{}{
"stageUndertakerMap": stageUndertakerMap,
})
// 获取承接人
for _, undertaker := range cooperationContract.Undertakers {
// 查询承接人分红预算单
... ... @@ -1404,6 +1410,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
"companyId": cooperationContract.Company.CompanyId,
"orgId": cooperationContract.Org.OrgId,
"dividendsUserId": undertaker.UserId,
"offsetLimit": false,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -1413,16 +1420,20 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
stageUndertakerMap[dividendsEstimate.DividendsStage] = append(stageUndertakerMap[dividendsEstimate.DividendsStage], undertaker)
}
}
break
} else if countDividendsEstimates == 0 { // 未分红,可以加入任意阶段进行金额激励
for i, _ := range stageUndertakerMap {
stageUndertakerMap[i] = append(stageUndertakerMap[i], undertaker)
}
break
}
}
}
log.Logger.Info("阶段承接人map", map[string]interface{}{
"stageUndertakerMap": stageUndertakerMap,
})
for k, v := range stageUndertakerMap {
stageAndUndertaker = append(stageAndUndertaker, &dto.StageAndUndertaker{
Stage: k,
... ... @@ -1431,10 +1442,22 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
}
moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract, stageAndUndertaker); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// 判断当前合约的承接人是否全部分红
allEstimate := true
for i, _ := range stageUndertakerMap {
if len(stageUndertakerMap[i]) > 0 {
allEstimate = false
break
}
}
if !allEstimate {
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract, stageAndUndertaker); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
}
moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
}
if err := transactionContext.CommitTransaction(); err != nil {
... ...
... ... @@ -1122,8 +1122,16 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide
}
orderTime := utils.TransformTimestampToTime(orderTimeInt)
// 退货单ID类型转换
dividendsReturnedOrderId, err := strconv.ParseInt(updateDividendsReturnedOrderCommand.DividendsReturnedOrderId, 10, 64)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "退货单ID类型错误")
}
// 获取分红退货单
dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderId": updateDividendsReturnedOrderCommand.DividendsReturnedOrderId})
dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{
"dividendsReturnedOrderId": dividendsReturnedOrderId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -9,7 +9,7 @@ import (
type DividendsEstimateDetail struct {
DividendsUser *domain.User `json:"dividendsUser"` // 共创参与(分红用户)
DividendsParticipateType int32 `json:"dividendsParticipateType"` // 参与类型
DividendsParticipateType int32 `json:"dividendsParticipateType"` // 参与类型 1承接人,2推荐人,3关联业务员
DividendsStage int32 `json:"dividendsStage"` // 分红阶段
DividendsAmount float64 `json:"dividendsAmount"` // 分红金额
OrderOrReturnedOrderNumber string `json:"orderOrReturnedOrderNumber"` // 分红订单号或退货单号
... ...
... ... @@ -60,26 +60,52 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
var dividendsEstimatesCanceled []*domain.DividendsEstimate
var orderOrReturnOrderNums []string
for _, dividendsEstimate := range dividendsEstimates {
// 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
"companyId": dividendsEstimate.Company.CompanyId,
"orgId": dividendsEstimate.Org.OrgId,
"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
}); err2 != nil {
return nil, err2
} else {
if countRelative > 0 {
for i, _ := range dividendsEstimatesRelative {
dividendsEstimatesRelative[i].IsCanceled = true
dividendsEstimatesRelative[i].Operator = operator
// 获取相关订单/退货单号
orderOrReturnOrderNums = append(orderOrReturnOrderNums, dividendsEstimatesRelative[i].OrderOrReturnedOrderNum)
if dividendsEstimate.DividendsType != 3 { // 非金额激励分红预算单处理
// 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
"companyId": dividendsEstimate.Company.CompanyId,
"orgId": dividendsEstimate.Org.OrgId,
"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
"offsetLimit": false,
}); err2 != nil {
return nil, err2
} else {
if countRelative > 0 {
for i, _ := range dividendsEstimatesRelative {
dividendsEstimatesRelative[i].IsCanceled = true
dividendsEstimatesRelative[i].Operator = operator
// 获取相关订单/退货单号
orderOrReturnOrderNums = append(orderOrReturnOrderNums, dividendsEstimatesRelative[i].OrderOrReturnedOrderNum)
}
dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative)
if err3 != nil {
return nil, err3
}
dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...)
}
dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative)
if err3 != nil {
return nil, err3
}
} else if dividendsEstimate.DividendsType == 3 {
// 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
"companyId": dividendsEstimate.Company.CompanyId,
"orgId": dividendsEstimate.Org.OrgId,
"cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
"dividendsType": int32(3),
"offsetLimit": false,
}); err2 != nil {
return nil, err2
} else {
if countRelative > 0 {
for i, _ := range dividendsEstimatesRelative {
dividendsEstimatesRelative[i].IsCanceled = true
dividendsEstimatesRelative[i].Operator = operator
}
dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative)
if err3 != nil {
return nil, err3
}
dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...)
}
dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...)
}
}
}
... ... @@ -88,98 +114,107 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
var orderNums []string
var returnedOrderNums []string
// 订单/退货单号数组去重
orderOrReturnOrderNumsWithoutDup := utils.RemoveDuplication(orderOrReturnOrderNums)
for _, orderNullNum := range orderOrReturnOrderNumsWithoutDup {
if orderNullNum[:2] == "RE" { // 分红退后单
returnedOrderNums = append(returnedOrderNums, orderNullNum)
} else if orderNullNum[:2] == "SL" { // 分红订单
orderNums = append(orderNums, orderNullNum)
if len(orderOrReturnOrderNums) > 0 {
// 订单/退货单号数组去重
orderOrReturnOrderNumsWithoutDup := utils.RemoveDuplication(orderOrReturnOrderNums)
for _, orderNullNum := range orderOrReturnOrderNumsWithoutDup {
if orderNullNum[:2] == "RE" { // 分红退后单
returnedOrderNums = append(returnedOrderNums, orderNullNum)
} else if orderNullNum[:2] == "SL" { // 分红订单
orderNums = append(orderNums, orderNullNum)
}
}
}
// 获取分红订单
if countDividendsOrder, orders, err4 := dividendsOrderRepository.Find(map[string]interface{}{
"companyId": dividendsEstimates[0].Company.CompanyId,
"orgId": dividendsEstimates[0].Org.OrgId,
"dividendsOrderNumbers": orderNums,
}); err4 != nil {
return nil, err4
} else {
if countDividendsOrder > 0 {
for i, _ := range orders {
orders[i].DividendStatus = 1
}
// 保存订单状态
if _, err6 := dividendsOrderRepository.UpdateMany(orders); err6 != nil {
return nil, err6
}
// 获取订单编号
ordersNumbers := make([]string, 0)
for _, order := range orders {
ordersNumbers = append(ordersNumbers, order.DividendsOrderNumber)
}
// 获取分红订单产品并更新产品状态
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
"orderNumbers": ordersNumbers,
"companyId": dividendsEstimates[0].Company.CompanyId,
"orgId": dividendsEstimates[0].Org.OrgId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// 获取分红订单并更新分红订单产品的状态
if len(orderNums) > 0 {
if countDividendsOrder, orders, err4 := dividendsOrderRepository.Find(map[string]interface{}{
"companyId": dividendsEstimates[0].Company.CompanyId,
"orgId": dividendsEstimates[0].Org.OrgId,
"dividendsOrderNumbers": orderNums,
}); err4 != nil {
return nil, err4
} else {
if countOrderGood > 0 {
for i, _ := range orderGoodsFound {
orderGoodsFound[i].OrderGoodDividendsStatus = int32(1) // 待分红
if countDividendsOrder > 0 {
for i, _ := range orders {
orders[i].DividendStatus = 1
}
// 保存订单状态
if _, err6 := dividendsOrderRepository.UpdateMany(orders); err6 != nil {
return nil, err6
}
// 获取订单编号
ordersNumbers := make([]string, 0)
for _, order := range orders {
ordersNumbers = append(ordersNumbers, order.DividendsOrderNumber)
}
if _, err6 := orderGoodRepository.UpdateMany(orderGoodsFound); err6 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err6.Error())
// 获取分红订单产品并更新产品状态
if len(ordersNumbers) > 0 {
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
"orderNumbers": ordersNumbers,
"companyId": dividendsEstimates[0].Company.CompanyId,
"orgId": dividendsEstimates[0].Org.OrgId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if countOrderGood > 0 {
for i, _ := range orderGoodsFound {
orderGoodsFound[i].OrderGoodDividendsStatus = int32(1) // 待分红
}
if _, err6 := orderGoodRepository.UpdateMany(orderGoodsFound); err6 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err6.Error())
}
}
}
}
}
}
}
}
// 获取分红退货单
if countDividendsReturnedOrder, returnedOrders, err5 := dividendsReturnedOrderRepository.Find(map[string]interface{}{
"companyId": dividendsEstimates[0].Company.CompanyId,
"orgId": dividendsEstimates[0].Org.OrgId,
"dividendsReturnedOrderNumbers": returnedOrderNums,
}); err5 != nil {
return nil, err5
} else {
if countDividendsReturnedOrder > 0 {
for i, _ := range returnedOrders {
returnedOrders[i].DividendStatus = 1
}
// 保存退货单状态
if _, err7 := dividendsReturnedOrderRepository.UpdateMany(returnedOrders); err7 != nil {
return nil, err7
}
// 获取订单编号
returnedOrdersNumbers := make([]string, 0)
for _, returnedOrder := range returnedOrders {
returnedOrdersNumbers = append(returnedOrdersNumbers, returnedOrder.DividendsReturnedOrderNumber)
}
// 获取退货单产品并更新产品状态
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
"returnedOrderNumbers": returnedOrdersNumbers,
"companyId": dividendsEstimates[0].Company.CompanyId,
"orgId": dividendsEstimates[0].Org.OrgId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// 获取分红退货单并更新订单产品的状态
if len(returnedOrderNums) > 0 {
if countDividendsReturnedOrder, returnedOrders, err5 := dividendsReturnedOrderRepository.Find(map[string]interface{}{
"companyId": dividendsEstimates[0].Company.CompanyId,
"orgId": dividendsEstimates[0].Org.OrgId,
"dividendsReturnedOrderNumbers": returnedOrderNums,
}); err5 != nil {
return nil, err5
} else {
if countOrderGood > 0 {
for i, _ := range orderGoodsFound {
orderGoodsFound[i].OrderGoodDividendsStatus = int32(1) // 待分红
if countDividendsReturnedOrder > 0 {
for i, _ := range returnedOrders {
returnedOrders[i].DividendStatus = 1
}
// 保存退货单状态
if _, err7 := dividendsReturnedOrderRepository.UpdateMany(returnedOrders); err7 != nil {
return nil, err7
}
if _, err6 := orderGoodRepository.UpdateMany(orderGoodsFound); err6 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err6.Error())
// 获取订单编号
returnedOrdersNumbers := make([]string, 0)
for _, returnedOrder := range returnedOrders {
returnedOrdersNumbers = append(returnedOrdersNumbers, returnedOrder.DividendsReturnedOrderNumber)
}
// 获取退货单产品并更新产品状态
if len(returnedOrdersNumbers) > 0 {
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
"returnedOrderNumbers": returnedOrdersNumbers,
"companyId": dividendsEstimates[0].Company.CompanyId,
"orgId": dividendsEstimates[0].Org.OrgId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if countOrderGood > 0 {
for i, _ := range orderGoodsFound {
orderGoodsFound[i].OrderGoodDividendsStatus = int32(1) // 待分红
}
if _, err6 := orderGoodRepository.UpdateMany(orderGoodsFound); err6 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err6.Error())
}
}
}
}
}
}
}
}
return dividendsEstimatesCanceled, nil
}
}
... ...
... ... @@ -44,7 +44,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
// 判断金额激励阶段是否合法
currentTime := time.Now()
if currentTime.Before(moneyIncentivesRuleMatched.MoneyIncentivesStageStart) {
if currentTime.Before(moneyIncentivesRuleMatched.MoneyIncentivesTime) {
return nil, fmt.Errorf("还未到分红时间")
}
... ... @@ -61,7 +61,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
return nil, err
}
if undertakerEstimated {
return nil, fmt.Errorf("用户 " + undertaker.UserName + " 已分红")
return nil, fmt.Errorf("承接人 " + undertaker.UserName + " 已分红")
} else {
undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Float64()
//Mul(decimal.NewFromFloat(1).Sub(decimal.NewFromFloat(moneyIncentivesRuleMatched.SalesmanPercentage).Add(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage)).Div(decimal.NewFromFloat(100)))).Float64()
... ... @@ -80,7 +80,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
Status: undertaker.Status,
Company: undertaker.Company,
},
DividendsParticipateType: domain.MONEY_INCENTIVES,
DividendsParticipateType: 1,
DividendsStage: stage,
DividendsAmount: undertakerDividendsAmount,
})
... ... @@ -114,7 +114,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
UserPhone: undertaker.Salesman.UserPhone,
Company: undertaker.Salesman.Company,
},
DividendsParticipateType: domain.MONEY_INCENTIVES,
DividendsParticipateType: 3,
DividendsStage: stage,
DividendsAmount: undertakerDividendsAmount,
})
... ... @@ -122,7 +122,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
}
// 判断关联业务员在当前阶段是否已经分红
// 判断推荐人在当前阶段是否已经分红
if undertaker.Referrer != nil {
referrerEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{
"undertakerUid": undertaker.Referrer.UserId,
... ... @@ -133,7 +133,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
return nil, err
}
if referrerEstimated {
return nil, fmt.Errorf("推荐人 " + undertaker.Salesman.UserName + " 已分红")
return nil, fmt.Errorf("推荐人 " + undertaker.Referrer.UserName + " 已分红")
} else {
undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Mul(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64()
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
... ... @@ -150,7 +150,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
UserPhone: undertaker.Referrer.UserPhone,
Company: undertaker.Referrer.Company,
},
DividendsParticipateType: domain.MONEY_INCENTIVES,
DividendsParticipateType: 2,
DividendsStage: stage,
DividendsAmount: undertakerDividendsAmount,
})
... ...
... ... @@ -308,6 +308,9 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte
if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 {
query.Where("cooperation_contract_number in (?)", pg.In(v))
}
if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" {
query.Where("cooperation_contract_number = ?", cooperationContractNumber)
}
if dividendsUserId, ok := queryOptions["dividendsUserId"]; ok && dividendsUserId.(int64) != 0 {
query.Where(`dividends_user @> '{"uid":"?"}'`, dividendsUserId)
}
... ...