Procházet zdrojové kódy

Merge branch 'feature/v2.4.31' into dev/v2.4.31_rjj

renjiaojiao před 1 rokem
rodič
revize
e2aec1b03c
1 změnil soubory, kde provedl 97 přidání a 63 odebrání
  1. 97 63
      src/order/orderManageController.go

+ 97 - 63
src/order/orderManageController.go

@@ -3312,73 +3312,117 @@ func IsOpenBig(context *admin.Context) (interface{}, error) {
 	var notStartFlag bool
 	var contactOrder []map[string]interface{} //关联订单
 	if param.Phone != "" {
-		userId := ""
-		nowTime := time.Now().Unix()
-		userData, ok := util.MQFW.FindOne("user", map[string]interface{}{"s_phone": param.Phone})
-		if ok && userData != nil && len(*userData) > 0 {
-			userId = mongodb.BsonIdToSId((*userData)["_id"])
-			bigStart = qutil.Int64All((*userData)["i_member_starttime"])
-			bigEnd = qutil.Int64All((*userData)["i_member_endtime"])
-			subStatus = qutil.IntAll((*userData)["i_member_sub_status"])
-			memberStatus = qutil.IntAll((*userData)["i_member_status"])
-			mainId = qutil.ObjToString((*userData)["s_member_mainid"])
-			//o_member_jy := qutil.ObjToMap((*userData)["(*userData)"])
-			if memberJyMap, ok1 := ((*userData)["o_member_jy"]).(map[string]interface{}); ok1 {
-				areaCount = qutil.IntAll(memberJyMap["i_areacount"])
-			}
-			buyCount = qutil.IntAll((*userData)["i_pay_sub_num"]) + qutil.IntAll((*userData)["i_free_sub_num"]) + 1
-		} else {
-			userDatas, oks := util.MQFW.FindOne("user", map[string]interface{}{"s_m_phone": param.Phone})
-			if oks && userDatas != nil && len(*userDatas) > 0 {
-				userId = mongodb.BsonIdToSId((*userDatas)["_id"])
-				bigStart = qutil.Int64All((*userDatas)["i_member_starttime"])
-				bigEnd = qutil.Int64All((*userDatas)["i_member_endtime"])
-				subStatus = qutil.IntAll((*userDatas)["i_member_sub_status"])
-				memberStatus = qutil.IntAll((*userDatas)["i_member_status"])
-				mainId = qutil.ObjToString((*userDatas)["s_member_mainid"])
-				if memberJyMap, ok1 := ((*userData)["(*userData)"]).(map[string]interface{}); ok1 {
+		if param.BuySubject == "1" { //个人版本会员状态查询
+			userId := ""
+			nowTime := time.Now().Unix()
+			userData, ok := util.MQFW.FindOne("user", map[string]interface{}{"s_phone": param.Phone})
+			if ok && userData != nil && len(*userData) > 0 {
+				userId = mongodb.BsonIdToSId((*userData)["_id"])
+				bigStart = qutil.Int64All((*userData)["i_member_starttime"])
+				bigEnd = qutil.Int64All((*userData)["i_member_endtime"])
+				subStatus = qutil.IntAll((*userData)["i_member_sub_status"])
+				memberStatus = qutil.IntAll((*userData)["i_member_status"])
+				mainId = qutil.ObjToString((*userData)["s_member_mainid"])
+				//o_member_jy := qutil.ObjToMap((*userData)["(*userData)"])
+				if memberJyMap, ok1 := ((*userData)["o_member_jy"]).(map[string]interface{}); ok1 {
 					areaCount = qutil.IntAll(memberJyMap["i_areacount"])
 				}
 				buyCount = qutil.IntAll((*userData)["i_pay_sub_num"]) + qutil.IntAll((*userData)["i_free_sub_num"]) + 1
 			} else {
-				isYear = 2
+				userDatas, oks := util.MQFW.FindOne("user", map[string]interface{}{"s_m_phone": param.Phone})
+				if oks && userDatas != nil && len(*userDatas) > 0 {
+					userId = mongodb.BsonIdToSId((*userDatas)["_id"])
+					bigStart = qutil.Int64All((*userDatas)["i_member_starttime"])
+					bigEnd = qutil.Int64All((*userDatas)["i_member_endtime"])
+					subStatus = qutil.IntAll((*userDatas)["i_member_sub_status"])
+					memberStatus = qutil.IntAll((*userDatas)["i_member_status"])
+					mainId = qutil.ObjToString((*userDatas)["s_member_mainid"])
+					if memberJyMap, ok1 := ((*userData)["(*userData)"]).(map[string]interface{}); ok1 {
+						areaCount = qutil.IntAll(memberJyMap["i_areacount"])
+					}
+					buyCount = qutil.IntAll((*userData)["i_pay_sub_num"]) + qutil.IntAll((*userData)["i_free_sub_num"]) + 1
+				} else {
+					isYear = 2
+				}
 			}
-		}
-		if nowTime < bigEnd && nowTime < bigStart {
-			existComingIntoEffective = true
-		}
-		if userId != "" {
-			if bigStart >= nowTime {
-				status = 1
-				endTime = bigEnd
-				notStartFlag = true
-			} else if (nowTime < bigEnd && memberStatus > 0) || bigStart >= nowTime {
-				status = 1
-				endTime = bigEnd
+			if nowTime < bigEnd && nowTime < bigStart {
+				existComingIntoEffective = true
 			}
-			if (subStatus == 0 && memberStatus < 0 && mainId != "") || (subStatus == 1 && memberStatus > 0 && mainId != "") {
-				isSub = 1
+			if userId != "" {
+				if bigStart >= nowTime {
+					status = 1
+					endTime = bigEnd
+					notStartFlag = true
+				} else if (nowTime < bigEnd && memberStatus > 0) || bigStart >= nowTime {
+					status = 1
+					endTime = bigEnd
+				}
+				if (subStatus == 0 && memberStatus < 0 && mainId != "") || (subStatus == 1 && memberStatus > 0 && mainId != "") {
+					isSub = 1
+				}
+				if memberStatus == 4 {
+					status = 2
+				}
+				orderData := util.JysqlDB.FindOne("dataexport_order", map[string]interface{}{"order_status": 1, "product_type": "大会员", "user_id": userId}, "vip_starttime,vip_endtime", "id asc")
+				if orderData != nil && len(*orderData) > 0 {
+					//获取本地location
+					start := qutil.ObjToString((*orderData)["vip_starttime"])
+					end := qutil.ObjToString((*orderData)["vip_endtime"])
+					loc, _ := time.LoadLocation("Local")
+					starts, _ := time.ParseInLocation(qutil.Date_Full_Layout, start, loc)
+					ends, _ := time.ParseInLocation(qutil.Date_Full_Layout, end, loc)
+					starttime := starts.Unix()
+					endtime := ends.Unix()
+					if endtime-starttime > 86400*360 {
+						isYear = 1
+					}
+				} else {
+					isYear = 2
+				}
 			}
-			if memberStatus == 4 {
-				status = 2
+			if param.OrderCode != "" && notStartFlag { // 编辑的时候需要再次验证是否存在待生效的订单
+				if !ExistNotStartOrder(param.Phone, BIGMEMBER, param.OrderCode) {
+					status = 0
+					existComingIntoEffective = false
+				}
 			}
-			orderData := util.JysqlDB.FindOne("dataexport_order", map[string]interface{}{"order_status": 1, "product_type": "大会员", "user_id": userId}, "vip_starttime,vip_endtime", "id asc")
-			if orderData != nil && len(*orderData) > 0 {
-				//获取本地location
-				start := qutil.ObjToString((*orderData)["vip_starttime"])
-				end := qutil.ObjToString((*orderData)["vip_endtime"])
-				loc, _ := time.LoadLocation("Local")
-				starts, _ := time.ParseInLocation(qutil.Date_Full_Layout, start, loc)
-				ends, _ := time.ParseInLocation(qutil.Date_Full_Layout, end, loc)
-				starttime := starts.Unix()
-				endtime := ends.Unix()
-				if endtime-starttime > 86400*360 {
+			// 增加如若存在订单审核状态为“待一审”、“待二审”、“已退回”的大会员订单的则不允许创建
+			if ExistProcessOrder(param.Phone, BIGMEMBER, param.OrderCode) {
+				existComingIntoEffective = true
+			}
+
+		} else { //企业版本会员状态查询
+			vipRes := util.JysqlDB.SelectBySql("SELECT ewe.* ,bc.id AS comoboId FROM entniche_info ei INNER JOIN entniche_wait_empower ewe ON ei.id = ewe.ent_id  LEFT JOIN bigmember_combo bc ON REPLACE(ewe.product_type,\"大会员\",\"\") = bc.s_name WHERE ei.NAME = ?  AND phone = ? ORDER BY ewe.create_time DESC LIMIT 1", param.EntName, param.Phone)
+			if vipRes != nil && len(*vipRes) > 0 {
+				start := qutil.ObjToString((*vipRes)[0]["start_time"])
+				end := qutil.ObjToString((*vipRes)[0]["end_time"])
+				starts, _ := time.ParseInLocation(qutil.Date_Full_Layout, start, time.Local)
+				ends, _ := time.ParseInLocation(qutil.Date_Full_Layout, end, time.Local)
+				bigStart = starts.Unix()
+				bigEnd = ends.Unix()
+
+				if bigEnd-bigStart > 86400*360 {
 					isYear = 1
 				}
+				nowTime := time.Now().Unix()
+				areaCount = qutil.IntAll((*vipRes)[0]["province_count"])
+				memberStatus = qutil.IntAll((*vipRes)[0]["comoboId"])
+				buyCount = qutil.IntAll((*vipRes)[0]["use_count"])
+
+				if nowTime < bigEnd && nowTime > bigStart {
+					status = memberStatus
+				} else {
+					status = -memberStatus
+				}
+
+				if nowTime < bigEnd && nowTime < bigStart {
+					existComingIntoEffective = true
+				}
 			} else {
 				isYear = 2
 			}
 		}
+
 		//获取关联订单
 		if param.GetContactOrder == 1 && param.BuySubject != "" {
 			res := &[]map[string]interface{}{}
@@ -3426,16 +3470,6 @@ func IsOpenBig(context *admin.Context) (interface{}, error) {
 			}
 		}
 	}
-	if param.OrderCode != "" && notStartFlag { // 编辑的时候需要再次验证是否存在待生效的订单
-		if !ExistNotStartOrder(param.Phone, BIGMEMBER, param.OrderCode) {
-			status = 0
-			existComingIntoEffective = false
-		}
-	}
-	// 增加如若存在订单审核状态为“待一审”、“待二审”、“已退回”的大会员订单的则不允许创建
-	if ExistProcessOrder(param.Phone, BIGMEMBER, param.OrderCode) {
-		existComingIntoEffective = true
-	}
 	return map[string]interface{}{
 		"Bigstatus":           status,
 		"isSub":               isSub,