作者 陈志颖

refactor:优化分红预算

... ... @@ -649,16 +649,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
cooperationContractRepository = value
}
// 共创项目仓储初始化
//var cooperationProjectRepository domain.CooperationProjectRepository
//if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
// "transactionContext": transactionContext,
//}); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//} else {
// cooperationProjectRepository = value
//}
// 初始化确认业绩激励分红预算领域服务
var confirmDividendsIncentivesEstimateService service.ConfirmDividendsIncentivesEstimateService
if value, err := factory.CreateConfirmDividendsIncentivesEstimateService(map[string]interface{}{
... ... @@ -672,26 +662,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
})
}
// 查询共创项目
//cooperationProjectsMap := make(map[string]*domain.CooperationProject, 0)
//if count, cooperationProjectsFound, err := cooperationProjectRepository.Find(map[string]interface{}{
// "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
// "orgId": confirmDividendsIncentivesEstimateCommand.OrgId,
// "offsetLimit": false,
//}); err != nil {
// return nil, err
//} else {
// if count > 0 {
// for _, cooperationProjectFound := range cooperationProjectsFound {
// cooperationProjectsMap[cooperationProjectFound.CooperationProjectNumber] = cooperationProjectFound
// }
// }
//}
//
//log.Logger.Info("查询共创项目", map[string]interface{}{
// "cooperationProjectsMap": cooperationProjectsMap,
//})
// 统计成功预算的分红订单
estimateSuccessfullyDividendsOrders := make(map[string]string)
... ... @@ -716,27 +686,30 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
newCooperationContractNumbers := utils.RemoveDuplicationString(cooperationContractNumbers)
// 查询共创合约
cooperationContractsMap := make(map[string]*domain.CooperationContract, 0)
if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{
"cooperationContractNumbers": newCooperationContractNumbers,
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
"orgId": confirmDividendsIncentivesEstimateCommand.OrgId,
"offsetLimit": false,
}); err != nil {
return nil, err
} else {
if count > 0 {
for _, cooperationContractFound := range cooperationContractsFound {
cooperationContractsMap[cooperationContractFound.CooperationContractNumber] = cooperationContractFound
// 查询共创合约
if len(newCooperationContractNumbers) > 0 {
if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{
"cooperationContractNumbers": newCooperationContractNumbers,
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
"orgId": confirmDividendsIncentivesEstimateCommand.OrgId,
"offsetLimit": false,
}); err != nil {
return nil, err
} else {
if count > 0 {
for _, cooperationContractFound := range cooperationContractsFound {
cooperationContractsMap[cooperationContractFound.CooperationContractNumber] = cooperationContractFound
}
}
}
} else {
return map[string]interface{}{
"report": fmt.Sprintf("已完成0单订单分红预算,生成0单分红预算,失败原因:产品未关联合约"),
}, nil
}
log.Logger.Info("查询共创合约", map[string]interface{}{
"cooperationContractsMap": cooperationContractsMap,
})
// 统计当前企业分红预算单数
count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
... ... @@ -747,129 +720,241 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
var countDividendsEstimate int64
orderGoodsToConfirm := make([]*domain.OrderGood, 0)
returnedOrderGoodsToConfirm := make([]*domain.OrderGood, 0)
for _, orderGood := range orderGoods {
log.Logger.Info("hello 1")
dividendsEstimate := &domain.DividendsEstimate{}
if orderGood.DividendsOrderNumber != "" { // 查询分红订单
orderGoodsToConfirm := make([]*domain.OrderGood, 0)
if orderGood.DividendsOrderNumber != "" {
orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
// 分红订单产品预算
if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, dividendsEstimateDetail := range dividendsEstimateDetails {
log.Logger.Info("hello 2")
if dividendsEstimateDetail.IsSuccessfully {
// 生成分红预算单号
dividendsEstimateOrderNumber, err := dividendsEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
} else if orderGood.DividendsReturnedOrderNumber != "" {
returnedOrderGoodsToConfirm = append(returnedOrderGoodsToConfirm, orderGood)
}
}
// 记录成功的订单号
estimateSuccessfullyDividendsOrders[dividendsEstimateDetail.OrderOrReturnedOrderNumber] = dividendsEstimateDetail.OrderOrReturnedOrderNumber
// 统计分红预算单数目
countDividendsEstimate = countDividendsEstimate + 1
dividendsEstimate = &domain.DividendsEstimate{
DividendsEstimateId: 0,
DividendsAccountStatus: domain.TO_BE_ACCOUNT,
DividendsAmount: dividendsEstimateDetail.DividendsAmount,
DividendsEstimateOrderNumber: dividendsEstimateOrderNumber,
DividendsEstimateTime: time.Now(),
DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType,
DividendsType: domain.ORDER_DIVIDENDS,
DividendsTypeName: "订单分红",
OrderOrReturnedOrderNum: orderGood.DividendsOrderNumber,
CooperationContractNumber: orderGood.CooperationContractNumber,
DividendsUser: dividendsEstimateDetail.DividendsUser,
DividendsPercentage: dividendsEstimateDetail.DividendsPercentage,
DividendsStage: dividendsEstimateDetail.DividendsStage,
Org: organization,
Company: company,
Operator: operator,
OperateTime: time.Time{},
IsCanceled: false,
CreatedAt: time.Now(),
DeletedAt: time.Time{},
UpdatedAt: time.Time{},
OrderGoodId: orderGood.OrderGoodId,
OrderGoodAmount: orderGood.OrderGoodAmount,
PaymentStatus: int32(1),
CooperationContractUndertakerId: dividendsEstimateDetail.CooperationContractUndertakerId,
}
if len(orderGoodsToConfirm) > 0 { // 分红订单产品预算
if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, dividendsEstimateDetail := range dividendsEstimateDetails {
if dividendsEstimateDetail.IsSuccessfully {
// 生成分红预算单号
dividendsEstimateOrderNumber, err := dividendsEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
} else {
// 记录失败的订单号和原因
estimateFailedDividendsOrders[dividendsEstimateDetail.OrderOrReturnedOrderNumber] = dividendsEstimateDetail.Reason
// 记录成功的订单号
estimateSuccessfullyDividendsOrders[dividendsEstimateDetail.OrderOrReturnedOrderNumber] = dividendsEstimateDetail.OrderOrReturnedOrderNumber
// 统计分红预算单数目
countDividendsEstimate = countDividendsEstimate + 1
dividendsEstimate := &domain.DividendsEstimate{
DividendsEstimateId: 0,
DividendsAccountStatus: domain.TO_BE_ACCOUNT,
DividendsAmount: dividendsEstimateDetail.DividendsAmount,
DividendsEstimateOrderNumber: dividendsEstimateOrderNumber,
DividendsEstimateTime: time.Now(),
DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType,
DividendsType: domain.ORDER_DIVIDENDS,
DividendsTypeName: "订单分红",
OrderOrReturnedOrderNum: dividendsEstimateDetail.OrderOrReturnedOrderNumber,
CooperationContractNumber: dividendsEstimateDetail.CooperationContractNumber,
DividendsUser: dividendsEstimateDetail.DividendsUser,
DividendsPercentage: dividendsEstimateDetail.DividendsPercentage,
DividendsStage: dividendsEstimateDetail.DividendsStage,
Org: organization,
Company: company,
Operator: operator,
OperateTime: time.Time{},
IsCanceled: false,
CreatedAt: time.Now(),
DeletedAt: time.Time{},
UpdatedAt: time.Time{},
OrderGoodId: dividendsEstimateDetail.OrderGoodId,
OrderGoodAmount: dividendsEstimateDetail.OrderGoodAmount,
PaymentStatus: int32(1),
CooperationContractUndertakerId: dividendsEstimateDetail.CooperationContractUndertakerId,
}
dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
} else {
// 记录失败的订单号和原因
estimateFailedDividendsOrders[dividendsEstimateDetail.OrderOrReturnedOrderNumber] = dividendsEstimateDetail.Reason
}
}
} else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
log.Logger.Info("hello 3")
orderGoodsToConfirm := make([]*domain.OrderGood, 0)
orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
// 分红退货单产品预算
if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {
if dividendsReturnedEstimateDetail.IsSuccessfully {
// 生成分红预算单号
dividendsEstimateOrderNumber, err := dividendsReturnedEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
// 记录成功的退货单号
estimateSuccessfullyDividendsOrders[dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber] = dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber
// 统计生成的预算单数量
countDividendsEstimate = countDividendsEstimate + 1
dividendsEstimate = &domain.DividendsEstimate{
DividendsEstimateId: 0,
DividendsAccountStatus: domain.TO_BE_ACCOUNT,
DividendsAmount: dividendsReturnedEstimateDetail.DividendsAmount,
DividendsEstimateOrderNumber: dividendsEstimateOrderNumber,
DividendsEstimateTime: time.Now(),
DividendsParticipateType: dividendsReturnedEstimateDetail.DividendsParticipateType,
DividendsType: domain.RETURN_WRITE_OFF,
DividendsTypeName: "退货冲销",
OrderOrReturnedOrderNum: orderGood.DividendsReturnedOrderNumber,
CooperationContractNumber: orderGood.CooperationContractNumber,
DividendsUser: dividendsReturnedEstimateDetail.DividendsUser,
DividendsPercentage: dividendsReturnedEstimateDetail.DividendsPercentage,
DividendsStage: dividendsReturnedEstimateDetail.DividendsStage,
Org: organization,
Company: company,
Operator: operator,
OperateTime: time.Time{},
IsCanceled: false,
CreatedAt: time.Now(),
DeletedAt: time.Time{},
UpdatedAt: time.Time{},
OrderGoodId: orderGood.OrderGoodId,
OrderGoodAmount: orderGood.OrderGoodAmount,
PaymentStatus: int32(1),
CooperationContractUndertakerId: dividendsReturnedEstimateDetail.CooperationContractUndertakerId,
}
}
} else if len(returnedOrderGoodsToConfirm) > 0 { // 退货单产品预算
if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(returnedOrderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {
if dividendsReturnedEstimateDetail.IsSuccessfully {
// 生成分红预算单号
dividendsEstimateOrderNumber, err := dividendsReturnedEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
} else {
// 记录失败的退货单号和原因
estimateFailedDividendsOrders[dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber] = dividendsReturnedEstimateDetail.Reason
// 记录成功的退货单号
estimateSuccessfullyDividendsOrders[dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber] = dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber
// 统计生成的预算单数量
countDividendsEstimate = countDividendsEstimate + 1
dividendsEstimate := &domain.DividendsEstimate{
DividendsEstimateId: 0,
DividendsAccountStatus: domain.TO_BE_ACCOUNT,
DividendsAmount: dividendsReturnedEstimateDetail.DividendsAmount,
DividendsEstimateOrderNumber: dividendsEstimateOrderNumber,
DividendsEstimateTime: time.Now(),
DividendsParticipateType: dividendsReturnedEstimateDetail.DividendsParticipateType,
DividendsType: domain.RETURN_WRITE_OFF,
DividendsTypeName: "退货冲销",
OrderOrReturnedOrderNum: dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber,
CooperationContractNumber: dividendsReturnedEstimateDetail.CooperationContractNumber,
DividendsUser: dividendsReturnedEstimateDetail.DividendsUser,
DividendsPercentage: dividendsReturnedEstimateDetail.DividendsPercentage,
DividendsStage: dividendsReturnedEstimateDetail.DividendsStage,
Org: organization,
Company: company,
Operator: operator,
OperateTime: time.Time{},
IsCanceled: false,
CreatedAt: time.Now(),
DeletedAt: time.Time{},
UpdatedAt: time.Time{},
OrderGoodId: dividendsReturnedEstimateDetail.OrderGoodId,
OrderGoodAmount: dividendsReturnedEstimateDetail.OrderGoodAmount,
PaymentStatus: int32(1),
CooperationContractUndertakerId: dividendsReturnedEstimateDetail.CooperationContractUndertakerId,
}
dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
} else {
// 记录失败的退货单号和原因
estimateFailedDividendsOrders[dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber] = dividendsReturnedEstimateDetail.Reason
}
}
}
}
log.Logger.Info("新增的分红预算单", map[string]interface{}{
"dividendsEstimates": dividendsEstimates,
})
//for _, orderGood := range orderGoods {
// dividendsEstimate := &domain.DividendsEstimate{}
// if orderGood.DividendsOrderNumber != "" { // 查询分红订单
// orderGoodsToConfirm := make([]*domain.OrderGood, 0)
// orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
// // 分红订单产品预算
// if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// } else {
// for _, dividendsEstimateDetail := range dividendsEstimateDetails {
// if dividendsEstimateDetail.IsSuccessfully {
// // 生成分红预算单号
// dividendsEstimateOrderNumber, err := dividendsEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
// }
//
// // 记录成功的订单号
// estimateSuccessfullyDividendsOrders[dividendsEstimateDetail.OrderOrReturnedOrderNumber] = dividendsEstimateDetail.OrderOrReturnedOrderNumber
//
// // 统计分红预算单数目
// countDividendsEstimate = countDividendsEstimate + 1
//
// dividendsEstimate = &domain.DividendsEstimate{
// DividendsEstimateId: 0,
// DividendsAccountStatus: domain.TO_BE_ACCOUNT,
// DividendsAmount: dividendsEstimateDetail.DividendsAmount,
// DividendsEstimateOrderNumber: dividendsEstimateOrderNumber,
// DividendsEstimateTime: time.Now(),
// DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType,
// DividendsType: domain.ORDER_DIVIDENDS,
// DividendsTypeName: "订单分红",
// OrderOrReturnedOrderNum: orderGood.DividendsOrderNumber,
// CooperationContractNumber: orderGood.CooperationContractNumber,
// DividendsUser: dividendsEstimateDetail.DividendsUser,
// DividendsPercentage: dividendsEstimateDetail.DividendsPercentage,
// DividendsStage: dividendsEstimateDetail.DividendsStage,
// Org: organization,
// Company: company,
// Operator: operator,
// OperateTime: time.Time{},
// IsCanceled: false,
// CreatedAt: time.Now(),
// DeletedAt: time.Time{},
// UpdatedAt: time.Time{},
// OrderGoodId: orderGood.OrderGoodId,
// OrderGoodAmount: orderGood.OrderGoodAmount,
// PaymentStatus: int32(1),
// CooperationContractUndertakerId: dividendsEstimateDetail.CooperationContractUndertakerId,
// }
//
// dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
// } else {
// // 记录失败的订单号和原因
// estimateFailedDividendsOrders[dividendsEstimateDetail.OrderOrReturnedOrderNumber] = dividendsEstimateDetail.Reason
// }
// }
// }
// } else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
// orderGoodsToConfirm := make([]*domain.OrderGood, 0)
// orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
// // 分红退货单产品预算
// if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// } else {
// for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {
// if dividendsReturnedEstimateDetail.IsSuccessfully {
// // 生成分红预算单号
// dividendsEstimateOrderNumber, err := dividendsReturnedEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
// }
//
// // 记录成功的退货单号
// estimateSuccessfullyDividendsOrders[dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber] = dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber
//
// // 统计生成的预算单数量
// countDividendsEstimate = countDividendsEstimate + 1
//
// dividendsEstimate = &domain.DividendsEstimate{
// DividendsEstimateId: 0,
// DividendsAccountStatus: domain.TO_BE_ACCOUNT,
// DividendsAmount: dividendsReturnedEstimateDetail.DividendsAmount,
// DividendsEstimateOrderNumber: dividendsEstimateOrderNumber,
// DividendsEstimateTime: time.Now(),
// DividendsParticipateType: dividendsReturnedEstimateDetail.DividendsParticipateType,
// DividendsType: domain.RETURN_WRITE_OFF,
// DividendsTypeName: "退货冲销",
// OrderOrReturnedOrderNum: orderGood.DividendsReturnedOrderNumber,
// CooperationContractNumber: orderGood.CooperationContractNumber,
// DividendsUser: dividendsReturnedEstimateDetail.DividendsUser,
// DividendsPercentage: dividendsReturnedEstimateDetail.DividendsPercentage,
// DividendsStage: dividendsReturnedEstimateDetail.DividendsStage,
// Org: organization,
// Company: company,
// Operator: operator,
// OperateTime: time.Time{},
// IsCanceled: false,
// CreatedAt: time.Now(),
// DeletedAt: time.Time{},
// UpdatedAt: time.Time{},
// OrderGoodId: orderGood.OrderGoodId,
// OrderGoodAmount: orderGood.OrderGoodAmount,
// PaymentStatus: int32(1),
// CooperationContractUndertakerId: dividendsReturnedEstimateDetail.CooperationContractUndertakerId,
// }
//
// dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
// } else {
// // 记录失败的退货单号和原因
// estimateFailedDividendsOrders[dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber] = dividendsReturnedEstimateDetail.Reason
// }
// }
// }
// }
//}
if dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -918,14 +1003,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
}
}
log.Logger.Info("分红订单", map[string]interface{}{
"dividendsOrderNumbers": dividendsOrderNumbers,
})
log.Logger.Info("分红退货单", map[string]interface{}{
"dividendsReturnedOrderNumbers": dividendsReturnedOrderNumbers,
})
// 查找分红订单
if len(dividendsOrderNumbers) > 0 {
if countDividendsOrdersFound, dividendsOrdersFound, err := dividendsOrderRepository.Find(map[string]interface{}{
... ...
... ... @@ -5,8 +5,8 @@ import "os"
const SERVICE_NAME = "allied-creation-cooperation"
// LOG_TYPE 日志相关设置
var LOG_TYPE = "console" // file, console, es
var LOG_FRAMEWORK = "logrus" // beego logrus
var LOG_TYPE = "console" // file, console, es
var LOG_FRAMEWORK = "beego" // beego logrus
var LOG_LEVEL = "debug"
var LOG_FILE = "app.log"
var LOG_PREFIX = "[allied-creation-cooperation]"
... ...
... ... @@ -17,6 +17,9 @@ type DividendsEstimateDetail struct {
IsSuccessfully bool `json:"isSuccessfully"` // 是否预算成功
Reason string `json:"reason"` // 错误原因
CooperationContractUndertakerId int64 `json:"cooperationContractUndertakerId"` // 承接人记录ID
CooperationContractNumber string `json:"cooperationContractNumber"`
OrderGoodId int64 `json:"orderGoodId"`
OrderGoodAmount float64 `json:"orderGoodAmount"`
}
// GenerateSpecificDividendsEstimateNumber 批量生成自定义分红预算单号
... ...
... ... @@ -97,26 +97,6 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
}
}
// 判断共创项目是否存在
//if _, ok := cooperationProjectsMap[cooperationContract.CooperationProjectNumber]; !ok {
// var orderNumber string
// if orderGood.DividendsOrderNumber != "" {
// orderNumber = orderGood.DividendsOrderNumber
// } else {
// orderNumber = orderGood.DividendsReturnedOrderNumber
// }
// dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
// DividendsUser: nil,
// DividendsParticipateType: 0,
// DividendsStage: 0,
// DividendsAmount: 0,
// OrderOrReturnedOrderNumber: orderNumber,
// IsSuccessfully: false,
// Reason: "共创项目" + cooperationContract.CooperationProjectNumber + "已结束或不存在",
// })
// continue
//}
if orderGood.DividendsOrderNumber != "" { // 获取分红订单
// 获取分红订单
dividendsOrder, err2 := dividendsOrderRepository.FindOne(map[string]interface{}{
... ... @@ -199,6 +179,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
IsSuccessfully: true,
CooperationContractUndertakerId: undertaker.UndertakerId,
DividendsPercentage: dividendsIncentivesRuleMatched.DividendsIncentivesPercentage,
CooperationContractNumber: orderGood.CooperationContractNumber,
OrderGoodId: orderGood.OrderGoodId,
OrderGoodAmount: orderGood.OrderGoodAmount,
})
}
// 添加推荐人分红预算信息详情
... ... @@ -226,6 +209,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
IsSuccessfully: true,
CooperationContractUndertakerId: undertaker.UndertakerId,
DividendsPercentage: dividendsIncentivesRuleMatched.ReferrerPercentage,
CooperationContractNumber: orderGood.CooperationContractNumber,
OrderGoodId: orderGood.OrderGoodId,
OrderGoodAmount: orderGood.OrderGoodAmount,
})
}
}
... ... @@ -254,6 +240,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
IsSuccessfully: true,
CooperationContractUndertakerId: undertaker.UndertakerId,
DividendsPercentage: dividendsIncentivesRuleMatched.SalesmanPercentage,
CooperationContractNumber: orderGood.CooperationContractNumber,
OrderGoodId: orderGood.OrderGoodId,
OrderGoodAmount: orderGood.OrderGoodAmount,
})
}
}
... ... @@ -337,6 +326,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
IsSuccessfully: true,
CooperationContractUndertakerId: undertaker.UndertakerId,
DividendsPercentage: dividendsIncentivesRuleMatched.DividendsIncentivesPercentage,
CooperationContractNumber: orderGood.CooperationContractNumber,
OrderGoodId: orderGood.OrderGoodId,
OrderGoodAmount: orderGood.OrderGoodAmount,
})
}
... ... @@ -365,6 +357,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
IsSuccessfully: true,
CooperationContractUndertakerId: undertaker.UndertakerId,
DividendsPercentage: dividendsIncentivesRuleMatched.ReferrerPercentage,
CooperationContractNumber: orderGood.CooperationContractNumber,
OrderGoodId: orderGood.OrderGoodId,
OrderGoodAmount: orderGood.OrderGoodAmount,
})
}
}
... ... @@ -394,6 +389,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
IsSuccessfully: true,
CooperationContractUndertakerId: undertaker.UndertakerId,
DividendsPercentage: dividendsIncentivesRuleMatched.SalesmanPercentage,
CooperationContractNumber: orderGood.CooperationContractNumber,
OrderGoodId: orderGood.OrderGoodId,
OrderGoodAmount: orderGood.OrderGoodAmount,
})
}
}
... ...
... ... @@ -68,10 +68,9 @@ func (hook SqlGeneratePrintHook) AfterQuery(c context.Context, q *pg.QueryEvent)
}
if constant.LOG_FRAMEWORK == "logrus" {
rawlog.Println(string(sqlStr))
} else {
//log.Logger.Debug(string(sqlStr))
}
//else {
// log.Logger.Debug(string(sqlStr))
//}
return nil
}
... ...
... ... @@ -223,15 +223,16 @@ func (repository *DividendsEstimateRepository) SaveMany(dividendsEstimates []*do
if _, err := tx.Model(&dividendsEstimateModels).Insert(); err != nil {
return nil, err
}
var dividendsEstimatesSaved []*domain.DividendsEstimate
for _, dividendsEstimateModel := range dividendsEstimateModels {
if dividendsEstimate, err := transform.TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel); err != nil {
return dividendsEstimates, err
} else {
dividendsEstimatesSaved = append(dividendsEstimatesSaved, dividendsEstimate)
}
}
return dividendsEstimatesSaved, nil
//var dividendsEstimatesSaved []*domain.DividendsEstimate
//for _, dividendsEstimateModel := range dividendsEstimateModels {
// if dividendsEstimate, err := transform.TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel); err != nil {
// return dividendsEstimates, err
// } else {
// dividendsEstimatesSaved = append(dividendsEstimatesSaved, dividendsEstimate)
// }
//}
//return dividendsEstimatesSaved, nil
return dividendsEstimates, nil
}
return nil, nil
}
... ...
... ... @@ -50,7 +50,8 @@ func (logger *BeegoLog) Debug(msg string, appends ...map[string]interface{}) {
logs.Debug(msg, make(map[string]interface{}, 0))
} else {
var out bytes.Buffer
err := json.Indent(&out, appendsJson, "", " ")
//err := json.Indent(&out, appendsJson, "", " ")
err := json.Compact(&out, appendsJson)
if err != nil {
fmt.Println(msg)
return
... ... @@ -65,7 +66,8 @@ func (logger *BeegoLog) Info(msg string, appends ...map[string]interface{}) {
logs.Info(msg, make(map[string]interface{}, 0))
} else {
var out bytes.Buffer
err := json.Indent(&out, appendsJson, "", " ")
//err := json.Indent(&out, appendsJson, "", " ")
err := json.Compact(&out, appendsJson)
if err != nil {
fmt.Println(msg)
return
... ...