aa
This commit is contained in:
@@ -1425,7 +1425,7 @@ func MergeJdsOrders(ctx *jxcontext.Context, vendorOrderIDs []string) (vendorOrde
|
|||||||
if err != nil || len(storeMaps) == 0 {
|
if err != nil || len(storeMaps) == 0 {
|
||||||
return "", fmt.Errorf("该门店未绑定京狗平台,请先绑定后再转移!门店:[%v]", storeID)
|
return "", fmt.Errorf("该门店未绑定京狗平台,请先绑定后再转移!门店:[%v]", storeID)
|
||||||
}
|
}
|
||||||
stores, _ := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, "")
|
stores, _ := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, nil, "")
|
||||||
var (
|
var (
|
||||||
newEarningPrice int64
|
newEarningPrice int64
|
||||||
actualPrice int64
|
actualPrice int64
|
||||||
@@ -1553,7 +1553,7 @@ func TransferJdsOrder(ctx *jxcontext.Context, vendorOrderID string, storeID int)
|
|||||||
if err != nil || len(storeMaps) == 0 {
|
if err != nil || len(storeMaps) == 0 {
|
||||||
return "", fmt.Errorf("该门店未绑定平台,请先绑定后再转移!门店:[%v]", storeID)
|
return "", fmt.Errorf("该门店未绑定平台,请先绑定后再转移!门店:[%v]", storeID)
|
||||||
}
|
}
|
||||||
stores, err := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, "")
|
stores, err := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, nil, "")
|
||||||
if len(storeMaps) > 0 && len(stores) > 0 {
|
if len(storeMaps) > 0 && len(stores) > 0 {
|
||||||
if storeMaps[0].VendorStoreID == "" {
|
if storeMaps[0].VendorStoreID == "" {
|
||||||
return "", fmt.Errorf("该门店未绑定平台,或绑定有误,请联系技术部!门店:[%v]", storeID)
|
return "", fmt.Errorf("该门店未绑定平台,或绑定有误,请联系技术部!门店:[%v]", storeID)
|
||||||
|
|||||||
@@ -1284,7 +1284,7 @@ func GetMatterStoreOrderCount(ctx *jxcontext.Context, storeID int) (result *Orde
|
|||||||
err = dao.GetRows(db, &orderPays, sql, sqlParams)
|
err = dao.GetRows(db, &orderPays, sql, sqlParams)
|
||||||
if len(orderPays) != 0 {
|
if len(orderPays) != 0 {
|
||||||
orderPay := orderPays[0]
|
orderPay := orderPays[0]
|
||||||
stores, _ := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, "")
|
stores, _ := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, nil, "")
|
||||||
if len(stores) > 0 {
|
if len(stores) > 0 {
|
||||||
store := stores[0]
|
store := stores[0]
|
||||||
if store.IsBoughtMatter == model.YES {
|
if store.IsBoughtMatter == model.YES {
|
||||||
@@ -1336,7 +1336,7 @@ func RefreshJdShopOrdersEarningPrice(ctx *jxcontext.Context, orderStartTime, ord
|
|||||||
if order == nil {
|
if order == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
stores, _ := dao.GetStoreList(db, []int{jxutils.GetSaleStoreIDFromOrder(order)}, nil, nil, nil, "")
|
stores, _ := dao.GetStoreList(db, []int{jxutils.GetSaleStoreIDFromOrder(order)}, nil, nil, nil, nil, "")
|
||||||
if len(stores) > 0 {
|
if len(stores) > 0 {
|
||||||
store := stores[0]
|
store := stores[0]
|
||||||
if order.NewEarningPrice == 0 {
|
if order.NewEarningPrice == 0 {
|
||||||
|
|||||||
@@ -458,7 +458,7 @@ func DeleteConfig(ctx *jxcontext.Context, key, configType string) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
errList.AddErr(err)
|
errList.AddErr(err)
|
||||||
storeList, err2 := dao.GetStoreList(db, nil, nil, nil, nil, key)
|
storeList, err2 := dao.GetStoreList(db, nil, nil, nil, nil, nil, key)
|
||||||
if err = err2; err == nil && len(storeList) > 0 {
|
if err = err2; err == nil && len(storeList) > 0 {
|
||||||
storeIDs := make([]int, len(storeList))
|
storeIDs := make([]int, len(storeList))
|
||||||
for k, v := range storeList {
|
for k, v := range storeList {
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
@@ -222,6 +224,12 @@ func UpdateUserRole(ctx *jxcontext.Context, userIDs []string, roleIDs []int) (er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, v := range userIDs {
|
||||||
|
if user, err := dao.GetUserByID(db, "userID", v); err == nil {
|
||||||
|
user.Type = user.Type | model.UserTypeRole
|
||||||
|
dao.UpdateEntity(db, user, "Type")
|
||||||
|
}
|
||||||
|
}
|
||||||
dao.Commit(db)
|
dao.Commit(db)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -299,3 +307,51 @@ func UpdateRoleMenu(ctx *jxcontext.Context, roleIDs, menuIDs []int) (err error)
|
|||||||
dao.Commit(db)
|
dao.Commit(db)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetUserStoresResultMap(userID string) (resultMap map[int]int, err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
brandIDMap = make(map[int]int)
|
||||||
|
cityCodeMap = make(map[int]int)
|
||||||
|
storeIDMap = make(map[int]int)
|
||||||
|
brandIDs, cityCodes, storeIDs []int
|
||||||
|
stores []*model.Store
|
||||||
|
)
|
||||||
|
resultMap = make(map[int]int)
|
||||||
|
userRoles, err := dao.GetUserRole2(db, []string{userID}, nil)
|
||||||
|
for _, v := range userRoles {
|
||||||
|
if _, ok := brandIDMap[v.BrandID]; !ok {
|
||||||
|
brandIDMap[v.BrandID] = 1
|
||||||
|
}
|
||||||
|
for _, cityCode := range jxutils.StrListToIntList(strings.Split(v.CityCodes, ",")) {
|
||||||
|
if _, ok := cityCodeMap[cityCode]; !ok {
|
||||||
|
cityCodeMap[cityCode] = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, storeID := range jxutils.StrListToIntList(strings.Split(v.StoreIDs, ",")) {
|
||||||
|
if _, ok := storeIDMap[storeID]; !ok {
|
||||||
|
storeIDMap[storeID] = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for k, _ := range brandIDMap {
|
||||||
|
brandIDs = append(brandIDs, k)
|
||||||
|
}
|
||||||
|
for k, _ := range cityCodeMap {
|
||||||
|
cityCodes = append(cityCodes, k)
|
||||||
|
}
|
||||||
|
for k, _ := range storeIDMap {
|
||||||
|
storeIDs = append(storeIDs, k)
|
||||||
|
}
|
||||||
|
if cityCodeMap[0] != 0 {
|
||||||
|
stores, err = dao.GetStoreList(db, nil, nil, nil, brandIDs, nil, "")
|
||||||
|
} else {
|
||||||
|
stores, err = dao.GetStoreList(db, storeIDs, cityCodes, nil, brandIDs, nil, "")
|
||||||
|
}
|
||||||
|
for _, v := range stores {
|
||||||
|
if _, ok := resultMap[v.ID]; !ok {
|
||||||
|
resultMap[v.ID] = v.ID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultMap, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -516,7 +516,23 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
|
|||||||
} else {
|
} else {
|
||||||
retVal.Stores = storeList
|
retVal.Stores = storeList
|
||||||
}
|
}
|
||||||
|
//权限
|
||||||
|
if ctx.GetUserName() != "jxadmin" {
|
||||||
|
if user, err := dao.GetUserByID(db, "userID", ctx.GetUserID()); err == nil {
|
||||||
|
if user.Type&model.UserTypeRole != 0 {
|
||||||
|
if storeIDsMap, err := GetUserStoresResultMap(user.UserID); err == nil {
|
||||||
|
var storeList2 []*StoreExt
|
||||||
|
for _, v := range retVal.Stores {
|
||||||
|
if storeIDsMap[v.ID] != 0 {
|
||||||
|
storeList2 = append(storeList2, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
retVal.Stores = nil
|
||||||
|
retVal.Stores = storeList2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// 订单情况过滤
|
// 订单情况过滤
|
||||||
storeList, err = filterStoreByOrderInfo(db, retVal.Stores, orderTimeFrom, orderTimeTo, orderCountFrom, orderCountTo)
|
storeList, err = filterStoreByOrderInfo(db, retVal.Stores, orderTimeFrom, orderTimeTo, orderCountFrom, orderCountTo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -2254,7 +2270,7 @@ func SendAlarmVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, p
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(userList) > 0 {
|
if len(userList) > 0 {
|
||||||
allStores, err := dao.GetStoreList(db, nil, nil, nil, nil, "")
|
allStores, err := dao.GetStoreList(db, nil, nil, nil, nil, nil, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -2428,7 +2444,7 @@ func SaveAndSendAlarmVendorSnapshot(ctx *jxcontext.Context, vendorIDs, storeIDs
|
|||||||
|
|
||||||
func SyncStoresCourierInfo(ctx *jxcontext.Context, storeIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func SyncStoresCourierInfo(ctx *jxcontext.Context, storeIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
storeList2, err := dao.GetStoreList(db, storeIDs, nil, nil, nil, "")
|
storeList2, err := dao.GetStoreList(db, storeIDs, nil, nil, nil, nil, "")
|
||||||
var storeList []*model.Store
|
var storeList []*model.Store
|
||||||
for _, v := range storeList2 {
|
for _, v := range storeList2 {
|
||||||
if v.Status != model.StoreStatusDisabled {
|
if v.Status != model.StoreStatusDisabled {
|
||||||
@@ -2957,7 +2973,7 @@ func UpdateJdStoreNameAll(ctx *jxcontext.Context) (err error) {
|
|||||||
func DeletePrinterSeq(ctx *jxcontext.Context, storeIDs []int) (err error) {
|
func DeletePrinterSeq(ctx *jxcontext.Context, storeIDs []int) (err error) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
for _, v := range storeIDs {
|
for _, v := range storeIDs {
|
||||||
stores, err := dao.GetStoreList(db, []int{v}, nil, nil, nil, "")
|
stores, err := dao.GetStoreList(db, []int{v}, nil, nil, nil, nil, "")
|
||||||
if err != nil || len(stores) == 0 {
|
if err != nil || len(stores) == 0 {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -3010,7 +3026,7 @@ func checkYbParams(db *dao.DaoDB, storeMap *model.StoreMap, storeID int) (err er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stores, err := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, "")
|
stores, err := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, nil, "")
|
||||||
if len(stores) > 0 {
|
if len(stores) > 0 {
|
||||||
if configs, err := dao.QueryConfigs(dao.GetDB(), "yinbaoCookie", model.ConfigTypeCookie, ""); err == nil {
|
if configs, err := dao.QueryConfigs(dao.GetDB(), "yinbaoCookie", model.ConfigTypeCookie, ""); err == nil {
|
||||||
yinbaoCookie = configs[0].Value
|
yinbaoCookie = configs[0].Value
|
||||||
@@ -3356,7 +3372,7 @@ func DisabledStoreWithoutVendor(ctx *jxcontext.Context, isContinueWhenError, isA
|
|||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
)
|
)
|
||||||
stores, err := dao.GetStoreList(db, nil, nil, []int{model.StoreStatusClosed, model.StoreStatusHaveRest, model.StoreStatusOpened}, nil, "")
|
stores, err := dao.GetStoreList(db, nil, nil, []int{model.StoreStatusClosed, model.StoreStatusHaveRest, model.StoreStatusOpened}, nil, nil, "")
|
||||||
task := tasksch.NewParallelTask("DisabledStoreWithoutVendor", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError), ctx,
|
task := tasksch.NewParallelTask("DisabledStoreWithoutVendor", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
store := batchItemList[0].(*model.Store)
|
store := batchItemList[0].(*model.Store)
|
||||||
@@ -3733,7 +3749,7 @@ func GetDiffJxStoreAndMTWMStoreInfo(ctx *jxcontext.Context, storeIDs []int) (err
|
|||||||
tmpDiffStore := &TmpDiffStore{
|
tmpDiffStore := &TmpDiffStore{
|
||||||
StoreID: v.StoreID,
|
StoreID: v.StoreID,
|
||||||
}
|
}
|
||||||
stores, err := dao.GetStoreList(db, []int{v.StoreID}, nil, nil, nil, "")
|
stores, err := dao.GetStoreList(db, []int{v.StoreID}, nil, nil, nil, nil, "")
|
||||||
store := stores[0]
|
store := stores[0]
|
||||||
place, _ := dao.GetPlaceByCode(db, store.CityCode)
|
place, _ := dao.GetPlaceByCode(db, store.CityCode)
|
||||||
tmpDiffStore.City = place.Name
|
tmpDiffStore.City = place.Name
|
||||||
|
|||||||
@@ -931,7 +931,7 @@ func UpdateStoresSkus(ctx *jxcontext.Context, causeFlag int, storeIDs []int, sku
|
|||||||
func UpdateStoresSkusWithoutSync(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*StoreSkuBindInfo, isRefreshHigh bool) (err error) {
|
func UpdateStoresSkusWithoutSync(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*StoreSkuBindInfo, isRefreshHigh bool) (err error) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
if len(storeIDs) == 0 {
|
if len(storeIDs) == 0 {
|
||||||
stores, _ := dao.GetStoreList(db, nil, nil, nil, nil, "")
|
stores, _ := dao.GetStoreList(db, nil, nil, nil, nil, nil, "")
|
||||||
for _, v := range stores {
|
for _, v := range stores {
|
||||||
storeIDs = append(storeIDs, v.ID)
|
storeIDs = append(storeIDs, v.ID)
|
||||||
}
|
}
|
||||||
@@ -3267,7 +3267,7 @@ func FocusStoreSkusByExcelBin(ctx *jxcontext.Context, reader io.Reader, isAsync,
|
|||||||
skuIDs = append(skuIDs, k)
|
skuIDs = append(skuIDs, k)
|
||||||
}
|
}
|
||||||
skuList, err := dao.GetSkus(db, skuIDs, nil, nil, nil, nil)
|
skuList, err := dao.GetSkus(db, skuIDs, nil, nil, nil, nil)
|
||||||
storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, "")
|
storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, nil, "")
|
||||||
if err != nil && len(skuList) == 0 {
|
if err != nil && len(skuList) == 0 {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@@ -3454,7 +3454,7 @@ func AutoFocusStoreSkusForTopSkus(ctx *jxcontext.Context, isAsync, isContinueWhe
|
|||||||
var (
|
var (
|
||||||
result1 []interface{}
|
result1 []interface{}
|
||||||
)
|
)
|
||||||
storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, "")
|
storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, nil, "")
|
||||||
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||||
switch step {
|
switch step {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -3552,7 +3552,7 @@ func AutoFocusStoreSkusWithoutFocus(ctx *jxcontext.Context, skuIDs []int, isSync
|
|||||||
nameMap = make(map[int]*StoreSkuBindInfo)
|
nameMap = make(map[int]*StoreSkuBindInfo)
|
||||||
)
|
)
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, "")
|
storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, nil, "")
|
||||||
for _, v := range storeList {
|
for _, v := range storeList {
|
||||||
storeSkuList, _ := dao.GetStoreSkusAndSkuName(db, []int{v.ID}, skuIDs, nil)
|
storeSkuList, _ := dao.GetStoreSkusAndSkuName(db, []int{v.ID}, skuIDs, nil)
|
||||||
for _, vv := range storeSkuList {
|
for _, vv := range storeSkuList {
|
||||||
@@ -4155,7 +4155,7 @@ func BackUpStoreSkuBind(ctx *jxcontext.Context, isAsync, isContinueWhenError boo
|
|||||||
SnapshotAt: snapshotAt.AddDate(0, 0, -5),
|
SnapshotAt: snapshotAt.AddDate(0, 0, -5),
|
||||||
}
|
}
|
||||||
dao.DeleteEntity(db, storeSkuBindHis, "SnapshotAt")
|
dao.DeleteEntity(db, storeSkuBindHis, "SnapshotAt")
|
||||||
storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, "")
|
storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, nil, "")
|
||||||
task := tasksch.NewParallelTask("BackUpStoreSkuBind", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
task := tasksch.NewParallelTask("BackUpStoreSkuBind", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
store := batchItemList[0].(*model.Store)
|
store := batchItemList[0].(*model.Store)
|
||||||
@@ -4701,7 +4701,7 @@ func doStoreSkuAudit(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*Sto
|
|||||||
time.Sleep(time.Second / 5)
|
time.Sleep(time.Second / 5)
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
for _, storeID := range storeIDs {
|
for _, storeID := range storeIDs {
|
||||||
stores, _ := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, "")
|
stores, _ := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, nil, "")
|
||||||
//扣点的门店改价不进审核
|
//扣点的门店改价不进审核
|
||||||
if len(stores) > 0 {
|
if len(stores) > 0 {
|
||||||
if stores[0].PayPercentage <= 50 || stores[0].StoreLevel == "E" || stores[0].StoreLevel == "D" {
|
if stores[0].PayPercentage <= 50 || stores[0].StoreLevel == "E" || stores[0].StoreLevel == "D" {
|
||||||
|
|||||||
@@ -1321,7 +1321,7 @@ func SetMTPSStatus(ctx *jxcontext.Context, storeId, courierStatus int) {
|
|||||||
//&& CourierStatus != 0
|
//&& CourierStatus != 0
|
||||||
if storeId != 0 {
|
if storeId != 0 {
|
||||||
var ShopName string
|
var ShopName string
|
||||||
StoreLists, _ := dao.GetStoreList(nil, []int{storeId}, nil, nil, nil, "")
|
StoreLists, _ := dao.GetStoreList(nil, []int{storeId}, nil, nil, nil, nil, "")
|
||||||
ShopName = StoreLists[0].Name
|
ShopName = StoreLists[0].Name
|
||||||
StoreInfoList := new(mtpsapi.GetStoreStatusResultAll)
|
StoreInfoList := new(mtpsapi.GetStoreStatusResultAll)
|
||||||
StoreInfoList, _ = api.MtpsAPI.GetStoreStatus(ShopName)
|
StoreInfoList, _ = api.MtpsAPI.GetStoreStatus(ShopName)
|
||||||
@@ -1462,7 +1462,7 @@ func SetMTPSStatus(ctx *jxcontext.Context, storeId, courierStatus int) {
|
|||||||
//test:
|
//test:
|
||||||
for _, StoreCourierList1 := range StoreCourierList {
|
for _, StoreCourierList1 := range StoreCourierList {
|
||||||
diff := false
|
diff := false
|
||||||
StoreLists, _ := dao.GetStoreList(db, []int{StoreCourierList1.StoreID}, nil, nil, nil, "")
|
StoreLists, _ := dao.GetStoreList(db, []int{StoreCourierList1.StoreID}, nil, nil, nil, nil, "")
|
||||||
if StoreLists == nil {
|
if StoreLists == nil {
|
||||||
globals.SugarLogger.Debugf("StoreID为:%s,在store表未找到", StoreCourierList1.StoreID)
|
globals.SugarLogger.Debugf("StoreID为:%s,在store表未找到", StoreCourierList1.StoreID)
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ func TryAddStoreBossRole4User(ctx *jxcontext.Context, user *model.User) (err err
|
|||||||
if user.Type&model.UserTypeStoreBoss != 0 {
|
if user.Type&model.UserTypeStoreBoss != 0 {
|
||||||
userMobile := user.GetMobile()
|
userMobile := user.GetMobile()
|
||||||
if userMobile != "" {
|
if userMobile != "" {
|
||||||
if storeList, err := dao.GetStoreList(dao.GetDB(), nil, nil, nil, []string{userMobile}, ""); err == nil && len(storeList) > 0 {
|
if storeList, err := dao.GetStoreList(dao.GetDB(), nil, nil, nil, nil, []string{userMobile}, ""); err == nil && len(storeList) > 0 {
|
||||||
roleList := make([]*authz.RoleInfo, len(storeList))
|
roleList := make([]*authz.RoleInfo, len(storeList))
|
||||||
for k, v := range storeList {
|
for k, v := range storeList {
|
||||||
roleList[k] = autils.NewStoreBossRole(v.ID)
|
roleList[k] = autils.NewStoreBossRole(v.ID)
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn
|
|||||||
resultMap = make(map[int]map[int]*model.PriceReferSnapshot)
|
resultMap = make(map[int]map[int]*model.PriceReferSnapshot)
|
||||||
resultCountryMap = make(map[int]*model.PriceReferSnapshot)
|
resultCountryMap = make(map[int]*model.PriceReferSnapshot)
|
||||||
)
|
)
|
||||||
storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, "")
|
storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, nil, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1037,3 +1037,17 @@ func polarTriangleArea(tan1, lng1, tan2, lng2 float64) (s float64) {
|
|||||||
t := tan1 * tan2
|
t := tan1 * tan2
|
||||||
return 2 * math.Atan2(t*math.Sin(deltaLng), 1+t*math.Cos(deltaLng))
|
return 2 * math.Atan2(t*math.Sin(deltaLng), 1+t*math.Cos(deltaLng))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IntListToStrList(i []int) (s []string) {
|
||||||
|
for _, v := range i {
|
||||||
|
s = append(s, utils.Int2Str(v))
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
func StrListToIntList(s []string) (i []int) {
|
||||||
|
for _, v := range s {
|
||||||
|
i = append(i, utils.Str2Int(v))
|
||||||
|
}
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ func isPushSMS(order *model.GoodsOrder) bool {
|
|||||||
|
|
||||||
func updateStoreSMSNotifyMark(order *model.GoodsOrder) (err error) {
|
func updateStoreSMSNotifyMark(order *model.GoodsOrder) (err error) {
|
||||||
var db = dao.GetDB()
|
var db = dao.GetDB()
|
||||||
stores, _ := dao.GetStoreList(db, []int{order.StoreID}, nil, nil, nil, "")
|
stores, _ := dao.GetStoreList(db, []int{order.StoreID}, nil, nil, nil, nil, "")
|
||||||
if len(stores) > 0 {
|
if len(stores) > 0 {
|
||||||
stores[0].SMSNotifyMark = model.YES
|
stores[0].SMSNotifyMark = model.YES
|
||||||
_, err = dao.UpdateEntity(db, stores[0], "SMSNotifyMark")
|
_, err = dao.UpdateEntity(db, stores[0], "SMSNotifyMark")
|
||||||
@@ -148,7 +148,7 @@ func NotifyNewUserOrder(order *model.GoodsOrder) (err error) {
|
|||||||
if order.ConsigneeMobile2 != "" {
|
if order.ConsigneeMobile2 != "" {
|
||||||
mobile = order.ConsigneeMobile2
|
mobile = order.ConsigneeMobile2
|
||||||
uoSMS, err := dao.GetUserOrderSMS(db, mobile, "")
|
uoSMS, err := dao.GetUserOrderSMS(db, mobile, "")
|
||||||
stores, _ := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, "")
|
stores, _ := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, nil, "")
|
||||||
if len(stores) > 0 {
|
if len(stores) > 0 {
|
||||||
if stores[0].Tel1 == "" {
|
if stores[0].Tel1 == "" {
|
||||||
storeTel = stores[0].Tel2
|
storeTel = stores[0].Tel2
|
||||||
@@ -205,7 +205,7 @@ func NotifyNewCourierOrder(bill *model.Waybill) (err error) {
|
|||||||
} else {
|
} else {
|
||||||
storeID = order.StoreID
|
storeID = order.StoreID
|
||||||
}
|
}
|
||||||
stores, _ := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, "")
|
stores, _ := dao.GetStoreList(db, []int{storeID}, nil, nil, nil, nil, "")
|
||||||
if len(stores) > 0 {
|
if len(stores) > 0 {
|
||||||
if stores[0].Tel1 == "" {
|
if stores[0].Tel1 == "" {
|
||||||
storeTel = stores[0].Tel2
|
storeTel = stores[0].Tel2
|
||||||
|
|||||||
@@ -90,6 +90,33 @@ func GetUserRole(db *DaoDB, userIDs []string, roleIDs []int) (userRoles []*model
|
|||||||
return userRoles, err
|
return userRoles, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetUserRole2Result struct {
|
||||||
|
model.Role
|
||||||
|
model.UserRole
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetUserRole2(db *DaoDB, userIDs []string, roleIDs []int) (userRoles []*GetUserRole2Result, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT *
|
||||||
|
FROM user_role a
|
||||||
|
JOIN role b ON a.role_id = b.id
|
||||||
|
WHERE a.deleted_at = ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
if len(userIDs) > 0 {
|
||||||
|
sql += " AND a.user_id IN (" + GenQuestionMarks(len(userIDs)) + ")"
|
||||||
|
sqlParams = append(sqlParams, userIDs)
|
||||||
|
}
|
||||||
|
if len(roleIDs) > 0 {
|
||||||
|
sql += " AND a.role_id IN (" + GenQuestionMarks(len(roleIDs)) + ")"
|
||||||
|
sqlParams = append(sqlParams, roleIDs)
|
||||||
|
}
|
||||||
|
err = GetRows(db, &userRoles, sql, sqlParams)
|
||||||
|
return userRoles, err
|
||||||
|
}
|
||||||
|
|
||||||
func GetRoleMenu(db *DaoDB, roleIDs, menuIDs []int) (roleMenus []*model.RoleMenu, err error) {
|
func GetRoleMenu(db *DaoDB, roleIDs, menuIDs []int) (roleMenus []*model.RoleMenu, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT *
|
SELECT *
|
||||||
@@ -110,7 +137,3 @@ func GetRoleMenu(db *DaoDB, roleIDs, menuIDs []int) (roleMenus []*model.RoleMenu
|
|||||||
err = GetRows(db, &roleMenus, sql, sqlParams)
|
err = GetRows(db, &roleMenus, sql, sqlParams)
|
||||||
return roleMenus, err
|
return roleMenus, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUserStores(db *DaoDB, userID string) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -514,7 +514,7 @@ func GetOpenedStoreCouriersByStoreID(db *DaoDB, storeID, vendorID int) (storeMap
|
|||||||
return storeMaps, nil
|
return storeMaps, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStoreList(db *DaoDB, idList, cityCodes, statuss []int, mobileList []string, shortRoleName string) (storeList []*model.Store, err error) {
|
func GetStoreList(db *DaoDB, idList, cityCodes, statuss, brandIDs []int, mobileList []string, shortRoleName string) (storeList []*model.Store, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT t1.*
|
SELECT t1.*
|
||||||
FROM store t1
|
FROM store t1
|
||||||
@@ -534,6 +534,10 @@ func GetStoreList(db *DaoDB, idList, cityCodes, statuss []int, mobileList []stri
|
|||||||
sql += " AND t1.status IN (" + GenQuestionMarks(len(statuss)) + ")"
|
sql += " AND t1.status IN (" + GenQuestionMarks(len(statuss)) + ")"
|
||||||
sqlParams = append(sqlParams, statuss)
|
sqlParams = append(sqlParams, statuss)
|
||||||
}
|
}
|
||||||
|
if len(brandIDs) > 0 {
|
||||||
|
sql += " AND t1.brand_id IN (" + GenQuestionMarks(len(brandIDs)) + ")"
|
||||||
|
sqlParams = append(sqlParams, brandIDs)
|
||||||
|
}
|
||||||
if len(mobileList) > 0 {
|
if len(mobileList) > 0 {
|
||||||
sql += " AND (t1.tel1 IN (" + GenQuestionMarks(len(mobileList)) + ") OR t1.tel2 IN (" + GenQuestionMarks(len(mobileList)) + "))"
|
sql += " AND (t1.tel1 IN (" + GenQuestionMarks(len(mobileList)) + ") OR t1.tel2 IN (" + GenQuestionMarks(len(mobileList)) + "))"
|
||||||
sqlParams = append(sqlParams, mobileList, mobileList)
|
sqlParams = append(sqlParams, mobileList, mobileList)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const (
|
|||||||
UserTypeStoreBoss = 2
|
UserTypeStoreBoss = 2
|
||||||
UserTypeOperator = 4
|
UserTypeOperator = 4
|
||||||
UserTypeBoss = 8
|
UserTypeBoss = 8
|
||||||
|
UserTypeRole = 16
|
||||||
UserTypeNonConsumer = ^1
|
UserTypeNonConsumer = ^1
|
||||||
|
|
||||||
MemberTypeDiscountCard = 1 //会员折扣卡
|
MemberTypeDiscountCard = 1 //会员折扣卡
|
||||||
@@ -27,6 +28,7 @@ var (
|
|||||||
UserTypeStoreBoss: "门店老板",
|
UserTypeStoreBoss: "门店老板",
|
||||||
UserTypeOperator: "运营",
|
UserTypeOperator: "运营",
|
||||||
UserTypeBoss: "老板",
|
UserTypeBoss: "老板",
|
||||||
|
UserTypeRole: "受权限管理",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user