作者 yangfu

企业共创用户列表修改

package domain
import "time"
// User 用户第三方服务防腐模型
type User struct {
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
... ... @@ -26,4 +28,6 @@ type User struct {
Status int32 `json:"status"`
// 用户关联公司信息
Company *Company `json:"company,omitempty"`
// 创建时间
CreatedAt time.Time `json:"createdAt,omitempty"`
}
... ...
... ... @@ -100,7 +100,7 @@ func (dao *CreditAccountDao) CooperationUsersDividendsStatistics(queryOptions ma
query.ColumnExpr(`0 cooperation_time`)
query.ColumnExpr(`sum(good_amount_count) dividends_order_amount`)
query.ColumnExpr(`sum(settlement_amount) divides_amount`)
query.ColumnExpr(`sum((case when payment_status = 1 then actually_paid_amount else 0 end)) actually_paid_amount`)
query.ColumnExpr(`sum((case when payment_status = 2 then actually_paid_amount else 0 end)) actually_paid_amount`)
query.ColumnExpr(`max(participator->>'userId') user_id`)
query.ColumnExpr(`max(participator#>>'{userInfo,userName}') user_name`)
if _, ok := queryOptions["beginTime"]; ok && !queryOptions["beginTime"].(time.Time).IsZero() {
... ... @@ -148,7 +148,7 @@ func (dao *CreditAccountDao) CooperationCompanyDividendsStatistics(queryOptions
query.ColumnExpr(`0 cooperation_time`)
query.ColumnExpr(`sum(good_amount_count) dividends_order_amount`)
query.ColumnExpr(`sum(settlement_amount) divides_amount`)
query.ColumnExpr(`sum((case when payment_status = 1 then actually_paid_amount else 0 end)) actually_paid_amount`)
query.ColumnExpr(`sum((case when payment_status = 2 then actually_paid_amount else 0 end)) actually_paid_amount`)
query.ColumnExpr(`max(org->>'orgId') org_id`)
query.ColumnExpr(`max(org->>'orgName') org_name`)
if _, ok := queryOptions["beginTime"]; ok {
... ...
... ... @@ -72,7 +72,8 @@ func (dao *OrderGoodDao) CooperationUserModeStatistics(queryOptions map[string]i
query.Where(fmt.Sprintf(`credit_account.participator->>'userId'='%v' `, v))
}
if v, ok := queryOptions["orgId"]; ok && v.(int64) > 0 {
query.Where(fmt.Sprintf(` org->>'orgId'= '%v'`, v))
query.Where(fmt.Sprintf(` "credit_account".org->>'orgId'= '%v'`, v))
query.Where(fmt.Sprintf(` a.org->>'orgId'= '%v'`, v))
}
query.Where("credit_account.deleted_at is null")
query.Group("cooperation_mode_number")
... ...
... ... @@ -208,13 +208,16 @@ func (ptr *CooperationStatisticsService) CompanyCooperationUsersStatistics(query
return nil, err
}
userService, _ := NewUserService()
var retMap = make([]interface{}, 0)
for i := range responses {
responses[i].CooperationTime = time.Now().Unix() * 1000
unPaidAmount := responses[i].DividesAmount - responses[i].ActuallyPaidAmount
retMap = append(retMap, map[string]interface{}{
item := map[string]interface{}{
"dividendsOrderAmount": responses[i].DividendsOrderAmount,
"dividesAmount": responses[i].DividesAmount,
"actuallyPaidAmount": responses[i].ActuallyPaidAmount,
"unPaidAmount": unPaidAmount,
"cooperationTime": time.Now().Unix() * 1000,
"participator": map[string]interface{}{
... ... @@ -223,7 +226,11 @@ func (ptr *CooperationStatisticsService) CompanyCooperationUsersStatistics(query
"userName": responses[i].UserName,
},
},
})
}
if user, e := userService.UserFrom(0, 0, responses[i].UserId); e == nil && user != nil {
item["cooperationTime"] = user.CreatedAt.Unix() * 1000
}
retMap = append(retMap, item)
}
return retMap, nil
... ... @@ -245,8 +252,8 @@ type usersStatisticsResponse struct {
func (ptr *CooperationStatisticsService) CooperationUserModeStatistics(queryOptions map[string]interface{}) (interface{}, error) {
// 参数验证
var request = struct {
UserId int64 `json:"offset" valid:"Required"`
//OrgId int64 `json:"orgId" valid:"Required"`
UserId int64 `json:"userId" valid:"Required"`
OrgId int64 `json:"orgId" valid:"Required"`
}{}
if err := LoadQueryObject(queryOptions, &request); err != nil {
return nil, err
... ... @@ -270,7 +277,7 @@ func (ptr *CooperationStatisticsService) CooperationUserModeStatistics(queryOpti
}
cooperationModeRepository, _ := repository.NewCooperationModeRepository(ptr.transactionContext)
_, cooperModes, err := cooperationModeRepository.Find(map[string]interface{}{"cooperationModeNumbers": modeNumbers})
_, cooperModes, err := cooperationModeRepository.Find(map[string]interface{}{"cooperationModeNumbers": modeNumbers, "orgId": request.OrgId})
if err != nil {
return nil, err
}
... ... @@ -284,7 +291,7 @@ func (ptr *CooperationStatisticsService) CooperationUserModeStatistics(queryOpti
totalDividendAmount += modeStatistics.SettlementAmount
dividendsExpenseByTypes = append(dividendsExpenseByTypes, map[string]interface{}{
"dividendsTypeName": m.CooperationModeName + "分红支出",
"dividendsExpense": modeStatistics.SettlementAmount,
"dividendsExpense": modeStatistics.SettlementAmount, //实际已支付金额
})
orderAmountByTypes = append(orderAmountByTypes, map[string]interface{}{
"orderAmount": modeStatistics.OrderAmount,
... ...
... ... @@ -70,6 +70,8 @@ type UserDetail struct {
DeletedAt time.Time `json:"deletedAt"`
OrgName string `json:"orgName"`
} `json:"userOrg"`
// 创建时间
CreatedAt time.Time `json:"createdAt,omitempty"`
}
func (translator *UserTranslator) ToRelevantFromRepresentation(user *UserDetail) (*domain.Relevant, error) {
... ... @@ -397,6 +399,7 @@ func (translator *UserTranslator) ToUserFromRepresentation(user *UserDetail) (*d
CompanyLogo: "",
CompanyName: user.Company.CompanyName,
},
CreatedAt: user.CreatedAt,
}, nil
}
... ...