作者 陈志颖

fix:空现金池时更新兑换活动

... ... @@ -386,3 +386,160 @@
}
2020/11/24 10:14:53.298 [D] [server.go:2843] <====Send RequestId:POST./statistics/employees-ranking-list.1606184093080911000 BodyData:{"code":0,"data":{"currentEmployeeContributions":{"Uid":3259769336137728,"EmployeeName":"杨志","EmployeesContributions":7232,"Ranking":3},"currentEmployeeWealth":{"Uid":3259769336137728,"EmployeeName":"杨志","EmployeeSuMoney":7032,"Ranking":3},"employeesContributions":[{"Uid":3259769335767040,"EmployeeName":"朱武","EmployeesContributions":88100,"Ranking":1},{"Uid":3259769336174592,"EmployeeName":"索超","EmployeesContributions":26217.3,"Ranking":2},{"Uid":3259769336137728,"EmployeeName":"杨志","EmployeesContributions":7232,"Ranking":3},{"Uid":3259769336070144,"EmployeeName":"杜迁","EmployeesContributions":3635,"Ranking":4},{"Uid":3259769336037376,"EmployeeName":"朱贵2","EmployeesContributions":3325,"Ranking":5},{"Uid":3259769336137728,"EmployeeName":"杨志358","EmployeesContributions":3309.8,"Ranking":6},{"Uid":3288265494991872,"EmployeeName":"李四","EmployeesContributions":10.5,"Ranking":7},{"Uid":3259769336317952,"EmployeeName":"陈达","EmployeesContributions":0,"Ran
2020/11/24 10:14:53.298 [D] [server.go:1925] | 127.0.0.1| 200 | 218.323689ms| match| POST  /statistics/employees-ranking-list r:/statistics/employees-ranking-list
2020/11/24 11:46:17.200 [I] [???:0] http server Running on http://:8082
2020/11/24 11:48:10.830 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/95.1606189690830647000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司358的兑换活动,哈哈哈",
"deadline": "2020-11-20T21:44:27.822562+08:00",
"exchangeRate": 1.1
}
2020/11/24 11:48:11.579 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/95.1606189690830647000 BodyData:{"code":0,"data":{"activityId":95,"exchangeActivityName":"这是更新后的公司358的兑换活动,哈哈哈","companyId":358,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2020-11-20T23:59:59+08:00","countDown":0,"rate":1.1,"createTime":"2020-11-23T11:08:23.237467+08:00"},"msg":"ok"}
2020/11/24 11:48:11.579 [D] [server.go:1925] | 127.0.0.1| 200 | 749.528378ms| match| PUT  /cash-pool/activity/95 r:/cash-pool/activity/:activityId
2020/11/24 11:48:50.658 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/95.1606189730658567000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司358的兑换活动,哈哈哈",
"deadline": "2020-11-20T21:44:27.822562+08:00",
"exchangeRate": 1.1
}
2020/11/24 11:48:50.732 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/95.1606189730658567000 BodyData:{"code":0,"data":{"activityId":95,"exchangeActivityName":"这是更新后的公司358的兑换活动,哈哈哈","companyId":358,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2020-11-20T21:44:27.822562+08:00","countDown":0,"rate":1.1,"createTime":"2020-11-23T11:08:23.237467+08:00"},"msg":"ok"}
2020/11/24 11:48:50.732 [D] [server.go:1925] | 127.0.0.1| 200 | 74.453429ms| match| PUT  /cash-pool/activity/95 r:/cash-pool/activity/:activityId
2020/11/24 11:49:00.247 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/95.1606189740247618000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司358的兑换活动,哈哈哈",
"deadline": "2020-11-20T21:44:27.822562+08:00",
"exchangeRate": 1.1
}
2020/11/24 11:49:00.369 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/95.1606189740247618000 BodyData:{"code":0,"data":{"activityId":95,"exchangeActivityName":"这是更新后的公司358的兑换活动,哈哈哈","companyId":358,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2020-11-20T21:44:27.822562+08:00","countDown":0,"rate":1.1,"createTime":"2020-11-23T11:08:23.237467+08:00"},"msg":"ok"}
2020/11/24 11:49:00.369 [D] [server.go:1925] | 127.0.0.1| 200 | 122.011188ms| match| PUT  /cash-pool/activity/95 r:/cash-pool/activity/:activityId
2020/11/24 11:49:01.642 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/95.1606189741642713000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司358的兑换活动,哈哈哈",
"deadline": "2020-11-20T21:44:27.822562+08:00",
"exchangeRate": 1.1
}
2020/11/24 11:49:01.757 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/95.1606189741642713000 BodyData:{"code":0,"data":{"activityId":95,"exchangeActivityName":"这是更新后的公司358的兑换活动,哈哈哈","companyId":358,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2020-11-20T21:44:27.822562+08:00","countDown":0,"rate":1.1,"createTime":"2020-11-23T11:08:23.237467+08:00"},"msg":"ok"}
2020/11/24 11:49:01.757 [D] [server.go:1925] | 127.0.0.1| 200 | 114.891328ms| match| PUT  /cash-pool/activity/95 r:/cash-pool/activity/:activityId
2020/11/24 11:49:02.715 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/95.1606189742715009000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司358的兑换活动,哈哈哈",
"deadline": "2020-11-20T21:44:27.822562+08:00",
"exchangeRate": 1.1
}
2020/11/24 11:49:02.722 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/95.1606189742715009000 BodyData:{"code":0,"data":{"activityId":95,"exchangeActivityName":"这是更新后的公司358的兑换活动,哈哈哈","companyId":358,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2020-11-20T21:44:27.822562+08:00","countDown":0,"rate":1.1,"createTime":"2020-11-23T11:08:23.237467+08:00"},"msg":"ok"}
2020/11/24 11:49:02.723 [D] [server.go:1925] | 127.0.0.1| 200 | 8.145799ms| match| PUT  /cash-pool/activity/95 r:/cash-pool/activity/:activityId
2020/11/24 11:49:03.784 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/95.1606189743784065000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司358的兑换活动,哈哈哈",
"deadline": "2020-11-20T21:44:27.822562+08:00",
"exchangeRate": 1.1
}
2020/11/24 11:49:03.798 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/95.1606189743784065000 BodyData:{"code":0,"data":{"activityId":95,"exchangeActivityName":"这是更新后的公司358的兑换活动,哈哈哈","companyId":358,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2020-11-20T21:44:27.822562+08:00","countDown":0,"rate":1.1,"createTime":"2020-11-23T11:08:23.237467+08:00"},"msg":"ok"}
2020/11/24 11:49:03.798 [D] [server.go:1925] | 127.0.0.1| 200 | 14.245609ms| match| PUT  /cash-pool/activity/95 r:/cash-pool/activity/:activityId
2020/11/24 11:49:11.859 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/95.1606189751859860000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司358的兑换活动,哈哈哈",
"deadline": "2020-11-21T21:44:27.822562+08:00",
"exchangeRate": 1.1
}
2020/11/24 11:49:11.940 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/95.1606189751859860000 BodyData:{"code":0,"data":{"activityId":95,"exchangeActivityName":"这是更新后的公司358的兑换活动,哈哈哈","companyId":358,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2020-11-21T21:44:27.822562+08:00","countDown":0,"rate":1.1,"createTime":"2020-11-23T11:08:23.237467+08:00"},"msg":"ok"}
2020/11/24 11:49:11.940 [D] [server.go:1925] | 127.0.0.1| 200 | 80.663504ms| match| PUT  /cash-pool/activity/95 r:/cash-pool/activity/:activityId
2020/11/24 11:49:28.865 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/95.1606189768865023000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司358的兑换活动,哈哈哈",
"deadline": "2020-11-21T21:44:27.822562+08:00",
"exchangeRate": 1.2
}
2020/11/24 11:49:28.891 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/95.1606189768865023000 BodyData:{"code":0,"data":{"activityId":95,"exchangeActivityName":"这是更新后的公司358的兑换活动,哈哈哈","companyId":358,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2020-11-21T21:44:27.822562+08:00","countDown":0,"rate":1.2,"createTime":"2020-11-23T11:08:23.237467+08:00"},"msg":"ok"}
2020/11/24 11:49:28.891 [D] [server.go:1925] | 127.0.0.1| 200 | 26.924025ms| match| PUT  /cash-pool/activity/95 r:/cash-pool/activity/:activityId
2020/11/24 11:51:50.769 [I] [???:0] http server Running on http://:8082
2020/11/24 11:51:57.285 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/95.1606189917285531000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司358的兑换活动,哈哈哈",
"deadline": "2020-11-21T21:44:27.822562+08:00",
"exchangeRate": 1.2
}
2020/11/24 11:51:57.488 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/95.1606189917285531000 BodyData:{"code":0,"data":{"activityId":95,"exchangeActivityName":"这是更新后的公司358的兑换活动,哈哈哈","companyId":358,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2020-11-21T21:44:27.822562+08:00","countDown":-2,"rate":1.2,"createTime":"2020-11-23T11:08:23.237467+08:00"},"msg":"ok"}
2020/11/24 11:51:57.488 [D] [server.go:1925] | 127.0.0.1| 200 | 203.175598ms| match| PUT  /cash-pool/activity/95 r:/cash-pool/activity/:activityId
2020/11/24 11:51:59.160 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/95.1606189919160786000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司358的兑换活动,哈哈哈",
"deadline": "2020-11-21T21:44:27.822562+08:00",
"exchangeRate": 1.2
}
2020/11/24 11:51:59.219 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/95.1606189919160786000 BodyData:{"code":0,"data":{"activityId":95,"exchangeActivityName":"这是更新后的公司358的兑换活动,哈哈哈","companyId":358,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2020-11-21T21:44:27.822562+08:00","countDown":-2,"rate":1.2,"createTime":"2020-11-23T11:08:23.237467+08:00"},"msg":"ok"}
2020/11/24 11:51:59.219 [D] [server.go:1925] | 127.0.0.1| 200 | 58.445365ms| match| PUT  /cash-pool/activity/95 r:/cash-pool/activity/:activityId
2020/11/24 11:52:00.251 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/95.1606189920251542000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司358的兑换活动,哈哈哈",
"deadline": "2020-11-21T21:44:27.822562+08:00",
"exchangeRate": 1.2
}
2020/11/24 11:52:00.389 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/95.1606189920251542000 BodyData:{"code":0,"data":{"activityId":95,"exchangeActivityName":"这是更新后的公司358的兑换活动,哈哈哈","companyId":358,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2020-11-21T21:44:27.822562+08:00","countDown":-2,"rate":1.2,"createTime":"2020-11-23T11:08:23.237467+08:00"},"msg":"ok"}
2020/11/24 11:52:00.389 [D] [server.go:1925] | 127.0.0.1| 200 | 137.612313ms| match| PUT  /cash-pool/activity/95 r:/cash-pool/activity/:activityId
2020/11/24 11:57:38.022 [I] [???:0] http server Running on http://:8082
2020/11/24 11:57:41.482 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/95.1606190261482367000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司358的兑换活动,哈哈哈",
"deadline": "2020-11-21T21:44:27.822562+08:00",
"exchangeRate": 1.2
}
2020/11/24 11:57:41.540 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/95.1606190261482367000 BodyData:{"code":0,"data":{"activityId":95,"exchangeActivityName":"这是更新后的公司358的兑换活动,哈哈哈","companyId":358,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2020-11-21T21:44:27.822562+08:00","countDown":-2,"rate":1.2,"createTime":"2020-11-24T11:57:41.494318+08:00"},"msg":"ok"}
2020/11/24 11:57:41.540 [D] [server.go:1925] | 127.0.0.1| 200 | 58.670594ms| match| PUT  /cash-pool/activity/95 r:/cash-pool/activity/:activityId
2020/11/24 11:57:42.687 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/95.1606190262687810000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司358的兑换活动,哈哈哈",
"deadline": "2020-11-21T21:44:27.822562+08:00",
"exchangeRate": 1.2
}
2020/11/24 11:57:42.720 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/95.1606190262687810000 BodyData:{"code":0,"data":{"activityId":95,"exchangeActivityName":"这是更新后的公司358的兑换活动,哈哈哈","companyId":358,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2020-11-21T21:44:27.822562+08:00","countDown":-2,"rate":1.2,"createTime":"2020-11-24T11:57:42.714394+08:00"},"msg":"ok"}
2020/11/24 11:57:42.720 [D] [server.go:1925] | 127.0.0.1| 200 | 32.885047ms| match| PUT  /cash-pool/activity/95 r:/cash-pool/activity/:activityId
2020/11/24 11:57:53.860 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/95.1606190273860478000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司358的兑换活动,哈哈哈",
"deadline": "2020-11-25T21:44:27.822562+08:00",
"exchangeRate": 1.2
}
2020/11/24 11:57:53.871 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/95.1606190273860478000 BodyData:{"code":0,"data":{"activityId":95,"exchangeActivityName":"这是更新后的公司358的兑换活动,哈哈哈","companyId":358,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2020-11-25T21:44:27.822562+08:00","countDown":-2,"rate":1.2,"createTime":"2020-11-24T11:57:53.863293+08:00"},"msg":"ok"}
2020/11/24 11:57:53.871 [D] [server.go:1925] | 127.0.0.1| 200 | 11.524971ms| match| PUT  /cash-pool/activity/95 r:/cash-pool/activity/:activityId
2020/11/24 11:58:56.912 [I] [???:0] http server Running on http://:8082
2020/11/24 11:59:01.987 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/95.1606190341987404000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司358的兑换活动,哈哈哈",
"deadline": "2020-11-25T21:44:27.822562+08:00",
"exchangeRate": 1.2
}
2020/11/24 11:59:02.027 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/95.1606190341987404000 BodyData:{"code":0,"data":{"activityId":95,"exchangeActivityName":"这是更新后的公司358的兑换活动,哈哈哈","companyId":358,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2020-11-25T21:44:27.822562+08:00","countDown":2,"rate":1.2,"createTime":"2020-11-24T11:59:02.00598+08:00"},"msg":"ok"}
2020/11/24 11:59:02.028 [D] [server.go:1925] | 127.0.0.1| 200 | 40.923833ms| match| PUT  /cash-pool/activity/95 r:/cash-pool/activity/:activityId
2020/11/24 11:59:03.575 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/95.1606190343575805000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司358的兑换活动,哈哈哈",
"deadline": "2020-11-25T21:44:27.822562+08:00",
"exchangeRate": 1.2
}
2020/11/24 11:59:03.583 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/95.1606190343575805000 BodyData:{"code":0,"data":{"activityId":95,"exchangeActivityName":"这是更新后的公司358的兑换活动,哈哈哈","companyId":358,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2020-11-25T21:44:27.822562+08:00","countDown":2,"rate":1.2,"createTime":"2020-11-24T11:59:03.582687+08:00"},"msg":"ok"}
2020/11/24 11:59:03.583 [D] [server.go:1925] | 127.0.0.1| 200 | 8.078491ms| match| PUT  /cash-pool/activity/95 r:/cash-pool/activity/:activityId
2020/11/24 11:59:04.435 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/95.1606190344435072000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司358的兑换活动,哈哈哈",
"deadline": "2020-11-25T21:44:27.822562+08:00",
"exchangeRate": 1.2
}
2020/11/24 11:59:04.439 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/95.1606190344435072000 BodyData:{"code":0,"data":{"activityId":95,"exchangeActivityName":"这是更新后的公司358的兑换活动,哈哈哈","companyId":358,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2020-11-25T21:44:27.822562+08:00","countDown":2,"rate":1.2,"createTime":"2020-11-24T11:59:04.4382+08:00"},"msg":"ok"}
2020/11/24 11:59:04.439 [D] [server.go:1925] | 127.0.0.1| 200 | 4.796071ms| match| PUT  /cash-pool/activity/95 r:/cash-pool/activity/:activityId
... ...
... ... @@ -859,8 +859,29 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(cashPoolsFound) == 0 {
var t1 = time.Now().Local()
var t2 = updateExchangeCashActivityCommand.Deadline.Local()
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, "当前公司未创建现金池")
updateExchangeCashActivityCommand.CountDown = int64(math.Ceil(t2.Sub(t1).Hours() / 24))
// 更新兑换活动
if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
// 保存兑换活动更新
if activityUpdated, err := exchangeCashActivityRepository.Save(activityFound); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
activityUpdated.ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityUpdated.ExchangedSuMoney), 64)
activityUpdated.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityUpdated.ExchangedCash), 64)
activityUpdated.Deadline = activityUpdated.Deadline.Local()
activityUpdated.CreateTime = activityUpdated.CreateTime.Local()
return activityUpdated, nil
}
}
// 获取当前兑换活动汇率
... ...
... ... @@ -51,7 +51,11 @@ func (exchangeCashActivity *ExchangeCashActivity) Update(data map[string]interfa
if exchangeRate, ok := data["exchangeRate"]; ok && exchangeRate != 0 {
exchangeCashActivity.Rate = exchangeRate.(float64)
}
return nil
if createTime, ok := data["createTime"]; ok && createTime.(time.Time).IsZero() {
exchangeCashActivity.CreateTime = createTime.(time.Time)
}
exchangeCashActivity.CreateTime = time.Now()
return nil
}
func (exchangeCashActivity *ExchangeCashActivity) TransferSuMoney(rate float64) error {
... ...
... ... @@ -64,3 +64,10 @@ func JsonToMap(jsonStr string) (map[string]string, error) {
return m, nil
}
func InsertSlice(index int, newstr []string, src []string) (ns []string) {
ns = append(ns, src[:index]...) // 切片后加..., 相当于拆包成单个元素
ns = append(ns, newstr...)
ns = append(ns, src[index:]...)
return
}
... ...
... ... @@ -6,6 +6,7 @@ import (
"github.com/360EntSecGroup-Skylar/excelize/v2"
"github.com/astaxie/beego"
"github.com/linmadan/egglib-go/web/beego/utils"
utils_tool "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/utils"
"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"
... ... @@ -433,6 +434,7 @@ func (controller *SuMoneyController) ImportExchangeList () {
// 文件行数校验
rows, _ := xlsx.GetRows("Sheet1")
// 表格超行判断
if len(rows) > 302 {
err := fmt.Errorf("%s", "导入行数超过300行")
response = utils.ResponseError(controller.Ctx, err)
... ... @@ -441,13 +443,27 @@ func (controller *SuMoneyController) ImportExchangeList () {
return
}
//空行记录
nullLine := make([]interface{}, 0)
// 空表格判断
if len(rows) < 3 {
err := fmt.Errorf("%s", "当前导入的为空表格")
response = utils.ResponseError(controller.Ctx, err)
controller.Data["json"] = response
controller.ServeJSON()
return
}
newstr := []string{"null"}
// 单元格非空校验
// 空字段判断
nullLine := make([]interface{}, 0)
for i, row := range rows {
if i > 2 {
if len(row) != 3 {
for j, cell := range row {
if cell == "" {
utils_tool.InsertSlice(j, row, newstr)
}
}
row = append(row, "单元格包含空字符")
nullLine = append(nullLine, row)
}
... ... @@ -474,17 +490,12 @@ func (controller *SuMoneyController) ImportExchangeList () {
// 新增成功计数
var successDataCount int64
//fmt.Print(len(rows), "\n")
for i, row := range rows {
//fmt.Printf("Row Number:%d, Row: %+v\n, Row Length: %d\n", i, row, len(row))
if i > 2 && len(row) > 1 {
// 创建兑换清单命令
createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{}
createExchangeCashPersonCommand.ExchangeCashActivityId, _ = strconv.ParseInt(jsonMap["activityId"].(string), 10, 64 )
//createExchangeCashPersonCommand.ExchangeCashActivityId, _ = strconv.ParseInt(interface{}(importExchangeCashListCommand.Where).(map[string]interface{})["activityId"].(string), 10, 64)
createExchangeCashPersonCommand.Operator = int64(jsonMap["uid"].(float64))
//createExchangeCashPersonCommand.Operator = int64(interface{}(importExchangeCashListCommand.Where).(map[string]interface{})["uid"].(float64))
createExchangeCashPersonCommand.PersonName = row[0]
createExchangeCashPersonCommand.PersonAccount = row[1]
r2, _ := strconv.ParseFloat(row[2], 64)
... ...