Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fit-finance
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fitness-server
fit-finance
Commits
59644bd9
Commit
59644bd9
authored
Feb 21, 2024
by
程裕兵
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:upload
parent
d1430411
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
37 deletions
+38
-37
app/src/main/java/com/jiejing/fitness/finance/app/config/FinanceAsyncConfiguration.java
+2
-2
service/src/main/java/com/jiejing/fitness/finance/service/merchant/convert/MerchantConvert.java
+16
-3
service/src/main/java/com/jiejing/fitness/finance/service/merchant/impl/BrandMerchantServiceImpl.java
+20
-32
No files found.
app/src/main/java/com/jiejing/fitness/finance/app/config/FinanceAsyncConfiguration.java
View file @
59644bd9
...
...
@@ -15,8 +15,8 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@Configuration
public
class
FinanceAsyncConfiguration
{
@Bean
(
value
=
"finance
AsyncConfiguration
"
)
public
AsyncTaskExecutor
payCenter
ThreadPool
()
{
@Bean
(
value
=
"finance
ThreadPool
"
)
public
AsyncTaskExecutor
finance
ThreadPool
()
{
ThreadPoolTaskExecutor
executor
=
new
ThreadPoolTaskExecutor
();
executor
.
setCorePoolSize
(
Runtime
.
getRuntime
().
availableProcessors
()
*
8
);
executor
.
setMaxPoolSize
(
Runtime
.
getRuntime
().
availableProcessors
()
*
16
);
...
...
service/src/main/java/com/jiejing/fitness/finance/service/merchant/convert/MerchantConvert.java
View file @
59644bd9
package
com
.
jiejing
.
fitness
.
finance
.
service
.
merchant
.
convert
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
com.google.common.collect.Lists
;
import
com.jiejing.common.utils.crypt.AesUtil
;
import
com.jiejing.filecenter.api.resource.vo.ResourceInfoVO
;
import
com.jiejing.fitness.finance.api.enums.ApplyTypeEnums
;
import
com.jiejing.fitness.finance.repository.entity.BrandMerchantApply
;
import
com.jiejing.fitness.finance.service.merchant.params.ApplyBrandMerchantParams
;
import
com.jiejing.paycenter.api.merchant.request.ApplyMerchantRequest
;
import
com.jiejing.paycenter.api.merchant.request.UploadRequest
;
import
com.jiejing.paycenter.common.enums.common.OpenStateEnums
;
import
com.jiejing.paycenter.common.enums.merchant.BusinessTypeEnums
;
import
com.jiejing.paycenter.common.enums.merchant.LicenseTypeEnums
;
import
com.jiejing.paycenter.common.enums.merchant.MccEnums
;
import
com.jiejing.paycenter.common.enums.merchant.PaySceneEnums
;
import
com.jiejing.paycenter.common.enums.merchant.ResourceTypeEnums
;
import
com.jiejing.paycenter.common.enums.merchant.SceneTypeEnums
;
import
com.jiejing.paycenter.common.model.Address
;
import
com.jiejing.paycenter.common.model.BankCard
;
...
...
@@ -146,9 +148,8 @@ public class MerchantConvert {
.
build
();
}
public
static
BrandMerchantApply
convertApply
(
ApplyBrandMerchantParams
params
,
StudioVO
studio
,
public
static
BrandMerchantApply
convertApply
(
Long
id
,
ApplyBrandMerchantParams
params
,
StudioVO
studio
,
BrandMerchantApply
exist
,
String
channel
)
{
long
id
=
IdWorker
.
getId
();
String
salt
=
AesUtil
.
getSalt
(
8
);
ApplyBrandMerchantParams
encrypt
=
params
.
encrypt
(
salt
);
return
BrandMerchantApply
.
builder
()
...
...
@@ -212,4 +213,16 @@ public class MerchantConvert {
.
updateTime
(
new
Date
())
.
build
();
}
public
static
UploadRequest
convertUploadRequest
(
String
channel
,
ResourceTypeEnums
type
,
ResourceInfoVO
vo
)
{
return
UploadRequest
.
builder
()
.
url
(
vo
.
getUrl
())
.
fileSize
(
vo
.
getFileSize
())
.
suffix
(
vo
.
getSuffix
())
.
channelNo
(
channel
)
.
resourceType
(
type
)
.
build
();
}
}
service/src/main/java/com/jiejing/fitness/finance/service/merchant/impl/BrandMerchantServiceImpl.java
View file @
59644bd9
package
com
.
jiejing
.
fitness
.
finance
.
service
.
merchant
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jiejing.common.exception.BizException
;
import
com.jiejing.common.utils.collection.CollectionUtil
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
com.jiejing.filecenter.api.resource.vo.ResourceInfoVO
;
import
com.jiejing.fitness.finance.repository.entity.BrandMerchantApply
;
import
com.jiejing.fitness.finance.repository.service.BrandMerchantApplyRpService
;
...
...
@@ -12,11 +10,7 @@ import com.jiejing.fitness.finance.service.merchant.params.ApplyBrandMerchantPar
import
com.jiejing.fitness.finance.service.rpc.MerchantRpcService
;
import
com.jiejing.fitness.finance.service.rpc.ResourceRpcService
;
import
com.jiejing.fitness.finance.service.rpc.StudioRpcService
;
import
com.jiejing.paycenter.api.merchant.request.ApplyMerchantRequest
;
import
com.jiejing.paycenter.api.merchant.request.UploadRequest
;
import
com.jiejing.paycenter.common.enums.common.OpenStateEnums
;
import
com.jiejing.paycenter.common.enums.error.PayErrorEnums
;
import
com.jiejing.paycenter.common.enums.merchant.ResourceTypeEnums
;
import
com.jiejing.paycenter.common.model.ResourceInfo
;
import
com.jiejing.studio.api.studio.vo.StudioVO
;
import
java.util.List
;
...
...
@@ -26,6 +20,7 @@ import java.util.stream.Collectors;
import
javax.annotation.Resource
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
/**
...
...
@@ -53,51 +48,44 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
@Resource
private
BrandMerchantApplyRpService
brandMerchantApplyRpService
;
@Async
(
value
=
"financeThreadPool"
)
@Override
public
void
apply
(
ApplyBrandMerchantParams
params
)
{
this
.
upload
(
params
);
Long
id
=
IdWorker
.
getId
();
StudioVO
studio
=
studioRpcService
.
getStudio
(
params
.
getStudioId
());
BrandMerchantApply
exist
=
brandMerchantApplyRpService
.
getLatestOneSuccessByBrandId
(
studio
.
getBrandId
());
BrandMerchantApply
apply
=
MerchantConvert
.
convertApply
(
params
,
studio
,
exist
,
channel
);
BrandMerchantApply
exist
=
brandMerchantApplyRpService
.
getLatestOneSuccessByBrandId
(
studio
.
getBrandId
());
BrandMerchantApply
apply
=
MerchantConvert
.
convertApply
(
id
,
params
,
studio
,
exist
,
channel
);
brandMerchantApplyRpService
.
insert
(
apply
);
try
{
brandMerchantApplyRpService
.
insert
(
apply
);
ApplyMerchantRequest
request
=
MerchantConvert
.
convertRequest
(
channel
,
apply
.
getApplyNo
(),
studio
.
getBrandId
(),
params
);
merchantRpcService
.
apply
(
request
);
this
.
upload
(
params
);
merchantRpcService
.
apply
(
MerchantConvert
.
convertRequest
(
channel
,
apply
.
getApplyNo
(),
studio
.
getBrandId
(),
params
));
}
catch
(
Exception
e
)
{
brandMerchantApplyRpService
.
updateById
(
BrandMerchantApply
.
builder
().
id
(
apply
.
getId
()
).
openState
(
OpenStateEnums
.
FAIL
)
BrandMerchantApply
.
builder
().
id
(
id
).
openState
(
OpenStateEnums
.
FAIL
)
.
openFailMessage
(
e
.
getMessage
()).
build
());
}
}
private
void
upload
(
ApplyBrandMerchantParams
params
)
{
Map
<
Long
,
ResourceInfoVO
>
resourceIdUrlMap
=
resourceRpcService
.
getResourceMap
(
params
.
getStudioId
(),
getResourceIds
(
params
));
List
<
ResourceTypeEnums
>
resourceTypes
=
params
.
getResourceInfo
().
keySet
().
stream
().
filter
(
type
->
{
Long
resourceId
=
params
.
getResourceInfo
().
get
(
type
).
getResourceId
();
return
type
.
getMaxSize
().
compareTo
(
resourceIdUrlMap
.
get
(
resourceId
).
getFileSize
())
<
0
;
}).
collect
(
Collectors
.
toList
());
if
(
CollectionUtil
.
isNotEmpty
(
resourceTypes
))
{
String
message
=
""
;
for
(
ResourceTypeEnums
type
:
resourceTypes
)
{
message
=
message
+
"["
+
type
.
getDesc
()
+
"大小不超过"
+
type
.
getMaxSize
()
/
1024
/
1024
+
"MB]"
;
}
throw
new
BizException
(
PayErrorEnums
.
PARAMS_ERROR
,
new
JSONObject
().
fluentPut
(
"message"
,
message
));
}
params
.
getResourceInfo
().
keySet
().
forEach
(
type
->
{
Long
resourceId
=
params
.
getResourceInfo
().
get
(
type
).
getResourceId
();
String
url
=
resourceIdUrlMap
.
get
(
resourceId
).
getUrl
();
String
thirdId
=
merchantRpcService
.
upload
(
UploadRequest
.
builder
().
url
(
url
).
channelNo
(
channel
).
resourceType
(
type
).
build
());
params
.
getResourceInfo
().
get
(
type
).
setThirdId
(
thirdId
);
ResourceInfo
info
=
params
.
getResourceInfo
().
get
(
type
);
ResourceInfoVO
vo
=
resourceIdUrlMap
.
get
(
info
.
getResourceId
());
String
thirdId
=
merchantRpcService
.
upload
(
MerchantConvert
.
convertUploadRequest
(
channel
,
type
,
vo
));
info
.
setThirdId
(
thirdId
);
});
}
private
List
<
Long
>
getResourceIds
(
ApplyBrandMerchantParams
params
)
{
...
...
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