...
|
...
|
@@ -47,6 +47,8 @@ const ( |
|
|
PersonCooperationProjectSharedInfo = "PersonCooperationProjectSharedInfo"
|
|
|
// 个人 - 共创项目共享信息数据 - 附件
|
|
|
PersonCooperationProjectSharedInfoAttachment = "PersonCooperationProjectSharedInfoAttachment"
|
|
|
// 个人 - 共创企业
|
|
|
PersonCooperationCompany = "PersonCooperationCompany"
|
|
|
|
|
|
// 账期结算单统计
|
|
|
CreditAccountStatistics = "CreditAccountStatistics"
|
...
|
...
|
@@ -107,6 +109,18 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma |
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
// 1.1 个人返回合约对应的项目
|
|
|
|
|
|
var mapProject = make(map[int64]*domain.CooperationProject)
|
|
|
var projectIds = domain.CooperationContractsToProjectIds(contracts)
|
|
|
if request.UserBaseId > 0 && len(projectIds) > 0 {
|
|
|
cooperationProjectRepository, _ := repository.NewCooperationProjectRepository(ptr.transactionContext)
|
|
|
mapProject, err = domain.CooperationProjectsToMap(map[string]interface{}{"cooperationProjectIds": projectIds}, cooperationProjectRepository.Find)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 2.根据合约查询分红预算
|
|
|
orderGoodDao, _ := dao.NewDividendsOrderDao(ptr.transactionContext)
|
|
|
dividendsEstimateDao, _ := dao.NewDividendsEstimateDao(ptr.transactionContext)
|
...
|
...
|
@@ -123,20 +137,12 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma |
|
|
}
|
|
|
resultItem.DividendsOrderAmount, _ = orderGoodDao.CalculateGoodOrderAmount(map[string]interface{}{"orgId": request.OrgId, "cooperationContractNumbers": []string{item.CooperationContractNumber}})
|
|
|
resultItem.DividendsAmount, _ = dividendsEstimateDao.CountDividendsEstimateDividendsAmount(map[string]interface{}{"orgId": request.OrgId, "userBaseId": request.UserBaseId, "cooperationContractNumbers": []string{item.CooperationContractNumber}})
|
|
|
|
|
|
if v, ok := mapProject[item.CooperationProjectId]; ok {
|
|
|
resultItem.Project = v.CloneSimple()
|
|
|
}
|
|
|
results = append(results, resultItem)
|
|
|
numbers = append(numbers, item.CooperationContractNumber)
|
|
|
}
|
|
|
//mapCreditAccount, err := ptr.getContractsCreditAccount(numbers)
|
|
|
//if err != nil {
|
|
|
// return nil, err
|
|
|
//}
|
|
|
//for i := range results {
|
|
|
// if v, ok := mapCreditAccount[results[i].CooperationContractNumber]; ok {
|
|
|
// results[i].DividendsAmount = v.SettlementAmount
|
|
|
// results[i].DividendsOrderAmount = v.GoodAmountCount
|
|
|
// }
|
|
|
//}
|
|
|
return results, nil
|
|
|
}
|
|
|
|
...
|
...
|
@@ -273,6 +279,8 @@ type searchContractDividendsResult struct { |
|
|
DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
|
|
|
// 创建时间
|
|
|
CreatedAt int64 `json:"createdAt"`
|
|
|
// 共创项目数据
|
|
|
Project interface{} `json:"project"`
|
|
|
}
|
|
|
|
|
|
/*1.2 分红合约详情*/
|
...
|
...
|
@@ -306,7 +314,7 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
res["cooperationContract"] = map[string]interface{}{
|
|
|
mapContract := map[string]interface{}{
|
|
|
"cooperationContractDescription": contract.CooperationContractDescription,
|
|
|
"cooperationContractId": contract.CooperationContractId,
|
|
|
"cooperationContractName": contract.CooperationContractName,
|
...
|
...
|
@@ -314,21 +322,36 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
|
|
"createdAt": contract.CreatedAt.Unix() * 1000,
|
|
|
"status": contract.Status,
|
|
|
}
|
|
|
if request.UserBaseId > 0 {
|
|
|
// 1.1.合约第一条合同的附件
|
|
|
undertakerRepository, _ := repository.NewCooperationContractUndertakerRepository(ptr.transactionContext)
|
|
|
_, undertakers, err := undertakerRepository.Find(map[string]interface{}{"cooperationContractId": contract.CooperationContractId, "userBaseId": request.UserBaseId, "companyId": contract.Company.CompanyId, "orgId": contract.Org.OrgId, "offsetLimit": false})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
for i := range undertakers {
|
|
|
if len(undertakers[i].Undertaker.ContractAttachment) > 0 && len(undertakers[i].Undertaker.ContractAttachment[0].Url) > 0 {
|
|
|
mapContract["contractAttachment"] = undertakers[i].Undertaker.ContractAttachment[0]
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
res["cooperationContract"] = mapContract
|
|
|
|
|
|
// 2.合约分红列表
|
|
|
creditAccountRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext)
|
|
|
dividendsEstimateRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext)
|
|
|
queryOptions["cooperationContractNumber"] = contract.CooperationContractNumber
|
|
|
queryOptions["orgId"] = contract.Org.OrgId
|
|
|
queryOptions["isCanceled"] = false
|
|
|
_, creditAccounts, err := creditAccountRepository.Find(queryOptions)
|
|
|
_, dividendsEstimates, err := dividendsEstimateRepository.Find(queryOptions)
|
|
|
if err != nil {
|
|
|
return res, err
|
|
|
}
|
|
|
|
|
|
// 3.取订单商品列表
|
|
|
var orderGoodIds []int64
|
|
|
for i := range creditAccounts {
|
|
|
a := creditAccounts[i]
|
|
|
for i := range dividendsEstimates {
|
|
|
a := dividendsEstimates[i]
|
|
|
orderGoodIds = append(orderGoodIds, a.OrderGoodId)
|
|
|
}
|
|
|
var mapOrderGoods = make(map[int64]*domain.OrderGood)
|
...
|
...
|
@@ -344,14 +367,14 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
|
|
}
|
|
|
|
|
|
var dividends = make([]interface{}, 0)
|
|
|
for i := range creditAccounts {
|
|
|
a := creditAccounts[i]
|
|
|
for i := range dividendsEstimates {
|
|
|
a := dividendsEstimates[i]
|
|
|
// 个人查看的时候只查看自己的分红明细
|
|
|
//if request.UserBaseId!=0 && a.DividendsUser.UserBaseId!=request.UserBaseId{
|
|
|
// continue
|
|
|
//}
|
|
|
item := map[string]interface{}{
|
|
|
"creditAccountId": a.DividendsEstimateId,
|
|
|
"dividendsEstimateId": a.DividendsEstimateId,
|
|
|
"orderGoodName": "",
|
|
|
"dividendsType": a.DividendsType,
|
|
|
"dividendsRatio": 0,
|
...
|
...
|
@@ -364,6 +387,7 @@ func (ptr *CooperationStatisticsService) GetContractDividends(queryOptions map[s |
|
|
"dividendsAccountStatus": a.DividendsAccountStatus,
|
|
|
"dividendsEstimateTime": a.CreatedAt.Unix() * 1000,
|
|
|
"orderOrReturnedOrderNum": a.DividendsEstimateOrderNumber,
|
|
|
"creditAccountId": a.CreditAccountId,
|
|
|
}
|
|
|
if a.PaymentStatus == 2 {
|
|
|
item["dividendsAccountStatus"] = 3
|
...
|
...
|
|