Commit dacd4285 by 程裕兵

feat:get merchant

parent b60eee13
...@@ -28,6 +28,9 @@ public class StudioMerchantVO { ...@@ -28,6 +28,9 @@ public class StudioMerchantVO {
@ApiModelProperty("场馆ID") @ApiModelProperty("场馆ID")
private Long studioId; private Long studioId;
@ApiModelProperty("原始场馆ID")
private Long sourceStudioId;
@ApiModelProperty("品牌ID") @ApiModelProperty("品牌ID")
private Long brandId; private Long brandId;
......
...@@ -33,6 +33,8 @@ public enum FinanceErrorEnums implements BaseBizError { ...@@ -33,6 +33,8 @@ public enum FinanceErrorEnums implements BaseBizError {
PAY_FAIL_5("支付失败,请联系场馆工作人员进行支付宝授权。"), PAY_FAIL_5("支付失败,请联系场馆工作人员进行支付宝授权。"),
PAY_FAIL_6("该场馆单笔收款有额度限制,请联系场馆提升收款额度或者分多笔订单支付。"), PAY_FAIL_6("该场馆单笔收款有额度限制,请联系场馆提升收款额度或者分多笔订单支付。"),
PAY_FAIL_7("该场馆单日收款有额度限制,请联系场馆提升收款额度。"), PAY_FAIL_7("该场馆单日收款有额度限制,请联系场馆提升收款额度。"),
PAY_FAIL_8("金额必须大于0元"),
PAY_FAIL_9("金额必须小于10000000元"),
; ;
......
...@@ -410,6 +410,7 @@ public class MerchantConvert { ...@@ -410,6 +410,7 @@ public class MerchantConvert {
JsonUtil.convertList(merchant.getSubChannelAuths(), SubChannelAuthInfo.class)); JsonUtil.convertList(merchant.getSubChannelAuths(), SubChannelAuthInfo.class));
return StudioMerchantVO.builder() return StudioMerchantVO.builder()
.studioId(relation.getPartyId()) .studioId(relation.getPartyId())
.sourceStudioId(apply.getStudioId())
.channelNo(merchant.getChannelNo()) .channelNo(merchant.getChannelNo())
.merchantId(merchant.getId()) .merchantId(merchant.getId())
.merchantNo(merchant.getMerchantNo()) .merchantNo(merchant.getMerchantNo())
......
...@@ -80,6 +80,7 @@ import javax.annotation.PostConstruct; ...@@ -80,6 +80,7 @@ import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionTemplate; import org.springframework.transaction.support.TransactionTemplate;
...@@ -92,6 +93,8 @@ import org.springframework.transaction.support.TransactionTemplate; ...@@ -92,6 +93,8 @@ import org.springframework.transaction.support.TransactionTemplate;
@Service @Service
public class PayServiceImpl implements PayService { public class PayServiceImpl implements PayService {
private static final BigDecimal MAX_AMOUNT = new BigDecimal("10000000");
@Resource @Resource
private PayChannelProperties config; private PayChannelProperties config;
...@@ -183,14 +186,11 @@ public class PayServiceImpl implements PayService { ...@@ -183,14 +186,11 @@ public class PayServiceImpl implements PayService {
@Override @Override
public PayVO merchantPay(StudioMerchantPayParams params) { public PayVO merchantPay(StudioMerchantPayParams params) {
StudioVO studio = studioRpcService.getStudio(params.getStudioId());
PartyToMerchant relation = partyToMerchantRpService.getByStudioId(studio.getId(), config.getCashier());
if (null == relation) {
throw new BizException(FinanceErrorEnums.PAY_FAIL_1);
}
MerchantVO merchant = merchantRpcService.getByMerchantId(relation.getMerchantId()); Pair<PartyToMerchant, StudioVO> pair = this.checkBeforeMerchantPay(params);
StudioCashierRecord record = PayConvert.convertPayInit(params, studio, merchant);
MerchantVO merchant = merchantRpcService.getByMerchantId(pair.getLeft().getMerchantId());
StudioCashierRecord record = PayConvert.convertPayInit(params, pair.getRight(), merchant);
PayRequest request = PayConvert.convert(params, record); PayRequest request = PayConvert.convert(params, record);
record.setFeeRate(payRpcService.getFeeRate(request)); record.setFeeRate(payRpcService.getFeeRate(request));
record.setFee(FeeUtil.calPayFee(record.getFeeRate(), params.getTransAmount())); record.setFee(FeeUtil.calPayFee(record.getFeeRate(), params.getTransAmount()));
...@@ -205,10 +205,6 @@ public class PayServiceImpl implements PayService { ...@@ -205,10 +205,6 @@ public class PayServiceImpl implements PayService {
return vo; return vo;
} }
private FinanceErrorEnums replaceFailMessage(String failMsg) {
return PayFailMessageReplaceEnums.convertBySource(failMsg);
}
@Override @Override
public void payCallback(PayEvent event) { public void payCallback(PayEvent event) {
if (!event.getChannelNo().equals(config.getCashier())) { if (!event.getChannelNo().equals(config.getCashier())) {
...@@ -509,6 +505,25 @@ public class PayServiceImpl implements PayService { ...@@ -509,6 +505,25 @@ public class PayServiceImpl implements PayService {
return BrandCashierTransStateEnum.PAY_SUCCESS == state || BrandCashierTransStateEnum.PAY_IN == state; return BrandCashierTransStateEnum.PAY_SUCCESS == state || BrandCashierTransStateEnum.PAY_IN == state;
} }
private Pair<PartyToMerchant, StudioVO> checkBeforeMerchantPay(StudioMerchantPayParams params) {
if (params.getTransAmount().compareTo(BigDecimal.ZERO) <= 0) {
throw new BizException(FinanceErrorEnums.PAY_FAIL_8);
}
if (params.getTransAmount().compareTo(MAX_AMOUNT) > 0) {
throw new BizException(FinanceErrorEnums.PAY_FAIL_9);
}
StudioVO studio = studioRpcService.getStudio(params.getStudioId());
PartyToMerchant relation = partyToMerchantRpService.getByStudioId(studio.getId(), config.getCashier());
if (null == relation) {
throw new BizException(FinanceErrorEnums.PAY_FAIL_1);
}
return Pair.of(relation, studio);
}
private FinanceErrorEnums replaceFailMessage(String failMsg) {
return PayFailMessageReplaceEnums.convertBySource(failMsg);
}
@Data @Data
private static class AliInfo { private static class AliInfo {
......
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