logic

package
v0.0.0-...-af31a00 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2017 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

*

  • 提现

Index

Constants

View Source
const (
	RankLimit = 100000
)
View Source
const (
	RefreshTokenDiff = 10 * 86400 // 如果refresh token的有效期低于10天,则生成新的refresh token,旧的token也有效
)

Variables

View Source
var CloseTime chan struct{}
View Source
var RedpacketContainers map[string]IRedpacket
View Source
var UpdateTime int64

Functions

func AddFriendToDB

func AddFriendToDB(userId, friendId, friendName, friendPor string)

添加好友入库

func AuditEnterpriseCert

func AuditEnterpriseCert(userId string, pass bool, reason string)

审核结果

func BindOauth

func BindOauth(userId, openId string, platform int) error

设置第三方账户

func BindPhone

func BindPhone(userId, phonenum, password string) error

func CheckOauth

func CheckOauth(openId string, platform int) bool

检查第三方是否注册过

func CreateBackpayRecord

func CreateBackpayRecord(record *models.BackpayRecord) error

创建提现记录

func CreateEnterpriseCert

func CreateEnterpriseCert(material *models.EnterpriseCertMaterial) error

创建企业认证

func CreateNewUser

func CreateNewUser(phonenum, password string) (error, *models.TokenInfo, *models.TokenInfo)

创建新用户

func CreateRedpacket

func CreateRedpacket(userId string, binding *models.SendRedpacketBinding) (string, error)

生成红包,等待付款后上架

func CreateScanning

func CreateScanning(form *models.SendScannigBinding) uint32

/////////////////////////////////////////////////////// public 创建一个扫红包

func CreateUserByQQ

func CreateUserByQQ(openId string, qqUerInfo *models.QQUserInfo) (error, *models.TokenInfo, *models.TokenInfo)

通过QQ注册用户

func CreateUserByWeibo

func CreateUserByWeibo(uid string, weiboUerInfo *models.WeiboUserInfo) (error, *models.TokenInfo, *models.TokenInfo)

func CreateUserByWeixin

func CreateUserByWeixin(openId string, weixinUser *models.WeixinUserInfo) (error, *models.TokenInfo, *models.TokenInfo)

通过微信注册用户

func DoingRedpacket

func DoingRedpacket(userId, redpacketId, deviceId string) uint32

完成分享等待截图确认(红包任务进行中,分享类需要)

func EditEnterpriseCertInfo

func EditEnterpriseCertInfo(userId string, info *models.EnterpriseCertInfoBinding) error

修改信息

func Filter

func Filter(userId string) *models.UserExpireList

删选器 筛选出用户以及操作的红包

func FindAccessToken

func FindAccessToken(userId string) string

根据用户id查询access token

func FindPayPhoneRecordById

func FindPayPhoneRecordById(tradeno string) (*models.PayPhoneRecord, error)

/////////////////////////////////////////////////////// 话费充值数据库查询相关 /////////////////////////////////////////////////////// 根据userid获取充值记录

func FindRefreshToken

func FindRefreshToken(userId string) string

根据用户id查询refresh token

func FindUserByAccount

func FindUserByAccount(username string) *models.User

根据手机号或红包号查找用户

func FindUserByOpenId

func FindUserByOpenId(openId string, platform int) *models.User

通过第三方openid查询用户数据

func FindUserDataById

func FindUserDataById(userId string) (*models.User, error)

/////////////////////////////////////////////////////// 用户数据库查找相关 /////////////////////////////////////////////////////// 根据userid获取user

func FindUserIdByAccount

func FindUserIdByAccount(account string) string

根据账号查询用户id

func FindUserRcToken

func FindUserRcToken(userId string) string

查询用户的融云Token

func FinishRedpacket

func FinishRedpacket(userId, redpacketId, deviceId string) uint32

完成红包任务

func GenAlgorithms

func GenAlgorithms(redpktId string, total, number uint32) bool

生成红包列表的算法 @total 红包总金额 @number 红包个数

func GetDailyGrab

func GetDailyGrab(userId string) int

获取每日已抢红包的次数

func GetEnterpriseCertMaterial

func GetEnterpriseCertMaterial(userId string) (*models.EnterpriseCertMaterial, error)

获取企业认证材料

func GetEnterpriseCertStatus

func GetEnterpriseCertStatus(userId string) int

获取认证状态 返回值 0=无认证,1=认证中,2=认证通过

func GetIncomeRank

func GetIncomeRank(userId string) int

获取总收入排名

func GetRedpacketNotice

func GetRedpacketNotice(userId string) []models.SysNoticeItem

获取红包的系统通知

func GetRedpacketPerMoney

func GetRedpacketPerMoney(redpacketId string) int

/////////////////////////////////////////////////////// public 获取红包的实际单价

func GetRedpktIdList

func GetRedpktIdList(startIdx uint32) []string

获取红包列表

func GetScanListByTag

func GetScanListByTag(startIdx uint32, tag string) *models.ScanningList

根据商品类型获取扫红包列表

func GetScanListByTag1

func GetScanListByTag1(startIdx uint32, tag string) *models.ScanningList

func GetScanningRedpkt

func GetScanningRedpkt(redpktId, userId string) uint32

扫描获得红包

func GetStatistics

func GetStatistics(redpacketId string) *models.RedpktStatistics

func GetSystemNoticeList

func GetSystemNoticeList(userId string) []models.SysNoticeItem

获取用户的系统通知

func GetUserData

func GetUserData(userId string) (*models.User, error)

从redis中获取user缓存

func GetUserLevel

func GetUserLevel(userId string) int

根据积分配置获取用户等级

func GetUserOwnedCount

func GetUserOwnedCount(userId string, redpktType int) int

用户当前拥有该类红包的次数

func GiveupRedpacket

func GiveupRedpacket(userId, redpacketId string)

用户主动放弃红包

func GrabRedpacket

func GrabRedpacket(userId, redpacketId, deviceId string) uint32

抢红包

func HandleBackpayRecord

func HandleBackpayRecord(id string, success bool) error

提现处理完成

func IncUserCacheField

func IncUserCacheField(userId, field string, value interface{})

慎用

func Init

func Init()

初始化各种服务

func InitRedpacket

func InitRedpacket()

func InitScanning

func InitScanning()

func Isfriends

func Isfriends(fromId, targetId string) bool

是否已经是好友了

func PayRedpacketBy3rdParty

func PayRedpacketBy3rdParty(redpktId string, fee int) bool

测试第三方支付

func PayRedpacketByBalance

func PayRedpacketByBalance(userId, redpktId string) bool

余额支付红包

func PushRemoteNotice

func PushRemoteNotice(userId, txt string)

push远程推送

func PushSystemNotice

func PushSystemNotice(userId, txt string)

push系统通知

func RefreshRcUser

func RefreshRcUser(userId, name, portraitUri string)

刷新融云用户信息

func RefreshTokens

func RefreshTokens(userId, accessStr, refreshStr string, oper int) (error, *models.TokenInfo, *models.TokenInfo)

登陆时,刷新token

func ResetPassword

func ResetPassword(userData *models.User, pwd string) (error, *models.TokenInfo, *models.TokenInfo)

重置密码并且重新生成盐

func ResetPhone

func ResetPhone(userId, phonenum string) error

func ScanRecordList

func ScanRecordList(redpacketId string, cursor int) map[string]int64

红包抢夺记录

func SendAddBlacklistReqToRcServer

func SendAddBlacklistReqToRcServer(userId, blackUserId string)

向融云服务器发送拉黑请求

func SendAddFriendReqToRcServer

func SendAddFriendReqToRcServer(fromId, targetId string) error

发送加好友请求到融云服务器

func SendAgreeNotifyToRcServer

func SendAgreeNotifyToRcServer(fromId, targetId, targetName string)

发送成为好友的通知

func UnBindOauth

func UnBindOauth(userId string, platform int) error

解绑第三方账号

func UpdateDailyGrab

func UpdateDailyGrab(userId string)

更新每日抢红包的次数和最后一次抢红包的时间

func UpdateMoney

func UpdateMoney(userId string, money int64)

/////////////////////////////////////////////////////// 用户数据相关操作 /////////////////////////////////////////////////////// 更新用户的账户余额

func UpdateNameToFriends

func UpdateNameToFriends(userId, nickName string)

将用户的最新信息更新到自己的好友列表

func UpdatePayPhoneRecordFinish

func UpdatePayPhoneRecordFinish(tradeno string) error

完成记录充值状态

func UpdateUserById

func UpdateUserById(userId string, update interface{}) error

/////////////////////////////////////////////////////// 封装用户数据的数据库更新 ///////////////////////////////////////////////////////

func UpdateUserCacheField

func UpdateUserCacheField(userId string, args ...interface{})

更新用户缓存字段(重新设置)

func UpdateVerify

func UpdateVerify(redpktId string, status int) bool

更新红包的审核状态

func VerifySmsCode

func VerifySmsCode(phone, zone, code string) error

验证短信验证码

Types

type AppRedpacket

type AppRedpacket struct {
	RedpacketBase
}

func (*AppRedpacket) Doing

func (this *AppRedpacket) Doing(userId, deviceId string) uint32

app和游戏下载类不需要

func (*AppRedpacket) Finish

func (this *AppRedpacket) Finish(userId, deviceId string) uint32

func (*AppRedpacket) GetExpires

func (this *AppRedpacket) GetExpires(userId string) *models.RedpacketExpire

获取用户抢到该红包的到期时间

func (*AppRedpacket) GiveUp

func (this *AppRedpacket) GiveUp(userId string)

func (*AppRedpacket) Grab

func (this *AppRedpacket) Grab(userId, deviceId string) uint32

/////////////////////////////////////////////////////// public 抢红包

type IRedpacket

type IRedpacket interface {
	GetRedpktType() int                               // 获取红包的类型
	GetRedpacketData() *models.RedPacket              // 获取红包信息
	IsStart() bool                                    // 红包是否开始
	Grab(userId, deviceId string) uint32              // 抢红包
	Doing(userId, deviceId string) uint32             // 红包任务进行中
	Finish(userId, deviceId string) uint32            // 完成红包任务
	GiveUp(userId string)                             // 放弃红包
	GetExpires(userId string) *models.RedpacketExpire // 获取红包的到期时间信息
	ScanRecord(cursor int) map[string]int64           // 红包领取记录
	IsGrabed(userId string) bool                      // 用户是否抢到了红包
}

红包的接口

func GetRedpacketCon

func GetRedpacketCon(redpktId string) IRedpacket

func NewAppRedpacket

func NewAppRedpacket(redpkt *models.RedPacket) IRedpacket

func NewShareRedpacket

func NewShareRedpacket(redpkt *models.RedPacket) IRedpacket

type RcTokenResponse

type RcTokenResponse struct {
	Code   int    `json:"code"`   // 返回码
	Token  string `json:"token"`  // 融云token
	UserId string `json:"userId"` // 用户id
}

func GetRcTokenFromRcSrv

func GetRcTokenFromRcSrv(userId, name, portrait string) (*RcTokenResponse, error)

从融云server获取新的token

type RedpacketBase

type RedpacketBase struct {
	Id            string            // 红包id
	CloseTimer    chan struct{}     // 关闭定时器
	ColdData      *models.RedPacket // 红包冷数据
	GrabStatusKey string            // 用户抢红包的状态
	GrabKey       string            // 抢红包的用户队列
	RecordKey     string            // 已领取红包的用户队列
	DeviceKey     string            // 用户设备映射
}

func (*RedpacketBase) GetRedpacketData

func (this *RedpacketBase) GetRedpacketData() *models.RedPacket

func (*RedpacketBase) GetRedpktType

func (this *RedpacketBase) GetRedpktType() int

func (*RedpacketBase) IsGrabed

func (this *RedpacketBase) IsGrabed(userId string) bool

已经拥有的次数

func (*RedpacketBase) IsStart

func (this *RedpacketBase) IsStart() bool

/////////////////////////////////////////////////////// public

func (*RedpacketBase) ScanRecord

func (this *RedpacketBase) ScanRecord(cursor int) map[string]int64

func (*RedpacketBase) ZRevRange

func (this *RedpacketBase) ZRevRange(key string, start, stop int, record map[string]int64)

type ShareRedpacket

type ShareRedpacket struct {
	RedpacketBase
}

func (*ShareRedpacket) Doing

func (this *ShareRedpacket) Doing(userId, deviceId string) uint32

func (*ShareRedpacket) Finish

func (this *ShareRedpacket) Finish(userId, deviceId string) uint32

func (*ShareRedpacket) GetExpires

func (this *ShareRedpacket) GetExpires(userId string) *models.RedpacketExpire

获取用户抢到该红包的到期时间

func (*ShareRedpacket) GiveUp

func (this *ShareRedpacket) GiveUp(userId string)

func (*ShareRedpacket) Grab

func (this *ShareRedpacket) Grab(userId, deviceId string) uint32

/////////////////////////////////////////////////////// public 抢红包

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL