|
@@ -940,17 +940,21 @@ func UpStateAndUpSpider(code, id, reason, username string, state int) (bool, err
|
|
|
}
|
|
|
//oldstate := qu.IntAll(one["state"])
|
|
|
switch state {
|
|
|
- case Sp_state_4: //作废
|
|
|
+ case Sp_state_4, Sp_state_6: //作废、下架
|
|
|
// if oldstate == Sp_state_5 {
|
|
|
// upresult = false
|
|
|
// err = errors.New("已上架不允许作废")
|
|
|
// } else {
|
|
|
// upresult = true
|
|
|
// }
|
|
|
- upresult, err = spider.UpdateSpiderByCodeState(code, "6", event) //下架
|
|
|
- case Sp_state_5, Sp_state_6: //上下架
|
|
|
- upresult, err = spider.UpdateSpiderByCodeState(code, fmt.Sprint(state), event)
|
|
|
- //log.Println(upresult, err)
|
|
|
+ upresult, err = spider.UpdateSpiderByCodeState(code, fmt.Sprint(state), event) //下架
|
|
|
+ case Sp_state_5: //上架(爬虫端在更新上架的时候为了更新内存中字段,采用先下架在上架)
|
|
|
+ upresult, err = spider.UpdateSpiderByCodeState(code, "6", event)
|
|
|
+ qu.Debug("下架:", upresult, code)
|
|
|
+ if upresult && err == nil {
|
|
|
+ upresult, err = spider.UpdateSpiderByCodeState(code, fmt.Sprint(state), event)
|
|
|
+ qu.Debug("上架:", upresult, code)
|
|
|
+ }
|
|
|
default:
|
|
|
upresult = true
|
|
|
err = nil
|
|
@@ -985,19 +989,21 @@ func UpStateAndUpSpider(code, id, reason, username string, state int) (bool, err
|
|
|
upset["disablereason"] = reason
|
|
|
upset["modifytime"] = time.Now().Unix()
|
|
|
}
|
|
|
- upresult = mgdb.Update("luaconfig", map[string]interface{}{"code": code}, map[string]interface{}{"$set": upset}, false, false)
|
|
|
- if state == Sp_state_1 { //提交审核,验证是否提交成功
|
|
|
- for i := 1; i <= 5; i++ { //解决提交不上,重试5次
|
|
|
- lua := *mgdb.FindOne("luaconfig", map[string]interface{}{"code": code})
|
|
|
- tmpState := qu.IntAll(lua["state"])
|
|
|
- if state == tmpState {
|
|
|
- break
|
|
|
- } else {
|
|
|
- upresult = mgdb.Update("luaconfig", map[string]interface{}{"code": code}, map[string]interface{}{"$set": upset}, false, false)
|
|
|
- upresult = false
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ qu.Debug("set:", upset)
|
|
|
+ upresult = u.MgoE.Update("luaconfig", map[string]interface{}{"code": code}, map[string]interface{}{"$set": upset}, false, false)
|
|
|
+ //upresult = mgdb.Update("luaconfig", map[string]interface{}{"code": code}, map[string]interface{}{"$set": upset}, false, false)
|
|
|
+ // if state == Sp_state_1 { //提交审核,验证是否提交成功
|
|
|
+ // for i := 1; i <= 5; i++ { //解决提交不上,重试5次
|
|
|
+ // lua := *mgdb.FindOne("luaconfig", map[string]interface{}{"code": code})
|
|
|
+ // tmpState := qu.IntAll(lua["state"])
|
|
|
+ // if state == tmpState {
|
|
|
+ // break
|
|
|
+ // } else {
|
|
|
+ // upresult = mgdb.Update("luaconfig", map[string]interface{}{"code": code}, map[string]interface{}{"$set": upset}, false, false)
|
|
|
+ // upresult = false
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
qu.Debug("提交日志:", code, upset, upresult)
|
|
|
if upresult && (state == Sp_state_2 || state == Sp_state_3) { //打回、审核记录日志
|
|
|
types := "打回"
|