作者 yangfu

企业共创用户列表修改

1 package domain 1 package domain
2 2
  3 +import "time"
  4 +
3 // User 用户第三方服务防腐模型 5 // User 用户第三方服务防腐模型
4 type User struct { 6 type User struct {
5 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 7 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
@@ -26,4 +28,6 @@ type User struct { @@ -26,4 +28,6 @@ type User struct {
26 Status int32 `json:"status"` 28 Status int32 `json:"status"`
27 // 用户关联公司信息 29 // 用户关联公司信息
28 Company *Company `json:"company,omitempty"` 30 Company *Company `json:"company,omitempty"`
  31 + // 创建时间
  32 + CreatedAt time.Time `json:"createdAt,omitempty"`
29 } 33 }
@@ -100,7 +100,7 @@ func (dao *CreditAccountDao) CooperationUsersDividendsStatistics(queryOptions ma @@ -100,7 +100,7 @@ func (dao *CreditAccountDao) CooperationUsersDividendsStatistics(queryOptions ma
100 query.ColumnExpr(`0 cooperation_time`) 100 query.ColumnExpr(`0 cooperation_time`)
101 query.ColumnExpr(`sum(good_amount_count) dividends_order_amount`) 101 query.ColumnExpr(`sum(good_amount_count) dividends_order_amount`)
102 query.ColumnExpr(`sum(settlement_amount) divides_amount`) 102 query.ColumnExpr(`sum(settlement_amount) divides_amount`)
103 - query.ColumnExpr(`sum((case when payment_status = 1 then actually_paid_amount else 0 end)) actually_paid_amount`) 103 + query.ColumnExpr(`sum((case when payment_status = 2 then actually_paid_amount else 0 end)) actually_paid_amount`)
104 query.ColumnExpr(`max(participator->>'userId') user_id`) 104 query.ColumnExpr(`max(participator->>'userId') user_id`)
105 query.ColumnExpr(`max(participator#>>'{userInfo,userName}') user_name`) 105 query.ColumnExpr(`max(participator#>>'{userInfo,userName}') user_name`)
106 if _, ok := queryOptions["beginTime"]; ok && !queryOptions["beginTime"].(time.Time).IsZero() { 106 if _, ok := queryOptions["beginTime"]; ok && !queryOptions["beginTime"].(time.Time).IsZero() {
@@ -148,7 +148,7 @@ func (dao *CreditAccountDao) CooperationCompanyDividendsStatistics(queryOptions @@ -148,7 +148,7 @@ func (dao *CreditAccountDao) CooperationCompanyDividendsStatistics(queryOptions
148 query.ColumnExpr(`0 cooperation_time`) 148 query.ColumnExpr(`0 cooperation_time`)
149 query.ColumnExpr(`sum(good_amount_count) dividends_order_amount`) 149 query.ColumnExpr(`sum(good_amount_count) dividends_order_amount`)
150 query.ColumnExpr(`sum(settlement_amount) divides_amount`) 150 query.ColumnExpr(`sum(settlement_amount) divides_amount`)
151 - query.ColumnExpr(`sum((case when payment_status = 1 then actually_paid_amount else 0 end)) actually_paid_amount`) 151 + query.ColumnExpr(`sum((case when payment_status = 2 then actually_paid_amount else 0 end)) actually_paid_amount`)
152 query.ColumnExpr(`max(org->>'orgId') org_id`) 152 query.ColumnExpr(`max(org->>'orgId') org_id`)
153 query.ColumnExpr(`max(org->>'orgName') org_name`) 153 query.ColumnExpr(`max(org->>'orgName') org_name`)
154 if _, ok := queryOptions["beginTime"]; ok { 154 if _, ok := queryOptions["beginTime"]; ok {
@@ -72,7 +72,8 @@ func (dao *OrderGoodDao) CooperationUserModeStatistics(queryOptions map[string]i @@ -72,7 +72,8 @@ func (dao *OrderGoodDao) CooperationUserModeStatistics(queryOptions map[string]i
72 query.Where(fmt.Sprintf(`credit_account.participator->>'userId'='%v' `, v)) 72 query.Where(fmt.Sprintf(`credit_account.participator->>'userId'='%v' `, v))
73 } 73 }
74 if v, ok := queryOptions["orgId"]; ok && v.(int64) > 0 { 74 if v, ok := queryOptions["orgId"]; ok && v.(int64) > 0 {
75 - query.Where(fmt.Sprintf(` org->>'orgId'= '%v'`, v)) 75 + query.Where(fmt.Sprintf(` "credit_account".org->>'orgId'= '%v'`, v))
  76 + query.Where(fmt.Sprintf(` a.org->>'orgId'= '%v'`, v))
76 } 77 }
77 query.Where("credit_account.deleted_at is null") 78 query.Where("credit_account.deleted_at is null")
78 query.Group("cooperation_mode_number") 79 query.Group("cooperation_mode_number")
@@ -208,13 +208,16 @@ func (ptr *CooperationStatisticsService) CompanyCooperationUsersStatistics(query @@ -208,13 +208,16 @@ func (ptr *CooperationStatisticsService) CompanyCooperationUsersStatistics(query
208 return nil, err 208 return nil, err
209 } 209 }
210 210
  211 + userService, _ := NewUserService()
  212 +
211 var retMap = make([]interface{}, 0) 213 var retMap = make([]interface{}, 0)
212 for i := range responses { 214 for i := range responses {
213 responses[i].CooperationTime = time.Now().Unix() * 1000 215 responses[i].CooperationTime = time.Now().Unix() * 1000
214 unPaidAmount := responses[i].DividesAmount - responses[i].ActuallyPaidAmount 216 unPaidAmount := responses[i].DividesAmount - responses[i].ActuallyPaidAmount
215 - retMap = append(retMap, map[string]interface{}{ 217 +
  218 + item := map[string]interface{}{
216 "dividendsOrderAmount": responses[i].DividendsOrderAmount, 219 "dividendsOrderAmount": responses[i].DividendsOrderAmount,
217 - "dividesAmount": responses[i].DividesAmount, 220 + "actuallyPaidAmount": responses[i].ActuallyPaidAmount,
218 "unPaidAmount": unPaidAmount, 221 "unPaidAmount": unPaidAmount,
219 "cooperationTime": time.Now().Unix() * 1000, 222 "cooperationTime": time.Now().Unix() * 1000,
220 "participator": map[string]interface{}{ 223 "participator": map[string]interface{}{
@@ -223,7 +226,11 @@ func (ptr *CooperationStatisticsService) CompanyCooperationUsersStatistics(query @@ -223,7 +226,11 @@ func (ptr *CooperationStatisticsService) CompanyCooperationUsersStatistics(query
223 "userName": responses[i].UserName, 226 "userName": responses[i].UserName,
224 }, 227 },
225 }, 228 },
226 - }) 229 + }
  230 + if user, e := userService.UserFrom(0, 0, responses[i].UserId); e == nil && user != nil {
  231 + item["cooperationTime"] = user.CreatedAt.Unix() * 1000
  232 + }
  233 + retMap = append(retMap, item)
227 } 234 }
228 235
229 return retMap, nil 236 return retMap, nil
@@ -245,8 +252,8 @@ type usersStatisticsResponse struct { @@ -245,8 +252,8 @@ type usersStatisticsResponse struct {
245 func (ptr *CooperationStatisticsService) CooperationUserModeStatistics(queryOptions map[string]interface{}) (interface{}, error) { 252 func (ptr *CooperationStatisticsService) CooperationUserModeStatistics(queryOptions map[string]interface{}) (interface{}, error) {
246 // 参数验证 253 // 参数验证
247 var request = struct { 254 var request = struct {
248 - UserId int64 `json:"offset" valid:"Required"`  
249 - //OrgId int64 `json:"orgId" valid:"Required"` 255 + UserId int64 `json:"userId" valid:"Required"`
  256 + OrgId int64 `json:"orgId" valid:"Required"`
250 }{} 257 }{}
251 if err := LoadQueryObject(queryOptions, &request); err != nil { 258 if err := LoadQueryObject(queryOptions, &request); err != nil {
252 return nil, err 259 return nil, err
@@ -270,7 +277,7 @@ func (ptr *CooperationStatisticsService) CooperationUserModeStatistics(queryOpti @@ -270,7 +277,7 @@ func (ptr *CooperationStatisticsService) CooperationUserModeStatistics(queryOpti
270 } 277 }
271 278
272 cooperationModeRepository, _ := repository.NewCooperationModeRepository(ptr.transactionContext) 279 cooperationModeRepository, _ := repository.NewCooperationModeRepository(ptr.transactionContext)
273 - _, cooperModes, err := cooperationModeRepository.Find(map[string]interface{}{"cooperationModeNumbers": modeNumbers}) 280 + _, cooperModes, err := cooperationModeRepository.Find(map[string]interface{}{"cooperationModeNumbers": modeNumbers, "orgId": request.OrgId})
274 if err != nil { 281 if err != nil {
275 return nil, err 282 return nil, err
276 } 283 }
@@ -284,7 +291,7 @@ func (ptr *CooperationStatisticsService) CooperationUserModeStatistics(queryOpti @@ -284,7 +291,7 @@ func (ptr *CooperationStatisticsService) CooperationUserModeStatistics(queryOpti
284 totalDividendAmount += modeStatistics.SettlementAmount 291 totalDividendAmount += modeStatistics.SettlementAmount
285 dividendsExpenseByTypes = append(dividendsExpenseByTypes, map[string]interface{}{ 292 dividendsExpenseByTypes = append(dividendsExpenseByTypes, map[string]interface{}{
286 "dividendsTypeName": m.CooperationModeName + "分红支出", 293 "dividendsTypeName": m.CooperationModeName + "分红支出",
287 - "dividendsExpense": modeStatistics.SettlementAmount, 294 + "dividendsExpense": modeStatistics.SettlementAmount, //实际已支付金额
288 }) 295 })
289 orderAmountByTypes = append(orderAmountByTypes, map[string]interface{}{ 296 orderAmountByTypes = append(orderAmountByTypes, map[string]interface{}{
290 "orderAmount": modeStatistics.OrderAmount, 297 "orderAmount": modeStatistics.OrderAmount,
@@ -70,6 +70,8 @@ type UserDetail struct { @@ -70,6 +70,8 @@ type UserDetail struct {
70 DeletedAt time.Time `json:"deletedAt"` 70 DeletedAt time.Time `json:"deletedAt"`
71 OrgName string `json:"orgName"` 71 OrgName string `json:"orgName"`
72 } `json:"userOrg"` 72 } `json:"userOrg"`
  73 + // 创建时间
  74 + CreatedAt time.Time `json:"createdAt,omitempty"`
73 } 75 }
74 76
75 func (translator *UserTranslator) ToRelevantFromRepresentation(user *UserDetail) (*domain.Relevant, error) { 77 func (translator *UserTranslator) ToRelevantFromRepresentation(user *UserDetail) (*domain.Relevant, error) {
@@ -397,6 +399,7 @@ func (translator *UserTranslator) ToUserFromRepresentation(user *UserDetail) (*d @@ -397,6 +399,7 @@ func (translator *UserTranslator) ToUserFromRepresentation(user *UserDetail) (*d
397 CompanyLogo: "", 399 CompanyLogo: "",
398 CompanyName: user.Company.CompanyName, 400 CompanyName: user.Company.CompanyName,
399 }, 401 },
  402 + CreatedAt: user.CreatedAt,
400 }, nil 403 }, nil
401 } 404 }
402 405