...
|
...
|
@@ -6,6 +6,7 @@ import ( |
|
|
"errors"
|
|
|
"fmt"
|
|
|
"github.com/beego/beego/v2/client/httplib"
|
|
|
"os"
|
|
|
"path"
|
|
|
"regexp"
|
|
|
"strconv"
|
...
|
...
|
@@ -659,6 +660,12 @@ func (c *OrderInfoController) DownloadTemplate() { |
|
|
c.ResponseError(errors.New("类型编码错误"))
|
|
|
}
|
|
|
|
|
|
// 创建下载文件夹
|
|
|
mkErr := os.Mkdir("download", os.ModePerm)
|
|
|
if mkErr != nil {
|
|
|
fmt.Println(mkErr)
|
|
|
}
|
|
|
|
|
|
// 获取导入模板
|
|
|
req := httplib.Get("http://suplus-file-dev.fjmaimaimai.com/upload/file/2021010803305336443.xlsx")
|
|
|
err = req.ToFile(constant.IMPORT_EXCEL)
|
...
|
...
|
@@ -1064,10 +1071,36 @@ func (c *OrderInfoController) ImportOrderFromExcel() { |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 批量创建订单命令集
|
|
|
// 产品数量校验
|
|
|
productNumberError := make([]interface{}, 0)
|
|
|
|
|
|
// 批量创建订单命令集和产品数量校验
|
|
|
var createOrderCommands []*orderCmd.CreateOrderCommand
|
|
|
for _, orderCommand := range orderCommands {
|
|
|
createOrderCommands = append(createOrderCommands, orderCommand)
|
|
|
if len(orderCommand.Goods) > 50 { // 产品数量校验
|
|
|
for _, line := range orderCommand.LineNumbers {
|
|
|
var tmpRow []string
|
|
|
tmpRow = append(tmpRow, "单笔订单产品超过50种") // 错误信息
|
|
|
s := strconv.Itoa(line + 1)
|
|
|
tmpRow = append(tmpRow, s) // 行号
|
|
|
tmpRow = append(tmpRow, rows[line]...) // 错误行数据
|
|
|
productNumberError = append(productNumberError, tmpRow)
|
|
|
}
|
|
|
} else {
|
|
|
createOrderCommands = append(createOrderCommands, orderCommand)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if len(productNumberError) > 0 {
|
|
|
ret = map[string]interface{}{
|
|
|
"successCount": 0,
|
|
|
"fail": map[string]interface{}{
|
|
|
"tableHeader": tableHeader,
|
|
|
"tableData": productNumberError,
|
|
|
},
|
|
|
}
|
|
|
c.ResponseData(ret)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 新增失败记录
|
...
|
...
|
|