Merge remote-tracking branch 'origin/mark' into don
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
func GetAuthBind(db *DaoDB, userID, authType, authID string) (authBind *model.AuthBind, err error) {
|
||||
func GetAuthBind(db *DaoDB, userID string, bindType int, authType, authID string) (authBind *model.AuthBind, err error) {
|
||||
if userID == "" && authID == "" {
|
||||
return nil, errors.New("userID, authID, authID2不能全为空")
|
||||
}
|
||||
@@ -24,6 +24,10 @@ func GetAuthBind(db *DaoDB, userID, authType, authID string) (authBind *model.Au
|
||||
sql += " AND t1.user_id = ?"
|
||||
sqlParams = append(sqlParams, userID)
|
||||
}
|
||||
if bindType != model.AuthBindTypeAll {
|
||||
sql += " AND t1.bind_type = ?"
|
||||
sqlParams = append(sqlParams, bindType)
|
||||
}
|
||||
if authType != "" {
|
||||
sql += " AND t1.type = ?"
|
||||
sqlParams = append(sqlParams, authType)
|
||||
@@ -37,32 +41,32 @@ func GetAuthBind(db *DaoDB, userID, authType, authID string) (authBind *model.Au
|
||||
return authBind, err
|
||||
}
|
||||
|
||||
func GetAuthBindsByAuthID2(db *DaoDB, authID2 string, typeList []string) (authBinds []*model.AuthBind, err error) {
|
||||
func GetUserBindAuthInfo(db *DaoDB, userID string, bindType int, authID2 string, typeList []string) (authList []*model.AuthBind, err error) {
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM auth_bind t1
|
||||
WHERE t1.deleted_at = ? AND t1.status = ? AND t1.auth_id2 = ? AND t1.type IN (` + GenQuestionMarks(len(typeList)) + ")"
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
model.AuthBindStatusNormal,
|
||||
authID2,
|
||||
typeList,
|
||||
}
|
||||
err = GetRows(db, &authBinds, sql, sqlParams...)
|
||||
return authBinds, err
|
||||
}
|
||||
|
||||
func GetUserBindAuthInfo(db *DaoDB, userID string) (authList []*model.AuthBind, err error) {
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM auth_bind t1
|
||||
WHERE t1.deleted_at = ? AND t1.status = ? AND t1.user_id = ?
|
||||
`
|
||||
WHERE t1.deleted_at = ? AND t1.status = ?`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
model.UserStatusNormal,
|
||||
userID,
|
||||
}
|
||||
if userID != "" {
|
||||
sql += " AND t1.user_id = ?"
|
||||
sqlParams = append(sqlParams, userID)
|
||||
}
|
||||
if bindType != model.AuthBindTypeAll {
|
||||
sql += " AND t1.bind_type = ?"
|
||||
sqlParams = append(sqlParams, bindType)
|
||||
}
|
||||
if authID2 != "" {
|
||||
sql += " AND t1.auth_id2 = ?"
|
||||
sqlParams = append(sqlParams, authID2)
|
||||
}
|
||||
if len(typeList) > 0 {
|
||||
sql += " AND t1.type IN (" + GenQuestionMarks(len(typeList)) + ")"
|
||||
sqlParams = append(sqlParams, typeList)
|
||||
}
|
||||
|
||||
err = GetRows(db, &authList, sql, sqlParams...)
|
||||
return authList, err
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package dao
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
@@ -64,3 +65,23 @@ func GetUsers(db *DaoDB, userType int, keyword string, userIDs []string, userID2
|
||||
}
|
||||
return userList, totalCount, err
|
||||
}
|
||||
|
||||
func DeleteUsers(db *DaoDB, userIDs []string) (num int64, err error) {
|
||||
if len(userIDs) > 0 {
|
||||
sql := `
|
||||
UPDATE user t1
|
||||
JOIN auth_bind t2 ON t2.user_id = t1.user_id
|
||||
SET
|
||||
t1.deleted_at = ?,
|
||||
t2.deleted_at = ?
|
||||
WHERE t1.user_id IN (` + GenQuestionMarks(len(userIDs)) + ");"
|
||||
now := time.Now()
|
||||
sqlParams := []interface{}{
|
||||
now,
|
||||
now,
|
||||
userIDs,
|
||||
}
|
||||
num, err = ExecuteSQL(db, sql, sqlParams...)
|
||||
}
|
||||
return num, err
|
||||
}
|
||||
|
||||
@@ -176,6 +176,7 @@ func GetStoreCategories(db *DaoDB, vendorID, storeID int, level int) (cats []*Sk
|
||||
}
|
||||
|
||||
// 以store_sku_bind为基础来做同步,正常情况下使用
|
||||
// !!! 此函数不要将store_sku_bind中的vendor_price取出来放到StoreSkuSyncInfo.VendorPrice中,因为之后会依赖这个VendorPrice进行重算
|
||||
// 单多门店模式厂商通用
|
||||
func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, isDirty bool) (skus []*StoreSkuSyncInfo, err error) {
|
||||
if vendorID < 0 {
|
||||
@@ -211,6 +212,11 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, isDirty bool)
|
||||
t5.%s_sync_status store_cat_sync_status, t5.%s_id vendor_cat_id,
|
||||
t5sku.%s_sync_status sku_store_cat_sync_status, t5sku.%s_id sku_vendor_cat_id`
|
||||
fmtParams = append(fmtParams, fieldPrefix, fieldPrefix, fieldPrefix, fieldPrefix)
|
||||
} else {
|
||||
sql += `,
|
||||
t4.%s_id vendor_cat_id,
|
||||
t5sku.%s_id sku_vendor_cat_id`
|
||||
fmtParams = append(fmtParams, fieldPrefix, fieldPrefix)
|
||||
}
|
||||
sql += `
|
||||
FROM store_sku_bind t1
|
||||
@@ -236,6 +242,9 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, isDirty bool)
|
||||
LEFT JOIN store_sku_category_map t5 ON t4.id = t5.category_id AND t5.store_id = t1.store_id AND t5.deleted_at = ?
|
||||
LEFT JOIN store_sku_category_map t5sku ON t2.category_id = t5sku.category_id AND t5sku.store_id = t1.store_id AND t5sku.deleted_at = ?`
|
||||
sqlParams = append(sqlParams, utils.DefaultTimeValue, utils.DefaultTimeValue)
|
||||
} else {
|
||||
sql += `
|
||||
LEFT JOIN sku_category t5sku ON t5sku.id = t2.category_id`
|
||||
}
|
||||
sql += " WHERE 1 = 1"
|
||||
if storeID > 0 {
|
||||
@@ -532,4 +541,4 @@ func (s *StoreSkuSyncInfo) GetSeq() int {
|
||||
return s.Seq
|
||||
}
|
||||
return int(s.VendorPrice)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user