Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jiedao-api-boot-master
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lanbaoming
jiedao-api-boot-master
Commits
9f7867a7
Commit
9f7867a7
authored
Jul 31, 2024
by
zhaobiyan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
兑换信息导入
parent
64378e69
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
46 deletions
+57
-46
RedeemRewardController.java
...eward/controller/admin/redeem/RedeemRewardController.java
+4
-4
RewardRedeemServiceImpl.java
...module/reward/service/redeem/RewardRedeemServiceImpl.java
+47
-33
RedeemInfoImportExcelVO.java
...udao/module/reward/vo/reward/RedeemInfoImportExcelVO.java
+2
-7
messages_en.properties
yudao-server/src/main/resources/i18n/messages_en.properties
+2
-1
messages_zh.properties
yudao-server/src/main/resources/i18n/messages_zh.properties
+2
-1
No files found.
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/controller/admin/redeem/RedeemRewardController.java
View file @
9f7867a7
...
...
@@ -91,11 +91,11 @@ public class RedeemRewardController {
public
void
importTemplate
(
HttpServletResponse
response
)
throws
IOException
{
// 手动创建导出 demo
List
<
RedeemInfoImportExcelVO
>
list
=
Arrays
.
asList
(
RedeemInfoImportExcelVO
.
builder
().
id
(
1111L
).
redeemType
(
"上门领取"
).
courierCompany
(
"顺丰空运"
).
expenses
(
BigDecimal
.
valueOf
(
11.11
))
.
currency
(
"人民币"
).
expressDate
(
new
Date
()
).
expressNo
(
"SDSD212212"
).
remark
(
"备注备注"
).
expressSender
(
"系统管理员"
)
RedeemInfoImportExcelVO
.
builder
().
id
(
String
.
valueOf
(
11111
)
).
redeemType
(
"上门领取"
).
courierCompany
(
"顺丰空运"
).
expenses
(
BigDecimal
.
valueOf
(
11.11
))
.
currency
(
"人民币"
).
expressDate
(
"2024-01-01 11:22:33"
).
expressNo
(
"SDSD212212"
).
remark
(
"备注备注"
).
expressSender
(
"系统管理员"
)
.
build
(),
RedeemInfoImportExcelVO
.
builder
().
id
(
2222L
).
redeemType
(
"包邮到家"
).
courierCompany
(
"顺丰空运"
).
expenses
(
BigDecimal
.
valueOf
(
11.11
))
.
currency
(
"美元"
).
expressDate
(
new
Date
()
).
expressNo
(
"SDSD212212"
).
remark
(
"备注备注"
).
expressSender
(
"系统管理员"
)
RedeemInfoImportExcelVO
.
builder
().
id
(
String
.
valueOf
(
11111
)
).
redeemType
(
"包邮到家"
).
courierCompany
(
"顺丰空运"
).
expenses
(
BigDecimal
.
valueOf
(
11.11
))
.
currency
(
"美元"
).
expressDate
(
"2024-01-01 11:22:33"
).
expressNo
(
"SDSD212212"
).
remark
(
"备注备注"
).
expressSender
(
"系统管理员"
)
.
build
());
// 输出
ExcelUtils
.
write
(
response
,
"兑换信息导入模板.xls"
,
"兑换信息"
,
RedeemInfoImportExcelVO
.
class
,
list
);
...
...
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/service/redeem/RewardRedeemServiceImpl.java
View file @
9f7867a7
package
cn
.
iocoder
.
yudao
.
module
.
reward
.
service
.
redeem
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.map.MapUtil
;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO
;
...
...
@@ -33,6 +34,7 @@ import java.util.*;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
static
cn
.
hutool
.
core
.
date
.
DatePattern
.
NORM_DATETIME_PATTERN
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
module
.
system
.
enums
.
download
.
DownloadTypeEnum
.
REWARD_REDEEM_RECORD
;
...
...
@@ -104,7 +106,7 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
@Override
public
Boolean
verify
(
RewardRedeemVerifyReqVO
request
)
{
if
(!
checkVerifyParam
(
request
)){
if
(!
checkVerifyParam
(
request
))
{
throw
exception
(
ErrorCodeConstants
.
REWARD_REDEEM_VERIFY_NO_PARAM
);
}
LambdaUpdateWrapper
<
RewardRedeemDO
>
wrapper
=
Wrappers
.
lambdaUpdate
();
...
...
@@ -190,6 +192,7 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
public
List
<
RewardRedeemPageRespVO
>
exportList
(
RewardRedeemPageReqVO
request
)
{
return
rewardRedeemMapper
.
exportList
(
request
);
}
@Override
public
Integer
exportCount
(
RewardRedeemPageReqVO
request
)
{
return
rewardRedeemMapper
.
pageCount
(
request
);
...
...
@@ -207,14 +210,14 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
Map
<
String
,
CurrencyRespDTO
>
titleZhCurrencyMap
=
allCurrency
.
stream
().
collect
(
Collectors
.
toMap
(
CurrencyRespDTO:
:
getTitleZh
,
Function
.
identity
(),
(
c1
,
c2
)
->
c1
));
Map
<
String
,
CurrencyRespDTO
>
titleEnCurrencyMap
=
allCurrency
.
stream
().
collect
(
Collectors
.
toMap
(
CurrencyRespDTO:
:
getTitleEn
,
Function
.
identity
(),
(
c1
,
c2
)
->
c1
));
Map
<
String
,
ExpressRespDTO
>
nameExpressMap
=
expressApi
.
getAllExpress
().
stream
().
collect
(
Collectors
.
toMap
(
ExpressRespDTO:
:
getCompanyName
,
Function
.
identity
(),
(
c1
,
c2
)
->
c1
));
Map
<
String
,
String
>
failedInfo
=
validate
(
dataList
,
titleZhCurrencyMap
,
titleEnCurrencyMap
,
nameExpressMap
);
Map
<
String
,
String
>
failedInfo
=
validate
(
dataList
,
titleZhCurrencyMap
,
titleEnCurrencyMap
,
nameExpressMap
);
if
(
MapUtil
.
isNotEmpty
(
failedInfo
))
{
return
RecordInfoImportRespVO
.
builder
().
redeemIdFailedMap
(
failedInfo
).
build
();
}
List
<
RewardRedeemDO
>
saveDataList
=
dataList
.
stream
().
map
(
data
->
{
RewardRedeemDO
rewardRedeemDO
=
new
RewardRedeemDO
();
rewardRedeemDO
.
setId
(
data
.
getId
(
));
rewardRedeemDO
.
setId
(
Long
.
parseLong
(
data
.
getId
()
));
DictDataRespDTO
redeemTypeDict
=
DictFrameworkUtils
.
parseDictDataFromCacheWithMultiLang
(
"way_of_receiving"
,
data
.
getRedeemType
());
rewardRedeemDO
.
setRedeemType
(
Integer
.
parseInt
(
redeemTypeDict
.
getValue
()));
rewardRedeemDO
.
setExpenses
(
data
.
getExpenses
());
...
...
@@ -225,7 +228,7 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
rewardRedeemDO
.
setCurrency
(
Optional
.
ofNullable
(
currencyRespDTO
).
map
(
CurrencyRespDTO:
:
getId
).
orElse
(
null
));
rewardRedeemDO
.
setCourierCompany
(
nameExpressMap
.
get
(
data
.
getCourierCompany
()).
getId
());
rewardRedeemDO
.
setExpressNo
(
data
.
getExpressNo
());
rewardRedeemDO
.
setExpressDate
(
data
.
getExpressDate
(
));
rewardRedeemDO
.
setExpressDate
(
DateUtil
.
parse
(
data
.
getExpressDate
(),
NORM_DATETIME_PATTERN
));
rewardRedeemDO
.
setExpressSender
(
data
.
getExpressSender
());
rewardRedeemDO
.
setRemark
(
data
.
getRemark
());
return
rewardRedeemDO
;
...
...
@@ -243,23 +246,36 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
.
collect
(
Collectors
.
toMap
(
RewardRedeemDO:
:
getId
,
Function
.
identity
(),
(
c1
,
c2
)
->
c1
));
Map
<
String
,
String
>
failedInfoMap
=
new
HashMap
<>();
dataList
.
forEach
(
data
->
{
RewardRedeemDO
rewardRedeemDO
=
idRewardRedeemDOMap
.
get
(
data
.
getId
());
long
id
;
try
{
id
=
Long
.
parseLong
(
data
.
getId
());
}
catch
(
Exception
e
)
{
failedInfoMap
.
put
(
data
.
getId
()
==
null
?
""
:
data
.
getId
(),
I18nMessage
.
getMessage
(
"reward.redeem.not.exist"
));
return
;
}
try
{
DateUtil
.
parse
(
data
.
getExpressDate
(),
NORM_DATETIME_PATTERN
);
}
catch
(
Exception
e
)
{
failedInfoMap
.
put
(
data
.
getId
()
==
null
?
""
:
data
.
getId
(),
I18nMessage
.
getMessage
(
"date.format.error"
));
return
;
}
RewardRedeemDO
rewardRedeemDO
=
idRewardRedeemDOMap
.
get
(
id
);
if
(
rewardRedeemDO
==
null
)
{
failedInfoMap
.
put
(
data
.
getId
()
==
null
?
""
:
String
.
valueOf
(
data
.
getId
()
),
I18nMessage
.
getMessage
(
"reward.redeem.not.exist"
));
failedInfoMap
.
put
(
data
.
getId
()
==
null
?
""
:
data
.
getId
(
),
I18nMessage
.
getMessage
(
"reward.redeem.not.exist"
));
return
;
}
if
(
rewardRedeemDO
.
getStatus
()
!=
RewardRedeemStatusEnum
.
REDEEMING
.
getValue
())
{
failedInfoMap
.
put
(
String
.
valueOf
(
rewardRedeemDO
.
getId
()
),
I18nMessage
.
getMessage
(
"reward.redeem.status.error"
));
failedInfoMap
.
put
(
data
.
getId
(
),
I18nMessage
.
getMessage
(
"reward.redeem.status.error"
));
return
;
}
DictDataRespDTO
redeemTypeDict
=
DictFrameworkUtils
.
parseDictDataFromCacheWithMultiLang
(
"way_of_receiving"
,
data
.
getRedeemType
());
if
(
redeemTypeDict
==
null
)
{
failedInfoMap
.
put
(
String
.
valueOf
(
rewardRedeemDO
.
getId
()
),
I18nMessage
.
getMessage
(
"dict.unknown.error"
,
"way_of_receiving"
,
data
.
getRedeemType
()));
failedInfoMap
.
put
(
data
.
getId
(
),
I18nMessage
.
getMessage
(
"dict.unknown.error"
,
"way_of_receiving"
,
data
.
getRedeemType
()));
return
;
}
ExpressRespDTO
expressRespDTO
=
nameExpressMap
.
get
(
data
.
getCourierCompany
());
if
(
expressRespDTO
==
null
)
{
failedInfoMap
.
put
(
String
.
valueOf
(
rewardRedeemDO
.
getId
()
),
I18nMessage
.
getMessage
(
"express.not.exist"
));
if
(
expressRespDTO
==
null
)
{
failedInfoMap
.
put
(
data
.
getId
(
),
I18nMessage
.
getMessage
(
"express.not.exist"
));
return
;
}
CurrencyRespDTO
currencyRespDTO
=
titleZhCurrencyMap
.
get
(
data
.
getCurrency
());
...
...
@@ -267,22 +283,21 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
currencyRespDTO
=
titleEnCurrencyMap
.
get
(
data
.
getCurrency
());
}
if
(
currencyRespDTO
==
null
&&
StringUtils
.
isNotBlank
(
data
.
getCurrency
()))
{
failedInfoMap
.
put
(
String
.
valueOf
(
rewardRedeemDO
.
getId
()
),
I18nMessage
.
getMessage
(
"currency.not.exist"
));
failedInfoMap
.
put
(
data
.
getId
(
),
I18nMessage
.
getMessage
(
"currency.not.exist"
));
return
;
}
if
(!
canVerify
(
RewardRedeemVerifyDTO
.
builder
()
.
id
(
data
.
getId
(
))
.
id
(
Long
.
parseLong
(
data
.
getId
()
))
.
redeemType
(
Integer
.
parseInt
(
redeemTypeDict
.
getValue
()))
.
status
(
rewardRedeemDO
.
getStatus
())
.
expense
(
data
.
getExpenses
())
.
currency
(
Optional
.
ofNullable
(
currencyRespDTO
).
map
(
CurrencyRespDTO:
:
getId
).
orElse
(
null
))
.
courierCompany
(
expressRespDTO
.
getId
())
.
expressSender
(
data
.
getExpressSender
())
.
expressDate
(
data
.
getExpressDate
(
))
.
expressDate
(
DateUtil
.
parse
(
data
.
getExpressDate
(),
NORM_DATETIME_PATTERN
))
.
expressNo
(
data
.
getExpressNo
())
.
recipientAddress
(
rewardRedeemDO
.
getRecipientAddress
()).
build
()))
{
failedInfoMap
.
put
(
String
.
valueOf
(
rewardRedeemDO
.
getId
()),
I18nMessage
.
getMessage
(
"reward.redeem.verify.no.param"
));
return
;
}
});
return
failedInfoMap
;
...
...
@@ -293,25 +308,24 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
wrapper
.
in
(
RewardRedeemDO:
:
getId
,
request
.
getIds
());
Map
<
Long
,
RewardRedeemDO
>
idRewardRedeemMap
=
this
.
list
(
wrapper
).
stream
()
.
collect
(
Collectors
.
toMap
(
RewardRedeemDO:
:
getId
,
Function
.
identity
(),
(
c1
,
c2
)
->
c1
));
List
<
Long
>
errorIds
=
idRewardRedeemMap
.
keySet
().
stream
().
filter
(
id
->
{
RewardRedeemDO
rewardRedeemDO
=
idRewardRedeemMap
.
get
(
id
);
if
(
rewardRedeemDO
==
null
)
{
return
true
;
}
return
!
canVerify
(
RewardRedeemVerifyDTO
.
builder
()
.
id
(
rewardRedeemDO
.
getId
())
.
status
(
rewardRedeemDO
.
getStatus
())
.
redeemType
(
rewardRedeemDO
.
getRedeemType
())
.
expense
(
rewardRedeemDO
.
getExpenses
())
.
currency
(
rewardRedeemDO
.
getCurrency
())
.
courierCompany
(
rewardRedeemDO
.
getCourierCompany
())
.
expressDate
(
rewardRedeemDO
.
getExpressDate
())
.
recipientAddress
(
rewardRedeemDO
.
getRecipientAddress
())
.
expressNo
(
rewardRedeemDO
.
getExpressNo
())
.
expressSender
(
rewardRedeemDO
.
getExpressSender
())
.
build
());
}).
collect
(
Collectors
.
toList
());
return
errorIds
;
return
idRewardRedeemMap
.
keySet
().
stream
().
filter
(
id
->
{
RewardRedeemDO
rewardRedeemDO
=
idRewardRedeemMap
.
get
(
id
);
if
(
rewardRedeemDO
==
null
)
{
return
true
;
}
return
!
canVerify
(
RewardRedeemVerifyDTO
.
builder
()
.
id
(
rewardRedeemDO
.
getId
())
.
status
(
rewardRedeemDO
.
getStatus
())
.
redeemType
(
rewardRedeemDO
.
getRedeemType
())
.
expense
(
rewardRedeemDO
.
getExpenses
())
.
currency
(
rewardRedeemDO
.
getCurrency
())
.
courierCompany
(
rewardRedeemDO
.
getCourierCompany
())
.
expressDate
(
rewardRedeemDO
.
getExpressDate
())
.
recipientAddress
(
rewardRedeemDO
.
getRecipientAddress
())
.
expressNo
(
rewardRedeemDO
.
getExpressNo
())
.
expressSender
(
rewardRedeemDO
.
getExpressSender
())
.
build
());
}).
collect
(
Collectors
.
toList
());
}
private
boolean
checkVerifyParam
(
RewardRedeemVerifyReqVO
request
)
{
...
...
yudao-module-reward/yudao-module-reward-impl/src/main/java/cn/iocoder/yudao/module/reward/vo/reward/RedeemInfoImportExcelVO.java
View file @
9f7867a7
package
cn
.
iocoder
.
yudao
.
module
.
reward
.
vo
.
reward
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.alibaba.excel.annotation.format.DateTimeFormat
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
...
...
@@ -9,9 +8,6 @@ import lombok.NoArgsConstructor;
import
lombok.experimental.Accessors
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
util
.
date
.
DateUtils
.
FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND
;
@Data
@Builder
...
...
@@ -20,7 +16,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Accessors
(
chain
=
false
)
public
class
RedeemInfoImportExcelVO
{
@ExcelProperty
(
"兑换记录ID/Redeem ID"
)
private
Lo
ng
id
;
private
Stri
ng
id
;
@ExcelProperty
(
"兑换方式/Redeem Method"
)
private
String
redeemType
;
@ExcelProperty
(
"费用/fee"
)
...
...
@@ -32,8 +28,7 @@ public class RedeemInfoImportExcelVO {
@ExcelProperty
(
"快递单号/Express NO"
)
private
String
expressNo
;
@ExcelProperty
(
value
=
"快递日期/Delivery Date"
)
@DateTimeFormat
(
value
=
FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND
)
private
Date
expressDate
;
private
String
expressDate
;
@ExcelProperty
(
"快递寄出人/Sender"
)
private
String
expressSender
;
@ExcelProperty
(
"备注/Remark"
)
...
...
yudao-server/src/main/resources/i18n/messages_en.properties
View file @
9f7867a7
...
...
@@ -1019,4 +1019,5 @@ reward.redeem.verify.back.status = record status must be redeemed
redeem.import.max.count
=
allow maximum number of imports is {}
dict.unknown.error
=
Not in dict {0}: {1}
express.not.exist
=
express not exist
currency.not.exist
=
currency not exist
\ No newline at end of file
currency.not.exist
=
currency not exist
date.format.error
=
date format error, for example : 2024-01-01 12:11:11
\ No newline at end of file
yudao-server/src/main/resources/i18n/messages_zh.properties
View file @
9f7867a7
...
...
@@ -1023,4 +1023,5 @@ reward.redeem.verify.back.status = \u56DE\u9000\u8BB0\u5F55\u72B6\u6001\u5FC5\u9
redeem.import.max.count
=
\u5141\u
8BB8
\u7684\u6700\u5927\u
5BFC
\u5165\u6761\u6570\u
4E3A{}
dict.unknown.error
=
\u
4E0D
\u5728
{0}
\u
5B57
\u5178\u
4E2D: {1}
express.not.exist
=
\u
5FEB
\u9012\u
516C
\u
53F8
\u
4E0D
\u
5B58
\u5728
currency.not.exist
=
\u
5E01
\u
79CD
\u
4E0D
\u
5B58
\u5728
\ No newline at end of file
currency.not.exist
=
\u
5E01
\u
79CD
\u
4E0D
\u
5B58
\u5728
date.format.error
=
\u
65E5
\u
671F
\u
683C
\u
5F0F
\u
4E0D
\u
6B63
\u
786E,
\u
6B63
\u
786E
\u
683C
\u
5F0F
\u
53C2
\u8003
: 2024-01-01 12:11:11
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment