|
|
|
|
@@ -38,6 +38,10 @@ const (
|
|
|
|
|
|
|
|
|
|
type StoreExt struct {
|
|
|
|
|
model.Store
|
|
|
|
|
|
|
|
|
|
MarketManName string `orm:"size(8)" json:"marketManName"` // 市场负责人姓名
|
|
|
|
|
OperatorName string `orm:"size(8)" json:"operatorName"` // 运营人姓名
|
|
|
|
|
|
|
|
|
|
FloatLng float64 `json:"lng"`
|
|
|
|
|
FloatLat float64 `json:"lat"`
|
|
|
|
|
|
|
|
|
|
@@ -151,7 +155,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
|
|
|
|
|
t1.licence2_code,
|
|
|
|
|
t1.licence2_valid,
|
|
|
|
|
t1.licence2_expire,
|
|
|
|
|
t1.market_man_name,
|
|
|
|
|
IF(mm.name <> '', mm.name, mm.user_id2) market_man_name,
|
|
|
|
|
t1.market_man_phone,
|
|
|
|
|
t1.jx_brand_fee_factor,
|
|
|
|
|
t1.market_add_fee_factor,
|
|
|
|
|
@@ -162,7 +166,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
|
|
|
|
|
bank.value payee_bank_name,
|
|
|
|
|
|
|
|
|
|
t1.pay_percentage,
|
|
|
|
|
t1.operator_name,
|
|
|
|
|
IF(om.name <> '', om.name, om.user_id2) operator_name,
|
|
|
|
|
t1.operator_phone,
|
|
|
|
|
t1.printer_disabled,
|
|
|
|
|
|
|
|
|
|
@@ -188,12 +192,16 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
|
|
|
|
|
LEFT JOIN place district ON t1.district_code = district.code AND district.level = 3
|
|
|
|
|
LEFT JOIN store_map m1 ON t1.id = m1.store_id AND m1.deleted_at = ?
|
|
|
|
|
LEFT JOIN store_courier_map m2 ON t1.id = m2.store_id AND m2.deleted_at = ?
|
|
|
|
|
LEFT JOIN user mm ON mm.mobile <> '' AND mm.mobile = t1.market_man_phone AND mm.deleted_at = ?
|
|
|
|
|
LEFT JOIN user om ON om.mobile <> '' AND om.mobile = t1.operator_phone AND om.deleted_at = ?
|
|
|
|
|
`
|
|
|
|
|
sqlParams := []interface{}{
|
|
|
|
|
utils.DefaultTimeValue,
|
|
|
|
|
model.ConfigTypeBank,
|
|
|
|
|
utils.DefaultTimeValue,
|
|
|
|
|
utils.DefaultTimeValue,
|
|
|
|
|
utils.DefaultTimeValue,
|
|
|
|
|
utils.DefaultTimeValue,
|
|
|
|
|
}
|
|
|
|
|
sqlWhere := `
|
|
|
|
|
WHERE t1.deleted_at = ?
|
|
|
|
|
@@ -1513,6 +1521,46 @@ func isVendorStoresStatusNotOk(storeMapList []*model.VendorStoreSnapshot) bool {
|
|
|
|
|
return len(statusMap) > 1 && maxStatus == model.StoreStatusOpened
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func getAllUsers4Store(ctx *jxcontext.Context, db *dao.DaoDB, store *model.Store) (userList []*model.User) {
|
|
|
|
|
storeID := store.ID
|
|
|
|
|
var userIDs []string
|
|
|
|
|
userMap := make(map[string]int)
|
|
|
|
|
|
|
|
|
|
// 门店老板
|
|
|
|
|
if roleUserIDList, err := GetRoleUserList(ctx, autils.NewStoreBossRole(storeID)); err == nil && len(roleUserIDList) > 0 {
|
|
|
|
|
userIDs = append(userIDs, roleUserIDList...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 全局相关角色(市场或运营)
|
|
|
|
|
for _, v := range []string{store.MarketManRole, store.OperatorRole, store.OperatorRole2} {
|
|
|
|
|
if v != "" {
|
|
|
|
|
if roleUserIDList, err := GetRoleUserList(ctx, autils.NewRole(v, 0)); err == nil && len(roleUserIDList) > 0 {
|
|
|
|
|
userIDs = append(userIDs, roleUserIDList...)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(userIDs) > 0 {
|
|
|
|
|
userList, _, _ = dao.GetUsers(db, 0, "", userIDs, "", "", 0, -1)
|
|
|
|
|
for _, v := range userList {
|
|
|
|
|
userMap[v.GetID()] = 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 直接电话信息相关人员
|
|
|
|
|
for _, mobile := range []string{store.Tel1, store.Tel2, store.MarketManPhone, store.OperatorPhone} {
|
|
|
|
|
if mobile != "" {
|
|
|
|
|
if user, err2 := dao.GetUserByID(db, "mobile", mobile); err2 == nil {
|
|
|
|
|
if userMap[user.GetID()] == 0 {
|
|
|
|
|
userMap[user.GetID()] = 1
|
|
|
|
|
userList = append(userList, user)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return userList
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func SendAlarmVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, prevSnapshotList, curSnapshotList []*model.VendorStoreSnapshot) (err error) {
|
|
|
|
|
if len(prevSnapshotList) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
@@ -1578,31 +1626,16 @@ func SendAlarmVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, p
|
|
|
|
|
storeDetail, _ := dao.GetStoreDetail(db, storeID, list[0].VendorID)
|
|
|
|
|
if storeDetail != nil {
|
|
|
|
|
storeDetailMap[storeID] = storeDetail
|
|
|
|
|
|
|
|
|
|
var userList []*model.User
|
|
|
|
|
if roleUserIDList, err := GetRoleUserList(ctx, autils.NewStoreBossRole(storeID)); err == nil && len(roleUserIDList) > 0 {
|
|
|
|
|
userList, _, _ = dao.GetUsers(db, 0, "", roleUserIDList, "", "", 0, -1)
|
|
|
|
|
}
|
|
|
|
|
for _, mobile := range []string{storeDetail.Tel1, storeDetail.Tel2, storeDetail.MarketManPhone, storeDetail.OperatorPhone} {
|
|
|
|
|
if mobile != "" {
|
|
|
|
|
if user, err2 := dao.GetUserByID(db, "mobile", mobile); err2 == nil {
|
|
|
|
|
userList = append(userList, user)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
processedUser := make(map[string]int)
|
|
|
|
|
userList := getAllUsers4Store(ctx, db, &storeDetail.Store)
|
|
|
|
|
for _, user := range userList {
|
|
|
|
|
userID := user.GetID()
|
|
|
|
|
if processedUser[userID] == 0 {
|
|
|
|
|
processedUser[userID] = 1
|
|
|
|
|
if userMap[userID] == nil {
|
|
|
|
|
userMap[userID] = make(map[int]int)
|
|
|
|
|
userMap2[userID] = user
|
|
|
|
|
}
|
|
|
|
|
userMap[userID][storeID] = 1
|
|
|
|
|
if txtAlarmSnapshotMap[storeID] != nil {
|
|
|
|
|
userMapTxt[userID] = append(userMapTxt[userID], txtAlarmSnapshotMap[storeID]...)
|
|
|
|
|
}
|
|
|
|
|
if userMap[userID] == nil {
|
|
|
|
|
userMap[userID] = make(map[int]int)
|
|
|
|
|
userMap2[userID] = user
|
|
|
|
|
}
|
|
|
|
|
userMap[userID][storeID] = 1
|
|
|
|
|
if txtAlarmSnapshotMap[storeID] != nil {
|
|
|
|
|
userMapTxt[userID] = append(userMapTxt[userID], txtAlarmSnapshotMap[storeID]...)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|