正在显示
8 个修改的文件
包含
112 行增加
和
70 行删除
@@ -1275,7 +1275,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1275,7 +1275,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
1275 | for _, rule := range cooperationContractFound.DividendsIncentivesRules { | 1275 | for _, rule := range cooperationContractFound.DividendsIncentivesRules { |
1276 | jsons, errs := json.Marshal(rule) | 1276 | jsons, errs := json.Marshal(rule) |
1277 | if errs != nil { | 1277 | if errs != nil { |
1278 | - fmt.Println(errs.Error()) | 1278 | + (errs.Error()) |
1279 | } | 1279 | } |
1280 | cooperationContractFoundBytes = append(cooperationContractFoundBytes, jsons...) | 1280 | cooperationContractFoundBytes = append(cooperationContractFoundBytes, jsons...) |
1281 | } | 1281 | } |
@@ -1288,7 +1288,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1288,7 +1288,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
1288 | for _, rule := range cooperationContract.DividendsIncentivesRules { | 1288 | for _, rule := range cooperationContract.DividendsIncentivesRules { |
1289 | jsons, errs := json.Marshal(rule) | 1289 | jsons, errs := json.Marshal(rule) |
1290 | if errs != nil { | 1290 | if errs != nil { |
1291 | - fmt.Println(errs.Error()) | 1291 | + (errs.Error()) |
1292 | } | 1292 | } |
1293 | cooperationContractBytes = append(cooperationContractBytes, jsons...) | 1293 | cooperationContractBytes = append(cooperationContractBytes, jsons...) |
1294 | } | 1294 | } |
@@ -1331,7 +1331,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1331,7 +1331,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
1331 | for _, rule := range cooperationContractFound.MoneyIncentivesRules { | 1331 | for _, rule := range cooperationContractFound.MoneyIncentivesRules { |
1332 | jsons, errs := json.Marshal(rule) | 1332 | jsons, errs := json.Marshal(rule) |
1333 | if errs != nil { | 1333 | if errs != nil { |
1334 | - fmt.Println(errs.Error()) | 1334 | + (errs.Error()) |
1335 | } | 1335 | } |
1336 | cooperationContractFoundBytes = append(cooperationContractFoundBytes, jsons...) | 1336 | cooperationContractFoundBytes = append(cooperationContractFoundBytes, jsons...) |
1337 | } | 1337 | } |
@@ -1344,7 +1344,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1344,7 +1344,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
1344 | for _, rule := range cooperationContract.MoneyIncentivesRules { | 1344 | for _, rule := range cooperationContract.MoneyIncentivesRules { |
1345 | jsons, errs := json.Marshal(rule) | 1345 | jsons, errs := json.Marshal(rule) |
1346 | if errs != nil { | 1346 | if errs != nil { |
1347 | - fmt.Println(errs.Error()) | 1347 | + (errs.Error()) |
1348 | } | 1348 | } |
1349 | cooperationContractBytes = append(cooperationContractBytes, jsons...) | 1349 | cooperationContractBytes = append(cooperationContractBytes, jsons...) |
1350 | } | 1350 | } |
@@ -1388,7 +1388,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1388,7 +1388,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
1388 | for _, undertaker := range cooperationContractFound.Undertakers { | 1388 | for _, undertaker := range cooperationContractFound.Undertakers { |
1389 | jsons, errs := json.Marshal(undertaker) | 1389 | jsons, errs := json.Marshal(undertaker) |
1390 | if errs != nil { | 1390 | if errs != nil { |
1391 | - fmt.Println(errs.Error()) | 1391 | + (errs.Error()) |
1392 | } | 1392 | } |
1393 | cooperationContractFoundBytes = append(cooperationContractFoundBytes, jsons...) | 1393 | cooperationContractFoundBytes = append(cooperationContractFoundBytes, jsons...) |
1394 | } | 1394 | } |
@@ -1400,7 +1400,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1400,7 +1400,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
1400 | for _, undertaker := range cooperationContract.Undertakers { | 1400 | for _, undertaker := range cooperationContract.Undertakers { |
1401 | jsons, errs := json.Marshal(undertaker) //转换成JSON返回的是byte[] | 1401 | jsons, errs := json.Marshal(undertaker) //转换成JSON返回的是byte[] |
1402 | if errs != nil { | 1402 | if errs != nil { |
1403 | - fmt.Println(errs.Error()) | 1403 | + (errs.Error()) |
1404 | } | 1404 | } |
1405 | cooperationContractBytes = append(cooperationContractBytes, jsons...) | 1405 | cooperationContractBytes = append(cooperationContractBytes, jsons...) |
1406 | } | 1406 | } |
@@ -26,9 +26,9 @@ func (batchRemoveCooperationModeCommand *BatchRemoveCooperationModeCommand) Vali | @@ -26,9 +26,9 @@ func (batchRemoveCooperationModeCommand *BatchRemoveCooperationModeCommand) Vali | ||
26 | for _, cooperationModeId := range batchRemoveCooperationModeCommand.CooperationModeIds { | 26 | for _, cooperationModeId := range batchRemoveCooperationModeCommand.CooperationModeIds { |
27 | switch v := reflect.ValueOf(cooperationModeId); v.Kind() { | 27 | switch v := reflect.ValueOf(cooperationModeId); v.Kind() { |
28 | case reflect.String: | 28 | case reflect.String: |
29 | - fmt.Println(v.String()) | 29 | + (v.String()) |
30 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: | 30 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: |
31 | - fmt.Println(v.Int()) | 31 | + (v.Int()) |
32 | _ = validation.SetError("CustomValid", "共创模式ID类型错误") | 32 | _ = validation.SetError("CustomValid", "共创模式ID类型错误") |
33 | default: | 33 | default: |
34 | fmt.Printf("unhandled kind %s", v.Kind()) | 34 | fmt.Printf("unhandled kind %s", v.Kind()) |
@@ -405,8 +405,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD | @@ -405,8 +405,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD | ||
405 | t := reflect.TypeOf(dividendsOrder) | 405 | t := reflect.TypeOf(dividendsOrder) |
406 | v := reflect.ValueOf(dividendsOrder) | 406 | v := reflect.ValueOf(dividendsOrder) |
407 | for k := 0; k < t.NumField(); k++ { | 407 | for k := 0; k < t.NumField(); k++ { |
408 | - //fmt.Println("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface()), ", yaml:", t.Field(k).Tag.Get("yaml")) | ||
409 | - //fmt.Println("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface())) | 408 | + //("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface()), ", yaml:", t.Field(k).Tag.Get("yaml")) |
409 | + //("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface())) | ||
410 | if t.Field(k).Name != "Expense" { | 410 | if t.Field(k).Name != "Expense" { |
411 | if v.Field(k).Interface() == "" { | 411 | if v.Field(k).Interface() == "" { |
412 | col := strconv.Itoa(k + 1) | 412 | col := strconv.Itoa(k + 1) |
@@ -1151,14 +1151,14 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba | @@ -1151,14 +1151,14 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba | ||
1151 | } | 1151 | } |
1152 | 1152 | ||
1153 | // 分红退货单仓储初始化 | 1153 | // 分红退货单仓储初始化 |
1154 | - var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository | ||
1155 | - if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{ | ||
1156 | - "transactionContext": transactionContext, | ||
1157 | - }); err != nil { | ||
1158 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1159 | - } else { | ||
1160 | - dividendsReturnedOrderRepository = value | ||
1161 | - } | 1154 | + //var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository |
1155 | + //if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{ | ||
1156 | + // "transactionContext": transactionContext, | ||
1157 | + //}); err != nil { | ||
1158 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1159 | + //} else { | ||
1160 | + // dividendsReturnedOrderRepository = value | ||
1161 | + //} | ||
1162 | 1162 | ||
1163 | // 分红预算单仓储初始化 | 1163 | // 分红预算单仓储初始化 |
1164 | //var dividendsEstimateRepository domain.DividendsEstimateRepository | 1164 | //var dividendsEstimateRepository domain.DividendsEstimateRepository |
@@ -1181,14 +1181,14 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba | @@ -1181,14 +1181,14 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba | ||
1181 | //} | 1181 | //} |
1182 | 1182 | ||
1183 | // 分红退货单DAO初始化 | 1183 | // 分红退货单DAO初始化 |
1184 | - //var dividendsReturnedOrderDao *dao.DividendsReturnedOrderDao | ||
1185 | - //if value, err := factory.CreateDividendsReturnedOrderDao(map[string]interface{}{ | ||
1186 | - // "transactionContext": transactionContext, | ||
1187 | - //}); err != nil { | ||
1188 | - // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1189 | - //} else { | ||
1190 | - // dividendsReturnedOrderDao = value | ||
1191 | - //} | 1184 | + var dividendsReturnedOrderDao *dao.DividendsReturnedOrderDao |
1185 | + if value, err := factory.CreateDividendsReturnedOrderDao(map[string]interface{}{ | ||
1186 | + "transactionContext": transactionContext, | ||
1187 | + }); err != nil { | ||
1188 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1189 | + } else { | ||
1190 | + dividendsReturnedOrderDao = value | ||
1191 | + } | ||
1192 | 1192 | ||
1193 | dividendsOrderIds, err := utils.SliceAtoi(batchRemoveDividendsOrderCommand.DividendsOrderIds) | 1193 | dividendsOrderIds, err := utils.SliceAtoi(batchRemoveDividendsOrderCommand.DividendsOrderIds) |
1194 | if err != nil { | 1194 | if err != nil { |
@@ -1205,34 +1205,34 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba | @@ -1205,34 +1205,34 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba | ||
1205 | if count > 0 { | 1205 | if count > 0 { |
1206 | for _, dividendsOrder := range dividendsOrders { | 1206 | for _, dividendsOrder := range dividendsOrders { |
1207 | // 校验分红订单是否有关联的退货单 | 1207 | // 校验分红订单是否有关联的退货单 |
1208 | + //startCount := time.Now() | ||
1209 | + //if countReturnedOrder, _, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{ | ||
1210 | + // "dividendsOrderNumber": dividendsOrder.DividendsOrderNumber, | ||
1211 | + // "companyId": dividendsOrder.Company.CompanyId, | ||
1212 | + // "limit": 1, | ||
1213 | + // "offset": 0, | ||
1214 | + //}); err != nil { | ||
1215 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1216 | + //} else { | ||
1217 | + // if countReturnedOrder > 0 { | ||
1218 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的退货单,不可删除", dividendsOrder.DividendsOrderNumber)) | ||
1219 | + // } | ||
1220 | + //} | ||
1221 | + //("退货单计数:", time.Since(startCount)) | ||
1222 | + | ||
1208 | startCount := time.Now() | 1223 | startCount := time.Now() |
1209 | - if countReturnedOrder, _, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{ | 1224 | + if returnedOrderExist, err := dividendsReturnedOrderDao.CheckDividendsReturnedOrderExist(map[string]interface{}{ |
1210 | "dividendsOrderNumber": dividendsOrder.DividendsOrderNumber, | 1225 | "dividendsOrderNumber": dividendsOrder.DividendsOrderNumber, |
1211 | "companyId": dividendsOrder.Company.CompanyId, | 1226 | "companyId": dividendsOrder.Company.CompanyId, |
1212 | - "limit": 1, | ||
1213 | - "offset": 0, | ||
1214 | }); err != nil { | 1227 | }); err != nil { |
1215 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1228 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1216 | } else { | 1229 | } else { |
1217 | - if countReturnedOrder > 0 { | 1230 | + if returnedOrderExist { |
1218 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的退货单,不可删除", dividendsOrder.DividendsOrderNumber)) | 1231 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的退货单,不可删除", dividendsOrder.DividendsOrderNumber)) |
1219 | } | 1232 | } |
1220 | } | 1233 | } |
1221 | fmt.Println("退货单计数:", time.Since(startCount)) | 1234 | fmt.Println("退货单计数:", time.Since(startCount)) |
1222 | 1235 | ||
1223 | - //startCount := time.Now() | ||
1224 | - //if returnedOrderExist, err := dividendsReturnedOrderDao.CheckDividendsReturnedOrderExist(map[string]interface{}{ | ||
1225 | - // "dividendsOrderNumber": dividendsOrder.DividendsOrderNumber, | ||
1226 | - // "companyId": dividendsOrder.Company.CompanyId, | ||
1227 | - //}); err != nil { | ||
1228 | - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1229 | - //} else { | ||
1230 | - // if returnedOrderExist { | ||
1231 | - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的退货单,不可删除", dividendsOrder.DividendsOrderNumber)) | ||
1232 | - // } | ||
1233 | - //} | ||
1234 | - //fmt.Println("退货单计数:", time.Since(startCount)) | ||
1235 | - | ||
1236 | // 校验分红订单是否有分红预算 | 1236 | // 校验分红订单是否有分红预算 |
1237 | //startEstimateCount := time.Now() | 1237 | //startEstimateCount := time.Now() |
1238 | //if countRelative, _, err2 := dividendsEstimateRepository.Find(map[string]interface{}{ | 1238 | //if countRelative, _, err2 := dividendsEstimateRepository.Find(map[string]interface{}{ |
@@ -1249,7 +1249,7 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba | @@ -1249,7 +1249,7 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba | ||
1249 | // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的预算单,不可删除", dividendsOrder.DividendsOrderNumber)) | 1249 | // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的预算单,不可删除", dividendsOrder.DividendsOrderNumber)) |
1250 | // } | 1250 | // } |
1251 | //} | 1251 | //} |
1252 | - //fmt.Println("预算单计数:", time.Since(startEstimateCount)) | 1252 | + //("预算单计数:", time.Since(startEstimateCount)) |
1253 | 1253 | ||
1254 | //startEstimateCount := time.Now() | 1254 | //startEstimateCount := time.Now() |
1255 | //if estimateOrderExist, err3 := dividendsEstimateDao.CheckDividendsEstimateOrderExist(map[string]interface{}{ | 1255 | //if estimateOrderExist, err3 := dividendsEstimateDao.CheckDividendsEstimateOrderExist(map[string]interface{}{ |
@@ -1276,6 +1276,7 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba | @@ -1276,6 +1276,7 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba | ||
1276 | if err != nil { | 1276 | if err != nil { |
1277 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 1277 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
1278 | } | 1278 | } |
1279 | + | ||
1279 | fmt.Println("截止目前耗时3:", time.Since(start)) | 1280 | fmt.Println("截止目前耗时3:", time.Since(start)) |
1280 | if err := transactionContext.CommitTransaction(); err != nil { | 1281 | if err := transactionContext.CommitTransaction(); err != nil { |
1281 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 1282 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -445,7 +445,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide | @@ -445,7 +445,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide | ||
445 | t := reflect.TypeOf(dividendsReturnedOrder) | 445 | t := reflect.TypeOf(dividendsReturnedOrder) |
446 | v := reflect.ValueOf(dividendsReturnedOrder) | 446 | v := reflect.ValueOf(dividendsReturnedOrder) |
447 | for k := 0; k < t.NumField(); k++ { | 447 | for k := 0; k < t.NumField(); k++ { |
448 | - //fmt.Println("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface())) | 448 | + //("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface())) |
449 | //if t.Field(k).Name != "RegionName" { | 449 | //if t.Field(k).Name != "RegionName" { |
450 | if v.Field(k).Interface() == "" { | 450 | if v.Field(k).Interface() == "" { |
451 | col := strconv.Itoa(k + 1) | 451 | col := strconv.Itoa(k + 1) |
@@ -6,7 +6,7 @@ import ( | @@ -6,7 +6,7 @@ import ( | ||
6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" |
7 | ) | 7 | ) |
8 | 8 | ||
9 | -func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel *models.DividendsOrder, goods []*models.OrderGood) (*domain.DividendsOrder, error) { | 9 | +func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModels []*models.DividendsOrder, goods []*models.OrderGood) ([]*domain.DividendsOrder, error) { |
10 | var orderGoods []*domain.OrderGood | 10 | var orderGoods []*domain.OrderGood |
11 | for _, good := range goods { | 11 | for _, good := range goods { |
12 | orderGoodAmount, _ := decimal.NewFromFloatWithExponent(good.OrderGoodAmount, -2).Float64() | 12 | orderGoodAmount, _ := decimal.NewFromFloatWithExponent(good.OrderGoodAmount, -2).Float64() |
@@ -26,8 +26,12 @@ func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel *model | @@ -26,8 +26,12 @@ func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel *model | ||
26 | UpdatedAt: good.UpdatedAt, | 26 | UpdatedAt: good.UpdatedAt, |
27 | }) | 27 | }) |
28 | } | 28 | } |
29 | + | ||
30 | + var dividendsOrders []*domain.DividendsOrder | ||
31 | + | ||
32 | + for _, dividendsOrderModel := range dividendsOrderModels { | ||
29 | dividendsOrderAmount, _ := decimal.NewFromFloatWithExponent(dividendsOrderModel.DividendsOrderAmount, -2).Float64() | 33 | dividendsOrderAmount, _ := decimal.NewFromFloatWithExponent(dividendsOrderModel.DividendsOrderAmount, -2).Float64() |
30 | - return &domain.DividendsOrder{ | 34 | + dividendsOrder := &domain.DividendsOrder{ |
31 | DividendsOrderId: dividendsOrderModel.DividendsOrderId, | 35 | DividendsOrderId: dividendsOrderModel.DividendsOrderId, |
32 | DividendsOrderNumber: dividendsOrderModel.DividendsOrderNumber, | 36 | DividendsOrderNumber: dividendsOrderModel.DividendsOrderNumber, |
33 | DividendsOriginalOrderNum: dividendsOrderModel.DividendsOriginalOrderNum, | 37 | DividendsOriginalOrderNum: dividendsOrderModel.DividendsOriginalOrderNum, |
@@ -38,7 +42,7 @@ func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel *model | @@ -38,7 +42,7 @@ func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel *model | ||
38 | Region: dividendsOrderModel.Region, | 42 | Region: dividendsOrderModel.Region, |
39 | CustomerName: dividendsOrderModel.CustomerName, | 43 | CustomerName: dividendsOrderModel.CustomerName, |
40 | Org: dividendsOrderModel.Org, | 44 | Org: dividendsOrderModel.Org, |
41 | - Goods: orderGoods, | 45 | + Goods: make([]*domain.OrderGood, 0), |
42 | Company: dividendsOrderModel.Company, | 46 | Company: dividendsOrderModel.Company, |
43 | CreatedAt: dividendsOrderModel.CreatedAt, | 47 | CreatedAt: dividendsOrderModel.CreatedAt, |
44 | DeletedAt: dividendsOrderModel.DeletedAt, | 48 | DeletedAt: dividendsOrderModel.DeletedAt, |
@@ -46,5 +50,35 @@ func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel *model | @@ -46,5 +50,35 @@ func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel *model | ||
46 | OperateTime: dividendsOrderModel.OperateTime, | 50 | OperateTime: dividendsOrderModel.OperateTime, |
47 | Operator: dividendsOrderModel.Operator, | 51 | Operator: dividendsOrderModel.Operator, |
48 | Remarks: dividendsOrderModel.Remarks, | 52 | Remarks: dividendsOrderModel.Remarks, |
49 | - }, nil | 53 | + } |
54 | + for _, orderGood := range orderGoods { | ||
55 | + if orderGood.CompanyId == dividendsOrder.Company.CompanyId && orderGood.DividendsOrderNumber == dividendsOrder.DividendsOrderNumber { | ||
56 | + dividendsOrder.Goods = append(dividendsOrder.Goods, orderGood) | ||
57 | + } | ||
58 | + } | ||
59 | + dividendsOrders = append(dividendsOrders, dividendsOrder) | ||
60 | + } | ||
61 | + | ||
62 | + return dividendsOrders, nil | ||
63 | + | ||
64 | + //return &domain.DividendsOrder{ | ||
65 | + // DividendsOrderId: dividendsOrderModel.DividendsOrderId, | ||
66 | + // DividendsOrderNumber: dividendsOrderModel.DividendsOrderNumber, | ||
67 | + // DividendsOriginalOrderNum: dividendsOrderModel.DividendsOriginalOrderNum, | ||
68 | + // DividendsOrderAmount: dividendsOrderAmount, | ||
69 | + // OrderTime: dividendsOrderModel.OrderTime, | ||
70 | + // DividendTime: dividendsOrderModel.DividendTime, | ||
71 | + // DividendStatus: dividendsOrderModel.DividendStatus, | ||
72 | + // Region: dividendsOrderModel.Region, | ||
73 | + // CustomerName: dividendsOrderModel.CustomerName, | ||
74 | + // Org: dividendsOrderModel.Org, | ||
75 | + // Goods: orderGoods, | ||
76 | + // Company: dividendsOrderModel.Company, | ||
77 | + // CreatedAt: dividendsOrderModel.CreatedAt, | ||
78 | + // DeletedAt: dividendsOrderModel.DeletedAt, | ||
79 | + // UpdatedAt: dividendsOrderModel.UpdatedAt, | ||
80 | + // OperateTime: dividendsOrderModel.OperateTime, | ||
81 | + // Operator: dividendsOrderModel.Operator, | ||
82 | + // Remarks: dividendsOrderModel.Remarks, | ||
83 | + //}, nil | ||
50 | } | 84 | } |
@@ -402,10 +402,10 @@ func (repository *DividendsOrderRepository) SaveMany(dividendsOrders []*domain.D | @@ -402,10 +402,10 @@ func (repository *DividendsOrderRepository) SaveMany(dividendsOrders []*domain.D | ||
402 | return nil, fmt.Errorf("分红订单关联的产品不存在") | 402 | return nil, fmt.Errorf("分红订单关联的产品不存在") |
403 | } | 403 | } |
404 | // 聚合分红订单 | 404 | // 聚合分红订单 |
405 | - if dividendsOrder, err := transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel, orderGoodModels); err != nil { | 405 | + if dividendsOrder, err := transform.TransformToDividendsOrderDomainModelFromPgModels([]*models.DividendsOrder{dividendsOrderModel}, orderGoodModels); err != nil { |
406 | return dividendsOrders, err | 406 | return dividendsOrders, err |
407 | } else { | 407 | } else { |
408 | - dividendsOrders = append(dividendsOrders, dividendsOrder) | 408 | + dividendsOrders = append(dividendsOrders, dividendsOrder...) |
409 | } | 409 | } |
410 | } | 410 | } |
411 | return dividendsOrdersSaved, nil | 411 | return dividendsOrdersSaved, nil |
@@ -488,14 +488,17 @@ func (repository *DividendsOrderRepository) BatchRemove(dividendsOrders []*domai | @@ -488,14 +488,17 @@ func (repository *DividendsOrderRepository) BatchRemove(dividendsOrders []*domai | ||
488 | if _, err := tx.Model(÷ndsOrderModels).WherePK().Delete(); err != nil { | 488 | if _, err := tx.Model(÷ndsOrderModels).WherePK().Delete(); err != nil { |
489 | return dividendsOrders, err | 489 | return dividendsOrders, err |
490 | } else { | 490 | } else { |
491 | + var dividendsOrderNumbers []string | ||
491 | for _, dividendsOrder := range dividendsOrders { | 492 | for _, dividendsOrder := range dividendsOrders { |
493 | + dividendsOrderNumbers = append(dividendsOrderNumbers, dividendsOrder.DividendsOrderNumber) | ||
494 | + } | ||
492 | // 删除订单产品 | 495 | // 删除订单产品 |
493 | var orderGoodModels []*models.OrderGood | 496 | var orderGoodModels []*models.OrderGood |
494 | orderGoodQuery := tx.Model(&orderGoodModels) | 497 | orderGoodQuery := tx.Model(&orderGoodModels) |
495 | if err := orderGoodQuery. | 498 | if err := orderGoodQuery. |
496 | - Where("company_id = ?", dividendsOrder.Company.CompanyId). | ||
497 | - Where("org_id = ?", dividendsOrder.Org.OrgId). | ||
498 | - Where("dividends_order_number = ?", dividendsOrder.DividendsOrderNumber). | 499 | + Where("company_id = ?", dividendsOrders[0].Company.CompanyId). |
500 | + Where("org_id = ?", dividendsOrders[0].Org.OrgId). | ||
501 | + Where("dividends_order_number in (?)", dividendsOrderNumbers). | ||
499 | Select(); err != nil { | 502 | Select(); err != nil { |
500 | return nil, err | 503 | return nil, err |
501 | } else { | 504 | } else { |
@@ -506,7 +509,6 @@ func (repository *DividendsOrderRepository) BatchRemove(dividendsOrders []*domai | @@ -506,7 +509,6 @@ func (repository *DividendsOrderRepository) BatchRemove(dividendsOrders []*domai | ||
506 | } | 509 | } |
507 | } | 510 | } |
508 | } | 511 | } |
509 | - } | ||
510 | return dividendsOrders, nil | 512 | return dividendsOrders, nil |
511 | } | 513 | } |
512 | 514 | ||
@@ -548,7 +550,11 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte | @@ -548,7 +550,11 @@ func (repository *DividendsOrderRepository) FindOne(queryOptions map[string]inte | ||
548 | return nil, fmt.Errorf("分红订单关联的产品不存在") | 550 | return nil, fmt.Errorf("分红订单关联的产品不存在") |
549 | } | 551 | } |
550 | // 聚合分红订单 | 552 | // 聚合分红订单 |
551 | - return transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel, orderGoodModels) | 553 | + result, err := transform.TransformToDividendsOrderDomainModelFromPgModels([]*models.DividendsOrder{dividendsOrderModel}, orderGoodModels) |
554 | + if err != nil { | ||
555 | + return nil, fmt.Errorf("分红订单不存在") | ||
556 | + } | ||
557 | + return result[0], nil | ||
552 | } | 558 | } |
553 | } | 559 | } |
554 | 560 | ||
@@ -591,26 +597,28 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa | @@ -591,26 +597,28 @@ func (repository *DividendsOrderRepository) Find(queryOptions map[string]interfa | ||
591 | return 0, dividendsOrders, err | 597 | return 0, dividendsOrders, err |
592 | } else { | 598 | } else { |
593 | if count > 0 { | 599 | if count > 0 { |
600 | + var dividendsOrderNumbers []string | ||
594 | for _, dividendsOrderModel := range dividendsOrderModels { | 601 | for _, dividendsOrderModel := range dividendsOrderModels { |
602 | + dividendsOrderNumbers = append(dividendsOrderNumbers, dividendsOrderModel.DividendsOrderNumber) | ||
603 | + } | ||
595 | //获取订单产品 | 604 | //获取订单产品 |
596 | var orderGoodModels []*models.OrderGood | 605 | var orderGoodModels []*models.OrderGood |
597 | orderGoodModelQuery := tx.Model(&orderGoodModels) | 606 | orderGoodModelQuery := tx.Model(&orderGoodModels) |
598 | if err := orderGoodModelQuery. | 607 | if err := orderGoodModelQuery. |
599 | - Where("company_id = ?", dividendsOrderModel.Company.CompanyId). | ||
600 | - Where("org_id = ?", dividendsOrderModel.Org.OrgId). | ||
601 | - Where("dividends_order_number = ?", dividendsOrderModel.DividendsOrderNumber). | 608 | + Where("company_id = ?", dividendsOrderModels[0].Company.CompanyId). |
609 | + //Where("org_id = ?", dividendsOrderModel.Org.OrgId). | ||
610 | + Where("dividends_order_number in (?)", dividendsOrderNumbers). | ||
602 | Select(); err != nil { | 611 | Select(); err != nil { |
603 | - log.Logger.Error("分红订单关联的产品不存在", map[string]interface{}{ | ||
604 | - "dividendsOrderModel": dividendsOrderModel, | ||
605 | - }) | 612 | + //log.Logger.Error("分红订单关联的产品不存在", map[string]interface{}{ |
613 | + // "dividendsOrderModel": dividendsOrderModel, | ||
614 | + //}) | ||
606 | return 0, nil, fmt.Errorf("分红订单关联的产品不存在") | 615 | return 0, nil, fmt.Errorf("分红订单关联的产品不存在") |
607 | } | 616 | } |
608 | // 聚合分红订单 | 617 | // 聚合分红订单 |
609 | - if dividendsOrder, err := transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel, orderGoodModels); err != nil { | 618 | + if dividendsOrder, err := transform.TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModels, orderGoodModels); err != nil { |
610 | return 0, dividendsOrders, err | 619 | return 0, dividendsOrders, err |
611 | } else { | 620 | } else { |
612 | - dividendsOrders = append(dividendsOrders, dividendsOrder) | ||
613 | - } | 621 | + dividendsOrders = append(dividendsOrders, dividendsOrder...) |
614 | } | 622 | } |
615 | } | 623 | } |
616 | return int64(count), dividendsOrders, nil | 624 | return int64(count), dividendsOrders, nil |
1 | package utils | 1 | package utils |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | - "fmt" | ||
5 | "strconv" | 4 | "strconv" |
6 | "time" | 5 | "time" |
7 | ) | 6 | ) |
@@ -48,6 +47,6 @@ func TransformTimestampToTime(timeStamp int64) time.Time { | @@ -48,6 +47,6 @@ func TransformTimestampToTime(timeStamp int64) time.Time { | ||
48 | ipart, _ := strconv.ParseInt(tIpartStr, 10, 64) | 47 | ipart, _ := strconv.ParseInt(tIpartStr, 10, 64) |
49 | //decpart, _ := strconv.ParseInt(tDecpartStr, 10, 64) | 48 | //decpart, _ := strconv.ParseInt(tDecpartStr, 10, 64) |
50 | myTime := time.Unix(ipart, 0) | 49 | myTime := time.Unix(ipart, 0) |
51 | - fmt.Println(myTime) | 50 | + //(myTime) |
52 | return time.Date(myTime.Year(), myTime.Month(), myTime.Day(), myTime.Hour(), myTime.Minute(), myTime.Second(), 0, time.Local) | 51 | return time.Date(myTime.Year(), myTime.Month(), myTime.Day(), myTime.Hour(), myTime.Minute(), myTime.Second(), 0, time.Local) |
53 | } | 52 | } |
@@ -99,19 +99,19 @@ func NewBeegoLog(conf LoggerConfig) *BeegoLog { | @@ -99,19 +99,19 @@ func NewBeegoLog(conf LoggerConfig) *BeegoLog { | ||
99 | confByte, _ := json.Marshal(conf) | 99 | confByte, _ := json.Marshal(conf) |
100 | err := logger.SetLogger(logs.AdapterFile, string(confByte)) | 100 | err := logger.SetLogger(logs.AdapterFile, string(confByte)) |
101 | if err != nil { | 101 | if err != nil { |
102 | - fmt.Println(err.Error()) | 102 | + (err.Error()) |
103 | return nil | 103 | return nil |
104 | } | 104 | } |
105 | } else if constant.LOG_TYPE == "es" { // 日志存储到ES | 105 | } else if constant.LOG_TYPE == "es" { // 日志存储到ES |
106 | err := logger.SetLogger(logs.AdapterEs, `{"dsn":"http://192.168.100.222:9200/","level":7}`) | 106 | err := logger.SetLogger(logs.AdapterEs, `{"dsn":"http://192.168.100.222:9200/","level":7}`) |
107 | if err != nil { | 107 | if err != nil { |
108 | - fmt.Println(err.Error()) | 108 | + (err.Error()) |
109 | return nil | 109 | return nil |
110 | } | 110 | } |
111 | } else { // 日志输出到控制台 | 111 | } else { // 日志输出到控制台 |
112 | err := logger.SetLogger(logs.AdapterConsole, `{"level":7,"color":true}`) | 112 | err := logger.SetLogger(logs.AdapterConsole, `{"level":7,"color":true}`) |
113 | if err != nil { | 113 | if err != nil { |
114 | - fmt.Println(err.Error()) | 114 | + (err.Error()) |
115 | return nil | 115 | return nil |
116 | } | 116 | } |
117 | } | 117 | } |
-
请 注册 或 登录 后发表评论