Browse Source

新增区县设置

WH01243 1 year ago
parent
commit
404821da8c

+ 8 - 8
src/jfw/modules/bigmember/src/db.json

@@ -15,7 +15,7 @@
       "password": "123456"
     },
     "ent": {
-      "address": "192.168.3.207:27001,192.168.3.206:27002",
+      "address": "192.168.3.206:27002",
       "size": 5,
       "dbName": "mixdata",
       "replSet": "",
@@ -25,7 +25,7 @@
       "password": "jy@DevGroup"
     },
     "bidding": {
-      "address": "192.168.3.207:27001,192.168.3.206:27002",
+      "address": "192.168.3.206:27002",
       "size": 5,
       "dbName": "qfw_data",
       "collection": "bidding",
@@ -36,11 +36,11 @@
   },
   "elasticsearch": {
     "main": {
-        "address": "http://192.168.3.241:9205",
-        "size": 30,
-		    "version": "v7",
-		    "userName": "",
-		    "password": ""
+      "address": "http://192.168.3.241:9205",
+      "size": 30,
+      "version": "v7",
+      "userName": "",
+      "password": ""
     }
   },
   "redis": {
@@ -67,7 +67,7 @@
     },
     "push": {
       "dbName": "jianyu",
-      "address": "192.168.3.11:3366",
+      "address": "192.168.3.149:3306",
       "userName": "root",
       "passWord": "Topnet123",
       "maxOpenConns": 5,

+ 30 - 0
src/jfw/modules/bigmember/src/service/use/use.go

@@ -3,6 +3,7 @@ package use
 import (
 	"encoding/json"
 	"fmt"
+	"github.com/gogf/gf/v2/util/gconv"
 	"jy/src/jfw/modules/bigmember/src/config"
 	"jy/src/jfw/modules/bigmember/src/db"
 	"jy/src/jfw/modules/bigmember/src/entity"
@@ -249,6 +250,35 @@ func (u *Use) Info() {
 				if (*o_member_jy)["o_area"] == nil {
 					(*o_member_jy)["o_area"] = map[string]interface{}{}
 				}
+				regionMap := map[string]map[string][]string{}
+				if (*o_member_jy)["o_area"] != nil {
+					district := map[string]interface{}{}
+					if (*o_member_jy)["o_district"] != nil {
+						district = *qu.ObjToMap((*o_member_jy)["o_district"])
+					}
+					o_area := (*o_member_jy)["o_area"]
+					for k, v := range *qu.ObjToMap(o_area) {
+						areaMap := map[string][]string{}
+						if k == "北京" || k == "天津" || k == "上海" || k == "重庆" {
+							city := fmt.Sprintf("%s市", k)
+							if district[city] != nil {
+								v = city
+							}
+						}
+						for _, city := range gconv.Strings(v) {
+							if city == "" {
+								continue
+							}
+							if district[city] != nil {
+								areaMap[city] = gconv.Strings(district[city])
+							} else {
+								areaMap[city] = []string{}
+							}
+						}
+						regionMap[k] = areaMap
+					}
+				}
+				(*o_member_jy)["regionMap"] = regionMap
 				//大会员默认全国
 				//大会员单省版本
 				(*o_member_jy)["i_areacount"] = qu.IntAllDef((*o_member_jy)["i_areacount"], -1)

+ 34 - 31
src/jfw/modules/publicapply/src/subscribePush/entity/setting.go

@@ -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

+ 2 - 1
src/jfw/modules/publicapply/src/subscribePush/service/subscribe.go

@@ -36,6 +36,7 @@ func (s *Subscribe) Update() {
 		EntId:     ent_id,
 		EntUserId: entUserId,
 		Session:   s.Session(),
+		District:  *qutil.ObjToMap(s.GetString("district")),
 	}
 	r := sub.SetAreaAndIndustry()
 	if r.Err != nil {
@@ -44,7 +45,7 @@ func (s *Subscribe) Update() {
 	s.ServeJson(r.Format())
 }
 
-//关键词、关键词匹配方式、信息类型、项目匹配
+// 关键词、关键词匹配方式、信息类型、项目匹配
 func (s *Subscribe) SetUserInfo() {
 	r := map[string]interface{}{}
 	userId := qutil.ObjToString(s.GetSession("userId"))

+ 39 - 7
src/jfw/modules/subscribepay/src/service/vipSubscribeChange.go

@@ -2,6 +2,8 @@ package service
 
 import (
 	"errors"
+	"fmt"
+	"github.com/gogf/gf/v2/util/gconv"
 	"jy/src/jfw/modules/subscribepay/src/config"
 	"jy/src/jfw/modules/subscribepay/src/entity"
 	"jy/src/jfw/modules/subscribepay/src/util"
@@ -17,7 +19,7 @@ import (
 	"go.mongodb.org/mongo-driver/bson"
 )
 
-//订阅修改 or 升级
+// 订阅修改 or 升级
 type SubscribeChange struct {
 	*xweb.Action
 	getSubBuyMsg   xweb.Mapper `xweb:"/vipsubscribe/getSubBuyMsg"`   //获取vip订阅详情
@@ -125,7 +127,7 @@ func (this *SubscribeChange) EffectiveTime() {
 	this.ServeJson(r.Format())
 }
 
-//获取购买订阅相关信息
+// 获取购买订阅相关信息
 func (this *SubscribeChange) GetSubBuyMsg() {
 	userId := qutil.ObjToString(this.GetSession("userId"))
 	r := func() *entity.FuncResult {
@@ -147,9 +149,39 @@ func (this *SubscribeChange) GetSubBuyMsg() {
 			}
 		}
 		bigPower := jy.GetBigVipUserBaseMsg(this.Session(), *config.Middleground)
+		//区域格式化
+		regionMap := map[string]map[string][]string{}
+		if (*o_vipjy)["o_area"] != nil {
+			district := map[string]interface{}{}
+			if (*o_vipjy)["o_district"] != nil {
+				district = *qutil.ObjToMap((*o_vipjy)["o_district"])
+			}
+			o_area := (*o_vipjy)["o_area"]
+			for k, v := range *qutil.ObjToMap(o_area) {
+				areaMap := map[string][]string{}
+				if k == "北京" || k == "天津" || k == "上海" || k == "重庆" {
+					city := fmt.Sprintf("%s市", k)
+					if district[city] != nil {
+						v = city
+					}
+				}
+				for _, city := range gconv.Strings(v) {
+					if city == "" {
+						continue
+					}
+					if district[city] != nil {
+						areaMap[city] = gconv.Strings(district[city])
+					} else {
+						areaMap[city] = []string{}
+					}
+				}
+				regionMap[k] = areaMap
+			}
+		}
 		return &entity.FuncResult{true, nil, map[string]interface{}{
 			"isTrial":         vipStatus == 1,
 			"area":            (*o_vipjy)["o_area"],
+			"regionMap":       regionMap,
 			"industry":        (*o_vipjy)["a_buyerclass"],
 			"buyset":          buyset,
 			"renewList":       renewList,
@@ -174,7 +206,7 @@ func (this *SubscribeChange) GetSubBuyMsg() {
 	this.ServeJson(r.Format())
 }
 
-//订阅修改
+// 订阅修改
 func (this *SubscribeChange) SaveChange() {
 	area := qutil.ObjToMap(this.GetString("area"))
 	industry := strings.Split(this.GetString("industry"), ",")
@@ -208,7 +240,7 @@ func (this *SubscribeChange) SaveChange() {
 	this.ServeJson(r.Format())
 }
 
-//免费用户设置超级订阅(体验)
+// 免费用户设置超级订阅(体验)
 func (this *SubscribeChange) FreeSaveChange() {
 	area := qutil.ObjToMap(this.GetString("area"))
 	industry := strings.Split(this.GetString("industry"), ",")
@@ -453,7 +485,7 @@ func (this *SubscribeChange) FreeSaveChange() {
 //    this.ServeJson(r.Format())
 //}
 
-//获取新版超级订阅升级价格、清单
+// 获取新版超级订阅升级价格、清单
 func getNewUpgradeDetail(userId string, newBuySet, oldBuySet *entity.SubvipBuySet, oldEndtime int64, count, unit int) (totalPrice int, subtotals []map[string]interface{}) {
 	rResult, ok := util.MQFW.Find("vip_upgrade", &bson.M{"s_userid": userId, "i_isvalid": 0}, `{"l_validtime":1}`, `{"o_buyset":1,"l_validtime":1}`, false, -1, -1)
 	if !ok {
@@ -514,7 +546,7 @@ func getNewUpgradeDetail(userId string, newBuySet, oldBuySet *entity.SubvipBuySe
 	return totalPrice, subtotals
 }
 
-//是否需要升级
+// 是否需要升级
 func needUpgrade(newBuySet, oldBuySet *entity.SubvipBuySet) bool {
 	if newBuySet.Upgrade != 1 { //旧版本订阅是否需要升级校验
 		BuyerclassUpgrade, AreaNeedUpgrade := false, false
@@ -705,7 +737,7 @@ func (this *SubscribeChange) MergeIndustry() {
 	this.ServeJson(r.Format())
 }
 
-//超级订阅优化,免费订阅判断新老用户  1:新用户 0:老用户
+// 超级订阅优化,免费订阅判断新老用户  1:新用户 0:老用户
 func NewUserByVIP(userId string, session *httpsession.Session) int {
 	mData := util.Compatible.Select(userId, `{"o_jy":1,"l_registedate":1}`)
 	if len(*mData) == 0 || mData == nil {