|
|
|
@ -33,6 +33,7 @@ type CreatedReq struct {
|
|
|
|
|
StartTime string `json:"start_time"`
|
|
|
|
|
EndTime string `json:"end_time"`
|
|
|
|
|
SortId uint `json:"sort_id"`
|
|
|
|
|
IsSale bool `json:"is_sale"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Add 新增轮播图
|
|
|
|
@ -140,7 +141,7 @@ func (b logicActiveBit) Add(p CreatedReq) error {
|
|
|
|
|
if activityOrGoods == "goods" && p.GoodsID > 0 {
|
|
|
|
|
// 重复性检查
|
|
|
|
|
var show rotation.RecookRotationModel
|
|
|
|
|
dbc.DB.Where("is_active=1").First(&show, "good_id = ?", p.GoodsID)
|
|
|
|
|
dbc.DB.Where("is_active=1").Where("is_sale=?", p.IsSale).First(&show, "good_id = ?", p.GoodsID)
|
|
|
|
|
if show.ID > 0 {
|
|
|
|
|
return errors.New("该商品已在钻展中")
|
|
|
|
|
}
|
|
|
|
@ -155,6 +156,7 @@ func (b logicActiveBit) Add(p CreatedReq) error {
|
|
|
|
|
StartTime: formatime.NewSecondFrom(t1),
|
|
|
|
|
EndTime: formatime.NewSecondFrom(t2),
|
|
|
|
|
SortId: p.SortId,
|
|
|
|
|
IsSale: p.IsSale,
|
|
|
|
|
}
|
|
|
|
|
err := dbc.DB.Table(one.TableName()).Create(&one).Error
|
|
|
|
|
if err != nil {
|
|
|
|
@ -186,6 +188,7 @@ func (b logicActiveBit) Add(p CreatedReq) error {
|
|
|
|
|
StartTime: formatime.NewSecondFrom(t1),
|
|
|
|
|
EndTime: formatime.NewSecondFrom(t2),
|
|
|
|
|
SortId: p.SortId,
|
|
|
|
|
IsSale: p.IsSale,
|
|
|
|
|
}
|
|
|
|
|
if err := dbc.DB.Create(&one).Error; err != nil {
|
|
|
|
|
return err
|
|
|
|
@ -206,10 +209,11 @@ type queryResp struct {
|
|
|
|
|
Status uint `json:"status"` //1:待生效 2:生效中 3已失效
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (b logicActiveBit) ShowList() (list []queryResp) {
|
|
|
|
|
func (b logicActiveBit) ShowList(isSale bool) (list []queryResp) {
|
|
|
|
|
|
|
|
|
|
var of []rotation.RecookRotationModel
|
|
|
|
|
mysql2.Db.Table((&rotation.RecookRotationModel{}).TableName()).Where("is_active=?", 1).Order("id desc").Find(&of)
|
|
|
|
|
mysql2.Db.Table((&rotation.RecookRotationModel{}).TableName()).Where("is_sale=?", isSale).
|
|
|
|
|
Where("is_active=?", 1).Order("id desc").Find(&of)
|
|
|
|
|
fmt.Println(len(of))
|
|
|
|
|
|
|
|
|
|
for _, v := range of {
|
|
|
|
|