作者 陈志颖

feat:调整素币管理功能增删改查功能,添加接口

@@ -9,15 +9,15 @@ import ( @@ -9,15 +9,15 @@ import (
9 9
10 // 创建现金兑换活动 10 // 创建现金兑换活动
11 type CreateExchangeActivityCommand struct { 11 type CreateExchangeActivityCommand struct {
12 - CompanyId int64 `json:"companyId" valid:"Required"` // 公司id  
13 - ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称  
14 - CashPool *domain.CashPool `json:"cashPool"` // 兑换现金活动关联的现金池,最新的现金池  
15 - Deadline time.Time `json:"deadline"` // 活动截止时间  
16 - CountDown int64 `json:"countDown"` // 活动倒计时  
17 - ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换素币  
18 - ExchangedCash float64 `json:"exchangedCash"` // 已兑换现金  
19 - ExchangeRate float64 `json:"exchangeRate"` // 兑换汇率  
20 - ExchangeCashPeople []*domain.ExchangeCashPerson `json:"exchangeList"` // 兑换活动清单 12 + CompanyId int64 `json:"companyId" valid:"Required"` // 公司id
  13 + ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称
  14 + CashPool *domain.CashPool `json:"cashPool"` // 兑换现金活动关联的现金池,最新的现金池
  15 + Deadline time.Time `json:"deadline"` // 活动截止时间
  16 + CountDown int64 `json:"countDown"` // 活动倒计时
  17 + ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换素币
  18 + ExchangedCash float64 `json:"exchangedCash"` // 已兑换现金
  19 + ExchangeRate float64 `json:"exchangeRate"` // 兑换汇率
  20 + ExchangeCashPeople []*domain.ExchangeCashPersonList `json:"exchangeList"` // 兑换活动清单
21 } 21 }
22 22
23 func (createExchangeActivityCommand *CreateExchangeActivityCommand) ValidateCommand() error { 23 func (createExchangeActivityCommand *CreateExchangeActivityCommand) ValidateCommand() error {
@@ -8,15 +8,15 @@ import ( @@ -8,15 +8,15 @@ import (
8 ) 8 )
9 9
10 type UpdateExchangeCashActivity struct { 10 type UpdateExchangeCashActivity struct {
11 - ExchangeCashActivityId int64 `json:"exchangeCashActivityId"` // 兑换现金活动id  
12 - CompanyId int64 `json:"companyId" valid:"Required"` // 公司id  
13 - ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称  
14 - Deadline time.Time `json:"deadline"` // 活动截止时间  
15 - CountDown int64 `json:"countDown"` // 活动倒计时  
16 - ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换素币  
17 - ExchangedCash float64 `json:"exchangedCash"` // 已兑换现金  
18 - ExchangeRate float64 `json:"exchangeRate"` // 兑换汇率  
19 - ExchangeCashPeople []*domain.ExchangeCashPerson `json:"exchangeCashPeople"` // 兑换活动清单 11 + ExchangeCashActivityId int64 `json:"exchangeCashActivityId"` // 兑换现金活动id
  12 + CompanyId int64 `json:"companyId" valid:"Required"` // 公司id
  13 + ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称
  14 + Deadline time.Time `json:"deadline"` // 活动截止时间
  15 + CountDown int64 `json:"countDown"` // 活动倒计时
  16 + ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换素币
  17 + ExchangedCash float64 `json:"exchangedCash"` // 已兑换现金
  18 + ExchangeRate float64 `json:"exchangeRate"` // 兑换汇率
  19 + ExchangeCashPeople []*domain.ExchangeCashPersonList `json:"exchangeCashPeople"` // 兑换活动清单
20 } 20 }
21 21
22 func (updateExchangeCashActivity *UpdateExchangeCashActivity) ValidateCommand() error { 22 func (updateExchangeCashActivity *UpdateExchangeCashActivity) ValidateCommand() error {
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/astaxie/beego/validation"
  7 +)
  8 +
  9 +type GetExchangeCashPersonQuery struct {
  10 + ExchangeCashPersonId int64 `json:"exchangeCashPersonId"` // 参与兑换现金活动人员id
  11 +}
  12 +
  13 +func (getExchangeCashPersonQuery *GetExchangeCashPersonQuery) ValidateQuery() error {
  14 + valid := validation.Validation{}
  15 + b, err := valid.Valid(getExchangeCashPersonQuery)
  16 + if err != nil {
  17 + return err
  18 + }
  19 + if !b {
  20 + for _, validErr := range valid.Errors {
  21 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  22 + }
  23 + }
  24 + return nil
  25 +}
@@ -4,17 +4,18 @@ import "time" @@ -4,17 +4,18 @@ import "time"
4 4
5 // 兑换现金活动 5 // 兑换现金活动
6 type ExchangeCashActivity struct { 6 type ExchangeCashActivity struct {
7 - ExchangeCashActivityId int64 `json:"exchangeActivityId"` // 兑换现金活动id  
8 - ExchangeActivityName string `json:"exchangeActivityName"` // 兑换现金活动名称  
9 - CompanyId int64 `json:"companyId"` // 公司ID  
10 - ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金  
11 - ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币  
12 - CreateTime time.Time `json:"createTime"` // 创建兑换现金活动时间  
13 - Deadline time.Time `json:"deadline"` // 兑换现金活动截止时间  
14 - CountDown string `json:"countDown"` // 兑换现金活动结束倒计时  
15 - Rate float64 `json:"rate"` // 兑换汇率  
16 - LastRate float64 `json:"lastRate"` // 上期兑换汇率  
17 - ExchangeCashPeople []*ExchangeCashPerson `json:"exchangeCashPeople"` // 兑换现金人员清单 7 + ExchangeCashActivityId int64 `json:"exchangeActivityId"` // 兑换现金活动id
  8 + ExchangeActivityName string `json:"exchangeActivityName"` // 兑换现金活动名称
  9 + CompanyId int64 `json:"companyId"` // 公司ID
  10 + ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金
  11 + ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币
  12 + CreateTime time.Time `json:"createTime"` // 创建兑换现金活动时间
  13 + Deadline time.Time `json:"deadline"` // 兑换现金活动截止时间
  14 + CountDown string `json:"countDown"` // 兑换现金活动结束倒计时
  15 + Rate float64 `json:"rate"` // 兑换汇率
  16 + LastRate float64 `json:"lastRate"` // 上期兑换汇率
  17 + Operator *EmployeeInfo `json:"operator"` // 活动发布人
  18 + ExchangeCashPeople []*ExchangeCashPersonList `json:"exchangeCashPeople"` // 兑换现金人员清单
18 } 19 }
19 20
20 type ExchangeActivityRepository interface { 21 type ExchangeActivityRepository interface {
1 -package domain  
2 -  
3 -// 参与兑换现金人员  
4 -type ExchangeCashPerson struct {  
5 - ExchangeCashPersonId int64 `json:"employeeId"` // 兑换人员ID  
6 - CompanyId int64 `json:"companyId"` // 公司id  
7 - ExchangeCashPersonInfo *EmployeeInfo `json:"employeeInfo"` // 兑换人员信息  
8 - ExchangedSuMoney float64 `json:"suMoney"` // 已兑换的素币  
9 - ExchangedCash float64 `json:"cash"` // 已兑换的现金  
10 -}  
11 -  
12 -type ExchangeCashPersonRepository interface {  
13 - Save(exchangeCashPerson *ExchangeCashPerson) (*ExchangeCashPerson, error)  
14 - Remove(exchangeCashPerson *ExchangeCashPerson) (*ExchangeCashPerson, error)  
15 - FindOne(queryOptions map[string]interface{}) (*ExchangeCashPerson, error)  
16 - Find(queryOptions map[string]interface{}) (int64, []*ExchangeCashPerson, error)  
17 -}  
18 -  
19 -func (exchangeCashPerson *ExchangeCashPerson) Identity() interface{} {  
20 - if exchangeCashPerson.ExchangeCashPersonId == 0 {  
21 - return nil  
22 - }  
23 - return exchangeCashPerson.ExchangeCashPersonId  
24 -}  
  1 +package domain
  2 +
  3 +// 参与兑换现金人员
  4 +type ExchangeCashPersonList struct {
  5 + ExchangeCashPersonListId int64 `json:"employeeId"` // 兑换人员ID
  6 + CompanyId int64 `json:"companyId"` // 公司id
  7 + ExchangeCashActivityId int64 `json:"exchangeActivityId"` // 参与的兑换活动id
  8 + ExchangeCashPerson *Employee `json:"employeeInfo"` // 兑换人员信息
  9 + ExchangedSuMoney float64 `json:"suMoney"` // 已兑换的素币
  10 + ExchangedCash float64 `json:"cash"` // 已兑换的现金
  11 +}
  12 +
  13 +type ExchangeCashPersonListRepository interface {
  14 + Save(exchangeCashPersonList *ExchangeCashPersonList) (*ExchangeCashPersonList, error)
  15 + Remove(exchangeCashPersonList *ExchangeCashPersonList) (*ExchangeCashPersonList, error)
  16 + FindOne(queryOptions map[string]interface{}) (*ExchangeCashPersonList, error)
  17 + Find(queryOptions map[string]interface{}) (int64, []*ExchangeCashPersonList, error)
  18 +}
  19 +
  20 +func (exchangeCashPersonList *ExchangeCashPersonList) Identity() interface{} {
  21 + if exchangeCashPersonList.ExchangeCashPersonListId == 0 {
  22 + return nil
  23 + }
  24 + return exchangeCashPersonList.ExchangeCashPersonListId
  25 +}
@@ -2,12 +2,10 @@ package domain_service @@ -2,12 +2,10 @@ package domain_service
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 - "github.com/linmadan/egglib-go/core/application"  
6 coreDomain "github.com/linmadan/egglib-go/core/domain" 5 coreDomain "github.com/linmadan/egglib-go/core/domain"
7 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
8 - "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory" 7 + //"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
9 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" 8 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
10 - "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"  
11 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/repository" 9 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/repository"
12 "time" 10 "time"
13 ) 11 )
@@ -27,34 +25,34 @@ func (service *CashPoolService) Input(companyId int64, operatorUid int64, cash f @@ -27,34 +25,34 @@ func (service *CashPoolService) Input(companyId int64, operatorUid int64, cash f
27 employeeRepository = repository 25 employeeRepository = repository
28 } 26 }
29 27
30 - transactionContext, err := factory.CreateTransactionContext(nil) 28 + //transactionContext, err := factory.CreateTransactionContext(nil)
  29 + //
  30 + //var employeeDao *dao.EmployeeDao
  31 + //if value, err := factory.CreateEmployeeDao(map[string]interface{}{
  32 + // "transactionContext": transactionContext,
  33 + //}); err != nil {
  34 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  35 + //} else {
  36 + // employeeDao = value
  37 + //}
31 38
32 - var employeeDao *dao.EmployeeDao  
33 - if value, err := factory.CreateEmployeeDao(map[string]interface{}{  
34 - "transactionContext": transactionContext,  
35 - }); err != nil {  
36 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
37 - } else {  
38 - employeeDao = value  
39 - } 39 + //var systemExchangedCash float64
  40 + //if value, err := employeeDao.CalculateSystemCash(companyId); err != nil {
  41 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  42 + //} else {
  43 + // systemExchangedCash = value
  44 + //}
40 45
41 - var systemExchangedCash float64  
42 - if value, err := employeeDao.CalculateSystemCash(companyId); err != nil {  
43 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
44 - } else {  
45 - systemExchangedCash = value  
46 - }  
47 -  
48 - var (  
49 - systemChangedSuMoney float64  
50 - systemUnChangeSuMoney float64  
51 - )  
52 - if value1, value2, err := employeeDao.CalculateSystemSuMoney(companyId); err != nil {  
53 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
54 - } else {  
55 - systemChangedSuMoney = value1  
56 - systemUnChangeSuMoney = value2  
57 - } 46 + //var (
  47 + // systemChangedSuMoney float64
  48 + // systemUnChangeSuMoney float64
  49 + //)
  50 + //if value1, value2, err := employeeDao.CalculateSystemSuMoney(companyId); err != nil {
  51 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  52 + //} else {
  53 + // systemChangedSuMoney = value1
  54 + // systemUnChangeSuMoney = value2
  55 + //}
58 56
59 operator, err := employeeRepository.FindOne(map[string]interface{}{ 57 operator, err := employeeRepository.FindOne(map[string]interface{}{
60 "uid": operatorUid, 58 "uid": operatorUid,
@@ -79,11 +77,11 @@ func (service *CashPoolService) Input(companyId int64, operatorUid int64, cash f @@ -79,11 +77,11 @@ func (service *CashPoolService) Input(companyId int64, operatorUid int64, cash f
79 cashPoolInfo := &domain.CashPool{ 77 cashPoolInfo := &domain.CashPool{
80 CompanyId: companyId, 78 CompanyId: companyId,
81 Cash: cash, 79 Cash: cash,
82 - ExchangedCash: systemExchangedCash, 80 + //ExchangedCash: systemExchangedCash,
83 UnExchangeCash: currentCashPool.UnExchangeCash + cash, 81 UnExchangeCash: currentCashPool.UnExchangeCash + cash,
84 - ExchangedSuMoney: systemChangedSuMoney,  
85 - UnExchangeSuMoney: systemUnChangeSuMoney,  
86 - Rate: systemExchangedCash / systemChangedSuMoney, 82 + //ExchangedSuMoney: systemChangedSuMoney,
  83 + //UnExchangeSuMoney: systemUnChangeSuMoney,
  84 + //Rate: systemExchangedCash / systemChangedSuMoney,
87 Operator: operator.EmployeeInfo, 85 Operator: operator.EmployeeInfo,
88 CreateTime: time.Now(), 86 CreateTime: time.Now(),
89 } 87 }
@@ -36,8 +36,9 @@ func init() { @@ -36,8 +36,9 @@ func init() {
36 (*models.RejectTaskRecord)(nil), 36 (*models.RejectTaskRecord)(nil),
37 (*models.Notification)(nil), 37 (*models.Notification)(nil),
38 (*models.SentNotification)(nil), 38 (*models.SentNotification)(nil),
39 - (*models.ExchangeActivities)(nil), 39 + (*models.ExchangeCashActivity)(nil),
40 (*models.CashPool)(nil), 40 (*models.CashPool)(nil),
  41 + (*models.ExchangeCashPersonList)(nil),
41 } { 42 } {
42 err := DB.CreateTable(model, &orm.CreateTableOptions{ 43 err := DB.CreateTable(model, &orm.CreateTableOptions{
43 Temp: false, 44 Temp: false,
1 package models 1 package models
2 2
3 type CashPool struct { 3 type CashPool struct {
4 - Id int64 `json:"id"` // 现金池id 4 + TableName string `pg:"cash_pools,alias:cash_pool"`
  5 + Id int64 `pg:",pk"` // 现金池id
  6 + CompanyId int64 // 公司id
  7 + ExchangedCash float64 // 系统已兑换现金
  8 + UnExchangeCash float64 // 系统未兑换现金
  9 + ExchangedSuMoney float64 // 系统已兑换素币
  10 + UnExchangeSuMoney float64 // 系统未兑换素币
  11 + Rate float64 // 兑换汇率
5 } 12 }
@@ -6,17 +6,17 @@ import ( @@ -6,17 +6,17 @@ import (
6 ) 6 )
7 7
8 type ExchangeCashActivity struct { 8 type ExchangeCashActivity struct {
9 - TableName string `pg:"exchange_activities,alias:exchange_activity"`  
10 - Id int64 `pg:",pk"` // 兑换活动ID  
11 - CompanyId int64 // 公司ID  
12 - ActivityName string // 兑换活动名称  
13 - ActivityStart time.Time // 兑换活动开始时间  
14 - ActivityEnd time.Time // 兑换活动结束时间  
15 - ActivityPeriod string // 兑换活动持续时间  
16 - ExchangedCash float64 // 已兑换现金  
17 - ExchangedSuMoney float64 // 已兑换素币  
18 - ExchangeRate float64 // 兑换汇率  
19 - ExchangeSuMoneyList []*domain.ExchangeCashPerson // 素币兑换人员清单  
20 - Sponsor *domain.EmployeeInfo // 活动发布人  
21 - CreateTime time.Time // 创建时间 9 + TableName string `pg:"exchange_cash_activities,alias:exchange_cash_activity"`
  10 + Id int64 `pg:",pk"` // 兑换活动ID
  11 + CompanyId int64 // 公司ID
  12 + ActivityName string // 兑换活动名称
  13 + Deadline time.Time // 兑换活动结束时间
  14 + CountDown string // 兑换活动结束倒计时
  15 + ExchangedCash float64 // 已兑换现金
  16 + ExchangedSuMoney float64 // 已兑换素币
  17 + ExchangeRate float64 // 兑换汇率
  18 + LastExchangeRate float64 // 上期活动兑换汇率
  19 + ExchangeSuMoneyList []*domain.ExchangeCashPersonList `pg:",array"` // 素币兑换人员清单
  20 + Sponsor *domain.EmployeeInfo // 活动发布人
  21 + CreateTime time.Time // 创建时间
22 } 22 }
1 -package models  
2 -  
3 -type ExchangeCashPerson struct {  
4 -  
5 -}  
  1 +package models
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  5 + "time"
  6 +)
  7 +
  8 +type ExchangeCashPersonList struct {
  9 + TableName string `pg:"exchange_cash_list"`
  10 + Id int64 `pg:",pk"` // 兑换现金清单id
  11 + PersonInfo *domain.Employee // 兑换现金人员
  12 + ExchangedSuMoney float64 // 已兑换素币
  13 + ExchangedCash float64 // 已兑换现金
  14 + CreateTime time.Time // 兑换时间
  15 +}
@@ -2,6 +2,7 @@ package repository @@ -2,6 +2,7 @@ package repository
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "github.com/go-pg/pg"
5 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
6 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" 7 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
7 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg/models" 8 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg/models"
@@ -11,19 +12,52 @@ type CashPoolRepository struct { @@ -11,19 +12,52 @@ type CashPoolRepository struct {
11 transactionContext *pgTransaction.TransactionContext 12 transactionContext *pgTransaction.TransactionContext
12 } 13 }
13 14
14 -func (repostitory *CashPoolRepository) Save() (*domain.CashPool, error) {  
15 -  
16 - return nil, nil 15 +func (repository *CashPoolRepository) Save(cashPool *domain.CashPool) (*domain.CashPool, error) {
  16 + tx := repository.transactionContext.PgTx
  17 + if cashPool.Identity() == nil {
  18 + if _, err := tx.QueryOne(
  19 + pg.Scan(&cashPool.CashPoolId, &cashPool.Cash, &cashPool.CompanyId, &cashPool.ExchangedCash, &cashPool.UnExchangeCash, &cashPool.ExchangedSuMoney, &cashPool.UnExchangeSuMoney, &cashPool.Rate),
  20 + "INSERT INTO cash_pool (cash, company_id, exchanged_cash, unExchange_cash, exchanged_su_money, unExchange_su_money, rate) VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, exchanged_cash, unExchange_cash, exchanged_su_money, unExchange_su_money",
  21 + cashPool.Cash, cashPool.CompanyId, cashPool.ExchangedCash, cashPool.UnExchangeCash, cashPool.ExchangedSuMoney, cashPool.UnExchangeSuMoney, cashPool.Rate); err != nil {
  22 + return cashPool, err
  23 + }
  24 + } else {
  25 + if _, err := tx.QueryOne(
  26 + pg.Scan(&cashPool.CashPoolId, &cashPool.Cash, &cashPool.CompanyId, &cashPool.ExchangedCash, &cashPool.UnExchangeCash, &cashPool.ExchangedSuMoney, &cashPool.UnExchangeSuMoney, &cashPool.Rate),
  27 + "UPDATE cash_pool SET cash=?, company_id=? exchanged_cash, unExchange_cash, exchanged_su_money, unExchange_su_money, rate WHERE company_id=? RETURNING id, company_id, exchanged_cash, unExchange_cash, exchanged_su_money, unExchange_su_money, rate",
  28 + cashPool.Cash, cashPool.CompanyId, cashPool.ExchangedCash, cashPool.UnExchangeCash, cashPool.ExchangedSuMoney, cashPool.UnExchangeSuMoney, cashPool.Rate, cashPool.Identity()); err != nil {
  29 + return cashPool, err
  30 + }
  31 + }
  32 + return cashPool, nil
17 } 33 }
18 34
19 -func (repostitory *CashPoolRepository) FindOne(queryOptions map[string]interface{}) (*domain.CashPool, error) {  
20 -  
21 - return nil, nil 35 +func (repository *CashPoolRepository) FindOne(queryOptions map[string]interface{}) (*domain.CashPool, error) {
  36 + tx := repository.transactionContext.PgTx
  37 + cashPoolModel := new(models.CashPool)
  38 + query := tx.Model(cashPoolModel)
  39 + // 根据公司id查找现金池
  40 + if companyId, ok := queryOptions["companyId"]; ok {
  41 + query = query.Where("cash_pool.company_id = ?", companyId)
  42 + }
  43 + if err := query.First(); err != nil {
  44 + if err.Error() == "pg: no rows in result set" {
  45 + return nil, fmt.Errorf("没有此资源")
  46 + } else {
  47 + return nil, err
  48 + }
  49 + }
  50 + if cashPoolModel.CompanyId == 0 {
  51 + return nil, nil
  52 + } else {
  53 + return repository.transformPgModelToDomainModel(cashPoolModel)
  54 + }
22 } 55 }
23 56
24 func (repository *CashPoolRepository) transformPgModelToDomainModel(cashPoolModel *models.CashPool) (*domain.CashPool, error) { 57 func (repository *CashPoolRepository) transformPgModelToDomainModel(cashPoolModel *models.CashPool) (*domain.CashPool, error) {
25 return &domain.CashPool{ 58 return &domain.CashPool{
26 CashPoolId: cashPoolModel.Id, 59 CashPoolId: cashPoolModel.Id,
  60 + CompanyId: cashPoolModel.CompanyId,
27 }, nil 61 }, nil
28 } 62 }
29 63
1 package repository 1 package repository
2 2
3 import ( 3 import (
  4 + "fmt"
  5 + "github.com/go-pg/pg"
4 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  7 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  8 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg/models"
  9 + "time"
5 ) 10 )
6 11
7 type ExchangeCashActivityRepository struct { 12 type ExchangeCashActivityRepository struct {
8 transactionContext *pgTransaction.TransactionContext 13 transactionContext *pgTransaction.TransactionContext
9 } 14 }
10 15
11 -func (repository *ExchangeCashActivityRepository) Save() (*ExchangeCashActivityRepository, error) {  
12 -  
13 - return nil, nil 16 +func (repository *ExchangeCashActivityRepository) Save(exchangeCashActivity *domain.ExchangeCashActivity) (*domain.ExchangeCashActivity, error) {
  17 + tx := repository.transactionContext.PgTx
  18 + if exchangeCashActivity.Identity() == nil {
  19 + if _, err := tx.QueryOne(
  20 + pg.Scan(&exchangeCashActivity.ExchangeCashActivityId, &exchangeCashActivity.ExchangeActivityName),
  21 + "INSERT INTO exchange_cash_activity () VALUES () RETURNING id, " ,
  22 + exchangeCashActivity.ExchangeActivityName); err != nil {
  23 + return exchangeCashActivity, err
  24 + }
  25 + } else {
  26 + if _, err := tx.QueryOne(
  27 + pg.Scan(&exchangeCashActivity.ExchangeCashActivityId, &exchangeCashActivity.ExchangeActivityName),
  28 + "UPDATE exchange_cash_activity SET exchange_activity_name=?, WHERE id=? RETURNING id, exchange_cash_activity_name",
  29 + exchangeCashActivity.ExchangeActivityName); err != nil {
  30 + return exchangeCashActivity, err
  31 + }
  32 + }
  33 + return exchangeCashActivity, nil
14 } 34 }
15 35
16 -func (repository *ExchangeCashActivityRepository) FindOne(queryOptions map[string]interface{}) (*ExchangeCashActivityRepository, error) {  
17 -  
18 - return nil, nil 36 +func (repository *ExchangeCashActivityRepository) FindOne(queryOptions map[string]interface{}) (*domain.ExchangeCashActivity, error) {
  37 + tx := repository.transactionContext.PgTx
  38 + exchangeCashActivityModel := new(models.ExchangeCashActivity)
  39 + query := tx.Model(exchangeCashActivityModel)
  40 + if exchangeCashActivityId, ok := queryOptions["exchangeCashActivityId"]; ok {
  41 + query = query.Where("exchange_cash_list.id = ?", exchangeCashActivityId)
  42 + }
  43 + if err := query.First(); err != nil {
  44 + if err.Error() == "pg: no rows in result set" {
  45 + return nil, fmt.Errorf("没有此资源")
  46 + } else {
  47 + return nil, err
  48 + }
  49 + }
  50 + if exchangeCashActivityModel.Id == 0 {
  51 + return nil, nil
  52 + } else {
  53 + return repository.transformPgModelToDomainModel(exchangeCashActivityModel)
  54 + }
19 } 55 }
20 56
21 -func (repository *ExchangeCashActivityRepository) Find(queryOptions map[string]interface{}) (*ExchangeCashActivityRepository, error) {  
22 -  
23 - return nil, nil 57 +func (repository *ExchangeCashActivityRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ExchangeCashActivity, error) {
  58 + tx := repository.transactionContext.PgTx
  59 + var exchangeCashActivityModels []*models.ExchangeCashActivity
  60 + exchangeCashActivities := make([]*domain.ExchangeCashActivity, 0)
  61 + query := tx.Model(&exchangeCashActivityModels)
  62 + // 公司相关活动搜索
  63 + if companyId, ok := queryOptions["companyId"]; ok {
  64 + query = query.Where(`exchange_cash_activity.company_id = ?`, companyId)
  65 + }
  66 + // 活动名称模糊搜索
  67 + if exchangeCashActivityNameMatch, ok := queryOptions["exchangeCashActivityNameMatch"]; ok && (exchangeCashActivityNameMatch != "") {
  68 + query = query.Where(`exchange_cash_activity.exchange_cash_activity_name LIKE ?`, fmt.Sprintf("%%%s%%", exchangeCashActivityNameMatch.(string)))
  69 + }
  70 + // 活动截止时间搜索
  71 + if deadline, ok := queryOptions["exchangeCashActivityDeadline"]; ok && !deadline.(time.Time).IsZero() {
  72 + query = query.Where(`exchange_cash_activity.deadline < ?`, deadline)
  73 + }
  74 + if offset, ok := queryOptions["offset"]; ok {
  75 + offset := offset.(int)
  76 + if offset > -1 {
  77 + query = query.Offset(offset)
  78 + }
  79 + } else {
  80 + query = query.Offset(0)
  81 + }
  82 + if limit, ok := queryOptions["limit"]; ok {
  83 + limit := limit.(int)
  84 + if limit > -1 {
  85 + query = query.Limit(limit)
  86 + }
  87 + } else {
  88 + query = query.Limit(20)
  89 + }
  90 + if count, err := query.Order("id DESC").SelectAndCount(); err != nil {
  91 + return 0, exchangeCashActivities, err
  92 + } else {
  93 + for _, exchangeCashActivityModel := range exchangeCashActivityModels {
  94 + if taskNature, err := repository.transformPgModelToDomainModel(exchangeCashActivityModel); err != nil {
  95 + return 0, exchangeCashActivities, err
  96 + } else {
  97 + exchangeCashActivities = append(exchangeCashActivities, taskNature)
  98 + }
  99 + }
  100 + return int64(count), exchangeCashActivities, nil
  101 + }
24 } 102 }
25 103
26 -func (repository *ExchangeCashActivityRepository) Remove() (*ExchangeCashActivityRepository, error) {  
27 -  
28 - return nil, nil 104 +func (repository *ExchangeCashActivityRepository) Remove(exchangeCashActivity *domain.ExchangeCashActivity) (*domain.ExchangeCashActivity, error) {
  105 + tx := repository.transactionContext.PgTx
  106 + exchangeCashActivityModel := new(models.ExchangeCashActivity)
  107 + exchangeCashActivity.ExchangeCashActivityId = exchangeCashActivity.Identity().(int64)
  108 + if _, err := tx.Model(exchangeCashActivityModel).WherePK().Delete(); err != nil {
  109 + return exchangeCashActivity, err
  110 + }
  111 + return exchangeCashActivity, nil
29 } 112 }
30 113
31 -//func (repository *ExchangeCashActivityRepository) transformPgModelToDomainModel(customerValueModel *models.CustomerValue) (*domain.CustomerValue, error) {  
32 -// return &domain.CustomerValue{  
33 -// CustomerValueId: customerValueModel.Id,  
34 -// CustomerValueName: customerValueModel.CustomerValueName,  
35 -// CompanyId: customerValueModel.CompanyId,  
36 -// }, nil  
37 -//}  
38 -//func NewExchangeCashActivityRepository(transactionContext *pgTransaction.TransactionContext) (*CustomerValueRepository, error) {  
39 -// if transactionContext == nil {  
40 -// return nil, fmt.Errorf("transactionContext参数不能为nil")  
41 -// } else {  
42 -// return &CustomerValueRepository{  
43 -// transactionContext: transactionContext,  
44 -// }, nil  
45 -// }  
46 -//}  
  114 +func (repository *ExchangeCashActivityRepository) transformPgModelToDomainModel(exchangeCashActivity *models.ExchangeCashActivity) (*domain.ExchangeCashActivity, error) {
  115 + return &domain.ExchangeCashActivity{
  116 + ExchangeCashActivityId: exchangeCashActivity.Id,
  117 + ExchangeActivityName: exchangeCashActivity.ActivityName,
  118 + CompanyId: exchangeCashActivity.CompanyId,
  119 + ExchangedCash: exchangeCashActivity.ExchangedCash,
  120 + ExchangedSuMoney: exchangeCashActivity.ExchangedSuMoney,
  121 + CreateTime: exchangeCashActivity.CreateTime,
  122 + Deadline: exchangeCashActivity.Deadline,
  123 + CountDown: exchangeCashActivity.CountDown,
  124 + Rate: exchangeCashActivity.ExchangeRate,
  125 + LastRate: exchangeCashActivity.LastExchangeRate,
  126 + Operator: exchangeCashActivity.Sponsor,
  127 + ExchangeCashPeople: exchangeCashActivity.ExchangeSuMoneyList,
  128 + }, nil
  129 +}
  130 +func NewExchangeCashActivityRepository(transactionContext *pgTransaction.TransactionContext) (*ExchangeCashActivityRepository, error) {
  131 + if transactionContext == nil {
  132 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  133 + } else {
  134 + return &ExchangeCashActivityRepository{
  135 + transactionContext: transactionContext,
  136 + }, nil
  137 + }
  138 +}
  1 +package repository
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/go-pg/pg"
  7 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  8 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  9 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg/models"
  10 +)
  11 +
  12 +type ExchangeCashPersonListRepository struct {
  13 + transactionContext *pgTransaction.TransactionContext
  14 +}
  15 +
  16 +func (repository *ExchangeCashPersonListRepository) Save(exchangeCashList *domain.ExchangeCashPersonList) (*domain.ExchangeCashPersonList, error) {
  17 + tx := repository.transactionContext.PgTx
  18 + if exchangeCashList.Identity() == nil {
  19 + if _, err := tx.QueryOne(
  20 + pg.Scan(&exchangeCashList.ExchangeCashPersonListId, &exchangeCashList.CompanyId, &exchangeCashList.ExchangeCashActivityId, &exchangeCashList.ExchangeCashPerson, &exchangeCashList.ExchangedSuMoney, &exchangeCashList.ExchangedCash),
  21 + "INSERT INTO exchange_cash_list (company_id, exchange_cash_activity_id, exchange_cash_person, exchanged_su_money, exchanged_cash) VALUES (?, ?, ?, ?, ?) RETURNING id, company_id, exchange_cash_activity_id, exchange_cash_person, exchanged_su_money, exchanged_cash",
  22 + exchangeCashList.CompanyId, exchangeCashList.ExchangeCashActivityId, exchangeCashList.ExchangeCashPerson, exchangeCashList.ExchangedSuMoney, exchangeCashList.ExchangedCash); err != nil {
  23 + return exchangeCashList, err
  24 + }
  25 + } else {
  26 + if _, err := tx.QueryOne(
  27 + pg.Scan(&exchangeCashList.ExchangeCashPersonListId, &exchangeCashList.CompanyId, &exchangeCashList.ExchangeCashPerson, &exchangeCashList.ExchangedSuMoney, &exchangeCashList.ExchangedCash),
  28 + "UPDATE exchange_cash_list SET company_id = ?, exchange_cash_activity_id=?, exchange_cash_person=?, exchanged_su_money=?, exchanged_cash=? WHERE id=? RETURNING id, company_id, exchange_cash_activity_id, exchange_cash_person, exchanged_su_money, exchanged_cash",
  29 + exchangeCashList.CompanyId, exchangeCashList.ExchangeCashPerson, exchangeCashList.ExchangeCashActivityId, exchangeCashList.ExchangedSuMoney, exchangeCashList.ExchangedCash); err != nil {
  30 + return exchangeCashList, err
  31 + }
  32 + }
  33 + return exchangeCashList, nil
  34 +}
  35 +
  36 +func (repository *ExchangeCashPersonListRepository) FindOne(queryOptions map[string]interface{}) (*domain.ExchangeCashPersonList, error) {
  37 + tx := repository.transactionContext.PgTx
  38 + exchangeCashListModel := new(models.ExchangeCashPersonList)
  39 + query := tx.Model(exchangeCashListModel)
  40 + if exchangeCashListId, ok := queryOptions["exchangeCashListId"]; ok {
  41 + query = query.Where("exchange_cash_list.id = ?", exchangeCashListId)
  42 + }
  43 + if err := query.First(); err != nil {
  44 + if err.Error() == "pg: no rows in result set" {
  45 + return nil, fmt.Errorf("没有此资源")
  46 + } else {
  47 + return nil, err
  48 + }
  49 + }
  50 + if exchangeCashListModel.Id == 0 {
  51 + return nil, nil
  52 + } else {
  53 + return repository.transformPgModelToDomainModel(exchangeCashListModel)
  54 + }
  55 +}
  56 +
  57 +func (repository *ExchangeCashPersonListRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ExchangeCashPersonList, error) {
  58 + tx := repository.transactionContext.PgTx
  59 + var exchangeCashListModels []*models.ExchangeCashPersonList
  60 + exchangeCashPeople := make([]*domain.ExchangeCashPersonList, 0)
  61 + query := tx.Model(&exchangeCashListModels)
  62 + // 根据公司id查找兑换现金人员清单
  63 + if companyId, ok := queryOptions["companyId"]; ok {
  64 + query = query.Where("exchange_cash_list.company_id = ?", companyId)
  65 + }
  66 + // 根据活动id查找兑换现金人员清单
  67 + if exchangeCashActivityId, ok := queryOptions["activityId"]; ok {
  68 + query = query.Where("exchange_cash_list.exchange_cash_activity_id = ?", exchangeCashActivityId)
  69 + }
  70 + // 根据兑换现金人员名称搜索人员清单
  71 + if personNameMatch, ok := queryOptions["personNameMatch"]; ok && (personNameMatch != ""){
  72 + query = query.Where("exchange_cash_list.exchange_cash_person LIKE ", fmt.Sprintf("%%%s%%", personNameMatch.(string)))
  73 + }
  74 + if offset, ok := queryOptions["offset"]; ok {
  75 + offset := offset.(int)
  76 + if offset > -1 {
  77 + query = query.Offset(offset)
  78 + }
  79 + } else {
  80 + query = query.Offset(0)
  81 + }
  82 + if limit, ok := queryOptions["limit"]; ok {
  83 + limit := limit.(int)
  84 + if limit > -1 {
  85 + query = query.Limit(limit)
  86 + }
  87 + } else {
  88 + query = query.Limit(20)
  89 + }
  90 + if count, err := query.Order("id DESC").SelectAndCount(); err != nil {
  91 + return 0, exchangeCashPeople, err
  92 + } else {
  93 + for _, exchangeCashListModel := range exchangeCashListModels {
  94 + if taskNature, err := repository.transformPgModelToDomainModel(exchangeCashListModel); err != nil {
  95 + return 0, exchangeCashPeople, err
  96 + } else {
  97 + exchangeCashPeople = append(exchangeCashPeople, taskNature)
  98 + }
  99 + }
  100 + return int64(count), exchangeCashPeople, nil
  101 + }
  102 +}
  103 +
  104 +func (repository *ExchangeCashPersonListRepository) Remove(exchangeCashList *domain.ExchangeCashPersonList) (*domain.ExchangeCashPersonList, error) {
  105 + tx := repository.transactionContext.PgTx
  106 + exchangeCashListModel := new(models.ExchangeCashPersonList)
  107 + exchangeCashList.ExchangeCashPersonListId = exchangeCashList.Identity().(int64)
  108 + if _, err := tx.Model(exchangeCashListModel).WherePK().Delete(); err != nil {
  109 + return exchangeCashList, err
  110 + }
  111 + return exchangeCashList, nil
  112 +}
  113 +
  114 +func (repository *ExchangeCashPersonListRepository) transformPgModelToDomainModel(exchangeCashList *models.ExchangeCashPersonList) (*domain.ExchangeCashPersonList, error) {
  115 + return &domain.ExchangeCashPersonList{
  116 + ExchangedCash: exchangeCashList.ExchangedCash,
  117 + ExchangedSuMoney: exchangeCashList.ExchangedSuMoney,
  118 + }, nil
  119 +}
  120 +func NewExchangeCashListRepository(transactionContext *pgTransaction.TransactionContext) (*ExchangeCashPersonListRepository, error) {
  121 + if transactionContext == nil {
  122 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  123 + } else {
  124 + return &ExchangeCashPersonListRepository{
  125 + transactionContext: transactionContext,
  126 + }, nil
  127 + }
  128 +}
@@ -32,6 +32,7 @@ func (repository *TaskNatureRepository) Save(taskNature *domain.TaskNature) (*do @@ -32,6 +32,7 @@ func (repository *TaskNatureRepository) Save(taskNature *domain.TaskNature) (*do
32 } 32 }
33 return taskNature, nil 33 return taskNature, nil
34 } 34 }
  35 +
35 func (repository *TaskNatureRepository) Remove(taskNature *domain.TaskNature) (*domain.TaskNature, error) { 36 func (repository *TaskNatureRepository) Remove(taskNature *domain.TaskNature) (*domain.TaskNature, error) {
36 tx := repository.transactionContext.PgTx 37 tx := repository.transactionContext.PgTx
37 taskNatureModel := new(models.TaskNature) 38 taskNatureModel := new(models.TaskNature)
@@ -41,6 +42,7 @@ func (repository *TaskNatureRepository) Remove(taskNature *domain.TaskNature) (* @@ -41,6 +42,7 @@ func (repository *TaskNatureRepository) Remove(taskNature *domain.TaskNature) (*
41 } 42 }
42 return taskNature, nil 43 return taskNature, nil
43 } 44 }
  45 +
44 func (repository *TaskNatureRepository) FindOne(queryOptions map[string]interface{}) (*domain.TaskNature, error) { 46 func (repository *TaskNatureRepository) FindOne(queryOptions map[string]interface{}) (*domain.TaskNature, error) {
45 tx := repository.transactionContext.PgTx 47 tx := repository.transactionContext.PgTx
46 taskNatureModel := new(models.TaskNature) 48 taskNatureModel := new(models.TaskNature)
@@ -61,6 +63,7 @@ func (repository *TaskNatureRepository) FindOne(queryOptions map[string]interfac @@ -61,6 +63,7 @@ func (repository *TaskNatureRepository) FindOne(queryOptions map[string]interfac
61 return repository.transformPgModelToDomainModel(taskNatureModel) 63 return repository.transformPgModelToDomainModel(taskNatureModel)
62 } 64 }
63 } 65 }
  66 +
64 func (repository *TaskNatureRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.TaskNature, error) { 67 func (repository *TaskNatureRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.TaskNature, error) {
65 tx := repository.transactionContext.PgTx 68 tx := repository.transactionContext.PgTx
66 var taskNatureModels []*models.TaskNature 69 var taskNatureModels []*models.TaskNature
@@ -104,6 +107,7 @@ func (repository *TaskNatureRepository) Find(queryOptions map[string]interface{} @@ -104,6 +107,7 @@ func (repository *TaskNatureRepository) Find(queryOptions map[string]interface{}
104 return int64(count), taskNatures, nil 107 return int64(count), taskNatures, nil
105 } 108 }
106 } 109 }
  110 +
107 func (repository *TaskNatureRepository) transformPgModelToDomainModel(taskNatureModel *models.TaskNature) (*domain.TaskNature, error) { 111 func (repository *TaskNatureRepository) transformPgModelToDomainModel(taskNatureModel *models.TaskNature) (*domain.TaskNature, error) {
108 return &domain.TaskNature{ 112 return &domain.TaskNature{
109 TaskNatureId: taskNatureModel.Id, 113 TaskNatureId: taskNatureModel.Id,
@@ -111,6 +115,7 @@ func (repository *TaskNatureRepository) transformPgModelToDomainModel(taskNature @@ -111,6 +115,7 @@ func (repository *TaskNatureRepository) transformPgModelToDomainModel(taskNature
111 CompanyId: taskNatureModel.CompanyId, 115 CompanyId: taskNatureModel.CompanyId,
112 }, nil 116 }, nil
113 } 117 }
  118 +
114 func NewTaskNatureRepository(transactionContext *pgTransaction.TransactionContext) (*TaskNatureRepository, error) { 119 func NewTaskNatureRepository(transactionContext *pgTransaction.TransactionContext) (*TaskNatureRepository, error) {
115 if transactionContext == nil { 120 if transactionContext == nil {
116 return nil, fmt.Errorf("transactionContext参数不能为nil") 121 return nil, fmt.Errorf("transactionContext参数不能为nil")
1 -package controllers  
2 -  
3 -import (  
4 -  
5 - "github.com/astaxie/beego"  
6 -)  
7 -  
8 -type CashPoolController struct {  
9 - beego.Controller  
10 -}  
11 -  
12 -/**  
13 - * 现金池投入  
14 - */  
15 -func (controller *CashPoolController) CashInput() {  
16 -  
17 -}  
18 -  
19 -/**  
20 - * 返回兑换活动列表  
21 - */  
22 -func (controller *CashPoolController) ListExchangeActivities () {  
23 -  
24 -}  
25 -  
26 -/**  
27 - * 更新兑换活动信息  
28 - */  
29 -func (controller *CashPoolController) UpdateExchangeActivities () {  
30 -  
31 -}  
32 -  
33 -/**  
34 - * 新增兑换活动  
35 - */  
36 -func (controller *CashPoolController) CreateExchangeActivities () {  
37 -  
38 -}  
39 -  
40 -/**  
41 - * 删除兑换活动  
42 - */  
43 -func (controller *CashPoolController) DeleteExchangeActivities () {  
44 -  
45 -}  
46 -  
47 -/**  
48 - * 搜索兑换素币活动  
49 - */  
50 -func (controller *CashPoolController) searchExchangeActivities () {  
51 -  
52 -}  
53 -  
54 -/**  
55 - * 兑换活动数据统计  
56 - */  
57 -func (controller *CashPoolController) exchangeActivitiesStatistics () {  
58 -  
59 -}  
60 -  
61 -/**  
62 - * 获取素币兑换清单  
63 - */  
64 -func (controller *CashPoolController) ListExchangeList () {  
65 -  
66 -}  
67 -  
68 -/**  
69 - * 新增素币兑换清单  
70 - */  
71 -func (controller *CashPoolController) CreateExchangeList () {  
72 -  
73 -}  
74 -  
75 -/**  
76 - * 更新素币兑换清单  
77 - */  
78 -func (controller *CashPoolController) UpdateExchangeList () {  
79 -  
80 -}  
81 -  
82 -/**  
83 - * 删除素币兑换清单  
84 - */  
85 -func (controller *CashPoolController) DeleteExchangeList () {  
86 -  
87 -}  
88 -  
89 -/**  
90 - * 搜索素币兑换清单  
91 - */  
92 -func (controller *CashPoolController) searchExchangeList () {  
93 -  
94 -}  
95 -  
96 -/**  
97 - * 导出素币兑换清单  
98 - */  
99 -func (controller *CashPoolController) ExportExchangeList () {  
100 -  
101 -}  
102 -  
103 -/**  
104 - * 导入素币兑换清单  
105 - */  
106 -func (controller *CashPoolController) ImportExchangeList () {  
107 -  
108 -}  
109 -  
110 -  
111 -  
112 -  
@@ -89,3 +89,101 @@ func (controller *SuMoneyController) SuMoneyTransactionRecordStatistics() { @@ -89,3 +89,101 @@ func (controller *SuMoneyController) SuMoneyTransactionRecordStatistics() {
89 controller.Data["json"] = response 89 controller.Data["json"] = response
90 controller.ServeJSON() 90 controller.ServeJSON()
91 } 91 }
  92 +
  93 +/**
  94 + * 现金池投入
  95 + */
  96 +func (controller *SuMoneyController) CashInput() {
  97 +
  98 +}
  99 +
  100 +/**
  101 + * 返回兑换活动列表
  102 + */
  103 +func (controller *SuMoneyController) ListExchangeActivities () {
  104 +
  105 +}
  106 +
  107 +/**
  108 + * 更新兑换活动信息
  109 + */
  110 +func (controller *SuMoneyController) UpdateExchangeActivities () {
  111 +
  112 +}
  113 +
  114 +/**
  115 + * 新增兑换活动
  116 + */
  117 +func (controller *SuMoneyController) CreateExchangeActivities () {
  118 +
  119 +}
  120 +
  121 +/**
  122 + * 删除兑换活动
  123 + */
  124 +func (controller *SuMoneyController) RemoveExchangeActivities () {
  125 +
  126 +}
  127 +
  128 +/**
  129 + * 搜索兑换素币活动
  130 + */
  131 +func (controller *SuMoneyController) searchExchangeActivities () {
  132 +
  133 +}
  134 +
  135 +/**
  136 + * 兑换活动数据统计
  137 + */
  138 +func (controller *SuMoneyController) exchangeActivitiesStatistics () {
  139 +
  140 +}
  141 +
  142 +/**
  143 + * 获取素币兑换清单
  144 + */
  145 +func (controller *SuMoneyController) ListExchangeList () {
  146 +
  147 +}
  148 +
  149 +/**
  150 + * 新增素币兑换清单
  151 + */
  152 +func (controller *SuMoneyController) CreateExchangeList () {
  153 +
  154 +}
  155 +
  156 +/**
  157 + * 更新素币兑换清单
  158 + */
  159 +func (controller *SuMoneyController) UpdateExchangeList () {
  160 +
  161 +}
  162 +
  163 +/**
  164 + * 删除素币兑换清单
  165 + */
  166 +func (controller *SuMoneyController) RemoveExchangeList () {
  167 +
  168 +}
  169 +
  170 +/**
  171 + * 搜索素币兑换清单
  172 + */
  173 +func (controller *SuMoneyController) searchExchangeList () {
  174 +
  175 +}
  176 +
  177 +/**
  178 + * 导出素币兑换清单
  179 + */
  180 +func (controller *SuMoneyController) ExportExchangeList () {
  181 +
  182 +}
  183 +
  184 +/**
  185 + * 导入素币兑换清单
  186 + */
  187 +func (controller *SuMoneyController) ImportExchangeList () {
  188 +
  189 +}
1 -package routers  
2 -  
3 -// TODO  
4 -func init() {  
5 - ///*****************************************现金池**********************************/  
6 - //beego.Router("/cash_pool/input", &controllers.ConfigController{}, "POST:CashInput") // 现金池投入  
7 - //  
8 - ///*****************************************兑换活动*********************************/  
9 - //beego.Router("/cashPool-pool/", &controllers.ConfigController{}, "GET:ListExchangeActivities") // 返回兑换活动列表  
10 - //beego.Router("/cashPool-pool/:aid", &controllers.ConfigController{}, "PUT:UpdateExchangeActivities") // 编辑兑换活动  
11 - //beego.Router("/cashPool-pool/", &controllers.ConfigController{}, "POST:CreateExchangeActivities") // 新增兑换活动  
12 - //beego.Router("/cashPool-pool/:aid", &controllers.ConfigController{}, "DELETE:DeleteExchangeActivities") // 删除兑换活动  
13 - //  
14 - ///*****************************************兑换素币清单****************************/  
15 - //beego.Router("/cashPool-pool/exchange", &controllers.ConfigController{}, "GET:ListExchangeList") // 返回素币兑换清单  
16 - //beego.Router("/cashPool-pool/exchange", &controllers.ConfigController{}, "POST:CreateExchangeList") // 新增素币兑换清单  
17 - //beego.Router("/cashPool-pool/exchange/:eid", &controllers.ConfigController{}, "PUT:UpdateExchangeList") // 编辑素币兑换清单  
18 - //beego.Router("/cashPool-pool/exchange/:eid", &controllers.ConfigController{}, "DELETE:RemoveExchangeList") // 删除素币兑换清单  
19 - //beego.Router("/cashPool-pool/export", &controllers.ConfigController{}, "POST:ExportExchangeList") // 导出素币兑换清单  
20 - //beego.Router("/cashPool-pool/import", &controllers.ConfigController{}, "POST:ImportExchangeList") // 导入素币兑换清单  
21 -}  
@@ -6,9 +6,25 @@ import ( @@ -6,9 +6,25 @@ import (
6 ) 6 )
7 7
8 func init() { 8 func init() {
  9 + /**********************************************素币流水******************************************/
9 beego.Router("/su-money/operation", &controllers.SuMoneyController{}, "Post:OperationSuMoney") 10 beego.Router("/su-money/operation", &controllers.SuMoneyController{}, "Post:OperationSuMoney")
10 beego.Router("/su-money/su-money-transaction-records/:suMoneyTransactionRecordId", &controllers.SuMoneyController{}, "Get:GetSuMoneyTransactionRecord") 11 beego.Router("/su-money/su-money-transaction-records/:suMoneyTransactionRecordId", &controllers.SuMoneyController{}, "Get:GetSuMoneyTransactionRecord")
11 beego.Router("/su-money/exchange", &controllers.SuMoneyController{}, "Post:ExchangeSuMoney") 12 beego.Router("/su-money/exchange", &controllers.SuMoneyController{}, "Post:ExchangeSuMoney")
12 beego.Router("/su-money/search-su-money-transaction-record", &controllers.SuMoneyController{}, "Post:SearchSuMoneyTransactionRecord") 13 beego.Router("/su-money/search-su-money-transaction-record", &controllers.SuMoneyController{}, "Post:SearchSuMoneyTransactionRecord")
13 beego.Router("/su-money/su-money-transaction-record-statistics", &controllers.SuMoneyController{}, "Post:SuMoneyTransactionRecordStatistics") 14 beego.Router("/su-money/su-money-transaction-record-statistics", &controllers.SuMoneyController{}, "Post:SuMoneyTransactionRecordStatistics")
  15 +
  16 + /**********************************************现金池*******************************************/
  17 + beego.Router("/cash-pool/input", &controllers.SuMoneyController{}, "POST:CashInput") // 现金池投入
  18 +
  19 + beego.Router("/cash-pool/", &controllers.SuMoneyController{}, "GET:ListExchangeActivities") // 返回兑换活动列表
  20 + beego.Router("/cash-pool/:activityId", &controllers.SuMoneyController{}, "PUT:UpdateExchangeActivities") // 编辑兑换活动
  21 + beego.Router("/cash-pool/", &controllers.SuMoneyController{}, "POST:CreateExchangeActivities") // 新增兑换活动
  22 + beego.Router("/cash-pool/:activityId", &controllers.SuMoneyController{}, "DELETE:RemoveExchangeActivities") // 删除兑换活动
  23 +
  24 + beego.Router("/cash-pool/exchange-list", &controllers.SuMoneyController{}, "GET:ListExchangeList") // 返回素币兑换清单
  25 + beego.Router("/cash-pool/exchange-list", &controllers.SuMoneyController{}, "POST:CreateExchangeList") // 新增素币兑换清单
  26 + beego.Router("/cash-pool/exchange-list/:personId", &controllers.SuMoneyController{}, "PUT:UpdateExchangeList") // 编辑素币兑换清单
  27 + beego.Router("/cash-pool/exchange-list/:personId", &controllers.SuMoneyController{}, "DELETE:RemoveExchangeList") // 删除素币兑换清单
  28 + beego.Router("/cash-pool/exchange-list/export", &controllers.SuMoneyController{}, "POST:ExportExchangeList") // 导出素币兑换清单
  29 + beego.Router("/cash-pool/exchange-list/import", &controllers.SuMoneyController{}, "POST:ImportExchangeList") // 导入素币兑换清单
14 } 30 }