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.
81 lines
1.9 KiB
81 lines
1.9 KiB
package shoppingcart
|
|
|
|
import (
|
|
"fmt"
|
|
"math/rand"
|
|
"recook/internal/back"
|
|
"recook/internal/v2/logic/app/shopping"
|
|
user2 "recook/internal/v2/model/recook/user"
|
|
"recook/internal/v2/model/weibo"
|
|
"recook/tools"
|
|
|
|
mysql2 "git.oa00.com/go/mysql"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type ShoppingController struct {
|
|
}
|
|
|
|
type viewLikeRes struct {
|
|
GoodsId uint `json:"goods_id"`
|
|
UserId uint `json:"user_id"`
|
|
IsSale bool `json:"is_sale"`
|
|
}
|
|
|
|
// ViewLike 找相似产品
|
|
func (s ShoppingController) ViewLike(c *gin.Context) {
|
|
var p viewLikeRes
|
|
if err := tools.ParseParams(&p, c); err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
rest := shopping.LogicShoppingCart.ViewLike(p.GoodsId, p.UserId, p.IsSale)
|
|
back.Suc(c, "", rest)
|
|
|
|
}
|
|
|
|
// ViewLikeMaybe 可能喜欢的商品
|
|
func (s ShoppingController) ViewLikeMaybe(c *gin.Context) {
|
|
var p viewLikeRes
|
|
if err := tools.ParseParams(&p, c); err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
rest := shopping.LogicShoppingCart.ViewLikeMayBe(p.UserId, p.IsSale)
|
|
back.Suc(c, "", rest)
|
|
}
|
|
|
|
//missing_children
|
|
|
|
type user struct {
|
|
UserId uint `json:"user_id"`
|
|
}
|
|
|
|
func (s ShoppingController) Children(c *gin.Context) {
|
|
var p user
|
|
if err := tools.ParseParams(&p, c); err != nil {
|
|
back.Fail(c, err.Error())
|
|
return
|
|
}
|
|
var status weibo.WeiBIsClosed
|
|
mysql2.Db.Table(status.TableName()).First(&status, "id=1")
|
|
if status.Status == 2 {
|
|
return
|
|
} else if status.Status == 1 {
|
|
var info user2.RecookUserInfoModel
|
|
mysql2.Db.Table(info.TableName()).Where("id=?", p.UserId).First(&info)
|
|
if info.Id == 0 {
|
|
back.Suc(c, "", nil)
|
|
} else {
|
|
var list []weibo.ReunionSystem
|
|
mysql2.Db.Table((&weibo.ReunionSystem{}).TableName()).Where("text like (?)", fmt.Sprintf("%%%s%%", info.Province)).Find(&list)
|
|
if len(list) == 0 {
|
|
mysql2.Db.Table((&weibo.ReunionSystem{}).TableName()).Find(&list)
|
|
}
|
|
index := rand.Perm(len(list))
|
|
back.Suc(c, "", list[index[0]])
|
|
}
|
|
}
|
|
|
|
}
|