Browse Source

fix:提交

duxin 4 months ago
parent
commit
8f3b12a3bb

+ 1 - 1
internal/jyutil/equityOpen.go

@@ -79,7 +79,7 @@ func EntLicense(ctx context.Context, entId, empowerCount, provinceCount, orderId
 		}
 		var pid int64
 		user, _ := g.DB().Ctx(ctx).GetOne(ctx, fmt.Sprintf(`SELECT * FROM entniche_order WHERE phone = '%s' and ent_id = '%s'`, phone, entId))
-		data, _ := g.DB().Ctx(ctx).GetOne(ctx, fmt.Sprintf(`SELECT id,empower_count FROM entniche_wait_empower WHERE product_type = '%d' and ent_id = '%s' and province_count =%d`, productType, entId, provinceCount))
+		data, _ := g.DB().Ctx(ctx).GetOne(ctx, fmt.Sprintf(`SELECT id,empower_count FROM entniche_wait_empower WHERE product_type = '%s' and ent_id = '%d' and province_count =%d`, productType, entId, provinceCount))
 		t := date.NowFormat(date.Date_Full_Layout)
 		if !data.IsEmpty() {
 			empower_count := gconv.Int(data.Map()["empower_count"])

+ 18 - 26
internal/logic/product/bigmember/BigMemberBuyTry.go

@@ -18,9 +18,8 @@ import (
 )
 
 func (p jyBigProduct) NewBigOpenService(ctx context.Context, startDate, endDate time.Time, buyCount, buySubject, entId int, pid int64) error {
-	ok := false
 	sets := map[string]interface{}{
-		"i_member_status":      common.If(startDate.Unix() <= time.Now().Unix(), p.param.ComboId, -p.param.ComboId),
+		"i_member_status":      common.If(startDate.Unix() <= time.Now().Unix(), p.param.Filter.ComboId, -p.param.Filter.ComboId),
 		"i_member_starttime":   startDate.Unix(),
 		"i_member_endtime":     endDate.Unix(),
 		"i_mainaccount":        1,
@@ -29,7 +28,7 @@ func (p jyBigProduct) NewBigOpenService(ctx context.Context, startDate, endDate
 	// p238 大会员省份版-商机版2.0单省版 可订阅省份数量为1个
 	var unset map[string]interface{}
 	//if common.IntAll(filterMap["areaCount"]) > 0 { // 省份版
-	if p.param.ComboId == 30190 { // 省份版
+	if p.param.Filter.ComboId == 30190 { // 省份版
 		sets["o_member_jy.i_areacount"] = 1
 		sets["o_member_jy.o_area"] = map[string]interface{}{
 			"北京": []interface{}{},
@@ -51,12 +50,8 @@ func (p jyBigProduct) NewBigOpenService(ctx context.Context, startDate, endDate
 	if unset != nil {
 		set["$unset"] = unset
 	}
-	if buySubject != 2 {
-		ok = jyutil.MG.DB().UpdateById("user", p.param.UserId, set)
-	} else {
-		ok = UpdateRule(ctx, entId, set, p.param.Phone)
-	}
-	if !ok {
+
+	if !jyutil.Compatible.UpdateByEntUserId(p.param.UserId, set) {
 		return errors.New("开通权益--大会员创建订单user表大会员状态更新失败")
 	}
 
@@ -84,24 +79,24 @@ func (p jyBigProduct) NewBigOpenService(ctx context.Context, startDate, endDate
 			}
 		}
 	}
-	p.UserEquityDistribution(ctx, startDate, endDate, entId, pid, true)
+	p.UserPdfDistribution(ctx, endDate, entId, buySubject, pid)
+	p.UserEquityDistribution(ctx, startDate, endDate)
 
 	//ClearBigVipUserPower(userId)
 	return nil
 }
 
-func (p jyBigProduct) BigMemberBuyTry(ctx context.Context, orderData map[string]interface{}, productDetail model.JyProductDetail) error {
+func (p jyBigProduct) BigMemberBuyTry(ctx context.Context, orderData, userData map[string]interface{}, productDetail model.JyBigParams) error {
 	var (
 		entService int
 		userCount  int
 	)
-	var bigFilter model.BigMember
 	bigStartTime, bigEndTime := utility.GetStartAndEndTime(time.Now(), utility.DateComp{
-		Num:  p.param.PayCycle,
-		Unit: p.param.PayCycleType,
+		Num:  p.param.Filter.BuyCycle,
+		Unit: p.param.Filter.BuyType,
 	}, utility.DateComp{
-		Num:  p.param.GifCycle,
-		Unit: p.param.GifCycleType,
+		Num:  p.param.Filter.GiftCycle,
+		Unit: p.param.Filter.GiftType,
 	})
 	if bigEndTime.Unix() < time.Now().Unix() {
 		log.Println("bigEndTime > time.now 订单已失效", bigEndTime)
@@ -113,38 +108,35 @@ func (p jyBigProduct) BigMemberBuyTry(ctx context.Context, orderData map[string]
 		pid   int64
 	)
 
-	bigFilter.ServersId = strings.Join(p.param.ServersId, ",")
-	bigFilter.Cycle = p.param.PayCycle
-	bigFilter.CycleType = p.param.PayCycleType
 	productDetail.ServiceStartTime = bigStartTime
 	productDetail.ServiceEndTime = bigEndTime
 	// 企业主体判断是否开通权益
 	if gconv.Int(orderData["buy_subject"]) == 2 {
-		fmt.Println("企业参数", gconv.String(orderData["company_name"]), p.param.Phone, p.param.OrderCode, 1, p.param.UserId)
+		fmt.Println("企业参数", gconv.String(orderData["company_name"]), p.param.Phone, p.param.OrderCode, 1, userData["userPositionId"])
 
 		var (
 			comboName = "自定义"
 		)
 		//获取套餐名称
-		if p.param.ComboId != 0 && p.param.ComboId != 5 {
-			comboData, err := g.DB().Ctx(ctx).GetOne(ctx, fmt.Sprintf(`SELECT s_name,s_servers FROM bigmember_combo WHERE id=%d`, p.param.ComboId))
+		if p.param.Filter.ComboId != 0 && p.param.Filter.ComboId != 5 {
+			comboData, err := g.DB().Ctx(ctx).GetOne(ctx, fmt.Sprintf(`SELECT s_name,s_servers FROM bigmember_combo WHERE id=%d`, p.param.Filter.ComboId))
 			if err != nil || comboData.IsEmpty() {
 				return errors.New("套餐id失效")
 			}
 			comboName = gconv.String(comboData.Map()["s_name"])
-			p.param.ServersId = strings.Split(gconv.String(comboData.Map()["s_servers"]), ",")
+			p.param.Filter.ServiceIds = strings.Split(gconv.String(comboData.Map()["s_servers"]), ",")
 		}
 		entService, userCount = jyutil.EntServiceOpen(entId, p.param.Phone)
 		//orderId := p.param.OrderCode
 		st := date.FormatDate(&bigStartTime, date.Date_Full_Layout)
 		et := date.FormatDate(&bigEndTime, date.Date_Full_Layout)
-		err, pid = jyutil.EntLicense(ctx, entId, p.param.PAccountNumber, -1, p.param.Id, userCount, fmt.Sprintf("%s%s", "大会员", comboName), st, et, p.param.Phone)
+		err, pid = jyutil.EntLicense(ctx, entId, p.param.Filter.FinalAccountCount, -1, p.param.Id, userCount, fmt.Sprintf("%s%s", "大会员", comboName), st, et, p.param.Phone)
 		if err != nil {
 			log.Printf("EntLicense 创建企业授权信息失败:code:%s,err:%s", p.param.OrderCode, err.Error())
 		}
 		switch entService {
 		case 2:
-			p.UserEquityDistribution(ctx, bigStartTime, bigEndTime, entId, pid, false)
+			p.UserPdfDistribution(ctx, bigEndTime, entId, 2, pid)
 			//TODO ClearBigVipUserPower(userId)
 			return nil
 		case 0:
@@ -155,7 +147,7 @@ func (p jyBigProduct) BigMemberBuyTry(ctx context.Context, orderData map[string]
 
 	if entService == 1 || gconv.Int(orderData["buy_subject"]) == 1 {
 		//sendingTime = bigStartTime.Unix()
-		err = p.NewBigOpenService(ctx, bigStartTime, bigEndTime, p.param.PAccountNumber, gconv.Int(orderData["buy_subject"]), entId, pid)
+		err = p.NewBigOpenService(ctx, bigStartTime, bigEndTime, p.param.Filter.FinalAccountCount, gconv.Int(orderData["buy_subject"]), entId, pid)
 		if err != nil {
 			return err
 		}

+ 16 - 15
internal/logic/product/bigmember/BigMemberRenew.go

@@ -25,7 +25,7 @@ func (p jyBigProduct) BigMemberExtend(ctx context.Context, startTime, endTime ti
 		setMap["i_member_endtime"] = effectiveDate.Unix()
 	} else {
 		setMap = map[string]interface{}{
-			"i_member_endtime":   endTime.Unix(),
+			"i_member_endtime":   effectiveDate.Unix(),
 			"i_member_starttime": startTime.Unix(),
 			"i_member_status":    -bigMemberStatus,
 		}
@@ -42,9 +42,9 @@ func (p jyBigProduct) BigMemberExtend(ctx context.Context, startTime, endTime ti
 	if !ok {
 		return errors.New("大会员创建订单user表大会员状态更新失败")
 	}
-	err := p.UserEquityDistribution(ctx, startTime, effectiveDate, 0, 0, true)
+	p.UserPdfDistribution(ctx, effectiveDate, 0, 1, 0)
+	err := p.UserEquityDistribution(ctx, startTime, effectiveDate)
 	return err
-
 }
 
 // BigEntMemberExtend ent大会员延长服务
@@ -53,6 +53,7 @@ func (p jyBigProduct) BigEntMemberExtend(ctx context.Context, waitEmpowerId int,
 	var (
 		errUserid, entUserId []string
 	)
+	p.UserPdfDistribution(ctx, startTime, 0, 1, 0)
 	for _, data := range EntEquityUser(ctx, waitEmpowerId) {
 		if jyutil.Compatible.UpdateByEntUserId(gconv.String(data["eUerId"]), map[string]interface{}{"$set": map[string]interface{}{
 			"i_entid":            gconv.Int(data["ent_id"]),
@@ -85,8 +86,8 @@ func (p jyBigProduct) BigEntMemberExtend(ctx context.Context, waitEmpowerId int,
 
 }
 
-func (p jyBigProduct) BigMemberRenew(ctx context.Context, userData map[string]interface{}, productDetail model.JyProductDetail) error {
-	switch p.param.BuySubject {
+func (p jyBigProduct) BigMemberRenew(ctx context.Context, orderData, userData map[string]interface{}, productDetail model.JyBigParams) error {
+	switch gconv.String(orderData["buy_subject"]) {
 	case "1":
 		updateOrder := make(map[string]interface{})
 		bigEndTime := common.Int64All(userData["i_member_endtime"])
@@ -100,14 +101,14 @@ func (p jyBigProduct) BigMemberRenew(ctx context.Context, userData map[string]in
 		}
 		//sendingTime := newStartTime.Unix()
 		newStartTime, newEndTime = utility.GetStartAndEndTime(newEndTime, utility.DateComp{
-			Num:  p.param.PayCycle,
-			Unit: p.param.PayCycleType,
+			Num:  p.param.Filter.BuyCycle,
+			Unit: p.param.Filter.BuyType,
 		}, utility.DateComp{
-			Num:  p.param.GifCycle,
-			Unit: p.param.GifCycleType,
+			Num:  p.param.Filter.GiftCycle,
+			Unit: p.param.Filter.GiftType,
 		})
 		productDetail.ServiceStartTime, productDetail.ServiceEndTime = newStartTime, newEndTime
-		//newEndTime = jyutil.GetDATE(p.param.PayCycle, p.param.PayCycleType, newStartTime.Unix())
+		//newEndTime = jyutil.GetDATE(p.param.Filter.BuyCycle, p.param.Filter.BuyType, newStartTime.Unix())
 		updateOrder["service_starttime"] = newStartTime.Format(date.Date_Full_Layout)
 		updateOrder["service_endtime"] = newEndTime.Format(date.Date_Full_Layout)
 		return p.BigMemberExtend(ctx, newStartTime, newEndTime, common.IntAll(userData["i_member_status"]))
@@ -119,7 +120,7 @@ func (p jyBigProduct) BigMemberRenew(ctx context.Context, userData map[string]in
 		data, _ := g.DB().Ctx(ctx).GetOne(ctx, fmt.Sprintf(`SELECT c.id as waitEmpowerId,c.start_time as sTime,c.end_time as eTime from jy_datareport_order a 
 INNER JOIN entniche_order b on a.id = b.order_id
 INNER JOIN entniche_wait_empower c on b.wait_empower_id=c.id
-where a.id = %s  `, p.param.LinkedOrderId))
+where a.id = %d  `, p.param.LinkedOrderId))
 		if !data.IsEmpty() {
 			eTime := gconv.Time(data.Map()["eTime"], time.DateTime)
 			if eTime.Unix() > time.Now().Unix() {
@@ -135,11 +136,11 @@ where a.id = %s  `, p.param.LinkedOrderId))
 			return errors.New("套餐id获取失败")
 		}
 		_, newEndTime = utility.GetStartAndEndTime(newEndTime, utility.DateComp{
-			Num:  p.param.PayCycle,
-			Unit: p.param.PayCycleType,
+			Num:  p.param.Filter.BuyCycle,
+			Unit: p.param.Filter.BuyType,
 		}, utility.DateComp{
-			Num:  p.param.GifCycle,
-			Unit: p.param.GifCycleType,
+			Num:  p.param.Filter.GiftCycle,
+			Unit: p.param.Filter.GiftType,
 		})
 		productDetail.ServiceStartTime, productDetail.ServiceEndTime = newStartTime, newEndTime
 		return p.BigEntMemberExtend(ctx, waitEmpowerId, newStartTime, newEndTime)

+ 49 - 58
internal/logic/product/bigmember/BigMemberUpgrades.go

@@ -14,76 +14,68 @@ import (
 	"time"
 )
 
-// BigEntMemberUpgrades ent大会员升级服务
-func (p jyBigProduct) BigEntMemberUpgrades(ctx context.Context, waitEmpowerId, entId int, startTime, endTime time.Time) error {
-	//关联订单明细查询
-	if p.param.PAccountNumber > 0 { //升级数量
-		upSql := fmt.Sprintf(`update bigmember_service_user set l_updatetime = '%s',empower_count = empower_count+%d  where  id =%d`, time.Now().Format(time.DateTime), p.param.PAccountNumber, waitEmpowerId)
-		log.Println("BigEntMemberUpgrades update bigmember_service_user sql:", upSql)
-		g.DB().Exec(ctx, upSql)
-
-	}
-	userId := p.param.SupServiceId
-	for _, data := range EntEquityUser(ctx, waitEmpowerId) {
-		if len(p.param.SupServiceId) > 0 { //补充服务
-			p.param.UserId = gconv.String(data["iId"])
-			p.UserEquityDistribution(ctx, startTime, endTime, entId, gconv.Int64(waitEmpowerId), true)
-		}
-	}
-	p.param.SupServiceId = userId
-	return nil
-
-}
-
-func (p jyBigProduct) BigMemberUpgrades(ctx context.Context, userData map[string]interface{}, productDetail model.JyProductDetail) error {
-	switch p.param.BuySubject {
-	case "1":
-		if gconv.Int(userData["i_member_status"]) < 0 {
-			return errors.New("服务已到期,权益开通失败")
-		}
-		//大会员补充服务
-		productDetail.ServiceStartTime = time.Now()
-		productDetail.ServiceEndTime = time.Unix(common.Int64All(userData["i_member_endtime"]), 0)
-		p.UserEquityDistribution(ctx, time.Now(), time.Unix(common.Int64All(userData["i_member_endtime"]), 0), 0, 0, true)
-	case "2":
+func (p jyBigProduct) BigMemberUpgrades(ctx context.Context, orderData, userData map[string]interface{}, productDetail model.JyBigParams) error {
+	if len(p.param.Filter.SupServiceIds) > 0 {
 		var (
-			newStartTime, newEndTime time.Time
-			waitEmpowerId, entId     int
+			waitEmpowerId, entId int
 		)
-		data, _ := g.DB().Ctx(ctx).GetOne(ctx, fmt.Sprintf(`SELECT c.id as waitEmpowerId,c.start_time as sTime,c.end_time as eTime,c.ent_id from jy_datareport_order a 
+		switch gconv.String(orderData["buy_subject"]) {
+		case "1":
+			if gconv.Int(userData["i_member_status"]) < 0 {
+				return errors.New("服务已到期,权益开通失败")
+			}
+			//大会员补充服务
+			productDetail.ServiceStartTime = time.Now()
+			productDetail.ServiceEndTime = time.Unix(common.Int64All(userData["i_member_endtime"]), 0)
+			p.UserEquityDistribution(ctx, time.Now(), time.Unix(common.Int64All(userData["i_member_endtime"]), 0))
+		case "2":
+			var (
+				newStartTime, newEndTime time.Time
+				waitEmpowerId            int
+			)
+			data, _ := g.DB().Ctx(ctx).GetOne(ctx, fmt.Sprintf(`SELECT c.id as waitEmpowerId,c.start_time as sTime,c.end_time as eTime,c.ent_id from jy_datareport_order a 
 INNER JOIN entniche_order b on a.id = b.order_id
 INNER JOIN entniche_wait_empower c on b.wait_empower_id=c.id
-where a.id = %s  `, p.param.LinkedOrderId))
-		if !data.IsEmpty() {
-			newStartTime = gconv.Time(data.Map()["eTime"], time.DateTime)
-			newEndTime = gconv.Time(data.Map()["sTime"], time.DateTime)
-			waitEmpowerId = gconv.Int(data["waitEmpowerId"])
-			entId = gconv.Int(data["ent_id"])
-		}
-		if waitEmpowerId == 0 {
-			return errors.New("套餐id获取失败")
+where a.id = %d  `, p.param.LinkedOrderId))
+			if !data.IsEmpty() {
+				newStartTime = gconv.Time(data.Map()["eTime"], time.DateTime)
+				newEndTime = gconv.Time(data.Map()["sTime"], time.DateTime)
+				waitEmpowerId = gconv.Int(data["waitEmpowerId"])
+				entId = gconv.Int(data["ent_id"])
+			}
+			if waitEmpowerId == 0 {
+				return errors.New("套餐id获取失败")
+			}
+			productDetail.ServiceStartTime = newStartTime
+			productDetail.ServiceEndTime = newEndTime
+			userId := p.param.UserId
+
+			for _, entUser := range EntEquityUser(ctx, waitEmpowerId) {
+				p.param.UserId = gconv.String(entUser["eId"])
+				p.UserEquityDistribution(ctx, newStartTime, newEndTime)
+			}
+			p.param.UserId = userId
 		}
-		productDetail.ServiceStartTime = newStartTime
-		productDetail.ServiceEndTime = newEndTime
-		p.BigEntMemberUpgrades(ctx, waitEmpowerId, entId, newStartTime, newEndTime)
+		p.UserPdfDistribution(ctx, productDetail.ServiceEndTime, entId, gconv.Int(orderData["buy_subject"]), gconv.Int64(waitEmpowerId))
 	}
+
 	return nil
 
 }
 
 // BigMemberSub 子账号
-func (p jyBigProduct) BigMemberSub(ctx context.Context, userData map[string]interface{}, productDetail model.JyProductDetail) error {
+func (p jyBigProduct) BigMemberSub(ctx context.Context, orderData, userData map[string]interface{}, productDetail model.JyBigParams) error {
 	memberStatus := common.IntAll(userData["i_member_status"])
-	if memberStatus < 0 && p.param.BuySubject == "1" {
+	if memberStatus < 0 && gconv.String(orderData["buy_subject"]) == "1" {
 		return errors.New("服务已到期,权益开通失败")
 	}
 	var buyCount int
-	switch p.param.BuySubject {
+	switch gconv.String(orderData["buy_subject"]) {
 	case "1":
 		freeSubNum := common.IntAll(userData["i_free_sub_num"])
 		bigStart := common.Int64All(userData["i_member_starttime"])
 		bigEnd := common.Int64All(userData["i_member_endtime"])
-		buyCount = p.param.PAccountNumber + gconv.Int(userData["i_pay_sub_num"])
+		buyCount = p.param.Filter.BuyAccountCount + p.param.Filter.GiftAccountCount + gconv.Int(userData["i_pay_sub_num"])
 		productDetail.ServiceStartTime = time.Now()
 		productDetail.ServiceEndTime = gconv.Time(bigStart, time.DateTime)
 		if !jyutil.MG.DB().UpdateById("user", p.param.UserId, map[string]interface{}{
@@ -113,21 +105,20 @@ func (p jyBigProduct) BigMemberSub(ctx context.Context, userData map[string]inte
 			}
 		}
 	case "2":
-		res, _ := g.DB().GetOne(ctx, fmt.Sprintf("SELECT c.end_time,c.start_time,c.province_count FROM jy_product_detail a LEFT JOIN entniche_order b on a.id = b.order_id LEFT JOIN entniche_wait_empower c ON b.wait_empower_id = c.id WHERE a.id = %s", p.param.LinkedOrderId))
+		var areaCount int
+		res, _ := g.DB().GetOne(ctx, fmt.Sprintf("SELECT c.end_time,c.start_time,c.province_count FROM jy_product_detail a LEFT JOIN entniche_order b on a.id = b.order_id LEFT JOIN entniche_wait_empower c ON b.wait_empower_id = c.id WHERE a.id = %d", p.param.LinkedOrderId))
 		if !res.IsEmpty() {
 			bs, _ := time.ParseInLocation(date.Date_Full_Layout, common.ObjToString(res.Map()["start_time"]), time.Local)
 			be, _ := time.ParseInLocation(date.Date_Full_Layout, common.ObjToString(res.Map()["end_time"]), time.Local)
 			productDetail.ServiceStartTime = bs
 			productDetail.ServiceEndTime = be
-			if common.IntAll(res.Map()["province_count"]) == -1 {
-				p.param.AreaCount = 0
-			} else {
-				p.param.AreaCount = 1
+			if common.IntAll(res.Map()["province_count"]) != -1 {
+				areaCount = 1
 			}
 		}
-		buyCount = p.param.PAccountNumber
+		buyCount = p.param.Filter.BuyAccountCount + p.param.Filter.GiftAccountCount
 		//企业版本开通
-		if err, _ := jyutil.EntLicense(ctx, gconv.Int(userData["ent_id"]), buyCount, gconv.Int(common.If(p.param.AreaCount == 0, -1, p.param.AreaCount)), p.param.Id, 0, GetBigMemberProductTypeByOrderCode(p.param.ComboId),
+		if err, _ := jyutil.EntLicense(ctx, gconv.Int(userData["ent_id"]), buyCount, gconv.Int(common.If(areaCount == 0, -1, areaCount)), p.param.Id, 0, GetBigMemberProductTypeByOrderCode(p.param.Filter.ComboId),
 			productDetail.ServiceStartTime.Format(date.Date_Full_Layout), productDetail.ServiceEndTime.Format(date.Date_Full_Layout), p.param.Phone); err != nil {
 			return err
 		}

+ 104 - 174
internal/logic/product/bigmember/bigcommon.go

@@ -8,13 +8,12 @@ import (
 	"encoding/json"
 	"errors"
 	"fmt"
+	"github.com/gogf/gf/v2/database/gdb"
 	"github.com/gogf/gf/v2/frame/g"
 	"github.com/gogf/gf/v2/util/gconv"
-	"go.mongodb.org/mongo-driver/bson"
 	"io/ioutil"
 	"jyOrderManager/internal/jyutil"
 	"jyOrderManager/internal/model"
-	"jyOrderManager/internal/service"
 	"log"
 	"net/http"
 	"net/url"
@@ -23,84 +22,42 @@ import (
 )
 
 const (
-	Buy      = iota + 1 //购买
-	Renew               //续费
-	Upgrades            //升级
-	try                 //试用
+	Buy            = iota + 1 //购买
+	Renew                     //续费
+	Upgrades                  //升级
+	try                       //试用
+	OrderDetailTab = "jy_product_detail"
 )
 
-func (p jyBigProduct) CheckParam(param model.CreateBigParams) error {
-	var ctx context.Context
-	m, err := p.GetPrice()
+// getLinkFilter 获取关联订单
+func getLinkFilter(ctx context.Context, linkOrderDetailId int64) (filter *model.JyBigProductFilter, st, et time.Time, err error) {
+	var (
+		re gdb.Record
+	)
+	re, err = g.DB().GetOne(ctx, fmt.Sprintf("SELECT filter,service_starttime,service_endtime FROM jy_product_detail WHERE id =%d", linkOrderDetailId))
 	if err != nil {
-		return errors.New("金额校验计算异常")
+		return
 	}
-	if p.param.Amount != m {
-		return errors.New("金额校验异常")
+	var (
+		dMap = re.Map()
+	)
+	if len(dMap) == 0 {
+		err = fmt.Errorf("获取关联订单异常")
+		return
 	}
-	pcls, err := service.Product().GetProduct(p.param.ProductCode)
+	err = gconv.Struct(dMap["filter"], filter)
 	if err != nil {
-		return errors.New("未知商品类型")
+		return
 	}
-	if pcls.ProductClass.Tactics != 3 && p.param.Tactics != pcls.ProductClass.Tactics {
-		return errors.New("销售策略不支持")
-	}
-
-	if param.RecordPayType == 0 {
-		return errors.New("缺少订单类型")
-	}
-	// 暂不提供手机号
-	if param.BuySubject != "2" && !strings.HasPrefix(param.Phone, "9") {
-		//个人订单校验是否存在未审核订单
-		if ExistProcessOrder(param.Phone, param.OrderCode) {
-			return errors.New("该手机号存在未审核通过的单子")
-		}
-		//个人权益是否开通
-		switch param.RecordPayType {
-		case Buy, try: //购买 试用
-			if userData, _, _, _ := jyutil.GetCreateUserData(param.Phone, "", false); userData != nil {
-				tm := time.Now().Unix()
-				if gconv.Int(userData["i_member_status"]) > 0 || gconv.Int64(userData["i_member_endtime"]) > tm {
-					return errors.New("该手机号个人权益已生效")
-				}
-			}
-		case Renew, Upgrades: //升级 续费
-			if userData, _, _, _ := jyutil.GetCreateUserData(param.Phone, "", false); userData != nil {
-				tm := time.Now().Unix()
-				if gconv.Int(userData["i_member_status"]) <= 0 || gconv.Int64(userData["i_member_endtime"]) <= tm {
-					return errors.New("该手机号个人权益已失效")
-				}
-			}
-		default:
-			return errors.New("订单类型错误")
-		}
-	}
-
-	if param.PayCycle == 0 || param.PayCycleType == 0 {
-		return errors.New("缺少周期")
-	}
-
-	if param.PayMoney == 0 && param.ZeroOrderType == "" {
-		return errors.New("0元订单缺少类型")
+	st, err = time.Parse(time.DateTime, gconv.String(dMap["service_starttime"]))
+	if err != nil {
+		return
 	}
-	if param.ComboId != 0 {
-		comboData, err := g.DB().Ctx(ctx).GetOne(ctx, fmt.Sprintf(`SELECT s_servers FROM bigmember_combo WHERE id=%d`, param.ComboId))
-		if err != nil || comboData.IsEmpty() {
-			return errors.New("套餐不存在")
-		}
-		var serviceIds []string
-		serversData, err := g.DB().Ctx(ctx).Query(ctx, fmt.Sprintf(`SELECT s_servers FROM bigmember_service WHERE id in (%s)`, gconv.String(comboData.Map()["s_servers"])))
-		if err != nil {
-			return errors.New("获取服务异常")
-		}
-		for _, m := range serversData.List() {
-			serviceIds = append(serviceIds, gconv.String(m["id"]))
-		}
-		param.ServersId = serviceIds
-	} else if param.RecordPayType != Renew && len(param.ServersId) == 0 {
-		return errors.New("服务id异常")
+	et, err = time.Parse(time.DateTime, gconv.String(dMap["service_endtime"]))
+	if err != nil {
+		return
 	}
-	return nil
+	return
 }
 
 // ExistProcessOrder 是否存在处理的订单(待一审、待二审、)
@@ -118,83 +75,39 @@ func ExistProcessOrder(phone string, orderCode string) bool {
 }
 
 // UserEquityDistribution 用户分配权益
-func (p jyBigProduct) UserEquityDistribution(ctx context.Context, startDate, endDate time.Time, entId int, pid int64, isEquity bool) error {
+func (p jyBigProduct) UserEquityDistribution(ctx context.Context, startDate, endDate time.Time) error {
 	status := common.If(startDate.Unix() <= time.Now().Unix(), 0, 1).(int)
-	buyCount := 1
 	var serviceIdArr []string
 	if p.param.RecordPayType == Upgrades {
-		if p.param.BuySubject == "2" {
-			data, _ := g.DB().Ctx(ctx).Query(ctx, fmt.Sprintf(`select * from entniche_wait_empower where id = %d`, pid))
-			if data != nil {
-				for _, m := range data.List() {
-					buyCount = common.IntAll(m["empower_count"])
-				}
-			}
-		}
-		serviceIdArr = p.param.SupServiceId
+		serviceIdArr = p.param.Filter.SupServiceIds
 	} else {
-		serviceIdArr = p.param.ServersId
+		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, ",")))
 	if !serverData.IsEmpty() {
 		for _, m := range serverData.List() {
 			serverId := common.If(gconv.Int(m["p_id"]) > 0, gconv.Int(m["p_id"]), gconv.Int(m["id"])).(int)
 			mainId := gconv.Int(m["id"])
-			if p.param.RecordPayType == Upgrades {
-				userService, _ := g.DB().Ctx(ctx).Query(ctx, fmt.Sprintf("select * from bigmember_service_user where s_serviceid = %s and s_userid = '%s' and  i_status != -1", serverId, p.param.UserId))
-				if userService.Len() > 0 {
-					log.Println("用户补充服务已存在")
-				}
-			}
-
+			userService, _ := g.DB().Ctx(ctx).Query(ctx, fmt.Sprintf("select * from bigmember_service_user where s_serviceid = %d and s_userid = '%s' and  i_status != -1", serverId, p.param.UserId))
 			var (
-				resourceType string
+				frequency int
 			)
 
-			if strings.Contains(common.InterfaceToStr(m["s_name"]), "市场分析定制报告pdf下载") {
-				resourceType = "市场分析定制报告下载包"
-			} else if strings.Contains(common.InterfaceToStr(m["s_name"]), "业主采购分析报告pdf下载") {
-				resourceType = "业主采购分析报告下载包"
-			} else if strings.Contains(common.InterfaceToStr(m["s_name"]), "企业中标分析报告pdf下载") {
-				resourceType = "企业中标分析报告下载包"
-			}
-			number := common.IntAll(m["s_count_year"])
-			comboId := p.param.ComboId
-			if comboId > 0 { //套餐 number*时间
-				cycle := p.param.PayCycle         //购买市场
-				cycleType := p.param.PayCycleType //时间类型
-				cycleFmt := common.If(cycleType == 0, 12, 366).(int)
-				number = number * (cycle / cycleFmt)
-			}
-
-			var frequency int
-
 			switch serverId {
 			case 11:
-				frequency = p.param.PayCycle * common.IntAll(m["s_count_month"])
+				frequency = p.param.Filter.BuyCycle * common.IntAll(m["s_count_month"])
 			case 15:
-				if p.param.PayCycle >= 12 {
-					frequency = (p.param.PayCycle / 12 * common.IntAll(m["s_count_year"])) + (p.param.PayCycle % 12 * common.IntAll(m["s_count_month"]))
+				if p.param.Filter.BuyCycle >= 12 {
+					frequency = (p.param.Filter.BuyCycle / 12 * common.IntAll(m["s_count_year"])) + (p.param.Filter.BuyCycle % 12 * common.IntAll(m["s_count_month"]))
 				} else {
-					frequency = p.param.PayCycle * common.IntAll(m["s_count_month"])
+					frequency = p.param.Filter.BuyCycle * common.IntAll(m["s_count_month"])
 				}
 			default:
 				frequency = common.IntAll(m["s_count_month"])
 			}
 			switch p.param.RecordPayType {
 			case Buy, try: //购买 试用
-				if number > 0 {
-					count := common.If(p.param.BuySubject == "2", p.param.PAccountNumber, 1).(int)
-					if err := AddPdfPack(p.param.UserId, p.param.UserId, resourceType, endDate.Format(date.Date_Short_Layout), number, count, entId, 1, pid); err != nil {
-						log.Println("AddPdfPack err ", err)
-					}
-				}
-				if !isEquity { //仅赠送pdf
-					continue
-				}
-
-				userServerData, _ := g.DB().Ctx(ctx).Query(ctx, fmt.Sprintf("select * from bigmember_service_user where s_serviceid = %d and s_userid = '%s' and  i_status != -1", serverId, p.param.UserId))
-				if !userServerData.IsEmpty() {
+				if !userService.IsEmpty() {
 					//i_status := common.If(dateType == 1, 0, 1)
 					_, err := g.DB().Ctx(ctx).Update(ctx, "bigmember_service_user", map[string]interface{}{
 						"l_updatetime": date.NowFormat(date.Date_Full_Layout),
@@ -227,15 +140,7 @@ func (p jyBigProduct) UserEquityDistribution(ctx context.Context, startDate, end
 					}
 				}
 			case Renew:
-				if number > 0 {
-					if err := AddPdfPack(p.param.UserId, p.param.UserId, resourceType, endDate.Format(date.Date_Short_Layout), number, 0, entId, 1, pid); err != nil {
-						log.Println("AddPdfPack err ", err)
-					}
-				}
-				if !isEquity { //仅赠送pdf
-					continue
-				}
-				if count, _ := g.DB().Ctx(ctx).GetCount(ctx, fmt.Sprintf(`SELECT count(1) FROM bigmember_service_user WHERE s_userid='%s' and s_serviceid=%d`, p.param.UserId, gconv.Int(m["id"]))); count > 0 {
+				if !userService.IsEmpty() {
 					if status == 1 {
 						sql1 := fmt.Sprintf("update bigmember_service_user set i_frequency = i_frequency + %v,l_updatetime = %v,l_endtime = %v where s_serviceid = %v and s_userid = %v", frequency, date.NowFormat(date.Date_Full_Layout), endDate, serverId, p.param.UserId)
 						_, err := g.DB().Ctx(ctx).Exec(ctx, sql1)
@@ -297,14 +202,6 @@ func (p jyBigProduct) UserEquityDistribution(ctx context.Context, startDate, end
 				}
 
 			case Upgrades:
-				if number > 0 {
-					if err := AddPdfPack(p.param.UserId, p.param.UserId, resourceType, endDate.Format(date.Date_Short_Layout), number, buyCount, entId, 1, pid); err != nil {
-						log.Println("AddPdfPack err ", err)
-					}
-				}
-				if !isEquity { //仅赠送pdf
-					continue
-				}
 				if gconv.Int(m["id"]) == 16 {
 					err := p.UserServiceRecharge(ctx, []string{"12", "13"}, gconv.Int(m["count"]), endDate)
 					if err != nil {
@@ -313,9 +210,8 @@ func (p jyBigProduct) UserEquityDistribution(ctx context.Context, startDate, end
 					continue
 				}
 
-				count, err := g.DB().Ctx(ctx).GetCount(ctx, fmt.Sprintf(`SELECT count(1) FROM bigmember_service_user WHERE s_serviceid = %s and s_userid = '%s' and i_status = 0 `, fmt.Sprint(serverId), p.param.UserId))
-				if count > 0 {
-					_, err = g.DB().Ctx(ctx).Exec(ctx, fmt.Sprintf("update bigmember_service_user set i_frequency = i_frequency + %d,l_updatetime = '%s' where s_serviceid = %v and s_userid = '%v' and i_status =0", gconv.Int(m["count"]), date.NowFormat(date.Date_Full_Layout), fmt.Sprint(serverId), p.param.UserId))
+				if !userService.IsEmpty() {
+					_, err := g.DB().Ctx(ctx).Exec(ctx, fmt.Sprintf("update bigmember_service_user set i_frequency = i_frequency + %d,l_updatetime = '%s' where s_serviceid = %v and s_userid = '%v' and i_status =0", gconv.Int(m["count"]), date.NowFormat(date.Date_Full_Layout), fmt.Sprint(serverId), p.param.UserId))
 					if err != nil {
 						log.Println("UserServiceRecharge err ", err.Error(), p.param.UserId, serverId)
 						continue
@@ -332,12 +228,12 @@ func (p jyBigProduct) UserEquityDistribution(ctx context.Context, startDate, end
 						"l_createtime": date.NowFormat(date.Date_Full_Layout),
 						"l_updatetime": date.NowFormat(date.Date_Full_Layout),
 					}
-					_, err = g.DB().Ctx(ctx).Insert(ctx, "bigmember_service_user", insert)
+					_, err := g.DB().Ctx(ctx).Insert(ctx, "bigmember_service_user", insert)
 					if err != nil {
 						return errors.New("用户服务表插入失败")
 					}
 				}
-				err = p.UserServiceRecharge(ctx, []string{gconv.String(serverId)}, gconv.Int(m["count"]), endDate)
+				err := p.UserServiceRecharge(ctx, []string{gconv.String(serverId)}, gconv.Int(m["count"]), endDate)
 				if err != nil {
 					log.Println("UserServiceRecharge err ", err.Error(), p.param.UserId, serverId)
 				}
@@ -347,9 +243,53 @@ func (p jyBigProduct) UserEquityDistribution(ctx context.Context, startDate, end
 	return nil
 }
 
+func (p jyBigProduct) UserPdfDistribution(ctx context.Context, endDate time.Time, entId, buySubject int, pid int64) error {
+	var (
+		serviceIdArr []string
+	)
+	if p.param.RecordPayType == Upgrades {
+		serviceIdArr = p.param.Filter.SupServiceIds
+	} 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, ",")))
+	if !serverData.IsEmpty() {
+		for _, m := range serverData.List() {
+			var (
+				resourceType string
+				number       int
+			)
+			//企业补充包不赠送下载报告
+			if strings.Contains(common.InterfaceToStr(m["s_name"]), "市场分析定制报告pdf下载") {
+				resourceType = "市场分析定制报告下载包"
+			} else if strings.Contains(common.InterfaceToStr(m["s_name"]), "业主采购分析报告pdf下载") {
+				resourceType = "业主采购分析报告下载包"
+			} else if strings.Contains(common.InterfaceToStr(m["s_name"]), "企业中标分析报告pdf下载") {
+				resourceType = "企业中标分析报告下载包"
+			}
+			number = common.IntAll(m["s_count_year"])
+			comboId := p.param.Filter.ComboId
+			if comboId > 0 { //套餐 number*时间
+				cycle := p.param.Filter.BuyCycle    //购买市场
+				cycleType := p.param.Filter.BuyType //时间类型
+				cycleFmt := common.If(cycleType == 0, 12, 366).(int)
+				number = number * (cycle / cycleFmt)
+			}
+
+			if number > 0 {
+				count := common.If(buySubject == 2, p.param.Filter.FinalAccountCount, 1).(int)
+				if err := AddPdfPack(p.param.UserId, p.param.UserId, resourceType, endDate.Format(date.Date_Short_Layout), number, count, entId, p.param.RecordPayType, pid); err != nil {
+					log.Println("AddPdfPack err ", err)
+				}
+			}
+		}
+	}
+	return nil
+}
+
 // EntEquityUser 企业服务已分配用户
 func EntEquityUser(ctx context.Context, waitEmpowerId int) []map[string]interface{} {
-	data, err := g.DB().Ctx(ctx).GetAll(ctx, fmt.Sprintf(`SELECT a.ent_id,a.ent_user_id,d.id as pId FROM entniche_power a
+	data, err := g.DB().Ctx(ctx).GetAll(ctx, fmt.Sprintf(`SELECT a.ent_id,a.ent_user_id,d.id as eId FROM entniche_power a
 INNER JOIN entniche_user b on a.ent_user_id=b.id 
 INNER JOIN base_service.base_user c on c.phone = b.phone
 INNER JOIN base_service.base_position d on c.id = d.user_id and a.ent_id = d.ent_id
@@ -409,11 +349,11 @@ func AddPdfPack(userId, accountId, resourceType, endTime string, num, count, ent
 			return errors.New("addPdfPack error")
 		}
 		switch sType {
-		case 1:
+		case Buy, try:
 			jyUrl = "config.SysConfigs.JyResources  " + "/resources/entAccountAdd"
-		case 2:
+		case Upgrades:
 			jyUrl = "config.SysConfigs.JyResources" + "/resources/entAccountAdd"
-		case 3:
+		case Renew:
 			jyUrl = "config.SysConfigs.JyResources" + "/resources/entSourceNumAdd"
 		}
 	}
@@ -465,8 +405,8 @@ func CommonPost(path string, param url.Values) (map[string]interface{}, error) {
 	return resMap, nil
 }
 
-// 企业订阅时间修改
-func UpdateRule(ctx context.Context, entId int, update map[string]interface{}, phone string) bool {
+//UpdateRule 企业订阅时间修改
+/*func UpdateRule(ctx context.Context, entId int, update map[string]interface{}, phone string) bool {
 	if entId > 0 && phone != "" {
 		//查找之前数据是否存在
 		userData, _ := g.DB().Ctx(ctx).GetOne(ctx, fmt.Sprintf(`SELECT * FROM entniche_user WHERE ent_id =%d and phone ='%s'`, entId, phone))
@@ -538,8 +478,8 @@ func UpdateRule(ctx context.Context, entId int, update map[string]interface{}, p
 		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_vip_status": bson.M{"$gt": 0}},
+					{"i_member_status": bson.M{"$gt": 0}},
 				},
 				"i_entid":  entId,
 				"i_userid": userData.Map()["id"],
@@ -556,26 +496,16 @@ func UpdateRule(ctx context.Context, entId int, update map[string]interface{}, p
 		return ok1 || ok2
 	}
 	return false
-}
+}*/
 
 func GetBigMemberProductTypeByOrderCode(level int) string {
-	var product_type = "大会员"
-	//1:专业版;2:智慧版;3:商机版;4:试用版 5:试用版 6:商机版2.0 7:专家版2.0
-	switch level {
-	case 1:
-		product_type += "专家版"
-	case 2:
-		product_type += "智慧版"
-	case 3:
-		product_type += "商机版"
-	case 4:
-		product_type += "试用版"
-	case 6:
-		product_type += "商机版2.0"
-	case 7:
-		product_type += "专家版2.0"
-	default:
-		product_type += "自定义"
+	productType := "大会员自定义"
+	if level < 0 || level == 5 {
+		return productType
+	}
+	comboData, _ := g.DB().Ctx(context.Background()).GetOne(context.Background(), fmt.Sprintf(`SELECT s_name,s_servers FROM bigmember_combo WHERE id=%d`, level))
+	if !comboData.IsEmpty() {
+		return fmt.Sprintf("大会员%s", gconv.String(comboData.Map()["s_name"]))
 	}
-	return product_type
+	return productType
 }

+ 139 - 82
internal/logic/product/bigmember/bigmember.go

@@ -1,7 +1,6 @@
 package bigmember
 
 import (
-	"app.yhyue.com/moapp/jybase/common"
 	"context"
 	"errors"
 	"fmt"
@@ -11,13 +10,14 @@ import (
 	"jyOrderManager/internal/logic/product"
 	"jyOrderManager/internal/model"
 	"jyOrderManager/internal/service"
+	"log"
 	"time"
 )
 
 type (
-	//剑鱼超级订阅商品
+	//剑鱼大会员商品
 	jyBigProduct struct {
-		param  model.CreateBigParams
+		param  model.JyBigParams
 		reqMap map[string]interface{}
 	}
 )
@@ -26,16 +26,16 @@ func init() {
 	product.JyProFunc.RegisterJyProductCreateFunc("bigmember", NewBigProduct)
 }
 
-func NewBigProduct(reqParam map[string]interface{}, detailId int64) (product.JyProduct, error) {
-	var p model.CreateBigParams
+func NewBigProduct(reqParam map[string]interface{}, detailId ...int64) (product.JyProduct, error) {
+	var p model.JyBigParams
 	_ = gconv.Struct(reqParam, &p)
 	//根据订单详情id,初始化字段
-	if detailId > 0 {
-		record, err := g.DB().GetOne(context.Background(), "SELECT * FROM jy_product_detail WHERE id=?", detailId)
+	if len(detailId) > 0 {
+		record, err := g.DB().GetOne(context.Background(), fmt.Sprintf("SELECT * FROM jy_product_detail WHERE id=%d", detailId[0]))
 		if err != nil {
 			return nil, errors.New("未知订单详情id")
 		}
-		if err := record.Struct(p); err != nil {
+		if err = record.Struct(p); err != nil {
 			return nil, err
 		}
 	}
@@ -45,108 +45,165 @@ func NewBigProduct(reqParam map[string]interface{}, detailId int64) (product.JyP
 	}, nil
 }
 
-func (p jyBigProduct) Check() error {
-	m, err := p.GetPrice()
-	if err != nil {
-		return errors.New("金额校验计算异常")
+func (p jyBigProduct) Check(t int) error {
+	if p.param.ProductCode == "" {
+		return errors.New("缺少商品code")
 	}
-	if p.param.Amount != m {
-		return errors.New("金额校验异常")
+
+	if p.param.Phone == "" {
+		return errors.New("缺少开通手机号")
+	}
+
+	if !(p.param.RecordPayType == try || p.param.RecordPayType == Renew || p.param.RecordPayType == Upgrades || p.param.RecordPayType == Buy) {
+		return errors.New("未知商品支付操作")
 	}
-	pcls, err := service.Product().GetProduct(p.param.ProductCode)
-	if err != nil {
-		return errors.New("未知商品类型")
+
+	if (p.param.RecordPayType == Renew || p.param.RecordPayType == Upgrades) && p.param.LinkedOrderId <= 0 {
+		return errors.New("缺少关联订单")
+	}
+
+	if p.param.Filter.BuyCycle <= 0 {
+		return errors.New("请选择时间")
 	}
-	if pcls.ProductClass.Tactics != 3 && p.param.Tactics != pcls.ProductClass.Tactics {
-		return errors.New("销售策略不支持")
+
+	if t == 1 { //订单报错校验
+		if !(p.param.Tactics == 1 || p.param.Tactics == 2) {
+			return fmt.Errorf("参数异常")
+		}
+
+		productItem, err := service.Product().GetProduct(p.param.ProductCode)
+		if err != nil {
+			return errors.New("未知商品")
+		}
+		productClass, err := service.Product().GetProductClass(productItem.ProductClassId)
+		if err != nil {
+			return errors.New("未知商品类型")
+		}
+		if productClass.Tactics != 3 && productClass.Tactics != p.param.Tactics {
+			return errors.New("非法销售策略")
+		}
+
+		m, err := p.GetPrice()
+		if err != nil {
+			return errors.New("金额校验计算异常")
+		}
+		if p.param.OriginalPrice != m {
+			return fmt.Errorf("%s 金额校验异常 %d!=%d", p.param.ProductCode, p.param.Amount, m)
+		}
 	}
 	return nil
 }
 
 func (p jyBigProduct) SaveUpdate(ctx context.Context) error {
-	switch p.param.ControlsType {
-	case 1: //保存
-		g.DB().Ctx(ctx).Insert(ctx, "jy_product_detail", model.JyProductDetail{
-			OrderCode:        p.param.OrderCode,
-			ProductType:      p.param.ProductType,
-			Phone:            p.param.Phone,
-			UserID:           p.param.UserId,
-			OriginalPrice:    p.param.OrderMoney,
-			FinalPrice:       p.param.PayMoney,
-			ServiceOpen:      "0",
-			ServiceOpenTime:  time.Now(),
-			BillingMode:      "1",
-			ServiceStartTime: time.Now(),
-			ServiceEndTime:   time.Now(),
-			ServiceType:      1,
-			ActivityID:       p.param.ActivityId,
-		})
-	case 2: //更新
-		g.DB().Ctx(ctx).Update(ctx, "jy_product_detail", model.JyProductDetail{
-			OrderCode:        p.param.OrderCode,
-			ProductType:      p.param.ProductType,
-			Phone:            p.param.Phone,
-			UserID:           p.param.UserId,
-			OriginalPrice:    p.param.OrderMoney,
-			FinalPrice:       p.param.PayMoney,
-			ServiceOpen:      "0",
-			ServiceOpenTime:  time.Now(),
-			BillingMode:      "1",
-			ServiceStartTime: time.Now(),
-			ServiceEndTime:   time.Now(),
-			ServiceType:      1,
-			ActivityID:       p.param.ActivityId,
-		},
-			map[string]interface{}{"id": p.param.Id})
+	var (
+		newData = g.Map{
+			"order_code":       p.param.OrderCode,
+			"product_type":     "大会员",
+			"phone":            p.param.Phone,
+			"original_price":   p.param.OriginalPrice,
+			"final_price":      p.param.Amount,
+			"product_id":       p.param.ProductCode,
+			"tactics":          p.param.Tactics,
+			"linked_detail_id": p.param.LinkedOrderId,
+		}
+
+		filter    = p.param.Filter
+		oldFilter *model.JyBigProductFilter
+		err       error
+	)
+	if err = p.Check(1); err != nil {
+		log.Println(err)
+		return err
+	}
+	filter.FinalAccountCount = 1 + filter.BuyAccountCount + filter.GiftAccountCount
+	if p.param.RecordPayType == 2 || p.param.RecordPayType == 3 { //获取
+		oldFilter, _, _, err = getLinkFilter(ctx, p.param.LinkedOrderId)
+		if err != nil {
+			return err
+		}
+		filter.FinalAccountCount = oldFilter.FinalAccountCount
+		if p.param.RecordPayType == 2 {
+			filter.FinalAreaCount = oldFilter.FinalAreaCount
+		} else {
+			sVal, err := service.Product().GetProduct(p.param.ProductCode)
+			if err != nil {
+				return err
+			}
+			filter.FinalAreaCount = sVal.UnitNum
+		}
+	}
+	newData["filter"] = gconv.String(filter)
+	if p.param.Id > 0 {
+		res, err := g.DB().Ctx(ctx).Update(ctx, OrderDetailTab, newData, " id = ? ", p.param.Id)
+		if err != nil {
+			return errors.New("大会员明细更新异常")
+		}
+		if num, err := res.RowsAffected(); num != 1 || err != nil {
+			return errors.New("大会员明细更新异常")
+		}
+	} else {
+		res, err := g.DB().Ctx(ctx).Insert(ctx, OrderDetailTab, newData)
+		if err != nil {
+			return errors.New("大会员插入订单明细异常")
+		}
+		if num, err := res.RowsAffected(); num != 1 || err != nil {
+			return errors.New("大会员插入订单明细异常")
+		}
 	}
 	return nil
 }
 
 func (p jyBigProduct) OpenService(ctx context.Context) error {
+	if err := p.Check(1); err != nil {
+		log.Println("参数校验异常")
+		return err
+	}
+	//购买试用校验权益开通时间
+	if p.param.RecordPayType == Buy || p.param.RecordPayType == try {
+		if p.param.ServiceStartTime.Unix() > time.Now().Unix() {
+			return errors.New("服务开通时间暂不支持")
+		}
+		if p.param.ServiceEndTime.Unix() < time.Now().Unix() {
+			return errors.New("服务结束时间已失效")
+		}
+	}
+
 	orderData, err := g.DB().Ctx(ctx).GetOne(ctx, fmt.Sprintf(`SELECT * FROM dataexport_order WHERE order_code ='%s'`, p.param.OrderCode))
 	if err != nil || orderData.IsEmpty() {
 		return errors.New("订单查询错误")
 	}
-	var productDetail = model.JyProductDetail{
-		OrderCode:        p.param.OrderCode,
+
+	userData, entId, userPositionId, err := jyutil.GetCreateUserData(p.param.Phone, gconv.String(orderData.Map()["company_name"]), gconv.Int(orderData.Map()["buy_subject"]) == 2)
+	if userData == nil || err != nil {
+		return errors.New("用户获取失败")
+	}
+	userData["userPositionId"] = userPositionId
+	userData["entId"] = entId
+	var productDetail = model.JyBigParams{
 		ProductType:      p.param.ProductType,
-		Phone:            p.param.Phone,
-		UserID:           p.param.UserId,
-		OriginalPrice:    p.param.OrderMoney,
-		FinalPrice:       p.param.PayMoney,
-		ServiceOpen:      "1",
 		ServiceOpenTime:  time.Now(),
-		BillingMode:      "1",
 		ServiceStartTime: time.Now(),
 		ServiceEndTime:   time.Now(),
-		ServiceType:      1,
-		ActivityID:       p.param.ActivityId,
 	}
-	userData, userPositionId, _, _ := jyutil.GetCreateUserData(p.param.Phone, gconv.String(orderData.Map()["company_name"]), gconv.Int(orderData.Map()["buy_subject"]) == 2)
-	if userData == nil {
-		return errors.New("用户获取失败")
-	}
-	p.param.UserId = gconv.String(userPositionId)
-	p.param.MgoId = common.InterfaceToStr(userData["_id"])
-	switch p.param.ProductType {
-	case "大会员":
-		return p.OpenBuyGigService(ctx, orderData.Map(), userData, productDetail)
-	case "大会员-子账号":
-		return p.BigMemberSub(ctx, orderData.Map(), productDetail)
-	case "大会员-补充包":
-		return p.BigMemberUpgrades(ctx, userData, productDetail)
-	}
-	return errors.New("产品异常")
+
+	return p.OpenBigService(ctx, orderData.Map(), userData, productDetail)
 }
 
-func (p jyBigProduct) OpenBuyGigService(ctx context.Context, orderData, userData map[string]interface{}, productDetail model.JyProductDetail) error {
+func (p jyBigProduct) OpenBigService(ctx context.Context, orderData, userData map[string]interface{}, productDetail model.JyBigParams) error {
 	switch p.param.RecordPayType {
 	case Buy, try: //购买 试用
-		return p.BigMemberBuyTry(ctx, orderData, productDetail)
+		return p.BigMemberBuyTry(ctx, orderData, userData, productDetail)
 	case Renew: // 续费
-		return p.BigMemberRenew(ctx, userData, productDetail)
+		return p.BigMemberRenew(ctx, orderData, userData, productDetail)
 	case Upgrades: //升级
-		return p.BigMemberUpgrades(ctx, userData, productDetail)
+		var err error
+		if p.param.Filter.FinalAccountCount > 0 { //补充子账号
+			err = p.BigMemberSub(ctx, orderData, userData, productDetail)
+		}
+		if len(p.param.Filter.SupServiceIds) > 0 { //补充服务
+			err = p.BigMemberUpgrades(ctx, orderData, userData, productDetail)
+		}
+		return err
 	}
 	//TODO 修改订单
 	return nil

+ 7 - 8
internal/logic/product/bigmember/price.go

@@ -16,33 +16,32 @@ type priceSetting struct {
 func (p jyBigProduct) GetPrice() (int64, error) {
 	var (
 		fPrice   int64
-		totalNum = p.param.SPayAccountNumber + p.param.SGiftAccountNumber
+		totalNum = p.param.Filter.FinalAccountCount
 	)
 	sVal, err := service.Product().GetPriceConfig(p.param.ProductCode)
 	if err != nil {
 		return 0, err
 	}
 	var thisPriceSetting priceSetting
-	if err := gconv.Struct(sVal.Rule, &thisPriceSetting); err != nil {
+	if err = gconv.Struct(sVal.Rule, &thisPriceSetting); err != nil {
 		return 0, gerror.NewCode(gcode.CodeValidationFailed, "价格格式配置异常")
 	}
 
-	if p.param.PayCycleType == p.param.GifCycleType { //购买周期和送的周期一样
-		p, err := thisPriceSetting.GetPrice(p.param.GifCycle+p.param.PayCycle, p.param.GifCycleType)
+	if p.param.Filter.BuyType == p.param.Filter.GiftType { //购买周期和送的周期一样
+		price, err := thisPriceSetting.GetPrice(p.param.Filter.GiftCycle+p.param.Filter.BuyCycle, p.param.Filter.GiftType)
 		if err != nil {
 			return 0, err
 		}
-		fPrice = p * gconv.Int64(totalNum)
+		fPrice = price * gconv.Int64(totalNum)
 	} else {
 		var (
 			p1, p2 int64
-			err    error
 		)
-		p1, err = thisPriceSetting.GetPrice(p.param.PayCycleType, p.param.PayCycleType)
+		p1, err = thisPriceSetting.GetPrice(p.param.Filter.BuyType, p.param.Filter.BuyType)
 		if err != nil {
 			return p1, err
 		}
-		p2, err = thisPriceSetting.GetPrice(p.param.GifCycle, p.param.GifCycleType)
+		p2, err = thisPriceSetting.GetPrice(p.param.Filter.GiftCycle, p.param.Filter.GiftType)
 		if err != nil {
 			return p2, err
 		}

+ 49 - 0
internal/logic/product/relationManage/relationCommon.go

@@ -0,0 +1,49 @@
+package relationManage
+
+import (
+	"context"
+	"fmt"
+	"github.com/gogf/gf/v2/database/gdb"
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/util/gconv"
+	"jyOrderManager/internal/model"
+	"time"
+)
+
+const (
+	Buy            = iota + 1 //购买
+	Renew                     //续费
+	Upgrades                  //升级
+	OrderDetailTab = "jy_product_detail"
+)
+
+// getLinkFilter 获取关联订单
+func getLinkFilter(ctx context.Context, linkOrderDetailId int64) (filter *model.JyRelationManageFilter, st, et time.Time, err error) {
+	var (
+		re gdb.Record
+	)
+	re, err = g.DB().GetOne(ctx, fmt.Sprintf("SELECT filter,service_starttime,service_endtime FROM jy_product_detail WHERE id =%d", linkOrderDetailId))
+	if err != nil {
+		return
+	}
+	var (
+		dMap = re.Map()
+	)
+	if len(dMap) == 0 {
+		err = fmt.Errorf("获取关联订单异常")
+		return
+	}
+	err = gconv.Struct(dMap["filter"], filter)
+	if err != nil {
+		return
+	}
+	st, err = time.Parse(time.DateTime, gconv.String(dMap["service_starttime"]))
+	if err != nil {
+		return
+	}
+	et, err = time.Parse(time.DateTime, gconv.String(dMap["service_endtime"]))
+	if err != nil {
+		return
+	}
+	return
+}

+ 236 - 0
internal/logic/product/relationManage/relationManage.go

@@ -0,0 +1,236 @@
+package relationManage
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	"github.com/gogf/gf/v2/errors/gcode"
+	"github.com/gogf/gf/v2/errors/gerror"
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/util/gconv"
+	"jyOrderManager/internal/logic/product"
+	"jyOrderManager/internal/model"
+	"jyOrderManager/internal/service"
+	"log"
+)
+
+type (
+	//剑鱼大会员商品
+	jyRelationManageProduct struct {
+		param  model.JyRelationManageParams
+		reqMap map[string]interface{}
+	}
+)
+
+func init() {
+	product.JyProFunc.RegisterJyProductCreateFunc("relationManage", NewrelationManageProduct)
+}
+
+func NewrelationManageProduct(reqParam map[string]interface{}, detailId ...int64) (product.JyProduct, error) {
+	var p model.JyRelationManageParams
+	_ = gconv.Struct(reqParam, &p)
+	//根据订单详情id,初始化字段
+	if len(detailId) > 0 {
+		record, err := g.DB().GetOne(context.Background(), fmt.Sprintf("SELECT * FROM jy_product_detail WHERE id=%d", detailId[0]))
+		if err != nil {
+			return nil, errors.New("未知订单详情id")
+		}
+		if err = record.Struct(p); err != nil {
+			return nil, err
+		}
+	}
+	return jyRelationManageProduct{
+		param:  p,
+		reqMap: reqParam,
+	}, nil
+}
+
+func (p jyRelationManageProduct) Check(t int) error {
+	if p.param.ProductCode == "" {
+		return errors.New("缺少商品code")
+	}
+
+	if p.param.Phone == "" {
+		return errors.New("缺少开通手机号")
+	}
+
+	if !(p.param.RecordPayType == Renew || p.param.RecordPayType == Upgrades || p.param.RecordPayType == Buy) {
+		return errors.New("未知商品支付操作")
+	}
+
+	if (p.param.RecordPayType == Renew || p.param.RecordPayType == Upgrades) && p.param.LinkedOrderId <= 0 {
+		return errors.New("缺少关联订单")
+	}
+
+	if p.param.Filter.BuyCycle <= 0 {
+		return errors.New("请选择时间")
+	}
+	if p.param.Filter.FinalAccountCount > 1 &&
+		(p.param.ProductType == "人脉管理" || p.param.ProductType == "阳光采购") {
+		return errors.New("不支持多数量购买")
+	}
+	//个人情况哪些产品不能购买
+	if p.param.Filter.BuySubject == 1 && (p.param.ProductType == "企业商机管理" || p.param.ProductType == "医械通" ||
+		p.param.ProductType == "物业数字化营销" || p.param.ProductType == "运营商专版") {
+		return errors.New("个人购买类型")
+	}
+
+	if p.param.ProductType == "" {
+
+	}
+
+	if t == 1 { //订单报错校验
+		if !(p.param.Tactics == 1 || p.param.Tactics == 2) {
+			return fmt.Errorf("参数异常")
+		}
+
+		productItem, err := service.Product().GetProduct(p.param.ProductCode)
+		if err != nil {
+			return errors.New("未知商品")
+		}
+		productClass, err := service.Product().GetProductClass(productItem.ProductClassId)
+		if err != nil {
+			return errors.New("未知商品类型")
+		}
+		if productClass.Tactics != 3 && productClass.Tactics != p.param.Tactics {
+			return errors.New("非法销售策略")
+		}
+
+		m, err := p.GetPrice()
+		if err != nil {
+			return errors.New("金额校验计算异常")
+		}
+		if p.param.OriginalPrice != m {
+			return fmt.Errorf("%s 金额校验异常 %d!=%d", p.param.ProductCode, p.param.Amount, m)
+		}
+	}
+	return nil
+}
+
+func (p jyRelationManageProduct) SaveUpdate(ctx context.Context) error {
+	var (
+		newData = g.Map{
+			"order_code":       p.param.OrderCode,
+			"product_type":     p.param.ProductType,
+			"phone":            p.param.Phone,
+			"original_price":   p.param.OriginalPrice,
+			"final_price":      p.param.Amount,
+			"product_id":       p.param.ProductCode,
+			"tactics":          p.param.Tactics,
+			"linked_detail_id": p.param.LinkedOrderId,
+		}
+
+		filter    = p.param.Filter
+		oldFilter *model.JyRelationManageFilter
+		err       error
+	)
+	if err = p.Check(1); err != nil {
+		log.Println(err)
+		return err
+	}
+	filter.FinalAccountCount = 1 + filter.BuyAccountCount + filter.GiftAccountCount
+	if p.param.RecordPayType == 2 || p.param.RecordPayType == 3 { //获取
+		oldFilter, _, _, err = getLinkFilter(ctx, p.param.LinkedOrderId)
+		if err != nil {
+			return err
+		}
+		filter.FinalAccountCount = oldFilter.FinalAccountCount
+		if p.param.RecordPayType == 2 {
+			filter.FinalAreaCount = oldFilter.FinalAreaCount
+		} else {
+			sVal, err := service.Product().GetProduct(p.param.ProductCode)
+			if err != nil {
+				return err
+			}
+			filter.FinalAreaCount = sVal.UnitNum
+		}
+	}
+	newData["filter"] = gconv.String(filter)
+	if p.param.Id > 0 {
+		res, err := g.DB().Ctx(ctx).Update(ctx, OrderDetailTab, newData, " id = ? ", p.param.Id)
+		if err != nil {
+			return errors.New("大会员明细更新异常")
+		}
+		if num, err := res.RowsAffected(); num != 1 || err != nil {
+			return errors.New("大会员明细更新异常")
+		}
+	} else {
+		res, err := g.DB().Ctx(ctx).Insert(ctx, OrderDetailTab, newData)
+		if err != nil {
+			return errors.New("大会员插入订单明细异常")
+		}
+		if num, err := res.RowsAffected(); num != 1 || err != nil {
+			return errors.New("大会员插入订单明细异常")
+		}
+	}
+	return nil
+}
+
+// OpenService 暂不支持程序开通
+func (p jyRelationManageProduct) OpenService(ctx context.Context) error {
+
+	return nil
+}
+
+type priceSetting struct {
+	Moth   int64 `json:"moth"`
+	Season int64 `json:"season"`
+	Year   int64 `json:"year"`
+}
+
+func (p jyRelationManageProduct) GetPrice() (int64, error) {
+	var (
+		fPrice   int64
+		totalNum = p.param.Filter.FinalAccountCount
+	)
+	sVal, err := service.Product().GetPriceConfig(p.param.ProductCode)
+	if err != nil {
+		return 0, err
+	}
+	var thisPriceSetting priceSetting
+	if err = gconv.Struct(sVal.Rule, &thisPriceSetting); err != nil {
+		return 0, gerror.NewCode(gcode.CodeValidationFailed, "价格格式配置异常")
+	}
+
+	if p.param.Filter.BuyType == p.param.Filter.GiftType { //购买周期和送的周期一样
+		price, err := thisPriceSetting.GetPrice(p.param.Filter.GiftCycle+p.param.Filter.BuyCycle, p.param.Filter.GiftType)
+		if err != nil {
+			return 0, err
+		}
+		fPrice = price * gconv.Int64(totalNum)
+	} else {
+		var (
+			p1, p2 int64
+		)
+		p1, err = thisPriceSetting.GetPrice(p.param.Filter.BuyType, p.param.Filter.BuyType)
+		if err != nil {
+			return p1, err
+		}
+		p2, err = thisPriceSetting.GetPrice(p.param.Filter.GiftCycle, p.param.Filter.GiftType)
+		if err != nil {
+			return p2, err
+		}
+		fPrice = (p1 + p2) * gconv.Int64(totalNum)
+	}
+	return fPrice, nil
+}
+
+func (ps priceSetting) GetPrice(num, cycleType int) (int64, error) {
+	switch cycleType { // 1-天 2-月 3-季 4-年
+	case 1:
+		return ps.Moth / 30 * gconv.Int64(num), nil
+	case 2:
+		if num >= 12 && ps.Year > 0 {
+			return ps.Year / 12 * gconv.Int64(num), nil
+		}
+		if num >= 3 && ps.Season > 0 {
+			return ps.Season / 3 * gconv.Int64(num), nil
+		}
+		return ps.Moth * gconv.Int64(num), nil
+	case 3:
+		return ps.Season * gconv.Int64(num), nil
+	case 4:
+		return ps.Year * gconv.Int64(num), nil
+	}
+	return -1, gerror.NewCode(gcode.CodeInvalidParameter, "未知时间参数")
+}

+ 0 - 8
internal/model/bigmember.go

@@ -4,12 +4,4 @@ type (
 	JyBigProductParam struct {
 		*ProductCommonParam
 	}
-	JyBigProductFilter struct {
-		BuyAccountCount  int `json:"buyAccountCount"`  //购买数量(仅购买主体是企业)
-		GiftAccountCount int `json:"giftAccountCount"` //赠送数量(仅购买主体是企业)
-		BuyCycle         int `json:"buy_cycle"`        //购买周期
-		BuyType          int `json:"buy_type"`         //购买周期 类型 1天 2月 3年 4季度
-		GiftCycle        int `json:"give_cycle"`       //赠送周期
-		GiftType         int `json:"give_type"`        //赠送周期 类型 1天 2月 3年 4季度
-	}
 )

+ 37 - 0
internal/model/entOperation.go

@@ -0,0 +1,37 @@
+package model
+
+import "time"
+
+type (
+	JyRelationManageParams struct {
+		*ProductCommonParam
+		ProductType       string    `json:"productType,omitempty"`                             //产品类型
+		UserId            string    `json:"userId,omitempty"`                                  //产品类型
+		MogUserId         string    `json:"mgoUserId,omitempty"`                               //产品类型
+		RecordPayType     int       `form:"recordPayType" json:"recordPayType,omitempty"`      //付费类型 1:购买 2:续费 3:升级 4:试用
+		LinkedOrderId     int64     `json:"linkedOrderId,omitempty"`                           //关联订单明细id
+		PaybackOpenServer bool      `json:"paybackOpenServer,omitempty"`                       //是否全额回款开通
+		PayMoney          int       `form:"payMoney" json:"payMoney,omitempty"`                //合同金额
+		ServiceOpenTime   time.Time `json:"service_open_time" gorm:"column:service_open_time"` // 服务开通时间
+
+		ServiceStartTime time.Time              `json:"service_start_time" gorm:"column:service_starttime"` // 开始日期
+		ServiceEndTime   time.Time              `json:"service_end_time" gorm:"column:service_endtime"`     // 结束日期
+		Filter           JyRelationManageFilter `json:"filter,omitempty"`                                   //大字段
+	}
+
+	JyRelationManageFilter struct {
+		BuySubject       int      `json:"buySubject"`
+		ComboId          int      `json:"comboId"`          //套餐id
+		BuyAccountCount  int      `json:"buyAccountCount"`  //购买数量
+		GiftAccountCount int      `json:"giftAccountCount"` //赠送数量
+		BuyCycle         int      `json:"buy_cycle"`        //购买周期
+		BuyType          int      `json:"buy_type"`         //购买周期 类型 1天 2月 3年 4季
+		GiftCycle        int      `json:"give_cycle"`       //赠送周期
+		GiftType         int      `json:"give_type"`        //赠送周期 类型 1天 2月 3年 4季
+		ServiceIds       []string `json:"serviceIds"`       //服务id
+
+		SupServiceIds     []string `json:"supServiceIds"`     //补充服务id
+		FinalAccountCount int      `json:"finalAccountCount"` //当前套餐最终
+		FinalAreaCount    int      `json:"finalAreaCount"`
+	}
+)

+ 29 - 17
internal/model/jyProductDetail.go

@@ -3,22 +3,34 @@ package model
 import "time"
 
 type (
-	JyProductDetail struct {
-		OrderCode        string    `json:"order_code" gorm:"column:order_code"`                // 订单code
-		ProductType      string    `json:"product_type" gorm:"column:product_type"`            // 订单类型
-		Phone            string    `json:"phone" gorm:"column:phone"`                          // 开通服务手机号
-		UserID           string    `json:"user_id" gorm:"column:user_id"`                      // 开通账户id
-		OriginalPrice    int       `json:"original_price" gorm:"column:original_price"`        // 原价
-		FinalPrice       int       `json:"final_price" gorm:"column:final_price"`              // 最终价格
-		ProductID        string    `json:"product_id" gorm:"column:product_id"`                // 常规产品id
-		ActivityID       string    `json:"activity_id" gorm:"column:activity_id"`              // 活动产品id
-		Filter           string    `json:"filter" gorm:"column:filter"`                        // 单个服务业务字段
-		ServiceOpen      string    `json:"service_open" gorm:"column:service_open"`            // 服务状态
-		ServiceOpenTime  time.Time `json:"service_open_time" gorm:"column:service_open_time"`  // 服务开通时间
-		BillingMode      string    `json:"billing_mode" gorm:"column:billing_mode"`            // 销售策略
-		ServiceStartTime time.Time `json:"service_start_time" gorm:"column:service_starttime"` // 开始日期
-		ServiceEndTime   time.Time `json:"service_end_time" gorm:"column:service_endtime"`     // 结束日期
-		ServiceType      int       `json:"service_type" gorm:"column:service_type"`            // 服务类型
-		LinkedDetailID   string    `json:"linked_detail_id" gorm:"column:linked_detail_id"`    // 关联明细表id
+	JyBigParams struct {
+		*ProductCommonParam
+		ProductType       string    `json:"productType,omitempty"`                             //产品类型
+		UserId            string    `json:"userId,omitempty"`                                  //产品类型
+		MogUserId         string    `json:"mgoUserId,omitempty"`                               //产品类型
+		RecordPayType     int       `form:"recordPayType" json:"recordPayType,omitempty"`      //付费类型 1:购买 2:续费 3:升级 4:试用
+		LinkedOrderId     int64     `json:"linkedOrderId,omitempty"`                           //关联订单明细id
+		PaybackOpenServer bool      `json:"paybackOpenServer,omitempty"`                       //是否全额回款开通
+		PayMoney          int       `form:"payMoney" json:"payMoney,omitempty"`                //合同金额
+		ServiceOpenTime   time.Time `json:"service_open_time" gorm:"column:service_open_time"` // 服务开通时间
+
+		ServiceStartTime time.Time          `json:"service_start_time" gorm:"column:service_starttime"` // 开始日期
+		ServiceEndTime   time.Time          `json:"service_end_time" gorm:"column:service_endtime"`     // 结束日期
+		Filter           JyBigProductFilter `json:"filter,omitempty"`                                   //大字段
+	}
+
+	JyBigProductFilter struct {
+		BuyAccountCount  int `json:"buyAccountCount"`  //购买数量
+		GiftAccountCount int `json:"giftAccountCount"` //赠送数量
+
+		BuyCycle   int      `json:"buy_cycle"`  //购买周期
+		BuyType    int      `json:"buy_type"`   //购买周期 类型 1天 2月 3年 4季度
+		GiftCycle  int      `json:"give_cycle"` //赠送周期
+		GiftType   int      `json:"give_type"`  //赠送周期 类型 1天 2月 3年 4季度
+		ServiceIds []string `json:"serviceIds"` //服务id
+
+		SupServiceIds     []string `json:"supServiceIds"`
+		FinalAccountCount int      `json:"finalAccountCount"` //当前套餐最终
+		FinalAreaCount    int      `json:"finalAreaCount"`
 	}
 )

+ 1 - 1
internal/model/orderParams.go

@@ -149,7 +149,7 @@ type (
 		OrderMoney        int    `form:"orderMoney" json:"orderMoney,omitempty"`       //标准售价
 		PayMoney          int    `form:"payMoney" json:"payMoney,omitempty"`           //合同金额
 	}
-	//EntServiceParams 人脉管理、阳光采购、物业数字化营销、运营商专版、医械通、企业商机管理:购买、续费、升级-增购子账号
+	//EntServiceParams 人脉管理、阳光采购、物业数字化营销、运营商专版、医械通、企业商机管理:购买
 	EntServiceParams struct {
 		*ProductCommonParam
 		OrderCode          string `json:"orderCode"`