作者 陈志颖

fix:修复导入兑换清单返回数据格式问题

... ... @@ -296,7 +296,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA
} else {
exchangeCashActivityRepository = value
}
activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": getExchangeCashActivityQuery.ExchangeCashActivityId})
activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"exchangeCashActivityId": getExchangeCashActivityQuery.ExchangeCashActivityId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -385,18 +385,20 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
transactionContext.RollbackTransaction()
}()
var exchangeCashActivityRepository domain.ExchangeActivityRepository
activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": createExchangeCashPersonCommand.ExchangeCashActivityId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if activity.Rate == 0 {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string("请设置汇率")))
}
// TODO 获取兑换活动兑换汇率
//var exchangeCashActivityRepository domain.ExchangeActivityRepository
//activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": createExchangeCashPersonCommand.ExchangeCashActivityId})
//if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//}
//if activity.Rate == 0 {
// return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string("请设置汇率")))
//}
// TODO 清单中现金总额超过现金池时创建失败,提示:“已超过投入现金池的未兑换现金”
// TODO 新增兑换人员时,判断成员是否存在,判断素币值是否超过本人持有的素币,以手机账号为判断依据
... ... @@ -407,7 +409,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
},
ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId,
ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
ExchangedCash: createExchangeCashPersonCommand.ExchangedSuMoney * activity.Rate,
//ExchangedCash: createExchangeCashPersonCommand.ExchangedSuMoney * activity.Rate,
ExchangedCash: createExchangeCashPersonCommand.ExchangedSuMoney,
}
var exchangeCashPersonListRepository domain.ExchangeCashPersonListRepository
... ... @@ -456,7 +459,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPer
} else {
exchangeCashPersonListRepository = value
}
person, err := exchangeCashPersonListRepository.FindOne(map[string]interface{}{"personId": getExchangeCashPersonQuery.ExchangeCashPersonId})
person, err := exchangeCashPersonListRepository.FindOne(map[string]interface{}{"exchangeCashListId": getExchangeCashPersonQuery.ExchangeCashPersonId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -39,7 +39,7 @@ func (repository *ExchangeCashActivityRepository) FindOne(queryOptions map[strin
exchangeCashActivityModel := new(models.ExchangeCashActivity)
query := tx.Model(exchangeCashActivityModel)
if exchangeCashActivityId, ok := queryOptions["exchangeCashActivityId"]; ok {
query = query.Where("exchange_cash_activities.id = ?", exchangeCashActivityId)
query = query.Where("exchange_cash_activity.id = ?", exchangeCashActivityId)
}
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
... ...
... ... @@ -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_person_lists.id = ?", exchangeCashListId)
query = query.Where("exchange_cash_person_list.id = ?", exchangeCashListId)
}
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
... ... @@ -59,11 +59,11 @@ func (repository *ExchangeCashPersonListRepository) Find(queryOptions map[string
var exchangeCashListModels []*models.ExchangeCashPersonList
exchangeCashPeople := make([]*domain.ExchangeCashPersonList, 0)
query := tx.Model(&exchangeCashListModels)
if exchangeCashActivityId, ok := queryOptions["activityId"]; ok {
query = query.Where("exchange_cash_person_lists.activity_id = ?", exchangeCashActivityId)
if exchangeCashActivityId, ok := queryOptions["exchangeCashActivityId"]; ok {
query = query.Where("exchange_cash_person_list.activity_id = ?", exchangeCashActivityId)
}
if personNameMatch, ok := queryOptions["personNameMatch"]; ok && (personNameMatch != ""){
query = query.Where("exchange_cash_person_lists.employee_name LIKE ?", fmt.Sprintf("%%%s%%", personNameMatch.(string)))
if personNameMatch, ok := queryOptions["exchangeCashPersonNameMatch"]; ok && (personNameMatch != ""){
query = query.Where("exchange_cash_person_list.employee_name LIKE ?", fmt.Sprintf("%%%s%%", personNameMatch.(string)))
}
if offset, ok := queryOptions["offset"]; ok {
offset := offset.(int)
... ...
... ... @@ -361,8 +361,10 @@ func (controller *SuMoneyController) ImportExchangeList () {
}
var response utils.JsonResponse
dataList := make([]interface{}, 0)
rows, _ := xlsx.GetRows("Sheet1")
for i, row := range rows {
if i > 0 {
for _, _ = range row {
... ... @@ -377,10 +379,16 @@ func (controller *SuMoneyController) ImportExchangeList () {
response = utils.ResponseError(controller.Ctx, err)
} else {
dataList = append(dataList, data)
response = utils.ResponseData(controller.Ctx, dataList)
}
}
}
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
... ...
... ... @@ -23,10 +23,10 @@ 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-listInterval", &controllers.SuMoneyController{}, "GET:ListExchangeList") // 返回素币兑换清单
beego.Router("/cash-pool/activity/exchange-listInterval/:listId", &controllers.SuMoneyController{}, "GET:GetExchangeCashPerson") // 返回素币兑换人员
beego.Router("/cash-pool/activity/exchange-listInterval", &controllers.SuMoneyController{}, "POST:CreateExchangeList") // 新增素币兑换清单
beego.Router("/cash-pool/activity/exchange-listInterval/:listId", &controllers.SuMoneyController{}, "PUT:UpdateExchangeList") // 编辑素币兑换清单
beego.Router("/cash-pool/activity/exchange-listInterval/:listId", &controllers.SuMoneyController{}, "DELETE:RemoveExchangeCashPerson") // 删除素币兑换清单
beego.Router("/cash-pool/activity/exchange-listInterval/import", &controllers.SuMoneyController{}, "POST:ImportExchangeList") // 导入素币兑换清单
beego.Router("/cash-pool/activity/exchange-list", &controllers.SuMoneyController{}, "GET:ListExchangeList") // 返回素币兑换清单
beego.Router("/cash-pool/activity/exchange-list/:listId", &controllers.SuMoneyController{}, "GET:GetExchangeCashPerson") // 返回素币兑换人员
beego.Router("/cash-pool/activity/exchange-list", &controllers.SuMoneyController{}, "POST:CreateExchangeList") // 新增素币兑换清单
beego.Router("/cash-pool/activity/exchange-list/:listId", &controllers.SuMoneyController{}, "PUT:UpdateExchangeList") // 编辑素币兑换清单
beego.Router("/cash-pool/activity/exchange-list/:listId", &controllers.SuMoneyController{}, "DELETE:RemoveExchangeCashPerson") // 删除素币兑换清单
beego.Router("/cash-pool/activity/exchange-list/import", &controllers.SuMoneyController{}, "POST:ImportExchangeList") // 导入素币兑换清单
}
... ...