|
@@ -17,7 +17,7 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-//订阅设置设置修改
|
|
|
+// 订阅设置设置修改
|
|
|
type SubscribeSet struct {
|
|
|
Area map[string]interface{} //地区
|
|
|
Industry []string //行业
|
|
@@ -26,6 +26,7 @@ type SubscribeSet struct {
|
|
|
EntId int
|
|
|
EntUserId int
|
|
|
Session *httpsession.Session
|
|
|
+ District map[string]interface{} //地区
|
|
|
}
|
|
|
|
|
|
func (this *SubscribeSet) SetAreaAndIndustry() *FuncResult {
|
|
@@ -33,17 +34,17 @@ func (this *SubscribeSet) SetAreaAndIndustry() *FuncResult {
|
|
|
industry := this.Industry
|
|
|
userId := this.UserId
|
|
|
typ := this.Type
|
|
|
+ district := this.District
|
|
|
if typ == "m" {
|
|
|
- return memberSet(area, industry, userId, this.Session)
|
|
|
+ return memberSet(area, district, industry, userId, this.Session)
|
|
|
} else if typ == "v" {
|
|
|
- return vipSet(area, industry, userId, this.Session)
|
|
|
+ return vipSet(area, district, industry, userId, this.Session)
|
|
|
} else {
|
|
|
- return freeSet(area, industry, userId, this.Session)
|
|
|
+ return freeSet(area, district, industry, userId, this.Session)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//
|
|
|
-func freeSet(area map[string]interface{}, industry []string, userId string, session *httpsession.Session) *FuncResult {
|
|
|
+func freeSet(area, district map[string]interface{}, industry []string, userId string, session *httpsession.Session) *FuncResult {
|
|
|
//isfirst:是否第一次设置地区;ppb:是否购买省级订阅包; areacount:省份订阅包购买的省份数量-1:全国 无限制调整
|
|
|
isfirst, ppb, areacount := IsCanSet(userId, area, session)
|
|
|
//购买省份订阅包 已调整地区次数
|
|
@@ -80,7 +81,7 @@ func freeSet(area map[string]interface{}, industry []string, userId string, sess
|
|
|
AppId: "10000",
|
|
|
})
|
|
|
config.Middleground.PowerCheckCenter.DelCheckRedis("10000", qutil.Int64All(positionId))
|
|
|
- if !FreeSubChange(userId, &area, industry, ppb, isfirst) {
|
|
|
+ if !FreeSubChange(userId, &area, &district, industry, ppb, isfirst) {
|
|
|
return &FuncResult{false, errors.New("保存修改出错"), nil}
|
|
|
} else if issetredis { //更新调整次数 非全国(第一次 不消耗次数)
|
|
|
//优先使用省份订阅包次数
|
|
@@ -104,11 +105,12 @@ func freeSet(area map[string]interface{}, industry []string, userId string, sess
|
|
|
}}
|
|
|
}
|
|
|
|
|
|
-//免费用户地区调整
|
|
|
-func FreeSubChange(userId string, area *map[string]interface{}, industry []string, ppb, isfirst bool) bool {
|
|
|
+// 免费用户地区调整
|
|
|
+func FreeSubChange(userId string, area, district *map[string]interface{}, industry []string, ppb, isfirst bool) bool {
|
|
|
setMap := map[string]interface{}{"$set": map[string]interface{}{
|
|
|
- "o_jy.o_area": area, //设置地区
|
|
|
- "o_jy.i_newfree": 1, //老免费用户=>新订阅设置页面 20211122
|
|
|
+ "o_jy.o_area": area, //设置地区
|
|
|
+ "o_jy.o_district": district, //设置地区
|
|
|
+ "o_jy.i_newfree": 1, //老免费用户=>新订阅设置页面 20211122
|
|
|
}}
|
|
|
if ppb {
|
|
|
setMap = map[string]interface{}{"$set": map[string]interface{}{
|
|
@@ -123,7 +125,7 @@ func FreeSubChange(userId string, area *map[string]interface{}, industry []strin
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
-//是否可进行地区调整
|
|
|
+// 是否可进行地区调整
|
|
|
func IsCanSet(userId string, areamap map[string]interface{}, session *httpsession.Session) (bool, bool, int) {
|
|
|
areacount := 0
|
|
|
myarea := []string{}
|
|
@@ -167,7 +169,6 @@ func IsCanSet(userId string, areamap map[string]interface{}, session *httpsessio
|
|
|
return o_jy["o_area"] == nil, qutil.IntAll(o_jy["i_ppstatus"]) > 0, areacount
|
|
|
}
|
|
|
|
|
|
-//
|
|
|
func areaSort(area []string) string {
|
|
|
sort.Slice(area, func(i, j int) bool {
|
|
|
return area[i] < area[j]
|
|
@@ -175,8 +176,7 @@ func areaSort(area []string) string {
|
|
|
return strings.Join(area, ",")
|
|
|
}
|
|
|
|
|
|
-//
|
|
|
-func vipSet(area map[string]interface{}, industry []string, userId string, session *httpsession.Session) *FuncResult {
|
|
|
+func vipSet(area, district map[string]interface{}, industry []string, userId string, session *httpsession.Session) *FuncResult {
|
|
|
if len(industry) == 1 && industry[0] == "" {
|
|
|
industry = []string{}
|
|
|
}
|
|
@@ -188,13 +188,13 @@ func vipSet(area map[string]interface{}, industry []string, userId string, sessi
|
|
|
if rData == nil || len(*rData) == 0 {
|
|
|
return &FuncResult{false, errors.New("获取信息失败"), nil}
|
|
|
}
|
|
|
- newBuyset := NewBuySet(&area, industry, oldBuyset.Upgrade == 1)
|
|
|
+ newBuyset := NewBuySet(&area, &district, industry, oldBuyset.Upgrade == 1)
|
|
|
|
|
|
if needUpgrade := needUpgrade(newBuyset, oldBuyset); needUpgrade {
|
|
|
log.Printf("%s 订阅内容超出套餐 %+v area:%v industry:%v", userId, oldBuyset, area, industry)
|
|
|
return &FuncResult{false, errors.New("订阅内容超出套餐"), nil}
|
|
|
}
|
|
|
- if !VipSubChange(userId, qutil.ObjToMap((*rData)["o_vipjy"]), &area, industry, session) {
|
|
|
+ if !VipSubChange(userId, qutil.ObjToMap((*rData)["o_vipjy"]), &area, &district, industry, session) {
|
|
|
return &FuncResult{false, errors.New("保存修改出错"), nil}
|
|
|
}
|
|
|
|
|
@@ -204,8 +204,8 @@ func vipSet(area map[string]interface{}, industry []string, userId string, sessi
|
|
|
}}
|
|
|
}
|
|
|
|
|
|
-//大会员订阅设置
|
|
|
-func memberSet(area map[string]interface{}, industry []string, userId string, session *httpsession.Session) *FuncResult {
|
|
|
+// 大会员订阅设置
|
|
|
+func memberSet(area, district map[string]interface{}, industry []string, userId string, session *httpsession.Session) *FuncResult {
|
|
|
if data := jy.GetBigVipUserBaseMsg(session, *config.Middleground); data.Status <= 0 {
|
|
|
return &FuncResult{false, errors.New("请求异常,非大会员状态"), nil}
|
|
|
}
|
|
@@ -218,7 +218,7 @@ func memberSet(area map[string]interface{}, industry []string, userId string, se
|
|
|
return &FuncResult{false, errors.New("订阅内容超出套餐"), nil}
|
|
|
}
|
|
|
positionType := qutil.Int64All(session.Get("positionType"))
|
|
|
- if !MemberSubChange(userId, &area, industry, session) {
|
|
|
+ if !MemberSubChange(userId, &area, &district, industry, session) {
|
|
|
return &FuncResult{false, errors.New("保存修改出错"), nil}
|
|
|
}
|
|
|
SetLog(userId, "o_member_jy", positionType, session)
|
|
@@ -227,7 +227,7 @@ func memberSet(area map[string]interface{}, industry []string, userId string, se
|
|
|
}}
|
|
|
}
|
|
|
|
|
|
-//购买内容
|
|
|
+// 购买内容
|
|
|
type SubvipBuySet struct {
|
|
|
Upgrade int `json:"upgrade"` //是否是升级版;1是 其他不是
|
|
|
AreaCount int `json:"areacount"` //-1 全国 >0 省份数量
|
|
@@ -248,8 +248,8 @@ func GetMemberDetail(userId string) (*map[string]interface{}, *SubvipBuySet, boo
|
|
|
}, i_member_status > 0
|
|
|
}
|
|
|
|
|
|
-//获取省份,城市,行业购买内容
|
|
|
-//[省份,城市,行业]
|
|
|
+// 获取省份,城市,行业购买内容
|
|
|
+// [省份,城市,行业]
|
|
|
func GetVipDetail(userId string) (*map[string]interface{}, *SubvipBuySet, bool) {
|
|
|
mData := config.Compatible.Select(userId, `{"o_vipjy":1,"i_vip_status":1,"l_vip_endtime":1,"l_vip_starttime":1,"isread":1}`)
|
|
|
if len(*mData) == 0 || mData == nil {
|
|
@@ -274,7 +274,7 @@ func init() {
|
|
|
qutil.ReadConfig("./subvip_price.json", &SubVipPrice)
|
|
|
}
|
|
|
|
|
|
-//价格表
|
|
|
+// 价格表
|
|
|
type subVipPrice struct {
|
|
|
Old struct {
|
|
|
Month struct {
|
|
@@ -321,8 +321,8 @@ type subVipPrice struct {
|
|
|
Discount float64 `json:"discount"` //折扣(测试使用)
|
|
|
}
|
|
|
|
|
|
-//超级订阅获取购买项
|
|
|
-func NewBuySet(area *map[string]interface{}, industry []string, isUpgrade bool) *SubvipBuySet {
|
|
|
+// 超级订阅获取购买项
|
|
|
+func NewBuySet(area, district *map[string]interface{}, industry []string, isUpgrade bool) *SubvipBuySet {
|
|
|
pCount := -1
|
|
|
citys := []int{}
|
|
|
if area != nil {
|
|
@@ -376,7 +376,7 @@ func NewBuySet(area *map[string]interface{}, industry []string, isUpgrade bool)
|
|
|
return &buyset
|
|
|
}
|
|
|
|
|
|
-//是否需要升级
|
|
|
+// 是否需要升级
|
|
|
func needUpgrade(newBuySet, oldBuySet *SubvipBuySet) bool {
|
|
|
if newBuySet.Upgrade != 1 { //旧版本订阅是否需要升级校验
|
|
|
BuyerclassUpgrade, AreaNeedUpgrade := false, false
|
|
@@ -541,12 +541,13 @@ func needUpgrade(newBuySet, oldBuySet *SubvipBuySet) bool {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//超级订阅 订阅修改
|
|
|
-func VipSubChange(userId string, oldVip, areaNew *map[string]interface{}, industryNew []string, session *httpsession.Session) bool {
|
|
|
+// 超级订阅 订阅修改
|
|
|
+func VipSubChange(userId string, oldVip, areaNew, district *map[string]interface{}, industryNew []string, session *httpsession.Session) bool {
|
|
|
updateOk := false
|
|
|
updateOk = config.Compatible.Update(userId,
|
|
|
map[string]interface{}{"$set": map[string]interface{}{
|
|
|
"o_vipjy.o_area": areaNew, //设置地区
|
|
|
+ "o_vipjy.o_district": district, //设置地区
|
|
|
"o_vipjy.a_buyerclass": industryNew, //设置行业
|
|
|
}})
|
|
|
|
|
@@ -560,6 +561,7 @@ func VipSubChange(userId string, oldVip, areaNew *map[string]interface{}, indust
|
|
|
"o_area_old": (*oldVip)["o_area"],
|
|
|
"a_buyerclass_old": (*oldVip)["a_buyerclass"],
|
|
|
"o_area": areaNew,
|
|
|
+ "o_district": district, //设置地区
|
|
|
"a_buyerclass": industryNew,
|
|
|
"l_changeTime": time.Now().Unix(),
|
|
|
})
|
|
@@ -568,11 +570,12 @@ func VipSubChange(userId string, oldVip, areaNew *map[string]interface{}, indust
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
-//超级订阅 订阅修改
|
|
|
-func MemberSubChange(userId string, areaNew *map[string]interface{}, industryNew []string, session *httpsession.Session) bool {
|
|
|
+// 超级订阅 订阅修改
|
|
|
+func MemberSubChange(userId string, areaNew, district *map[string]interface{}, industryNew []string, session *httpsession.Session) bool {
|
|
|
if updateOk := config.Compatible.Update(userId,
|
|
|
map[string]interface{}{"$set": map[string]interface{}{
|
|
|
"o_member_jy.o_area": areaNew, //设置地区
|
|
|
+ "o_member_jy.o_district": district, //设置地区
|
|
|
"o_member_jy.a_buyerclass": industryNew, //设置行业
|
|
|
}}); !updateOk {
|
|
|
return false
|