添加Store.OperatorPhone3

This commit is contained in:
gazebo
2020-02-12 08:40:18 +08:00
parent f77849d08a
commit 97a5c2d921
7 changed files with 128 additions and 121 deletions

View File

@@ -100,37 +100,34 @@ func DeleteUsers(db *DaoDB, userIDs []string) (num int64, err error) {
return num, err
}
func GetStoreListByMobile(db *DaoDB, mobile string) (storeList []*StoreWithCityName, err error) {
if mobile != "" {
sql := `
SELECT
DISTINCT t1.*, t2.name city_name
FROM (
SELECT *
FROM store t1
WHERE (t1.market_man_phone = ? OR t1.operator_phone = ? OR t1.operator_phone2 = ?)
UNION DISTINCT
SELECT t1.*
FROM store t1
JOIN weixins t2 ON t2.jxstoreid = t1.id AND t2.parentid = -1
LEFT JOIN weixins t3 ON t3.parentid = t2.id
WHERE (t2.tel = ? OR t3.tel = ?)
) t1
LEFT JOIN place t2 ON t2.code = t1.city_code
WHERE t1.deleted_at = ?
ORDER BY t1.name`
sqlParams := []interface{}{
mobile,
mobile,
mobile,
mobile,
mobile,
utils.DefaultTimeValue,
}
err = GetRows(db, &storeList, sql, sqlParams...)
}
return storeList, err
}
// func GetStoreListByMobile(db *DaoDB, mobile string) (storeList []*StoreWithCityName, err error) {
// if mobile != "" {
// sql := `
// SELECT
// DISTINCT t1.*, t2.name city_name
// FROM (
// SELECT *
// FROM store t1
// WHERE (t1.market_man_phone = ? OR t1.operator_phone = ? OR t1.operator_phone2 = ? OR t1.operator_phone3 = ?)
// UNION DISTINCT
// SELECT t1.*
// FROM store t1
// JOIN weixins t2 ON t2.jxstoreid = t1.id AND t2.parentid = -1
// LEFT JOIN weixins t3 ON t3.parentid = t2.id
// WHERE (t2.tel = ? OR t3.tel = ?)
// ) t1
// LEFT JOIN place t2 ON t2.code = t1.city_code
// WHERE t1.deleted_at = ?
// ORDER BY t1.name`
// sqlParams := []interface{}{
// mobile, mobile, mobile, mobile,
// mobile, mobile,
// utils.DefaultTimeValue,
// }
// err = GetRows(db, &storeList, sql, sqlParams...)
// }
// return storeList, err
// }
func GetStoreListByMobileOrStoreIDs(db *DaoDB, mobile string, shortRoleNameList []string, storeIDs []int) (storeList []*StoreWithCityName, err error) {
sql := `
@@ -142,13 +139,13 @@ func GetStoreListByMobileOrStoreIDs(db *DaoDB, mobile string, shortRoleNameList
utils.DefaultTimeValue,
}
if mobile != "" {
sql += " OR t1.tel1 = ? OR t1.tel2 = ? OR t1.market_man_phone = ? OR t1.operator_phone = ? OR t1.operator_phone2 = ?"
sqlParams = append(sqlParams, mobile, mobile, mobile, mobile, mobile)
sql += " OR t1.tel1 = ? OR t1.tel2 = ? OR t1.market_man_phone = ? OR t1.operator_phone = ? OR t1.operator_phone2 = ? OR t1.operator_phone3 = ?"
sqlParams = append(sqlParams, mobile, mobile, mobile, mobile, mobile, mobile)
}
if len(shortRoleNameList) > 0 {
questionMarks := GenQuestionMarks(len(shortRoleNameList))
sql += " OR t1.market_man_role IN (" + questionMarks + ") OR t1.operator_role IN (" + questionMarks + ") OR t1.operator_role2 IN (" + questionMarks + ")"
sqlParams = append(sqlParams, shortRoleNameList, shortRoleNameList, shortRoleNameList)
sql += " OR t1.market_man_role IN (" + questionMarks + ") OR t1.operator_role IN (" + questionMarks + ") OR t1.operator_role2 IN (" + questionMarks + ") OR t1.operator_role3 IN (" + questionMarks + ")"
sqlParams = append(sqlParams, shortRoleNameList, shortRoleNameList, shortRoleNameList, shortRoleNameList)
}
if len(storeIDs) > 0 {
sql += " OR t1.id IN (" + GenQuestionMarks(len(storeIDs)) + ")"