添加Store.OperatorPhone3
This commit is contained in:
@@ -1389,13 +1389,8 @@ func isOrderCanSwitch2SelfDeliver(order *model.GoodsOrder) (isCan bool) {
|
||||
|
||||
//订单预计利润若低于0,则向门店运营负责人发送钉钉消息
|
||||
func OrderProfitWarning(order *model.GoodsOrder) {
|
||||
var (
|
||||
operatorName string
|
||||
operatorPhone string
|
||||
noticeMsg string
|
||||
profit float64
|
||||
storeID int
|
||||
)
|
||||
var profit float64
|
||||
|
||||
db := dao.GetDB()
|
||||
if order == nil {
|
||||
return
|
||||
@@ -1404,7 +1399,7 @@ func OrderProfitWarning(order *model.GoodsOrder) {
|
||||
globals.SugarLogger.Debugf("OrderProfitWarning TotalShopMoney=0 orderID:%s", order.VendorOrderID)
|
||||
return
|
||||
}
|
||||
storeID = jxutils.GetShowStoreIDFromOrder(order)
|
||||
storeID := jxutils.GetShowStoreIDFromOrder(order)
|
||||
storeDetail, err := dao.GetStoreDetail(db, storeID, order.VendorID)
|
||||
if storeDetail != nil && err == nil {
|
||||
payPercentage := storeDetail.PayPercentage
|
||||
@@ -1414,17 +1409,13 @@ func OrderProfitWarning(order *model.GoodsOrder) {
|
||||
profit = utils.Str2Float64(utils.Int64ToStr(order.TotalShopMoney*int64(payPercentage)/200)) / 100
|
||||
}
|
||||
if profit < 0 {
|
||||
if storeDetail.OperatorPhone != "" {
|
||||
operatorName = storeDetail.OperatorName
|
||||
operatorPhone = storeDetail.OperatorPhone
|
||||
} else if storeDetail.OperatorPhone2 != "" {
|
||||
operatorName = storeDetail.OperatorName2
|
||||
operatorPhone = storeDetail.OperatorPhone2
|
||||
}
|
||||
noticeMsg = fmt.Sprintf("利润 :[%v],运营负责人:[%v],门店ID:[%v],平台门店ID[%v],门店名:[%v],订单号(点击进入详情):%v", profit, operatorName, order.StoreID, order.VendorStoreID, order.StoreName, globals.BackstageHost+"/#/ordermanager/"+order.VendorOrderID)
|
||||
user, err := dao.GetUserByID(db, "mobile", operatorPhone)
|
||||
if user != nil && err == nil {
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.UserID, "警告!此订单利润低于0", noticeMsg)
|
||||
operatorPhone, operatorName := getOrderOperatorInfo(order, storeDetail)
|
||||
if operatorPhone != "" {
|
||||
noticeMsg := fmt.Sprintf("利润 :[%v],运营负责人:[%v],门店ID:[%v],平台门店ID[%v],门店名:[%v],订单号(点击进入详情):%v", profit, operatorName, order.StoreID, order.VendorStoreID, order.StoreName, globals.BackstageHost+"/#/ordermanager/"+order.VendorOrderID)
|
||||
user, err := dao.GetUserByID(db, "mobile", operatorPhone)
|
||||
if user != nil && err == nil {
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, user.UserID, "警告!此订单利润低于0", noticeMsg)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1436,8 +1427,11 @@ func (s *DefScheduler) notifyOrderStakeHolder(order *model.GoodsOrder, msgTitle,
|
||||
}
|
||||
db := dao.GetDB()
|
||||
storeDetail, err := dao.GetStoreDetail(db, jxutils.GetSaleStoreIDFromOrder(order), order.VendorID)
|
||||
if err == nil && storeDetail.OperatorPhone != "" {
|
||||
userMobiles = append(userMobiles, storeDetail.OperatorPhone)
|
||||
if err == nil {
|
||||
operatorPhone, _ := getOrderOperatorInfo(order, storeDetail)
|
||||
if operatorPhone != "" {
|
||||
userMobiles = append(userMobiles, operatorPhone)
|
||||
}
|
||||
}
|
||||
if len(userMobiles) > 0 {
|
||||
if msgTitle == "" {
|
||||
@@ -1454,3 +1448,18 @@ func (s *DefScheduler) notifyOrderStakeHolder(order *model.GoodsOrder, msgTitle,
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func getOrderOperatorInfo(order *model.GoodsOrder, storeDetail *dao.StoreDetail) (operatorPhone, operatorName string) {
|
||||
switch order.VendorID {
|
||||
case model.VendorIDJD:
|
||||
operatorPhone = storeDetail.OperatorPhone
|
||||
operatorName = storeDetail.OperatorName
|
||||
case model.VendorIDEBAI:
|
||||
operatorPhone = storeDetail.OperatorPhone2
|
||||
operatorName = storeDetail.OperatorName2
|
||||
case model.VendorIDMTWM:
|
||||
operatorPhone = storeDetail.OperatorPhone3
|
||||
operatorName = storeDetail.OperatorName3
|
||||
}
|
||||
return operatorPhone, operatorName
|
||||
}
|
||||
|
||||
@@ -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}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -100,37 +100,34 @@ func DeleteUsers(db *DaoDB, userIDs []string) (num int64, err error) {
|
||||
return num, err
|
||||
}
|
||||
|
||||
func GetStoreListByMobile(db *DaoDB, mobile string) (storeList []*StoreWithCityName, err error) {
|
||||
if mobile != "" {
|
||||
sql := `
|
||||
SELECT
|
||||
DISTINCT t1.*, t2.name city_name
|
||||
FROM (
|
||||
SELECT *
|
||||
FROM store t1
|
||||
WHERE (t1.market_man_phone = ? OR t1.operator_phone = ? OR t1.operator_phone2 = ?)
|
||||
UNION DISTINCT
|
||||
SELECT t1.*
|
||||
FROM store t1
|
||||
JOIN weixins t2 ON t2.jxstoreid = t1.id AND t2.parentid = -1
|
||||
LEFT JOIN weixins t3 ON t3.parentid = t2.id
|
||||
WHERE (t2.tel = ? OR t3.tel = ?)
|
||||
) t1
|
||||
LEFT JOIN place t2 ON t2.code = t1.city_code
|
||||
WHERE t1.deleted_at = ?
|
||||
ORDER BY t1.name`
|
||||
sqlParams := []interface{}{
|
||||
mobile,
|
||||
mobile,
|
||||
mobile,
|
||||
mobile,
|
||||
mobile,
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
err = GetRows(db, &storeList, sql, sqlParams...)
|
||||
}
|
||||
return storeList, err
|
||||
}
|
||||
// func GetStoreListByMobile(db *DaoDB, mobile string) (storeList []*StoreWithCityName, err error) {
|
||||
// if mobile != "" {
|
||||
// sql := `
|
||||
// SELECT
|
||||
// DISTINCT t1.*, t2.name city_name
|
||||
// FROM (
|
||||
// SELECT *
|
||||
// FROM store t1
|
||||
// WHERE (t1.market_man_phone = ? OR t1.operator_phone = ? OR t1.operator_phone2 = ? OR t1.operator_phone3 = ?)
|
||||
// UNION DISTINCT
|
||||
// SELECT t1.*
|
||||
// FROM store t1
|
||||
// JOIN weixins t2 ON t2.jxstoreid = t1.id AND t2.parentid = -1
|
||||
// LEFT JOIN weixins t3 ON t3.parentid = t2.id
|
||||
// WHERE (t2.tel = ? OR t3.tel = ?)
|
||||
// ) t1
|
||||
// LEFT JOIN place t2 ON t2.code = t1.city_code
|
||||
// WHERE t1.deleted_at = ?
|
||||
// ORDER BY t1.name`
|
||||
// sqlParams := []interface{}{
|
||||
// mobile, mobile, mobile, mobile,
|
||||
// mobile, mobile,
|
||||
// utils.DefaultTimeValue,
|
||||
// }
|
||||
// err = GetRows(db, &storeList, sql, sqlParams...)
|
||||
// }
|
||||
// return storeList, err
|
||||
// }
|
||||
|
||||
func GetStoreListByMobileOrStoreIDs(db *DaoDB, mobile string, shortRoleNameList []string, storeIDs []int) (storeList []*StoreWithCityName, err error) {
|
||||
sql := `
|
||||
@@ -142,13 +139,13 @@ func GetStoreListByMobileOrStoreIDs(db *DaoDB, mobile string, shortRoleNameList
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if mobile != "" {
|
||||
sql += " OR t1.tel1 = ? OR t1.tel2 = ? OR t1.market_man_phone = ? OR t1.operator_phone = ? OR t1.operator_phone2 = ?"
|
||||
sqlParams = append(sqlParams, mobile, mobile, mobile, mobile, mobile)
|
||||
sql += " OR t1.tel1 = ? OR t1.tel2 = ? OR t1.market_man_phone = ? OR t1.operator_phone = ? OR t1.operator_phone2 = ? OR t1.operator_phone3 = ?"
|
||||
sqlParams = append(sqlParams, mobile, mobile, mobile, mobile, mobile, mobile)
|
||||
}
|
||||
if len(shortRoleNameList) > 0 {
|
||||
questionMarks := GenQuestionMarks(len(shortRoleNameList))
|
||||
sql += " OR t1.market_man_role IN (" + questionMarks + ") OR t1.operator_role IN (" + questionMarks + ") OR t1.operator_role2 IN (" + questionMarks + ")"
|
||||
sqlParams = append(sqlParams, shortRoleNameList, shortRoleNameList, shortRoleNameList)
|
||||
sql += " OR t1.market_man_role IN (" + questionMarks + ") OR t1.operator_role IN (" + questionMarks + ") OR t1.operator_role2 IN (" + questionMarks + ") OR t1.operator_role3 IN (" + questionMarks + ")"
|
||||
sqlParams = append(sqlParams, shortRoleNameList, shortRoleNameList, shortRoleNameList, shortRoleNameList)
|
||||
}
|
||||
if len(storeIDs) > 0 {
|
||||
sql += " OR t1.id IN (" + GenQuestionMarks(len(storeIDs)) + ")"
|
||||
|
||||
@@ -32,6 +32,7 @@ type StatisticsReportForOrdersList struct {
|
||||
MarketManName string `json:"marketManName"` //市场负责人
|
||||
OperatorName string `json:"operatorName"` //运营负责人
|
||||
OperatorName2 string `json:"operatorName2"`
|
||||
OperatorName3 string `json:"operatorName3"`
|
||||
|
||||
CityName string `json:"cityName"`
|
||||
Status int `json:"status"`
|
||||
@@ -71,12 +72,14 @@ func GetStatisticsReportForOrders(db *DaoDB, storeIDs []int, fromDate time.Time,
|
||||
IF(mm.name <> '', mm.name, mm.user_id2) market_man_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,
|
||||
p.name city_name
|
||||
FROM store c
|
||||
LEFT JOIN place p ON p.code = c.city_code
|
||||
LEFT JOIN user mm ON mm.mobile <> '' AND mm.mobile = c.market_man_phone
|
||||
LEFT JOIN user om ON om.mobile <> '' AND om.mobile = c.operator_phone
|
||||
LEFT JOIN user om2 ON om2.mobile <> '' AND om2.mobile = c.operator_phone2
|
||||
LEFT JOIN user om3 ON om3.mobile <> '' AND om3.mobile = c.operator_phone3
|
||||
LEFT JOIN
|
||||
(
|
||||
SELECT
|
||||
@@ -147,12 +150,14 @@ func GetGetStatisticsReportForAfsOrders(db *DaoDB, storeIDs []int, fromDate time
|
||||
IF(mm.name <> '', mm.name, mm.user_id2) market_man_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,
|
||||
p.name city_name
|
||||
FROM store c
|
||||
LEFT JOIN place p ON p.code = c.city_code
|
||||
LEFT JOIN user mm ON mm.mobile <> '' AND mm.mobile = c.market_man_phone
|
||||
LEFT JOIN user om ON om.mobile <> '' AND om.mobile = c.operator_phone
|
||||
LEFT JOIN user mm ON mm.mobile <> '' AND mm.mobile = c.market_man_phone
|
||||
LEFT JOIN user om ON om.mobile <> '' AND om.mobile = c.operator_phone
|
||||
LEFT JOIN user om2 ON om2.mobile <> '' AND om2.mobile = c.operator_phone2
|
||||
LEFT JOIN user om3 ON om3.mobile <> '' AND om3.mobile = c.operator_phone3
|
||||
LEFT JOIN
|
||||
(
|
||||
SELECT
|
||||
|
||||
@@ -41,6 +41,7 @@ type StoreDetail struct {
|
||||
MarketManName string `json:"marketManName"` //市场负责人
|
||||
OperatorName string `json:"operatorName"` //运营负责人
|
||||
OperatorName2 string `json:"operatorName2"`
|
||||
OperatorName3 string `json:"operatorName3"`
|
||||
|
||||
JdStoreLevel string `json:"jdStoreLevel"` //京东门店等级
|
||||
}
|
||||
@@ -93,7 +94,8 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto
|
||||
city.name city_name,
|
||||
IF(mm.name <> '', mm.name, mm.user_id2) market_man_name,
|
||||
IF(om.name <> '', om.name, om.user_id2) operator_name,
|
||||
IF(om2.name <> '', om2.name, om2.user_id2) operator_name2
|
||||
IF(om2.name <> '', om2.name, om2.user_id2) operator_name2,
|
||||
IF(om3.name <> '', om3.name, om3.user_id2) operator_name3
|
||||
FROM store t1
|
||||
LEFT JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND t2.deleted_at = ?
|
||||
LEFT JOIN place city ON city.code = t1.city_code
|
||||
@@ -103,6 +105,7 @@ func getStoreDetail(db *DaoDB, storeID, vendorID int, vendorStoreID string) (sto
|
||||
LEFT JOIN user mm ON mm.mobile <> '' AND mm.mobile = t1.market_man_phone
|
||||
LEFT JOIN user om ON om.mobile <> '' AND om.mobile = t1.operator_phone
|
||||
LEFT JOIN user om2 ON om2.mobile <> '' AND om2.mobile = t1.operator_phone2
|
||||
LEFT JOIN user om3 ON om3.mobile <> '' AND om3.mobile = t1.operator_phone3
|
||||
WHERE t1.deleted_at = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
@@ -492,8 +495,8 @@ func GetStoreList(db *DaoDB, idList, cityCodes, statuss []int, mobileList []stri
|
||||
sqlParams = append(sqlParams, mobileList, mobileList)
|
||||
}
|
||||
if shortRoleName != "" {
|
||||
sql += " AND (t1.market_man_role = ? OR t1.operator_role = ? OR t1.operator_role2 = ?)"
|
||||
sqlParams = append(sqlParams, shortRoleName, shortRoleName, shortRoleName)
|
||||
sql += " AND (t1.market_man_role = ? OR t1.operator_role = ? OR t1.operator_role2 = ? OR t1.operator_role3 = ?)"
|
||||
sqlParams = append(sqlParams, shortRoleName, shortRoleName, shortRoleName, shortRoleName)
|
||||
}
|
||||
err = GetRows(db, &storeList, sql, sqlParams...)
|
||||
return storeList, err
|
||||
|
||||
@@ -322,12 +322,16 @@ type Store struct {
|
||||
PayPercentage int `json:"payPercentage"`
|
||||
|
||||
// OperatorName string `orm:"size(8)" json:"operatorName"` // 运营人姓名
|
||||
OperatorPhone string `orm:"size(16)" json:"operatorPhone"` // 运营人电话
|
||||
OperatorPhone string `orm:"size(16)" json:"operatorPhone"` // 京东运营人电话
|
||||
OperatorRole string `orm:"size(32)" json:"operatorRole"` // 京东运营人组(角色)
|
||||
|
||||
OperatorPhone2 string `orm:"size(16)" json:"operatorPhone2"` // 非京东运营人电话
|
||||
OperatorRole2 string `orm:"size(32)" json:"operatorRole2"` // 非京东运营人组(角色)
|
||||
PromoteInfo string `orm:"size(255)" json:"promoteInfo"` //门店公告(所有平台统一的公告)
|
||||
OperatorPhone2 string `orm:"size(16)" json:"operatorPhone2"` // 美团运营人电话
|
||||
OperatorRole2 string `orm:"size(32)" json:"operatorRole2"` // 美团运营人组(角色)
|
||||
|
||||
OperatorPhone3 string `orm:"size(16)" json:"operatorPhone3"` // 饿百运营人电话
|
||||
OperatorRole3 string `orm:"size(32)" json:"operatorRole3"` // 饿百运营人组(角色)
|
||||
|
||||
PromoteInfo string `orm:"size(255)" json:"promoteInfo"` //门店公告(所有平台统一的公告)
|
||||
}
|
||||
|
||||
func (*Store) TableUnique() [][]string {
|
||||
|
||||
Reference in New Issue
Block a user