作者 唐旭辉

Merge branch 'dev' into test

... ... @@ -34,6 +34,7 @@ func (dao OrderBaseDao) CheckOrderExist(companyId int64, orderCode string,
query := tx.Model(&models.OrderBase{}).
Where("company_id=?", companyId).
Where("order_code=?", orderCode).
Where("delivery_code=?", deliveryCode).
Where("partner_id=?", partnerId).
Where(`partner_category @>'{"id":?}'`, partnerCategory).
Where("id<>?", notId)
... ...
... ... @@ -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
}
// 新增失败记录
... ...
... ... @@ -6,10 +6,6 @@ import (
)
func init() {
// 导入相关
beego.Router("/fileImportTemplate", &controllers.OrderInfoController{}, "POST:DownloadTemplate") // 下载导入模板
beego.Router("/fileImport", &controllers.OrderInfoController{}, "POST:ImportOrderFromExcel") // 导入订单数据
adminRouter := beego.NewNamespace("/v1",
beego.NSNamespace("/auth",
beego.NSRouter("/login", &controllers.AdminLoginController{}, "POST:Login"),
... ... @@ -45,6 +41,8 @@ func init() {
beego.NSRouter("/actual/del", &controllers.OrderInfoController{}, "POST:RemoveOrderReal"), // 删除实际订单
beego.NSRouter("/actual/update", &controllers.OrderInfoController{}, "POST:UpdateOrderReal"), // 新增实际订单
beego.NSRouter("/actual/close", &controllers.OrderInfoController{}, "POST:OrderDisable"),
beego.NSRouter("/fileImportTemplate", &controllers.OrderInfoController{}, "POST:DownloadTemplate"), // 下载导入模板
beego.NSRouter("/fileImport", &controllers.OrderInfoController{}, "POST:ImportOrderFromExcel"), // 导入订单数据
),
beego.NSNamespace("/common",
beego.NSRouter("/partner", &controllers.CommonController{}, "POST:GetPartnerList"),
... ...