正在显示
3 个修改的文件
包含
59 行增加
和
23 行删除
@@ -235,9 +235,12 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) ( | @@ -235,9 +235,12 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) ( | ||
235 | }); err != nil { | 235 | }); err != nil { |
236 | return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | 236 | return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) |
237 | } | 237 | } |
238 | - | 238 | + goodNames := []string{} |
239 | + for _, v := range cmd.Goods { | ||
240 | + goodNames = append(goodNames, v.GoodName) | ||
241 | + } | ||
239 | if ok, err := orderBaseDao.CheckOrderExist(cmd.CompanyId, cmd.OrderCode, cmd.DeliveryCode, | 242 | if ok, err := orderBaseDao.CheckOrderExist(cmd.CompanyId, cmd.OrderCode, cmd.DeliveryCode, |
240 | - cmd.PartnerCategory, cmd.PartnerId, 0); err != nil { | 243 | + cmd.PartnerCategory, cmd.PartnerId, 0, goodNames); err != nil { |
241 | return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | 244 | return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) |
242 | } else if ok { | 245 | } else if ok { |
243 | return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单已存在") | 246 | return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单已存在") |
@@ -447,8 +450,13 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand) | @@ -447,8 +450,13 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand) | ||
447 | // return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单号已存在") | 450 | // return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单号已存在") |
448 | // } | 451 | // } |
449 | // } | 452 | // } |
453 | + goodNames := []string{} | ||
454 | + for _, v := range cmd.Goods { | ||
455 | + goodNames = append(goodNames, v.GoodName) | ||
456 | + } | ||
450 | //检查delivery_code是否重复 | 457 | //检查delivery_code是否重复 |
451 | - if ok, err := orderBaseDao.CheckOrderExist(cmd.CompanyId, cmd.OrderCode, cmd.DeliveryCode, cmd.PartnerCategory, cmd.PartnerId, cmd.Id); err != nil { | 458 | + if ok, err := orderBaseDao.CheckOrderExist(cmd.CompanyId, cmd.OrderCode, cmd.DeliveryCode, |
459 | + cmd.PartnerCategory, cmd.PartnerId, cmd.Id, goodNames); err != nil { | ||
452 | return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | 460 | return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) |
453 | } else if ok { | 461 | } else if ok { |
454 | return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单已存在") | 462 | return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单已存在") |
@@ -1056,10 +1064,13 @@ func (service OrderInfoService) CreateNewOrderByImport(createOrderCommands []*co | @@ -1056,10 +1064,13 @@ func (service OrderInfoService) CreateNewOrderByImport(createOrderCommands []*co | ||
1056 | errorDataList = append(errorDataList, row) | 1064 | errorDataList = append(errorDataList, row) |
1057 | continue | 1065 | continue |
1058 | } | 1066 | } |
1059 | - | 1067 | + goodNames := []string{} |
1068 | + for _, v := range cmd.Goods { | ||
1069 | + goodNames = append(goodNames, v.GoodName) | ||
1070 | + } | ||
1060 | // 批量校验订单 | 1071 | // 批量校验订单 |
1061 | if ok, err := orderBaseDao.CheckOrderExist(cmd.CompanyId, cmd.OrderCode, cmd.DeliveryCode, | 1072 | if ok, err := orderBaseDao.CheckOrderExist(cmd.CompanyId, cmd.OrderCode, cmd.DeliveryCode, |
1062 | - cmd.PartnerCategory, cmd.PartnerId, 0); err != nil { | 1073 | + cmd.PartnerCategory, cmd.PartnerId, 0, goodNames); err != nil { |
1063 | row := &domain.ImportInfo{ | 1074 | row := &domain.ImportInfo{ |
1064 | Error: lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()), | 1075 | Error: lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()), |
1065 | LineNumbers: cmd.LineNumbers, // 错误影响的行 | 1076 | LineNumbers: cmd.LineNumbers, // 错误影响的行 |
@@ -28,16 +28,19 @@ func NewOrderBaseDao(transactionContext *transaction.TransactionContext) (*Order | @@ -28,16 +28,19 @@ func NewOrderBaseDao(transactionContext *transaction.TransactionContext) (*Order | ||
28 | //@orderCode 订单号 | 28 | //@orderCode 订单号 |
29 | //@deliveryCode 发货单号 | 29 | //@deliveryCode 发货单号 |
30 | //@partnerCategoryCode 合伙人类型编号 | 30 | //@partnerCategoryCode 合伙人类型编号 |
31 | +//@goodNames 货品名称列表 | ||
31 | func (dao OrderBaseDao) CheckOrderExist(companyId int64, orderCode string, | 32 | func (dao OrderBaseDao) CheckOrderExist(companyId int64, orderCode string, |
32 | - deliveryCode string, partnerCategory int64, partnerId int64, notId int64) (bool, error) { | 33 | + deliveryCode string, partnerCategory int64, partnerId int64, notId int64, goodNames []string) (bool, error) { |
33 | tx := dao.transactionContext.GetDB() | 34 | tx := dao.transactionContext.GetDB() |
34 | query := tx.Model(&models.OrderBase{}). | 35 | query := tx.Model(&models.OrderBase{}). |
36 | + Join("JOIN order_good ON order_base.id=order_good.order_id"). | ||
35 | Where("company_id=?", companyId). | 37 | Where("company_id=?", companyId). |
36 | Where("order_code=?", orderCode). | 38 | Where("order_code=?", orderCode). |
37 | Where("delivery_code=?", deliveryCode). | 39 | Where("delivery_code=?", deliveryCode). |
38 | Where("partner_id=?", partnerId). | 40 | Where("partner_id=?", partnerId). |
39 | Where(`partner_category @>'{"id":?}'`, partnerCategory). | 41 | Where(`partner_category @>'{"id":?}'`, partnerCategory). |
40 | - Where("id<>?", notId) | 42 | + Where("id<>?", notId). |
43 | + WhereIn("order_good.good_name in(?)", goodNames) | ||
41 | ok, err := query.Exists() | 44 | ok, err := query.Exists() |
42 | return ok, err | 45 | return ok, err |
43 | } | 46 | } |
@@ -709,7 +709,7 @@ func (c *OrderInfoController) ImportOrderFromExcel() { | @@ -709,7 +709,7 @@ func (c *OrderInfoController) ImportOrderFromExcel() { | ||
709 | // c.ResponseError(errors.New("json数据解析失败")) | 709 | // c.ResponseError(errors.New("json数据解析失败")) |
710 | //} | 710 | //} |
711 | 711 | ||
712 | - if typeCode != "PARTNER_ORDER_IMPORT" { | 712 | + if typeCode != "PARTNER_ORDER_FILE" { |
713 | c.ResponseError(errors.New("类型编码错误")) | 713 | c.ResponseError(errors.New("类型编码错误")) |
714 | } | 714 | } |
715 | 715 | ||
@@ -987,6 +987,9 @@ func (c *OrderInfoController) ImportOrderFromExcel() { | @@ -987,6 +987,9 @@ func (c *OrderInfoController) ImportOrderFromExcel() { | ||
987 | // 创建订单服务 | 987 | // 创建订单服务 |
988 | orderSrv := orderService.NewOrderInfoService(nil) | 988 | orderSrv := orderService.NewOrderInfoService(nil) |
989 | 989 | ||
990 | + // 合伙人检索错误 | ||
991 | + partnerDataList := make([]interface{}, 0) | ||
992 | + | ||
990 | // 聚合订单产品 | 993 | // 聚合订单产品 |
991 | var orderCommands = make(map[string]*orderCmd.CreateOrderCommand, 0) | 994 | var orderCommands = make(map[string]*orderCmd.CreateOrderCommand, 0) |
992 | for i, row := range rows { | 995 | for i, row := range rows { |
@@ -1028,27 +1031,35 @@ func (c *OrderInfoController) ImportOrderFromExcel() { | @@ -1028,27 +1031,35 @@ func (c *OrderInfoController) ImportOrderFromExcel() { | ||
1028 | 1031 | ||
1029 | // 获取partnerId | 1032 | // 获取partnerId |
1030 | var partnerInfo *domain.PartnerInfo | 1033 | var partnerInfo *domain.PartnerInfo |
1031 | - partnerInfo, err = orderSrv.GetPartnerIdByCodeAndCategory(orderQuery.GetPartnerIdQuery{ | 1034 | + orderQueryData := orderQuery.GetPartnerIdQuery{ |
1032 | Code: row[4], | 1035 | Code: row[4], |
1033 | PartnerCategory: 0, | 1036 | PartnerCategory: 0, |
1034 | CompanyId: companyId, | 1037 | CompanyId: companyId, |
1035 | - }) | ||
1036 | - if err != nil { | ||
1037 | - | 1038 | + } |
1039 | + // 1: 事业合伙、2: 业务合伙、3: 研发合伙、4: 业务-产品应用合伙 | ||
1040 | + switch row[6] { | ||
1041 | + case "事业合伙": | ||
1042 | + orderQueryData.PartnerCategory = 1 | ||
1043 | + case "业务合伙": | ||
1044 | + orderQueryData.PartnerCategory = 2 | ||
1045 | + case "研发合伙": | ||
1046 | + orderQueryData.PartnerCategory = 3 | ||
1047 | + case "业务-产品应用合伙": | ||
1048 | + orderQueryData.PartnerCategory = 4 | ||
1049 | + default: | ||
1050 | + orderQueryData.PartnerCategory = 0 | ||
1051 | + } | ||
1052 | + partnerInfo, err = orderSrv.GetPartnerIdByCodeAndCategory(orderQueryData) | ||
1053 | + if err != nil || partnerInfo == nil { // 检索合伙人错误 | ||
1054 | + var tmpRow []string | ||
1055 | + tmpRow = append(tmpRow, err.Error()) // 错误信息 | ||
1056 | + s := strconv.Itoa(i + 1) | ||
1057 | + tmpRow = append(tmpRow, s) // 行号 | ||
1058 | + tmpRow = append(tmpRow, row...) // 错误行数据 | ||
1059 | + partnerDataList = append(partnerDataList, tmpRow) | ||
1038 | } | 1060 | } |
1039 | if partnerInfo != nil { | 1061 | if partnerInfo != nil { |
1040 | orderCommands[hashString].PartnerId = partnerInfo.Partner.Id | 1062 | orderCommands[hashString].PartnerId = partnerInfo.Partner.Id |
1041 | - // 1: 事业合伙、2: 业务合伙、3: 研发合伙、4: 业务-产品应用合伙 | ||
1042 | - switch row[6] { | ||
1043 | - case "事业合伙": | ||
1044 | - partnerInfo.PartnerCategory = 1 | ||
1045 | - case "业务合伙": | ||
1046 | - partnerInfo.PartnerCategory = 2 | ||
1047 | - case "研发合伙": | ||
1048 | - partnerInfo.PartnerCategory = 3 | ||
1049 | - case "业务-产品应用合伙": | ||
1050 | - partnerInfo.PartnerCategory = 4 | ||
1051 | - } | ||
1052 | } | 1063 | } |
1053 | } else { | 1064 | } else { |
1054 | //产品相关,8: 产品名称, 9: 数量, 10: 单价, 11: 合伙人分红比例 | 1065 | //产品相关,8: 产品名称, 9: 数量, 10: 单价, 11: 合伙人分红比例 |
@@ -1070,6 +1081,17 @@ func (c *OrderInfoController) ImportOrderFromExcel() { | @@ -1070,6 +1081,17 @@ func (c *OrderInfoController) ImportOrderFromExcel() { | ||
1070 | } | 1081 | } |
1071 | } | 1082 | } |
1072 | } | 1083 | } |
1084 | + if len(partnerDataList) > 0 { | ||
1085 | + ret = map[string]interface{}{ | ||
1086 | + "successCount": 0, | ||
1087 | + "fail": map[string]interface{}{ | ||
1088 | + "tableHeader": tableHeader, | ||
1089 | + "tableData": partnerDataList, | ||
1090 | + }, | ||
1091 | + } | ||
1092 | + c.ResponseData(ret) | ||
1093 | + return | ||
1094 | + } | ||
1073 | 1095 | ||
1074 | // 产品数量校验 | 1096 | // 产品数量校验 |
1075 | productNumberError := make([]interface{}, 0) | 1097 | productNumberError := make([]interface{}, 0) |
-
请 注册 或 登录 后发表评论