|
@@ -54,7 +54,7 @@ func (p jyBigProduct) GetPrice() (price int64, err error) {
|
|
|
if p.param.Filter.ComboId != 0 { //套餐
|
|
|
price = thisPriceSetting.UnityPrice(gconv.Float64(p.param.Filter.BuyCycle+p.param.Filter.GiftCycle), cycleType, gconv.Int(finalAccountCount), 0, p.param.ReqSubject == 2)
|
|
|
} else if len(p.param.Filter.ServiceIds) > 0 { //自定义
|
|
|
- price = DiyBigMember(context.Background(), 1, gconv.Int(finalAccountCount+1), utility.GetMonthNum(p.param.Filter.BuyCycle+p.param.Filter.GiftCycle, cycleType), p.param.UserId, p.param.Filter.ServiceIds, p.param.ReqSubject == 2)
|
|
|
+ price = DiyBigMember(context.Background(), 1, gconv.Int(finalAccountCount+1), utility.GetMonthNum(p.param.Filter.BuyCycle+p.param.Filter.GiftCycle, cycleType), nil, p.param.Filter.ServiceIds, p.param.ReqSubject == 2)
|
|
|
//获取各个服务
|
|
|
/*var (
|
|
|
diyPrice, specialPrice int64
|
|
@@ -95,10 +95,6 @@ func (p jyBigProduct) GetPrice() (price int64, err error) {
|
|
|
return 0, fmt.Errorf("查询关联订单异常")
|
|
|
}
|
|
|
|
|
|
- //filter, _, _, err := common2.GetLinkBigCycleFilter(context.Background(), p.param.LinkedOrderId)
|
|
|
- //if err != nil {
|
|
|
- // return 0, err
|
|
|
- //}
|
|
|
finalAccountCount := gconv.Int64(count - 1)
|
|
|
if gconv.String(re.Map()["code"]) != "dyh001" {
|
|
|
//套餐
|
|
@@ -145,6 +141,10 @@ func (p jyBigProduct) GetPrice() (price int64, err error) {
|
|
|
}*/
|
|
|
price += thisPriceSetting.UnityPrice(gconv.Float64(p.param.Filter.BuyCycle+p.param.Filter.GiftCycle), cycleType, gconv.Int(finalAccountCount), 0, p.param.ReqSubject == 2)
|
|
|
} else { //自定义
|
|
|
+ filter, _, _, err := common2.GetLinkBigCycleFilter(context.Background(), p.param.LinkedOrderId)
|
|
|
+ if err != nil {
|
|
|
+ return 0, err
|
|
|
+ }
|
|
|
//获取各个服务
|
|
|
/*var (
|
|
|
diyPrice, specialPrice int64
|
|
@@ -167,7 +167,7 @@ func (p jyBigProduct) GetPrice() (price int64, err error) {
|
|
|
}
|
|
|
}
|
|
|
price = thisPriceSetting.UnityPrice(p.param.Filter.BuyCycle+p.param.Filter.GiftCycle, cycleType, gconv.Int(finalAccountCount), gconv.Int(diyPrice), p.param.ReqSubject == 2) + specialPrice*/
|
|
|
- price = DiyBigMember(context.Background(), 3, gconv.Int(finalAccountCount+1), utility.GetMonthNum(p.param.Filter.BuyCycle+p.param.Filter.GiftCycle, cycleType), p.param.UserId, p.param.Filter.ServiceIds, p.param.ReqSubject == 2)
|
|
|
+ price = DiyBigMember(context.Background(), 3, gconv.Int(finalAccountCount+1), utility.GetMonthNum(p.param.Filter.BuyCycle+p.param.Filter.GiftCycle, cycleType), filter.ServiceIds, p.param.Filter.ServiceIds, p.param.ReqSubject == 2)
|
|
|
}
|
|
|
|
|
|
case 3: //升级
|
|
@@ -176,7 +176,7 @@ func (p jyBigProduct) GetPrice() (price int64, err error) {
|
|
|
//if err != nil {
|
|
|
// return 0, fmt.Errorf("查询关联订单异常")
|
|
|
//}
|
|
|
- _, _, entTime, err := common2.GetLinkBigCycleFilter(context.Background(), p.param.LinkedOrderId)
|
|
|
+ filter, _, entTime, err := common2.GetLinkBigCycleFilter(context.Background(), p.param.LinkedOrderId)
|
|
|
if err != nil {
|
|
|
return 0, fmt.Errorf("查询关联订单异常")
|
|
|
}
|
|
@@ -190,7 +190,7 @@ func (p jyBigProduct) GetPrice() (price int64, err error) {
|
|
|
if p.param.ProductCode != "dyh001" { //升级子账号
|
|
|
price = thisPriceSetting.UnityPrice(gconv.Float64(utility.GetMonthDayNum(time.Now(), entTime)), 2, gconv.Int(finalAccountCount), 0, p.param.ReqSubject == 2, "1")
|
|
|
} else { //补充服务和升级子账号
|
|
|
- price = DiyBigMember(context.Background(), 2, gconv.Int(finalAccountCount), utility.GetMonthNumTime(time.Now(), entTime), p.param.UserId, p.param.Filter.SupServiceIds, p.param.ReqSubject == 2)
|
|
|
+ price = DiyBigMember(context.Background(), 2, gconv.Int(finalAccountCount), utility.GetMonthNumTime(time.Now(), entTime), filter.ServiceIds, p.param.Filter.SupServiceIds, p.param.ReqSubject == 2)
|
|
|
}
|
|
|
|
|
|
/*mNum, day := utility.GetMonthDayNum(time.Now(), entTime)
|
|
@@ -262,7 +262,7 @@ func GetMonthDisc(monthCount int) float64 {
|
|
|
return monthDiscount * gconv.Float64(monthCount)
|
|
|
}
|
|
|
|
|
|
-func DiyBigMember(ctx context.Context, createType, count int, month int, userId string, serversId []string, isEnt bool) int64 {
|
|
|
+func DiyBigMember(ctx context.Context, createType, count int, month int, serversId, supServersId []string, isEnt bool) int64 {
|
|
|
var (
|
|
|
price float64
|
|
|
subAccountPrice, packPrice, primaryAccountPrice int
|
|
@@ -280,41 +280,43 @@ func DiyBigMember(ctx context.Context, createType, count int, month int, userId
|
|
|
idArr := map[int]bool{}
|
|
|
var dataService int
|
|
|
if createType == 2 {
|
|
|
- serOneData, _ := g.DB().GetOne(context.Background(), fmt.Sprintf(`SELECT id,i_price_year,s_new_name FROM bigmember_service WHERE i_class=4 and id in ('%s') order by i_price_year desc limit 1`, strings.Join(serversId, `','`)))
|
|
|
+ serOneData, _ := g.DB().GetOne(context.Background(), fmt.Sprintf(`SELECT id,i_price_year,s_new_name FROM bigmember_service WHERE i_class=4 and id in ('%s') order by i_price_year desc limit 1`, strings.Join(supServersId, `','`)))
|
|
|
if !serOneData.IsEmpty() {
|
|
|
dataService = gconv.Int(serOneData.Map()["i_price_year"])
|
|
|
}
|
|
|
//补充服务
|
|
|
//价格计算需要去掉之前购买服务
|
|
|
- userServer, _ := g.DB().Query(ctx, "SELECT * FROM bigmember_service_user WHERE s_userid = ? and i_status =0", userId)
|
|
|
- if !userServer.IsEmpty() {
|
|
|
- isHUa, _ := g.DB().GetCount(ctx, `SELECT count(1) as count FROM bigmember_service_user WHERE s_userid = ? and i_status =0 and (s_serviceid=4 or s_serviceid =19)`, userId)
|
|
|
- for _, v := range userServer.List() {
|
|
|
- if isHUa > 0 && v["s_serviceid"] == 26 {
|
|
|
- continue
|
|
|
- }
|
|
|
- if common.IntAll(v["s_smainid"]) == 0 {
|
|
|
- if common.IntAll(v["s_serviceid"]) == 12 {
|
|
|
- idArr[23] = true
|
|
|
- } else {
|
|
|
- idArr[common.IntAll(v["s_serviceid"])] = true
|
|
|
- }
|
|
|
+ var isHUa bool
|
|
|
+ for _, s := range serversId {
|
|
|
+ if s == "4" || s == "19" {
|
|
|
+ isHUa = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, v := range serversId {
|
|
|
+ if isHUa && v == "26" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if common.IntAll(v) == 0 {
|
|
|
+ if v == "12" {
|
|
|
+ idArr[23] = true
|
|
|
} else {
|
|
|
- if common.IntAll(v["s_smainid"]) == 12 {
|
|
|
- idArr[23] = true
|
|
|
- } else {
|
|
|
- idArr[common.IntAll(v["s_serviceid"])] = true
|
|
|
- }
|
|
|
+ idArr[common.IntAll(v)] = true
|
|
|
}
|
|
|
- if common.IntAll(v["s_serviceid"]) == 12 {
|
|
|
- idArr[20] = true
|
|
|
+ } else {
|
|
|
+ if v == "12" {
|
|
|
idArr[23] = true
|
|
|
+ } else {
|
|
|
+ idArr[common.IntAll(v)] = true
|
|
|
}
|
|
|
}
|
|
|
+ if v == "12" {
|
|
|
+ idArr[20] = true
|
|
|
+ idArr[23] = true
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- for _, v := range serversId {
|
|
|
+ for _, v := range supServersId {
|
|
|
if common.IntAll(v) == 3 || common.IntAll(v) == 13 || common.IntAll(v) == 21 {
|
|
|
continue
|
|
|
}
|