作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !6
@@ -262,6 +262,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -262,6 +262,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
262 SalesmanPercentage: dividendsIncentivesRule.SalesmanPercentage, 262 SalesmanPercentage: dividendsIncentivesRule.SalesmanPercentage,
263 DividendsIncentivesPercentage: dividendsIncentivesRule.DividendsIncentivesPercentage, 263 DividendsIncentivesPercentage: dividendsIncentivesRule.DividendsIncentivesPercentage,
264 DividendsIncentivesStage: dividendsIncentivesRule.DividendsIncentivesStage, 264 DividendsIncentivesStage: dividendsIncentivesRule.DividendsIncentivesStage,
  265 + DividendsIncentivesStageCN: utils.NumberToCNNumber(int(dividendsIncentivesRule.DividendsIncentivesStage)),
265 DividendsIncentivesStageEnd: dividendsIncentivesRule.DividendsIncentivesStageEnd, 266 DividendsIncentivesStageEnd: dividendsIncentivesRule.DividendsIncentivesStageEnd,
266 DividendsIncentivesStageStart: dividendsIncentivesRule.DividendsIncentivesStageStart, 267 DividendsIncentivesStageStart: dividendsIncentivesRule.DividendsIncentivesStageStart,
267 Org: organization, 268 Org: organization,
@@ -281,6 +282,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -281,6 +282,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
281 CooperationContractNumber: contractNumber, 282 CooperationContractNumber: contractNumber,
282 MoneyIncentivesAmount: moneyIncentivesRule.MoneyIncentivesAmount, 283 MoneyIncentivesAmount: moneyIncentivesRule.MoneyIncentivesAmount,
283 MoneyIncentivesStage: moneyIncentivesRule.MoneyIncentivesStage, 284 MoneyIncentivesStage: moneyIncentivesRule.MoneyIncentivesStage,
  285 + MoneyIncentivesStageCN: utils.NumberToCNNumber(int(moneyIncentivesRule.MoneyIncentivesStage)),
284 MoneyIncentivesStageEnd: moneyIncentivesRule.MoneyIncentivesStageEnd, 286 MoneyIncentivesStageEnd: moneyIncentivesRule.MoneyIncentivesStageEnd,
285 MoneyIncentivesStageStart: moneyIncentivesRule.MoneyIncentivesStageStart, 287 MoneyIncentivesStageStart: moneyIncentivesRule.MoneyIncentivesStageStart,
286 MoneyIncentivesTime: moneyIncentivesRule.MoneyIncentivesTime, 288 MoneyIncentivesTime: moneyIncentivesRule.MoneyIncentivesTime,
@@ -1117,6 +1119,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1117,6 +1119,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1117 SalesmanPercentage: dividendsIncentivesRule.SalesmanPercentage, 1119 SalesmanPercentage: dividendsIncentivesRule.SalesmanPercentage,
1118 DividendsIncentivesPercentage: dividendsIncentivesRule.DividendsIncentivesPercentage, 1120 DividendsIncentivesPercentage: dividendsIncentivesRule.DividendsIncentivesPercentage,
1119 DividendsIncentivesStage: dividendsIncentivesRule.DividendsIncentivesStage, 1121 DividendsIncentivesStage: dividendsIncentivesRule.DividendsIncentivesStage,
  1122 + DividendsIncentivesStageCN: utils.NumberToCNNumber(int(dividendsIncentivesRule.DividendsIncentivesStage)),
1120 DividendsIncentivesStageEnd: dividendsIncentivesRule.DividendsIncentivesStageEnd, 1123 DividendsIncentivesStageEnd: dividendsIncentivesRule.DividendsIncentivesStageEnd,
1121 DividendsIncentivesStageStart: dividendsIncentivesRule.DividendsIncentivesStageStart, 1124 DividendsIncentivesStageStart: dividendsIncentivesRule.DividendsIncentivesStageStart,
1122 Org: organization, 1125 Org: organization,
@@ -1143,6 +1146,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1143,6 +1146,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1143 CooperationContractNumber: cooperationContract.CooperationContractNumber, 1146 CooperationContractNumber: cooperationContract.CooperationContractNumber,
1144 MoneyIncentivesAmount: moneyIncentivesRule.MoneyIncentivesAmount, 1147 MoneyIncentivesAmount: moneyIncentivesRule.MoneyIncentivesAmount,
1145 MoneyIncentivesStage: moneyIncentivesRule.MoneyIncentivesStage, 1148 MoneyIncentivesStage: moneyIncentivesRule.MoneyIncentivesStage,
  1149 + MoneyIncentivesStageCN: utils.NumberToCNNumber(int(moneyIncentivesRule.MoneyIncentivesStage)),
1146 MoneyIncentivesStageEnd: moneyIncentivesRule.MoneyIncentivesStageEnd, 1150 MoneyIncentivesStageEnd: moneyIncentivesRule.MoneyIncentivesStageEnd,
1147 MoneyIncentivesStageStart: moneyIncentivesRule.MoneyIncentivesStageStart, 1151 MoneyIncentivesStageStart: moneyIncentivesRule.MoneyIncentivesStageStart,
1148 MoneyIncentivesTime: moneyIncentivesRule.MoneyIncentivesTime, 1152 MoneyIncentivesTime: moneyIncentivesRule.MoneyIncentivesTime,
@@ -175,6 +175,8 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro @@ -175,6 +175,8 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
175 "orgId": createCooperationProjectCommand.OrgId, 175 "orgId": createCooperationProjectCommand.OrgId,
176 "cooperationProjectNumber": projectNumber, 176 "cooperationProjectNumber": projectNumber,
177 }) 177 })
  178 + // TODO 校验共创项目名称是否唯一
  179 +
178 if !numberAvailable { 180 if !numberAvailable {
179 return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增共创项目异常") 181 return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增共创项目异常")
180 } 182 }
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,
@@ -10,7 +10,7 @@ type DividendsReturnedOrder struct { @@ -10,7 +10,7 @@ type DividendsReturnedOrder struct {
10 // 分红退货单记录ID 10 // 分红退货单记录ID
11 DividendsReturnedOrderId int64 `comment:"分红退货单记录ID" pg:",pk"` 11 DividendsReturnedOrderId int64 `comment:"分红退货单记录ID" pg:",pk"`
12 // 分红退货单号 12 // 分红退货单号
13 - DividendsReturnedOrderNumber string `comment:"分红退货单号"` 13 + DividendsReturnedOrderNumber string `comment:"分红退货单号" pg:",unique"`
14 // 退货金额 14 // 退货金额
15 DividendsReturnedOrderRefund float64 `comment:"退货金额"` 15 DividendsReturnedOrderRefund float64 `comment:"退货金额"`
16 // 源单号(原始订单号) 16 // 源单号(原始订单号)
@@ -234,6 +234,8 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string @@ -234,6 +234,8 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
234 if cooperationProjectName, ok := queryOptions["cooperationProjectName"]; ok && cooperationProjectName != "" { 234 if cooperationProjectName, ok := queryOptions["cooperationProjectName"]; ok && cooperationProjectName != "" {
235 query.Join("LEFT JOIN cooperation_projects AS a"). 235 query.Join("LEFT JOIN cooperation_projects AS a").
236 JoinOn("a.cooperation_project_number = cooperation_application.cooperation_project_number"). 236 JoinOn("a.cooperation_project_number = cooperation_application.cooperation_project_number").
  237 + JoinOn("a.company->>'companyId' = cooperation_application.company->>'companyId'").
  238 + JoinOn("a.org->>'orgId' = cooperation_application.org->>'orgId'").
237 Where("a.cooperation_project_name like ?", fmt.Sprintf("%%%s%%", cooperationProjectName)) 239 Where("a.cooperation_project_name like ?", fmt.Sprintf("%%%s%%", cooperationProjectName))
238 } 240 }
239 if applicantName, ok := queryOptions["applicantName"]; ok && applicantName != "" { 241 if applicantName, ok := queryOptions["applicantName"]; ok && applicantName != "" {
@@ -254,14 +256,14 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string @@ -254,14 +256,14 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
254 } 256 }
255 } 257 }
256 if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { 258 if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
257 - query.Where("company->>'companyId' = '?'", companyId) 259 + query.Where("cooperation_application.company->>'companyId' = '?'", companyId)
258 } 260 }
259 if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { 261 if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
260 - query.Where("org->>'orgId' = '?'", orgId) 262 + query.Where("cooperation_application.org->>'orgId' = '?'", orgId)
261 } 263 }
262 if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 { 264 if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
263 newOrgIds := utils.SliceItoa(orgIds.([]int64)) 265 newOrgIds := utils.SliceItoa(orgIds.([]int64))
264 - query.Where("org->>'orgId' in (?)", pg.In(newOrgIds)) 266 + query.Where("cooperation_application.org->>'orgId' in (?)", pg.In(newOrgIds))
265 } 267 }
266 offsetLimitFlag := true 268 offsetLimitFlag := true
267 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 269 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
@@ -271,7 +273,7 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string @@ -271,7 +273,7 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
271 query.SetOffsetAndLimit(20) 273 query.SetOffsetAndLimit(20)
272 } 274 }
273 275
274 - query.SetOrderDirect("cooperation_application_id", "DESC") 276 + query.SetOrderDirect("created_at", "DESC")
275 if count, err := query.SelectAndCount(); err != nil { 277 if count, err := query.SelectAndCount(); err != nil {
276 return 0, cooperationApplications, err 278 return 0, cooperationApplications, err
277 } else { 279 } else {
@@ -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