duxin 3 mesiacov pred
rodič
commit
a68c95dfc6

+ 1 - 0
internal/cmd/cmd.go

@@ -34,6 +34,7 @@ var (
 					group.GET("/getSelectItem", controller.GetSelectItemHandler)              //获取公共选项
 					group.GET("/getSalesList", controller.GetSalesListHandler)                //获取销售人员列表
 					group.POST("/getAccountVipStatus", controller.GetAccountVipStatusHandler) //获取账户会员状态
+					group.POST("/userServiceStatus", controller.GetUserServiceNew)            //获取账户大会员服务
 					group.POST("/userService", controller.GetUserService)                     //获取账户大会员服务
 					group.POST("/userChangePhone", controller.UserChangePhone)                //用户编辑手机号个人权益
 					group.GET("/getSalesChannelItem", controller.GetSalesChannelItem)         //销售区点&0原订单类型

+ 31 - 0
internal/controller/userServiceNew.go

@@ -0,0 +1,31 @@
+package controller
+
+import (
+	. "app.yhyue.com/moapp/jybase/api"
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/net/ghttp"
+	"github.com/gogf/gf/v2/util/gconv"
+	"github.com/pkg/errors"
+	"jyOrderManager/internal/logic/user"
+	"jyOrderManager/internal/model"
+)
+
+// GetUserServiceNew 用户开通服务
+func GetUserServiceNew(r *ghttp.Request) {
+	rData, err := func() (interface{}, error) {
+		var param model.UserServiceParams
+		err := gconv.Struct(r.GetBody(), &param)
+		if err != nil {
+			return nil, errors.Wrap(err, "数据校验异常")
+		}
+		list, err := user.GetUserServiceNew(r.Context(), param)
+		if err != nil {
+			return nil, errors.Wrap(err, "用户开通服务异常")
+		}
+		return list, nil
+	}()
+	if err != nil {
+		g.Log().Errorf(r.Context(), "用户开通服务异常 %v", err)
+	}
+	r.Response.WriteJson(NewResult(rData, err))
+}

+ 70 - 60
internal/logic/order/detail.go

@@ -81,6 +81,67 @@ func Detail(ctx context.Context, param model.OrderDetailParams) (map[string]inte
 	if err != nil || productData.IsEmpty() {
 		return nil, err
 	}
+	var (
+		//佣金 手续费 合同金额 企业
+		isCommission, isProceduresMoney, isCash, isEnt bool
+		newEntName                                     string
+		moneyCorrectionArr                             []map[string]interface{}
+		productRed                                     map[int]int
+	)
+	//红冲
+	redPunch := make(map[string]interface{})
+	subject := orderData.Map()["return_commpany"]
+	moneyCorrectionData, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT * FROM  moneyCorrection WHERE orderCode =%s order by createTime desc`, param.OrderCode))
+	if !moneyCorrectionData.IsEmpty() {
+		for _, m := range moneyCorrectionData.List() {
+			if detailId := gconv.Int(m["detail_id"]); detailId > 0 {
+				productRed[detailId] += gconv.Int(m["payMoney"])
+				orderDetail, _ := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT product_type FROM  jy_order_detail WHERE id =%d`, gconv.Int(m["detail_id"])))
+				if !orderDetail.IsEmpty() {
+					m["name"] = orderDetail.Map()["product_type"]
+				} else if gconv.String(m["activity_code"]) != "" {
+					activityData, err := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT * FROM  jy_product_activity WHERE code ='%s' `, gconv.String(m["activity_code"])))
+					if err == nil && !activityData.IsEmpty() {
+						m["name"] = gconv.String(activityData.Map()["name"])
+					}
+				}
+			}
+			if common.InterfaceToStr(m["redType"]) == "金额红冲" {
+				if common.IntAll(m["payMoney"]) != 0 {
+					isCash = true
+				}
+				if common.IntAll(m["commission"]) != 0 {
+					isCommission = true
+				}
+				if common.IntAll(m["proceduresMoney"]) != 0 {
+					isProceduresMoney = true
+				}
+				if common.InterfaceToStr(m["signingSubject"]) == "" {
+					m["signingSubject"] = subject
+				}
+			} else if strings.Contains(common.InterfaceToStr(m["redType"]), "主体") {
+				isEnt = true
+				if common.InterfaceToStr(m["newSigningSubject"]) != "" {
+					m["signingSubject"] = m["newSigningSubject"]
+				}
+				if newSigningSubject := common.InterfaceToStr(m["newSigningSubject"]); newSigningSubject != "" && newEntName == "" {
+					newEntName = newSigningSubject
+				}
+			}
+			moneyCorrectionArr = append(moneyCorrectionArr, m)
+		}
+		if newEntName != "" {
+			orderMap["return_commpany"] = newEntName
+		}
+	}
+
+	redPunch["moneyCorrectionData"] = moneyCorrectionArr
+	redPunch["isUpCash"] = isCash
+	redPunch["isUpCommission"] = isCommission
+	redPunch["isUpProceduresMoney"] = isProceduresMoney
+	redPunch["isUpEnt"] = isEnt
+	result["redPunchData"] = redPunch
+
 	for _, m := range productData.List() {
 		if activityCode := gconv.String(m["activity_code"]); activityCode != "" {
 			activityData, err := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT * FROM  jy_product_activity WHERE code ='%s' `, activityCode))
@@ -88,6 +149,7 @@ func Detail(ctx context.Context, param model.OrderDetailParams) (map[string]inte
 				m["activityName"] = gconv.String(activityData.Map()["name"])
 			}
 		}
+		m["final_price"] = gconv.Int(m["final_price"]) + productRed[gconv.Int(m["id"])]
 		productItem, _ := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT jpi.name,jpc.auto,jpc.code,jpc.attribute FROM jy_product_item jpi
 INNER JOIN jy_product_class jpc on jpi.product_class_id = jpc.id WHERE jpi.code = '%s'`, gconv.String(m["product_code"])))
 		if !productItem.IsEmpty() {
@@ -146,8 +208,14 @@ INNER JOIN jy_product_class jpc on jpi.product_class_id = jpc.id WHERE jpi.code
 			var orderArr []map[string]interface{}
 			//关联订单
 			if gconv.String(m["product_type"]) != "大会员" && gconv.String(m["product_type"]) != "VIP订阅" {
-				if linkedOrder := user.SpecialService(ctx, common.InterfaceToStr(orderData.Map()["user_id"]), gconv.String(m["product_type"])); linkedOrder != nil {
-					m["linkedOrder"] = linkedOrder[0]
+				var whereSql string
+				if gconv.Int(orderData.Map()["buy_subject"]) == 1 {
+					whereSql = fmt.Sprintf("dor.user_phone = '%s' and dor.buy_subject =1 ", gconv.String(orderData.Map()["user_phone"]))
+				} else {
+					whereSql = fmt.Sprintf("dor.user_phone = '%s' and dor.buy_subject =2 and dor.company_name ='%s'  ", gconv.String(orderData.Map()["user_phone"]), gconv.String(orderData.Map()["company_name"]))
+				}
+				if linkedOrder := user.SpecialService(ctx, whereSql, gconv.String(m["product_type"]), gconv.Int(orderData.Map()["buy_subject"])); linkedOrder != nil {
+					m["linkedOrder"] = linkedOrder
 				}
 			} else {
 				switch gconv.Int(orderData.Map()["buy_subject"]) {
@@ -264,64 +332,6 @@ WHERE eo.wait_empower_id = %s and jod.is_service_open =1 ORDER BY do.create_time
 		result["orderTransfer"] = orderTransfer.List()
 	}
 
-	var (
-		//佣金 手续费 合同金额 企业
-		isCommission, isProceduresMoney, isCash, isEnt bool
-		newEntName                                     string
-		moneyCorrectionArr                             []map[string]interface{}
-	)
-	//红冲
-	redPunch := make(map[string]interface{})
-	subject := orderData.Map()["return_commpany"]
-	moneyCorrectionData, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT * FROM  moneyCorrection WHERE orderCode =%s order by createTime desc`, param.OrderCode))
-	if !moneyCorrectionData.IsEmpty() {
-		for _, m := range moneyCorrectionData.List() {
-			if gconv.Int(m["detail_id"]) > 0 {
-				orderDetail, _ := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT product_type FROM  jy_order_detail WHERE id =%d`, gconv.Int(m["detail_id"])))
-				if !orderDetail.IsEmpty() {
-					m["name"] = orderDetail.Map()["product_type"]
-				} else if gconv.String(m["activity_code"]) != "" {
-					activityData, err := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT * FROM  jy_product_activity WHERE code ='%s' `, gconv.String(m["activity_code"])))
-					if err == nil && !activityData.IsEmpty() {
-						m["name"] = gconv.String(activityData.Map()["name"])
-					}
-				}
-			}
-			if common.InterfaceToStr(m["redType"]) == "金额红冲" {
-				if common.IntAll(m["payMoney"]) != 0 {
-					isCash = true
-				}
-				if common.IntAll(m["commission"]) != 0 {
-					isCommission = true
-				}
-				if common.IntAll(m["proceduresMoney"]) != 0 {
-					isProceduresMoney = true
-				}
-				if common.InterfaceToStr(m["signingSubject"]) == "" {
-					m["signingSubject"] = subject
-				}
-			} else if strings.Contains(common.InterfaceToStr(m["redType"]), "主体") {
-				isEnt = true
-				if common.InterfaceToStr(m["newSigningSubject"]) != "" {
-					m["signingSubject"] = m["newSigningSubject"]
-				}
-				if newSigningSubject := common.InterfaceToStr(m["newSigningSubject"]); newSigningSubject != "" && newEntName == "" {
-					newEntName = newSigningSubject
-				}
-			}
-			moneyCorrectionArr = append(moneyCorrectionArr, m)
-		}
-		if newEntName != "" {
-			orderMap["return_commpany"] = newEntName
-		}
-	}
-
-	redPunch["moneyCorrectionData"] = moneyCorrectionArr
-	redPunch["isUpCash"] = isCash
-	redPunch["isUpCommission"] = isCommission
-	redPunch["isUpProceduresMoney"] = isProceduresMoney
-	redPunch["isUpEnt"] = isEnt
-	result["redPunchData"] = redPunch
 	//合同
 	contractData, _ := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT * FROM  contract WHERE order_code =%s `, param.OrderCode))
 	if !contractData.IsEmpty() {

+ 1 - 1
internal/logic/product/bigmember/bigcommon.go

@@ -237,7 +237,7 @@ func (p jyBigProduct) UserPdfDistribution(ctx context.Context, endDate time.Time
 	} else {
 		serviceIdArr = p.param.Filter.ServiceIds
 	}
-	serverData, _ := g.DB().Ctx(ctx).Query(ctx, fmt.Sprintf(`SELECT * FROM bigmember_service WHERE id in (%s) `, strings.Join(serviceIdArr, ",")))
+	serverData, _ := g.DB().Ctx(ctx).Query(ctx, `SELECT * FROM bigmember_service WHERE id in (?) and s_name like '%报告pdf下载%'`, strings.Join(serviceIdArr, ","))
 	if !serverData.IsEmpty() {
 		for _, m := range serverData.List() {
 			var (

+ 10 - 9
internal/logic/product/bigmember/bigmember.go

@@ -138,15 +138,16 @@ func (p jyBigProduct) Check(ctx context.Context, t int) error {
 	if (p.param.ServiceType == Renew || p.param.ServiceType == Upgrades) && p.param.LinkedOrderId == "" {
 		return errors.New("缺少关联订单")
 	}
-
-	switch p.param.Tactics {
-	case 2:
-		if p.param.Filter.GiftType <= 0 {
-			return errors.New("大会员-请选择时间")
-		}
-	default:
-		if p.param.Filter.BuyCycle <= 0 {
-			return errors.New("大会员请选择时间")
+	if p.param.ServiceType == 1 || p.param.ServiceType == 2 || p.param.ServiceType == 4 {
+		switch p.param.Tactics {
+		case 2:
+			if p.param.Filter.GiftType <= 0 {
+				return errors.New("大会员-请选择时间")
+			}
+		default:
+			if p.param.Filter.BuyCycle <= 0 {
+				return errors.New("大会员-请选择时间")
+			}
 		}
 	}
 

+ 10 - 8
internal/logic/product/subvip/check.go

@@ -28,14 +28,16 @@ func (p jySubVipProduct) Check(ctx context.Context, t int) error {
 	if (p.OrderDetail.ServiceType == 2 || p.OrderDetail.ServiceType == 3) && p.OrderDetail.LinkedOrderId <= 0 {
 		return errors.New("超级订阅-缺少关联订单")
 	}
-	switch p.OrderDetail.Tactics {
-	case 2:
-		if p.OrderDetail.Filter.GiftType <= 0 {
-			return errors.New("超级订阅-请选择时间")
-		}
-	default:
-		if p.OrderDetail.Filter.BuyCycle <= 0 {
-			return errors.New("超级订阅-请选择时间")
+	if p.OrderDetail.ServiceType == 1 || p.OrderDetail.ServiceType == 2 || p.OrderDetail.ServiceType == 4 {
+		switch p.OrderDetail.Tactics {
+		case 2:
+			if p.OrderDetail.Filter.GiftType <= 0 {
+				return errors.New("超级订阅-请选择时间")
+			}
+		default:
+			if p.OrderDetail.Filter.BuyCycle <= 0 {
+				return errors.New("超级订阅-请选择时间")
+			}
 		}
 	}
 

+ 287 - 268
internal/logic/user/getService.go

@@ -2,13 +2,12 @@ package user
 
 import (
 	"app.yhyue.com/moapp/jybase/common"
-	"app.yhyue.com/moapp/jybase/date"
-	"app.yhyue.com/moapp/jybase/mongodb"
 	"context"
+	"errors"
 	"fmt"
+	"github.com/gogf/gf/v2/database/gdb"
 	"github.com/gogf/gf/v2/frame/g"
 	"github.com/gogf/gf/v2/util/gconv"
-	"github.com/pkg/errors"
 	"jyOrderManager/internal/jyutil"
 	"jyOrderManager/internal/model"
 	"strings"
@@ -20,60 +19,82 @@ func GetUserService(ctx context.Context, param model.UserServiceParams) (interfa
 		serviceArrMap []map[string]interface{}
 		userData      *map[string]interface{}
 		vipExist      bool
+		whereEntTime  string
+		entRec        gdb.Record
 	)
 	if param.Phone != "" {
-		if param.BuySubject == "1" { //个人版本会员状态查询
-			if strings.Contains(param.ProductType, "大会员") || strings.Contains(param.ProductType, "订阅") {
-				sqlStr := fmt.Sprintf(`SELECT  * FROM jy_order_detail 
-WHERE jod.status = 1 and jod.is_service_open = 0  and de.buy_subject =1 and de.user_phone = '%s' and product_type like '%s'`, param.Phone, common.If(param.ProductType == "VIP订阅", "%VIP订阅%", "%大会员%"))
-				if param.OrderCode != "" {
-					sqlStr += fmt.Sprintf(" AND order_code != '%s'", param.OrderCode)
-				}
-				//检验订单是否可以进行传创建
-				order, _ := g.DB().Query(ctx, sqlStr)
-				if !order.IsEmpty() && order.Len() > 0 {
-					return map[string]interface{}{
-						"willEffect":    true,
-						"userData":      userData,
-						"serviceArrMap": nil,
-					}, nil
-				}
+		//大会员超||级订阅 判断是否有待生效订单
+		if (strings.Contains(param.ProductType, "大会员") || strings.Contains(param.ProductType, "订阅")) && param.BuySubject == "1" {
+			sqlStr := fmt.Sprintf(`SELECT  * FROM jy_order_detail  jod
+INNER JOIN dataexport_order de on jod.order_code = de.order_code
+WHERE jod.status = 4 and jod.is_service_open = 0  and de.buy_subject =1 and de.user_phone = '%s' and jod.product_type like '%s'`, param.Phone, common.If(param.ProductType == "VIP订阅", "%VIP订阅%", "%大会员%"))
+			if param.OrderCode != "" {
+				sqlStr += fmt.Sprintf(" AND order_code != '%s'", param.OrderCode)
 			}
-			userData, _ = jyutil.MG.DB().FindOne("user", map[string]interface{}{
-				"$or": []map[string]interface{}{
-					{"s_phone": param.Phone},
-					{"s_m_phone": param.Phone},
-				},
-			})
-			if userData == nil || len(*userData) == 0 {
+			//检验订单是否可以进行传创建
+			order, _ := g.DB().Query(ctx, sqlStr)
+			if !order.IsEmpty() && order.Len() > 0 {
 				return map[string]interface{}{
-					"willEffect": false,
-					//"userData":      userData,
+					"willEffect":    true,
+					"userData":      userData,
 					"serviceArrMap": nil,
 				}, nil
 			}
-			if userData != nil && len(*userData) > 0 {
-				userId := mongodb.BsonIdToSId((*userData)["_id"])
-				if param.ProductType != "大会员" && param.ProductType != "VIP订阅" {
-					serviceArrMap = SpecialService(ctx, userId, param.ProductType)
-				} else {
+		}
+		if param.BuySubject == "2" {
+			if param.EntName == "" {
+				return nil, errors.New("企业名称校验异常")
+			}
+			whereEntTime = fmt.Sprintf(` and a.end_time>'%s' `, time.Now().Format("2006-01-02 15:04:05"))
+			entRec, _ = g.DB().GetOne(ctx, fmt.Sprintf(`SELECT a.id,b.id as entUserId FROM entniche_info a
+inner JOIN entniche_user b on a.id = b.ent_id
+WHERE b.phone = '%s' and a.name = '%s'`, param.Phone, param.EntName))
+		}
+
+		//手机号是否注册
+		userData, _ = jyutil.MG.DB().FindOne("user", map[string]interface{}{
+			"$or": []map[string]interface{}{
+				{"s_phone": param.Phone},
+				{"s_m_phone": param.Phone},
+			},
+		})
+		if userData == nil || len(*userData) == 0 {
+			return map[string]interface{}{
+				"willEffect": false,
+				//"userData":      userData,
+				"serviceArrMap": nil,
+			}, nil
+		}
+		var whereSql string
+		if param.BuySubject == "1" {
+			whereSql = fmt.Sprintf("dor.user_phone = '%s' and dor.buy_subject =1 ", param.Phone)
+		} else {
+			whereSql = fmt.Sprintf("dor.user_phone = '%s' and dor.buy_subject =2 and dor.company_name ='%s'  ", param.Phone, param.EntName)
+		}
+		orderDetailType, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT DISTINCT(jod.product_type)  FROM jy_order_detail jod
+INNER JOIN dataexport_order dor on jod.order_code = dor.order_code
+WHERE %s order by dor.create_time desc`, whereSql))
+		if orderDetailType.IsEmpty() {
+			return map[string]interface{}{
+				"willEffect": false,
+				//"userData":      userData,
+				"serviceArrMap": nil,
+			}, nil
+		}
+		for _, m := range orderDetailType.List() {
+			switch gconv.String(m["product_type"]) {
+			case "大会员":
+				if param.BuySubject == "1" {
 					var (
-						serviceList                    []int
-						endTime, startTime             string
-						paySubNum, areaCount, linkedId int
-						orderArr                       []map[string]interface{}
+						linkedId, comboId, areaCount, paySubNum int
+						endTime                                 string
+						orderArr                                []map[string]interface{}
+						serviceList                             []int
+						userId                                  = common.InterfaceToStr((*userData)["_id"])
 					)
-					var whereEntTime string
-					//购买关联
-					if param.ServiceType != 1 && param.ServiceType != 4 {
-						whereEntTime = "and a.is_service_open = 1"
-					} else {
-						//续费升级关联
-						whereEntTime = "and b.order_status = 1"
-					}
-					orderData, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT   a.id,a.service_type,a.order_code,b.create_time   FROM jy_order_detail  a
+					orderData, _ := g.DB().Query(ctx, `SELECT   a.id,a.service_type,a.order_code,b.create_time   FROM jy_order_detail  a
 INNER JOIN dataexport_order b on a.order_code = b.order_code
-WHERE a.status = 1 %s and b.user_phone = '%s' and a.product_type like '%s' ORDER BY b.create_time desc `, whereEntTime, param.Phone, common.If(param.ProductType == "VIP订阅", "%VIP订阅%", "%大会员%")))
+WHERE a.status = 1  and b.user_phone = ? and a.product_type like '%大会员%' ORDER BY b.create_time desc `, param.Phone)
 					if !orderData.IsEmpty() {
 						for _, m2 := range orderData.List() {
 							if linkedId == 0 {
@@ -87,230 +108,148 @@ WHERE a.status = 1 %s and b.user_phone = '%s' and a.product_type like '%s' ORDER
 							})
 						}
 					}
-					var comboId int
-					switch param.ProductType {
-					case "VIP订阅":
-						var (
-							newVip, nationwide bool
-						)
-						vipExist = gconv.Int((*userData)["i_vip_status"]) == 2
-						if vipExist {
-							paySubNum = 1
-							vipInfo := common.ObjToMap((*userData)["o_vipjy"])
-							buySet := common.ObjToMap((*vipInfo)["o_buyset"])
-							areaCount = common.IntAll((*buySet)["areacount"])
-							//判断是新版超级订阅还是老版超级订阅
-							if common.IntAll((*buySet)["upgrade"]) == 1 {
-								newVip = true
-							}
-
-							if areaCount == -1 {
-								nationwide = true
+					startTime := common.Int64All((*userData)["i_member_starttime"])
+					bigEnd := common.Int64All((*userData)["i_member_endtime"])
+					subStatus := common.IntAll((*userData)["i_member_sub_status"])
+					memberStatus := common.IntAll((*userData)["i_member_status"])
+					comboId = common.If(memberStatus == 5, 0, memberStatus).(int)
+					mainId := common.ObjToString((*userData)["s_member_mainid"])
+					if memberJyMap, ok1 := ((*userData)["o_member_jy"]).(map[string]interface{}); ok1 {
+						areaCount = common.IntAll(memberJyMap["i_areacount"])
+					}
+					if startTime >= time.Now().Unix() {
+						endTime = time.Unix(bigEnd, 0).Format("2006-01-02 15:04:05")
+						vipExist = true
+					} else if (time.Now().Unix() < bigEnd && memberStatus > 0) || startTime >= time.Now().Unix() {
+						vipExist = true
+						endTime = time.Unix(bigEnd, 0).Format("2006-01-02 15:04:05")
+					}
+					if (subStatus == 0 && memberStatus < 0 && mainId != "") || (subStatus == 1 && memberStatus > 0 && mainId != "") {
+						vipExist = true
+					}
+					userServer, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT s_serviceid,s_smainid,l_endtime,l_starttime FROM bigmember_service_user WHERE s_userid = '%s' and i_status =0`, userId))
+					if !userServer.IsEmpty() {
+						vipExist = true
+						serMap := make(map[int]bool)
+						count, _ := g.DB().GetCount(ctx, fmt.Sprintf(`SELECT *  FROM bigmember_service_user WHERE s_userid = '%s' and i_status =0 and (s_serviceid=4 or s_serviceid =19)`, userId))
+						isHUa := count > 0
+						for _, v := range userServer.List() {
+							if isHUa && v["s_serviceid"] == 26 {
+								continue
 							}
-							endTime = time.Unix(common.Int64All((*userData)["l_vip_endtime"]), 0).Format("2006-01-02 15:04:05")
-						}
-						productCode := fmt.Sprintf("cjdy%03d", gconv.Int(common.If(areaCount > 15 || areaCount == -1, 16, areaCount)))
-						serviceArrMap = append(serviceArrMap, map[string]interface{}{
-							"vipExist":         vipExist, //当前服务是否在有限期内
-							"nationwide":       nationwide,
-							"name":             param.ProductType, //产品名称
-							"serviceEndTime":   endTime,           //服务结束时间
-							"serviceStartTime": startTime,         //服务开始时间
-							"productCode":      productCode,
-							"newVip":           newVip,
-							"empowerCount":     paySubNum,   //服务授权数
-							"provinceCount":    areaCount,   //订阅省份
-							"buySubject":       1,           //个体
-							"comboId":          comboId,     //套餐id
-							"serviceList":      serviceList, //大会员服务id
-							"linkedId":         linkedId,    //关联id
-							"linkedOrder":      orderArr,    //关联订单
-						})
-					case "大会员":
-						bigStart := common.Int64All((*userData)["i_member_starttime"])
-						bigEnd := common.Int64All((*userData)["i_member_endtime"])
-						subStatus := common.IntAll((*userData)["i_member_sub_status"])
-						memberStatus := common.IntAll((*userData)["i_member_status"])
-						comboId = common.If(memberStatus == 5, 0, memberStatus).(int)
-						mainId := common.ObjToString((*userData)["s_member_mainid"])
-						if memberJyMap, ok1 := ((*userData)["o_member_jy"]).(map[string]interface{}); ok1 {
-							areaCount = common.IntAll(memberJyMap["i_areacount"])
-						}
-						if bigStart >= time.Now().Unix() {
-							endTime = time.Unix(bigEnd, 0).Format("2006-01-02 15:04:05")
-							vipExist = true
-						} else if (time.Now().Unix() < bigEnd && memberStatus > 0) || bigStart >= time.Now().Unix() {
-							vipExist = true
-							endTime = time.Unix(bigEnd, 0).Format("2006-01-02 15:04:05")
-						}
-						if (subStatus == 0 && memberStatus < 0 && mainId != "") || (subStatus == 1 && memberStatus > 0 && mainId != "") {
-							vipExist = true
-						}
-						userServer, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT s_serviceid,s_smainid,l_endtime,l_starttime FROM bigmember_service_user WHERE s_userid = '%s' and i_status =0`, userId))
-						if !userServer.IsEmpty() {
-							vipExist = true
-							serMap := make(map[int]bool)
-							count, _ := g.DB().GetCount(ctx, fmt.Sprintf(`SELECT *  FROM bigmember_service_user WHERE s_userid = '%s' and i_status =0 and (s_serviceid=4 or s_serviceid =19)`, userId))
-							isHUa := count > 0
-							for _, v := range userServer.List() {
-								if isHUa && v["s_serviceid"] == 26 {
-									continue
-								}
-								var serviceId int
-								if common.IntAll(v["s_smainid"]) == 0 {
-									if common.IntAll(v["s_serviceid"]) == 12 {
-										serviceId = 23
-									} else {
-										serviceId = common.IntAll(v["s_serviceid"])
-									}
+							var serviceId int
+							if common.IntAll(v["s_smainid"]) == 0 {
+								if common.IntAll(v["s_serviceid"]) == 12 {
+									serviceId = 23
 								} else {
-									if common.IntAll(v["s_smainid"]) == 12 {
-										serviceId = 23
-									} else {
-										serviceId = common.IntAll(v["s_smainid"])
-									}
+									serviceId = common.IntAll(v["s_serviceid"])
 								}
-								if !serMap[serviceId] {
-									serviceList = append(serviceList, serviceId)
-									serMap[serviceId] = true
+							} else {
+								if common.IntAll(v["s_smainid"]) == 12 {
+									serviceId = 23
+								} else {
+									serviceId = common.IntAll(v["s_smainid"])
 								}
 							}
+							if !serMap[serviceId] {
+								serviceList = append(serviceList, serviceId)
+								serMap[serviceId] = true
+							}
 						}
-						if vipExist {
-							paySubNum = common.IntAll((*userData)["i_pay_sub_num"]) + common.IntAll((*userData)["i_free_sub_num"]) + 1
-						}
-						var productCode string
-						itemMap, _ := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT code FROM jy_product_item WHERE JSON_EXTRACT(price, '$.comboId') = %d;`, comboId))
-						if !itemMap.IsEmpty() {
-							productCode = gconv.String(itemMap.Map()["code"])
-						}
-						serviceArrMap = append(serviceArrMap, map[string]interface{}{
-							"vipExist":         vipExist,          //当前服务是否在有限期内
-							"name":             param.ProductType, //产品名称
-							"productCode":      productCode,       //产品code
-							"serviceEndTime":   endTime,           //服务结束时间
-							"serviceStartTime": startTime,         //服务开始时间
-							"empowerCount":     paySubNum,         //服务授权数
-							"provinceCount":    areaCount,         //订阅省份
-							"buySubject":       1,                 //个体
-							"comboId":          comboId,           //套餐id
-							"serviceList":      serviceList,       //大会员服务id
-							"linkedId":         linkedId,          //关联id
-							"linkedOrder":      orderArr,          //关联订单
-						})
 					}
-				}
-			}
-		} else { //企业版本会员状态查询
-			if param.EntName == "" {
-				return nil, errors.New("企业名称获取异常")
-			}
-			//获取企业信息
-			if param.ProductType == "大会员" {
-				vipRes1, _ := g.DB().Ctx(ctx).GetOne(ctx, fmt.Sprintf(`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 = '%s'  AND phone = '%s' ORDER BY ewe.create_time DESC LIMIT 1`, param.EntName, param.Phone))
-				if !vipRes1.IsEmpty() {
-					start := common.ObjToString(vipRes1.Map()["start_time"])
-					end := common.ObjToString(vipRes1.Map()["end_time"])
-					starts, _ := time.ParseInLocation(date.Date_Full_Layout, start, time.Local)
-					ends, _ := time.ParseInLocation(date.Date_Full_Layout, end, time.Local)
-					bigStart := starts.Unix()
-					bigEnd := ends.Unix()
-					nowTime := time.Now().Unix()
-					if nowTime < bigEnd && nowTime < bigStart {
-						return map[string]interface{}{
-							"willEffect":    true,
-							"userData":      userData,
-							"serviceArrMap": nil,
-						}, nil
+					if vipExist {
+						paySubNum = common.IntAll((*userData)["i_pay_sub_num"]) + common.IntAll((*userData)["i_free_sub_num"]) + 1
 					}
-				}
-			}
-
-			vipRes, _ := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT a.id,b.id as entUserId FROM entniche_info a
-inner JOIN entniche_user b on a.id = b.ent_id
-WHERE b.phone = '%s' and a.name = '%s'`, param.Phone, param.EntName))
-			if !vipRes.IsEmpty() {
-				if param.ProductType != "大会员" && param.ProductType != "VIP订阅" {
-					serviceArrMap = SpecialService(ctx, gconv.String(vipRes.Map()["entUserId"]), param.ProductType)
+					var productCode string
+					itemMap, _ := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT code FROM jy_product_item WHERE JSON_EXTRACT(price, '$.comboId') = %d;`, comboId))
+					if !itemMap.IsEmpty() {
+						productCode = gconv.String(itemMap.Map()["code"])
+					}
+					serviceArrMap = append(serviceArrMap, map[string]interface{}{
+						"vipExist":         vipExist,          //当前服务是否在有限期内
+						"name":             param.ProductType, //产品名称
+						"productCode":      productCode,       //产品code
+						"serviceEndTime":   endTime,           //服务结束时间
+						"serviceStartTime": startTime,         //服务开始时间
+						"empowerCount":     paySubNum,         //服务授权数
+						"provinceCount":    areaCount,         //订阅省份
+						"buySubject":       1,                 //个体
+						"comboId":          comboId,           //套餐id
+						"serviceList":      serviceList,       //大会员服务id
+						"linkedId":         linkedId,          //关联id
+						"linkedOrder":      orderArr,          //关联订单
+					})
 				} else {
-					entID := gconv.String(vipRes.Map()["id"])
-					var whereEntTime, productCode string
-					if param.ServiceType != 1 && param.ServiceType != 4 {
-						whereEntTime = fmt.Sprintf(` and a.end_time>'%s' `, time.Now().Format("2006-01-02 15:04:05"))
+					if !entRec.IsEmpty() {
+						serviceArrMap = append(serviceArrMap, userEntService(ctx, gconv.String(entRec.Map()["id"]), whereEntTime, "%大会员%"))
 					}
-					//获取企业下的服务
-					entService, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT * FROM entniche_wait_empower a 
-WHERE a.ent_id = '%s'  %s and a.product_type like '%s'  ORDER BY a.end_time desc`, entID, whereEntTime, common.If(param.ProductType == "VIP订阅", "%VIP订阅%", `%大会员%`)))
-					if !entService.IsEmpty() {
-						for _, m := range entService.List() {
-							var (
-								serviceList []int
-								comboId     int
-							)
-
-							if param.ProductType == "大会员" {
-								//大会员获取下服务最新id
-								serviceId, _ := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT  b.filter FROM entniche_order a 
-	INNER JOIN  jy_order_detail b on a.order_detail_id = b.id WHERE a.wait_empower_id = %d ORDER BY a.create_time desc LIMIT 1`, gconv.Int(m["id"])))
-								if !serviceId.IsEmpty() {
-									comboId = gconv.Int(gconv.Map(serviceId.Map()["filter"])["comboId"])
-									itemMap, _ := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT code FROM jy_product_item WHERE JSON_EXTRACT(price, '$.comboId') = %d;`, comboId))
-									if !itemMap.IsEmpty() {
-										productCode = gconv.String(itemMap.Map()["code"])
-									}
-									for _, id := range gconv.Ints(gconv.Map(serviceId.Map()["filter"])["serviceIds"]) {
-										if id == 12 {
-											serviceList = append(serviceList, 23)
-										} else if id == 19 {
-											serviceList = append(serviceList, 4)
-										} else {
-											serviceList = append(serviceList, id)
-										}
-									}
-								}
-							} else {
-								productCode = fmt.Sprintf("cjdy%03d", gconv.Int(common.If(gconv.Int(m["province_count"]) > 15 || gconv.Int(m["province_count"]) == -1, 16, gconv.Int(m["province_count"]))))
-							}
-							vipExist = jyutil.StrToTime(gconv.String(m["end_time"])).Unix() > time.Now().Unix()
-							var (
-								orderArr []map[string]interface{}
-								linkedId int
-							)
-							//获取订单
-							entOrderService, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT  b.id,b.service_type,b.order_code,c.create_time FROM entniche_order a 
-	INNER JOIN  jy_order_detail b on a.order_detail_id = b.id
-	LEFT JOIN dataexport_order c on b.order_code = c.order_code WHERE a.wait_empower_id = %d order by b.id desc`, gconv.Int(m["id"])))
-							if !entOrderService.IsEmpty() {
-								for _, m2 := range entOrderService.List() {
-									if linkedId == 0 {
-										linkedId = gconv.Int(m2["id"])
-									}
-									orderArr = append(orderArr, map[string]interface{}{
-										"order_code":      m2["order_code"],
-										"create_time":     m2["create_time"],
-										"service_type":    m2["service_type"],
-										"order_detail_id": m2["id"],
-									})
-								}
+				}
+			case "VIP订阅":
+				var (
+					serviceList                    []int
+					endTime, startTime             string
+					paySubNum, areaCount, linkedId int
+					orderArr                       []map[string]interface{}
+				)
+				if param.BuySubject == "1" {
+					var (
+						newVip, nationwide bool
+					)
+					orderData, _ := g.DB().Query(ctx, `SELECT   a.id,a.service_type,a.order_code,b.create_time   FROM jy_order_detail  a
+INNER JOIN dataexport_order b on a.order_code = b.order_code
+WHERE a.status = 1 and b.user_phone = ? and a.product_type like '%VIP订阅%' ORDER BY b.create_time desc `, param.Phone)
+					if !orderData.IsEmpty() {
+						for _, m2 := range orderData.List() {
+							if linkedId == 0 {
+								linkedId = gconv.Int(m2["id"])
 							}
-
-							serviceArrMap = append(serviceArrMap, map[string]interface{}{
-								"name":             gconv.String(m["product_type"]),  //产品名称
-								"productCode":      productCode,                      //产品code
-								"vipExist":         vipExist,                         //当前服务是否在有限期内
-								"serviceEndTime":   gconv.String(m["end_time"]),      //服务结束时间
-								"serviceStartTime": gconv.String(m["start_time"]),    //服务开始时间
-								"empowerCount":     gconv.String(m["empower_count"]), //服务授权数
-								"provinceCount":    gconv.Int(m["province_count"]),   //订阅省份
-								"buySubject":       2,                                //个体
-								"linkedId":         linkedId,                         //关联id
-								"comboId":          comboId,                          //套餐id
-								"serviceList":      serviceList,                      //大会员服务id
-								"linkedOrder":      orderArr,                         //关联订单
+							orderArr = append(orderArr, map[string]interface{}{
+								"order_code":      m2["order_code"],
+								"create_time":     m2["create_time"],
+								"service_type":    m2["service_type"],
+								"order_detail_id": m2["id"],
 							})
 						}
 					}
+					vipExist = gconv.Int((*userData)["i_vip_status"]) == 2
+					if vipExist {
+						paySubNum = 1
+						vipInfo := common.ObjToMap((*userData)["o_vipjy"])
+						buySet := common.ObjToMap((*vipInfo)["o_buyset"])
+						areaCount = common.IntAll((*buySet)["areacount"])
+						//判断是新版超级订阅还是老版超级订阅
+						if common.IntAll((*buySet)["upgrade"]) == 1 {
+							newVip = true
+						}
+
+						if areaCount == -1 {
+							nationwide = true
+						}
+						endTime = time.Unix(common.Int64All((*userData)["l_vip_endtime"]), 0).Format("2006-01-02 15:04:05")
+					}
+					productCode := fmt.Sprintf("cjdy%03d", gconv.Int(common.If(areaCount > 15 || areaCount == -1, 16, areaCount)))
+					serviceArrMap = append(serviceArrMap, map[string]interface{}{
+						"vipExist":         vipExist, //当前服务是否在有限期内
+						"nationwide":       nationwide,
+						"name":             param.ProductType, //产品名称
+						"serviceEndTime":   endTime,           //服务结束时间
+						"serviceStartTime": startTime,         //服务开始时间
+						"productCode":      productCode,
+						"newVip":           newVip,
+						"empowerCount":     paySubNum,   //服务授权数
+						"provinceCount":    areaCount,   //订阅省份
+						"buySubject":       1,           //个体
+						"serviceList":      serviceList, //大会员服务id
+						"linkedId":         linkedId,    //关联id
+						"linkedOrder":      orderArr,    //关联订单
+					})
+				} else {
+					if !entRec.IsEmpty() {
+						serviceArrMap = append(serviceArrMap, userEntService(ctx, gconv.String(entRec.Map()["id"]), whereEntTime, "%VIP订阅%"))
+					}
 				}
+			default:
+				serviceArrMap = append(serviceArrMap, SpecialService(ctx, whereSql, gconv.String(m["product_type"]), gconv.Int(param.BuySubject)))
 			}
 		}
 	}
@@ -322,7 +261,87 @@ WHERE a.ent_id = '%s'  %s and a.product_type like '%s'  ORDER BY a.end_time desc
 	}, nil
 }
 
-func SpecialService(ctx context.Context, userId, productType string) []map[string]interface{} {
+func userEntService(ctx context.Context, entID string, whereEntTime, productType string) map[string]interface{} {
+	//获取企业下的服务
+	var (
+		productCode string
+		vipExist    bool
+	)
+	entService, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT * FROM entniche_wait_empower a 
+WHERE a.ent_id = '%s'  %s and a.product_type like '%s'  ORDER BY a.end_time desc`, entID, whereEntTime, productType))
+	if !entService.IsEmpty() {
+		for _, m := range entService.List() {
+			var (
+				serviceList []int
+				comboId     int
+			)
+			switch {
+			case strings.Contains(productType, "大会员"):
+				//大会员获取下服务最新id
+				serviceId, _ := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT  b.filter FROM entniche_order a 
+	INNER JOIN  jy_order_detail b on a.order_detail_id = b.id WHERE a.wait_empower_id = %d ORDER BY a.create_time desc LIMIT 1`, gconv.Int(m["id"])))
+				if !serviceId.IsEmpty() {
+					comboId = gconv.Int(gconv.Map(serviceId.Map()["filter"])["comboId"])
+					itemMap, _ := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT code FROM jy_product_item WHERE JSON_EXTRACT(price, '$.comboId') = %d;`, comboId))
+					if !itemMap.IsEmpty() {
+						productCode = gconv.String(itemMap.Map()["code"])
+					}
+					for _, id := range gconv.Ints(gconv.Map(serviceId.Map()["filter"])["serviceIds"]) {
+						if id == 12 {
+							serviceList = append(serviceList, 23)
+						} else if id == 19 {
+							serviceList = append(serviceList, 4)
+						} else {
+							serviceList = append(serviceList, id)
+						}
+					}
+				}
+			case strings.Contains(productType, "订阅"):
+				productCode = fmt.Sprintf("cjdy%03d", gconv.Int(common.If(gconv.Int(m["province_count"]) > 15 || gconv.Int(m["province_count"]) == -1, 16, gconv.Int(m["province_count"]))))
+			}
+			vipExist = jyutil.StrToTime(gconv.String(m["end_time"])).Unix() > time.Now().Unix()
+			var (
+				orderArr []map[string]interface{}
+				linkedId int
+			)
+			//获取订单
+			entOrderService, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT  b.id,b.service_type,b.order_code,c.create_time FROM entniche_order a 
+	INNER JOIN  jy_order_detail b on a.order_detail_id = b.id
+	LEFT JOIN dataexport_order c on b.order_code = c.order_code WHERE a.wait_empower_id = %d order by b.id desc`, gconv.Int(m["id"])))
+			if !entOrderService.IsEmpty() {
+				for _, m2 := range entOrderService.List() {
+					if linkedId == 0 {
+						linkedId = gconv.Int(m2["id"])
+					}
+					orderArr = append(orderArr, map[string]interface{}{
+						"order_code":      m2["order_code"],
+						"create_time":     m2["create_time"],
+						"service_type":    m2["service_type"],
+						"order_detail_id": m2["id"],
+					})
+				}
+			}
+
+			return map[string]interface{}{
+				"name":             gconv.String(m["product_type"]),  //产品名称
+				"productCode":      productCode,                      //产品code
+				"vipExist":         vipExist,                         //当前服务是否在有限期内
+				"serviceEndTime":   gconv.String(m["end_time"]),      //服务结束时间
+				"serviceStartTime": gconv.String(m["start_time"]),    //服务开始时间
+				"empowerCount":     gconv.String(m["empower_count"]), //服务授权数
+				"provinceCount":    gconv.Int(m["province_count"]),   //订阅省份
+				"buySubject":       2,                                //个体
+				"linkedId":         linkedId,                         //关联id
+				"comboId":          comboId,                          //套餐id
+				"serviceList":      serviceList,                      //大会员服务id
+				"linkedOrder":      orderArr,                         //关联订单
+			}
+		}
+	}
+	return nil
+}
+
+func SpecialService(ctx context.Context, phone, productType string, buySubject int) map[string]interface{} {
 	var (
 		linkedId           int
 		orderArr           []map[string]interface{}
@@ -345,7 +364,7 @@ func SpecialService(ctx context.Context, userId, productType string) []map[strin
 
 	orderData, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT jod.service_endtime,jod.id,jod.service_starttime,jod.service_type,jod.order_code,dor.create_time FROM dataexport_order dor 
 INNER JOIN jy_order_detail jod on dor.order_code = jod.order_code 
-WHERE dor.user_id = '%s' and jod.product_type = '%s'  ORDER BY dor.create_time desc `, userId, productType))
+WHERE %s and %s ORDER BY dor.create_time desc `, phone, productType))
 	if !orderData.IsEmpty() {
 		for _, m2 := range orderData.List() {
 			if linkedId == 0 {
@@ -367,16 +386,16 @@ WHERE dor.user_id = '%s' and jod.product_type = '%s'  ORDER BY dor.create_time d
 				"order_detail_id": m2["id"],
 			})
 		}
-		return []map[string]interface{}{{
-			"name":             fmt.Sprintf("%s标准版", productType),              //产品名称
-			"vipExist":         vipExist,                                       //当前服务是否在有限期内
-			"serviceEndTime":   common.If(endTime != "", endTime, "-"),         //服务结束时间
-			"serviceStartTime": startTime,                                      //服务开始时间
-			"buySubject":       common.If(mongodb.IsObjectIdHex(userId), 1, 2), //个体
-			"empowerCount":     common.If(productType == "数据流量包", "1", "-"),    //B.产品属性为“资源包”,则为“1”; C.产品属性非“会员服务”且非“资源包”,则展示-
-			"linkedId":         linkedId,                                       //关联id
-			"linkedOrder":      orderArr,                                       //关联订单
-		}}
+		return map[string]interface{}{
+			"name":             fmt.Sprintf("%s标准版", productType),           //产品名称
+			"vipExist":         vipExist,                                    //当前服务是否在有限期内
+			"serviceEndTime":   common.If(endTime != "", endTime, "-"),      //服务结束时间
+			"serviceStartTime": startTime,                                   //服务开始时间
+			"buySubject":       buySubject,                                  //个体
+			"empowerCount":     common.If(productType == "数据流量包", "1", "-"), //B.产品属性为“资源包”,则为“1”; C.产品属性非“会员服务”且非“资源包”,则展示-
+			"linkedId":         linkedId,                                    //关联id
+			"linkedOrder":      orderArr,                                    //关联订单
+		}
 	}
 	return nil
 }

+ 95 - 0
internal/logic/user/getServiceNew.go

@@ -0,0 +1,95 @@
+package user
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	"context"
+	"fmt"
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/util/gconv"
+	"jyOrderManager/internal/jyutil"
+	"jyOrderManager/internal/model"
+	"time"
+)
+
+func GetUserServiceNew(ctx context.Context, param model.UserServiceParams) (interface{}, error) {
+	switch param.BuySubject {
+	case "1":
+		//手机号是否注册
+		userData, _ := jyutil.MG.DB().FindOne("user", map[string]interface{}{
+			"$or": []map[string]interface{}{
+				{"s_phone": param.Phone},
+				{"s_m_phone": param.Phone},
+			},
+		})
+		if userData == nil || len(*userData) == 0 {
+			return map[string]interface{}{
+				"willEffect": false,
+				//"userData":      userData,
+				"serviceArrMap": nil,
+			}, nil
+		}
+		//大会员
+		var (
+			memberExist, vipExist bool
+		)
+		memberStartTime := common.Int64All((*userData)["i_member_starttime"])
+		memberEndTime := common.Int64All((*userData)["i_member_endtime"])
+		memberSubStatus := common.IntAll((*userData)["i_member_sub_status"])
+		memberStatus := common.IntAll((*userData)["i_member_status"])
+		mainId := common.ObjToString((*userData)["s_member_mainid"])
+		if memberStartTime >= time.Now().Unix() {
+			memberExist = true
+		} else if (time.Now().Unix() < memberEndTime && memberStatus > 0) || memberStartTime >= time.Now().Unix() {
+			memberExist = true
+		}
+		if (memberSubStatus == 0 && memberStatus < 0 && mainId != "") || (memberSubStatus == 1 && memberStatus > 0 && mainId != "") {
+			memberExist = true
+		}
+
+		//超级订阅
+		var (
+			newVip, nationwide bool
+			areaCount          int
+		)
+		vipExist = gconv.Int((*userData)["i_vip_status"]) == 2
+		if vipExist {
+			vipInfo := common.ObjToMap((*userData)["o_vipjy"])
+			buySet := common.ObjToMap((*vipInfo)["o_buyset"])
+			areaCount = common.IntAll((*buySet)["areacount"])
+			//判断是新版超级订阅还是老版超级订阅
+			if common.IntAll((*buySet)["upgrade"]) == 1 {
+				newVip = true
+			}
+
+			if areaCount == -1 {
+				nationwide = true
+			}
+		}
+		return map[string]interface{}{
+			"memberExist":     memberExist,
+			"memberStartTime": memberStartTime,
+			"memberEndTime":   memberEndTime,
+			"vipExist":        vipExist,
+			"newVip":          newVip,
+			"nationwide":      nationwide,
+			"vipEndTime":      (*userData)["l_vip_endtime"],
+			"vipStartTime":    (*userData)["l_vip_starttime"],
+		}, nil
+	case "2":
+		entRec, _ := g.DB().GetOne(ctx, fmt.Sprintf(`SELECT a.id,b.id as entUserId FROM entniche_info a
+inner JOIN entniche_user b on a.id = b.ent_id
+WHERE b.phone = '%s' and a.name = '%s'`, param.Phone, param.EntName))
+		if !entRec.IsEmpty() {
+			bigService, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT * FROM entniche_wait_empower a 
+WHERE a.ent_id = '%s'  %s and a.product_type like '%s' and a.end_time>'%s'   ORDER BY a.end_time desc`, entRec.Map()["id"], "%大会员%", time.Now().Format("2006-01-02 15:04:05")))
+			vipService, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT * FROM entniche_wait_empower a 
+WHERE a.ent_id = '%s'  %s and a.product_type like '%s' and a.end_time>'%s'   ORDER BY a.end_time desc`, entRec.Map()["id"], "%大会员%", time.Now().Format("2006-01-02 15:04:05")))
+			return map[string]interface{}{
+				"memberExist": bigService.Len() > 0,
+				"vipExist":    vipService.Len() > 0,
+			}, nil
+		}
+
+	}
+	return nil, nil
+}

+ 0 - 1
internal/model/orderParams.go

@@ -184,7 +184,6 @@ type (
 	RedPunch struct {
 		Id         int64  `json:"id"`
 		ActiveCode string `json:"activeCode"`
-		OrderMoney int    `json:"orderMoney"`
 		PayMoney   int    `json:"payMoney"` //支付金额
 		//BigSubMoney      int    `json:"bigSubMoney"` //大会员子账号金额
 		//SupplyMoney      int    `json:"supplyMoney"` //补充包金额