This commit is contained in:
suyl
2021-07-19 16:48:44 +08:00
parent 145211bbe2
commit 38891c676a
3 changed files with 41 additions and 43 deletions

View File

@@ -176,7 +176,7 @@ func Init() {
}, 5*time.Second, 10*time.Minute)
ScheduleTimerFuncByInterval(func() {
report.RefreshStoreManageState(jxcontext.AdminCtx)
report.RefreshStoreManageState(jxcontext.AdminCtx, nil)
}, 5*time.Second, 20*time.Minute)
ScheduleTimerFuncByInterval(func() {

View File

@@ -389,7 +389,7 @@ func GetManageState(ctx *jxcontext.Context, cityCodes []int, vendorID int) (getM
return getManageStateResult, err
}
func RefreshStoreManageState(ctx *jxcontext.Context) {
func RefreshStoreManageState(ctx *jxcontext.Context, storeIDs []int) {
var (
db = dao.GetDB()
vendorIDs = []int{model.VendorIDJD, model.VendorIDMTWM, model.VendorIDEBAI}
@@ -398,8 +398,8 @@ func RefreshStoreManageState(ctx *jxcontext.Context) {
task := tasksch.NewParallelTask("RefreshStoreManageState", tasksch.NewParallelConfig().SetParallelCount(3).SetIsContinueWhenError(true), ctx,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
vendorID := batchItemList[0].(int)
storeMaps, err := dao.GetStoresMapList(db, []int{vendorID}, nil, []int{model.StoreStatusOpened, model.StoreStatusClosed, model.StoreStatusHaveRest}, model.StoreStatusAll, model.StoreIsSyncAll, "", "", "")
storeManageStates, err := dao.GetStoreManageStateSimple(db, nil, nil, vendorID)
storeMaps, err := dao.GetStoresMapList(db, []int{vendorID}, storeIDs, []int{model.StoreStatusOpened, model.StoreStatusClosed, model.StoreStatusHaveRest}, model.StoreStatusAll, model.StoreIsSyncAll, "", "", "")
storeManageStates, err := dao.GetStoreManageStateSimple(db, storeIDs, nil, vendorID)
var (
storeMapsMap = make(map[int]*model.StoreMap)
storeManagesMap = make(map[int]*model.StoreManageState)

View File

@@ -3,11 +3,8 @@ package tempop
import (
"bytes"
"context"
"crypto/md5"
"crypto/sha1"
"fmt"
"git.rosy.net.cn/jx-callback/business/auth2"
"git.rosy.net.cn/jx-callback/business/jxstore/permission"
"git.rosy.net.cn/jx-callback/business/jxstore/report"
"net"
"regexp"
"strings"
@@ -1954,41 +1951,42 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) {
//`
//weixinmsg.SmartMessageTemplateSend("oYN_usv1RPvrSxCvo1WsbwI8lZa0", weixinmsg.WX_NEWORDER_TEMPLATE_ID, "", weixinmsg.WX_MINI_TO_ORDER_PAGE_URL+fmt.Sprintf("?jxStoreId=%v&data=%v", storeID, data), nil)
//加门店账号
var (
db = dao.GetDB()
user = &model.User{}
)
store, _ := dao.GetStoreDetail(db, 668023, model.VendorIDJX, "")
if store.Tel1 != "" {
if user, _ = dao.GetUserByID(db, "mobile", store.Tel1); err == nil {
if user != nil {
//bind
if auths, _ := dao.GetUserBindAuthInfo(db, user.UserID, 0, []string{auth2.AuthTypePassword}, "", "", nil); len(auths) > 0 {
//已经有密码了?
auth := auths[0]
auth.AuthSecret2 = "AA0D5ABE801F11E98489525400AE46A6"
auth.AuthSecret = fmt.Sprintf("%x", sha1.Sum([]byte(fmt.Sprintf("%x", md5.Sum([]byte(store.Tel1)))+auth.AuthSecret2)))
} else {
auth := &model.AuthBind{
UserID: user.UserID,
Type: auth2.AuthTypePassword,
Status: model.YES,
AuthID: user.UserID,
AuthSecret2: "AA0D5ABE801F11E98489525400AE46A6",
AuthSecret: fmt.Sprintf("%x", sha1.Sum([]byte(fmt.Sprintf("%x", md5.Sum([]byte(store.Tel1)))+"AA0D5ABE801F11E98489525400AE46A6"))),
}
dao.WrapAddIDCULDEntity(auth, "")
dao.CreateEntity(db, auth)
}
user.BindStoreID = store.ID
user.BindStoreUser = store.Tel1
dao.UpdateEntity(db, user, "BindStoreID", "BindStoreUser")
permission.UpdateUserRole(ctx, []string{user.UserID}, []int{31})
} else {
//注册
}
}
}
//var (
// db = dao.GetDB()
// user = &model.User{}
//)
//store, _ := dao.GetStoreDetail(db, 668023, model.VendorIDJX, "")
//if store.Tel1 != "" {
// if user, _ = dao.GetUserByID(db, "mobile", store.Tel1); err == nil {
// if user != nil {
// //bind
// if auths, _ := dao.GetUserBindAuthInfo(db, user.UserID, 0, []string{auth2.AuthTypePassword}, "", "", nil); len(auths) > 0 {
// //已经有密码了?
// auth := auths[0]
// auth.AuthSecret2 = "AA0D5ABE801F11E98489525400AE46A6"
// auth.AuthSecret = fmt.Sprintf("%x", sha1.Sum([]byte(fmt.Sprintf("%x", md5.Sum([]byte(store.Tel1)))+auth.AuthSecret2)))
// } else {
// auth := &model.AuthBind{
// UserID: user.UserID,
// Type: auth2.AuthTypePassword,
// Status: model.YES,
// AuthID: user.UserID,
// AuthSecret2: "AA0D5ABE801F11E98489525400AE46A6",
// AuthSecret: fmt.Sprintf("%x", sha1.Sum([]byte(fmt.Sprintf("%x", md5.Sum([]byte(store.Tel1)))+"AA0D5ABE801F11E98489525400AE46A6"))),
// }
// dao.WrapAddIDCULDEntity(auth, "")
// dao.CreateEntity(db, auth)
// }
// user.BindStoreID = store.ID
// user.BindStoreUser = store.Tel1
// dao.UpdateEntity(db, user, "BindStoreID", "BindStoreUser")
// permission.UpdateUserRole(ctx, []string{user.UserID}, []int{31})
// } else {
// //注册
// }
// }
//}
report.RefreshStoreManageState(ctx, []int{668023})
return err
}