作者 陈志颖

feat:添加兑换活动领域对象、现金池领域对象

正在显示 37 个修改的文件 包含 192 行增加0 行删除
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type InputCashPooCommand struct {
Cash float64 `json:"cash" valid:"Required"` // 投入的现金值
Operator int64 `json:"operator,omitempty"` // 操作人UID
InputDescription string `json:"inputDescription" valid:"Required"` // 投入描述
}
func (inputCashPooCommand *InputCashPooCommand) ValidateCommand() error {
valid := validation.Validation{}
rt, err := valid.Valid(inputCashPooCommand)
if err != nil {
return err
}
if !rt {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package service
// 投入现金服务
type CashService struct {
}
// 投入现金
//func (cashService *CashService) InputCashPool(inputCashPoolCommand *command.InputCashPooCommand) (interface{}, error) {
//
//}
\ No newline at end of file
... ...
package domain
// 现金池信息
type CashPoolInfo struct {
Cash float64 `json:"cash"` // 投入现金池的现金
ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金
UnExchangeCash float64 `json:"unExchangeCash"` // 未兑换的现金
ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币
UnExchangeSuMoney float64 `json:"unExchangeSuMoney"` // 未兑换的素币
Rate float64 `json:"rate"` // 平均兑换汇率
}
\ No newline at end of file
... ...
package domain
// 兑换活动
type ExchangeActivity struct {
ActivityId int64 `json:"activityId"` // 活动编号
ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金
ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币
Rate float64 `json:"rate"` // 兑换汇率
}
type ExchangeActivityRepository interface {
Save(activity *ExchangeActivity) (*ExchangeActivity, error)
Remove(activity *ExchangeActivity) (*ExchangeActivity, error)
FindOne(queryOptions map[string]interface{}) (*ExchangeActivity, error)
Find(queryOptions map[string]interface{}) (int64, []*ExchangeActivity, error)
}
func (activity *ExchangeActivity) Identity() interface{} {
if activity.ActivityId == 0 {
return nil
}
return activity.ActivityId
}
func (activity *ExchangeActivity) TransferSuMoney(rate float64) error {
activity.ExchangedSuMoney = activity.ExchangedCash * rate
return nil
}
... ...
package domain
// 兑换人
type ExchangePerson struct {
Uid int64 `json:"uid"` // 统一用户ID
Name string `json:"name"` // 已兑换人员名称
Account string `json:"account"` // 已兑换人员账号
ExchangedSuMoney float64 `json:"exchangeSuMoney"` // 已兑换素币
ExchangedCash float64 `json:"exchangedCash"` // 已兑换现金
}
type ExchangePersonRepository interface {
Save(exchangePerson *ExchangePerson) (*ExchangePerson, error)
Remove(exchangePerson *ExchangePerson) (*ExchangePerson, error)
FindOne(queryOptions map[string]interface{}) (*ExchangePerson, error)
Find(queryOptions map[string]interface{}) (int64, []*ExchangePerson, error)
}
func (exchangePerson *ExchangePerson) TransferSuMoney(rate float64) error {
exchangePerson.ExchangedCash = exchangePerson.ExchangedSuMoney / rate
return nil
}
\ No newline at end of file
... ...
package models
import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"time"
)
type CashPoolTransactionRecord struct {
TableName string `pg:"cash_pool"`
CreateTime time.Time // 创建时间
}
... ...
package routers
//func init() {
// /*****************************************现金池**********************************/
// beego.Router("/", &controllers.ConfigController{}, "POST:CashInput") // 现金池投入
//
// /*****************************************兑换活动*********************************/
// beego.Router("/", &controllers.ConfigController{}, "GET:ListExchangeActivities") // 返回兑换活动列表
// beego.Router("/", &controllers.ConfigController{}, "PUT:UpdateExchangeActivities") // 更新兑换活动信息
// beego.Router("/", &controllers.ConfigController{}, "POST:CreateExchangeActivities") // 新增兑换活动
// beego.Router("/", &controllers.ConfigController{}, "DELETE:DeleteExchangeActivities") // 删除兑换活动
// beego.Router("/", &controllers.ConfigController{}, "POST:SearchExchangeActivities") // 搜索兑换素币活动
// beego.Router("/", &controllers.ConfigController{}, "GET:ExchangeActivitiesStatistics") // 兑换活动数据统计
//
// /*****************************************兑换素币清单****************************/
// beego.Router("/", &controllers.ConfigController{}, "GET:ListExchangeList") // 返回素币兑换清单列表
// beego.Router("/", &controllers.ConfigController{}, "GET:GetExchangeList") // 返回素币兑换清单
// beego.Router("/", &controllers.ConfigController{}, "POST:CreateExchangeList") // 新增素币兑换清单
// beego.Router("/", &controllers.ConfigController{}, "PUT:UpdateExchangeList") // 更新素币兑换清单
// beego.Router("/", &controllers.ConfigController{}, "DELETE:RemoveExchangeList") // 删除素币兑换清单
// beego.Router("/", &controllers.ConfigController{}, "POST:SearchExchangeList") // 搜索素币兑换记录
// beego.Router("/", &controllers.ConfigController{}, "POST:ExportExchangeList") // 导出素币兑换清单
// beego.Router("/", &controllers.ConfigController{}, "POST:ImportExchangeList") // 导入素币兑换清单
//}
\ No newline at end of file
... ...
package cashPool
import (
"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
"net/http"
"net/http/httptest"
"testing"
"github.com/astaxie/beego"
_ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
_ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/port/beego"
)
func TestConfig(t *testing.T) {
gomega.RegisterFailHandler(Fail)
ginkgo.RunSpecs()
}
var handler http.Handler
var server *httptest.Server
var _ = BeforeSuite(func() {
handler = beego.BeeApp.Handlers
server = httptest.NewServer(handler)
})
var _ = ginkgo.AfterSuite(func() {
server.Close()
})
\ No newline at end of file
... ...