|
|
@@ -706,46 +706,29 @@ public class WxCouponServiceImpl implements WxCouponService { |
|
|
if (receiver == null) { |
|
|
if (receiver == null) { |
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "[\""+makeMerchant.getName()+"\"]未配置收款账户"); |
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "[\""+makeMerchant.getName()+"\"]未配置收款账户"); |
|
|
} |
|
|
} |
|
|
|
|
|
//如果是直连,抖音,多商户券必须只配置支付宝 |
|
|
if (EnumAppPlat.TOUTIAO.equals(plat)) { |
|
|
if (EnumAppPlat.TOUTIAO.equals(plat)) { |
|
|
if (!MerchantImportStatus.improt_success.getCode().equals(receiver.getWxImportStatus()) |
|
|
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(receiver.getAlipayImportStatus()) |
|
|
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(receiver.getHzImportStatus())) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "[\""+makeMerchant.getName()+"\"]未配置收款账户"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (merchantList.size() > 1 ) { |
|
|
|
|
|
if (MerchantImportStatus.improt_success.getCode().equals(receiver.getAlipayImportStatus()) && |
|
|
|
|
|
!MerchantImportStatus.improt_success.getCode().equals(receiver.getWxImportStatus()) ) { |
|
|
|
|
|
}else { |
|
|
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "[\""+makeMerchant.getName()+"\"]配置收款账户错误,多商户券主收款账户不能配置微信."); |
|
|
|
|
|
} |
|
|
|
|
|
}else { |
|
|
|
|
|
if (!MerchantImportStatus.improt_success.getCode().equals(receiver.getWxImportStatus()) |
|
|
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(receiver.getAlipayImportStatus()) |
|
|
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(receiver.getHzImportStatus())) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "[\""+makeMerchant.getName()+"\"]未配置收款账户"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} else if (EnumPayShare.YES.equals(isShare)) { |
|
|
} else if (EnumPayShare.YES.equals(isShare)) { |
|
|
List<String> badNames = new ArrayList(); |
|
|
List<String> badNames = new ArrayList(); |
|
|
for (WxMerchant merchant:merchantList) { |
|
|
for (WxMerchant merchant:merchantList) { |
|
|
WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant.getId(), null, payMchType.getCode()); |
|
|
|
|
|
|
|
|
|
|
|
if (receiver == null) { |
|
|
|
|
|
badNames.add(merchant.getName()); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
if (EnumAppPlat.TOUTIAO.equals(plat)) { |
|
|
|
|
|
QueryMerchantResult openPayResult = payAccount.getOpenPayResult(); |
|
|
|
|
|
|
|
|
|
|
|
if(!EnumYesOrNo.YES.getCode().equals(openPayResult.getAlipay()) |
|
|
|
|
|
&& !EnumYesOrNo.YES.getCode().equals(openPayResult.getWx()) |
|
|
|
|
|
&& !EnumYesOrNo.YES.getCode().equals(openPayResult.getHz())){ |
|
|
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "分账模式未设置开通支付渠道"); |
|
|
|
|
|
} |
|
|
|
|
|
if(EnumYesOrNo.YES.getCode().equals(openPayResult.getAlipay()) |
|
|
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(receiver.getAlipayImportStatus())){ |
|
|
|
|
|
badNames.add(merchant.getName()); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
if(EnumYesOrNo.YES.getCode().equals(openPayResult.getWx()) |
|
|
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(receiver.getWxImportStatus())){ |
|
|
|
|
|
badNames.add(merchant.getName()); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
if(EnumYesOrNo.YES.getCode().equals(openPayResult.getHz()) |
|
|
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(receiver.getHzImportStatus())){ |
|
|
|
|
|
badNames.add(merchant.getName()); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
boolean isBad = toTalPayMchTypeMerchantIsBad(payShareServie,payAccount,merchant.getName(),merchant.getId(),payMchType,plat); |
|
|
|
|
|
if (isBad) { |
|
|
|
|
|
badNames.add(merchant.getName()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
if(!badNames.isEmpty()){ |
|
|
if(!badNames.isEmpty()){ |
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), JSONArray.toJSONString(badNames)+"未配置分账账户"); |
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), JSONArray.toJSONString(badNames)+"未配置分账账户"); |
|
|
@@ -754,6 +737,37 @@ public class WxCouponServiceImpl implements WxCouponService { |
|
|
} |
|
|
} |
|
|
return merchantList; |
|
|
return merchantList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//总分模式下不能分账的商户 |
|
|
|
|
|
private boolean toTalPayMchTypeMerchantIsBad(PayShareAdapterService payShareServie,WxPayAccount payAccount, |
|
|
|
|
|
String merchantName,Long merchantId,EnumPayMchType payMchType,EnumAppPlat plat) throws Exception { |
|
|
|
|
|
WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchantId, null, payMchType.getCode()); |
|
|
|
|
|
if (receiver == null) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
if (EnumAppPlat.TOUTIAO.equals(plat)) { |
|
|
|
|
|
QueryMerchantResult openPayResult = payAccount.getOpenPayResult(); |
|
|
|
|
|
|
|
|
|
|
|
if(!EnumYesOrNo.YES.getCode().equals(openPayResult.getAlipay()) |
|
|
|
|
|
&& !EnumYesOrNo.YES.getCode().equals(openPayResult.getWx()) |
|
|
|
|
|
&& !EnumYesOrNo.YES.getCode().equals(openPayResult.getHz())){ |
|
|
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "分账模式未设置开通支付渠道"); |
|
|
|
|
|
} |
|
|
|
|
|
if(EnumYesOrNo.YES.getCode().equals(openPayResult.getAlipay()) |
|
|
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(receiver.getAlipayImportStatus())){ |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
if(EnumYesOrNo.YES.getCode().equals(openPayResult.getWx()) |
|
|
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(receiver.getWxImportStatus())){ |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
if(EnumYesOrNo.YES.getCode().equals(openPayResult.getHz()) |
|
|
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(receiver.getHzImportStatus())){ |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public ResultData updateTtProduct(WxCoupon record) { |
|
|
public ResultData updateTtProduct(WxCoupon record) { |
|
|
@@ -1416,6 +1430,79 @@ public class WxCouponServiceImpl implements WxCouponService { |
|
|
throw e; |
|
|
throw e; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Map<Long, Boolean> generateMerchantAutoShareAll(Long[] merchantIds,boolean auto) { |
|
|
|
|
|
Map<Long,Boolean> merchantAutoShareMap = new HashMap<Long,Boolean>(); |
|
|
|
|
|
for (Long mid:merchantIds) { |
|
|
|
|
|
merchantAutoShareMap.put(mid, auto); |
|
|
|
|
|
} |
|
|
|
|
|
return merchantAutoShareMap; |
|
|
|
|
|
} |
|
|
|
|
|
@Override |
|
|
|
|
|
public Map<Long, Boolean> couponMerchantAutoShare(WxCoupon wxCoupon) throws Exception { |
|
|
|
|
|
if (null == wxCoupon.getMerchantIds() || null == wxCoupon.getId() || null == wxCoupon.getType() || null == wxCoupon.getMerchantType()) { |
|
|
|
|
|
throw new MallinkException(Result.ERROR,"缺少参数"); |
|
|
|
|
|
} |
|
|
|
|
|
EnumAppPlat plat = EnumCouponType.getAppPlat(wxCoupon.getType()); |
|
|
|
|
|
EnumPayWay payWay = EnumAppPlat.getPayWay(plat); |
|
|
|
|
|
WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(wxCoupon,plat); |
|
|
|
|
|
if (cAppInfo == null) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); |
|
|
|
|
|
} |
|
|
|
|
|
WxPayAccount payAccount = payAccountMapper.selectById(cAppInfo.getPayId()); |
|
|
|
|
|
if (payAccount == null) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); |
|
|
|
|
|
} |
|
|
|
|
|
EnumPayMchType payMchType = EnumPayMchType.getEnum(payAccount.getMchType()); |
|
|
|
|
|
EnumPayShare isShare = EnumPayShare.getEnum(payAccount.getShare()); |
|
|
|
|
|
PayShareAdapterService payShareServie = payServiceFactory.getPayShareAdapterService(payWay.getCode(),payAccount.getPayVersion()); |
|
|
|
|
|
//直连模式,如果是单商户券,则都可以;如果是多商户券,抖音则只要开通了支付宝就可以,微信则不行。 |
|
|
|
|
|
if (payMchType == EnumPayMchType.DIRECT) { |
|
|
|
|
|
if (EnumCouponMerchantType.ONE_MERCHANT.getCode() == wxCoupon.getMerchantType()) { |
|
|
|
|
|
return generateMerchantAutoShareAll(wxCoupon.getMerchantIds(),true); |
|
|
|
|
|
}else { |
|
|
|
|
|
if (plat == EnumAppPlat.TOUTIAO) { |
|
|
|
|
|
Map<Long,Boolean> merchantAutoShareMap = new HashMap<Long,Boolean>(); |
|
|
|
|
|
for (Long mid:wxCoupon.getMerchantIds()) { |
|
|
|
|
|
//开通了支付宝就可以 |
|
|
|
|
|
WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, mid, null, payMchType.getCode()); |
|
|
|
|
|
if (MerchantImportStatus.improt_success.getCode().equals(receiver.getAlipayImportStatus())) { |
|
|
|
|
|
merchantAutoShareMap.put(mid, true); |
|
|
|
|
|
}else { |
|
|
|
|
|
merchantAutoShareMap.put(mid, false); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return merchantAutoShareMap; |
|
|
|
|
|
}else if (plat == EnumAppPlat.WX){ |
|
|
|
|
|
return generateMerchantAutoShareAll(wxCoupon.getMerchantIds(),false); |
|
|
|
|
|
}else { |
|
|
|
|
|
return generateMerchantAutoShareAll(wxCoupon.getMerchantIds(),false); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}else { |
|
|
|
|
|
//总分模式,分账开启,微信平台则认为是100%分账,抖音则只要开通了支付宝就可以。 |
|
|
|
|
|
if (isShare == EnumPayShare.YES) { |
|
|
|
|
|
if (plat == EnumAppPlat.WX) { |
|
|
|
|
|
return generateMerchantAutoShareAll(wxCoupon.getMerchantIds(),true); |
|
|
|
|
|
}else if (plat == EnumAppPlat.TOUTIAO) { |
|
|
|
|
|
Map<Long,Boolean> merchantAutoShareMap = new HashMap<Long,Boolean>(); |
|
|
|
|
|
for (Long mid:wxCoupon.getMerchantIds()) { |
|
|
|
|
|
boolean isBad = toTalPayMchTypeMerchantIsBad(payShareServie,payAccount,String.valueOf(mid),mid,payMchType,plat); |
|
|
|
|
|
if (isBad) { |
|
|
|
|
|
merchantAutoShareMap.put(mid, false); |
|
|
|
|
|
}else { |
|
|
|
|
|
merchantAutoShareMap.put(mid, true); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return merchantAutoShareMap; |
|
|
|
|
|
}else { |
|
|
|
|
|
return generateMerchantAutoShareAll(wxCoupon.getMerchantIds(),true); |
|
|
|
|
|
} |
|
|
|
|
|
}else { |
|
|
|
|
|
return generateMerchantAutoShareAll(wxCoupon.getMerchantIds(),false); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |