Commit 10010900 by 程裕兵

feat:pay channel

parent 31aafe18
...@@ -15,6 +15,7 @@ spring: ...@@ -15,6 +15,7 @@ spring:
default-binder: biz-kafka default-binder: biz-kafka
finance: finance:
brand: channel:
merchant: cashier: "001"
channel: "001" ali_native: "002"
wx_native: "003"
...@@ -15,6 +15,7 @@ spring: ...@@ -15,6 +15,7 @@ spring:
default-binder: biz-kafka default-binder: biz-kafka
finance: finance:
brand: channel:
merchant: cashier: "001"
channel: "001" ali_native: "002"
wx_native: "003"
...@@ -20,6 +20,7 @@ spring: ...@@ -20,6 +20,7 @@ spring:
default-binder: biz-kafka default-binder: biz-kafka
finance: finance:
brand: channel:
merchant: cashier: "001"
channel: "001" ali_native: "002"
wx_native: "003"
...@@ -15,6 +15,7 @@ spring: ...@@ -15,6 +15,7 @@ spring:
default-binder: biz-kafka default-binder: biz-kafka
finance: finance:
brand: channel:
merchant: cashier: "001"
channel: "001" ali_native: "002"
wx_native: "003"
...@@ -15,6 +15,7 @@ spring: ...@@ -15,6 +15,7 @@ spring:
default-binder: biz-kafka default-binder: biz-kafka
finance: finance:
brand: channel:
merchant: cashier: "001"
channel: "001" ali_native: "002"
wx_native: "003"
package com.jiejing.fitness.finance.service.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* 支付渠道配置
*
* @author chengyubing
* @since 2024/4/15 14:14
*/
@Data
@Configuration
@EnableConfigurationProperties(PayChannelConfig.class)
@ConfigurationProperties(prefix = "finance.channel")
public class PayChannelConfig {
private String cashier;
private String aliNative;
private String wxNative;
}
...@@ -8,6 +8,7 @@ import com.jiejing.fitness.finance.repository.entity.PartyToMerchant; ...@@ -8,6 +8,7 @@ import com.jiejing.fitness.finance.repository.entity.PartyToMerchant;
import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply; import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply;
import com.jiejing.fitness.finance.repository.service.PartyToMerchantRpService; import com.jiejing.fitness.finance.repository.service.PartyToMerchantRpService;
import com.jiejing.fitness.finance.repository.service.StudioMerchantApplyRpService; import com.jiejing.fitness.finance.repository.service.StudioMerchantApplyRpService;
import com.jiejing.fitness.finance.service.config.PayChannelConfig;
import com.jiejing.fitness.finance.service.global.ConfigService; import com.jiejing.fitness.finance.service.global.ConfigService;
import com.jiejing.fitness.finance.service.merchant.BrandMerchantService; import com.jiejing.fitness.finance.service.merchant.BrandMerchantService;
import com.jiejing.fitness.finance.service.merchant.convert.MerchantConvert; import com.jiejing.fitness.finance.service.merchant.convert.MerchantConvert;
...@@ -33,8 +34,8 @@ import org.springframework.stereotype.Service; ...@@ -33,8 +34,8 @@ import org.springframework.stereotype.Service;
@Service @Service
public class BrandMerchantServiceImpl implements BrandMerchantService { public class BrandMerchantServiceImpl implements BrandMerchantService {
@Value("${finance.brand.merchant.channel}") @Resource
private String channel; private PayChannelConfig config;
@Resource @Resource
private StudioMerchantApplyRpService studioMerchantApplyRpService; private StudioMerchantApplyRpService studioMerchantApplyRpService;
...@@ -53,7 +54,7 @@ public class BrandMerchantServiceImpl implements BrandMerchantService { ...@@ -53,7 +54,7 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
@Override @Override
public void bind(Long brandId, Long merchantId) { public void bind(Long brandId, Long merchantId) {
PartyToMerchant exist = partyToMerchantRpService.getOneByPartyAndMerchantId(channel, brandId, PartyToMerchant exist = partyToMerchantRpService.getOneByPartyAndMerchantId(config.getCashier(), brandId,
PartyTypeEnum.BRAND, merchantId); PartyTypeEnum.BRAND, merchantId);
if (null != exist) { if (null != exist) {
return; return;
...@@ -73,7 +74,7 @@ public class BrandMerchantServiceImpl implements BrandMerchantService { ...@@ -73,7 +74,7 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
@Override @Override
public List<BrandMerchantVO> list(Long brandId) { public List<BrandMerchantVO> list(Long brandId) {
List<PartyToMerchant> relations = partyToMerchantRpService.listByParty(brandId, PartyTypeEnum.BRAND, List<PartyToMerchant> relations = partyToMerchantRpService.listByParty(brandId, PartyTypeEnum.BRAND,
channel); config.getCashier());
if (CollectionUtil.isEmpty(relations)) { if (CollectionUtil.isEmpty(relations)) {
return Lists.newArrayList(); return Lists.newArrayList();
} }
......
...@@ -18,6 +18,7 @@ import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply; ...@@ -18,6 +18,7 @@ import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply;
import com.jiejing.fitness.finance.repository.query.PageStudioMerchantApplyQuery; import com.jiejing.fitness.finance.repository.query.PageStudioMerchantApplyQuery;
import com.jiejing.fitness.finance.repository.service.PartyToMerchantRpService; import com.jiejing.fitness.finance.repository.service.PartyToMerchantRpService;
import com.jiejing.fitness.finance.repository.service.StudioMerchantApplyRpService; import com.jiejing.fitness.finance.repository.service.StudioMerchantApplyRpService;
import com.jiejing.fitness.finance.service.config.PayChannelConfig;
import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums; import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums;
import com.jiejing.fitness.finance.service.global.ConfigService; import com.jiejing.fitness.finance.service.global.ConfigService;
import com.jiejing.fitness.finance.service.global.dto.SubChannelInfoDTO; import com.jiejing.fitness.finance.service.global.dto.SubChannelInfoDTO;
...@@ -66,8 +67,8 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -66,8 +67,8 @@ import org.springframework.transaction.annotation.Transactional;
@Service @Service
public class StudioMerchantServiceImpl implements StudioMerchantService { public class StudioMerchantServiceImpl implements StudioMerchantService {
@Value("${finance.brand.merchant.channel}") @Resource
private String channel; private PayChannelConfig config;
@Resource @Resource
private StudioRpcService studioRpcService; private StudioRpcService studioRpcService;
...@@ -219,8 +220,8 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -219,8 +220,8 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
if (null == relation) { if (null == relation) {
throw new BizException(FinanceErrorEnums.MERCHANT_NOT_OPEN); throw new BizException(FinanceErrorEnums.MERCHANT_NOT_OPEN);
} }
ConfigSubChannelVO vo = merchantRpcService.bindAppIdWxXcxOffline(channel, relation.getMerchantId(), ConfigSubChannelVO vo = merchantRpcService.bindAppIdWxXcxOffline(config.getCashier(),
appId); relation.getMerchantId(), appId);
return StudioMerchantBindXcxAppIdVO.builder().state(vo.getState()).failMessage(vo.getFailMessage()) return StudioMerchantBindXcxAppIdVO.builder().state(vo.getState()).failMessage(vo.getFailMessage())
.build(); .build();
...@@ -228,7 +229,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -228,7 +229,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
private PartyToMerchant getRelation(Long studioId) { private PartyToMerchant getRelation(Long studioId) {
List<PartyToMerchant> relations = partyToMerchantRpService.listByParty(studioId, PartyTypeEnum.STUDIO, List<PartyToMerchant> relations = partyToMerchantRpService.listByParty(studioId, PartyTypeEnum.STUDIO,
channel); config.getCashier());
if (CollectionUtil.isEmpty(relations)) { if (CollectionUtil.isEmpty(relations)) {
return null; return null;
} }
...@@ -243,8 +244,8 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -243,8 +244,8 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
throw new BizException(FinanceErrorEnums.MERCHANT_NOT_OPEN); throw new BizException(FinanceErrorEnums.MERCHANT_NOT_OPEN);
} }
AuthSubChannelVO vo = merchantRpcService.authSubChannel(channel, relation.getMerchantId(), subChannel, AuthSubChannelVO vo = merchantRpcService.authSubChannel(config.getCashier(), relation.getMerchantId(),
authType); subChannel, authType);
return BeanUtil.map(vo, StudioMerchantAuthSubChannelVO.class); return BeanUtil.map(vo, StudioMerchantAuthSubChannelVO.class);
} }
...@@ -303,7 +304,8 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -303,7 +304,8 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
config.getAppId())); config.getAppId()));
} }
private Map<ResourceTypeEnums, ResourceInfo> upload(ApplyStudioMerchantParams params, StudioMerchantApply apply) { private Map<ResourceTypeEnums, ResourceInfo> upload(ApplyStudioMerchantParams params,
StudioMerchantApply apply) {
Map<ResourceTypeEnums, ResourceInfo> resourceMap = MerchantConvert.convertResourceMap( Map<ResourceTypeEnums, ResourceInfo> resourceMap = MerchantConvert.convertResourceMap(
params.getResourceMap()); params.getResourceMap());
...@@ -314,7 +316,8 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -314,7 +316,8 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
resourceMap.keySet().forEach(type -> { resourceMap.keySet().forEach(type -> {
ResourceInfo info = resourceMap.get(type); ResourceInfo info = resourceMap.get(type);
ResourceInfoVO vo = resourceIdUrlMap.get(info.getResourceId()); ResourceInfoVO vo = resourceIdUrlMap.get(info.getResourceId());
String thirdId = merchantRpcService.upload(MerchantConvert.convertUploadRequest(channel, type, vo)); String thirdId = merchantRpcService.upload(
MerchantConvert.convertUploadRequest(config.getCashier(), type, vo));
info.setThirdId(thirdId); info.setThirdId(thirdId);
}); });
return resourceMap; return resourceMap;
...@@ -355,7 +358,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService { ...@@ -355,7 +358,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
Long id = IdWorker.getId(); Long id = IdWorker.getId();
StudioVO studio = studioRpcService.getStudio(params.getStudioId()); StudioVO studio = studioRpcService.getStudio(params.getStudioId());
StudioMerchantApply exist = studioMerchantApplyRpService.getLatestOneSuccessByStudioId(studio.getId()); StudioMerchantApply exist = studioMerchantApplyRpService.getLatestOneSuccessByStudioId(studio.getId());
StudioMerchantApply apply = MerchantConvert.convertApply(id, params, studio, exist, channel); StudioMerchantApply apply = MerchantConvert.convertApply(id, params, studio, exist, config.getCashier());
studioMerchantApplyRpService.insert(apply); studioMerchantApplyRpService.insert(apply);
return apply; return apply;
......
...@@ -29,6 +29,7 @@ import com.jiejing.fitness.finance.repository.service.PartyToMerchantRpService; ...@@ -29,6 +29,7 @@ import com.jiejing.fitness.finance.repository.service.PartyToMerchantRpService;
import com.jiejing.fitness.finance.repository.service.StudioCheckSettleRecordRpService; import com.jiejing.fitness.finance.repository.service.StudioCheckSettleRecordRpService;
import com.jiejing.fitness.finance.repository.service.StudioMerchantApplyRpService; import com.jiejing.fitness.finance.repository.service.StudioMerchantApplyRpService;
import com.jiejing.fitness.finance.repository.service.StudioSettleRecordRpService; import com.jiejing.fitness.finance.repository.service.StudioSettleRecordRpService;
import com.jiejing.fitness.finance.service.config.PayChannelConfig;
import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums; import com.jiejing.fitness.finance.service.enums.FinanceErrorEnums;
import com.jiejing.fitness.finance.service.enums.GlobalConfigEnums; import com.jiejing.fitness.finance.service.enums.GlobalConfigEnums;
import com.jiejing.fitness.finance.service.pay.PayService; import com.jiejing.fitness.finance.service.pay.PayService;
...@@ -82,8 +83,8 @@ import org.springframework.stereotype.Service; ...@@ -82,8 +83,8 @@ import org.springframework.stereotype.Service;
@Service @Service
public class PayServiceImpl implements PayService { public class PayServiceImpl implements PayService {
@Value("${finance.brand.merchant.channel}") @Resource
private String channel; private PayChannelConfig config;
@Resource @Resource
private PartyToMerchantRpService partyToMerchantRpService; private PartyToMerchantRpService partyToMerchantRpService;
...@@ -161,7 +162,7 @@ public class PayServiceImpl implements PayService { ...@@ -161,7 +162,7 @@ public class PayServiceImpl implements PayService {
@Override @Override
public PayVO merchantPay(StudioMerchantPayParams params) { public PayVO merchantPay(StudioMerchantPayParams params) {
StudioVO studio = studioRpcService.getStudio(params.getStudioId()); StudioVO studio = studioRpcService.getStudio(params.getStudioId());
PartyToMerchant relation = partyToMerchantRpService.getByStudioId(studio.getId(), channel); PartyToMerchant relation = partyToMerchantRpService.getByStudioId(studio.getId(), config.getCashier());
if (null == relation) { if (null == relation) {
throw new BizException(FinanceErrorEnums.MERCHANT_NOT_OPEN); throw new BizException(FinanceErrorEnums.MERCHANT_NOT_OPEN);
} }
...@@ -178,7 +179,7 @@ public class PayServiceImpl implements PayService { ...@@ -178,7 +179,7 @@ public class PayServiceImpl implements PayService {
@Override @Override
public void payCallback(PayEvent event) { public void payCallback(PayEvent event) {
if (!event.getChannelNo().equals(channel)) { if (!event.getChannelNo().equals(config.getCashier())) {
return; return;
} }
StudioCashierRecord record = studioCashierRecordRpService.getById(Long.parseLong(event.getTransNo())) StudioCashierRecord record = studioCashierRecordRpService.getById(Long.parseLong(event.getTransNo()))
...@@ -331,9 +332,9 @@ public class PayServiceImpl implements PayService { ...@@ -331,9 +332,9 @@ public class PayServiceImpl implements PayService {
private String getChannelNo(NativePayParams params) { private String getChannelNo(NativePayParams params) {
switch (params.getChannel()) { switch (params.getChannel()) {
case WX: case WX:
return "003"; return config.getWxNative();
case ALI: case ALI:
return "002"; return config.getAliNative();
default: default:
throw new BizException(FinanceErrorEnums.NOT_SUPPORT_TYPE); throw new BizException(FinanceErrorEnums.NOT_SUPPORT_TYPE);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment