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
9ef43d78
Commit
9ef43d78
authored
Apr 11, 2024
by
程裕兵
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:getOpenId
parent
8d5fba81
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
162 additions
and
0 deletions
+162
-0
api/src/main/java/com/jiejing/fitness/finance/api/merchant/StudioMerchantApi.java
+5
-0
api/src/main/java/com/jiejing/fitness/finance/api/merchant/StudioMerchantApiFallback.java
+6
-0
api/src/main/java/com/jiejing/fitness/finance/api/merchant/request/GetOpenIdRequest.java
+36
-0
app/src/main/java/com/jiejing/fitness/finance/app/controller/merchant/StudioMerchantController.java
+9
-0
pom.xml
+11
-0
service/pom.xml
+8
-0
service/src/main/java/com/jiejing/fitness/finance/service/enums/GlobalConfigEnums.java
+1
-0
service/src/main/java/com/jiejing/fitness/finance/service/pay/PayService.java
+11
-0
service/src/main/java/com/jiejing/fitness/finance/service/pay/impl/PayServiceImpl.java
+75
-0
No files found.
api/src/main/java/com/jiejing/fitness/finance/api/merchant/StudioMerchantApi.java
View file @
9ef43d78
...
...
@@ -7,6 +7,7 @@ import com.jiejing.fitness.finance.api.merchant.request.AuthStudioSubChannelRequ
import
com.jiejing.fitness.finance.api.merchant.request.BindStudioMerchantRequest
;
import
com.jiejing.fitness.finance.api.merchant.request.BindStudioMerchantXcxAppIdRequest
;
import
com.jiejing.fitness.finance.api.merchant.request.GetAuthStudioSubChannelRequest
;
import
com.jiejing.fitness.finance.api.merchant.request.GetOpenIdRequest
;
import
com.jiejing.fitness.finance.api.merchant.request.GetStudioLatestMerchantApplyRequest
;
import
com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantApplyRequest
;
import
com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantRequest
;
...
...
@@ -72,6 +73,10 @@ public interface StudioMerchantApi {
@PostMapping
(
value
=
"/private/studioMerchant/listAuthSubChannel"
)
JsonResult
<
List
<
StudioMerchantAuthSubChannelVO
>>
listAuthSubChannel
(
GetAuthStudioSubChannelRequest
request
);
@ApiOperation
(
value
=
"获取openId"
,
tags
=
{
TAG
})
@PostMapping
(
value
=
"/private/studioMerchant/getOpenId"
)
JsonResult
<
String
>
getOpenId
(
GetOpenIdRequest
request
);
@ApiOperation
(
value
=
"支付"
,
tags
=
{
TAG
})
@PostMapping
(
value
=
"/private/studioMerchant/pay"
)
JsonResult
<
PayVO
>
pay
(
StudioMerchantPayRequest
request
);
...
...
api/src/main/java/com/jiejing/fitness/finance/api/merchant/StudioMerchantApiFallback.java
View file @
9ef43d78
...
...
@@ -7,6 +7,7 @@ import com.jiejing.fitness.finance.api.merchant.request.AuthStudioSubChannelRequ
import
com.jiejing.fitness.finance.api.merchant.request.BindStudioMerchantRequest
;
import
com.jiejing.fitness.finance.api.merchant.request.BindStudioMerchantXcxAppIdRequest
;
import
com.jiejing.fitness.finance.api.merchant.request.GetAuthStudioSubChannelRequest
;
import
com.jiejing.fitness.finance.api.merchant.request.GetOpenIdRequest
;
import
com.jiejing.fitness.finance.api.merchant.request.GetStudioLatestMerchantApplyRequest
;
import
com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantApplyRequest
;
import
com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantRequest
;
...
...
@@ -85,6 +86,11 @@ public class StudioMerchantApiFallback implements FallbackFactory<StudioMerchant
}
@Override
public
JsonResult
<
String
>
getOpenId
(
GetOpenIdRequest
request
)
{
return
JsonResult
.
rpcError
();
}
@Override
public
JsonResult
<
PayVO
>
pay
(
StudioMerchantPayRequest
request
)
{
return
JsonResult
.
rpcError
();
}
...
...
api/src/main/java/com/jiejing/fitness/finance/api/merchant/request/GetOpenIdRequest.java
0 → 100644
View file @
9ef43d78
package
com
.
jiejing
.
fitness
.
finance
.
api
.
merchant
.
request
;
import
com.jiejing.paycenter.common.enums.common.PayChannelEnums
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @author chengyubing
* @since 2024/2/27 10:54
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel
(
description
=
"获取openIdRequest"
)
public
class
GetOpenIdRequest
{
@ApiModelProperty
(
value
=
"支付渠道"
,
required
=
true
)
@NotNull
(
message
=
"支付渠道不能为空"
)
private
PayChannelEnums
channel
;
@ApiModelProperty
(
name
=
"应用ID"
,
required
=
true
)
@NotBlank
(
message
=
"应用ID不能为空"
)
private
String
appId
;
@ApiModelProperty
(
name
=
"authCode"
,
required
=
true
)
@NotBlank
(
message
=
"authCode不能为空"
)
private
String
authCode
;
}
app/src/main/java/com/jiejing/fitness/finance/app/controller/merchant/StudioMerchantController.java
View file @
9ef43d78
...
...
@@ -9,6 +9,7 @@ import com.jiejing.fitness.finance.api.merchant.request.AuthStudioSubChannelRequ
import
com.jiejing.fitness.finance.api.merchant.request.BindStudioMerchantRequest
;
import
com.jiejing.fitness.finance.api.merchant.request.BindStudioMerchantXcxAppIdRequest
;
import
com.jiejing.fitness.finance.api.merchant.request.GetAuthStudioSubChannelRequest
;
import
com.jiejing.fitness.finance.api.merchant.request.GetOpenIdRequest
;
import
com.jiejing.fitness.finance.api.merchant.request.GetStudioLatestMerchantApplyRequest
;
import
com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantApplyRequest
;
import
com.jiejing.fitness.finance.api.merchant.request.GetStudioMerchantRequest
;
...
...
@@ -128,6 +129,14 @@ public class StudioMerchantController implements StudioMerchantApi {
return
JsonResult
.
success
(
studioMerchantService
.
listAuthSubChannel
(
request
.
getStudioId
()));
}
@ApiOperation
(
value
=
"获取openId"
,
tags
=
{
TAG
})
@PostMapping
(
value
=
"/private/studioMerchant/getOpenId"
)
@Override
public
JsonResult
<
String
>
getOpenId
(
@RequestBody
@Valid
GetOpenIdRequest
request
)
{
return
JsonResult
.
success
(
payService
.
getOpenId
(
request
.
getChannel
(),
request
.
getAppId
(),
request
.
getAuthCode
()));
}
@ApiOperation
(
value
=
"支付"
,
tags
=
{
TAG
})
@PostMapping
(
value
=
"/private/studioMerchant/pay"
)
@Override
...
...
pom.xml
View file @
9ef43d78
...
...
@@ -120,6 +120,17 @@
<artifactId>
ding-client
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.jiejing.fitness
</groupId>
<artifactId>
wechat-client
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.alipay.sdk
</groupId>
<artifactId>
alipay-sdk-java
</artifactId>
<version>
4.38.221.ALL
</version>
</dependency>
<!-- ======================= jiejing tools end ======================= -->
<!-- ======================= data source start ======================= -->
...
...
service/pom.xml
View file @
9ef43d78
...
...
@@ -69,6 +69,14 @@
<groupId>
com.jiejing.common
</groupId>
<artifactId>
ding-client
</artifactId>
</dependency>
<dependency>
<groupId>
com.jiejing.fitness
</groupId>
<artifactId>
wechat-client
</artifactId>
</dependency>
<dependency>
<groupId>
com.alipay.sdk
</groupId>
<artifactId>
alipay-sdk-java
</artifactId>
</dependency>
</dependencies>
</project>
service/src/main/java/com/jiejing/fitness/finance/service/enums/GlobalConfigEnums.java
View file @
9ef43d78
...
...
@@ -17,6 +17,7 @@ public enum GlobalConfigEnums {
*/
BRAND_MERCHANT_SUB_CHANNELS
(
"BRAND_MERCHANT_SUB_CHANNELS"
,
"品牌商户默认开通的子渠道以及对应费率"
),
CASHIER_APP_IDS
(
"CASHIER_APP_IDS"
,
"收银所需的appId"
),
CASHIER_ALI_INFO
(
"CASHIER_ALI_INFO"
,
"收银所需支付宝信息"
),
;
@EnumValue
...
...
service/src/main/java/com/jiejing/fitness/finance/service/pay/PayService.java
View file @
9ef43d78
...
...
@@ -3,6 +3,7 @@ package com.jiejing.fitness.finance.service.pay;
import
com.jiejing.fitness.finance.service.pay.params.NativePayParams
;
import
com.jiejing.fitness.finance.service.pay.params.StudioMerchantPayParams
;
import
com.jiejing.fitness.finance.service.pay.params.BrandMerchantRefundParams
;
import
com.jiejing.paycenter.common.enums.common.PayChannelEnums
;
import
com.jiejing.paycenter.common.model.vo.PayVO
;
import
com.jiejing.paycenter.api.pay.vo.RefundVO
;
import
com.jiejing.paycenter.common.event.PayEvent
;
...
...
@@ -16,6 +17,16 @@ import java.util.Date;
public
interface
PayService
{
/**
* 获取openId
*
* @param channel 渠道
* @param appId appId
* @param authCode 标记
* @return openId
*/
String
getOpenId
(
PayChannelEnums
channel
,
String
appId
,
String
authCode
);
/**
* Native支付
*
* @param params 参数
...
...
service/src/main/java/com/jiejing/fitness/finance/service/pay/impl/PayServiceImpl.java
View file @
9ef43d78
...
...
@@ -2,6 +2,13 @@ package com.jiejing.fitness.finance.service.pay.impl;
import
static
java
.
util
.
stream
.
Collectors
.
toList
;
import
com.alibaba.fastjson.JSON
;
import
com.alipay.api.AlipayApiException
;
import
com.alipay.api.AlipayConfig
;
import
com.alipay.api.AlipayRequest
;
import
com.alipay.api.DefaultAlipayClient
;
import
com.alipay.api.request.AlipaySystemOauthTokenRequest
;
import
com.alipay.api.response.AlipaySystemOauthTokenResponse
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
com.google.common.collect.Lists
;
import
com.jiejing.common.exception.BizException
;
...
...
@@ -10,17 +17,20 @@ import com.jiejing.common.utils.time.TimeUtil;
import
com.jiejing.fitness.enums.finance.BrandCashierTransStateEnum
;
import
com.jiejing.fitness.enums.finance.PartyTypeEnum
;
import
com.jiejing.fitness.finance.api.pay.request.NativePayRequest
;
import
com.jiejing.fitness.finance.repository.entity.GlobalConfig
;
import
com.jiejing.fitness.finance.repository.entity.StudioCashierRecord
;
import
com.jiejing.fitness.finance.repository.entity.PartyToMerchant
;
import
com.jiejing.fitness.finance.repository.entity.StudioCheckSettleRecord
;
import
com.jiejing.fitness.finance.repository.entity.StudioMerchantApply
;
import
com.jiejing.fitness.finance.repository.entity.StudioSettleRecord
;
import
com.jiejing.fitness.finance.repository.service.GlobalConfigRpService
;
import
com.jiejing.fitness.finance.repository.service.StudioCashierRecordRpService
;
import
com.jiejing.fitness.finance.repository.service.PartyToMerchantRpService
;
import
com.jiejing.fitness.finance.repository.service.StudioCheckSettleRecordRpService
;
import
com.jiejing.fitness.finance.repository.service.StudioMerchantApplyRpService
;
import
com.jiejing.fitness.finance.repository.service.StudioSettleRecordRpService
;
import
com.jiejing.fitness.finance.service.enums.FinanceErrorEnums
;
import
com.jiejing.fitness.finance.service.enums.GlobalConfigEnums
;
import
com.jiejing.fitness.finance.service.pay.PayService
;
import
com.jiejing.fitness.finance.service.pay.convert.PayConvert
;
import
com.jiejing.fitness.finance.service.pay.params.BrandMerchantRefundParams
;
...
...
@@ -30,6 +40,7 @@ import com.jiejing.fitness.finance.service.rpc.MerchantRpcService;
import
com.jiejing.fitness.finance.service.rpc.PayRpcService
;
import
com.jiejing.fitness.finance.service.rpc.StudioRpcService
;
import
com.jiejing.fitness.finance.service.utils.DingUtil
;
import
com.jiejing.paycenter.common.enums.common.PayChannelEnums
;
import
com.jiejing.paycenter.common.enums.common.TransStateEnums
;
import
com.jiejing.paycenter.common.enums.pay.PayTypeEnums
;
import
com.jiejing.paycenter.common.model.vo.MerchantVO
;
...
...
@@ -41,14 +52,20 @@ import com.jiejing.paycenter.common.event.PayEvent;
import
com.jiejing.paycenter.common.event.RefundEvent
;
import
com.jiejing.paycenter.common.model.vo.SettleVO
;
import
com.jiejing.studio.api.studio.vo.StudioVO
;
import
com.jiejing.wechat.WeChatAuthService
;
import
com.jiejing.wechat.vo.weChat.BaseAuthInfoVO
;
import
java.math.BigDecimal
;
import
java.time.temporal.ChronoUnit
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.function.Consumer
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.Resource
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.domain.Page
;
...
...
@@ -89,6 +106,50 @@ public class PayServiceImpl implements PayService {
@Resource
private
StudioCheckSettleRecordRpService
studioCheckSettleRecordRpService
;
@Resource
private
WeChatAuthService
weChatAuthService
;
@Resource
private
GlobalConfigRpService
globalConfigRpService
;
private
final
Map
<
String
,
DefaultAlipayClient
>
aliClientMap
=
new
HashMap
<>();
@PostConstruct
public
void
init
()
{
GlobalConfig
config
=
globalConfigRpService
.
getById
(
GlobalConfigEnums
.
CASHIER_ALI_INFO
.
getCode
())
.
orElse
(
new
GlobalConfig
());
AliInfo
info
=
JSON
.
parseObject
(
config
.
getConfigValue
(),
AliInfo
.
class
);
aliClientMap
.
put
(
info
.
getAppId
(),
new
DefaultAlipayClient
(
info
.
getBaseUrl
(),
info
.
getAppId
(),
info
.
getMerchantPrivateKey
(),
"json"
,
"utf-8"
));
}
@Override
public
String
getOpenId
(
PayChannelEnums
channel
,
String
appId
,
String
authCode
)
{
switch
(
channel
)
{
case
WX:
return
Optional
.
ofNullable
(
weChatAuthService
.
getBaseAuthInfo
(
null
,
appId
,
authCode
))
.
map
(
BaseAuthInfoVO:
:
getOpenId
).
orElse
(
null
);
case
ALI:
try
{
AlipaySystemOauthTokenResponse
response
=
aliClientMap
.
get
(
appId
).
execute
(
convert
(
authCode
));
return
response
.
getUserId
();
}
catch
(
AlipayApiException
e
)
{
throw
new
BizException
(
e
.
getErrCode
(),
e
.
getMessage
());
}
default
:
throw
new
BizException
(
FinanceErrorEnums
.
NOT_SUPPORT_TYPE
);
}
}
public
AlipaySystemOauthTokenRequest
convert
(
String
authCode
)
{
AlipaySystemOauthTokenRequest
aliRequest
=
new
AlipaySystemOauthTokenRequest
();
aliRequest
.
setCode
(
authCode
);
aliRequest
.
setGrantType
(
"authorization_code"
);
return
aliRequest
;
}
@Override
public
PayVO
nativePay
(
NativePayParams
params
)
{
return
payRpcService
.
pay
(
convertNativePay
(
params
));
...
...
@@ -289,4 +350,18 @@ public class PayServiceImpl implements PayService {
return
req
;
}
@Data
private
static
class
AliInfo
{
private
String
appId
;
private
String
baseUrl
;
private
String
alipayPublicKey
;
private
String
merchantPrivateKey
;
}
}
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