72 lines
2.0 KiB
Go
72 lines
2.0 KiB
Go
package cms
|
|
|
|
import (
|
|
"encoding/json"
|
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
|
"git.rosy.net.cn/jx-callback/globals"
|
|
"strconv"
|
|
)
|
|
|
|
// 更新门店负责人信息
|
|
func UpdateStoreOperatorConfig() {
|
|
globals.SugarLogger.Debug("======测试输出")
|
|
db := dao.GetDB()
|
|
store, err := dao.GetStoreList(db, nil, nil, nil, nil, nil, "")
|
|
if err != nil {
|
|
globals.SugarLogger.Debug("定时任务,获取所有门店信息错误")
|
|
return
|
|
}
|
|
userData := make(map[string][][]interface{}, 0)
|
|
jx := make(map[string]string, 0)
|
|
jd := make(map[string]string, 0)
|
|
mt := make(map[string]string, 0)
|
|
eb := make(map[string]string, 0)
|
|
for _, v := range store {
|
|
storeDetail, err := dao.GetStoreDetail(dao.GetDB(), v.ID, 0, "")
|
|
if err != nil {
|
|
globals.SugarLogger.Debug("定时任务,更新门店负责人,美团负责人.....错误", v.ID)
|
|
return
|
|
}
|
|
if storeDetail.MarketManPhone != "" { // 平台负责人jx
|
|
jx[storeDetail.MarketManName] = storeDetail.MarketManPhone
|
|
}
|
|
if storeDetail.OperatorPhone != "" { // 京东负责人电话
|
|
jd[storeDetail.OperatorName] = storeDetail.OperatorPhone
|
|
}
|
|
if storeDetail.OperatorPhone2 != "" { // 美团负责人电话
|
|
mt[storeDetail.OperatorName2] = storeDetail.OperatorPhone2
|
|
}
|
|
if storeDetail.OperatorPhone3 != "" { // 饿了么负责人电话
|
|
eb[storeDetail.OperatorName3] = storeDetail.OperatorPhone3
|
|
}
|
|
}
|
|
userData["jx"] = Map2Slice(jx)
|
|
userData["jd"] = Map2Slice(jd)
|
|
userData["mt"] = Map2Slice(mt)
|
|
userData["eb"] = Map2Slice(eb)
|
|
// 写入配置
|
|
byteData, err := json.Marshal(userData)
|
|
if err != nil {
|
|
globals.SugarLogger.Debug("Marshal err :", err)
|
|
return
|
|
}
|
|
if err := dao.UpdateOperatorConfig(string(byteData)); err != nil {
|
|
globals.SugarLogger.Debug("update new_config err :", err)
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func Map2Slice(param map[string]string) [][]interface{}{
|
|
if len(param) <= 0 {
|
|
return nil
|
|
}
|
|
|
|
result := make([][]interface{}, len(param), 0)
|
|
for k, v := range param {
|
|
phone, _ := strconv.Atoi(v)
|
|
result = append(result, []interface{}{k, phone})
|
|
}
|
|
return result
|
|
}
|