|
@@ -1,7 +1,6 @@
|
|
|
package service
|
|
|
|
|
|
import (
|
|
|
- "app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenterclient"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"log"
|
|
@@ -9,6 +8,10 @@ import (
|
|
|
"strings"
|
|
|
"time"
|
|
|
|
|
|
+ "bp.jydev.jianyu360.cn/BaseService/entManageApplication/entity"
|
|
|
+
|
|
|
+ "app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenterclient"
|
|
|
+
|
|
|
"context"
|
|
|
|
|
|
. "app.yhyue.com/moapp/jybase/date"
|
|
@@ -16,6 +19,7 @@ import (
|
|
|
. "bp.jydev.jianyu360.cn/BaseService/entManageApplication/entity"
|
|
|
"bp.jydev.jianyu360.cn/BaseService/entManageApplication/rpc/entmanageapplication"
|
|
|
"bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/rpc/powercheck"
|
|
|
+ "bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/pb"
|
|
|
"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/usercenter"
|
|
|
|
|
|
// "github.com/zeromicro/go-zero/core/logx"
|
|
@@ -190,19 +194,20 @@ func BuyProductList(this *entmanageapplication.BuyProductListReq) *entmanageappl
|
|
|
}
|
|
|
|
|
|
func addPower(waitEmpowerId int64, entUserId int, entId int64) {
|
|
|
+ identity := getPositionId(entUserId)
|
|
|
+ ResourcePowerHandle(identity, waitEmpowerId, 1)
|
|
|
data := JyMysql.FindOne(EntnicheOrder, map[string]interface{}{"wait_empower_id": waitEmpowerId}, "", "")
|
|
|
if data != nil && len(*data) > 0 {
|
|
|
orderId := common.Int64All((*data)["order_id"])
|
|
|
orderData := JyMysql.FindOne(Order, map[string]interface{}{"id": orderId}, "", "")
|
|
|
if orderData != nil && len(*orderData) > 0 {
|
|
|
productType := common.ObjToString((*orderData)["product_type"])
|
|
|
- posititonId := getPositionId(entUserId)
|
|
|
if productType == "VIP订阅" {
|
|
|
- log.Println("开通超级订阅", posititonId)
|
|
|
- setRule(1, int64(entUserId), entId, *orderData, posititonId)
|
|
|
+ log.Println("开通超级订阅", identity.PositionId)
|
|
|
+ setRule(1, int64(entUserId), entId, *orderData, identity.PositionId)
|
|
|
} else if productType == "大会员" {
|
|
|
- log.Println("开通大会员", posititonId)
|
|
|
- setRule(2, int64(entUserId), entId, *orderData, posititonId)
|
|
|
+ log.Println("开通大会员", identity.PositionId)
|
|
|
+ setRule(2, int64(entUserId), entId, *orderData, identity.PositionId)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -251,6 +256,8 @@ func delPower(id int64) {
|
|
|
if data != nil && len(*data) > 0 {
|
|
|
waitEmpowerId := common.Int64All((*data)["wait_empower_id"])
|
|
|
entUserId := common.IntAll((*data)["ent_user_id"])
|
|
|
+ identity := getPositionId(entUserId)
|
|
|
+ ResourcePowerHandle(identity, waitEmpowerId, -1)
|
|
|
JyMysql.UpdateOrDeleteBySql(`update `+EntnicheWaitEmpower+` set use_count = use_count - 1 where id = ? and use_count > 0`, waitEmpowerId)
|
|
|
eOData := JyMysql.FindOne(EntnicheOrder, map[string]interface{}{"wait_empower_id": waitEmpowerId}, "", "")
|
|
|
if eOData != nil && len(*eOData) > 0 {
|
|
@@ -258,7 +265,6 @@ func delPower(id int64) {
|
|
|
orderData := JyMysql.FindOne(Order, map[string]interface{}{"id": orderId}, "", "")
|
|
|
set := map[string]interface{}{}
|
|
|
if orderData != nil && len(*orderData) > 0 {
|
|
|
- posititonId := getPositionId(entUserId)
|
|
|
productType := common.ObjToString((*orderData)["product_type"])
|
|
|
entId := common.Int64All((*orderData)["ent_id"])
|
|
|
if productType == "VIP订阅" {
|
|
@@ -267,7 +273,7 @@ func delPower(id int64) {
|
|
|
} else if productType == "大会员" {
|
|
|
set["i_member_endtime"] = time.Now().Unix()
|
|
|
set["i_member_status"] = 0
|
|
|
- JyMysql.Update(BigServiceUser, map[string]interface{}{"s_userid": common.InterfaceToStr(posititonId)}, map[string]interface{}{"i_status": -1})
|
|
|
+ JyMysql.Update(BigServiceUser, map[string]interface{}{"s_userid": common.InterfaceToStr(identity.PositionId)}, map[string]interface{}{"i_status": -1})
|
|
|
}
|
|
|
|
|
|
Mgo.Update("ent_user", map[string]interface{}{
|
|
@@ -277,7 +283,7 @@ func delPower(id int64) {
|
|
|
"$set": set,
|
|
|
}, true, false)
|
|
|
|
|
|
- posititonIdStr := strconv.Itoa(int(posititonId))
|
|
|
+ posititonIdStr := strconv.Itoa(int(identity.PositionId))
|
|
|
RedisDel(posititonIdStr)
|
|
|
}
|
|
|
}
|
|
@@ -286,13 +292,12 @@ func delPower(id int64) {
|
|
|
|
|
|
// 获取用户信息
|
|
|
// return 职位id
|
|
|
-func getPositionId(entUserId int) int64 {
|
|
|
+func getPositionId(entUserId int) *usercenter.Identity {
|
|
|
ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
|
|
|
res, _ := UserCenterRpc.IdentityByEntUserId(ctx, &usercenter.IdentityReq{
|
|
|
Id: int64(entUserId),
|
|
|
})
|
|
|
- log.Println(res)
|
|
|
- return res.PositionId
|
|
|
+ return res
|
|
|
}
|
|
|
|
|
|
// 订阅设置
|
|
@@ -589,3 +594,20 @@ func delRedisByPowerCheck(positionId string) bool {
|
|
|
}
|
|
|
return true
|
|
|
}
|
|
|
+
|
|
|
+//
|
|
|
+func ResourcePowerHandle(identity *usercenter.Identity, waitEmpowerId, t int64) {
|
|
|
+ //如果是运营商数据定制及分析产品,调用资源中台,取消对应菜单权限
|
|
|
+ if JyMysql.CountBySql(`select count(1) as count from `+EntnicheWaitEmpower+` where id=? and product_type='运营商数据定制及分析'`, waitEmpowerId) > 0 {
|
|
|
+ entity.ResourceRpc.PowerHandle(context.Background(), &pb.PowerReq{
|
|
|
+ Appid: "10000",
|
|
|
+ GoodsCode: "special_nosale_goods",
|
|
|
+ GoodsSpecId: 31,
|
|
|
+ BuyNum: 1,
|
|
|
+ Type: t,
|
|
|
+ AccountId: identity.AccountId,
|
|
|
+ EntAccountId: identity.EntAccountId,
|
|
|
+ EntId: identity.EntId,
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|