添加Store.OperatorPhone3

This commit is contained in:
gazebo
2020-02-12 08:40:18 +08:00
committed by 苏尹岚
parent 4d9c933167
commit aec442b5e2
7 changed files with 128 additions and 121 deletions

View File

@@ -53,8 +53,9 @@ type StoreExt struct {
model.Store
MarketManName string `orm:"size(8)" json:"marketManName"` // 市场负责人姓名
OperatorName string `orm:"size(8)" json:"operatorName"` // 运营人姓名
OperatorName2 string `orm:"size(8)" json:"operatorName2"` // 非京东运营人姓名
OperatorName string `orm:"size(8)" json:"operatorName"` // 京东运营人姓名
OperatorName2 string `orm:"size(8)" json:"operatorName2"` // 美团运营人姓名
OperatorName3 string `orm:"size(8)" json:"operatorName3"` // 饿百运营人姓名
FloatLng float64 `json:"lng"`
FloatLat float64 `json:"lat"`
@@ -150,6 +151,7 @@ type VendorStoreExcel struct {
MarketManName string `json:"市场负责人"`
OperatorName string `json:"运营负责人"`
OperatorName2 string `json:"运营负责人2"`
OperatorName3 string `json:"运营负责人3"`
}
type JdStoreLevelExt struct {
@@ -243,6 +245,7 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte
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 = ?
LEFT JOIN user om2 ON om2.mobile <> '' AND om2.mobile = t1.operator_phone2 AND om2.deleted_at = ?
LEFT JOIN user om3 ON om3.mobile <> '' AND om3.mobile = t1.operator_phone3 AND om3.deleted_at = ?
`
sqlFromParams = []interface{}{
utils.DefaultTimeValue,
@@ -252,6 +255,7 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte
utils.DefaultTimeValue,
utils.DefaultTimeValue,
utils.DefaultTimeValue,
utils.DefaultTimeValue,
}
sqlWhere := `
WHERE t1.deleted_at = ?
@@ -311,9 +315,9 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte
}
if keyword != "" {
keywordLike := "%" + keyword + "%"
sqlWhere += ` AND (t1.name LIKE ? OR t1.tel1 LIKE ? OR t1.tel2 LIKE ? OR t1.operator_phone LIKE ? OR t1.operator_phone2 LIKE ? OR t1.market_man_phone LIKE ?
sqlWhere += ` AND (t1.name LIKE ? OR t1.tel1 LIKE ? OR t1.tel2 LIKE ? OR t1.operator_phone LIKE ? OR t1.operator_phone2 LIKE ? OR t1.operator_phone3 LIKE ? OR t1.market_man_phone LIKE ?
OR t1.last_operator LIKE ? OR city.name LIKE ? OR t1.address LIKE ? OR t1.printer_sn LIKE ? OR t1.licence_code LIKE ? OR t1.id_code LIKE ?`
sqlWhereParams = append(sqlWhereParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike,
sqlWhereParams = append(sqlWhereParams, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike,
keywordLike, keywordLike, keywordLike, keywordLike, keywordLike, keywordLike)
if keywordInt64, err2 := strconv.ParseInt(keyword, 10, 64); err2 == nil {
@@ -322,10 +326,10 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte
SELECT COUNT(*)
FROM casbin_rule t11
JOIN user t12 ON t12.user_id = t11.v0 AND t12.mobile LIKE ?
WHERE t11.v1 <> '' AND (t11.v1 = CONCAT(?, t1.id) OR t11.v1 = CONCAT(?, t1.market_man_role) OR t11.v1 = CONCAT(?, t1.operator_role) OR t11.v1 = CONCAT(?, t1.operator_role2))
WHERE t11.v1 <> '' AND (t11.v1 = CONCAT(?, t1.id) OR t11.v1 = CONCAT(?, t1.market_man_role) OR t11.v1 = CONCAT(?, t1.operator_role) OR t11.v1 = CONCAT(?, t1.operator_role2) OR t11.v1 = CONCAT(?, t1.operator_role3))
) > 0`
prefix := autils.NewRole("", 0).GetFullName()
sqlWhereParams = append(sqlWhereParams, keyword+"%", autils.NewStoreBossRole(-1).GetFullName(), prefix, prefix, prefix) // 必须要前缀,不然不能用过些会很慢
sqlWhereParams = append(sqlWhereParams, keyword+"%", autils.NewStoreBossRole(-1).GetFullName(), prefix, prefix, prefix, prefix) // 必须要前缀,不然不能用过些会很慢
}
sqlWhere += " OR t1.id = ? OR t1.city_code = ? OR t1.district_code = ? OR t1.link_store_id = ?"
sqlWhereParams = append(sqlWhereParams, keywordInt64, keywordInt64, keywordInt64, keywordInt64)
@@ -451,6 +455,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
bank.value payee_bank_name,
IF(om.name <> '', om.name, om.user_id2) operator_name,
IF(om2.name <> '', om2.name, om2.user_id2) operator_name2,
IF(om3.name <> '', om3.name, om3.user_id2) operator_name3,
province.code province_code,
province.name province_name,
city.name city_name,
@@ -923,8 +928,10 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
} else {
dao.Commit(db)
}
notifyStoreOperatorChanged(store, valid["operatorPhone"])
notifyStoreMarketChanged(store, valid["marketManPhone"])
notifyStoreOperatorChanged(store.ID, "京东运营", store.OperatorPhone, valid["operatorPhone"])
notifyStoreOperatorChanged(store.ID, "美团运营", store.OperatorPhone2, valid["operatorPhone2"])
notifyStoreOperatorChanged(store.ID, "饿百运营", store.OperatorPhone3, valid["operatorPhone3"])
notifyStoreOperatorChanged(store.ID, "市场", store.MarketManPhone, valid["marketManPhone"])
if err == nil {
if valid["openTime1"] != 0 || valid["closeTime1"] != 0 || valid["openTime2"] != 0 || valid["closeTime2"] != 0 {
err = CurVendorSync.ChangeStoreSkuSaleStatus(ctx, storeID, true, true)
@@ -937,32 +944,17 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
return num, err
}
func notifyStoreOperatorChanged(store *model.Store, newOperator2 interface{}) {
if store.OperatorPhone != "" && newOperator2 != nil {
func notifyStoreOperatorChanged(storeID int, operatorRoleName, phone string, newPhone interface{}) {
if phone != "" && newPhone != nil {
db := dao.GetDB()
if user, err := dao.GetUserByID(db, "mobile", store.OperatorPhone); err == nil {
if user, err := dao.GetUserByID(db, "mobile", phone); err == nil {
curUserName := ""
if newOperator := utils.Interface2String(newOperator2); newOperator != "" {
if newOperator := utils.Interface2String(newPhone); newOperator != "" {
if curUser, err := dao.GetUserByID(db, "mobile", newOperator); err == nil {
curUserName = curUser.GetName()
}
}
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.GetID(), "门店运营变更", fmt.Sprintf("门店:%d-%s,原运营:%s,变更为:%s", store.ID, store.Name, user.GetName(), curUserName))
}
}
}
func notifyStoreMarketChanged(store *model.Store, newMarketManPhone2 interface{}) {
if store.MarketManPhone != "" && newMarketManPhone2 != nil {
db := dao.GetDB()
if user, err := dao.GetUserByID(db, "mobile", store.MarketManPhone); err == nil {
curUserName := ""
if newOperator := utils.Interface2String(newMarketManPhone2); newOperator != "" {
if curUser, err := dao.GetUserByID(db, "mobile", newOperator); err == nil {
curUserName = curUser.GetName()
}
}
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.GetID(), "门店市场变更", fmt.Sprintf("门店:%d-%s,原市场:%s,变更为:%s", store.ID, store.Name, user.GetName(), curUserName))
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.GetID(), fmt.Sprintf("门店%s变更", operatorRoleName), fmt.Sprintf("门店:%d,原%s:%s,变更为:%s", storeID, operatorRoleName, user.GetName(), curUserName))
}
}
}
@@ -1042,7 +1034,7 @@ func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (i
}
db := dao.GetDB()
if globals.EnableWXAuth2 {
if err = dao.ValidateRoles(db, store.MarketManRole, store.OperatorRole, store.OperatorRole2); err != nil {
if err = dao.ValidateRoles(db, store.MarketManRole, store.OperatorRole, store.OperatorRole2, store.OperatorRole3); err != nil {
return 0, err
}
}
@@ -1955,7 +1947,7 @@ func getAllUsers4Store(ctx *jxcontext.Context, db *dao.DaoDB, store *model.Store
}
// 全局相关角色(市场或运营)
for _, v := range []string{store.MarketManRole, store.OperatorRole, store.OperatorRole2} {
for _, v := range []string{store.MarketManRole, store.OperatorRole, store.OperatorRole2, store.OperatorRole3} {
if v != "" {
if roleUserIDList, err := GetRoleUserList(ctx, autils.NewRole(v, 0)); err == nil && len(roleUserIDList) > 0 {
userIDs = append(userIDs, roleUserIDList...)
@@ -1971,7 +1963,7 @@ func getAllUsers4Store(ctx *jxcontext.Context, db *dao.DaoDB, store *model.Store
}
// 直接电话信息相关人员
for _, mobile := range []string{store.Tel1, store.Tel2, store.MarketManPhone, store.OperatorPhone, store.OperatorPhone2} {
for _, mobile := range []string{store.Tel1, store.Tel2, store.MarketManPhone, store.OperatorPhone, store.OperatorPhone2, store.OperatorPhone3} {
if mobile != "" {
if user, err2 := dao.GetUserByID(db, "mobile", mobile); err2 == nil {
if userMap[user.GetID()] == 0 {
@@ -2587,6 +2579,7 @@ func GetVendorStoreInfo(ctx *jxcontext.Context, vendorIDList []int, isAsync, isC
MarketManName: storeDetail2.MarketManName,
OperatorName: storeDetail2.OperatorName,
OperatorName2: storeDetail2.OperatorName2,
OperatorName3: storeDetail2.OperatorName3,
}
retVal = []VendorStoreExcel{storeExcel}
}

View File

@@ -169,13 +169,13 @@ type tUpdateStoresSkus struct {
}
type tStoreSkusSecKill struct {
StoreID int `orm:"column(store_id)"`
VendorID int `orm:"column(vendor_id)"`
SecKillCount int
SecKillCount2 int
OperatorPhone string
MarketManPhone string
NoticeMsg string
StoreID int `orm:"column(store_id)"`
VendorID int `orm:"column(vendor_id)"`
SecKillCount int
SecKillCount2 int
OperatorPhoneList []string
MarketManPhone string
NoticeMsg string
}
type JdStoreSkus struct {
@@ -3460,19 +3460,13 @@ func SendSeckillSkusCountMsg(ctx *jxcontext.Context, vendorIDs []int, isAsync, i
if type1 < type1Count || type2 < type2Count {
storeDetail, _ := dao.GetStoreDetail(db, store.StoreID, store.VendorID)
var (
operatorName string
operatorPhone string
type1Str = "爆品数量低于8个"
type2Str = "爆品价格小于1元的爆品数量低于5个"
typeResult = ""
type1Str = "爆品数量低于8个"
type2Str = "爆品价格小于1元的爆品数量低于5个"
typeResult = ""
)
if storeDetail.OperatorPhone != "" {
operatorName = storeDetail.OperatorName
operatorPhone = storeDetail.OperatorPhone
} else if storeDetail.OperatorPhone2 != "" {
operatorName = storeDetail.OperatorName2
operatorPhone = storeDetail.OperatorPhone2
}
operatorNameList := jxutils.BatchString2Slice(storeDetail.OperatorName, storeDetail.OperatorName2, storeDetail.OperatorName3)
operatorPhoneList := jxutils.BatchString2Slice(storeDetail.OperatorPhone, storeDetail.OperatorPhone2, storeDetail.OperatorPhone3)
if type1 < type1Count {
typeResult += type1Str
}
@@ -3480,8 +3474,8 @@ func SendSeckillSkusCountMsg(ctx *jxcontext.Context, vendorIDs []int, isAsync, i
typeResult += type2Str
}
var result = &tStoreSkusSecKill{}
noticeMsg := fmt.Sprintf("运营负责人:[%v],市场负责人:[%v]门店ID[%v]平台门店ID[%v],门店名:[%v],平台:[%v],警告类型:[%v]\n", operatorName, storeDetail.MarketManName, store.StoreID, storeDetail.VendorStoreID, store.StoreName, model.VendorChineseNames[store.VendorID], typeResult)
result.OperatorPhone = operatorPhone
noticeMsg := fmt.Sprintf("运营负责人:[%v],市场负责人:[%v]门店ID[%v]平台门店ID[%v],门店名:[%v],平台:[%v],警告类型:[%v]\n", strings.Join(operatorNameList, ","), storeDetail.MarketManName, store.StoreID, storeDetail.VendorStoreID, store.StoreName, model.VendorChineseNames[store.VendorID], typeResult)
result.OperatorPhoneList = operatorPhoneList
result.MarketManPhone = storeDetail.MarketManPhone
result.NoticeMsg = noticeMsg
retVal = []*tStoreSkusSecKill{result}
@@ -3498,10 +3492,12 @@ func SendSeckillSkusCountMsg(ctx *jxcontext.Context, vendorIDs []int, isAsync, i
)
for _, v := range ddMsgresult {
ddm := v.(*tStoreSkusSecKill)
if operaterMap[ddm.OperatorPhone] != "" {
operaterMap[ddm.OperatorPhone] += ddm.NoticeMsg
} else {
operaterMap[ddm.OperatorPhone] = ddm.NoticeMsg
for _, phone := range ddm.OperatorPhoneList {
if operaterMap[phone] != "" {
operaterMap[phone] += ddm.NoticeMsg
} else {
operaterMap[phone] = ddm.NoticeMsg
}
}
if marketMap[ddm.MarketManPhone] != "" {
marketMap[ddm.MarketManPhone] += ddm.NoticeMsg