WH01243 2 år sedan
förälder
incheckning
49d73be187

+ 1 - 1
src/jfw/modules/publicapply/src/go.mod

@@ -4,7 +4,7 @@ go 1.18
 
 require (
 	app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a
-	app.yhyue.com/moapp/jypkg v0.0.0-20230208065001-1bb9895b1831
+	app.yhyue.com/moapp/jypkg v0.0.0-20230209022443-283a80f1b7fa
 	bp.jydev.jianyu360.cn/BaseService/userCenter v0.0.0-20230129060002-f69424aa14ba
 	github.com/SKatiyar/qr v0.0.0-20151201054752-25b6bdf44e67
 	github.com/gogf/gf/v2 v2.0.6

+ 175 - 194
src/jfw/modules/subscribepay/src/entity/member.go

@@ -1,18 +1,18 @@
 package entity
 
 import (
-	"encoding/json"
-	"fmt"
-	"jy/src/jfw/modules/subscribepay/src/config"
-	"jy/src/jfw/modules/subscribepay/src/util"
-	"log"
-	"strconv"
-	"strings"
-	"time"
+    "encoding/json"
+    "fmt"
+    "jy/src/jfw/modules/subscribepay/src/config"
+    "jy/src/jfw/modules/subscribepay/src/util"
+    "log"
+    "strconv"
+    "strings"
+    "time"
 
-	qutil "app.yhyue.com/moapp/jybase/common"
-	. "app.yhyue.com/moapp/jybase/date"
-	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+    qutil "app.yhyue.com/moapp/jybase/common"
+    . "app.yhyue.com/moapp/jybase/date"
+    "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
 )
 
 type memberStruct struct{}
@@ -21,197 +21,178 @@ var MemberStruct memberStruct
 var Bigmember_serice map[int]map[int]int //权益 k:子id ; v:map[int]int{父id:年数量}
 
 func init() {
-	log.Println("初始化大会员权益")
-	//初始化用户权益
-	member_serice := map[int]map[int]int{}
-	if rdata := util.Mysql.SelectBySql(`SELECT id,s_name,i_pid,s_count_year FROM bigmember_service`); rdata != nil && len(*rdata) > 0 {
-		for _, v := range *rdata {
-			sid := qutil.IntAll(v["id"])
-			pid := qutil.IntAll(v["i_pid"])
-			count_year := qutil.IntAll(v["s_count_year"])
-			// log.Println(pid, sid, count_year)
-			if pid != 0 {
-				member_serice[sid] = map[int]int{
-					pid: count_year,
-				}
-			} else {
-				member_serice[sid] = map[int]int{
-					sid: count_year,
-				}
-			}
-		}
-	}
-	Bigmember_serice = member_serice
-	log.Println("初始化大会员权益已结束")
+    log.Println("初始化大会员权益")
+    //初始化用户权益
+    member_serice := map[int]map[int]int{}
+    if rdata := util.Mysql.SelectBySql(`SELECT id,s_name,i_pid,s_count_year FROM bigmember_service`); rdata != nil && len(*rdata) > 0 {
+        for _, v := range *rdata {
+            sid := qutil.IntAll(v["id"])
+            pid := qutil.IntAll(v["i_pid"])
+            count_year := qutil.IntAll(v["s_count_year"])
+            // log.Println(pid, sid, count_year)
+            if pid != 0 {
+                member_serice[sid] = map[int]int{
+                    pid: count_year,
+                }
+            } else {
+                member_serice[sid] = map[int]int{
+                    sid: count_year,
+                }
+            }
+        }
+    }
+    Bigmember_serice = member_serice
+    log.Println("初始化大会员权益已结束")
 }
 
 // 大会员支付完成回调方法
 func (m *memberStruct) PayCallBack(param *CallBackParam) bool {
-	orderdata := util.Mysql.FindOne("dataexport_order", param.GetPaySuccessOrderQuery(), "id,filter,order_code,order_status,user_id,vip_type,prepay_time", "")
-	if orderdata == nil {
-		return false
-	}
-	userId := qutil.ObjToString((*orderdata)["user_id"])
-	if qutil.IntAll((*orderdata)["order_status"]) == 0 {
-		now := time.Now()
-		nowFormat := FormatDate(&now, Date_Full_Layout)
-		var filter map[string]interface{}
-		if err := json.Unmarshal([]byte(qutil.ObjToString((*orderdata)["filter"])), &filter); err != nil {
-			log.Println("大会员支付成功json.Unmarshal出错", err)
-		} else {
-			cycle := qutil.IntAll(filter["cycle"])
-			level := qutil.IntAll(filter["level"])
-			var enddate = time.Now()
-			if level == 4 { //试用用户 试用七天
-				enddate = time.Date(now.Year(), now.Month(), now.Day()+cycle, 23, 59, 59, 0, time.Local)
-			} else {
-				enddate = time.Date(now.Year()+cycle, now.Month(), now.Day(), 23, 59, 59, 0, time.Local)
-			}
-			normal_member(level, enddate, userId, 0, 0, 0)
-			update := util.Mysql.Update("dataexport_order", map[string]interface{}{
-				"id": (*orderdata)["id"],
-			}, map[string]interface{}{
-				"pay_money":     param.CashFee,
-				"pay_time":      nowFormat,
-				"order_status":  1,
-				"vip_starttime": nowFormat,
-				"vip_endtime":   FormatDate(&enddate, Date_Full_Layout),
-				//支付成功后更新成支付成功的out_trade_no 避免多人支付重复刷新字段
-				"out_trade_no": param.OutTradeno,
-			})
-			if update {
-				util.MsgRemind.BigMemberPaySuccess(qutil.IntAll((*orderdata)["id"]), qutil.ObjToString((*orderdata)["order_code"]), qutil.ObjToString((*orderdata)["user_id"]), qutil.ObjToString((*orderdata)["prepay_time"]), qutil.IntAllDef((*orderdata)["vip_type"], -1))
-				//取消其他订单
-				go PayCancel(userId, "大会员", "")
-			}
-		}
-	}
-	return true
+    orderdata := util.Mysql.FindOne("dataexport_order", param.GetPaySuccessOrderQuery(), "id,filter,order_code,order_status,user_id,vip_type,prepay_time", "")
+    if orderdata == nil {
+        return false
+    }
+    userId := qutil.ObjToString((*orderdata)["user_id"])
+    if qutil.IntAll((*orderdata)["order_status"]) == 0 {
+        now := time.Now()
+        nowFormat := FormatDate(&now, Date_Full_Layout)
+        var filter map[string]interface{}
+        if err := json.Unmarshal([]byte(qutil.ObjToString((*orderdata)["filter"])), &filter); err != nil {
+            log.Println("大会员支付成功json.Unmarshal出错", err)
+        } else {
+            cycle := qutil.IntAll(filter["cycle"])
+            level := qutil.IntAll(filter["level"])
+            var enddate = time.Now()
+            if level == 4 { //试用用户 试用七天
+                enddate = time.Date(now.Year(), now.Month(), now.Day()+cycle, 23, 59, 59, 0, time.Local)
+            } else {
+                enddate = time.Date(now.Year()+cycle, now.Month(), now.Day(), 23, 59, 59, 0, time.Local)
+            }
+            normal_member(level, enddate, userId, 0, 0, 0)
+            update := util.Mysql.Update("dataexport_order", map[string]interface{}{
+                "id": (*orderdata)["id"],
+            }, map[string]interface{}{
+                "pay_money":     param.CashFee,
+                "pay_time":      nowFormat,
+                "order_status":  1,
+                "vip_starttime": nowFormat,
+                "vip_endtime":   FormatDate(&enddate, Date_Full_Layout),
+                //支付成功后更新成支付成功的out_trade_no 避免多人支付重复刷新字段
+                "out_trade_no": param.OutTradeno,
+            })
+            if update {
+                util.MsgRemind.BigMemberPaySuccess(qutil.IntAll((*orderdata)["id"]), qutil.ObjToString((*orderdata)["order_code"]), qutil.ObjToString((*orderdata)["user_id"]), qutil.ObjToString((*orderdata)["prepay_time"]), qutil.IntAllDef((*orderdata)["vip_type"], -1))
+                //取消其他订单
+                go PayCancel(userId, "大会员", "")
+            }
+        }
+    }
+    return true
 }
 
 func normal_member(level int, enddate time.Time, userId string, positionType, entId, entUserId int64) {
-	//修改用户表权限
-	set := map[string]interface{}{}
-	if positionType == 0 {
-		set = map[string]interface{}{
-			"i_member_status":      level,
-			"i_member_starttime":   time.Now().Unix(),
-			"i_member_endtime":     enddate.Unix(),
-			"o_member_jy.i_wxpush": 1,
-		}
-	} else {
-		set = map[string]interface{}{
-			"i_status":            level,
-			"i_starttime":         time.Now().Unix(),
-			"i_endtime":           enddate.Unix(),
-			"o_entniche.i_wxpush": 1,
-		}
-	}
-	if level == 4 { //试用用户
-		set["i_member_trial"] = 1 //试用标识
-	} else {
-		//查看当前用户是否是试用用户 正在试用中(大会员状态ing)
-		userInfo := util.Compatible.Select(userId, `{"o_vipjy"}`)
-		if userInfo != nil && *userInfo != nil {
-			if (*userInfo)["i_member_status"] != nil && qutil.IntAll((*userInfo)["i_member_status"]) > 0 {
-				//禁用当前大会员服务
-				util.Mysql.UpdateOrDeleteBySql(`UPDATE `+jy.BigmemberUserPowerTable+` a SET a.i_frequency = 0 , a.i_status = -1, a.l_updatetime=? WHERE a.s_userid = ?`, NowFormat(Date_Full_Layout), userId)
-			}
-		}
-	}
-	if positionType == 0 {
-		util.MQFW.UpdateById("user", userId, map[string]interface{}{
-			"$set": set,
-		})
-	} else {
-		query := map[string]interface{}{
-			"i_userid": entUserId,
-			"i_entid":  entId,
-			"i_type":   1,
-		}
-		util.MQFW.Update("entniche_rule", query, map[string]interface{}{
-			"$set": set,
-		}, true, false)
-	}
-	//更新大会员用户服务表
-	bigmember_combo_list := util.Mysql.SelectBySql(`SELECT * FROM bigmember_combo a WHERE a.id = ?`, level)
-	serviceCode := "" //大会员服务id集合
-	if len(*bigmember_combo_list) > 0 {
-		list := (*bigmember_combo_list)[0]
-		serviceCode = list["s_servers"].(string)
-	}
-	if serviceCode != "" {
-		for _, v := range strings.Split(serviceCode, ",") {
-			var s_serviceid = v
-			var frequency = 0
-			sid, _ := strconv.Atoi(v)
-			if Bigmember_serice[sid] != nil {
-				for k, v := range Bigmember_serice[sid] {
-					s_serviceid = strconv.Itoa(k)
-					frequency = v
-				}
-			}
-			if util.Mysql.CountBySql(`select count(*) from `+jy.BigmemberUserPowerTable+` where s_userid=? and s_serviceid=?`, userId, v) == 0 {
-				insert := map[string]interface{}{
-					"s_userid":     userId,
-					"s_serviceid":  s_serviceid,
-					"i_frequency":  frequency,
-					"l_starttime":  NowFormat(Date_Full_Layout),
-					"l_endtime":    FormatDate(&enddate, Date_Full_Layout),
-					"i_status":     0,
-					"l_createtime": NowFormat(Date_Full_Layout),
-					"l_updatetime": NowFormat(Date_Full_Layout),
-					"s_smainid":    v,
-				}
-				order_id := util.Mysql.Insert(jy.BigmemberUserPowerTable, insert)
-				if order_id == 0 {
-					log.Println("保存出错:", userId, "---", v)
-				}
-			} else {
-				query := map[string]interface{}{
-					"s_userid":    userId,
-					"s_serviceid": s_serviceid,
-				}
-				update := map[string]interface{}{
-					"i_status":     0,
-					"i_frequency":  frequency,
-					"l_updatetime": NowFormat(Date_Full_Layout),
-					"l_endtime":    FormatDate(&enddate, Date_Full_Layout),
-					"s_smainid":    v,
-				}
-				if !util.Mysql.Update(jy.BigmemberUserPowerTable, query, update) {
-					log.Println("更新大会员用户服务表出错:", userId, v)
-				}
-			}
-		}
-		//redis 存储缓存
-		go func() {
-			if !jy.ClearBigVipUserPower(userId) {
-				log.Println("userid:", userId, "清除redis缓存失败-")
-			}
-		}()
-	} else {
-		log.Println("查询 大会员套餐 信息出错:", userId, ";大会员等级:", level)
-	}
+    //修改用户表权限
+    set := map[string]interface{}{}
+    set = map[string]interface{}{
+        "i_member_status":      level,
+        "i_member_starttime":   time.Now().Unix(),
+        "i_member_endtime":     enddate.Unix(),
+        "o_member_jy.i_wxpush": 1,
+    }
+
+    if level == 4 { //试用用户
+        set["i_member_trial"] = 1 //试用标识
+    } else {
+        //查看当前用户是否是试用用户 正在试用中(大会员状态ing)
+        userInfo := util.Compatible.Select(userId, `{"o_vipjy"}`)
+        if userInfo != nil && *userInfo != nil {
+            if (*userInfo)["i_member_status"] != nil && qutil.IntAll((*userInfo)["i_member_status"]) > 0 {
+                //禁用当前大会员服务
+                util.Mysql.UpdateOrDeleteBySql(`UPDATE `+jy.BigmemberUserPowerTable+` a SET a.i_frequency = 0 , a.i_status = -1, a.l_updatetime=? WHERE a.s_userid = ?`, NowFormat(Date_Full_Layout), userId)
+            }
+        }
+    }
+    util.Compatible.Update(userId, map[string]interface{}{
+        "$set": set,
+    })
+    //更新大会员用户服务表
+    bigmember_combo_list := util.Mysql.SelectBySql(`SELECT * FROM bigmember_combo a WHERE a.id = ?`, level)
+    serviceCode := "" //大会员服务id集合
+    if len(*bigmember_combo_list) > 0 {
+        list := (*bigmember_combo_list)[0]
+        serviceCode = list["s_servers"].(string)
+    }
+    if serviceCode != "" {
+        for _, v := range strings.Split(serviceCode, ",") {
+            var s_serviceid = v
+            var frequency = 0
+            sid, _ := strconv.Atoi(v)
+            if Bigmember_serice[sid] != nil {
+                for k, v := range Bigmember_serice[sid] {
+                    s_serviceid = strconv.Itoa(k)
+                    frequency = v
+                }
+            }
+            if util.Mysql.CountBySql(`select count(*) from `+jy.BigmemberUserPowerTable+` where s_userid=? and s_serviceid=?`, userId, v) == 0 {
+                insert := map[string]interface{}{
+                    "s_userid":     userId,
+                    "s_serviceid":  s_serviceid,
+                    "i_frequency":  frequency,
+                    "l_starttime":  NowFormat(Date_Full_Layout),
+                    "l_endtime":    FormatDate(&enddate, Date_Full_Layout),
+                    "i_status":     0,
+                    "l_createtime": NowFormat(Date_Full_Layout),
+                    "l_updatetime": NowFormat(Date_Full_Layout),
+                    "s_smainid":    v,
+                }
+                order_id := util.Mysql.Insert(jy.BigmemberUserPowerTable, insert)
+                if order_id == 0 {
+                    log.Println("保存出错:", userId, "---", v)
+                }
+            } else {
+                query := map[string]interface{}{
+                    "s_userid":    userId,
+                    "s_serviceid": s_serviceid,
+                }
+                update := map[string]interface{}{
+                    "i_status":     0,
+                    "i_frequency":  frequency,
+                    "l_updatetime": NowFormat(Date_Full_Layout),
+                    "l_endtime":    FormatDate(&enddate, Date_Full_Layout),
+                    "s_smainid":    v,
+                }
+                if !util.Mysql.Update(jy.BigmemberUserPowerTable, query, update) {
+                    log.Println("更新大会员用户服务表出错:", userId, v)
+                }
+            }
+        }
+        //redis 存储缓存
+        go func() {
+            if !jy.ClearBigVipUserPower(userId) {
+                log.Println("userid:", userId, "清除redis缓存失败-")
+            }
+        }()
+    } else {
+        log.Println("查询 大会员套餐 信息出错:", userId, ";大会员等级:", level)
+    }
 }
 
 func (m *memberStruct) GetMoney(userId string, level, cycle int) int {
-	if level > 7 || cycle < 1 {
-		log.Println(userId, "大会员订单level、cycle参数不合法", level, cycle)
-		return -1
-	}
-	var price float64
-	price = config.MemberConfig.Price[fmt.Sprintf("%v", level)] * float64(cycle)
-	if level == 4 {
-		price = config.MemberConfig.Price[fmt.Sprintf("%v", level)]
-	}
-	log.Println(level, " : ", price)
-	if price == 0 {
-		log.Println(userId, "大会员订单获取price错误")
-		return -1
-	}
-	if price < 1 {
-		price = 1
-	}
-	return int(price)
+    if level > 7 || cycle < 1 {
+        log.Println(userId, "大会员订单level、cycle参数不合法", level, cycle)
+        return -1
+    }
+    var price float64
+    price = config.MemberConfig.Price[fmt.Sprintf("%v", level)] * float64(cycle)
+    if level == 4 {
+        price = config.MemberConfig.Price[fmt.Sprintf("%v", level)]
+    }
+    log.Println(level, " : ", price)
+    if price == 0 {
+        log.Println(userId, "大会员订单获取price错误")
+        return -1
+    }
+    if price < 1 {
+        price = 1
+    }
+    return int(price)
 }

+ 115 - 115
src/jfw/modules/subscribepay/src/rpcfollow/share.go

@@ -1,129 +1,129 @@
 package rpcfollow
 
 import (
-	"encoding/json"
-	"jy/src/jfw/modules/subscribepay/src/config"
-	"jy/src/jfw/modules/subscribepay/src/entity"
-	"jy/src/jfw/modules/subscribepay/src/util"
-	"time"
+    "encoding/json"
+    "jy/src/jfw/modules/subscribepay/src/config"
+    "jy/src/jfw/modules/subscribepay/src/entity"
+    "jy/src/jfw/modules/subscribepay/src/util"
+    "time"
 
-	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
-	"go.mongodb.org/mongo-driver/bson/primitive"
+    "app.yhyue.com/moapp/jybase/go-xweb/httpsession"
+    "go.mongodb.org/mongo-driver/bson/primitive"
 
-	qu "app.yhyue.com/moapp/jybase/common"
-	. "app.yhyue.com/moapp/jybase/date"
-	frpc "app.yhyue.com/moapp/jybase/rpc"
-	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+    qu "app.yhyue.com/moapp/jybase/common"
+    . "app.yhyue.com/moapp/jybase/date"
+    frpc "app.yhyue.com/moapp/jybase/rpc"
+    "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
 )
 
 //用户分享完成后,分享者和被分享者订单处理
 func (s *JyPayRpc) ShareFissionNew(p *frpc.JYShareUserIdsRes, r *frpc.JYShareResp, sessVal map[string]interface{}) error {
-	if len(p.ShareUserInfo) > 0 {
-		errArr := []interface{}{}
-		for _, ps := range p.ShareUserInfo {
-			userId := ps.UserId
-			_, err := primitive.ObjectIDFromHex(userId)
-			if err != nil {
-				continue
-			}
-			data := util.Compatible.Select(userId, `{"i_vip_status":1,"l_vip_starttime":1,"l_vip_endtime":1,"o_vipjy":1,"i_shareCount":1,"s_m_openid":1}`)
-			if data != nil && len(*data) > 0 {
-				now := time.Now()
-				vip_status := qu.IntAll((*data)["i_vip_status"])
-				nowDay := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 59, now.Location()).Unix() //当前晚上23:59:59
-				endtime := qu.Int64All(qu.If(qu.Int64All((*data)["l_vip_endtime"]) < nowDay, nowDay, qu.Int64All((*data)["l_vip_endtime"])))
-				//更新user表
-				setMap := map[string]interface{}{}
-				var updateMap = map[string]interface{}{}
-				endT := time.Unix(endtime, 0).AddDate(0, 0, ps.TimeExpand)
-				types := 2 //默认开通权益
-				if vip_status == 2 {
-					types = 1 //仅延长周期
-					//超级订阅用户
-					updateMap = map[string]interface{}{
-						"l_vip_endtime": endT.Unix(),
-					}
-				} else if vip_status <= 0 {
-					var (
-						area      = map[string]interface{}{"北京": []string{}}
-						areaCount = 1
-					)
-					//22年双十一预热福利---2021年至今的免费用户
-					if ps.Remark == "22年双十一预热福利" {
-						//活动赠送7天  全国  超级订阅
-						area = map[string]interface{}{}
-						areaCount = -1
-					}
-					//非超级订阅用户
-					updateMap = map[string]interface{}{
-						"i_vip_status":                     2,
-						"l_vip_starttime":                  now.Unix(),
-						"l_vip_endtime":                    endT.Unix(),
-						"o_vipjy.o_area":                   area,
-						"o_vipjy.o_buyset.areacount":       areaCount,
-						"o_vipjy.o_buyset.buyerclasscount": -1,
-						"o_vipjy.o_buyset.upgrade":         1,
-						"o_vipjy.o_buyset.newcitys":        []string{},
-					}
-					if vip_status == 0 {
-						updateMap["o_vipjy.i_trial"] = -1
-						updateMap["o_vipjy.a_buyerclass"] = []string{}
-					}
-				}
-				setMap["$set"] = updateMap
-				if !util.MQFW.UpdateById("user", userId, setMap) {
-					errArr = append(errArr, map[string]interface{}{
-						"code":   -3,
-						"msg":    "更新用户超级订阅状态失败",
-						"userId": userId,
-					})
-				}
-				jy.ClearBigVipUserPower(userId)
-				st, et := "", ""
-				st = time.Unix(endtime, 0).Format(Date_Full_Layout)
-				et = endT.Format(Date_Full_Layout)
-				if !entity.Order(userId, st, et, types, ps.TimeExpand, ps.Remark) {
-					r.Error_code = -2
-					errArr = append(errArr, map[string]interface{}{
-						"code":   -2,
-						"msg":    "保存记录失败",
-						"userId": userId,
-					})
-				}
-			} else {
-				r.Error_code = -1
-				errArr = append(errArr, map[string]interface{}{
-					"code":   -1,
-					"msg":    "mgo获取用户信息失败",
-					"userId": userId,
-				})
-			}
-		}
-		if len(errArr) > 0 {
-			b, _ := json.Marshal(errArr)
-			r.Data = b
-		}
-	}
-	return nil
+    if len(p.ShareUserInfo) > 0 {
+        errArr := []interface{}{}
+        for _, ps := range p.ShareUserInfo {
+            userId := ps.UserId
+            _, err := primitive.ObjectIDFromHex(userId)
+            if err != nil {
+                continue
+            }
+            data := util.Compatible.Select(userId, `{"i_vip_status":1,"l_vip_starttime":1,"l_vip_endtime":1,"o_vipjy":1,"i_shareCount":1,"s_m_openid":1}`)
+            if data != nil && len(*data) > 0 {
+                now := time.Now()
+                vip_status := qu.IntAll((*data)["i_vip_status"])
+                nowDay := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 59, now.Location()).Unix() //当前晚上23:59:59
+                endtime := qu.Int64All(qu.If(qu.Int64All((*data)["l_vip_endtime"]) < nowDay, nowDay, qu.Int64All((*data)["l_vip_endtime"])))
+                //更新user表
+                setMap := map[string]interface{}{}
+                var updateMap = map[string]interface{}{}
+                endT := time.Unix(endtime, 0).AddDate(0, 0, ps.TimeExpand)
+                types := 2 //默认开通权益
+                if vip_status == 2 {
+                    types = 1 //仅延长周期
+                    //超级订阅用户
+                    updateMap = map[string]interface{}{
+                        "l_vip_endtime": endT.Unix(),
+                    }
+                } else if vip_status <= 0 {
+                    var (
+                        area      = map[string]interface{}{"北京": []string{}}
+                        areaCount = 1
+                    )
+                    //22年双十一预热福利---2021年至今的免费用户
+                    if ps.Remark == "22年双十一预热福利" {
+                        //活动赠送7天  全国  超级订阅
+                        area = map[string]interface{}{}
+                        areaCount = -1
+                    }
+                    //非超级订阅用户
+                    updateMap = map[string]interface{}{
+                        "i_vip_status":                     2,
+                        "l_vip_starttime":                  now.Unix(),
+                        "l_vip_endtime":                    endT.Unix(),
+                        "o_vipjy.o_area":                   area,
+                        "o_vipjy.o_buyset.areacount":       areaCount,
+                        "o_vipjy.o_buyset.buyerclasscount": -1,
+                        "o_vipjy.o_buyset.upgrade":         1,
+                        "o_vipjy.o_buyset.newcitys":        []string{},
+                    }
+                    if vip_status == 0 {
+                        updateMap["o_vipjy.i_trial"] = -1
+                        updateMap["o_vipjy.a_buyerclass"] = []string{}
+                    }
+                }
+                setMap["$set"] = updateMap
+                if !util.Compatible.Update(userId, setMap) {
+                    errArr = append(errArr, map[string]interface{}{
+                        "code":   -3,
+                        "msg":    "更新用户超级订阅状态失败",
+                        "userId": userId,
+                    })
+                }
+                jy.ClearBigVipUserPower(userId)
+                st, et := "", ""
+                st = time.Unix(endtime, 0).Format(Date_Full_Layout)
+                et = endT.Format(Date_Full_Layout)
+                if !entity.Order(userId, st, et, types, ps.TimeExpand, ps.Remark) {
+                    r.Error_code = -2
+                    errArr = append(errArr, map[string]interface{}{
+                        "code":   -2,
+                        "msg":    "保存记录失败",
+                        "userId": userId,
+                    })
+                }
+            } else {
+                r.Error_code = -1
+                errArr = append(errArr, map[string]interface{}{
+                    "code":   -1,
+                    "msg":    "mgo获取用户信息失败",
+                    "userId": userId,
+                })
+            }
+        }
+        if len(errArr) > 0 {
+            b, _ := json.Marshal(errArr)
+            r.Data = b
+        }
+    }
+    return nil
 }
 
 //获取用户权益信息
 func (s *JyPayRpc) GetUserPowerInfo(p *frpc.JYShareUserIdsRes, r *frpc.JYShareResp, session *httpsession.Session) error {
-	if len(p.ShareUserInfo) > 0 {
-		ps := p.ShareUserInfo[0]
-		bigBaseMsg := jy.GetBigVipUserBaseMsg(session, *config.Middleground)
-		if bigBaseMsg == nil {
-			r.Error_code = -1
-			r.Error_msg = ps.UserId
-			r.Data = map[string]interface{}{
-				"code":   -1,
-				"msg":    "获取用户权益详情失败",
-				"userId": ps.UserId,
-			}
-		} else {
-			data, _ := json.Marshal(*bigBaseMsg)
-			r.Data = data
-		}
-	}
-	return nil
+    if len(p.ShareUserInfo) > 0 {
+        ps := p.ShareUserInfo[0]
+        bigBaseMsg := jy.GetBigVipUserBaseMsg(session, *config.Middleground)
+        if bigBaseMsg == nil {
+            r.Error_code = -1
+            r.Error_msg = ps.UserId
+            r.Data = map[string]interface{}{
+                "code":   -1,
+                "msg":    "获取用户权益详情失败",
+                "userId": ps.UserId,
+            }
+        } else {
+            data, _ := json.Marshal(*bigBaseMsg)
+            r.Data = data
+        }
+    }
+    return nil
 }