+ EnableWXAuth2

This commit is contained in:
gazebo
2019-08-12 17:54:00 +08:00
parent c5a5f4777b
commit 339b60c374
6 changed files with 119 additions and 40 deletions

View File

@@ -244,7 +244,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
sqlWhereParams = append(sqlWhereParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike)
if keywordInt64, err2 := strconv.ParseInt(keyword, 10, 64); err2 == nil {
if jxutils.IsLegalMobileNumber(keywordInt64) {
if !globals.EnableWXAuth2 && jxutils.IsLegalMobileNumber(keywordInt64) {
sql += `
LEFT JOIN weixins wx1 ON t1.id = wx1.jxstoreid AND wx1.parentid = -1 AND wx1.tel = ?
LEFT JOIN weixins wx2 ON t1.id = wx2.jxstoreid AND wx2.parentid = -1

View File

@@ -8,6 +8,7 @@ import (
"sync"
"time"
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
"git.rosy.net.cn/jx-callback/business/partner/delivery"
"git.rosy.net.cn/baseapi/platformapi/jdapi"
@@ -899,18 +900,32 @@ func PrintMsg(ctx *jxcontext.Context, vendorID int, id1, id2, msgTitle, msgConte
}
func UpdateAllWeiXinRemark(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) {
var weixinList []*legacymodel.WeiXins
if err = dao.GetRows(dao.GetDB(), &weixinList, `
SELECT *
var mobileList []string
sql := `
SELECT tel
FROM weixins
WHERE openid <> '' AND tel <> ''
`); err == nil {
WHERE openid <> '' AND tel <> ''`
sqlParams := []interface{}{}
if globals.EnableWXAuth2 {
sql = `
SELECT t1.mobile
FROM user t1
JOIN auth_bind t2 ON t2.user_id = t1.user_id AND t2.deleted_at = ? and t2.type = ?
WHERE t1.deleted_at = ? AND t1.type & ? <> 0`
sqlParams = []interface{}{
utils.DefaultTimeValue,
weixin.AuthTypeMP,
utils.DefaultTimeValue,
model.UserTypeStoreBoss,
}
}
if err = dao.GetRows(dao.GetDB(), &mobileList, sql, sqlParams...); err == nil {
rootTask := tasksch.NewParallelTask("刷新微信备注", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
weixins := batchItemList[0].(*legacymodel.WeiXins)
err = jxutils.HandleUserWXRemark(dao.GetDB(), weixins.Tel)
tel := batchItemList[0].(string)
err = jxutils.HandleUserWXRemark(dao.GetDB(), tel)
return nil, err
}, weixinList)
}, mobileList)
tasksch.ManageTask(rootTask).Run()
if !isAsync {
_, err = rootTask.GetResult(0)