Selaa lähdekoodia

回款开通权益

renjiaojiao 1 vuosi sitten
vanhempi
commit
2b40cc6ccf
2 muutettua tiedostoa jossa 22 lisäystä ja 11 poistoa
  1. 18 6
      src/order/otherOrderService.go
  2. 4 5
      src/order/serviceOpen.go

+ 18 - 6
src/order/otherOrderService.go

@@ -2096,12 +2096,7 @@ func UpdateRule(entId int, update map[string]interface{}, phone string) bool {
 				"i_type":   tp,
 			}, up3, true, false)
 		}
-		if len(up1) > 0 {
-			ok1 = util.MQFW.Update("ent_user", map[string]interface{}{
-				"i_entid":  entId,
-				"i_userid": (*userData)["id"],
-			}, up1, true, false)
-		}
+
 		if len(up2) > 0 {
 			ok2 = util.MQFW.Update("entniche_rule", map[string]interface{}{
 				"i_entid":  entId,
@@ -2109,6 +2104,23 @@ func UpdateRule(entId int, update map[string]interface{}, phone string) bool {
 				"i_type":   tp,
 			}, up2, true, false)
 		}
+		if len(up1) > 0 {
+			query := bson.M{
+				"$or": []bson.M{
+					bson.M{"i_vip_status": bson.M{"$gt": 0}},
+					bson.M{"i_member_status": bson.M{"$gt": 0}},
+				},
+				"i_entid":  entId,
+				"i_userid": (*userData)["id"],
+			}
+			if util.MQFW.Count("ent_user", query) > 0 {
+				return true
+			}
+			ok1 = util.MQFW.Update("ent_user", map[string]interface{}{
+				"i_entid":  entId,
+				"i_userid": (*userData)["id"],
+			}, up1, true, false)
+		}
 		//默认数据处理
 
 		return ok1 || ok2

+ 4 - 5
src/order/serviceOpen.go

@@ -431,6 +431,7 @@ func OpenUserService(tx *sql.Tx, orderCode string, orderInfo map[string]interfac
 	if productType == "VIP订阅" {
 		vipType := cm.IntAll(orderInfo["vip_type"])
 		if vipType == 0 {
+			vipStartTime, vipEndTime := GetStartAndEndTime(time.Now().Format(cm.Date_Short_Layout), cm.IntAll(filterMap["cyclecount"]), cm.IntAll(filterMap["cycleunit"]))
 			if cm.IntAll(orderInfo["buy_subject"]) == 2 { //购买主体是企业,手机号改变,需要重新创建企业
 				entId, err, userPositionId = AutomaticallyCreatingEnt(cm.ObjToString(orderInfo["company_name"]), cm.ObjToString(orderInfo["user_phone"]), orderCode, 1, userId)
 				if err != nil {
@@ -438,19 +439,16 @@ func OpenUserService(tx *sql.Tx, orderCode string, orderInfo map[string]interfac
 					return err
 				}
 				userId = userPositionId
-			}
-			vipStartTime, vipEndTime := GetStartAndEndTime(time.Now().Format(cm.Date_Short_Layout), cm.IntAll(filterMap["cyclecount"]), cm.IntAll(filterMap["cycleunit"]))
-			if cm.IntAll(orderInfo["buy_subject"]) == 2 {
 				var (
 					entService bool
 					userCount  int
 				)
 				entService, userCount = EntServiceOpen(entId, cm.ObjToString(orderInfo["user_phone"]), cm.ObjToString(orderInfo["product_type"]), vipStartTime.Unix())
 				orderId := cm.IntAll(orderInfo["id"])
-				if cm.IntAll(entId) != 0 && cm.IntAll(orderInfo["buy_count"]) > 0 {
+				if entId != 0 && cm.IntAll(orderInfo["buy_count"]) > 0 {
 					regRuler := "^1[3456789]{1}\\d{9}$"
 					reg := regexp.MustCompile(regRuler)
-					if cm.IntAll(orderInfo["order_status"]) == 1 && reg.MatchString(cm.ObjToString(orderInfo["user_phone"])) && cm.ObjToString(orderInfo["company_name"]) != "" {
+					if reg.MatchString(cm.ObjToString(orderInfo["user_phone"])) && cm.ObjToString(orderInfo["company_name"]) != "" {
 						newBuySet := cm.ObjToMap(filterMap["newBuyset"])
 						if newBuySet == nil {
 							return errors.New("filtermap newBuyset字段为空")
@@ -531,6 +529,7 @@ func OpenUserService(tx *sql.Tx, orderCode string, orderInfo map[string]interfac
 					//清理缓存
 					go ClearBigVipUserPower(userId)
 				}
+				updateOrder["vip_starttime"] = time.Now().Format(cm.Date_Full_Layout)
 			}
 		}