|
|
|
@ -105,16 +105,20 @@ func QueryGoodsListByComprehension(c *gin.Context) {
|
|
|
|
|
sub := mysql2.Db.Table((&ac2.ActivityGoods{}).TableName()).Select("goods_id").Where("activity_id = ?", p.ActivityID)
|
|
|
|
|
q3 = q3.Where("id in (?) and sale_publish = 1 and is_sale = 1", sub)
|
|
|
|
|
}
|
|
|
|
|
findByKeyWord(q3, p.Keyword, &goodsList, p.Page, p.IsSale)
|
|
|
|
|
findByKeyWord(q3, p.Keyword, &goodsList, p.Page, p.IsSale, false)
|
|
|
|
|
back.Suc(c, "", GetGoodsRespByInfoList(goodsList, p.UserId, p.IsSale))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func findByKeyWord(q *gorm2.DB, str string, data *[]goods.Information, page uint, isSale bool) {
|
|
|
|
|
func findByKeyWord(q *gorm2.DB, str string, data *[]goods.Information, page uint, isSale bool, isCondition bool) {
|
|
|
|
|
if str != "" {
|
|
|
|
|
if !isSale {
|
|
|
|
|
gl, _, _ := search_ali.SearchByAliES(str, 20, int(page))
|
|
|
|
|
q.Clauses(clause.OrderBy{
|
|
|
|
|
Expression: clause.Expr{SQL: "FIELD(id,?)", Vars: []interface{}{gl}, WithoutParentheses: true}}).Where("a.id in (?)", gl).Find(&data)
|
|
|
|
|
q = q.Where("a.id in (?)", gl)
|
|
|
|
|
if !isCondition {
|
|
|
|
|
q = q.Clauses(clause.OrderBy{
|
|
|
|
|
Expression: clause.Expr{SQL: "FIELD(id,?)", Vars: []interface{}{gl}, WithoutParentheses: true}})
|
|
|
|
|
}
|
|
|
|
|
q.Find(&data)
|
|
|
|
|
} else {
|
|
|
|
|
like := fmt.Sprintf("%%%v%%", str)
|
|
|
|
|
q.Where("is_sale = 1 and sale_publish = 1").Where("goods_name like ?", like).Limit(20).Offset(int(page * 20)).Find(&data)
|
|
|
|
@ -166,7 +170,7 @@ func QueryGoodsListBySalesVolume(c *gin.Context) {
|
|
|
|
|
sub := mysql2.Db.Table((&ac2.ActivityGoods{}).TableName()).Select("goods_id").Where("activity_id = ?", p.ActivityID)
|
|
|
|
|
q3 = q3.Where("id in (?) and sale_publish = 1 and is_sale = 1", sub)
|
|
|
|
|
}
|
|
|
|
|
findByKeyWord(q3, p.Keyword, &goodsList, p.Page, p.IsSale)
|
|
|
|
|
findByKeyWord(q3, p.Keyword, &goodsList, p.Page, p.IsSale, true)
|
|
|
|
|
back.Suc(c, "", GetGoodsRespByInfoList(goodsList, p.UserId, p.IsSale))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -200,7 +204,7 @@ func QueryGoodsListByDiscountPrice(c *gin.Context) {
|
|
|
|
|
q3 = q3.Where("id in (?) and sale_publish = 1 and is_sale= 1", sub)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
findByKeyWord(q3, p.Keyword, &goodsInfoIdList, p.Page, p.IsSale)
|
|
|
|
|
findByKeyWord(q3, p.Keyword, &goodsInfoIdList, p.Page, p.IsSale, true)
|
|
|
|
|
for _, v := range goodsInfoIdList {
|
|
|
|
|
goodsIdList = append(goodsIdList, v.ID)
|
|
|
|
|
}
|
|
|
|
|