diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 72206c593..ef6187168 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -1509,7 +1509,17 @@ func GetStoreCourierMaps(ctx *jxcontext.Context, db *dao.DaoDB, storeID int, ven if vendorID != -1 { cond[model.FieldVendorID] = vendorID } - return storeCourierMaps, dao.GetEntitiesByKV(db, &storeCourierMaps, cond, false) + err = dao.GetEntitiesByKV(db, &storeCourierMaps, cond, false) + if len(storeCourierMaps) != 0 { + //同步美团配送与否状态及美团门店是否存在 + for _, v := range storeCourierMaps { + if v.VendorID != model.VendorIDMTPS { + continue + } + SetMTPSStatus(jxcontext.AdminCtx, v.StoreID, v.Status) + } + } + return storeCourierMaps, err } func AddStoreCourierMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID int, storeCourierMap *model.StoreCourierMap) (outStoreCourierMap *model.StoreCourierMap, err error) { @@ -1556,6 +1566,10 @@ func addStoreCourierMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID } else { err = ErrCanNotFindVendor } + //同步美团配送与否状态及美团门店是否存在 + if outStoreCourierMap.VendorID == model.VendorIDMTPS { + SetMTPSStatus(jxcontext.AdminCtx, outStoreCourierMap.StoreID, outStoreCourierMap.Status) + } return outStoreCourierMap, err } diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index c4fc83f79..6cbfa5985 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -1279,89 +1279,107 @@ func SyncSkuExperfixAndWatermark(ctx *jxcontext.Context) (err error) { return err } -func SetMTPSStatus(ctx *jxcontext.Context) { - globals.SugarLogger.Debug("StoreOpenAll skuID is start") +func SetMTPSStatus(ctx *jxcontext.Context, StoreId, CourierStatus int) { + globals.SugarLogger.Debug("StoreOpenAll skuID is start ") + globals.SugarLogger.Debug("StoreId", "CourierStatus", StoreId, CourierStatus) /*获取美团门店信息*/ - StoreInfoList, _ := api.MtpsAPI.GetStoreStatusAll() - StoreInfoList2 := make(map[string]string) - for _, store := range StoreInfoList { - for _, data := range store.DataList { - StoreInfoList2[data.OuterPoiID] = data.PoiName + if StoreId != 0 && CourierStatus != 0 { + StoreLists, _ := dao.GetStoreList(nil, []int{StoreId}, nil, nil, nil, "") + StoreInfoList, _ := api.MtpsAPI.GetStoreStatus(StoreLists[0].Name) + if StoreInfoList != nil && StoreInfoList.PoiName != "" { + //若存在且名字不为空,就是找到了 + if StoreInfoList.OpenType != CourierStatus { + sl := make(map[string]interface{}) + sl["vendorStoreID"] = StoreInfoList.OuterPoiID + sl["status"] = StoreInfoList.OpenType + sl["vendorStatus"] = StoreInfoList.OpenType + globals.SugarLogger.Debugf("被修改配送状态的VendorStoreID是:%s,名称是:%s,美团状态是:%s,本地状态是:%s", + StoreInfoList.OuterPoiID, StoreInfoList.PoiName, strconv.Itoa(StoreInfoList.OpenType), strconv.Itoa(StoreLists[0].Status)) + UpdateStoreCourierMap(ctx, nil, StoreId, model.VendorIDMTPS, sl, ctx.GetUserName()) + } } - } - db := dao.GetDB() - /*比较营业状态*/ - /*把获取的京西状态和名称存一下*/ - StoreCourierList, _ := dao.GetStoreCourierList(db, []int{}, model.StoreStatusAll, model.StoreStatusAll) - /*循环美团*/ - for _, StoreInfoList1 := range StoreInfoList { - for _, StoreInfoList11 := range StoreInfoList1.DataList { - /*循环京西*/ - for _, StoreCourierList1 := range StoreCourierList { - /*只比较美团*/ - if StoreCourierList1.VendorID != model.VendorIDMTPS { - continue - } - /*如果门店ID相同的时候进入判断,一个门店只用判断一次就行*/ - if StoreCourierList1.VendorStoreID == StoreInfoList11.OuterPoiID { - if StoreCourierList1.Status != StoreInfoList11.OpenType { - sl := make(map[string]interface{}) - sl["vendorStoreID"] = StoreInfoList11.OuterPoiID - sl["status"] = StoreInfoList11.OpenType - sl["vendorStatus"] = StoreInfoList11.OpenType - globals.SugarLogger.Debugf("被修改配送状态的VendorStoreID是:%s,名称是:%s,美团状态是:%s,本地状态是:%s", - StoreInfoList11.OuterPoiID, StoreInfoList11.PoiName, strconv.Itoa(StoreInfoList11.OpenType), strconv.Itoa(StoreCourierList1.Status)) - UpdateStoreCourierMap(ctx, nil, StoreCourierList1.StoreID, StoreCourierList1.VendorID, sl, ctx.GetUserName()) - break + } else { + StoreInfoList, _ := api.MtpsAPI.GetStoreStatusAll() + StoreInfoList2 := make(map[string]string) + for _, store := range StoreInfoList { + for _, data := range store.DataList { + StoreInfoList2[data.OuterPoiID] = data.PoiName + } + } + db := dao.GetDB() + /*比较营业状态*/ + /*把获取的京西状态和名称存一下*/ + StoreCourierList, _ := dao.GetStoreCourierList(db, []int{}, model.StoreStatusAll, model.StoreStatusAll) + /*循环美团*/ + for _, StoreInfoList1 := range StoreInfoList { + for _, StoreInfoList11 := range StoreInfoList1.DataList { + /*循环京西*/ + for _, StoreCourierList1 := range StoreCourierList { + /*只比较美团*/ + if StoreCourierList1.VendorID != model.VendorIDMTPS { + continue + } + /*如果门店ID相同的时候进入判断,一个门店只用判断一次就行*/ + if StoreCourierList1.VendorStoreID == StoreInfoList11.OuterPoiID { + if StoreCourierList1.Status != StoreInfoList11.OpenType { + sl := make(map[string]interface{}) + sl["vendorStoreID"] = StoreInfoList11.OuterPoiID + sl["status"] = StoreInfoList11.OpenType + sl["vendorStatus"] = StoreInfoList11.OpenType + globals.SugarLogger.Debugf("被修改配送状态的VendorStoreID是:%s,名称是:%s,美团状态是:%s,本地状态是:%s", + StoreInfoList11.OuterPoiID, StoreInfoList11.PoiName, strconv.Itoa(StoreInfoList11.OpenType), strconv.Itoa(StoreCourierList1.Status)) + UpdateStoreCourierMap(ctx, nil, StoreCourierList1.StoreID, StoreCourierList1.VendorID, sl, ctx.GetUserName()) + break + } } } } } - } - /* 美团配送的门店是否存在,调用美团配送的api(有可能接了),查询京西门店对应的美团配送门店是否存在,若不存在则要在京西这边解绑美团配送门店 - 怎么解绑可以在网页上门店管理那点一下看看调的什么接口,传的什么参数*/ - /*获取所有门店信息*/ - //test: - for _, StoreCourierList1 := range StoreCourierList { - diff := false - StoreLists, _ := dao.GetStoreList(db, []int{StoreCourierList1.StoreID}, nil, nil, nil, "") - if StoreLists == nil { - globals.SugarLogger.Debugf("StoreID为:%s,在store表未找到", StoreCourierList1.StoreID) - continue - } - if StoreCourierList1.VendorID != model.VendorIDMTPS || StoreCourierList1.VendorStoreID == "" { - continue - } - if StoreCourierList1.Status == model.StoreStatusDisabled || StoreCourierList1.Status == model.StoreStatusClosed { - continue - } - /*京西不为空,容错*/ - //if { - /*调用API获取美团的商店信息*/ - MTPSInfo := new(mtpsapi.ShopInfo) - MTPSInfo, _ = api.MtpsAPI.ShopQuery(StoreCourierList1.VendorStoreID) - if MTPSInfo == nil { - globals.SugarLogger.Debug("美团未找到该门店," + StoreLists[0].Name + strconv.Itoa(StoreCourierList1.StoreID) + " 被解绑,关联的ID为:" + StoreCourierList1.VendorStoreID) - diff = true - } - if MTPSInfo != nil && MTPSInfo.ShopName == "" { - MTPSInfo.ShopName = StoreInfoList2[MTPSInfo.ShopID] - } - if MTPSInfo != nil && MTPSInfo.ShopLng != StoreCourierList1.Lng && MTPSInfo.ShopLat == StoreCourierList1.Lat { - /*平台上但是坐标不同,解绑*/ - globals.SugarLogger.Debug("商店与美团配送上的坐标不同," + StoreLists[0].Name + strconv.Itoa(StoreCourierList1.StoreID) + " 被解绑,关联的ID为:" + StoreCourierList1.VendorStoreID) - if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil { - globals.SugarLogger.Debug(err.Error()) - return + /* 美团配送的门店是否存在,调用美团配送的api(有可能接了),查询京西门店对应的美团配送门店是否存在,若不存在则要在京西这边解绑美团配送门店 + 怎么解绑可以在网页上门店管理那点一下看看调的什么接口,传的什么参数*/ + /*获取所有门店信息*/ + //test: + for _, StoreCourierList1 := range StoreCourierList { + diff := false + StoreLists, _ := dao.GetStoreList(db, []int{StoreCourierList1.StoreID}, nil, nil, nil, "") + if StoreLists == nil { + globals.SugarLogger.Debugf("StoreID为:%s,在store表未找到", StoreCourierList1.StoreID) + continue } - diff = true - } - if diff { - if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil { - globals.SugarLogger.Debug(err.Error()) - return + if StoreCourierList1.VendorID != model.VendorIDMTPS || StoreCourierList1.VendorStoreID == "" { + continue + } + if StoreCourierList1.Status == model.StoreStatusDisabled || StoreCourierList1.Status == model.StoreStatusClosed { + continue + } + /*京西不为空,容错*/ + //if { + /*调用API获取美团的商店信息*/ + MTPSInfo := new(mtpsapi.ShopInfo) + MTPSInfo, _ = api.MtpsAPI.ShopQuery(StoreCourierList1.VendorStoreID) + if MTPSInfo == nil { + globals.SugarLogger.Debug("美团未找到该门店," + StoreLists[0].Name + strconv.Itoa(StoreCourierList1.StoreID) + " 被解绑,关联的ID为:" + StoreCourierList1.VendorStoreID) + diff = true + } + if MTPSInfo != nil && MTPSInfo.ShopName == "" { + MTPSInfo.ShopName = StoreInfoList2[MTPSInfo.ShopID] + } + if MTPSInfo != nil && MTPSInfo.ShopLng != StoreCourierList1.Lng && MTPSInfo.ShopLat == StoreCourierList1.Lat { + /*平台上但是坐标不同,解绑*/ + globals.SugarLogger.Debug("商店与美团配送上的坐标不同," + StoreLists[0].Name + strconv.Itoa(StoreCourierList1.StoreID) + " 被解绑,关联的ID为:" + StoreCourierList1.VendorStoreID) + if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil { + globals.SugarLogger.Debug(err.Error()) + return + } + diff = true + } + if diff { + if _, err := DeleteStoreCourierMap(ctx, db, StoreCourierList1.StoreID, StoreCourierList1.VendorID, ctx.GetUserName()); err != nil { + globals.SugarLogger.Debug(err.Error()) + return + } + //break test } - //break test } } globals.SugarLogger.Debug("StoreOpenAll skuID is Complete") diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index c7f20be56..4a74159d5 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -423,7 +423,7 @@ func doDailyWork() { //同步上架京东商城待售商品 cms.RefreshJdsSkusStatus(jxcontext.AdminCtx) //同步美团配送与否状态及美团门店是否存在 - cms.SetMTPSStatus(jxcontext.AdminCtx) + cms.SetMTPSStatus(jxcontext.AdminCtx, 0, 0) } func RefreshRealMobile(ctx *jxcontext.Context, vendorID int, fromTime, toTime time.Time, isAsync, isContinueWhenError bool) (hint string, err error) { diff --git a/business/model/dao/sensitive_words.go b/business/model/dao/sensitive_words.go index 540801d41..3a9801574 100644 --- a/business/model/dao/sensitive_words.go +++ b/business/model/dao/sensitive_words.go @@ -1,12 +1,15 @@ package dao import ( + "errors" + "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/model" + "time" ) func GetSensitiveWordList() (wordList []*model.SensitiveWord, err error) { - sql := `SELECT * FROM sensitive_word` - err = GetRows(nil, &wordList, sql) + sql := `SELECT * FROM sensitive_word WHERE deleted_at = ?` + err = GetRows(nil, &wordList, sql, utils.DefaultTimeValue) return wordList, err } @@ -15,3 +18,27 @@ func InsertSensitiveWord(word string, vendorID int, userName string) error { WrapAddIDCULDEntity(sensitiveWord, userName) return CreateEntity(nil, sensitiveWord) } + +func DeleteSensitiveWord(wordList *model.SensitiveWord, id int) error { + if id == 0 { + return errors.New("入参错误,找不到相应ID") + } + wordList.ID = id + wordList.DeletedAt = time.Now() + if _, err := UpdateEntity(nil, wordList, "deleted_at"); err != nil { + return err + } + return nil +} + +func UpdateSensitiveWord(wordList *model.SensitiveWord, id int, params ...string) error { + if id == 0 { + return errors.New("入参错误,找不到相应ID") + } + wordList.ID = id + wordList.DeletedAt = time.Now() + if _, err := UpdateEntity(nil, wordList, params...); err != nil { + return err + } + return nil +} diff --git a/controllers/cms_sku.go b/controllers/cms_sku.go index bd04f8fb0..ce5e11d8f 100644 --- a/controllers/cms_sku.go +++ b/controllers/cms_sku.go @@ -353,6 +353,31 @@ func (c *SkuController) GetSensitiveWordList() { }) } +// @Title 插入敏感词列表 +// @Description 插入敏感词列表 +// @Param token header string true "认证token" +// @Param word query string true "关键词名字" +// @Param vendorID query int false "VendorID" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /InsertSensitiveWord [post] +func (c *SkuController) InsertSensitiveWord() { + +} + +// @Title 修改敏感词列表 +// @Description 修改敏感词列表 +// @Param token header string true "认证token" +// @Param word query string true "关键词名字" +// @Param vendorID query int false "VendorID" +// @Param Status query int false "状态,0为修改默认,1为删除" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /UpdateSensitiveWord [put] +func (c *SkuController) UpdateSensitiveWord() { + +} + // @Title 子分类下商品的重排序 // @Description 子分类下商品的重排序 // @Param token header string true "认证token"