切换导航条
此项目
正在载入...
登录
linmadan
/
mmm-worth
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
陈志颖
4 years ago
提交
35f48891632a52701b8d823d2ac206cc581b5443
1 个父辈
f045c641
rafactor:导入
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
43 行增加
和
25 行删除
pkg/application/suMoney/service/cash_pool.go
pkg/port/beego/controllers/su_money_controller.go
pkg/application/suMoney/service/cash_pool.go
查看文件 @
35f4889
...
...
@@ -2194,6 +2194,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
}
return
failureDataList
,
nil
}
return
failureDataList
,
nil
}
...
...
pkg/port/beego/controllers/su_money_controller.go
查看文件 @
35f4889
...
...
@@ -10,7 +10,7 @@ import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/service"
utils_tool
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/utils"
//utility
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/utils"
"os"
"path"
"strconv"
...
...
@@ -437,7 +437,7 @@ func (controller *SuMoneyController) ImportExchangeList () {
// 文件行数校验
rows
,
_
:=
xlsx
.
GetRows
(
"Sheet1"
)
fmt
.
Print
(
len
(
rows
),
"
\n
"
)
//
fmt.Print(len(rows), "\n")
if
len
(
rows
)
>
302
{
err
:=
&
application
.
ServiceError
{
Code
:
500
,
...
...
@@ -461,36 +461,32 @@ func (controller *SuMoneyController) ImportExchangeList () {
return
}
// 单元格校验
newstr
:=
[]
string
{
"null"
}
//nullChar := []string{"单元格包含空字符"}
// 必填项校验
nullLine
:=
make
([]
interface
{},
0
)
nullFlag
:=
false
for
i
,
row
:=
range
rows
{
if
i
>
2
{
fmt
.
Print
(
len
(
row
),
"
\n
"
)
// 头部、中间空
if
len
(
row
)
==
3
{
var
myRow
[]
string
=
row
for
j
,
cell
:=
range
row
{
fmt
.
Print
(
cell
,
"
\n
"
)
if
cell
==
""
{
utils_tool
.
InsertSlice
(
j
,
newstr
,
row
)
row
=
append
(
row
,
"单元格包含空字符"
)
nullLine
=
append
(
nullLine
,
row
)
if
cell
==
""
||
cell
==
" "
{
myRow
[
j
]
=
""
nullFlag
=
true
}
}
}
// 尾空
if
len
(
row
)
<
3
{
for
j
,
cell
:=
range
row
{
fmt
.
Print
(
cell
,
"
\n
"
)
if
cell
==
""
{
utils_tool
.
InsertSlice
(
j
,
row
,
newstr
)
row
=
append
(
row
,
"单元格包含空字符"
)
nullLine
=
append
(
nullLine
,
row
)
}
if
nullFlag
{
myRow
=
append
(
myRow
,
"必填项不能为空"
)
nullLine
=
append
(
nullLine
,
myRow
)
nullFlag
=
false
}
}
else
if
len
(
row
)
<
3
{
var
myRow
[]
string
=
row
for
i
:=
0
;
i
<
3
-
len
(
row
);
i
++
{
myRow
=
append
(
myRow
,
""
)
}
myRow
=
append
(
myRow
,
"必填项不能为空"
)
nullLine
=
append
(
nullLine
,
myRow
)
}
}
}
...
...
@@ -518,20 +514,41 @@ func (controller *SuMoneyController) ImportExchangeList () {
// 导入命令
var
createExchangeCashPersonCommands
[]
*
command
.
CreateExchangeCashPersonCommand
errorLine
:=
make
([]
interface
{},
0
)
for
i
,
row
:=
range
rows
{
if
i
>
2
&&
len
(
row
)
>
1
{
// 创建兑换清单命令
createExchangeCashPersonCommand
:=
&
command
.
CreateExchangeCashPersonCommand
{}
createExchangeCashPersonCommand
.
ExchangeCashActivityId
,
_
=
strconv
.
ParseInt
(
jsonMap
[
"activityId"
]
.
(
string
),
10
,
64
)
createExchangeCashPersonCommand
.
ExchangeCashActivityId
,
err
=
strconv
.
ParseInt
(
jsonMap
[
"activityId"
]
.
(
string
),
10
,
64
)
createExchangeCashPersonCommand
.
Operator
=
int64
(
jsonMap
[
"uid"
]
.
(
float64
))
createExchangeCashPersonCommand
.
PersonName
=
row
[
0
]
createExchangeCashPersonCommand
.
PersonAccount
=
row
[
1
]
r2
,
_
:=
strconv
.
ParseFloat
(
row
[
2
],
64
)
r2
,
err
:=
strconv
.
ParseFloat
(
row
[
2
],
64
)
if
err
!=
nil
{
// 已兑换素币格式不正确
var
myRow
[]
string
=
row
myRow
=
append
(
myRow
,
"已兑换素币格式不正确"
)
errorLine
=
append
(
errorLine
,
myRow
)
continue
}
createExchangeCashPersonCommand
.
ExchangedSuMoney
=
r2
createExchangeCashPersonCommands
=
append
(
createExchangeCashPersonCommands
,
createExchangeCashPersonCommand
)
}
}
if
len
(
errorLine
)
>
0
{
ret
=
map
[
string
]
interface
{}{
"successCount"
:
0
,
"fail"
:
map
[
string
]
interface
{}{
"tableHeader"
:
tableHeader
,
"tableData"
:
errorLine
,
},
}
response
=
utils
.
ResponseData
(
controller
.
Ctx
,
ret
)
controller
.
Data
[
"json"
]
=
response
controller
.
ServeJSON
()
return
}
// 创建兑换素币清单
failureDataList
,
err
=
cashPoolService
.
ImportCreateExchangeCashPerson
(
createExchangeCashPersonCommands
,
failureDataList
)
if
err
!=
nil
{
// 导入失败处理
...
...
请
注册
或
登录
后发表评论