123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- package rpc
- import (
- qu "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/go-logger/logger"
- "encoding/json"
- "fmt"
- "github.com/gogf/gf/v2/os/gcfg"
- "github.com/gogf/gf/v2/os/gctx"
- "github.com/gogf/gf/v2/util/gconv"
- "net/rpc"
- )
- //===========================================
- // 来源 https://bp.jydev.jianyu360.cn/BP/common/src/master/src/qfw/util/rpc/order.go
- //==========================================
- // shareUserInfo
- type shareUserInfo struct {
- UserId string `json:"userId"` //用户id
- TimeExpand int `json:"timeExpand"` //延长时间
- Remark string `json:"remark"` //备注
- }
- //分享完成 订单处理结果
- type JYShareResp struct {
- Error_code int64 `json:"error_code"`
- Error_msg string `json:"error_msg"`
- Data interface{} `json:"data"`
- }
- type JYShareUserIdsRes struct {
- ShareUserInfo []shareUserInfo //被分享者+分享者等用户信息
- }
- //===========================================
- // SubVipHarvest 超级订阅奖励发放
- func SubVipHarvest(userId string, num int, remark string) (err error) {
- defer qu.Catch()
- client, err := rpc.DialHTTP("tcp", gcfg.Instance().MustGet(gctx.New(), "rpc.payrpc").String())
- if err != nil {
- logger.Error("GetUserVipBaseMsgByRpc userId", userId, "err", err.Error())
- return err
- }
- var repl JYShareResp
- req := JYShareUserIdsRes{
- ShareUserInfo: []shareUserInfo{
- {
- UserId: userId,
- TimeExpand: num,
- Remark: remark,
- },
- },
- }
- if err = client.Call("JyPayRpc.ShareFissionNew", req, &repl); err != nil {
- logger.Error("JyPayRpc.ShareFissionNew userId", userId, "err", err.Error())
- return err
- }
- if repl.Error_code != 0 {
- err = fmt.Errorf(repl.Error_msg)
- return
- }
- return nil
- }
- type VipStatus struct {
- Status int `json:"status"` //大会员状态
- VipStatus int `json:"vip_status"` //超级订阅状态
- EntnicheStatus int `json:"entniche_status"` //超级订阅状态
- }
- // GetUserVipBaseMsgByRpc 获取用户Vip信息
- func GetUserVipBaseMsgByRpc(userId string) (vs VipStatus, err error) {
- defer qu.Catch()
- var repl JYShareResp
- vs = VipStatus{}
- client, err := rpc.DialHTTP("tcp", gcfg.Instance().MustGet(gctx.New(), "rpc.payrpc").String())
- if err != nil {
- logger.Error("GetUserVipBaseMsgByRpc userId", userId, "err", err.Error())
- return
- }
- req := JYShareUserIdsRes{
- ShareUserInfo: []shareUserInfo{
- shareUserInfo{
- UserId: userId,
- },
- },
- }
- if err = client.Call("JyPayRpc.GetUserPowerInfo", req, &repl); err != nil {
- logger.Error("GetUserVipBaseMsgByRpc userId", userId, "err", err.Error())
- return
- }
- if repl.Error_code != 0 {
- err = fmt.Errorf(repl.Error_msg)
- return
- }
- umErr := json.Unmarshal(gconv.Bytes(repl.Data), &vs)
- if umErr != nil {
- err = fmt.Errorf("格式化信息异常")
- }
- return
- }
|