调整依赖结构,jxutils不依赖于dao,dao依赖于jxutils
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/dingding"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
||||
"git.rosy.net.cn/jx-callback/business/authz"
|
||||
"git.rosy.net.cn/jx-callback/business/authz/autils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
@@ -201,7 +202,7 @@ func HandleOrder4Consignee(order *model.GoodsOrder) (err error) {
|
||||
if mobileNumber == "" && order.VendorUserID == "" {
|
||||
return fmt.Errorf("订单:%s手机号与平台用户标识都是空", order.VendorOrderID)
|
||||
}
|
||||
authType := jxutils.GetAuthType4Vendor(order.VendorID)
|
||||
authType := dao.GetAuthType4Vendor(order.VendorID)
|
||||
if authType == "" {
|
||||
msg := fmt.Sprintf("平台ID:%d当前不被支持,请联系开发", order.VendorID)
|
||||
globals.SugarLogger.Warn(msg)
|
||||
@@ -470,7 +471,7 @@ func AddRoles4User(ctx *jxcontext.Context, userID string, rList []*authz.RoleInf
|
||||
if err = api2.RoleMan.AddRole4User(userID, v); err != nil {
|
||||
errList.AddErr(err)
|
||||
} else if v.StoreID > 0 {
|
||||
jxutils.HandleUserWXRemark(dao.GetDB(), userID, true)
|
||||
HandleUserWXRemark(dao.GetDB(), userID, true)
|
||||
}
|
||||
} else {
|
||||
errList.AddErr(err)
|
||||
@@ -485,7 +486,7 @@ func DeleteRoles4User(ctx *jxcontext.Context, userID string, rList []*authz.Role
|
||||
if err = api2.RoleMan.DeleteRole4User(userID, v); err != nil {
|
||||
errList.AddErr(err)
|
||||
} else if v.StoreID > 0 {
|
||||
jxutils.HandleUserWXRemark(dao.GetDB(), userID, true)
|
||||
HandleUserWXRemark(dao.GetDB(), userID, true)
|
||||
}
|
||||
}
|
||||
return errList.GetErrListAsOne()
|
||||
@@ -504,7 +505,7 @@ func AddUsers4Role(ctx *jxcontext.Context, r *authz.RoleInfo, userIDList []strin
|
||||
if err = api2.RoleMan.AddRole4User(v, r); err != nil {
|
||||
errList.AddErr(err)
|
||||
} else if r.StoreID > 0 {
|
||||
jxutils.HandleUserWXRemark(dao.GetDB(), v, true)
|
||||
HandleUserWXRemark(dao.GetDB(), v, true)
|
||||
}
|
||||
}
|
||||
return errList.GetErrListAsOne()
|
||||
@@ -516,7 +517,7 @@ func DeleteUsers4Role(ctx *jxcontext.Context, r *authz.RoleInfo, userIDList []st
|
||||
if err = api2.RoleMan.DeleteRole4User(v, r); err != nil {
|
||||
errList.AddErr(err)
|
||||
} else if r.StoreID > 0 {
|
||||
jxutils.HandleUserWXRemark(dao.GetDB(), v, true)
|
||||
HandleUserWXRemark(dao.GetDB(), v, true)
|
||||
}
|
||||
}
|
||||
return errList.GetErrListAsOne()
|
||||
@@ -713,3 +714,66 @@ func GetSelfInfo(ctx *jxcontext.Context) (user *model.User, err error) {
|
||||
}
|
||||
return user, err
|
||||
}
|
||||
|
||||
func HandleUserWXRemark(db *dao.DaoDB, mobile string, mobileIsUerID bool) (err error) {
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
openIDs := []string{}
|
||||
storeID := 0
|
||||
remark := ""
|
||||
|
||||
// if !globals.DisableWXAuth1 {
|
||||
// wxinfo, err := dao.GetUserStoreInfo(db, "tel", mobile)
|
||||
// if err == nil {
|
||||
// openIDs = []string{wxinfo.OpenID}
|
||||
// storeID = wxinfo.JxStoreID
|
||||
// }
|
||||
// }
|
||||
if globals.EnableWXAuth2 {
|
||||
userID := ""
|
||||
if mobileIsUerID {
|
||||
userID = mobile
|
||||
} else {
|
||||
userList, _, err2 := dao.GetUsers(db, model.UserTypeStoreBoss, "", nil, "", mobile, 0, -1)
|
||||
if err = err2; len(userList) > 0 {
|
||||
userID = userList[0].GetID()
|
||||
}
|
||||
}
|
||||
if userID != "" {
|
||||
authBindList, err2 := dao.GetUserBindAuthInfo(db, userID, model.AuthBindTypeAuth, []string{weixin.AuthTypeMP}, "", "")
|
||||
if err = err2; err == nil {
|
||||
for _, v := range authBindList {
|
||||
openIDs = append(openIDs, v.AuthID)
|
||||
}
|
||||
}
|
||||
roleList, err2 := api2.RoleMan.GetUserRoleList(userID)
|
||||
if err = err2; err == nil && len(roleList) > 0 {
|
||||
storeID = roleList[0].StoreID
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(openIDs) > 0 {
|
||||
if storeID > 0 {
|
||||
store := &model.Store{}
|
||||
store.ID = storeID
|
||||
if err = dao.GetEntity(db, store); err == nil {
|
||||
city := &model.Place{
|
||||
Code: store.CityCode,
|
||||
}
|
||||
if err = dao.GetEntity(db, city, "Code"); err == nil {
|
||||
remark = city.Name + "-" + store.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
if globals.EnableStoreWrite {
|
||||
for _, openID := range openIDs {
|
||||
err = api.WeixinAPI.CBUpdateRemark(openID, remark)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -954,7 +954,7 @@ func UpdateAllWeiXinRemark(ctx *jxcontext.Context, isAsync, isContinueWhenError
|
||||
rootTask := tasksch.NewParallelTask("刷新微信备注", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
tel := batchItemList[0].(string)
|
||||
err = jxutils.HandleUserWXRemark(dao.GetDB(), tel, false)
|
||||
err = cms.HandleUserWXRemark(dao.GetDB(), tel, false)
|
||||
return nil, err
|
||||
}, mobileList)
|
||||
tasksch.ManageTask(rootTask).Run()
|
||||
|
||||
@@ -15,12 +15,9 @@ import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/baseapi/utils/routinepool"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"git.rosy.net.cn/jx-callback/globals/api2"
|
||||
"github.com/qiniu/api.v7/storage"
|
||||
)
|
||||
|
||||
@@ -457,69 +454,6 @@ func Strings2Objs(strAndObjAddPairs ...interface{}) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func HandleUserWXRemark(db *dao.DaoDB, mobile string, mobileIsUerID bool) (err error) {
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
openIDs := []string{}
|
||||
storeID := 0
|
||||
remark := ""
|
||||
|
||||
// if !globals.DisableWXAuth1 {
|
||||
// wxinfo, err := dao.GetUserStoreInfo(db, "tel", mobile)
|
||||
// if err == nil {
|
||||
// openIDs = []string{wxinfo.OpenID}
|
||||
// storeID = wxinfo.JxStoreID
|
||||
// }
|
||||
// }
|
||||
if globals.EnableWXAuth2 {
|
||||
userID := ""
|
||||
if mobileIsUerID {
|
||||
userID = mobile
|
||||
} else {
|
||||
userList, _, err2 := dao.GetUsers(db, model.UserTypeStoreBoss, "", nil, "", mobile, 0, -1)
|
||||
if err = err2; len(userList) > 0 {
|
||||
userID = userList[0].GetID()
|
||||
}
|
||||
}
|
||||
if userID != "" {
|
||||
authBindList, err2 := dao.GetUserBindAuthInfo(db, userID, model.AuthBindTypeAuth, []string{weixin.AuthTypeMP}, "", "")
|
||||
if err = err2; err == nil {
|
||||
for _, v := range authBindList {
|
||||
openIDs = append(openIDs, v.AuthID)
|
||||
}
|
||||
}
|
||||
roleList, err2 := api2.RoleMan.GetUserRoleList(userID)
|
||||
if err = err2; err == nil && len(roleList) > 0 {
|
||||
storeID = roleList[0].StoreID
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(openIDs) > 0 {
|
||||
if storeID > 0 {
|
||||
store := &model.Store{}
|
||||
store.ID = storeID
|
||||
if err = dao.GetEntity(db, store); err == nil {
|
||||
city := &model.Place{
|
||||
Code: store.CityCode,
|
||||
}
|
||||
if err = dao.GetEntity(db, city, "Code"); err == nil {
|
||||
remark = city.Name + "-" + store.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
if globals.EnableStoreWrite {
|
||||
for _, openID := range openIDs {
|
||||
err = api.WeixinAPI.CBUpdateRemark(openID, remark)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func RefreshOrderSkuRelated(order *model.GoodsOrder) *model.GoodsOrder {
|
||||
order.SkuCount = 0
|
||||
order.GoodsCount = 0
|
||||
@@ -723,14 +657,6 @@ func GetRealMobile4Order(order *model.GoodsOrder) (mobileNumber string) {
|
||||
return mobileNumber
|
||||
}
|
||||
|
||||
func GetAuthType4Vendor(vendorID int) (authType string) {
|
||||
authType = dao.ConvertJsonFieldPrefix(model.VendorNames[vendorID])
|
||||
if authType != "" {
|
||||
authType = "vendor." + authType
|
||||
}
|
||||
return authType
|
||||
}
|
||||
|
||||
func GuessDataResourceVendor(resourceURL string) (vendorID int) {
|
||||
vendorID = -1
|
||||
for tmpVendorID, urlList := range resourceTypeMap {
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"github.com/boombuler/barcode"
|
||||
"github.com/boombuler/barcode/code128"
|
||||
@@ -370,11 +369,19 @@ func IsEmptyID(id int64) bool {
|
||||
}
|
||||
|
||||
func FormalizePageSize(pageSize int) int {
|
||||
return dao.FormalizePageSize(pageSize)
|
||||
if pageSize == 0 {
|
||||
return model.DefPageSize
|
||||
} else if pageSize < 0 {
|
||||
return model.UnlimitedPageSize
|
||||
}
|
||||
return pageSize
|
||||
}
|
||||
|
||||
func FormalizePageOffset(pageSize int) int {
|
||||
return dao.FormalizePageOffset(pageSize)
|
||||
func FormalizePageOffset(offset int) int {
|
||||
if offset < 0 {
|
||||
offset = 0
|
||||
}
|
||||
return offset
|
||||
}
|
||||
|
||||
func FormalizeName(name string) string {
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
@@ -71,8 +72,8 @@ func GetActVendorInfo(db *DaoDB, actID int, vendorIDs []int) (actMap map[int]*mo
|
||||
|
||||
func GetActStoreSkuVendorList(db *DaoDB, actID int, vendorIDs, storeIDs, skuIDs []int, keyword string, offset, pageSize int) (totalCount int, actStoreSkuList []*model.ActStoreSku2, err error) {
|
||||
globals.SugarLogger.Debugf("GetActStoreSkuVendorList actID:%d", actID)
|
||||
offset = FormalizePageOffset(offset)
|
||||
pageSize = FormalizePageSize(pageSize)
|
||||
offset = jxutils.FormalizePageOffset(offset)
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
|
||||
leftOrEmpty := ""
|
||||
if len(vendorIDs) == 1 && (vendorIDs[0] == -1 || vendorIDs[0] == model.VendorIDJX) {
|
||||
@@ -178,8 +179,8 @@ func QueryActs(db *DaoDB, actID int, offset, pageSize int, syncStatus int, keywo
|
||||
if actID == 0 && utils.IsTimeZero(createdAtFrom) && utils.IsTimeZero(beginAt) {
|
||||
return nil, fmt.Errorf("actID,createdAtFrom和beginAt中,至少要指定一个条件")
|
||||
}
|
||||
offset = FormalizePageOffset(offset)
|
||||
pageSize = FormalizePageSize(pageSize)
|
||||
offset = jxutils.FormalizePageOffset(offset)
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
isGetAll := offset == 0 && pageSize == model.UnlimitedPageSize
|
||||
|
||||
sql := `
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
@@ -38,8 +39,8 @@ func GetUserByID(db *DaoDB, fieldName, fieldValue string) (user *model.User, err
|
||||
}
|
||||
|
||||
func GetUsers(db *DaoDB, userType int, keyword string, userIDs []string, userID2, mobile string, offset, pageSize int) (userList []*model.User, totalCount int, err error) {
|
||||
offset = FormalizePageOffset(offset)
|
||||
pageSize = FormalizePageSize(pageSize)
|
||||
offset = jxutils.FormalizePageOffset(offset)
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
if userType == 0 {
|
||||
userType = 255
|
||||
}
|
||||
@@ -182,8 +183,8 @@ func QueryUserDeliveryAddress(db *DaoDB, addressID int64, userIDs []string, offs
|
||||
sql += " AND t1.user_id IN (" + GenQuestionMarks(len(userIDs)) + ")"
|
||||
sqlParams = append(sqlParams, userIDs)
|
||||
}
|
||||
offset = FormalizePageOffset(offset)
|
||||
pageSize = FormalizePageSize(pageSize)
|
||||
offset = jxutils.FormalizePageOffset(offset)
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
sql += `
|
||||
ORDER BY t1.is_default DESC, t1.consignee_name
|
||||
LIMIT ? OFFSET ?`
|
||||
|
||||
@@ -201,18 +201,10 @@ func IsVendorThingIDEmpty(vendorThingID string) bool {
|
||||
return vendorThingID == "" || vendorThingID == "0"
|
||||
}
|
||||
|
||||
func FormalizePageSize(pageSize int) int {
|
||||
if pageSize == 0 {
|
||||
return model.DefPageSize
|
||||
} else if pageSize < 0 {
|
||||
return model.UnlimitedPageSize
|
||||
func GetAuthType4Vendor(vendorID int) (authType string) {
|
||||
authType = ConvertJsonFieldPrefix(model.VendorNames[vendorID])
|
||||
if authType != "" {
|
||||
authType = "vendor." + authType
|
||||
}
|
||||
return pageSize
|
||||
}
|
||||
|
||||
func FormalizePageOffset(offset int) int {
|
||||
if offset < 0 {
|
||||
offset = 0
|
||||
}
|
||||
return offset
|
||||
return authType
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package dao
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
@@ -72,8 +73,8 @@ func QueryFoodRecipes(db *DaoDB, keyword string, recipeID int, authorID, userID
|
||||
) > 0`
|
||||
sqlParams = append(sqlParams, skuIDs)
|
||||
}
|
||||
offset = FormalizePageOffset(offset)
|
||||
pageSize = FormalizePageSize(pageSize)
|
||||
offset = jxutils.FormalizePageOffset(offset)
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
sql += `
|
||||
ORDER BY t1.created_at DESC
|
||||
LIMIT ? OFFSET ?`
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
@@ -76,8 +77,8 @@ func QueryPageStores(db *DaoDB, pageSize, offset int, keyword string, vendorStor
|
||||
ORDER BY t1.recent_order_num DESC
|
||||
LIMIT ? OFFSET ?
|
||||
`
|
||||
pageSize = FormalizePageSize(pageSize)
|
||||
offset = FormalizePageOffset(offset)
|
||||
pageSize = jxutils.FormalizePageSize(pageSize)
|
||||
offset = jxutils.FormalizePageOffset(offset)
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
var shopList []*PageShopWithPlaceName
|
||||
Begin(db)
|
||||
|
||||
@@ -66,8 +66,8 @@ func (c *NetSpiderController) QueryPageStores() {
|
||||
params.VendorID = -1
|
||||
}
|
||||
var lng, lat, lng1, lat1, lng2, lat2 float64
|
||||
params.Offset = dao.FormalizePageOffset(params.Offset)
|
||||
params.PageSize = dao.FormalizePageSize(params.PageSize)
|
||||
params.Offset = jxutils.FormalizePageOffset(params.Offset)
|
||||
params.PageSize = jxutils.FormalizePageSize(params.PageSize)
|
||||
offset := params.Offset
|
||||
pageSize := params.PageSize
|
||||
if params.Radius > 0 {
|
||||
|
||||
Reference in New Issue
Block a user