作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !5
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Docker for Mac" type="docker-deploy" factoryName="dockerfile" server-name="Docker for Mac">
<configuration default="false" name="Docker for Mac" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
<deployment type="dockerfile">
<settings>
<option name="imageTag" value="" />
<option name="imageTag" value="latest" />
<option name="containerName" value="allied-creation-cooperation" />
<option name="envVars">
<list>
<DockerEnvVarImpl>
<option name="name" value="POSTGRESQL_HOST" />
<option name="value" value="114.55.200.59" />
</DockerEnvVarImpl>
<DockerEnvVarImpl>
<option name="name" value="POSTGRESQL_DB_NAME" />
<option name="value" value="allied_creation_cooperation_dev" />
</DockerEnvVarImpl>
<DockerEnvVarImpl>
<option name="name" value="POSTGRESQL_PORT" />
<option name="value" value="31543" />
</DockerEnvVarImpl>
<DockerEnvVarImpl>
<option name="name" value="POSTGRESQL_PASSWORD" />
<option name="value" value="eagle1010" />
</DockerEnvVarImpl>
</list>
</option>
<option name="portBindings">
<list>
<DockerPortBindingImpl>
<option name="containerPort" value="8082" />
<option name="hostPort" value="8082" />
</DockerPortBindingImpl>
</list>
</option>
<option name="sourceFilePath" value="Dockerfile" />
</settings>
</deployment>
... ...
... ... @@ -14,4 +14,22 @@ ENV GOPROXY https://goproxy.io
RUN ["go","mod","tidy"]
RUN ["ls"]
RUN ["go","build"]
ENTRYPOINT ["./allied-creation-cooperation"]
\ No newline at end of file
ENTRYPOINT ["./allied-creation-cooperation"]
##############################
### STEP 1 build executable binary
##############################
#FROM golang:latest AS builder
#MAINTAINER 陈志颖 <steve.d.chan@qq.com>
#RUN mkdir /app
#WORKDIR /app
#COPY . /app
#RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
#RUN GO111MODULE="on" GOPROXY="https://goproxy.cn" CGO_ENABLED=0 GOOS=linux go build -o allied-creation-cooperation
#
##############################
### STEP 2 build a small image
#############################
#FROM scratch as final
#COPY --from=builder /app/allied-creation-cooperation /app/allied-creation-cooperation
#ENTRYPOINT ["./app/allied-creation-cooperation"]
\ No newline at end of file
... ...
... ... @@ -859,7 +859,7 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("共创项目%s不存在", strconv.FormatInt(cooperationApplicationSaved.CooperationProject.CooperationProjectId, 10)))
}
// 更新共创项目申请统计
cooperationProject.ApplicantCount = cooperationProject.ApplicantCount - 1
//cooperationProject.ApplicantCount = cooperationProject.ApplicantCount - 1
if _, err := cooperationProjectRepository.Save(cooperationProject); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -159,8 +159,12 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
}
// 校验承接人是否属于承接对象,1员工,2共创用户,4公开
if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, 4) {
if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, undertakerDomain.UserType) {
if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, 3) {
var userType int32
if undertakerDomain.UserType > 1024 {
userType = undertakerDomain.UserType - 1024
}
if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, userType) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象")
}
}
... ... @@ -1020,8 +1024,12 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
}
// 校验:判断用户类型是否属于承接对象
if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, 4) { // 非公开类型校验
if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, undertakerDomain.UserType) {
if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, 3) { // 非公开类型校验
var userType int32
if undertakerDomain.UserType > 1024 {
userType = undertakerDomain.UserType - 1024
}
if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, userType) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象")
}
}
... ... @@ -1172,7 +1180,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
if cooperationContractFound.IncentivesType != cooperationContractSaved.IncentivesType && cooperationContractFound.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES && cooperationContractSaved.IncentivesType == domain.TYPE_MONEY_INCENTIVES { // 1.激励类型变更
// 业绩分红-->金额激励
incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
//【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
// 原业绩分红激励规则
var dividendsIncentivesRuleOriginal string
... ... @@ -1203,7 +1210,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
// 金额激励-->业绩分红
incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
//【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
// 原金额激励规则
var moneyIncentivesRuleOriginal string
for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules {
... ... @@ -1214,7 +1220,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
"," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
}
moneyIncentivesRuleOriginalTmp := "【" + moneyIncentivesRuleOriginal + "】"
// 变更后的业绩分红激励规则
var dividendsIncentivesRuleChanged string
for _, dividendsIncentivesRule := range cooperationContractSaved.DividendsIncentivesRules {
... ... @@ -1226,7 +1231,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
"," + fmt.Sprint(dividendsIncentivesRule.SalesmanPercentage) + ";"
}
dividendsIncentivesRuleOriginalTmp := "【" + dividendsIncentivesRuleChanged + "】"
// 拼接规则变更
incentivesRuleChangeDetail = moneyIncentivesRuleOriginalTmp + " 变更为 " + dividendsIncentivesRuleOriginalTmp
} else { // 2.激励规则变更
... ... @@ -1235,7 +1239,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
// 业绩分红-->业绩分红
incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
//【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
// 原业绩分红激励规则
var dividendsIncentivesRuleOriginal string
for _, dividendsIncentivesRule := range cooperationContractFound.DividendsIncentivesRules {
... ... @@ -1247,7 +1250,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
"," + fmt.Sprint(dividendsIncentivesRule.SalesmanPercentage) + ";"
}
dividendsIncentivesRuleOriginalTmp := "【" + dividendsIncentivesRuleOriginal + "】"
// 变更后的业绩分红激励规则
var dividendsIncentivesRuleChanged string
for _, dividendsIncentivesRule := range cooperationContractSaved.DividendsIncentivesRules {
... ... @@ -1259,7 +1261,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
"," + fmt.Sprint(dividendsIncentivesRule.SalesmanPercentage) + ";"
}
dividendsIncentivesRuleChangedTmp := "【" + dividendsIncentivesRuleChanged + "】"
// 拼接规则变更
incentivesRuleChangeDetail = dividendsIncentivesRuleOriginalTmp + " 变更为 " + dividendsIncentivesRuleChangedTmp
}
... ... @@ -1267,7 +1268,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
if !cooperationContract.MoneyIncentivesRuleSliceEqualBCE(cooperationContractFound.MoneyIncentivesRules, cooperationContractSaved.MoneyIncentivesRules) {
incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
//【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
// 原金额激励规则
var moneyIncentivesRuleOriginal string
for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules {
... ... @@ -1278,7 +1278,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
"," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
}
moneyIncentivesRuleOriginalTmp := "【" + moneyIncentivesRuleOriginal + "】"
// 变更后的激励规则
var moneyIncentivesRuleChanged string
for _, moneyIncentivesRule := range cooperationContractSaved.MoneyIncentivesRules {
... ... @@ -1289,7 +1288,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
"," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
}
moneyIncentivesRuleChangedTmp := "【" + moneyIncentivesRuleChanged + "】"
// 拼接规则变更
incentivesRuleChangeDetail = moneyIncentivesRuleOriginalTmp + " 变更为 " + moneyIncentivesRuleChangedTmp
}
... ...
... ... @@ -290,6 +290,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 3)
}
// TODO 返回所有员工类型的申请通过人
cooperationProjectDto := &dto.CooperationProjectsDto{}
if err := cooperationProjectDto.LoadDto(cooperationProject, nil, undertakerTypesUncheckedAvailable); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -31,8 +31,7 @@ type MoneyIncentivesEstimateDto struct {
StageAndUndertaker []*StageAndUndertaker `json:"stageAndUndertaker"`
}
func (dto *MoneyIncentivesEstimateDto) LoadDto(contract *domain.CooperationContract) error {
// TODO 阶段承接人数据聚合
func (dto *MoneyIncentivesEstimateDto) LoadDto(contract *domain.CooperationContract, stageAndUndertaker []*StageAndUndertaker) error {
dto.CooperationContractId = contract.CooperationContractId
dto.CooperationContractNumber = contract.CooperationContractNumber
dto.CooperationContractName = contract.CooperationContractName
... ... @@ -40,9 +39,6 @@ func (dto *MoneyIncentivesEstimateDto) LoadDto(contract *domain.CooperationContr
dto.Department = contract.Department
dto.CooperationContractSponsorName = contract.CooperationContractSponsor.UserName
dto.CreatedAt = contract.CreatedAt
dto.StageAndUndertaker = append(dto.StageAndUndertaker, &StageAndUndertaker{
Stage: 0,
Undertakers: nil,
})
dto.StageAndUndertaker = stageAndUndertaker
return nil
}
... ...
... ... @@ -24,6 +24,8 @@ type ListDividendsIncentivesEstimateQuery struct {
UserId int64 `cname:"用户ID" json:"userId"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
// 分红状态
OrderGoodDividendsStatus int32 `cname:"分红状态" json:"orderGoodDividendsStatus,omitempty"`
}
func (listDividendsIncentivesEstimateQuery *ListDividendsIncentivesEstimateQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -28,6 +28,8 @@ type SearchDividendsIncentivesEstimateQuery struct {
PageNumber int64 `cname:"页码" json:"pageNumber,omitempty"`
// 页面大小
PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"`
// 分红状态
OrderGoodDividendsStatus int32 `cname:"分红状态" json:"orderGoodDividendsStatus,omitempty"`
}
func (searchDividendsIncentivesEstimateQuery *SearchDividendsIncentivesEstimateQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -68,6 +68,7 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive
}
// 获取订单产品
listDividendsIncentivesEstimateQuery.OrderGoodDividendsStatus = int32(1)
if count, orderGoods, err := orderGoodRepository.Find(tool_funs.SimpleStructToMap(listDividendsIncentivesEstimateQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -77,8 +78,8 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive
if orderGood.DividendsOrderNumber != "" { // 查询分红订单
dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{
"dividendsOrderNumber": orderGood.DividendsOrderNumber,
"companyId": orderGood.CompanyId,
"orgId": orderGood.OrgId,
"companyId": listDividendsIncentivesEstimateQuery.CompanyId,
"orgId": listDividendsIncentivesEstimateQuery.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -92,8 +93,8 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive
dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
} else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{
"companyId": orderGood.CompanyId,
"orgId": orderGood.OrgId,
"companyId": listDividendsIncentivesEstimateQuery.CompanyId,
"orgId": listDividendsIncentivesEstimateQuery.OrgId,
"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber,
})
if err != nil {
... ... @@ -147,13 +148,11 @@ func (dividendsEstimateService *DividendsEstimateService) ListMoneyIncentivesEst
if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(listMoneyIncentivesEstimateQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
// TODO 判断承接人是否已分红
// 数据传输对象
var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto
for _, cooperationContract := range cooperationContracts {
moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract); err != nil {
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract, nil); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
... ... @@ -749,8 +748,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
} else {
// 获取产品ID
orderGoodSavedIds := make([]int64, 0)
for _, dividendsEstimateSaved := range dividendsEstimatesSaved {
orderGoodSavedIds = append(orderGoodSavedIds, dividendsEstimateSaved.OrderGoodId)
for _, dividendsEstimate := range dividendsEstimates {
orderGoodSavedIds = append(orderGoodSavedIds, dividendsEstimate.OrderGoodId)
}
// 获取订单产品
... ... @@ -899,7 +898,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
}
return map[string]interface{}{
"report": fmt.Sprintf("已完成%d笔单订单分红预算,生成%d笔单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr),
"report": fmt.Sprintf("已完成%d单订单分红预算,生成%d单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr),
}, nil
}
}
... ... @@ -1283,39 +1282,45 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti
}
// 获取订单产品
searchDividendsIncentivesEstimateQuery.OrderGoodDividendsStatus = int32(1) // 查询带分红的产品
if count, orderGoods, err := orderGoodRepository.Find(tool_funs.SimpleStructToMap(searchDividendsIncentivesEstimateQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
var dividendsIncentivesEstimateDtos []*dto.DividendsIncentivesEstimateDto
for _, orderGood := range orderGoods {
dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{}
if orderGood.DividendsOrderNumber != "" { // 查询分红订单
dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{}
dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{
"dividendsOrderNumber": orderGood.DividendsOrderNumber,
"companyId": orderGood.CompanyId,
"orgId": orderGood.OrgId,
"companyId": searchDividendsIncentivesEstimateQuery.CompanyId,
"orgId": searchDividendsIncentivesEstimateQuery.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
continue
//return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if dividendsOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))
continue
//return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))
}
if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsOrder.DividendsOrderNumber, dividendsOrder.DividendsOriginalOrderNum, dividendsOrder.CustomerName, dividendsOrder.Region.RegionName, dividendsOrder.OrderTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
} else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{}
dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{
"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber,
"companyId": orderGood.CompanyId,
"orgId": orderGood.OrgId,
"companyId": searchDividendsIncentivesEstimateQuery.CompanyId,
"orgId": searchDividendsIncentivesEstimateQuery.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
continue
//return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if dividendsReturnedOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))
continue
//return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))
}
if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsReturnedOrder.DividendsReturnedOrderNumber, dividendsReturnedOrder.OriginalOrderNum, dividendsReturnedOrder.DividendsReturnedCustomerName, dividendsReturnedOrder.Region.RegionName, dividendsReturnedOrder.OrderTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -1348,6 +1353,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 共创合约仓储初始化
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
... ... @@ -1357,6 +1363,10 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
} else {
cooperationContractRepository = value
}
// TODO 阶段承接人列表
stageAndUndertaker := make([]*dto.StageAndUndertaker, 0)
// 查找共创合约
searchMoneyIncentivesEstimateQuery.IncentivesType = 2
if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(searchMoneyIncentivesEstimateQuery)); err != nil {
... ... @@ -1364,8 +1374,13 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
} else {
var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto
for _, cooperationContract := range cooperationContracts {
// TODO 判断承接人是否已分红
//for _, undertaker := range cooperationContract.Undertakers {
//
//}
moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract); err != nil {
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract, stageAndUndertaker); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
... ...
... ... @@ -265,6 +265,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) GetDividends
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 退货单仓储初始化
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -273,7 +274,15 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) GetDividends
} else {
dividendsReturnedOrderRepository = value
}
dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderId": getDividendsReturnedOrderQuery.DividendsReturnedOrderId})
// 查找退货单
dividendsReturnedOrderId, err := strconv.ParseInt(getDividendsReturnedOrderQuery.DividendsReturnedOrderId, 10, 64)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{
"dividendsReturnedOrderId": dividendsReturnedOrderId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -7,19 +7,20 @@ import (
func TransformToOrderGoodDomainModelFromPgModels(orderGoodModel *models.OrderGood) (*domain.OrderGood, error) {
return &domain.OrderGood{
OrderGoodId: orderGoodModel.OrderGoodId,
OrderGoodAmount: orderGoodModel.OrderGoodAmount,
OrderGoodName: orderGoodModel.OrderGoodName,
OrderGoodPrice: orderGoodModel.OrderGoodPrice,
OrderGoodQuantity: orderGoodModel.OrderGoodQuantity,
DividendsOrderNumber: orderGoodModel.DividendsOrderNumber,
CooperationContractNumber: orderGoodModel.CooperationContractNumber,
OrderGoodExpense: orderGoodModel.OrderGoodExpense,
OrderGoodDividendsStatus: orderGoodModel.OrderGoodDividendsStatus,
OrgId: orderGoodModel.OrgId,
CompanyId: orderGoodModel.CompanyId,
CreatedAt: orderGoodModel.CreatedAt,
DeletedAt: orderGoodModel.DeletedAt,
UpdatedAt: orderGoodModel.UpdatedAt,
OrderGoodId: orderGoodModel.OrderGoodId,
OrderGoodAmount: orderGoodModel.OrderGoodAmount,
OrderGoodName: orderGoodModel.OrderGoodName,
OrderGoodPrice: orderGoodModel.OrderGoodPrice,
OrderGoodQuantity: orderGoodModel.OrderGoodQuantity,
DividendsOrderNumber: orderGoodModel.DividendsOrderNumber,
DividendsReturnedOrderNumber: orderGoodModel.DividendsReturnedOrderNumber,
CooperationContractNumber: orderGoodModel.CooperationContractNumber,
OrderGoodExpense: orderGoodModel.OrderGoodExpense,
OrderGoodDividendsStatus: orderGoodModel.OrderGoodDividendsStatus,
OrgId: orderGoodModel.OrgId,
CompanyId: orderGoodModel.CompanyId,
CreatedAt: orderGoodModel.CreatedAt,
DeletedAt: orderGoodModel.DeletedAt,
UpdatedAt: orderGoodModel.UpdatedAt,
}, nil
}
... ...
... ... @@ -518,7 +518,8 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte
if err := orderGoodModelQuery.
Where("company_id = ?", dividendsOrderModel.Company.CompanyId).
Where("org_id = ?", dividendsOrderModel.Org.OrgId).
Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber).Select(); err != nil {
Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber).
Select(); err != nil {
return nil, fmt.Errorf("分红订单关联的产品不存在")
}
// 聚合分红订单
... ...
... ... @@ -488,8 +488,20 @@ func (repository *DividendsReturnedOrderRepository) FindOne(queryOptions map[str
tx := repository.transactionContext.PgTx
dividendsReturnedOrderModel := new(models.DividendsReturnedOrder)
query := sqlbuilder.BuildQuery(tx.Model(dividendsReturnedOrderModel), queryOptions)
query.SetWhereByQueryOption("dividends_returned_order.dividends_returned_order_id = ?", "dividendsReturnedOrderId")
query.SetWhereByQueryOption("dividends_returned_order.dividends_returned_order_number = ?", "dividendsReturnedOrderNumber")
if dividendsReturnedOrderId, ok := queryOptions["dividendsReturnedOrderId"]; ok && dividendsReturnedOrderId.(int64) != 0 {
query.Where("dividends_returned_order.dividends_returned_order_id = ?", dividendsReturnedOrderId)
}
//query.SetWhereByQueryOption("dividends_returned_order.dividends_returned_order_id = ?", "dividendsReturnedOrderId")
//query.SetWhereByQueryOption("dividends_returned_order.dividends_returned_order_number = ?", "dividendsReturnedOrderNumber")
if dividendsReturnedOrderNumber, ok := queryOptions["dividendsReturnedOrderNumber"]; ok && dividendsReturnedOrderNumber != "" {
query.Where("dividends_returned_order.dividends_returned_order_number = ?", dividendsReturnedOrderNumber)
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("分红退货单不存在")
... ...
... ... @@ -203,6 +203,9 @@ func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{})
return q, nil
})
}
if orderGoodDividendsStatus, ok := queryOptions["orderGoodDividendsStatus"]; ok && orderGoodDividendsStatus.(int32) != 0 {
query.Where("order_good_dividends_status = ?", orderGoodDividendsStatus)
}
if orderGoodIds, ok := queryOptions["orderGoodIds"]; ok && len(orderGoodIds.([]int64)) > 0 {
query.Where("order_good_id IN (?)", pg.In(orderGoodIds))
}
... ...