作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !6
... ... @@ -262,6 +262,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
SalesmanPercentage: dividendsIncentivesRule.SalesmanPercentage,
DividendsIncentivesPercentage: dividendsIncentivesRule.DividendsIncentivesPercentage,
DividendsIncentivesStage: dividendsIncentivesRule.DividendsIncentivesStage,
DividendsIncentivesStageCN: utils.NumberToCNNumber(int(dividendsIncentivesRule.DividendsIncentivesStage)),
DividendsIncentivesStageEnd: dividendsIncentivesRule.DividendsIncentivesStageEnd,
DividendsIncentivesStageStart: dividendsIncentivesRule.DividendsIncentivesStageStart,
Org: organization,
... ... @@ -281,6 +282,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
CooperationContractNumber: contractNumber,
MoneyIncentivesAmount: moneyIncentivesRule.MoneyIncentivesAmount,
MoneyIncentivesStage: moneyIncentivesRule.MoneyIncentivesStage,
MoneyIncentivesStageCN: utils.NumberToCNNumber(int(moneyIncentivesRule.MoneyIncentivesStage)),
MoneyIncentivesStageEnd: moneyIncentivesRule.MoneyIncentivesStageEnd,
MoneyIncentivesStageStart: moneyIncentivesRule.MoneyIncentivesStageStart,
MoneyIncentivesTime: moneyIncentivesRule.MoneyIncentivesTime,
... ... @@ -1117,6 +1119,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
SalesmanPercentage: dividendsIncentivesRule.SalesmanPercentage,
DividendsIncentivesPercentage: dividendsIncentivesRule.DividendsIncentivesPercentage,
DividendsIncentivesStage: dividendsIncentivesRule.DividendsIncentivesStage,
DividendsIncentivesStageCN: utils.NumberToCNNumber(int(dividendsIncentivesRule.DividendsIncentivesStage)),
DividendsIncentivesStageEnd: dividendsIncentivesRule.DividendsIncentivesStageEnd,
DividendsIncentivesStageStart: dividendsIncentivesRule.DividendsIncentivesStageStart,
Org: organization,
... ... @@ -1143,6 +1146,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
CooperationContractNumber: cooperationContract.CooperationContractNumber,
MoneyIncentivesAmount: moneyIncentivesRule.MoneyIncentivesAmount,
MoneyIncentivesStage: moneyIncentivesRule.MoneyIncentivesStage,
MoneyIncentivesStageCN: utils.NumberToCNNumber(int(moneyIncentivesRule.MoneyIncentivesStage)),
MoneyIncentivesStageEnd: moneyIncentivesRule.MoneyIncentivesStageEnd,
MoneyIncentivesStageStart: moneyIncentivesRule.MoneyIncentivesStageStart,
MoneyIncentivesTime: moneyIncentivesRule.MoneyIncentivesTime,
... ...
... ... @@ -175,6 +175,8 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
"orgId": createCooperationProjectCommand.OrgId,
"cooperationProjectNumber": projectNumber,
})
// TODO 校验共创项目名称是否唯一
if !numberAvailable {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增共创项目异常")
}
... ...
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,
... ...
... ... @@ -10,7 +10,7 @@ type DividendsReturnedOrder struct {
// 分红退货单记录ID
DividendsReturnedOrderId int64 `comment:"分红退货单记录ID" pg:",pk"`
// 分红退货单号
DividendsReturnedOrderNumber string `comment:"分红退货单号"`
DividendsReturnedOrderNumber string `comment:"分红退货单号" pg:",unique"`
// 退货金额
DividendsReturnedOrderRefund float64 `comment:"退货金额"`
// 源单号(原始订单号)
... ...
... ... @@ -234,6 +234,8 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
if cooperationProjectName, ok := queryOptions["cooperationProjectName"]; ok && cooperationProjectName != "" {
query.Join("LEFT JOIN cooperation_projects AS a").
JoinOn("a.cooperation_project_number = cooperation_application.cooperation_project_number").
JoinOn("a.company->>'companyId' = cooperation_application.company->>'companyId'").
JoinOn("a.org->>'orgId' = cooperation_application.org->>'orgId'").
Where("a.cooperation_project_name like ?", fmt.Sprintf("%%%s%%", cooperationProjectName))
}
if applicantName, ok := queryOptions["applicantName"]; ok && applicantName != "" {
... ... @@ -254,14 +256,14 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
}
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
query.Where("cooperation_application.company->>'companyId' = '?'", companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
query.Where("cooperation_application.org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
newOrgIds := utils.SliceItoa(orgIds.([]int64))
query.Where("org->>'orgId' in (?)", pg.In(newOrgIds))
query.Where("cooperation_application.org->>'orgId' in (?)", pg.In(newOrgIds))
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
... ... @@ -271,7 +273,7 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
query.SetOffsetAndLimit(20)
}
query.SetOrderDirect("cooperation_application_id", "DESC")
query.SetOrderDirect("created_at", "DESC")
if count, err := query.SelectAndCount(); err != nil {
return 0, cooperationApplications, err
} else {
... ...
... ... @@ -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
}
... ...