作者 陈志颖

fix:修改兑换素币清单path参数

... ... @@ -42,8 +42,8 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
// cashPoolDao = value
//}
// TODO 统计系统已兑换现金、未兑换现金、已兑换素币、未兑换素币
var systemUnExchangeCash float64
//systemExchangedCash, err := cashPoolDao.CalculateSystemCash(createCashPoolCommand.CompanyId)
//if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -76,7 +76,9 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
// systemUnExchangeCash = cashPools[0].UnExchangeCash
//}
// TODO 计算系统平均兑换汇率
//rate, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", systemExchangedCash / systemChangedSuMoney), 64) // 平均兑换汇率
newCashPool := &domain.CashPool{
CompanyId: createCashPoolCommand.CompanyId,
Cash: createCashPoolCommand.Cash,
... ... @@ -142,14 +144,14 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC
// TODO 初始状态下,现金池返回默认值
if count == 0 {
return map[string]interface{}{
"cashPoolId": 4,
"cashPoolId": 0,
"cash": 0,
"companyId": 101,
"exchangedCash": 100,
"unExchangeCash": 1001,
"exchangedSuMoney": 50,
"unExchangeSuMoney": 11,
"rate": 2,
"companyId": 0,
"exchangedCash": 0,
"unExchangeCash": 0,
"exchangedSuMoney": 0,
"unExchangeSuMoney": 0,
"rate": 0,
"createTime": "2020-11-03T17:23:00.848676+08:00",
}, nil
}
... ... @@ -376,8 +378,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
// cashPoolRepository = value
//}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ... @@ -385,7 +385,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
}
}
// 新增兑换现金人员
// 新增兑换素币清单
func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeCashPersonCommand *command.CreateExchangeCashPersonCommand) (interface{}, error) {
if err := createExchangeCashPersonCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -452,7 +452,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
}
}
// 返回兑换现金人员
// 返回兑换素币清单
func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPersonQuery *query.GetExchangeCashPersonQuery) (interface{}, error) {
if err := getExchangeCashPersonQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -491,7 +491,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPer
}
}
// 返回兑换现金人员列表
// 返回兑换素币清单列表
func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashPersonQuery *query.ListExchangeCashPersonQuery) (interface{}, error) {
if err := listExchangeCashPersonQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -528,7 +528,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP
}
}
// 移除兑换现金人员
// 移除兑换素币清单
func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeCashPersonCommand *command.RemoveExchangeCashPersonCommand) (interface{}, error) {
if err := removeExchangeCashPersonCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ...
... ... @@ -37,7 +37,7 @@ func (repository *ExchangeCashPersonListRepository) FindOne(queryOptions map[str
tx := repository.transactionContext.PgTx
exchangeCashListModel := new(models.ExchangeCashPersonList)
query := tx.Model(exchangeCashListModel)
if exchangeCashListId, ok := queryOptions["exchangeCashListId"]; ok {
if exchangeCashListId, ok := queryOptions["listId"]; ok {
query = query.Where("exchange_cash_person_list.id = ?", exchangeCashListId)
}
if err := query.First(); err != nil {
... ...
... ... @@ -245,7 +245,7 @@ func (controller *SuMoneyController) GetExchangeCashActivity () {
controller.ServeJSON()
}
// 返回兑换现金人员列表
// 返回兑换素币清单列表
func (controller *SuMoneyController) ListExchangeList () {
cashPoolService := service.NewCashPoolService(nil)
listExchangeCashListQuery := &query.ListExchangeCashPersonQuery{}
... ... @@ -271,7 +271,7 @@ func (controller *SuMoneyController) ListExchangeList () {
controller.ServeJSON()
}
// 新增兑换现金人员
// 返回兑换素币清单
func (controller *SuMoneyController) CreateExchangeList () {
cashPoolService := service.NewCashPoolService(nil)
createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{}
... ... @@ -287,12 +287,12 @@ func (controller *SuMoneyController) CreateExchangeList () {
controller.ServeJSON()
}
// 更新兑换现金人员
// 更新兑换素币清单
func (controller *SuMoneyController) UpdateExchangeList () {
cashPoolService := service.NewCashPoolService(nil)
updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), updateExchangeCashPersonCommand)
personId, _ := controller.GetInt64(":personId")
personId, _ := controller.GetInt64(":listId")
updateExchangeCashPersonCommand.ListId = personId
data, err := cashPoolService.UpdateExchangeCashPerson(updateExchangeCashPersonCommand)
var response utils.JsonResponse
... ... @@ -305,7 +305,7 @@ func (controller *SuMoneyController) UpdateExchangeList () {
controller.ServeJSON()
}
// 移除兑换现金人员
// 移除兑换素币清单
func (controller *SuMoneyController) RemoveExchangeCashPerson() {
cashPoolService := service.NewCashPoolService(nil)
removeExchangeCashPersonCommand := &command.RemoveExchangeCashPersonCommand{}
... ... @@ -322,7 +322,7 @@ func (controller *SuMoneyController) RemoveExchangeCashPerson() {
controller.ServeJSON()
}
// 返回素币兑换人员
// 返回兑换素币清单
func (controller *SuMoneyController) GetExchangeCashPerson () {
cashPoolService := service.NewCashPoolService(nil)
getExchangeCashPersonQuery := &query.GetExchangeCashPersonQuery{}
... ... @@ -339,14 +339,13 @@ func (controller *SuMoneyController) GetExchangeCashPerson () {
controller.ServeJSON()
}
// 导入素币兑换清单
// 导入兑换素币清单
func (controller *SuMoneyController) ImportExchangeList () {
cashPoolService := service.NewCashPoolService(nil)
createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{}
activityId, _ := controller.GetInt64("activityId")
file, h, _ := controller.GetFile("file") //获取上传的文件
ext := path.Ext(h.Filename)
//验证后缀名是否符合要求
AllowExtMap := map[string]bool{
".xlsx":true,
}
... ... @@ -359,12 +358,9 @@ func (controller *SuMoneyController) ImportExchangeList () {
fmt.Println(err)
return
}
var response utils.JsonResponse
dataList := make([]interface{}, 0)
rows, _ := xlsx.GetRows("Sheet1")
for i, row := range rows {
if i > 0 {
for _, _ = range row {
... ... @@ -382,13 +378,11 @@ func (controller *SuMoneyController) ImportExchangeList () {
}
}
}
ret := map[string]interface{}{
"count": len(dataList),
"people": dataList,
}
response = utils.ResponseData(controller.Ctx, ret)
controller.Data["json"] = response
controller.ServeJSON()
}
\ No newline at end of file
... ...