Create & Init Project...

This commit is contained in:
2019-04-22 18:49:16 +08:00
commit fc4fa37393
25440 changed files with 4054998 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"income.go",
"service.go",
"trade.go",
],
importpath = "go-common/app/interface/main/ugcpay/service",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/interface/main/ugcpay/conf:go_default_library",
"//app/interface/main/ugcpay/dao:go_default_library",
"//app/interface/main/ugcpay/model:go_default_library",
"//library/log:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,44 @@
package service
import (
"context"
"go-common/app/interface/main/ugcpay/model"
"go-common/library/log"
)
// IncomeAssetOverview 获得收入总览数据
func (s *Service) IncomeAssetOverview(ctx context.Context, mid int64) (inc *model.IncomeAssetOverview, err error) {
inc, err = s.dao.IncomeAssetOverview(ctx, mid)
return
}
// IncomeAssetList 获得稿件维度的收入数据
func (s *Service) IncomeAssetList(ctx context.Context, mid int64, ver int64, ps, pn int64) (inc *model.IncomeAssetMonthly, page *model.Page, err error) {
if inc, err = s.dao.IncomeUserAssetList(ctx, mid, ver, ps, pn); err != nil {
return
}
// 获得稿件标题信息
var (
aids = make([]int64, 0)
titleMap = make(map[int64]string)
)
for _, l := range inc.List {
aids = append(aids, l.OID)
}
if titleMap, err = s.dao.ArchiveTitles(ctx, aids); err != nil {
log.Error("s.dao.ArchiveTitles aids: %+v, err: %+v", aids, err)
err = nil
}
for _, l := range inc.List {
l.Title = titleMap[l.OID]
}
page = &model.Page{
Size: inc.Page.Size,
Num: inc.Page.Num,
Total: inc.Page.Total,
}
return
}

View File

@@ -0,0 +1,33 @@
package service
import (
"context"
"go-common/app/interface/main/ugcpay/conf"
"go-common/app/interface/main/ugcpay/dao"
)
// Service struct
type Service struct {
c *conf.Config
dao *dao.Dao
}
// New init
func New(c *conf.Config) (s *Service) {
s = &Service{
c: c,
dao: dao.New(c),
}
return s
}
// Ping Service
func (s *Service) Ping(c context.Context) (err error) {
return s.dao.Ping(c)
}
// Close Service
func (s *Service) Close() {
s.dao.Close()
}

View File

@@ -0,0 +1,34 @@
package service
import (
"context"
"go-common/app/interface/main/ugcpay/model"
)
// TradeCreate 订单创建
func (s *Service) TradeCreate(ctx context.Context, mid int64, platform string, oid int64, otype string, currency string) (orderID string, payData string, err error) {
if platform == "" {
platform = "web"
}
orderID, payData, err = s.dao.TradeCreate(ctx, platform, mid, oid, otype, currency)
return
}
// TradeQuery 订单查询
func (s *Service) TradeQuery(ctx context.Context, orderID string) (order *model.TradeOrder, err error) {
order, err = s.dao.TradeQuery(ctx, orderID)
return
}
// TradeConfirm 订单二次确认
func (s *Service) TradeConfirm(ctx context.Context, orderID string) (order *model.TradeOrder, err error) {
order, err = s.dao.TradeConfirm(ctx, orderID)
return
}
// TradeCancel 订单取消
func (s *Service) TradeCancel(ctx context.Context, orderID string) (err error) {
err = s.dao.TradeCancel(ctx, orderID)
return
}