作者 yangfu

Merge branch 'test' of http://gitlab.fjmaimaimai.com/allied-creation/allied-crea…

…tion-cooperation into test
... ... @@ -26,6 +26,8 @@ type OneClickApprovalCooperationApplicationCommand struct {
CooperationApplicationStatus int32 `cname:"共创申请审核状态" json:"cooperationApplicationStatus"`
// 查询限制
OffsetLimit bool `cname:"查询限制" json:"offsetLimit"`
// 是否取消标志
IsCanceled int32 `cname:"是否删除" json:"isCanceled"`
}
func (oneClickApprovalCooperationApplicationCommand *OneClickApprovalCooperationApplicationCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -445,7 +445,7 @@ func (cooperationApplicationService *CooperationApplicationService) OneClickAppr
// 获取审核人
var verifier *domain.User
if data, err := userService.UserFrom(oneClickApprovalCooperationApplicationCommand.CompanyId, oneClickApprovalCooperationApplicationCommand.OrgId, oneClickApprovalCooperationApplicationCommand.UserId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取申请人失败")
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取审核人失败")
} else {
verifier = data
}
... ... @@ -453,6 +453,10 @@ func (cooperationApplicationService *CooperationApplicationService) OneClickAppr
// 查询共创申请
oneClickApprovalCooperationApplicationCommand.CooperationApplicationStatus = 1 // 待审核
oneClickApprovalCooperationApplicationCommand.OffsetLimit = false
oneClickApprovalCooperationApplicationCommand.IsCanceled = int32(1)
oneClickApprovalCooperationApplicationCommand.UserBaseId = 0
oneClickApprovalCooperationApplicationCommand.UserId = 0
if count, cooperationApplications, err := cooperationApplicationRepository.Find(tool_funs.SimpleStructToMap(oneClickApprovalCooperationApplicationCommand)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ...
... ... @@ -8,6 +8,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
)
type CancelDividendsEstimateService struct {
... ... @@ -21,6 +22,12 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储
var orderGoodRepository domain.OrderGoodRepository // 订单产品仓储
type orderGoodInfo struct {
OrderGoodId int64
CompanyId int64
OrgId int64
}
// 分红预算单仓储初始化
if repo, err := repository.NewDividendsEstimateRepository(domainService.transactionContext); err != nil {
return nil, err
... ... @@ -60,6 +67,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
var dividendsEstimatesCanceled []*domain.DividendsEstimate
var orderOrReturnOrderNums []string
var orderGoodIds []int64
orderGoodMaps := make(map[string][]int64, 0)
for _, dividendsEstimate := range dividendsEstimates {
if dividendsEstimate.DividendsType == 1 || dividendsEstimate.DividendsType == 2 { // 1.订单分红 2.退货冲销
// 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
... ... @@ -83,6 +91,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
// 获取相关订单/退货单号
orderOrReturnOrderNums = append(orderOrReturnOrderNums, dividendsEstimatesRelative[i].OrderOrReturnedOrderNum)
orderGoodIds = append(orderGoodIds, dividendsEstimatesRelative[i].OrderGoodId)
orderGoodMaps[dividendsEstimatesRelative[i].OrderOrReturnedOrderNum] = append(orderGoodMaps[dividendsEstimatesRelative[i].OrderOrReturnedOrderNum], dividendsEstimatesRelative[i].OrderGoodId)
}
dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative)
if err3 != nil {
... ... @@ -151,18 +160,19 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
}); err4 != nil {
return nil, err4
} else {
// orderGoodIds去重
newOrderGoodIds := utils.RemoveDuplicationInt64(orderGoodIds)
if countDividendsOrder > 0 {
for i, order := range orders {
// 取消分红的订单产品
newOrderGoodIds := utils.RemoveDuplicationInt64(orderGoodMaps[order.DividendsOrderNumber])
var goodIds []int64
for _, good := range order.Goods {
if good.OrderGoodDividendsStatus == 2 {
goodIds = append(goodIds, good.OrderGoodId)
}
}
// goodIds去重
// goodIds去重
newGoodIds := utils.RemoveDuplicationInt64(goodIds)
log.Logger.Info("")
if len(newGoodIds) == len(newOrderGoodIds) { // 1.已分红的产品数量等于取消的产品数量,订单分红状态变更为未分红
orders[i].DividendStatus = 1
} else if len(newGoodIds) > len(newOrderGoodIds) { // 3.已分红的产品数量大于被取消分红的产品数量,订单分红状态变更为部分分红
... ... @@ -216,21 +226,21 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
}); err5 != nil {
return nil, err5
} else {
// orderGoodIds去重
newReturnedOrderGoodIds := utils.RemoveDuplicationInt64(orderGoodIds)
if countDividendsReturnedOrder > 0 {
for i, returnedOrder := range returnedOrders {
goods := make([]*domain.OrderGood, 0)
// 已取消的退货单产品
newReturnedOrderGoodIds := utils.RemoveDuplicationInt64(orderGoodMaps[returnedOrder.DividendsReturnedOrderNumber])
var goodIds []int64
for _, good := range returnedOrder.Goods {
if good.OrderGoodDividendsStatus == 2 {
goods = append(goods, good)
goodIds = append(goodIds, good.OrderGoodId)
}
}
if len(goods) == len(newReturnedOrderGoodIds) { // 1.已分红的产品数量等于取消的产品数量,退货单分红状态变更为未分红
// goodIds去重
newGoodIds := utils.RemoveDuplicationInt64(goodIds)
if len(newGoodIds) == len(newReturnedOrderGoodIds) { // 1.已分红的产品数量等于取消的产品数量,退货单分红状态变更为未分红
returnedOrders[i].DividendStatus = 1
} else if len(goods) > len(newReturnedOrderGoodIds) { // 3.已分红的产品数量大于被取消分红的产品数量,退货单分红状态变更为部分分红
} else if len(newGoodIds) > len(newReturnedOrderGoodIds) { // 3.已分红的产品数量大于被取消分红的产品数量,退货单分红状态变更为部分分红
returnedOrders[i].DividendStatus = 3
}
returnedOrders[i].DividendStatus = returnedOrder.DividendStatus
... ...