You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.3 KiB
Go
64 lines
1.3 KiB
Go
package service
|
|
|
|
import (
|
|
containers "joybuywork/internal/service/containers/projectuser"
|
|
"joybuywork/internal/service/provider/projectuser"
|
|
pb "joybuywork/proto/go_proto/w_project_user"
|
|
)
|
|
|
|
type WProjectUser struct {
|
|
Service
|
|
}
|
|
|
|
// Point 积分
|
|
func (s *WProjectUser) Point(req *pb.PointReq, res *pb.PointRes) (err error) {
|
|
defer s.checkErr()
|
|
|
|
*res = pb.PointRes{}
|
|
container := new(containers.Point)
|
|
{
|
|
container.Init(s.ctx)
|
|
container.Req = req
|
|
container.Res = res
|
|
}
|
|
|
|
return container.Run()
|
|
}
|
|
|
|
// EarnCoin 获取积分
|
|
func (s *WProjectUser) EarnCoin(req *pb.EarnCoinReq, res *pb.EarnCoinRes) (err error) {
|
|
defer s.checkErr()
|
|
project, err := s.ProjectErrNil(req.GetProjectId())
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
pu, err := projectuser.NewProjectUser(s.ctx, projectuser.WithInit(project.ID, req.GetUserId()))
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
var earns []*projectuser.EarnCoinParam
|
|
|
|
for _, earn := range req.GetEarns() {
|
|
earns = append(earns, &projectuser.EarnCoinParam{
|
|
CoinNum: earn.GetCoinNum(),
|
|
IsExpired: int8(earn.GetIsExpired()),
|
|
ExpiredAt: earn.GetExpiredAt(),
|
|
Source: earn.GetSource(),
|
|
SourceID: earn.GetSourceId(),
|
|
SourceData: earn.GetSourceData(),
|
|
Operate: earn.GetOperate(),
|
|
})
|
|
}
|
|
|
|
err = pu.EarnCoin(earns...)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
*res = pb.EarnCoinRes{}
|
|
|
|
return
|
|
}
|