Browse Source

fix bug

release_toaliyun_real
zhengfangyuan 3 years ago
parent
commit
11c2484879
4 changed files with 141 additions and 36 deletions
  1. +14
    -1
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java
  2. +3
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java
  3. +2
    -0
      mallinkService/src/main/java/com/iformall/service/WxCouponService.java
  4. +122
    -35
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java

+ 14
- 1
mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java View File

@@ -571,7 +571,7 @@ public class WxCouponController extends BaseController {
return new ResultData(wxCouponMallService.list(wxCouponMall)); return new ResultData(wxCouponMallService.list(wxCouponMall));
} }
@ApiOperation("商场查询:平台券列表")
@ApiOperation("商场查询:平台券商场列表")
@GetMapping("/couponMalls") @GetMapping("/couponMalls")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "ids", value = "ids[]", dataType = "Long", paramType = "query", required = true)}) @ApiImplicitParam(name = "ids", value = "ids[]", dataType = "Long", paramType = "query", required = true)})
@@ -612,5 +612,18 @@ public class WxCouponController extends BaseController {
} }
return new ResultData(); return new ResultData();
} }
@ApiOperation("券商户是否自动分账")
@PostMapping("/couponMerchantAutoShare")
public ResultData couponMerchantAutoShare(@RequestBody WxCoupon wxCoupon) {
wxCoupon.updateTenantInfo(getTenantInfo());
try {
Map<Long, Boolean> map = wxCouponService.couponMerchantAutoShare(wxCoupon);
return new ResultData(map);
} catch (Exception e) {
return new ResultData(Result.ERROR,e.getMessage());
}
}


} }

+ 3
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java View File

@@ -388,6 +388,9 @@ public class WxCoupon extends TenantEntity {


@io.swagger.annotations.ApiModelProperty(value = "是否删除1是0否", name = "isDel") @io.swagger.annotations.ApiModelProperty(value = "是否删除1是0否", name = "isDel")
private Integer isDel; private Integer isDel;
@TableField(exist = false)
private Long[] merchantIds;


public String getSalePriceStr() { public String getSalePriceStr() {
if(salePrice!=null) { if(salePrice!=null) {


+ 2
- 0
mallinkService/src/main/java/com/iformall/service/WxCouponService.java View File

@@ -289,4 +289,6 @@ public interface WxCouponService {
ResultData disable(TenantEntity tenantInfo, Long couponId); ResultData disable(TenantEntity tenantInfo, Long couponId);
void setCouponMerchants(WxCoupon wxCoupon) throws Exception; void setCouponMerchants(WxCoupon wxCoupon) throws Exception;
Map<Long,Boolean> couponMerchantAutoShare(WxCoupon wxCoupon) throws Exception;
} }

+ 122
- 35
mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java View File

@@ -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);
}
}
}


} }

Loading…
Cancel
Save