...
|
...
|
@@ -412,15 +412,15 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
|
// 返回信息表头定义
|
|
|
var tableHeader = map[string]interface{}{
|
|
|
"failReason": "错误详情",
|
|
|
"originalOrderNum": "来源单号",
|
|
|
"dividendsReturnedCustomerName": "客户名称",
|
|
|
"orderGoodName": "产品名称",
|
|
|
"dividendsReturnedDate": "退货日期",
|
|
|
"regionName": "订单日期",
|
|
|
"orderGoodPrice": "订单区域",
|
|
|
"orderGoodQuantity": "退货数量",
|
|
|
"cooperationContractNumber": "退货价格",
|
|
|
"orderTime": "项目合约编号",
|
|
|
"originalOrderNum": "来源单号", // 0
|
|
|
"dividendsReturnedCustomerName": "客户名称", // 1
|
|
|
"orderGoodName": "产品名称", // 2
|
|
|
"dividendsReturnedDate": "退货日期", // 3
|
|
|
"orderTime": "订单日期", // 4
|
|
|
"regionName": "订单区域", // 5
|
|
|
"orderGoodQuantity": "退货数量", // 6
|
|
|
"orderGoodPrice": "退货价格", // 7
|
|
|
"cooperationContractNumber": "项目合约编号", // 8
|
|
|
}
|
|
|
|
|
|
/***************************************************** 空文件校验 ***************************************************/
|
...
|
...
|
@@ -446,7 +446,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
|
v := reflect.ValueOf(dividendsReturnedOrder)
|
|
|
for k := 0; k < t.NumField(); k++ {
|
|
|
fmt.Println("name:", fmt.Sprintf("%+v", t.Field(k).Name), ", value:", fmt.Sprintf("%v", v.Field(k).Interface()))
|
|
|
if t.Field(k).Name != "RegionName" && t.Field(k).Name != "CooperationContractNumber" {
|
|
|
if t.Field(k).Name != "RegionName" {
|
|
|
if v.Field(k).Interface() == "" {
|
|
|
col := strconv.Itoa(k + 1)
|
|
|
nullCell = append(nullCell, col)
|
...
|
...
|
@@ -581,10 +581,9 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
|
var dividendsReturnedOrderCommands = make(map[string]*command.CreateDividendsReturnedOrderCommand)
|
|
|
|
|
|
for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData {
|
|
|
hashValue := md5.Sum([]byte(dividendsReturnedOrder.OriginalOrderNum))
|
|
|
hashValue := md5.Sum([]byte(dividendsReturnedOrder.OriginalOrderNum + dividendsReturnedOrder.OrderTime))
|
|
|
hashString := hex.EncodeToString(hashValue[:])
|
|
|
if _, ok := dividendsReturnedOrderCommands[hashString]; !ok {
|
|
|
|
|
|
// 订单日期时间格式转换
|
|
|
timeValue, err := time.ParseInLocation("2006/01/02", dividendsReturnedOrder.OrderTime, time.Local)
|
|
|
if err != nil {
|
...
|
...
|
@@ -600,7 +599,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
|
timeValue2, err := time.ParseInLocation("2006/01/02", dividendsReturnedOrder.DividendsReturnedDate, time.Local)
|
|
|
if err != nil {
|
|
|
tmpRow := &domain.FailReturnedInfo{
|
|
|
FailReason: "无效的订单日期",
|
|
|
FailReason: "无效的退货日期",
|
|
|
ImportDividendsReturnedOrderData: ÷ndsReturnedOrder,
|
|
|
}
|
|
|
aggregateErrorList = append(aggregateErrorList, tmpRow)
|
...
|
...
|
@@ -617,6 +616,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
|
aggregateErrorList = append(aggregateErrorList, tmpRow)
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
price, err := strconv.ParseFloat(dividendsReturnedOrder.OrderGoodPrice, 64)
|
|
|
if err != nil {
|
|
|
tmpRow := &domain.FailReturnedInfo{
|
...
|
...
|
@@ -666,6 +666,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
|
aggregateErrorList = append(aggregateErrorList, tmpRow)
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
price, err := strconv.ParseFloat(dividendsReturnedOrder.OrderGoodPrice, 64)
|
|
|
if err != nil {
|
|
|
tmpRow := &domain.FailReturnedInfo{
|
...
|
...
|
@@ -782,14 +783,6 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
|
|
|
|
// 批量导入创建退货单
|
|
|
for i, dividendsReturnedOrder := range createDividendsReturnedOrderCommands {
|
|
|
// 生成退货订单号
|
|
|
//dividendsReturnedOrderNumber, err := dividendsReturnedOrderDao.GenerateDividendsReturnedOrderNumber(map[string]interface{}{
|
|
|
// "companyId": importDividendsReturnedOrderCommand.CompanyId,
|
|
|
//})
|
|
|
//if err != nil {
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
//}
|
|
|
|
|
|
// 生成分红订单号
|
|
|
dividendsReturnedOrderNumber, err := dividendsReturnedOrder.GenerateSpecificDividendsReturnedOrderNumber(int64(count), time.Time{}, int64(i))
|
|
|
if err != nil {
|
...
|
...
|
@@ -831,16 +824,16 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
|
returnedTime := utils.TransformTimestampToTime(returnedTimeInt)
|
|
|
|
|
|
// 校验退货订单编号是否唯一
|
|
|
numberAvailable, err3 := dividendsReturnedOrderDao.CheckDividendsReturnedOrderNumberAvailable(map[string]interface{}{
|
|
|
"companyId": importDividendsReturnedOrderCommand.CompanyId,
|
|
|
"dividendsReturnedOrderNumber": dividendsReturnedOrderNumber,
|
|
|
})
|
|
|
if err3 != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())
|
|
|
}
|
|
|
if !numberAvailable {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增分红订单异常")
|
|
|
}
|
|
|
//numberAvailable, err3 := dividendsReturnedOrderDao.CheckDividendsReturnedOrderNumberAvailable(map[string]interface{}{
|
|
|
// "companyId": importDividendsReturnedOrderCommand.CompanyId,
|
|
|
// "dividendsReturnedOrderNumber": dividendsReturnedOrderNumber,
|
|
|
//})
|
|
|
//if err3 != nil {
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())
|
|
|
//}
|
|
|
//if !numberAvailable {
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增分红订单异常")
|
|
|
//}
|
|
|
|
|
|
// 新增订单产品
|
|
|
var orderGoods []*domain.OrderGood
|
...
|
...
|
@@ -856,7 +849,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
|
}
|
|
|
}
|
|
|
if !contractNumberExist {
|
|
|
orderGoodErrMap[dividendsReturnedOrder.OrderGoods[j].LineNumber] = "订单产品关联的共创合约不存在"
|
|
|
orderGoodErrMap[dividendsReturnedOrder.OrderGoods[j].LineNumber] = "退货单产品关联的共创合约不存在"
|
|
|
continue
|
|
|
}
|
|
|
|
...
|
...
|
@@ -909,8 +902,9 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide |
|
|
UpdatedAt: time.Time{},
|
|
|
})
|
|
|
|
|
|
// 计算分红订单金额
|
|
|
dividendsReturnedOrderAmount = dividendsReturnedOrderAmount + orderGood.OrderGoodAmount
|
|
|
// 计算分红退货单金额
|
|
|
dividendsReturnedOrderAmount, _ = decimal.NewFromFloat(dividendsReturnedOrderAmount).Add(decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity))).Float64()
|
|
|
//dividendsReturnedOrderAmount + orderGood.OrderGoodAmount
|
|
|
}
|
|
|
|
|
|
if len(orderGoodErrMap) > 0 {
|
...
|
...
|
|