作者 陈志颖

fix:批量删除分红订单和分红退货单

... ... @@ -558,19 +558,21 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
var dividendsOrderCommands = make(map[string]*command.CreateDividendsOrderCommand)
for i, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData {
hashValue := md5.Sum([]byte(dividendsOrder.OriginalOrderNum + dividendsOrder.OrderTime))
hashValue := md5.Sum([]byte(dividendsOrder.OriginalOrderNum))
hashString := hex.EncodeToString(hashValue[:])
if _, ok := dividendsOrderCommands[hashString]; !ok {
// 订单日期时间格式转换
timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local)
if err != nil {
tmpRow := &domain.FailInfo{
FailReason: "无效的订单日期",
}
tmpRow.ImportDividendsOrderData = &dividendsOrder
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
// 订单日期时间格式转换
timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local)
if err != nil {
tmpRow := &domain.FailInfo{
FailReason: "无效的订单日期",
}
tmpRow.ImportDividendsOrderData = &dividendsOrder
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
}
if _, ok := dividendsOrderCommands[hashString]; !ok {
// 产品相关:产品名称,产品数量、产品价格、费用
quantity, err := strconv.ParseFloat(dividendsOrder.OrderGoodQuantity, 64)
... ... @@ -670,6 +672,29 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
}
}
log.Logger.Info("订单时间1:", map[string]interface{}{
"timeValue": strconv.FormatInt(timeValue.Local().UnixNano()/1e6, 10),
})
log.Logger.Info("订单时间2:", map[string]interface{}{
"timeValue": dividendsOrderCommands[hashString].OrderTime,
})
if strconv.FormatInt(timeValue.Local().UnixNano()/1e6, 10) != dividendsOrderCommands[hashString].OrderTime {
log.Logger.Info("订单:", map[string]interface{}{
"order": dividendsOrder,
})
tmpRow := &domain.FailInfo{
FailReason: "同一笔订单的订单时间必须相同",
ImportDividendsOrderData: &dividendsOrder,
}
aggregateErrorList = append(aggregateErrorList, tmpRow)
log.Logger.Info("聚合订单错误:", map[string]interface{}{
"aggregateErrorList": aggregateErrorList,
})
continue
}
dividendsOrderCommands[hashString].OrderGoods = append(dividendsOrderCommands[hashString].OrderGoods, command.OrderGoods{
OrderGoodId: "0",
OrderGoodAmount: 0,
... ... @@ -1127,6 +1152,7 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba
}
if count, dividendsOrders, err := dividendsOrderRepository.Find(map[string]interface{}{
"dividendsOrderIds": dividendsOrderIds,
"offsetLimit": false,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ...
... ... @@ -581,7 +581,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
var dividendsReturnedOrderCommands = make(map[string]*command.CreateDividendsReturnedOrderCommand)
for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData {
hashValue := md5.Sum([]byte(dividendsReturnedOrder.OriginalOrderNum + dividendsReturnedOrder.OrderTime))
hashValue := md5.Sum([]byte(dividendsReturnedOrder.OriginalOrderNum))
hashString := hex.EncodeToString(hashValue[:])
if _, ok := dividendsReturnedOrderCommands[hashString]; !ok {
// 订单日期时间格式转换
... ... @@ -656,6 +656,17 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
LineNumbers: []int{i}, // 记录行号
}
} else { // 聚合同一笔订单产品
// 订单日期时间格式转换
timeValue, err := time.ParseInLocation("2006/01/02", dividendsReturnedOrder.OrderTime, time.Local)
if err != nil {
tmpRow := &domain.FailReturnedInfo{
FailReason: "无效的订单日期",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
}
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
}
// 产品相关:产品名称,退货数量、退货价格
quantity, err := strconv.ParseFloat(dividendsReturnedOrder.OrderGoodQuantity, 64)
if err != nil {
... ... @@ -677,6 +688,15 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
continue
}
if strconv.FormatInt(timeValue.Local().UnixNano()/1e6, 10) != dividendsReturnedOrderCommands[hashString].OrderTime {
tmpRow := &domain.FailReturnedInfo{
FailReason: "同一笔退货单的订单时间必须相同",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
}
aggregateErrorList = append(aggregateErrorList, tmpRow)
continue
}
dividendsReturnedOrderCommands[hashString].OrderGoods = append(dividendsReturnedOrderCommands[hashString].OrderGoods, command.OrderGoods{
OrderGoodId: "0",
OrderGoodAmount: 0,
... ... @@ -1113,6 +1133,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) BatchRemoveD
}
if count, dividendsReturnedOrders, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{
"dividendsReturnedOrderIds": dividendsReturnedOrderIds,
"offsetLimit": false,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ...