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.
86 lines
2.0 KiB
86 lines
2.0 KiB
package goods
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/shopspring/decimal"
|
|
"recook/internal/back"
|
|
"recook/internal/libs/bean"
|
|
"recook/internal/v2/logic/supplier/goods"
|
|
"recook/tools"
|
|
)
|
|
|
|
type GysPurchaseController struct {
|
|
}
|
|
type listRep struct {
|
|
GysId uint `json:"gys_id"`
|
|
GoodsName string `json:"goods_name"`
|
|
GoodsSn string `json:"goods_sn"`
|
|
EffectiveTime string `json:"effective_time"`
|
|
Page bean.Page `json:"page"`
|
|
}
|
|
|
|
//显示供应商名下商品和供应商采购提报记录
|
|
func (g GysPurchaseController) List(c *gin.Context) {
|
|
var p listRep
|
|
if err := tools.Params(&p, c); err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
if p.GysId == 0 {
|
|
back.Fail(c, "请传入供应商id")
|
|
return
|
|
}
|
|
list, total := goods.CaiGouLogic.List(p.GysId, p.GoodsName, p.GoodsSn, p.EffectiveTime, p.Page)
|
|
back.Suc(c, "ok", bean.ResultLists{
|
|
List: list, Total: int(total),
|
|
})
|
|
|
|
}
|
|
|
|
type createdReq struct {
|
|
SkuId uint `json:"sku_id"`
|
|
NewPrice decimal.Decimal `json:"new_price"`
|
|
EffectiveTime string `json:"effective_time"`
|
|
MinPrice decimal.Decimal `json:"min_price"`
|
|
SuggestedPrice decimal.Decimal `json:"suggested_price"`
|
|
}
|
|
|
|
//新增修改供货价
|
|
func (g GysPurchaseController) Created(c *gin.Context) {
|
|
var p createdReq
|
|
if err := tools.Params(&p, c); err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
if p.SkuId == 0 || p.NewPrice.IsZero() || p.EffectiveTime == "" {
|
|
back.Fail(c, "缺失必传项")
|
|
return
|
|
}
|
|
err := goods.CaiGouLogic.CreatedGHJ(p.SkuId, p.NewPrice, p.EffectiveTime, p.MinPrice, p.SuggestedPrice)
|
|
if err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
back.Suc(c, "ok", nil)
|
|
|
|
}
|
|
|
|
type delReq struct {
|
|
SkuId uint `json:"sku_id"`
|
|
}
|
|
|
|
//撤回
|
|
func (g GysPurchaseController) DEl(c *gin.Context) {
|
|
var p delReq
|
|
if err := tools.Params(&p, c); err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
err := goods.CaiGouLogic.Del(p.SkuId)
|
|
if err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
back.Suc(c, "ok", nil)
|
|
}
|