作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…

…ion-cooperation into dev
... ... @@ -1096,6 +1096,16 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba
dividendsReturnedOrderRepository = value
}
// 分红预算单仓储初始化
var dividendsEstimateRepository domain.DividendsEstimateRepository
if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dividendsEstimateRepository = value
}
dividendsOrderIds, err := utils.SliceAtoi(batchRemoveDividendsOrderCommand.DividendsOrderIds)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单ID类型错误")
... ... @@ -1120,9 +1130,22 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的退货单,不可删除", dividendsOrder.DividendsOrderNumber))
}
}
}
// TODO 校验分红订单是否有分红预算
// 校验分红订单是否有分红预算
if countRelative, _, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
"companyId": dividendsOrder.Company.CompanyId,
"orgId": dividendsOrder.Org.OrgId,
"orderOrReturnedOrderNum": dividendsOrder.DividendsOrderNumber,
"offsetLimit": false,
"isCanceled": false,
}); err2 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
} else {
if countRelative > 0 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的预算单,不可删除", dividendsOrder.DividendsOrderNumber))
}
}
}
dividendsOrdersRemoved, err := dividendsOrderRepository.BatchRemove(dividendsOrders)
if err != nil {
... ...
... ... @@ -42,7 +42,7 @@ type DividendsEstimate struct {
// 操作时间
OperateTime time.Time `comment:"操作时间"`
// 取消状态
IsCanceled bool `comment:"取消状态"`
IsCanceled bool `comment:"取消状态" pg:",use_zero,default:false"`
// 产品ID
OrderGoodId int64 `comment:"产品ID"`
// 创建时间
... ...
... ... @@ -346,6 +346,9 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
if isCanceled, ok := queryOptions["isCanceled"]; ok {
query.Where("is_canceled = ?", isCanceled.(bool))
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
... ...
... ... @@ -477,7 +477,7 @@ func (repository *DividendsOrderRepository) BatchRemove(dividendsOrders []*domai
if _, err := tx.Model(&orderGoodModels).
Where("company_id = ?", dividendsOrder.Company.CompanyId).
Where("org_id = ?", dividendsOrder.Org.OrgId).
Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).Delete(); err != nil {
Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber).WherePK().Delete(); err != nil {
return nil, err
}
}
... ...
... ... @@ -535,6 +535,9 @@ func (repository *DividendsReturnedOrderRepository) Find(queryOptions map[string
if dividendsReturnedOrderIds, ok := queryOptions["dividendsReturnedOrderIds"]; ok && len(dividendsReturnedOrderIds.([]int64)) > 0 {
query.Where("dividends_returned_order_id IN (?)", pg.In(dividendsReturnedOrderIds.([]int64)))
}
if dividendsOrderNumber, ok := queryOptions["dividendsOrderNumber"]; ok && dividendsOrderNumber != "" {
query.Where("dividends_order_number = ?", dividendsOrderNumber)
}
if dividendsReturnedOrderNumber, ok := queryOptions["dividendsReturnedOrderNumber"]; ok && dividendsReturnedOrderNumber != "" {
query.Where("dividends_returned_order_number ilike ?", fmt.Sprintf("%%%s%%", dividendsReturnedOrderNumber))
}
... ...