Commit 10010900 by 程裕兵

feat:pay channel

parent 31aafe18
......@@ -15,6 +15,7 @@ spring:
default-binder: biz-kafka
finance:
brand:
merchant:
channel: "001"
channel:
cashier: "001"
ali_native: "002"
wx_native: "003"
......@@ -15,6 +15,7 @@ spring:
default-binder: biz-kafka
finance:
brand:
merchant:
channel: "001"
channel:
cashier: "001"
ali_native: "002"
wx_native: "003"
......@@ -20,6 +20,7 @@ spring:
default-binder: biz-kafka
finance:
brand:
merchant:
channel: "001"
channel:
cashier: "001"
ali_native: "002"
wx_native: "003"
......@@ -15,6 +15,7 @@ spring:
default-binder: biz-kafka
finance:
brand:
merchant:
channel: "001"
channel:
cashier: "001"
ali_native: "002"
wx_native: "003"
......@@ -15,6 +15,7 @@ spring:
default-binder: biz-kafka
finance:
brand:
merchant:
channel: "001"
channel:
cashier: "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;
import com.jiejing.fitness.finance.repository.entity.StudioMerchantApply;
import com.jiejing.fitness.finance.repository.service.PartyToMerchantRpService;
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.merchant.BrandMerchantService;
import com.jiejing.fitness.finance.service.merchant.convert.MerchantConvert;
......@@ -33,8 +34,8 @@ import org.springframework.stereotype.Service;
@Service
public class BrandMerchantServiceImpl implements BrandMerchantService {
@Value("${finance.brand.merchant.channel}")
private String channel;
@Resource
private PayChannelConfig config;
@Resource
private StudioMerchantApplyRpService studioMerchantApplyRpService;
......@@ -53,7 +54,7 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
@Override
public void bind(Long brandId, Long merchantId) {
PartyToMerchant exist = partyToMerchantRpService.getOneByPartyAndMerchantId(channel, brandId,
PartyToMerchant exist = partyToMerchantRpService.getOneByPartyAndMerchantId(config.getCashier(), brandId,
PartyTypeEnum.BRAND, merchantId);
if (null != exist) {
return;
......@@ -73,7 +74,7 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
@Override
public List<BrandMerchantVO> list(Long brandId) {
List<PartyToMerchant> relations = partyToMerchantRpService.listByParty(brandId, PartyTypeEnum.BRAND,
channel);
config.getCashier());
if (CollectionUtil.isEmpty(relations)) {
return Lists.newArrayList();
}
......
......@@ -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.service.PartyToMerchantRpService;
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.global.ConfigService;
import com.jiejing.fitness.finance.service.global.dto.SubChannelInfoDTO;
......@@ -66,8 +67,8 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class StudioMerchantServiceImpl implements StudioMerchantService {
@Value("${finance.brand.merchant.channel}")
private String channel;
@Resource
private PayChannelConfig config;
@Resource
private StudioRpcService studioRpcService;
......@@ -219,8 +220,8 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
if (null == relation) {
throw new BizException(FinanceErrorEnums.MERCHANT_NOT_OPEN);
}
ConfigSubChannelVO vo = merchantRpcService.bindAppIdWxXcxOffline(channel, relation.getMerchantId(),
appId);
ConfigSubChannelVO vo = merchantRpcService.bindAppIdWxXcxOffline(config.getCashier(),
relation.getMerchantId(), appId);
return StudioMerchantBindXcxAppIdVO.builder().state(vo.getState()).failMessage(vo.getFailMessage())
.build();
......@@ -228,7 +229,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
private PartyToMerchant getRelation(Long studioId) {
List<PartyToMerchant> relations = partyToMerchantRpService.listByParty(studioId, PartyTypeEnum.STUDIO,
channel);
config.getCashier());
if (CollectionUtil.isEmpty(relations)) {
return null;
}
......@@ -243,8 +244,8 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
throw new BizException(FinanceErrorEnums.MERCHANT_NOT_OPEN);
}
AuthSubChannelVO vo = merchantRpcService.authSubChannel(channel, relation.getMerchantId(), subChannel,
authType);
AuthSubChannelVO vo = merchantRpcService.authSubChannel(config.getCashier(), relation.getMerchantId(),
subChannel, authType);
return BeanUtil.map(vo, StudioMerchantAuthSubChannelVO.class);
}
......@@ -303,7 +304,8 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
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(
params.getResourceMap());
......@@ -314,7 +316,8 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
resourceMap.keySet().forEach(type -> {
ResourceInfo info = resourceMap.get(type);
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);
});
return resourceMap;
......@@ -355,7 +358,7 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
Long id = IdWorker.getId();
StudioVO studio = studioRpcService.getStudio(params.getStudioId());
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);
return apply;
......
......@@ -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.StudioMerchantApplyRpService;
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.GlobalConfigEnums;
import com.jiejing.fitness.finance.service.pay.PayService;
......@@ -82,8 +83,8 @@ import org.springframework.stereotype.Service;
@Service
public class PayServiceImpl implements PayService {
@Value("${finance.brand.merchant.channel}")
private String channel;
@Resource
private PayChannelConfig config;
@Resource
private PartyToMerchantRpService partyToMerchantRpService;
......@@ -161,7 +162,7 @@ public class PayServiceImpl implements PayService {
@Override
public PayVO merchantPay(StudioMerchantPayParams params) {
StudioVO studio = studioRpcService.getStudio(params.getStudioId());
PartyToMerchant relation = partyToMerchantRpService.getByStudioId(studio.getId(), channel);
PartyToMerchant relation = partyToMerchantRpService.getByStudioId(studio.getId(), config.getCashier());
if (null == relation) {
throw new BizException(FinanceErrorEnums.MERCHANT_NOT_OPEN);
}
......@@ -178,7 +179,7 @@ public class PayServiceImpl implements PayService {
@Override
public void payCallback(PayEvent event) {
if (!event.getChannelNo().equals(channel)) {
if (!event.getChannelNo().equals(config.getCashier())) {
return;
}
StudioCashierRecord record = studioCashierRecordRpService.getById(Long.parseLong(event.getTransNo()))
......@@ -331,9 +332,9 @@ public class PayServiceImpl implements PayService {
private String getChannelNo(NativePayParams params) {
switch (params.getChannel()) {
case WX:
return "003";
return config.getWxNative();
case ALI:
return "002";
return config.getAliNative();
default:
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