aa
This commit is contained in:
@@ -1483,14 +1483,33 @@ func GetPriceDefendOrder(db *DaoDB, vendorOrderID string, storeIDs, skuIDs, issu
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetCoupons(db *DaoDB, couponType int, couponStatuss, storeIDs []int, keyword string) (coupons []*model.Coupons, err error) {
|
func GetCoupons(db *DaoDB, couponType int, couponStatuss, storeIDs []int, keyword string) (coupons []*model.Coupons, err error) {
|
||||||
|
sqlParams := []interface{}{}
|
||||||
sql := `
|
sql := `
|
||||||
|
SELECT *
|
||||||
|
FROM coupons
|
||||||
|
WHERE 1 = 1 AND is_all = ?
|
||||||
|
`
|
||||||
|
sqlParams = append(sqlParams, model.YES)
|
||||||
|
if couponType != 0 {
|
||||||
|
sql += " AND coupon_type = ?"
|
||||||
|
sqlParams = append(sqlParams, couponType)
|
||||||
|
}
|
||||||
|
if keyword != "" {
|
||||||
|
sql += " AND (name LIKE ? OR desc LIKE ?)"
|
||||||
|
sqlParams = append(sqlParams, "%"+keyword+"%", "%"+keyword+"%")
|
||||||
|
}
|
||||||
|
if len(couponStatuss) > 0 {
|
||||||
|
sql += " AND coupon_status IN (" + GenQuestionMarks(len(couponStatuss)) + ")"
|
||||||
|
sqlParams = append(sqlParams, couponStatuss)
|
||||||
|
}
|
||||||
|
sql +=
|
||||||
|
`UNION
|
||||||
SELECT DISTINCT a.*
|
SELECT DISTINCT a.*
|
||||||
FROM coupons a
|
FROM coupons a
|
||||||
LEFT JOIN store_coupons b ON a.id = b.coupon_id AND b.deleted_at = ?
|
LEFT JOIN store_coupons b ON a.id = b.coupon_id AND b.deleted_at = ?
|
||||||
LEFT JOIN coupons c ON a.id = c.id AND c.is_all = ?
|
|
||||||
WHERE 1 = 1
|
WHERE 1 = 1
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{utils.DefaultTimeValue, model.YES}
|
sqlParams = append(sqlParams, utils.DefaultTimeValue)
|
||||||
if couponType != 0 {
|
if couponType != 0 {
|
||||||
sql += " AND a.coupon_type = ?"
|
sql += " AND a.coupon_type = ?"
|
||||||
sqlParams = append(sqlParams, couponType)
|
sqlParams = append(sqlParams, couponType)
|
||||||
|
|||||||
Reference in New Issue
Block a user