作者 陈志颖

feat:完善现金池、兑换现金活动对象

正在显示 38 个修改的文件 包含 337 行增加203 行删除
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type SystemCashStatisticsCommand struct {
CompanyId int64 `json:"companyId" valid:"Required"` // 公司ID
}
func (systemCashStatisticsCommand *SystemCashStatisticsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(systemCashStatisticsCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type SystemSuMoneyStatisticsCommand struct {
CompanyId int64 `json:"companyId" valid:"Required"` // 公司ID
}
func (systemSuMoneyStatisticsCommand *SystemSuMoneyStatisticsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(systemSuMoneyStatisticsCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
... ... @@ -160,6 +160,7 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone
defer func() {
transactionContext.RollbackTransaction()
}()
var employeeDao *dao.EmployeeDao
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -168,6 +169,7 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone
} else {
employeeDao = value
}
var employeeRepository domain.EmployeeRepository
if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -185,6 +187,7 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone
if employee == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的企业员工")
}
if personSuMoneyStatistics, err := employeeDao.CalculatePersonSuMoney(personSuMoneyStatisticsCommand.Uid); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -196,6 +199,52 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone
}
}
/**
* 获取系统素币统计
*/
func (statisticsService *StatisticsService) SystemSuMoneyStatistics(systemSuMoneyStatisticsCommand *command.SystemSuMoneyStatisticsCommand) (interface{}, error) {
if err := systemSuMoneyStatisticsCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var employeeDao *dao.EmployeeDao
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
employeeDao = value
}
if systemSuMoneyStatistics, err := employeeDao.CalculateSystemExchangedCash(systemSuMoneyStatisticsCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//systemSuMoneyStatistics["currentSuMoney"] = employee.SuMoney
return systemSuMoneyStatistics, nil
}
}
/**
* 获取系统现金统计
*/
//func (statisticsService *StatisticsService) SystemCashStatistics(systemCashStatisticsCommand *command.SystemCashStatisticsCommand) (interface{}, error) {
//
//}
func NewStatisticsService(options map[string]interface{}) *StatisticsService {
newStatisticsService := &StatisticsService{}
return newStatisticsService
... ...
... ... @@ -6,15 +6,16 @@ import (
"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"` // 投入描述
type CreateCashPoolCommand struct {
CashPoolId int64 `json:"cashPoolId" valid:"Required"` // 现金池ID
CompanyId int64 `json:"companyId" valid:"Requires"` // 公司ID
Cash float64 `json:"cash" valid:"Required"` // 投入的现金值
Operator int64 `json:"operator,omitempty"` // 操作人UID
}
func (inputCashPooCommand *InputCashPooCommand) ValidateCommand() error {
func (createCashPoolCommand *CreateCashPoolCommand) ValidateCommand() error {
valid := validation.Validation{}
rt, err := valid.Valid(inputCashPooCommand)
rt, err := valid.Valid(createCashPoolCommand)
if err != nil {
return err
}
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"time"
)
type CreateExchangeActivityCommand struct {
CompanyId int64 `json:"companyId" valid:"Required"` // 公司id
ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称
Deadline time.Time `json:"deadline"` // 活动截止时间
CountDown int64 `json:"countDown"` // 活动倒计时
ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换素币
ExchangedCash float64 `json:"exchangedCash"` // 已兑换现金
ExchangeRate float64 `json:"exchangeRate"` // 兑换汇率
ExchangeCashPeople []*domain.ExchangeCashPerson `json:"exchangeList"` // 兑换活动清单
}
func (createExchangeActivityCommand *CreateExchangeActivityCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(createExchangeActivityCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
... ... @@ -7,16 +7,11 @@ import (
)
type OperationSuMoneyCommand struct {
// 素币拥有者UID
Uid int64 `json:"uid" valid:"Required"`
// 操作类型(1增加,2扣除)
OperationType int `json:"operationType" valid:"Required"`
// 素币值
SuMoney float64 `json:"suMoney" valid:"Required"`
// 操作人UID
Operator int64 `json:"operator,omitempty"`
// 理由描述
OperationDescription string `json:"operationDescription" valid:"Required"`
Uid int64 `json:"uid" valid:"Required"` // 素币拥有者UID
OperationType int `json:"operationType" valid:"Required"` // 操作类型(1增加,2扣除)
SuMoney float64 `json:"suMoney" valid:"Required"` // 素币值
Operator int64 `json:"operator,omitempty"` // 操作人UID
OperationDescription string `json:"operationDescription" valid:"Required"` // 理由描述
}
func (operationSuMoneyCommand *OperationSuMoneyCommand) ValidateCommand() error {
... ...
... ... @@ -114,6 +114,9 @@ func (suMoneyService *SuMoneyService) ExchangeSuMoney(exchangeSuMoneyCommand *co
}
}
// 素币兑换现金
//func (suMoneyService *SuMoneyService) ExchangeCash(exchangeCashComman *)
// 搜索素币事务记录
func (suMoneyService *SuMoneyService) SearchSuMoneyTransactionRecord(searchSuMoneyTransactionRecordCommand *command.SearchSuMoneyTransactionRecordCommand) (interface{}, error) {
if err := searchSuMoneyTransactionRecordCommand.ValidateCommand(); err != nil {
... ...
package domain
// 现金池信息
// 现金池
type CashPool 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
CashPoolId int64 `json:"cashPoolId"` // 现金池id
CompanyId int64 `json:"companyId"` // 公司id
Cash float64 `json:"cashPool"` // 投入现金池的现金
ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金
UnExchangeCash float64 `json:"unExchangeCash"` // 未兑换的现金
ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币
UnExchangeSuMoney float64 `json:"unExchangeSuMoney"` // 未兑换的素币
Rate float64 `json:"rate"` // 平均兑换汇率
}
type CashPoolRepository interface {
Save(cashPool *CashPool) (*CashPool, error)
}
func (cashPool *CashPool) Identity() interface{} {
if cashPool.CompanyId == 0 {
return nil
}
return cashPool.CompanyId
}
... ...
package domain
import "time"
// 现金池事务记录
type CashPoolTransactionRecord struct {
CashPoolTransactionRecordId int64 `json:"cashPoolTransactionRecordId"` // 现金池事务记录ID
RecordType int `json:"recordType"` // 记录类型
CashPoolBeforeTransaction *CashPool `json:"cashPoolBeforeTransaction"` // 事务处理前现金池
CurrentCashPool *CashPool `json:"CurrentCashPool"` // 当前现金池
Cash float64 `json:"CashPool"` // 事务现金值
Operator *EmployeeInfo `json:"operator"` // 操作人
RecordDescription string `json:"recordDescription"` // 现金池事务记录描述
CreateTime time.Time `json:"createTime"` // 创建时间
}
type CashPoolTransactionRecordRepository interface {
Save(cashPoolTransactionRecord *CashPoolTransactionRecord) (*CashPoolTransactionRecord, error)
}
func (cashPoolTransactionRecord *CashPoolTransactionRecord) Identity() interface{} {
if cashPoolTransactionRecord.CashPoolTransactionRecordId == 0 {
return nil
}
return cashPoolTransactionRecord.CashPoolTransactionRecordId
}
// 计算当前现金池中的未兑换现金
func (cashPoolTransactionRecord *CashPoolTransactionRecord) TransferUnExchangeCash(cash float64) error {
cashPoolTransactionRecord.CurrentCashPool.UnExchangeCash += cash
return nil
}
\ No newline at end of file
package domain
import "time"
// 兑换活动
type ExchangeActivity struct {
ExchangeActivityId int64 `json:"exchangeActivityId"` // 兑换素币活动编号
ExchangeActivityName string `json:"exchangeActivityName"` // 兑换素币活动名称
CompanyId int64 `json:"companyId"` // 公司ID
ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金
ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币
CreateTime time.Time `json:"createTime"` // 创建兑换素币活动时间
Deadline time.Time `json:"deadline"` // 兑换素币活动截止时间
CountDown string `json:"countDown"` // 兑换素币活动结束倒计时
Rate float64 `json:"rate"` // 兑换汇率
LastRate float64 `json:"lastRate"` // 上期兑换汇率
ExchangeSuMoneyList []*ExchangePerson `json:"exchangeSuMoneyList"` // 素币兑换清单
}
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.ExchangeActivityId == 0 {
return nil
}
return activity.ExchangeActivityId
}
func (activity *ExchangeActivity) TransferSuMoney(rate float64) error {
activity.ExchangedSuMoney = activity.ExchangedCash * rate
return nil
}
func (activity *ExchangeActivity) TransferLastRate(lastRate float64) error {
activity.LastRate = lastRate
return nil
}
func (activity *ExchangeActivity) TransferCountDown() error {
activity.CountDown = string(time.Until(activity.Deadline))
return nil
}
package domain
import "time"
// 兑换现金活动
type ExchangeCashActivity struct {
ExchangeCashActivityId int64 `json:"exchangeActivityId"` // 兑换现金活动id
ExchangeActivityName string `json:"exchangeActivityName"` // 兑换现金活动名称
CompanyId int64 `json:"companyId"` // 公司ID
ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金
ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币
CreateTime time.Time `json:"createTime"` // 创建兑换现金活动时间
Deadline time.Time `json:"deadline"` // 兑换现金活动截止时间
CountDown string `json:"countDown"` // 兑换现金活动结束倒计时
Rate float64 `json:"rate"` // 兑换汇率
LastRate float64 `json:"lastRate"` // 上期兑换汇率
ExchangeCashPeople []*ExchangeCashPerson `json:"exchangeCashPeople"` // 兑换现金人员清单
}
type ExchangeActivityRepository interface {
Save(exchangeCashActivity *ExchangeCashActivity) (*ExchangeCashActivity, error)
Remove(exchangeCashActivity *ExchangeCashActivity) (*ExchangeCashActivity, error)
FindOne(queryOptions map[string]interface{}) (*ExchangeCashActivity, error)
Find(queryOptions map[string]interface{}) (int64, []*ExchangeCashActivity, error)
}
func (exchangeCashActivity *ExchangeCashActivity) Identity() interface{} {
if exchangeCashActivity.ExchangeCashActivityId == 0 {
return nil
}
return exchangeCashActivity.ExchangeCashActivityId
}
func (exchangeCashActivity *ExchangeCashActivity) TransferSuMoney(rate float64) error {
exchangeCashActivity.ExchangedSuMoney = exchangeCashActivity.ExchangedCash * rate
return nil
}
func (exchangeCashActivity *ExchangeCashActivity) TransferLastRate(lastRate float64) error {
exchangeCashActivity.LastRate = lastRate
return nil
}
func (exchangeCashActivity *ExchangeCashActivity) TransferCountDown() error {
exchangeCashActivity.CountDown = string(time.Until(exchangeCashActivity.Deadline))
return nil
}
... ...
package domain
// 参与兑换现金人员
type ExchangeCashPerson struct {
PersonId int64 `json:"employeeId"` // 兑换人员ID
CompanyId int64 `json:"companyId"` // 公司id
PersonInfo *EmployeeInfo `json:"employeeInfo"` // 兑换人员信息
ExchangedSuMoney float64 `json:"suMoney"` // 已兑换的素币
ExchangedCash float64 `json:"cash"` // 已兑换的现金
}
type ExchangeCashPersonRepository interface {
Save(exchangeCashPerson *ExchangeCashPerson) (*ExchangeCashPerson, error)
Remove(exchangeCashPerson *ExchangeCashPerson) (*ExchangeCashPerson, error)
FindOne(queryOptions map[string]interface{}) (*ExchangeCashPerson, error)
Find(queryOptions map[string]interface{}) (int64, []*ExchangeCashPerson, error)
}
func (exchangeCashPerson *ExchangeCashPerson) Identity() interface{} {
if exchangeCashPerson.PersonId == 0 {
return nil
}
return exchangeCashPerson.PersonId
}
\ No newline at end of file
... ...
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
... ... @@ -3,7 +3,7 @@ package domain
import "time"
const (
SU_MONEY_TRANSACTION_RECORD_TYPE_EXCHANGE = iota + 1 //兑换
SU_MONEY_TRANSACTION_RECORD_TYPE_EXCHANGE = iota + 1 //兑换(物资、现金)
SU_MONEY_TRANSACTION_RECORD_TYPE_AWARD //任务奖励
SU_MONEY_TRANSACTION_RECORD_TYPE_INCREASE //增加
SU_MONEY_TRANSACTION_RECORD_TYPE_DEDUCT //扣除
... ... @@ -11,24 +11,18 @@ const (
// 素币事务记录
type SuMoneyTransactionRecord struct {
// 素币事务记录ID
SuMoneyTransactionRecordId int64 `json:"suMoneyTransactionRecordId"`
// 记录类型
RecordType int `json:"recordType"`
// 记录关联员工
Employee *EmployeeInfo `json:"employee"`
// 事务处理前素币值
SuMoneyBeforeTransaction float64 `json:"suMoneyBeforeTransaction"`
// 当前素币值
CurrentSuMoney float64 `json:"currentSuMoney"`
// 事务素币值
SuMoney float64 `json:"suMoney"`
// 操作人
Operator *EmployeeInfo `json:"operator"`
// 素币事务记录描述
RecordDescription string `json:"recordDescription"`
// 创建时间
CreateTime time.Time `json:"createTime"`
SuMoneyTransactionRecordId int64 `json:"suMoneyTransactionRecordId"` // 素币事务记录ID
RecordType int `json:"recordType"` // 记录类型
Employee *EmployeeInfo `json:"employee"` // 记录关联员工
SuMoneyBeforeTransaction float64 `json:"suMoneyBeforeTransaction"` // 事务处理前素币值
CurrentSuMoney float64 `json:"currentSuMoney"` // 当前素币值
CashPoolBeforeTransaction *CashPool `json:"cashPoolBeforeTransaction"` // 事务处理前现金池,用于兑换现金操作
CurrentCashPool *CashPool `json:"currentCashPool"` // 当前现金池,用于兑换现金操作
SuMoney float64 `json:"suMoney"` // 事务素币值
Cash float64 `json:"cash"` // 事务现金值,用于兑换现金
Operator *EmployeeInfo `json:"operator"` // 操作人
RecordDescription string `json:"recordDescription"` // 素币事务记录描述
CreateTime time.Time `json:"createTime"` // 创建时间
}
type SuMoneyTransactionRecordRepository interface {
... ...
... ... @@ -143,6 +143,42 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction
}, nil
}
func (dao *EmployeeDao) CalculateSystemUnChangeSuMoney(companyId int64) (map[string]interface{}, error) {
var unExchangeSuMoney float64
tx := dao.transactionContext.PgTx
employeeModel := new(models.Employee)
if err := tx.Model(employeeModel).
ColumnExpr("sum(employee.su_money) AS unExchangeSuMoney").
Where("employee.company_id = ?", companyId).
Select(&employeeModel); err != nil {
return nil, err
}
return map[string]interface{}{
"unExchangeSuMoney": unExchangeSuMoney,
}, nil
}
func (dao *EmployeeDao) CalculateSystemExchangedCash(companyId int64) (map[string]interface{}, error) {
var exchangedCash float64
tx := dao.transactionContext.PgTx
suMoneyExchangeTransactionRecordModel := new(models.SuMoneyExchangeTransactionRecord)
if err := tx.Model(suMoneyExchangeTransactionRecordModel).
ColumnExpr("sum(su_money_exchange_transaction_record.cash) AS exchangedCash").
Where("su_money_exchange_transaction_record.company_id = ?", companyId).
Select(&suMoneyExchangeTransactionRecordModel) ; err != nil {
return nil, err
}
return map[string]interface{}{
"exchangedCash": exchangedCash,
}, nil
}
func NewEmployeeDao(transactionContext *pgTransaction.TransactionContext) (*EmployeeDao, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
... ...
... ... @@ -37,8 +37,6 @@ func init() {
(*models.Notification)(nil),
(*models.SentNotification)(nil),
(*models.ExchangeActivities)(nil),
(*models.CashPoolTransactionRecord)(nil),
(*models.ExchangePerson)(nil),
} {
err := DB.CreateTable(model, &orm.CreateTableOptions{
Temp: false,
... ...
... ... @@ -16,7 +16,7 @@ type ExchangeActivities struct {
ExchangedCash float64 // 已兑换现金
ExchangedSuMoney float64 // 已兑换素币
ExchangeRate float64 // 兑换汇率
ExchangeSuMoneyList []*domain.ExchangePerson // 素币兑换人员清单
ExchangeSuMoneyList []*domain.ExchangeCashPerson // 素币兑换人员清单
Sponsor *domain.EmployeeInfo // 活动发布人
CreateTime time.Time // 创建时间
}
\ No newline at end of file
... ...
... ... @@ -5,12 +5,14 @@ import (
"time"
)
type CashPoolTransactionRecord struct {
TableName string `pg:"cash_pool_transaction_records,alias:cash_pool_transaction_record"`
Id int64 `pg:",pk"` // 现金池事务记录ID
type SuMoneyExchangeTransactionRecord struct {
TableName string `pg:"su_money_exchange_transaction_records,alias:su_money_exchange_transaction_record"`
Id int64 `pg:",pk"` // 现金兑换务记录ID
RecordType int // 记录类型
CashPoolBeforeTransaction *domain.CashPoolInfo // 事务处理前现金池
CurrentCashPool *domain.CashPoolInfo // 当前现金池
Employee *domain.EmployeeInfo // 记录关联员工
CashPoolBeforeTransaction *domain.CashPool // 事务处理前现金池
CurrentCashPool *domain.CashPool // 当前现金池
SuMoney float64 // 事务素币值
Cash float64 // 事务现金值
Operator *domain.EmployeeInfo // 操作人
RecordDescription string // 现金投入事务记录描述
... ...
package repository
import (
"github.com/go-pg/pg"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
)
type CashPoolTransactionRecordRepository struct {
transactionContext *pgTransaction.TransactionContext
}
func (repository *CashPoolTransactionRecordRepository) Save(cashPoolTransactionRecord *domain.CashPoolTransactionRecord) (*domain.CashPoolTransactionRecord, error) {
tx := repository.transactionContext.PgTx
if cashPoolTransactionRecord.Identity() == nil {
if _, err := tx.QueryOne(
pg.Scan(&cashPoolTransactionRecord.CashPoolTransactionRecordId, &cashPoolTransactionRecord.RecordType, &cashPoolTransactionRecord.Cash, &cashPoolTransactionRecord.CashPoolBeforeTransaction, &cashPoolTransactionRecord.CurrentCashPool, &cashPoolTransactionRecord.Operator, &cashPoolTransactionRecord.CreateTime, &cashPoolTransactionRecord.RecordDescription),
"INSERT INTO cash_pool_transaction_records ()"); err != nil {
return cashPoolTransactionRecord, err
}
} else {
if _, err := tx.QueryOne(
pg.Scan(&cashPoolTransactionRecord.CashPoolTransactionRecordId, &cashPoolTransactionRecord.RecordType, &cashPoolTransactionRecord.Cash, &cashPoolTransactionRecord.CashPoolBeforeTransaction, &cashPoolTransactionRecord.CurrentCashPool, &cashPoolTransactionRecord.Operator, &cashPoolTransactionRecord.CreateTime, &cashPoolTransactionRecord.RecordDescription),
"UPDATE cash_pool_transaction_records SET "); err != nil {
return cashPoolTransactionRecord, err
}
}
return cashPoolTransactionRecord, nil
}
\ No newline at end of file
... ... @@ -33,6 +33,7 @@ func (repository *SuMoneyTransactionRecordRepository) Save(suMoneyTransactionRec
}
return suMoneyTransactionRecord, nil
}
func (repository *SuMoneyTransactionRecordRepository) Remove(suMoneyTransactionRecord *domain.SuMoneyTransactionRecord) (*domain.SuMoneyTransactionRecord, error) {
tx := repository.transactionContext.PgTx
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
... ... @@ -42,6 +43,7 @@ func (repository *SuMoneyTransactionRecordRepository) Remove(suMoneyTransactionR
}
return suMoneyTransactionRecord, nil
}
func (repository *SuMoneyTransactionRecordRepository) FindOne(queryOptions map[string]interface{}) (*domain.SuMoneyTransactionRecord, error) {
tx := repository.transactionContext.PgTx
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
... ... @@ -62,6 +64,7 @@ func (repository *SuMoneyTransactionRecordRepository) FindOne(queryOptions map[s
return repository.transformPgModelToDomainModel(suMoneyTransactionRecordModel)
}
}
func (repository *SuMoneyTransactionRecordRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.SuMoneyTransactionRecord, error) {
tx := repository.transactionContext.PgTx
var suMoneyTransactionRecordModels []*models.SuMoneyTransactionRecord
... ... @@ -114,6 +117,7 @@ func (repository *SuMoneyTransactionRecordRepository) Find(queryOptions map[stri
return int64(count), suMoneyTransactionRecords, nil
}
}
func (repository *SuMoneyTransactionRecordRepository) transformPgModelToDomainModel(suMoneyTransactionRecordModel *models.SuMoneyTransactionRecord) (*domain.SuMoneyTransactionRecord, error) {
return &domain.SuMoneyTransactionRecord{
SuMoneyTransactionRecordId: suMoneyTransactionRecordModel.Id,
... ... @@ -127,6 +131,7 @@ func (repository *SuMoneyTransactionRecordRepository) transformPgModelToDomainMo
CreateTime: suMoneyTransactionRecordModel.CreateTime,
}, nil
}
func NewSuMoneyTransactionRecordRepository(transactionContext *pgTransaction.TransactionContext) (*SuMoneyTransactionRecordRepository, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
... ...
... ... @@ -72,3 +72,17 @@ func (controller *StatisticsController) PersonNotificationStatistics() {
controller.Data["json"] = response
controller.ServeJSON()
}
// TODO 系统素币统计
func (controller *StatisticsController) SystemSuMoneyStatistics() {
//statisticsService := service.NewStatisticsService(nil)
//systemSuMoneyStatisticsCommand := &command.SystemSuMoneyStatisticsCommand{}
//json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), systemSuMoneyStatisticsCommand)
////data, err := statisticsService
}
// TODO 系统现金统计
func (controller *StatisticsController) SystemCashStatistics() {
//statisticsService := service.NewStatisticsService(nil)
}
\ No newline at end of file
... ...
package routers
// TODO
//func init() {
// /*****************************************现金池**********************************/
// beego.Router("/cash_pool/input", &controllers.ConfigController{}, "POST:CashInput") // 现金池投入
//
// /*****************************************兑换活动*********************************/
// beego.Router("/cash_pool/", &controllers.ConfigController{}, "GET:ListExchangeActivities") // 返回兑换活动列表
// beego.Router("/cash_pool/:aid", &controllers.ConfigController{}, "PUT:UpdateExchangeActivities") // 编辑兑换活动信息
// beego.Router("/cash_pool/", &controllers.ConfigController{}, "POST:CreateExchangeActivities") // 新增兑换活动
// beego.Router("/cash_pool/:aid", &controllers.ConfigController{}, "DELETE:DeleteExchangeActivities") // 删除兑换活动
//
// /*****************************************兑换素币清单****************************/
// beego.Router("/cash_pool/exchange", &controllers.ConfigController{}, "GET:ListExchangeList") // 返回素币兑换清单
// beego.Router("/cash_pool/exchange", &controllers.ConfigController{}, "POST:CreateExchangeList") // 新增素币兑换清单列表
// beego.Router("/cash_pool/exchange/:eid", &controllers.ConfigController{}, "PUT:UpdateExchangeList") // 编辑素币兑换清单
// beego.Router("/cash_pool/exchange/:eid", &controllers.ConfigController{}, "DELETE:RemoveExchangeList") // 删除素币兑换清单
// beego.Router("/cash_pool/export", &controllers.ConfigController{}, "POST:ExportExchangeList") // 导出素币兑换清单
// beego.Router("/cash_pool/import", &controllers.ConfigController{}, "POST:ImportExchangeList") // 导入素币兑换清单
//}
\ No newline at end of file
func init() {
///*****************************************现金池**********************************/
//beego.Router("/cash_pool/input", &controllers.ConfigController{}, "POST:CashInput") // 现金池投入
//
///*****************************************兑换活动*********************************/
//beego.Router("/cashPool-pool/", &controllers.ConfigController{}, "GET:ListExchangeActivities") // 返回兑换活动列表
//beego.Router("/cashPool-pool/:aid", &controllers.ConfigController{}, "PUT:UpdateExchangeActivities") // 编辑兑换活动
//beego.Router("/cashPool-pool/", &controllers.ConfigController{}, "POST:CreateExchangeActivities") // 新增兑换活动
//beego.Router("/cashPool-pool/:aid", &controllers.ConfigController{}, "DELETE:DeleteExchangeActivities") // 删除兑换活动
//
///*****************************************兑换素币清单****************************/
//beego.Router("/cashPool-pool/exchange", &controllers.ConfigController{}, "GET:ListExchangeList") // 返回素币兑换清单
//beego.Router("/cashPool-pool/exchange", &controllers.ConfigController{}, "POST:CreateExchangeList") // 新增素币兑换清单
//beego.Router("/cashPool-pool/exchange/:eid", &controllers.ConfigController{}, "PUT:UpdateExchangeList") // 编辑素币兑换清单
//beego.Router("/cashPool-pool/exchange/:eid", &controllers.ConfigController{}, "DELETE:RemoveExchangeList") // 删除素币兑换清单
//beego.Router("/cashPool-pool/export", &controllers.ConfigController{}, "POST:ExportExchangeList") // 导出素币兑换清单
//beego.Router("/cashPool-pool/import", &controllers.ConfigController{}, "POST:ImportExchangeList") // 导入素币兑换清单
}
\ No newline at end of file
... ...
... ... @@ -10,4 +10,6 @@ func init() {
beego.Router("/statistics/person-task", &controllers.StatisticsController{}, "Post:PersonTaskStatistics")
beego.Router("/statistics/person-su-money", &controllers.StatisticsController{}, "Post:PersonSuMoneyStatistics")
beego.Router("/statistics/person-notification", &controllers.StatisticsController{}, "Post:PersonNotificationStatistics")
beego.Router("/statistics/system-su-money", &controllers.StatisticsController{}, "Post:SystemSuMoneyStatistics") // 系统素币统计
beego.Router("/statistics/system-cashPool", &controllers.StatisticsController{}, "Post:SystemCashStatistics") // 系统现金统计
}
... ...