feat:特推位

master
howell 3 years ago
parent 86f544f6db
commit ef9fa3bca3

@ -3,9 +3,6 @@ package activebit
import (
"errors"
"fmt"
mysql2 "git.oa00.com/go/mysql"
"github.com/360EntSecGroup-Skylar/excelize/v2"
"github.com/gin-gonic/gin"
"path/filepath"
"recook/internal/back"
"recook/internal/libs/bean"
@ -17,7 +14,12 @@ import (
manage "recook/internal/v2/model/third"
"recook/tools"
"reflect"
"strconv"
"time"
mysql2 "git.oa00.com/go/mysql"
"github.com/360EntSecGroup-Skylar/excelize/v2"
"github.com/gin-gonic/gin"
)
type ControllerActive struct {
@ -115,8 +117,8 @@ func (a ControllerActive) ActivityList(c *gin.Context) {
}
rest, total := activebit.LogicActiveBit.ShowActivityList(p.IsType)
back.Suc(c, "ok", bean.ResultLists{
rest,
int(total),
List: rest,
Total: int(total),
})
}
@ -175,7 +177,9 @@ func (a ControllerActive) AddRecommend(c *gin.Context) {
//存入 1高佣 2特惠
status, _ := c.GetPostForm("status")
err = activebit.LogicActiveBit.AddCommends(result, status)
isSale, _ := c.GetPostForm("is_sale")
is_sale, _ := strconv.Atoi(isSale)
err = activebit.LogicActiveBit.AddCommends(result, status, is_sale == 1)
if err != nil {
back.Fail(c, err.Error())
return
@ -185,6 +189,7 @@ func (a ControllerActive) AddRecommend(c *gin.Context) {
type listReq struct {
Status uint `json:"status"`
IsSale bool `json:"is_sale"`
}
func (a ControllerActive) List(c *gin.Context) {
@ -198,7 +203,8 @@ func (a ControllerActive) List(c *gin.Context) {
return
}
var list []recommendedlist.RecookCommendList
mysql2.Db.Table((&recommendedlist.RecookCommendList{}).TableName()).Where("status=?", p.Status).Find(&list)
mysql2.Db.Table((&recommendedlist.RecookCommendList{}).TableName()).
Where("is_sale=?", p.IsSale).Where("status=?", p.Status).Find(&list)
back.Suc(c, "", list)
}

@ -3,9 +3,6 @@ package activebit
import (
"errors"
"fmt"
mysql2 "git.oa00.com/go/mysql"
"github.com/golangkit/formatime"
"github.com/shopspring/decimal"
"recook/internal/dbc"
"recook/internal/v2/model/gys/enterprise"
"recook/internal/v2/model/recommendedlist"
@ -14,6 +11,10 @@ import (
"strconv"
"strings"
"time"
mysql2 "git.oa00.com/go/mysql"
"github.com/golangkit/formatime"
"github.com/shopspring/decimal"
)
type logicActiveBit struct {
@ -398,7 +399,7 @@ func (b logicActiveBit) ShowActivityList(id uint) ([]showActivityListRes, int64)
//遍历存数据库
func (b logicActiveBit) AddCommends(result []string, status string) error {
func (b logicActiveBit) AddCommends(result []string, status string, isSale bool) error {
//判读status
st, _ := strconv.Atoi(status)
@ -451,6 +452,7 @@ func (b logicActiveBit) AddCommends(result []string, status string) error {
DiscountPriceList: discon,
GysName: gys.EnterpriseName,
Status: uint(st),
IsSale: isSale,
}
list = append(list, one)
}

@ -12,6 +12,7 @@ type RecookCommendList struct {
DiscountPriceList string `gorm:"column:discount_price_list" json:"discount_price_list"`
GysName string `gorm:"column:gys_name" json:"gys_name"`
Status uint `gorm:"column:status" json:"status"`
IsSale bool `json:"is_sale"`
}
func (r RecookCommendList) TableName() string {

Loading…
Cancel
Save