作者 陈志颖

test:测试修复现金池、素币兑换活动、素币兑换清单

... ... @@ -128,6 +128,7 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
... ... @@ -220,6 +221,7 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
mellium.im/sasl v0.2.1 h1:nspKSRg7/SyO0cRGY71OkfHab8tf9kCts6a6oTDut0w=
mellium.im/sasl v0.2.1/go.mod h1:ROaEDLQNuf9vjKqE1SrAfnsobm2YKXT1gnN1uDp1PjQ=
... ...
... ... @@ -10,7 +10,7 @@ import (
type CreateCashPoolCommand struct {
//Uid int64 `json:"uid"` // 统一用户id
//CashPoolId int64 `json:"cashPoolId" valid:"Required"` // 现金池ID
CompanyId int64 `json:"companyId"` // 公司ID
CompanyId int64 `json:"companyId" valid:"Required"` // 公司ID
Cash float64 `json:"cash" valid:"Required"` // 投入的现金值
//ExchangedCash float64 `json:"exchangedCash,omitempty"` // 现金池已兑换现金值
//UnExchangeCash float64 `json:"unExchangeCash,omitempty"` // 现金池未兑换现金值
... ...
... ... @@ -3,14 +3,15 @@ package command
import (
"fmt"
"github.com/astaxie/beego/validation"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
)
type CreateExchangeCashPersonCommand struct {
ExchangeCashPerson *domain.Employee `json:"exchangeCashPerson"` // 兑换现金人员
ExchangeCashActivityId int64 `json:"exchangeCashActivityId"` // 参与的兑换活动id
PersonId int64 `json:"personId" valid:"Required"` // 兑换现金人员uid
PersonName string `json:"personName,omitempty"` // 兑换现金人员名称
PersonAccount string `json:"personAccount,omitempty"` // 手机账号
ExchangeCashActivityId int64 `json:"exchangeCashActivityId" valid:"Required"` // 参与的兑换活动id
ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换素币值
ExchangedCash float64 `json:"exchangedCash"` // 已兑换现金值
//ExchangedCash float64 `json:"exchangedCash"` // 已兑换现金值
}
func (createExchangeCashPersonCommand *CreateExchangeCashPersonCommand) ValidateCommand() error {
... ...
... ... @@ -9,7 +9,8 @@ import (
type SearchSuMoneyTransactionRecordCommand struct {
// 统一用户UID
Uid int64 `json:"uid" valid:"Required"`
//Uid int64 `json:"uid" valid:"Required"`
Uid int64 `json:"uid"`
// 记录类型(1兑换,2任务奖励,3增加,4扣除)
RecordType int `json:"recordType,omitempty"`
// 记录类型列表(1兑换,2任务奖励,3增加,4扣除)
... ... @@ -20,7 +21,7 @@ type SearchSuMoneyTransactionRecordCommand struct {
TransactionEndTime time.Time `json:"transactionEndTime,omitempty"`
// 操作人UID
Operator int64 `json:"operator,omitempty"`
// 关联人员
// 关联人员姓名
EmployeeMatchName string `json:"employeeMatchName"`
// 查询偏离量
Offset int `json:"offset,omitempty"`
... ...
... ... @@ -66,6 +66,8 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
systemUnChangeSuMoney = value2
}
fmt.Print("1234567", createCashPoolCommand)
newCashPool := &domain.CashPool{
CompanyId: createCashPoolCommand.CompanyId,
Cash: createCashPoolCommand.Cash,
... ... @@ -86,6 +88,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
cashPoolRepository = value
}
// 每个公司一个现金池
if activity, err := cashPoolRepository.Save(newCashPool); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -203,16 +206,16 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
transactionContext.RollbackTransaction()
}()
var cashPoolRepository domain.CashPoolRepository
if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
var exchangeActivityRepository domain.ExchangeActivityRepository
if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cashPoolRepository = value
exchangeActivityRepository = value
}
if count, activities, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(listExchangeCashActivityQuery)); err != nil {
if count, activities, err := exchangeActivityRepository.Find(tool_funs.SimpleStructToMap(listExchangeCashActivityQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
... ... @@ -379,11 +382,13 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
// 创建兑换清单
newPerson := &domain.ExchangeCashPersonList{
CompanyId: createExchangeCashPersonCommand.ExchangeCashPerson.CompanyId,
EmployeeInfo: &domain.EmployeeInfo{
Uid: createExchangeCashPersonCommand.PersonId,
EmployeeName: createExchangeCashPersonCommand.PersonName,
EmployeeAccount: createExchangeCashPersonCommand.PersonAccount,
},
ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId,
ExchangeCashPerson: createExchangeCashPersonCommand.ExchangeCashPerson,
ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
ExchangedCash: createExchangeCashPersonCommand.ExchangedCash,
}
// 兑换活动资源库
... ... @@ -462,16 +467,16 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP
transactionContext.RollbackTransaction()
}()
var cashPoolRepository domain.CashPoolRepository
if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
var exchangeCashPersonListRepository domain.ExchangeCashPersonListRepository
if value, err := factory.CreateExchangeCashPersonListRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cashPoolRepository = value
exchangeCashPersonListRepository = value
}
if count, people, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(listExchangeCashPersonQuery)); err != nil {
if count, people, err := exchangeCashPersonListRepository.Find(tool_funs.SimpleStructToMap(listExchangeCashPersonQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
... ...
... ... @@ -5,8 +5,8 @@ import "time"
// 现金池
type CashPool struct {
CashPoolId int64 `json:"cashPoolId"` // 现金池id
CompanyId int64 `json:"companyId"` // 公司id
Cash float64 `json:"cash"` // 投入现金池的现金
CompanyId int64 `json:"companyId"` // 公司id
ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金
UnExchangeCash float64 `json:"unExchangeCash"` // 未兑换的现金
ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币
... ...
... ... @@ -2,10 +2,12 @@ package domain
// 参与兑换现金人员
type ExchangeCashPersonList struct {
ExchangeCashPersonListId int64 `json:"employeeId"` // 兑换人员ID
CompanyId int64 `json:"companyId"` // 公司id
ExchangeCashPersonListId int64 `json:"exchangeCashPersonListId"` // 兑换人员ID
//CompanyId int64 `json:"companyId"` // 公司id
EmployeeInfo *EmployeeInfo `json:"employeeInfo"`
//PersonId int64 `json:"personId"` // 兑换人员uid
//ExchangeCashPersonName string `json:"exchangeCashPersonName"` // 兑换人员名称
ExchangeCashActivityId int64 `json:"exchangeActivityId"` // 参与的兑换活动id
ExchangeCashPerson *Employee `json:"employeeInfo"` // 兑换人员信息
ExchangedSuMoney float64 `json:"suMoney"` // 已兑换的素币
ExchangedCash float64 `json:"cash"` // 已兑换的现金
}
... ...
... ... @@ -16,10 +16,10 @@ type SuMoneyTransactionRecord struct {
Employee *EmployeeInfo `json:"employee"` // 记录关联员工
SuMoneyBeforeTransaction float64 `json:"suMoneyBeforeTransaction"` // 事务处理前素币值
CurrentSuMoney float64 `json:"currentSuMoney"` // 当前素币值
CashPoolBeforeTransaction *CashPool `json:"cashPoolBeforeTransaction"` // 事务处理前现金池,用于兑换现金操作
CurrentCashPool *CashPool `json:"currentCashPool"` // 当前现金池,用于兑换现金操作
//CashPoolBeforeTransaction *CashPool `json:"cashPoolBeforeTransaction"` // 事务处理前现金池,用于兑换现金操作
//CurrentCashPool *CashPool `json:"currentCashPool"` // 当前现金池,用于兑换现金操作
SuMoney float64 `json:"suMoney"` // 事务素币值
Cash float64 `json:"cash"` // 事务现金值,用于兑换现金操作
//Cash float64 `json:"cash"` // 事务现金值,用于兑换现金操作
Operator *EmployeeInfo `json:"operator"` // 操作人
RecordDescription string `json:"recordDescription"` // 素币事务记录描述
CreateTime time.Time `json:"createTime"` // 创建时间
... ...
package models
import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"time"
)
type ExchangeCashPersonList struct {
TableName string `pg:"exchange_cash_list"`
Id int64 `pg:",pk"` // 兑换现金清单id
PersonInfo *domain.Employee // 兑换现金人员
TableName string `pg:"exchange_cash_person_list,alias:exchange_cash_person_lists"`
Id int64 `pg:",pk"` // 清单id
ActivityId int64 // 兑换活动id
Uid int64 // 统一用户UID
EmployeeName string // 员工姓名
EmployeeAccount string // 员工账号
EmployeeAvatarUrl string // 员工头像URL
IsPrincipal bool `pg:",notnull,default:false"` // 是否公司负责人
ExchangedSuMoney float64 // 已兑换素币
ExchangedCash float64 // 已兑换现金
CreateTime time.Time // 兑换时间
}
\ No newline at end of file
... ...
... ... @@ -10,8 +10,8 @@ type SuMoneyExchangeTransactionRecord struct {
Id int64 `pg:",pk"` // 现金兑换务记录ID
RecordType int // 记录类型
Employee *domain.EmployeeInfo // 记录关联员工
CashPoolBeforeTransaction *domain.CashPool // 事务处理前现金池
CurrentCashPool *domain.CashPool // 当前现金池
//CashPoolBeforeTransaction *domain.CashPool // 事务处理前现金池
//CurrentCashPool *domain.CashPool // 当前现金池
SuMoney float64 // 事务素币值
Cash float64 // 事务现金值
Operator *domain.EmployeeInfo // 操作人
... ...
... ... @@ -17,15 +17,15 @@ func (repository *CashPoolRepository) Save(cashPool *domain.CashPool) (*domain.C
if cashPool.Identity() == nil {
if _, err := tx.QueryOne(
pg.Scan(&cashPool.CashPoolId, &cashPool.Cash, &cashPool.CompanyId, &cashPool.ExchangedCash, &cashPool.UnExchangeCash, &cashPool.ExchangedSuMoney, &cashPool.UnExchangeSuMoney, &cashPool.Rate),
"INSERT INTO cash_pools (cash, company_id, exchanged_cash, un_exchange_cash, exchanged_su_money, un_exchange_su_money, rate) VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, exchanged_cash, un_exchange_cash, exchanged_su_money, un_exchange_su_money, rate",
"INSERT INTO cash_pools (cash, company_id, exchanged_cash, un_exchange_cash, exchanged_su_money, un_exchange_su_money, rate) VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING id, cash, company_id, exchanged_cash, un_exchange_cash, exchanged_su_money, un_exchange_su_money, rate",
cashPool.Cash, cashPool.CompanyId, cashPool.ExchangedCash, cashPool.UnExchangeCash, cashPool.ExchangedSuMoney, cashPool.UnExchangeSuMoney, cashPool.Rate); err != nil {
return cashPool, err
}
} else {
if _, err := tx.QueryOne(
pg.Scan(&cashPool.CashPoolId, &cashPool.Cash, &cashPool.CompanyId, &cashPool.ExchangedCash, &cashPool.UnExchangeCash, &cashPool.ExchangedSuMoney, &cashPool.UnExchangeSuMoney, &cashPool.Rate),
"UPDATE cash_pools SET cash=?, company_id=? exchanged_cash=?, un_exchange_cash=?, exchanged_su_money=?, un_exchange_su_money=?, rate=? WHERE company_id=? RETURNING id, company_id, exchanged_cash, un_exchange_cash, exchanged_su_money, un_exchange_su_money, rate",
cashPool.Cash, cashPool.CompanyId, cashPool.ExchangedCash, cashPool.UnExchangeCash, cashPool.ExchangedSuMoney, cashPool.UnExchangeSuMoney, cashPool.Rate, cashPool.Identity()); err != nil {
"UPDATE cash_pools SET cash=?, company_id=?, exchanged_cash=?, un_exchange_cash=?, exchanged_su_money=?, un_exchange_su_money=?, rate=? WHERE id=? RETURNING id, cash, company_id, exchanged_cash, un_exchange_cash, exchanged_su_money, un_exchange_su_money, rate",
cashPool.Cash, cashPool.CompanyId, cashPool.ExchangedCash, cashPool.UnExchangeCash, cashPool.ExchangedSuMoney, cashPool.UnExchangeSuMoney, cashPool.Rate, cashPool.CashPoolId, cashPool.Identity()); err != nil {
return cashPool, err
}
}
... ... @@ -39,7 +39,7 @@ func (repository *CashPoolRepository) Find(queryOptions map[string]interface{})
query := tx.Model(&cashPoolModels)
// 根据公司id查找现金池
if companyId, ok := queryOptions["companyId"]; ok {
query = query.Where("cash_pools.company_id = ?", companyId)
query = query.Where("cash_pool.company_id = ?", companyId)
}
if offset, ok := queryOptions["offset"]; ok {
offset := offset.(int)
... ... @@ -55,7 +55,7 @@ func (repository *CashPoolRepository) Find(queryOptions map[string]interface{})
query = query.Limit(limit)
}
} else {
query = query.Limit(20)
query = query.Limit(1)
}
if count, err := query.Order("id DESC").SelectAndCount(); err != nil {
return 0, cashPools, err
... ...
... ... @@ -2,11 +2,12 @@ package repository
import (
"fmt"
"time"
"github.com/go-pg/pg"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg/models"
"time"
)
type ExchangeCashActivityRepository struct {
... ... @@ -24,9 +25,9 @@ func (repository *ExchangeCashActivityRepository) Save(exchangeCashActivity *dom
}
} else {
if _, err := tx.QueryOne(
pg.Scan(&exchangeCashActivity.ActivityId, &exchangeCashActivity.ExchangeActivityName),
"UPDATE exchange_cash_activities SET company_id=?, activity_name=?, deadline=?, count_down=?, exchanged_cash=?, exchanged_su_money=?, exchange_rate=?, create_time=?, WHERE id=? RETURNING id, company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate",
exchangeCashActivity.CompanyId, exchangeCashActivity.ExchangeActivityName, exchangeCashActivity.Deadline, exchangeCashActivity.CountDown, exchangeCashActivity.ExchangedCash, exchangeCashActivity.ExchangedSuMoney, exchangeCashActivity.Rate); err != nil {
pg.Scan(&exchangeCashActivity.ActivityId, &exchangeCashActivity.CompanyId, &exchangeCashActivity.ExchangeActivityName, &exchangeCashActivity.Deadline, &exchangeCashActivity.CountDown, &exchangeCashActivity.ExchangedCash, &exchangeCashActivity.ExchangedSuMoney, &exchangeCashActivity.Rate),
"UPDATE exchange_cash_activities SET activity_name=?, deadline=?, count_down=?, exchanged_cash=?, exchanged_su_money=?, exchange_rate=? WHERE id=? RETURNING id, company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate",
exchangeCashActivity.ExchangeActivityName, exchangeCashActivity.Deadline, exchangeCashActivity.CountDown, exchangeCashActivity.ExchangedCash, exchangeCashActivity.ExchangedSuMoney, exchangeCashActivity.Rate, exchangeCashActivity.ActivityId); err != nil {
return exchangeCashActivity, err
}
}
... ... @@ -65,7 +66,7 @@ func (repository *ExchangeCashActivityRepository) Find(queryOptions map[string]i
}
// 活动名称模糊搜索
if exchangeCashActivityNameMatch, ok := queryOptions["exchangeCashActivityNameMatch"]; ok && (exchangeCashActivityNameMatch != "") {
query = query.Where(`exchange_cash_activity.exchange_cash_activity_name LIKE ?`, fmt.Sprintf("%%%s%%", exchangeCashActivityNameMatch.(string)))
query = query.Where(`exchange_cash_activity.activity_name LIKE ?`, fmt.Sprintf("%%%s%%", exchangeCashActivityNameMatch.(string)))
}
// 活动截止时间搜索
if deadline, ok := queryOptions["exchangeCashActivityDeadline"]; ok && !deadline.(time.Time).IsZero() {
... ...
... ... @@ -17,16 +17,16 @@ func (repository *ExchangeCashPersonListRepository) Save(exchangeCashList *domai
tx := repository.transactionContext.PgTx
if exchangeCashList.Identity() == nil {
if _, err := tx.QueryOne(
pg.Scan(&exchangeCashList.ExchangeCashPersonListId, &exchangeCashList.CompanyId, &exchangeCashList.ExchangeCashActivityId, &exchangeCashList.ExchangeCashPerson, &exchangeCashList.ExchangedSuMoney, &exchangeCashList.ExchangedCash),
"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",
exchangeCashList.CompanyId, exchangeCashList.ExchangeCashActivityId, exchangeCashList.ExchangeCashPerson, exchangeCashList.ExchangedSuMoney, exchangeCashList.ExchangedCash); err != nil {
pg.Scan(&exchangeCashList.ExchangeCashPersonListId, &exchangeCashList.ExchangeCashActivityId, &exchangeCashList.EmployeeInfo.Uid, &exchangeCashList.EmployeeInfo.EmployeeName, &exchangeCashList.EmployeeInfo.EmployeeAccount, &exchangeCashList.ExchangedSuMoney, &exchangeCashList.ExchangedCash),
"INSERT INTO exchange_cash_person_lists (activity_id, uid, employee_name, employee_account, exchanged_su_money, exchanged_cash) VALUES (?, ?, ?, ?, ?, ?) RETURNING id, activity_id, uid, employee_name, employee_account, exchanged_su_money, exchanged_cash",
exchangeCashList.ExchangeCashActivityId, exchangeCashList.EmployeeInfo.Uid, exchangeCashList.EmployeeInfo.EmployeeName, exchangeCashList.EmployeeInfo.EmployeeAccount, exchangeCashList.ExchangedSuMoney, exchangeCashList.ExchangedCash); err != nil {
return exchangeCashList, err
}
} else {
if _, err := tx.QueryOne(
pg.Scan(&exchangeCashList.ExchangeCashPersonListId, &exchangeCashList.CompanyId, &exchangeCashList.ExchangeCashPerson, &exchangeCashList.ExchangedSuMoney, &exchangeCashList.ExchangedCash),
"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",
exchangeCashList.CompanyId, exchangeCashList.ExchangeCashPerson, exchangeCashList.ExchangeCashActivityId, exchangeCashList.ExchangedSuMoney, exchangeCashList.ExchangedCash); err != nil {
pg.Scan(&exchangeCashList.ExchangeCashPersonListId, &exchangeCashList.ExchangeCashActivityId, &exchangeCashList.EmployeeInfo.Uid, &exchangeCashList.EmployeeInfo.EmployeeName, &exchangeCashList.EmployeeInfo.EmployeeAccount, &exchangeCashList.ExchangedSuMoney, &exchangeCashList.ExchangedCash),
"UPDATE exchange_cash_person_lists SET exchanged_su_money=? WHERE uid=? RETURNING id, activity_id, uid, employee_name, employee_account, exchanged_su_money, exchanged_cash",
exchangeCashList.ExchangedSuMoney, exchangeCashList.EmployeeInfo.Uid); err != nil {
return exchangeCashList, err
}
}
... ... @@ -38,7 +38,7 @@ func (repository *ExchangeCashPersonListRepository) FindOne(queryOptions map[str
exchangeCashListModel := new(models.ExchangeCashPersonList)
query := tx.Model(exchangeCashListModel)
if exchangeCashListId, ok := queryOptions["exchangeCashListId"]; ok {
query = query.Where("exchange_cash_list.id = ?", exchangeCashListId)
query = query.Where("exchange_cash_person_lists.id = ?", exchangeCashListId)
}
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
... ... @@ -60,16 +60,16 @@ func (repository *ExchangeCashPersonListRepository) Find(queryOptions map[string
exchangeCashPeople := make([]*domain.ExchangeCashPersonList, 0)
query := tx.Model(&exchangeCashListModels)
// 根据公司id查找兑换现金人员清单
if companyId, ok := queryOptions["companyId"]; ok {
query = query.Where("exchange_cash_list.company_id = ?", companyId)
}
//if companyId, ok := queryOptions["companyId"]; ok {
// query = query.Where("exchange_cash_person_lists.company_id = ?", companyId)
//}
// 根据活动id查找兑换现金人员清单
if exchangeCashActivityId, ok := queryOptions["activityId"]; ok {
query = query.Where("exchange_cash_list.exchange_cash_activity_id = ?", exchangeCashActivityId)
query = query.Where("exchange_cash_person_lists.activity_id = ?", exchangeCashActivityId)
}
// 根据兑换现金人员名称搜索人员清单
if personNameMatch, ok := queryOptions["personNameMatch"]; ok && (personNameMatch != ""){
query = query.Where("exchange_cash_list.exchange_cash_person LIKE ?", fmt.Sprintf("%%%s%%", personNameMatch.(string)))
query = query.Where("exchange_cash_person_lists.employee_name LIKE ?", fmt.Sprintf("%%%s%%", personNameMatch.(string)))
}
if offset, ok := queryOptions["offset"]; ok {
offset := offset.(int)
... ...
... ... @@ -75,7 +75,9 @@ func (repository *SuMoneyTransactionRecordRepository) Find(queryOptions map[stri
}
// TODO 姓名模糊查询
if employeeMatchName, ok := queryOptions["employeeMatchName"]; ok && (employeeMatchName != "") {
query = query.Where(`su_money_transaction_record.employee @> '{"employeeName":LIKE ?}'`, fmt.Sprintf("%%%s%%", employeeMatchName.(string)))
//query = query.Where(`su_money_transaction_record.employee @> 'employeeName' LIKE ?`, fmt.Sprintf("%%%s%%", employeeMatchName.(string)))
//query = query.Where(`su_money_transaction_record.employee :json->> 'employeeName' LIKE ?`, fmt.Sprintf("%%%s%%", employeeMatchName.(string)))
query = query.Where(`su_money_transaction_record.employee @> '{"employeeName":?}'`, employeeMatchName.(string))
}
if recordType, ok := queryOptions["recordType"]; ok && (recordType != 0) {
query = query.Where(`su_money_transaction_record.record_type = ?`, recordType)
... ...
... ... @@ -81,8 +81,8 @@ func (controller *SuMoneyController) SearchSuMoneyTransactionRecord() {
suMoneyService := service.NewSuMoneyService(nil)
searchSuMoneyTransactionRecordCommand := &command.SearchSuMoneyTransactionRecordCommand{}
employeeMatchName := controller.GetString("employeeMatchName")
searchSuMoneyTransactionRecordCommand.EmployeeMatchName = employeeMatchName
//employeeMatchName := controller.GetString("employeeMatchName")
//searchSuMoneyTransactionRecordCommand.EmployeeMatchName = employeeMatchName
offset, _ := controller.GetInt("offset")
searchSuMoneyTransactionRecordCommand.Offset = offset
... ... @@ -130,19 +130,14 @@ func (controller *SuMoneyController) SuMoneyTransactionRecordStatistics() {
func (controller *SuMoneyController) CashInput() {
cashPoolService := service.NewCashPoolService(nil)
createCashPoolCommand := &command.CreateCashPoolCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), createCashPoolCommand)
data, err := cashPoolService.CreateCashPool(createCashPoolCommand)
var response utils.JsonResponse
if err != nil {
response = utils.ResponseError(controller.Ctx, err)
} else {
response = utils.ResponseData(controller.Ctx, data)
}
controller.Data["json"] = response
controller.ServeJSON()
}
... ...
... ... @@ -23,7 +23,7 @@ func init() {
beego.Router("/cash-pool/activity", &controllers.SuMoneyController{}, "POST:CreateExchangeActivities") // 新增兑换活动
beego.Router("/cash-pool/activity/:activityId", &controllers.SuMoneyController{}, "DELETE:RemoveExchangeActivities") // 删除兑换活动
beego.Router("/cash-pool/activity/exchange-list/", &controllers.SuMoneyController{}, "GET:ListExchangeList") // 返回素币兑换清单
beego.Router("/cash-pool/activity/exchange-list", &controllers.SuMoneyController{}, "GET:ListExchangeList") // 返回素币兑换清单
beego.Router("/cash-pool/activity/exchange-list/:personId", &controllers.SuMoneyController{}, "GET:GetExchangeCashPerson") // 返回素币兑换人员
beego.Router("/cash-pool/activity/exchange-list", &controllers.SuMoneyController{}, "POST:CreateExchangeList") // 新增素币兑换清单
beego.Router("/cash-pool/activity/exchange-list/:personId", &controllers.SuMoneyController{}, "PUT:UpdateExchangeList") // 编辑素币兑换清单
... ...