作者 唐旭辉

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/partnermg into dev

... ... @@ -19,10 +19,19 @@ type CreateOrderCommand struct {
//业务员抽成比例
SalesmanBonusPercent float64 `json:"salesmanBonusPercent"`
//货品
Goods []OrderGoodData `json:"goods"`
CompanyId int64 `json:"companyId"`
Goods []OrderGoodData `json:"goods"`
//公司id
CompanyId int64 `json:"companyId"`
//合伙人类型
PartnerCategory int64 `json:"partner_category"`
//行号-错误信息返回
LineNumbers []int `json:"lineNumber"`
//合伙人姓名
PartnerName string `json:"partnerName"`
//编号-错误信息返回
Code string `json:"code"`
//合伙人类型名称-错误信息返回
PartnerCategoryName string `json:"partnerCategoryName"`
}
func (postData *CreateOrderCommand) Valid() error {
... ...
... ... @@ -20,6 +20,8 @@ type OrderGoodData struct {
PartnerBonusPercent float64 `json:"partnerBonusPercent"`
//备注信息
Remark string `json:"remark"`
//行号-错误信息返回
LineNumber int `json:"lineNumber"`
}
func (postData OrderGoodData) Valid() error {
... ...
... ... @@ -18,8 +18,9 @@ type UpdateOrderCommand struct {
//订单类型
OrderType int `json:"orderType"`
//货品
Goods []OrderGoodData `json:"goods"`
CompanyId int64 `json:"companyId"`
Goods []OrderGoodData `json:"goods"`
//公司id
CompanyId int64 `json:"companyId"`
// 合伙人类型
PartnerCategory int64 `json:"partner_category"`
}
... ...
/**
@author: stevechan
@date: 2021/1/6
@note:
**/
package query
/**
* @Author SteveChan
* @Description //TODO 查询合伙人id
* @Date 23:18 2021/1/6
**/
type GetPartnerIdQuery struct {
Code string `json:"code"`
PartnerCategory int `json:"partnerCategory"`
CompanyId int64 `json:"companyId"`
}
... ...
/**
@author: stevechan
@date: 2021/1/6
@note:
**/
package query
/**
* @Author SteveChan
* @Description //TODO 查询产品id
* @Date 23:18 2021/1/6
**/
type GetProductIdQuery struct {
ProductName int64 `json:"productName"`
}
... ...
... ... @@ -941,3 +941,261 @@ func (service OrderInfoService) ListOrderForExcel(listOrderQuery query.ListOrder
}
return resultMaps, column, nil
}
/**
* @Author SteveChan
* @Description // 批量导入创建订单
* @Date 11:00 2021/1/7
* @Param
* @return
**/
func (service OrderInfoService) CreateNewOrderByImport(createOrderCommands []*command.CreateOrderCommand) ([]interface{}, error) {
// 事务初始化
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
err error
failureDataList []interface{} // 错误数据返回
)
// 循环校验命令
for _, cmd := range createOrderCommands {
if err = cmd.Valid(); err != nil {
// 返回信息 0: 订单号, 1: 发货单号, 2: 客户名称, 3: 订单区域, 4: 编号, 5: 合伙人, 6: 类型, 7: 业务抽成比例, 8: 产品名称, 9: 数量, 10: 单价, 11: 合伙人分红比例
row := []interface{}{
lib.ThrowError(lib.BUSINESS_ERROR, err.Error()), // 错误信息
cmd.LineNumbers, // 错误影响的行
}
failureDataList = append(failureDataList, row)
continue
}
}
// 开始事务
if err = transactionContext.StartTransaction(); err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
// 仓储、数据访问对象初始化
var (
orderBaseRepository domain.OrderBaseRepository
orderGoodRepository domain.OrderGoodRepository
PartnerInfoRepository domain.PartnerInfoRepository
categoryRepository domain.PartnerCategoryRepository
orderBaseDao *dao.OrderBaseDao
)
// 合伙人信息仓储初始化
if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
// 订单仓储初始化
if orderBaseRepository, err = factory.CreateOrderBaseRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
// 订单产品仓储初始化
if orderGoodRepository, err = factory.CreateOrderGoodRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
// 合伙人类型仓储初始化
if categoryRepository, err = factory.CreatePartnerCategoryRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
// 订单数据访问对象初始化
if orderBaseDao, err = factory.CreateOrderBaseDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
}
// 批量创建订单
for _, cmd := range createOrderCommands {
// 批量校验合伙人信息
var partnerData *domain.PartnerInfo
partnerData, err = PartnerInfoRepository.FindOne(domain.PartnerFindOneQuery{UserId: cmd.PartnerId})
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("检索合伙人数据失败"))
}
// 批量校验订单
if ok, err := orderBaseDao.CheckOrderExist(cmd.CompanyId, cmd.OrderCode, cmd.DeliveryCode,
cmd.PartnerCategory, cmd.PartnerId, 0); err != nil {
return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
} else if ok {
return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单已存在")
}
// 批量校验产品
var goodMap = map[string]int{}
for i := range cmd.Goods {
goodName := cmd.Goods[i].GoodName
if _, ok := goodMap[goodName]; ok {
return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单中货品重复已存在")
}
goodMap[goodName] = 1
}
newOrder := &domain.OrderBase{
OrderType: cmd.OrderType, OrderCode: cmd.OrderCode,
DeliveryCode: cmd.DeliveryCode,
Buyer: domain.Buyer{
BuyerName: cmd.BuyerName,
},
RegionInfo: domain.RegionInfo{
RegionName: cmd.OrderRegion,
},
PartnerId: cmd.PartnerId,
PartnerInfo: partnerData.Partner,
SalesmanBonusPercent: cmd.SalesmanBonusPercent,
CompanyId: cmd.CompanyId,
}
// 批量校验合伙人分类数据
var cmdPartnerCategoryOk bool
for _, v := range partnerData.PartnerCategoryInfos {
if v.Id == cmd.PartnerCategory {
_, categories, err := categoryRepository.Find(domain.PartnerCategoryFindQuery{
Ids: []int64{v.Id},
})
if err != nil {
e := fmt.Sprintf("获取合伙人分类数据失败:%s", err)
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
}
if len(categories) > 0 {
newOrder.PartnerCategory = categories[0]
cmdPartnerCategoryOk = true
}
break
}
}
if !cmdPartnerCategoryOk {
return nil, lib.ThrowError(lib.BUSINESS_ERROR, "合伙人类型选择错误")
}
// 订单产品分红核算
var orderGoods []domain.OrderGood
for _, good := range cmd.Goods {
m := domain.NewOrderGood()
m.OrderId = 0
m.GoodName = good.GoodName
m.PlanGoodNumber = good.PlanGoodNumber
m.Price = good.Price
m.PartnerBonusPercent = good.PartnerBonusPercent
m.Remark = good.Remark
m.CompanyId = cmd.CompanyId
err = m.Compute()
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的数值失败:%s", err))
}
err = m.CurrentBonusStatus.WartPayPartnerBonus(&m)
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的分红数值失败:%s", err))
}
orderGoods = append(orderGoods, m)
}
newOrder.Goods = orderGoods
err = newOrder.Compute()
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中合计的数值失败:%s", err))
}
// 保存订单数据
err = orderBaseRepository.Save(newOrder)
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("保存订单数据失败:%s", err))
}
for i := range newOrder.Goods {
newOrder.Goods[i].OrderId = newOrder.Id
}
// 保存订单产品
err = orderGoodRepository.Save(orderGoods)
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("保存订单中的商品数据失败:%s", err))
}
newOrder.Goods = orderGoods
}
if len(failureDataList) == 0 {
// 完成事务
err = transactionContext.CommitTransaction()
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
return failureDataList, nil
}
return failureDataList, nil
}
/**
* @Author SteveChan
* @Description // 根据合伙人编号和合伙人类型获取合伙人id
* @Date 23:15 2021/1/6
* @Param
* @return
**/
func (service OrderInfoService) GetPartnerIdByCodeAndCategory(getPartnerIdQuery query.GetPartnerIdQuery) (*domain.PartnerInfo, error) {
// 事务初始化
var (
transactionContext, _ = factory.CreateTransactionContext(nil)
err error
partnerData *domain.PartnerInfo
)
// 开始事务
if err = transactionContext.StartTransaction(); err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
// 收尾
defer func() {
transactionContext.RollbackTransaction()
}()
// 仓储、数据访问对象初始化
var (
PartnerInfoRepository domain.PartnerInfoRepository
)
// 合伙人信息仓储初始化
if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
//var partnerData *domain.PartnerInfo
partnerData, err = PartnerInfoRepository.FindOne(domain.PartnerFindOneQuery{
CompanyId: getPartnerIdQuery.CompanyId,
Code: getPartnerIdQuery.Code,
PartnerCategory: getPartnerIdQuery.PartnerCategory,
})
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("检索合伙人数据失败"))
}
// 完成事务
err = transactionContext.CommitTransaction()
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
return partnerData, nil
}
... ...
... ... @@ -280,7 +280,13 @@ func (service UsersService) GetUserList(queryOption query.UserListQuery) (int, [
return cnt, result, nil
}
//buildGetUserList 组装构建前端需要的用户列表数据
/**
* @Author SteveChan
* @Description // 组装构建前端需要的用户列表数据
* @Date 00:22 2021/1/8
* @Param
* @return
**/
func (service UsersService) buildGetUserList(usersData []domain.Users, permissionData []domain.AdminPermission) []map[string]interface{} {
result := make([]map[string]interface{}, 0, len(usersData))
permissionMap := map[int64]domain.AdminPermission{}
... ... @@ -313,9 +319,11 @@ func (service UsersService) buildGetUserList(usersData []domain.Users, permissio
"permission": permissionTypes,
"isAdmin": 0,
"partnership": len(usersData[i].AccessPartners),
"isSenior": usersData[i].IsSenior,
}
if usersData[i].IsSuperAdmin() {
m["isAdmin"] = 1
m["name"] = m["name"].(string) + "(管理员)"
}
result = append(result, m)
}
... ...
... ... @@ -14,8 +14,8 @@ var KafkaCfg KafkaConfig
func init() {
KafkaCfg = KafkaConfig{
Servers: []string{"127.0.0.1:9092"},
ConsumerId: "partnermg_local",
Servers: []string{"106.52.15.41:9092"},
ConsumerId: "partnermg_dev",
}
if os.Getenv("KAFKA_HOST") != "" {
kafkaHost := os.Getenv("KAFKA_HOST")
... ...
... ... @@ -84,7 +84,8 @@ type OrderGood struct {
CompanyId int64 `json:"companyId"`
//原因备注
RemarkReason OrderGoodRemarkReason `json:"remarkReason"`
DataFrom OrderDataFrom `json:"data_from"`
//数据来源
DataFrom OrderDataFrom `json:"data_from"`
}
//NewOrderGood 初始值设定
... ...
... ... @@ -61,9 +61,11 @@ func (p *PartnerInfo) IsCompany(companyId int64) bool {
}
type PartnerFindOneQuery struct {
UserId int64
AccountEqual string
CompanyId int64
UserId int64
AccountEqual string
CompanyId int64
Code string // 合伙人编码
PartnerCategory int // 合伙人类型
}
type PartnerFindQuery struct {
... ...
... ... @@ -43,6 +43,6 @@ type OrderGood struct {
CompanyId int64
//原因备注
RemarkReason domain.OrderGoodRemarkReason ``
//数据来源
DataFrom domain.OrderDataFrom ``
}
... ...
... ... @@ -3,6 +3,7 @@ package repository
import (
"errors"
"fmt"
"github.com/go-pg/pg/v10"
"github.com/go-pg/pg/v10/orm"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
... ... @@ -81,6 +82,10 @@ func (repository *PartnerInfoRepository) FindOne(queryOptions domain.PartnerFind
hasCondition = true
query = query.Where("company_id=?", queryOptions.CompanyId)
}
if queryOptions.PartnerCategory > 0 && queryOptions.Code != "" { // 合伙人类型和编码判断
hasCondition = true
query = query.Where(`partner_category_infos@> '[{"id":?,"code":?}]'`, queryOptions.PartnerCategory, pg.Ident(queryOptions.Code))
}
if !hasCondition {
return nil, errors.New("FindOne 必须要有查询条件")
}
... ...
... ... @@ -183,7 +183,8 @@ func (reponsitory UsersRepository) Find(queryOption domain.UsersFindQuery) (int,
usersReturn = make([]domain.Users, 0)
cnt int
)
query = query.Order("id DESC")
//query = query.Order("id DESC")
query = query.Order("admin_type DESC")
cnt, err = query.SelectAndCount()
if err != nil {
return 0, usersReturn, err
... ...
... ... @@ -8,7 +8,6 @@ import (
)
func init() {
logs.SetLevel(logLevel(constant.LOG_LEVEL))
logs.SetLogFuncCall(false)
logs.SetLogger("file", getlogFileConfig())
... ...
package controllers
import (
"crypto/md5"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
... ... @@ -618,11 +620,14 @@ func (c *OrderInfoController) ListOrderForExcel() {
* @return
**/
func (c *OrderInfoController) ImportOrderFromExcel() {
// 获取参数
where := c.GetString("where")
file, h, _ := c.GetFile("file")
jsonMap := make(map[string]interface{})
companyId := c.GetUserCompany()
// Json数据解析
jsonMap := make(map[string]interface{})
err := json.Unmarshal([]byte(where), &jsonMap)
if err != nil {
logs.Error(err)
... ... @@ -632,8 +637,7 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
// 返回字段定义
ret := map[string]interface{}{}
// 返回信息表头定义
// 0: 订单号, 1: 发货单号, 3: 客户名称, 3: 订单区域, 4: 编号, 5: 合伙人, 6: 类型, 7: 业务抽成比例, 8: 产品名称, 9: 数量, 10: 单价, 11: 合伙人分红比例
// 返回信息表头定义 0: 订单号, 1: 发货单号, 2: 客户名称, 3: 订单区域, 4: 编号, 5: 合伙人, 6: 类型, 7: 业务抽成比例, 8: 产品名称, 9: 数量, 10: 单价, 11: 合伙人分红比例
var tableHeader = []string{"错误详情", "行号", "订单号", "发货单号", "客户名称", "订单区域", "编号", "合伙人", "类型", "业务抽成比例", "产品名称", "数量", "单价", "合伙人分红比例"}
// 文件后缀名校验
... ... @@ -642,14 +646,14 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
".xlsx": true,
}
if _, ok := AllowExtMap[ext]; !ok {
c.ResponseError(errors.New("文件后缀名不符合上传要求,请上传正确的文件"))
c.ResponseError(errors.New("文件后缀名不符合上传要求,请上传正确格式的文件"))
return
}
// 打开文件
xlsx, err := excelize.OpenReader(file)
if err != nil {
c.ResponseError(errors.New("文件打开失败"))
c.ResponseError(errors.New("文件打开失败,请确定文件能够正常打开"))
return
}
... ... @@ -669,13 +673,14 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
nullLine := make([]interface{}, 0)
nullFlag := false
for i, row := range rows {
if i > 2 {
if i > 2 && row != nil {
if len(row) == constant.EXCEL_COLUMN { // 中间空字符校验
var myRow = row
var tmpRow = row
var myRow []string
for j, cell := range row {
if j != 8 { // 业务员抽成比例不校验
if cell == "" || cell == " " { // 空字符串填充
myRow[j] = "null"
tmpRow[j] = "null"
nullFlag = true
}
}
... ... @@ -683,14 +688,14 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
if nullFlag {
myRow = append(myRow, "必填项不能为空") // 错误信息
s := strconv.Itoa(i + 1)
myRow = append(myRow, s) // 行号
myRow = append(myRow, row...) // 错误行数据
myRow = append(myRow, s) // 行号
myRow = append(myRow, tmpRow...) // 错误行数据
nullLine = append(nullLine, myRow)
nullFlag = false
}
} else if len(row) < constant.EXCEL_COLUMN && len(row) > 0 { // 尾部空字符校验
} else if len(row) > 0 && len(row) < constant.EXCEL_COLUMN { // 尾部空字符校验
var myRow []string
for i := 0; i < constant.EXCEL_COLUMN-len(row); i++ {
for i := 0; i < constant.EXCEL_COLUMN-len(row); i++ { // null补位
myRow = append(myRow, "null")
}
myRow = append(myRow, "必填项不能为空") // 错误信息
... ... @@ -702,6 +707,7 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
}
}
// 空单元格返回
if len(nullLine) > 0 {
ret = map[string]interface{}{
"successCount": 0,
... ... @@ -714,11 +720,11 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
return
}
// 单元格长度、内容校验
// 内容校验
errorLine := make([]interface{}, 0)
var partnerType = []string{"事业合伙", "业务合伙", "研发合伙", "业务-产品应用合伙"}
for i, row := range rows {
if i > 2 && len(row) == constant.EXCEL_COLUMN { // 数据行
if i > 2 && row != nil && len(row) == constant.EXCEL_COLUMN { // 数据行
var myRow []string
for j, cell := range row {
switch j {
... ... @@ -829,10 +835,13 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
}
}
}
errorLine = append(errorLine, myRow)
if myRow != nil {
errorLine = append(errorLine, myRow)
}
}
}
// 内容错误行返回
if len(errorLine) > 0 {
ret = map[string]interface{}{
"successCount": 0,
... ... @@ -845,20 +854,134 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
return
}
// 归类订单
// 创建订单服务
orderSrv := orderService.NewOrderInfoService(nil)
// 聚合订单产品
var orderCommands = make(map[string]*orderCmd.CreateOrderCommand, 0)
for i, row := range rows {
if i > 2 && len(row) == 13 {
if i > 2 && len(row) == constant.EXCEL_COLUMN {
hashValue := md5.Sum([]byte(row[0] + row[1] + row[4] + row[6])) // 根据:订单号+发货单号+合伙人编号+合伙类型计算哈希值
hashString := hex.EncodeToString(hashValue[:])
if _, ok := orderCommands[hashString]; !ok {
//订单相关,0: 订单号, 1: 发货单号, 2: 客户名称, 3: 订单区域, 4: 编号, 5: 合伙人, 6: 类型, 7: 业务抽成比例,
sbPercent, _ := strconv.ParseFloat(row[7], 64) //业务抽成比例
//产品相关,8: 产品名称, 9: 数量, 10: 单价, 11: 合伙人分红比例
amount, _ := strconv.ParseInt(row[9], 10, 64) // 数量
price, _ := strconv.ParseFloat(row[10], 64) // 单价
percent, _ := strconv.ParseFloat(row[11], 64) // 合伙人分红比例
// 初始化建订单命令集
orderCommands[hashString] = &orderCmd.CreateOrderCommand{
OrderType: 0,
OrderCode: row[0],
DeliveryCode: row[1],
BuyerName: row[2],
OrderRegion: row[3],
PartnerId: 0, // 根据合伙人类型+合伙人编号查找合伙人id
SalesmanBonusPercent: sbPercent,
Goods: []orderCmd.OrderGoodData{
{
GoodName: row[8],
PlanGoodNumber: int(amount),
Price: price,
PartnerBonusPercent: percent,
},
},
CompanyId: companyId,
PartnerCategory: 1,
LineNumbers: []int{i},
}
// 获取partnerId
var partnerInfo *domain.PartnerInfo
partnerInfo, err = orderSrv.GetPartnerIdByCodeAndCategory(orderQuery.GetPartnerIdQuery{
Code: row[4],
PartnerCategory: 0,
CompanyId: companyId,
})
if err != nil {
}
if partnerInfo != nil {
orderCommands[hashString].PartnerId = partnerInfo.Partner.Id
// 1: 事业合伙、2: 业务合伙、3: 研发合伙、4: 业务-产品应用合伙
switch row[6] {
case "事业合伙":
partnerInfo.PartnerCategory = 1
case "业务合伙":
partnerInfo.PartnerCategory = 2
case "研发合伙":
partnerInfo.PartnerCategory = 3
case "业务-产品应用合伙":
partnerInfo.PartnerCategory = 4
}
}
} else {
//产品相关,8: 产品名称, 9: 数量, 10: 单价, 11: 合伙人分红比例
amount, _ := strconv.ParseInt(row[9], 10, 64) // 数量
price, _ := strconv.ParseFloat(row[10], 64) // 单价
percent, _ := strconv.ParseFloat(row[11], 64) // 合伙人分红比例
// 记录同一笔订单产品
orderCommands[hashString].Goods = append(orderCommands[hashString].Goods, orderCmd.OrderGoodData{
GoodName: row[8],
PlanGoodNumber: int(amount),
Price: price,
PartnerBonusPercent: percent,
LineNumber: i, // 记录行号
})
// 记录聚合行号
orderCommands[hashString].LineNumbers = append(orderCommands[hashString].LineNumbers, i)
}
}
}
// 批量创建订单命令集
var createOrderCommands []*orderCmd.CreateOrderCommand
for _, orderCommand := range orderCommands {
createOrderCommands = append(createOrderCommands, orderCommand)
}
// 新增失败记录
failureDataList := make([]interface{}, 0)
// 新增成功记录计数
//var successDataCount int64
var successDataCount int64
c.ResponseData(failureDataList)
// 新增错误信息
var createError error
// 批量新增订单
failureDataList, createError = orderSrv.CreateNewOrderByImport(createOrderCommands)
if createError != nil {
c.ResponseError(createError)
return
} else {
if len(failureDataList) > 0 { // 导入失败返回
successDataCount = 0
ret = map[string]interface{}{
"successCount": successDataCount,
"fail": map[string]interface{}{
"tableHeader": tableHeader,
"tableData": failureDataList,
},
}
} else { // 导入成功返回
successDataCount = int64(len(rows) - 3 - len(failureDataList))
if successDataCount == int64(len(rows)-3) {
ret = map[string]interface{}{
"successCount": successDataCount,
"fail": nil,
}
}
}
}
// 返回错误详情
c.ResponseData(ret)
return
}
... ...
... ... @@ -35,12 +35,12 @@ func init() {
beego.NSRouter("/list/excel", &controllers.OrderDividendController{}, "POST:ListOrderBonusForExcel"),
),
beego.NSNamespace("/order",
beego.NSRouter("/actual/list", &controllers.OrderInfoController{}, "POST:PageListOrderReal"),
beego.NSRouter("/actual/list", &controllers.OrderInfoController{}, "POST:PageListOrderReal"), // 返归订单列表
beego.NSRouter("/actual/list/excel", &controllers.OrderInfoController{}, "POST:ListOrderForExcel"), // 导出excel
beego.NSRouter("/actual/import/excel", &controllers.OrderInfoController{}, "POST:ImportOrderFromExcel"), // 导入订单数据
beego.NSRouter("/actual/detail", &controllers.OrderInfoController{}, "POST:GetOrderReal"),
beego.NSRouter("/actual/del", &controllers.OrderInfoController{}, "POST:RemoveOrderReal"),
beego.NSRouter("/actual/update", &controllers.OrderInfoController{}, "POST:UpdateOrderReal"),
beego.NSRouter("/actual/detail", &controllers.OrderInfoController{}, "POST:GetOrderReal"), // 查看实际订单详情
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.NSNamespace("/common",
... ...