|
@@ -198,162 +198,6 @@ func addPower(waitEmpowerId int64, entUserId int, entId int64) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func openPowerBig(orderData map[string]interface{}, userId string) bool {
|
|
|
|
- filterMap := common.ObjToMap(orderData["filter"])
|
|
|
|
- startTime := common.ObjToString(orderData["vip_starttime"])
|
|
|
|
- endTime := common.ObjToString(orderData["vip_endtime"])
|
|
|
|
- tmp := "2006-01-02 15:04:05"
|
|
|
|
- startdate, _ := time.ParseInLocation(tmp, startTime, time.Local)
|
|
|
|
- enddate, _ := time.ParseInLocation(tmp, endTime, time.Local)
|
|
|
|
- level := common.IntAll((*filterMap)["level"])
|
|
|
|
- comboId := common.IntAll((*filterMap)["comboId"])
|
|
|
|
- payCycle := common.IntAll((*filterMap)["cycle"])
|
|
|
|
- serversId := common.ObjToString((*filterMap)["serversId"])
|
|
|
|
- serverMap := GetServerPid()
|
|
|
|
- dataType := 1
|
|
|
|
- if startdate.Unix() > time.Now().Unix() {
|
|
|
|
- dataType = 2
|
|
|
|
- }
|
|
|
|
- sets := map[string]interface{}{
|
|
|
|
- "i_member_status": common.If(dataType == 1, level, -level),
|
|
|
|
- "i_member_starttime": startdate.Unix(),
|
|
|
|
- "i_member_endtime": enddate.Unix(),
|
|
|
|
- "i_mainaccount": 1,
|
|
|
|
- "o_member_jy.i_wxpush": 1,
|
|
|
|
- }
|
|
|
|
- set := map[string]interface{}{
|
|
|
|
- "$set": sets,
|
|
|
|
- }
|
|
|
|
- ok := Mgo.UpdateById("user", userId, set)
|
|
|
|
- if !ok {
|
|
|
|
- log.Println("大会员创建订单user表大会员状态更新失败")
|
|
|
|
- }
|
|
|
|
- if comboId != 0 {
|
|
|
|
- datas := JyMysql.FindOne("bigmember_combo", map[string]interface{}{"id": comboId}, "", "")
|
|
|
|
- if datas == nil || len(*datas) == 0 {
|
|
|
|
- log.Println("未找到此套餐")
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- s_servers := common.ObjToString((*datas)["s_servers"])
|
|
|
|
- for _, s := range strings.Split(s_servers, ",") {
|
|
|
|
- serverId, _ := strconv.Atoi(s)
|
|
|
|
- mainId := serverId
|
|
|
|
- if serverMap[serverId] != 0 {
|
|
|
|
- serverId = serverMap[serverId]
|
|
|
|
- }
|
|
|
|
- serverData := JyMysql.FindOne("bigmember_service", map[string]interface{}{"id": mainId}, "", "")
|
|
|
|
- frequency := 0
|
|
|
|
- if serverData != nil && len(*serverData) > 0 {
|
|
|
|
- if serverId == 11 || serverId == 15 {
|
|
|
|
- if serverId == 15 {
|
|
|
|
- if payCycle >= 12 {
|
|
|
|
- frequency = (payCycle / 12 * common.IntAll((*serverData)["s_count_year"])) + (payCycle % 12 * common.IntAll((*serverData)["s_count_month"]))
|
|
|
|
- } else {
|
|
|
|
- frequency = payCycle * common.IntAll((*serverData)["s_count_month"])
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- frequency = payCycle * common.IntAll((*serverData)["s_count_month"])
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- frequency = common.IntAll((*serverData)["s_count_month"])
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- sqls := "select * from bigmember_service_user where s_serviceid = ? and s_userid = ? and i_status = -1"
|
|
|
|
- serverDatas := JyMysql.SelectBySql(sqls, serverId, userId)
|
|
|
|
- if serverDatas != nil && len(*serverDatas) > 0 {
|
|
|
|
- i_status := common.If(dataType == 1, 0, 1)
|
|
|
|
- // sql := ""
|
|
|
|
- // if serverId == 17 || serverId == 18 {
|
|
|
|
- sql := "update bigmember_service_user set i_frequency = ?,l_updatetime = ?,l_starttime = ?,l_endtime = ?,i_status = ? where s_serviceid = ? and s_userid = ?"
|
|
|
|
- // } else {
|
|
|
|
- // sql = "update bigmember_service_user set i_frequency = ?,l_updatetime = ?,l_starttime = ?,l_endtime = ?,i_status = ? where s_serviceid = ? and s_userid = ?"
|
|
|
|
- // }
|
|
|
|
- status1 := JyMysql.UpdateOrDeleteBySql(sql, fmt.Sprint(frequency), time.Now().Format(tmp), startdate.Format(tmp), enddate.Format(tmp), fmt.Sprint(i_status), serverId, userId)
|
|
|
|
- if status1 < 0 {
|
|
|
|
- log.Println("新建服务-更新服务表出错", userId)
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- insert := map[string]interface{}{
|
|
|
|
- "s_smainid": mainId,
|
|
|
|
- "s_userid": userId,
|
|
|
|
- "s_serviceid": serverId,
|
|
|
|
- "i_frequency": frequency,
|
|
|
|
- "l_starttime": startdate.Format(tmp),
|
|
|
|
- "l_endtime": enddate.Format(tmp),
|
|
|
|
- "i_status": common.If(dataType == 1, 0, 1),
|
|
|
|
- "l_createtime": time.Now().Format(tmp),
|
|
|
|
- "l_updatetime": time.Now().Format(tmp),
|
|
|
|
- }
|
|
|
|
- order_id := JyMysql.Insert(BigServiceUser, insert)
|
|
|
|
- if order_id > 0 {
|
|
|
|
- log.Println("用户服务表插入成功", userId)
|
|
|
|
- } else {
|
|
|
|
- log.Println("用户服务表插入失败", userId)
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- for _, s := range strings.Split(serversId, ",") {
|
|
|
|
- serverId, _ := strconv.Atoi(s)
|
|
|
|
- mainId := serverId
|
|
|
|
- if serverMap[serverId] != 0 {
|
|
|
|
- serverId = serverMap[serverId]
|
|
|
|
- }
|
|
|
|
- serverData := JyMysql.FindOne("bigmember_service", map[string]interface{}{"id": mainId}, "", "")
|
|
|
|
- frequency := 0
|
|
|
|
- if serverData != nil && len(*serverData) > 0 {
|
|
|
|
- if serverId == 11 || serverId == 15 {
|
|
|
|
- if serverId == 15 {
|
|
|
|
- if payCycle >= 12 {
|
|
|
|
- frequency = (payCycle / 12 * common.IntAll((*serverData)["s_count_year"])) + (payCycle % 12 * common.IntAll((*serverData)["s_count_month"]))
|
|
|
|
- } else {
|
|
|
|
- frequency = payCycle * common.IntAll((*serverData)["s_count_month"])
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- frequency = payCycle * common.IntAll((*serverData)["s_count_month"])
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- frequency = common.IntAll((*serverData)["s_count_month"])
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- sqls := "select * from bigmember_service_user where s_serviceid = ? and s_userid = ? and i_status = -1"
|
|
|
|
- serverDatas := JyMysql.SelectBySql(sqls, serverId, userId)
|
|
|
|
- if serverDatas != nil && len(*serverDatas) > 0 {
|
|
|
|
- i_status := common.If(dataType == 1, 0, 1)
|
|
|
|
- sql := "update bigmember_service_user set i_frequency = ?,l_updatetime = ?,l_starttime = ?,l_endtime = ?,i_status = ? where s_serviceid = ? and s_userid = ?"
|
|
|
|
- status1 := JyMysql.UpdateOrDeleteBySql(sql, fmt.Sprint(frequency), time.Now().Format(tmp), startdate.Format(tmp), enddate.Format(tmp), fmt.Sprint(i_status), serverId, userId)
|
|
|
|
- if status1 < 0 {
|
|
|
|
- log.Println("新建服务-更新服务表出错")
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- insert := map[string]interface{}{
|
|
|
|
- "s_userid": userId,
|
|
|
|
- "s_smainid": mainId,
|
|
|
|
- "s_serviceid": serverId,
|
|
|
|
- "i_frequency": frequency,
|
|
|
|
- "l_starttime": startdate.Format(tmp),
|
|
|
|
- "l_endtime": enddate.Format(tmp),
|
|
|
|
- "i_status": common.If(dataType == 1, 0, 1),
|
|
|
|
- "l_createtime": time.Now().Format(tmp),
|
|
|
|
- "l_updatetime": time.Now().Format(tmp),
|
|
|
|
- }
|
|
|
|
- order_id := JyMysql.Insert(BigServiceUser, insert)
|
|
|
|
- if order_id > 0 {
|
|
|
|
- log.Println("用户服务表插入成功", userId)
|
|
|
|
- } else {
|
|
|
|
- log.Println("用户服务表插入失败")
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- RedisDel(userId)
|
|
|
|
- return true
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
func GetServerPid() map[int]int {
|
|
func GetServerPid() map[int]int {
|
|
pidMap := map[int]int{}
|
|
pidMap := map[int]int{}
|
|
datas := JyMysql.Find("bigmember_service", map[string]interface{}{"i_status": 0}, "id,i_pid", "", 0, 0)
|
|
datas := JyMysql.Find("bigmember_service", map[string]interface{}{"i_status": 0}, "id,i_pid", "", 0, 0)
|
|
@@ -371,66 +215,18 @@ func RedisDel(userId string) {
|
|
redis.Del(NewOther, "pl_indexMessage_"+userId)
|
|
redis.Del(NewOther, "pl_indexMessage_"+userId)
|
|
cacheKey := fmt.Sprintf(PowerCacheKey, userId)
|
|
cacheKey := fmt.Sprintf(PowerCacheKey, userId)
|
|
baseInfoCacheKey := fmt.Sprintf(IsGetUserBaseInfoRedisKey, userId)
|
|
baseInfoCacheKey := fmt.Sprintf(IsGetUserBaseInfoRedisKey, userId)
|
|
- redisMenuKeyPC := fmt.Sprintf(RedisMenuKeyPC, userId)
|
|
|
|
- redisMenuKeyWX := fmt.Sprintf(RedisMenuKeyWX, userId)
|
|
|
|
- redisMenuKeyAPP := fmt.Sprintf(RedisMenuKeyAPP, userId)
|
|
|
|
|
|
+ redisMenuKeyPC := fmt.Sprintf(RedisMenuKey1, userId)
|
|
|
|
+ redisMenuKeyWX := fmt.Sprintf(RedisMenuKey2, userId)
|
|
|
|
+ redisMenuKeyAPP := fmt.Sprintf(RedisMenuKey3, userId)
|
|
userPowerRedisKey := fmt.Sprintf(UserPowerRedisKey, time.Now().Day(), userId)
|
|
userPowerRedisKey := fmt.Sprintf(UserPowerRedisKey, time.Now().Day(), userId)
|
|
|
|
+ powerCheckKey := fmt.Sprintf(PowerCheckKey, userId)
|
|
redis.Del(NewOther, cacheKey)
|
|
redis.Del(NewOther, cacheKey)
|
|
redis.Del(NewOther, baseInfoCacheKey)
|
|
redis.Del(NewOther, baseInfoCacheKey)
|
|
redis.Del(NewOther, redisMenuKeyPC)
|
|
redis.Del(NewOther, redisMenuKeyPC)
|
|
redis.Del(NewOther, redisMenuKeyWX)
|
|
redis.Del(NewOther, redisMenuKeyWX)
|
|
redis.Del(NewOther, redisMenuKeyAPP)
|
|
redis.Del(NewOther, redisMenuKeyAPP)
|
|
redis.Del(NewOther, userPowerRedisKey)
|
|
redis.Del(NewOther, userPowerRedisKey)
|
|
-}
|
|
|
|
-
|
|
|
|
-func openPowerVip(orderData map[string]interface{}, userId string) bool {
|
|
|
|
- vms := VipSimpleMsg{}
|
|
|
|
- json.Unmarshal([]byte(common.ObjToString(orderData["filter"])), &vms)
|
|
|
|
- startTime := common.ObjToString(orderData["vip_starttime"])
|
|
|
|
- endTime := common.ObjToString(orderData["vip_endtime"])
|
|
|
|
- Date_Full_Layout := "2006-01-02 15:04:05"
|
|
|
|
- user_phone := common.ObjToString(orderData["user_phone"])
|
|
|
|
-
|
|
|
|
- startdate, _ := time.ParseInLocation(Date_Full_Layout, startTime, time.Local)
|
|
|
|
- enddate, _ := time.ParseInLocation(Date_Full_Layout, endTime, time.Local)
|
|
|
|
- dataType := 1
|
|
|
|
- if startdate.Unix() > time.Now().Unix() {
|
|
|
|
- dataType = 2
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //为用户开通超级订阅权限
|
|
|
|
- //是否开通超级订阅 -1 试用到期 -2 正式到期 1 试用 2 开通
|
|
|
|
- isTrial := false
|
|
|
|
- if dataType == 2 {
|
|
|
|
- isTrial = true
|
|
|
|
- }
|
|
|
|
- isOk := StartSubVip(user_phone, *vms.Area, *vms.NewBuyset, startdate, enddate, isTrial, userId)
|
|
|
|
- return isOk
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func StartSubVip(phone string, area map[string]interface{}, newBuyset SubvipBuySet, startTime, endTime time.Time, isTrial bool, userId string) bool {
|
|
|
|
- set := map[string]interface{}{
|
|
|
|
- "o_vipjy.i_trial": -1, //已激活试用
|
|
|
|
- "o_vipjy.o_area": area, //设置地区
|
|
|
|
- "o_vipjy.o_buyset": newBuyset, //购买内容 城市、省份、行业数量
|
|
|
|
- "l_vip_starttime": startTime.Unix(), //开始时间
|
|
|
|
- "l_vip_endtime": endTime.Unix(), //结束时间
|
|
|
|
- "i_vip_status": common.If(isTrial, -2, 2), //1试用 2正式 -2 试用到期
|
|
|
|
- "i_vip_expire_tip": 0, //消息提示初始化
|
|
|
|
- "o_vipjy.a_buyerclass": []interface{}{}, //设置行业
|
|
|
|
- }
|
|
|
|
- isOk := Mgo.UpdateById("user", userId, map[string]interface{}{
|
|
|
|
- "$set": set,
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- go func() {
|
|
|
|
- // MergeKws(userId)
|
|
|
|
- RedisDel(userId)
|
|
|
|
- }()
|
|
|
|
- if isOk {
|
|
|
|
- return true
|
|
|
|
- }
|
|
|
|
- return true
|
|
|
|
|
|
+ redis.Del(NewOther, powerCheckKey)
|
|
}
|
|
}
|
|
|
|
|
|
// 初始化vip订阅关键词
|
|
// 初始化vip订阅关键词
|
|
@@ -464,12 +260,12 @@ func delPower(id int64) {
|
|
orderData := JyMysql.FindOne(Order, map[string]interface{}{"id": orderId}, "", "")
|
|
orderData := JyMysql.FindOne(Order, map[string]interface{}{"id": orderId}, "", "")
|
|
set := map[string]interface{}{}
|
|
set := map[string]interface{}{}
|
|
if orderData != nil && len(*orderData) > 0 {
|
|
if orderData != nil && len(*orderData) > 0 {
|
|
|
|
+ posititonId := getPositionId(entUserId)
|
|
productType := common.ObjToString((*orderData)["product_type"])
|
|
productType := common.ObjToString((*orderData)["product_type"])
|
|
entId := common.Int64All((*orderData)["ent_id"])
|
|
entId := common.Int64All((*orderData)["ent_id"])
|
|
if productType == "VIP订阅" {
|
|
if productType == "VIP订阅" {
|
|
set["l_vip_endtime"] = time.Now().Unix()
|
|
set["l_vip_endtime"] = time.Now().Unix()
|
|
} else if productType == "大会员" {
|
|
} else if productType == "大会员" {
|
|
- posititonId := getPositionId(entUserId)
|
|
|
|
set["i_member_endtime"] = time.Now().Unix()
|
|
set["i_member_endtime"] = time.Now().Unix()
|
|
JyMysql.Update(BigServiceUser, map[string]interface{}{"s_userid": posititonId}, map[string]interface{}{"i_status": -1})
|
|
JyMysql.Update(BigServiceUser, map[string]interface{}{"s_userid": posititonId}, map[string]interface{}{"i_status": -1})
|
|
}
|
|
}
|
|
@@ -480,7 +276,9 @@ func delPower(id int64) {
|
|
}, map[string]interface{}{
|
|
}, map[string]interface{}{
|
|
"$set": set,
|
|
"$set": set,
|
|
}, true, false)
|
|
}, true, false)
|
|
- // RedisDel(userId)
|
|
|
|
|
|
+
|
|
|
|
+ posititonIdStr := strconv.Itoa(int(posititonId))
|
|
|
|
+ RedisDel(posititonIdStr)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -524,7 +322,8 @@ func setRule(types int64, entUserId, entId int64, orderData map[string]interface
|
|
|
|
|
|
go func() {
|
|
go func() {
|
|
MergeKws(entId, entUserId)
|
|
MergeKws(entId, entUserId)
|
|
- // RedisDel(userId)
|
|
|
|
|
|
+ posititonIdStr := strconv.Itoa(int(posititonId))
|
|
|
|
+ RedisDel(posititonIdStr)
|
|
}()
|
|
}()
|
|
return ok1 && ok2
|
|
return ok1 && ok2
|
|
}
|
|
}
|