Browse Source

订阅设置日志保存

WH01243 8 tháng trước cách đây
mục cha
commit
aa99ca4aee
1 tập tin đã thay đổi với 31 bổ sung14 xóa
  1. 31 14
      entniche_new/src/service/distribute/distribute.go

+ 31 - 14
entniche_new/src/service/distribute/distribute.go

@@ -256,7 +256,7 @@ func (ac *Action) Distribute_add() {
 	if len(distribute_ruleMap) > 0 {
 		if distribute_ruleMap["area"] != nil {
 			areabl := false
-			for k, _ := range *qutil.ObjToMap(distribute_ruleMap["area"]) {
+			for k := range *qutil.ObjToMap(distribute_ruleMap["area"]) {
 				if k == "全国" {
 					areabl = true
 				}
@@ -292,6 +292,10 @@ func (ac *Action) Distribute_add() {
 		ac.ServeJson(Result{Data: M{"status": 0}})
 		return
 	}
+	//保存分发
+	distribute_rule["rule_id"] = id
+	distribute_rule["createtime"] = time.Now().Unix()
+	util.Mgo_Log.Save("district_log", distribute_rule)
 	persons, _ := distribute_ruleMap["persons"].([]interface{})
 	if len(persons) > 0 {
 		array := []string{}
@@ -434,7 +438,7 @@ func (ac *Action) Distribute_update() {
 	if update_map != nil && update_map["id"] != nil {
 		if update_map["area"] != nil {
 			areabl := false
-			for k, _ := range *qutil.ObjToMap(update_map["area"]) {
+			for k := range *qutil.ObjToMap(update_map["area"]) {
 				if k == "全国" {
 					areabl = true
 				}
@@ -461,6 +465,15 @@ func (ac *Action) Distribute_update() {
 			"o_district":   distribute_rule["o_district"],
 			"a_buyerclass": distribute_rule["a_buyerclass"],
 		}}) {
+			//保存分发
+			util.Mgo_Log.Save("district_log", map[string]interface{}{
+				"rule_id":      rule_id,
+				"a_items":      distribute_rule["a_items"],
+				"o_area":       distribute_rule["o_area"],
+				"o_district":   distribute_rule["o_district"],
+				"a_buyerclass": distribute_rule["a_buyerclass"],
+				"createtime":   time.Now().Unix(),
+			})
 			status = 1
 		}
 		persons, _ := update_map["persons"].([]interface{})
@@ -691,8 +704,8 @@ func UpdateAreaForDistribute(productType string, userId, entId int, area interfa
 	mdata, ok := util.MQFW.Find(`user`, map[string]interface{}{
 		"i_appid": 2,
 		"$or": []map[string]interface{}{
-			map[string]interface{}{"s_phone": phone},
-			map[string]interface{}{"s_m_phone": phone}},
+			{"s_phone": phone},
+			{"s_m_phone": phone}},
 	}, nil, `{"_id":1}`, false, -1, -1)
 	if ok && mdata != nil && len(*mdata) > 0 {
 		i_type := 0
@@ -704,7 +717,6 @@ func UpdateAreaForDistribute(productType string, userId, entId int, area interfa
 			if uid == "" {
 				continue
 			}
-
 			ruleData, ok2 := util.MQFW.Find(`entniche_rule`, map[string]interface{}{
 				"i_userid": userId,
 				"i_entid":  entId,
@@ -713,15 +725,6 @@ func UpdateAreaForDistribute(productType string, userId, entId int, area interfa
 			if !ok2 || mdata == nil || len(*ruleData) == 0 {
 				continue
 			}
-			o_entniche, _ := v["o_entniche"].(map[string]interface{})
-			util.Mgo_Log.Save("ovipjy_log", map[string]interface{}{
-				"userid":      uid,
-				"type":        types,
-				"ovipjy":      o_entniche,
-				"o_member_jy": o_entniche,
-				"createtime":  time.Now().Unix(),
-				"from":        "distribute", //用于区分是分发设置的
-			})
 			//个人订阅
 			util.MQFW.Update("entniche_rule", map[string]interface{}{
 				"i_userid": userId,
@@ -733,6 +736,20 @@ func UpdateAreaForDistribute(productType string, userId, entId int, area interfa
 					"o_entniche.o_area":     area,
 					"o_entniche.o_district": district,
 				}}, true, false)
+			ruleData, ok2 = util.MQFW.Find(`entniche_rule`, map[string]interface{}{
+				"i_userid": userId,
+				"i_entid":  entId,
+				"i_type":   i_type,
+			}, nil, `{"o_entniche":1}`, false, -1, -1)
+			o_entniche, _ := (*ruleData)[0]["o_entniche"].(map[string]interface{})
+			util.Mgo_Log.Save("ovipjy_log", map[string]interface{}{
+				"userid":      userId,
+				"type":        types,
+				"ovipjy":      o_entniche,
+				"o_member_jy": o_entniche,
+				"createtime":  time.Now().Unix(),
+				"from":        "distribute", //用于区分是分发设置的
+			})
 		}
 	}
 }