作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !8
... ... @@ -175,11 +175,20 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
"orgId": createCooperationProjectCommand.OrgId,
"cooperationProjectNumber": projectNumber,
})
// TODO 校验共创项目名称是否唯一
if !numberAvailable {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增共创项目异常")
}
// 校验共创项目名称是否唯一
nameAvailable, _ := cooperationProjectDao.CheckProjectNameAvailable(map[string]interface{}{
"companyId": createCooperationProjectCommand.CompanyId,
"orgId": createCooperationProjectCommand.OrgId,
"cooperationProjectName": createCooperationProjectCommand.CooperationProjectName,
})
if !nameAvailable {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "共创项目名称重复")
}
newCooperationProject := &domain.CooperationProject{
CooperationProjectNumber: projectNumber,
CooperationProjectName: createCooperationProjectCommand.CooperationProjectName,
... ... @@ -489,6 +498,16 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
operator = data
}
// 共创项目DAO初始化
var cooperationProjectDao *dao.CooperationProjectDao
if value, err := factory.CreateCooperationProjectDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
cooperationProjectDao = value
}
// 获取发起人
var sponsor *domain.User
// sponsorUid类型转换
... ... @@ -520,6 +539,18 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationProjectCommand.CooperationProjectId)))
}
// 校验共创项目名称是否唯一
if cooperationProject.CooperationProjectName != updateCooperationProjectCommand.CooperationProjectName {
nameAvailable, _ := cooperationProjectDao.CheckProjectNameAvailable(map[string]interface{}{
"companyId": updateCooperationProjectCommand.CompanyId,
"orgId": updateCooperationProjectCommand.OrgId,
"cooperationProjectName": updateCooperationProjectCommand.CooperationProjectName,
})
if !nameAvailable {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "共创项目名称重复")
}
}
applicantTypes := make(map[int32]interface{})
// 获取所有申请人
... ...
... ... @@ -104,6 +104,24 @@ func (dao *CooperationProjectDao) CheckProjectNumberAvailable(queryOptions map[s
return !ok, err
}
// CheckProjectNameAvailable 校验共创项目名称唯一
func (dao *CooperationProjectDao) CheckProjectNameAvailable(queryOptions map[string]interface{}) (bool, error) {
tx := dao.transactionContext.PgTx
var cooperationProjectModels []*models.CooperationProject
query := tx.Model(&cooperationProjectModels)
if cooperationProjectName, ok := queryOptions["cooperationProjectName"]; ok && cooperationProjectName != "" {
query = query.Where("cooperation_project_name = ?", cooperationProjectName)
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query = query.Where(`cooperation_project.company @> '{"companyId":"?"}'`, companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query = query.Where(`cooperation_project.org @> '{"orgId":"?"}'`, orgId)
}
ok, err := query.Exists()
return !ok, err
}
func NewCooperationProjectDao(transactionContext *pgTransaction.TransactionContext) (*CooperationProjectDao, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
... ...
... ... @@ -229,6 +229,12 @@ func (ptr *CooperationStatisticsService) CompanyCooperationUsersStatistics(query
}
if user, e := userService.UserFrom(0, 0, responses[i].UserId); e == nil && user != nil {
item["cooperationTime"] = user.CreatedAt.Unix() * 1000
item["participator"] = map[string]interface{}{
"userId": user.UserId,
"userInfo": map[string]interface{}{
"userName": user.UserName,
},
}
}
retMap = append(retMap, item)
}
... ...
... ... @@ -515,6 +515,7 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m
if item.DividendsType == 1 {
order, err := dividendsOrderRepository.FindOne(map[string]interface{}{
"dividendsOrderNumber": item.OrderOrReturnedOrderNum,
"orgId": request.OrgId,
})
if err != nil {
return nil, err
... ... @@ -522,7 +523,7 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m
result.DividendsOrderAmount = order.DividendsOrderAmount
result.CustomerName = order.CustomerName
} else if item.DividendsType == 2 {
order, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderNumber": item.OrderOrReturnedOrderNum})
order, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderNumber": item.OrderOrReturnedOrderNum, "orgId": request.OrgId})
if err != nil {
return nil, err
}
... ... @@ -584,7 +585,7 @@ func (ptr *CooperationStatisticsService) RelevantCooperationContractNumbers(quer
return nil, err
}
queryOptions = tool_funs.SimpleStructToMap(&request)
queryOptions["limit"] = 999
contractNumbers, err := ptr.getRelevantContracts(queryOptions)
return contractNumbers, err
}
... ...
... ... @@ -8,7 +8,7 @@ import (
type CooperationContractUndertaker struct {
tableName string `comment:"共创合约承接人" pg:"cooperation_contract_undertakers,alias:cooperation_contract_undertaker"`
// 共创合约承接人id
CooperationContractUndertakerId int64 `comment:"共创合约承接人id" pg:",pk,unique"`
CooperationContractUndertakerId int64 `comment:"共创合约承接人id" pg:",pk"`
// 共创合约编号
CooperationContractNumber string `comment:"共创合约编号"`
// 共创合约承接人uid
... ...
... ... @@ -8,7 +8,7 @@ import (
type DividendsIncentivesRule struct {
tableName string `comment:"金额激励规则实体" pg:"dividends_incentives_rules,alias:dividends_incentives_rule"`
// 分红规则ID
DividendsIncentivesRuleId int64 `comment:"分红规则ID" pg:",pk,unique"`
DividendsIncentivesRuleId int64 `comment:"分红规则ID" pg:",pk"`
// 关联的项目合约编号
CooperationContractNumber string `comment:"关联的项目合约编号"`
// 推荐人抽成比例
... ...
... ... @@ -10,7 +10,7 @@ type DividendsOrder struct {
// 分红订单ID
DividendsOrderId int64 `comment:"分红订单ID" pg:",pk"`
// 分红订单号
DividendsOrderNumber string `comment:"分红订单号" pg:",unique"`
DividendsOrderNumber string `comment:"分红订单号"`
// 分红订单原单号
DividendsOriginalOrderNum string `comment:"分红订单原单号"`
// 分红订单金额
... ...
... ... @@ -10,7 +10,7 @@ type DividendsReturnedOrder struct {
// 分红退货单记录ID
DividendsReturnedOrderId int64 `comment:"分红退货单记录ID" pg:",pk"`
// 分红退货单号
DividendsReturnedOrderNumber string `comment:"分红退货单号" pg:",unique"`
DividendsReturnedOrderNumber string `comment:"分红退货单号"`
// 退货金额
DividendsReturnedOrderRefund float64 `comment:"退货金额"`
// 源单号(原始订单号)
... ...
... ... @@ -8,7 +8,7 @@ import (
type MoneyIncentivesRule struct {
tableName string `comment:"金额激励规则实体" pg:"money_incentives_rules,alias:money_incentives_rule"`
// 金额激励规则ID
MoneyIncentivesRuleId int64 `comment:"金额激励规则ID" pg:",pk,unique"`
MoneyIncentivesRuleId int64 `comment:"金额激励规则ID" pg:",pk"`
// 关联的共创合约编号
CooperationContractNumber string `comment:"关联的共创合约编号"`
// 激励金额
... ...
... ... @@ -208,6 +208,9 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac
if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" {
query.Where(`cooperation_contract_number = ?`, fmt.Sprintf("%s", cooperationContractNumber))
}
if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 {
query.Where("cooperation_contract_number in (?)", pg.In(v))
}
if paymentStatus, ok := queryOptions["paymentStatus"]; ok && paymentStatus.(int32) != 0 {
query.Where("payment_status = ?", paymentStatus)
}
... ...