You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.0 KiB

package order
import (
"github.com/360EntSecGroup-Skylar/excelize/v2"
"github.com/gin-gonic/gin"
"recook/internal/v2/lib/back"
"recook/internal/v2/lib/common"
"recook/internal/v2/logic/manage/order"
"recook/tools"
)
type Express struct {
}
type argsQuery struct {
OrderGoodsId uint `json:"orderGoodsId" form:"orderGoodsId"`
}
// @Style 查询快递信息
func (e *Express) Query(c *gin.Context) {
var args argsQuery
err := tools.Params(&args, c)
if err != nil {
back.Fail(c, err.Error())
return
}
if args.OrderGoodsId == 0 {
back.Fail(c, "参数错误")
return
}
result, err := order.Expresslogic.Query(args.OrderGoodsId)
if err != nil {
back.Fail(c, err.Error())
return
}
back.Suc(c, "", result)
}
type argsUpdate struct {
OrderGoodsId uint `json:"orderGoodsId" form:"orderGoodsId"`
Express []order.ExpressInfo `json:"express" form:"express"`
}
// @Style 修改快递信息
func (e *Express) Update(c *gin.Context) {
var args argsUpdate
err := tools.Params(&args, c)
if err != nil {
back.Fail(c, err.Error())
return
}
if args.OrderGoodsId == 0 {
back.Fail(c, "参数错误")
return
}
user, _ := common.GetGysUser(c)
if err := order.Expresslogic.Update(user, args.OrderGoodsId, args.Express); err != nil {
back.Fail(c, err.Error())
return
}
c.Set("status", "SyncExpress")
c.Set("id", args.OrderGoodsId)
back.Suc(c, "操作成功", nil)
}
// @Style 快递公司筛选
func (e *Express) Select(c *gin.Context) {
back.Suc(c, "操作成功", order.Expresslogic.Select())
}
// @Style 批量发货
func (e *Express) MulUpdate(c *gin.Context) {
upfile, err := c.FormFile("excel")
if err != nil {
back.Fail(c, err.Error())
return
}
file, err := upfile.Open()
exl, err := excelize.OpenReader(file)
if err != nil {
back.Err(c, err.Error())
return
}
user, _ := common.GetGysUser(c)
result := order.Expresslogic.MulUpdate(user, exl)
c.Set("status", "SyncExpress")
c.Set("id", result.OrderGoodsID)
back.Suc(c, "操作成功", result)
}