|
|
|
@@ -31,6 +31,8 @@ import com.iformall.service.excel.WxCardDataExporter; |
|
|
|
import com.iformall.service.excel.WxCouponDataExporter; |
|
|
|
import com.iformall.service.excel.WxPressDataExporter; |
|
|
|
|
|
|
|
import com.iformall.service.pay.PayServiceFactory; |
|
|
|
import com.iformall.service.pay.service.share.PayShareAdapterService; |
|
|
|
import org.apache.commons.collections.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
@@ -136,6 +138,9 @@ public class WxCouponServiceImpl implements WxCouponService { |
|
|
|
@Autowired |
|
|
|
private MqBaseProducer mqBaseProducer; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
PayServiceFactory payServiceFactory; |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultData list(TenantEntity tenantEntity,WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { |
|
|
|
if (null == wxCoupon) wxCoupon = new WxCoupon(); |
|
|
|
@@ -643,6 +648,11 @@ public class WxCouponServiceImpl implements WxCouponService { |
|
|
|
if (platEnum != null) { |
|
|
|
plat = platEnum; |
|
|
|
} |
|
|
|
EnumPayWay payWay = EnumPayWay.PAY_WAY_WECHAT; |
|
|
|
if(EnumAppPlat.TOUTIAO.equals(plat)){ |
|
|
|
payWay = EnumPayWay.PAY_WAY_TT; |
|
|
|
} |
|
|
|
|
|
|
|
WxPayAccount payAccount = payAccountMapper.selectById(cAppInfo.getPayId()); |
|
|
|
if (payAccount == null) { |
|
|
|
return new ResultData(ErrorCode.APP_ID_NOT_FOUND); |
|
|
|
@@ -663,6 +673,8 @@ public class WxCouponServiceImpl implements WxCouponService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
PayShareAdapterService payShareServie = payServiceFactory.getPayShareAdapterService(payWay.getCode(),payAccount.getPayVersion()); |
|
|
|
|
|
|
|
if (EnumPayMchType.DIRECT.equals(payMchType)) { |
|
|
|
Long merchantId = null; |
|
|
|
if (merchantParamList.size() > 1) { |
|
|
|
@@ -687,34 +699,25 @@ public class WxCouponServiceImpl implements WxCouponService { |
|
|
|
record.setMerchantType(EnumCouponMerchantType.ONE_MERCHANT.getCode()); |
|
|
|
merchantId = merchantParamList.get(0).getLong("id"); |
|
|
|
} |
|
|
|
WxProfitSharingReceiver psReceiverQ = new WxProfitSharingReceiver(); |
|
|
|
psReceiverQ.updateTenantInfo(record); |
|
|
|
psReceiverQ.setMerchantId(merchantId); |
|
|
|
psReceiverQ.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); |
|
|
|
psReceiverQ.setPlat(plat.getCode()); |
|
|
|
WxProfitSharingReceiver one = wxProfitSharingReceiverMapper.findOne(psReceiverQ); |
|
|
|
if (one == null) { |
|
|
|
WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchantId, null, payMchTypeEnum.getCode()); |
|
|
|
|
|
|
|
if (receiver == null) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "对应门店至少进件一种支付模式"); |
|
|
|
} |
|
|
|
if (EnumAppPlat.TOUTIAO.equals(plat)) { |
|
|
|
if (!MerchantImportStatus.improt_success.getCode().equals(one.getWxImportStatus()) |
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(one.getAlipayImportStatus()) |
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(one.getHzImportStatus())) { |
|
|
|
if (!MerchantImportStatus.improt_success.getCode().equals(receiver.getWxImportStatus()) |
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(receiver.getAlipayImportStatus()) |
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(receiver.getHzImportStatus())) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "对应门店至少进件一种支付模式"); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (EnumPayShare.YES.equals(isShare)) { |
|
|
|
for (int i = 0, size = merchantParamList.size(); i < size; i++) { |
|
|
|
JSONObject jsonObject = merchantParamList.get(i); |
|
|
|
Long id = jsonObject.getLong("id"); |
|
|
|
WxProfitSharingReceiver psReceiverQ = new WxProfitSharingReceiver(); |
|
|
|
psReceiverQ.updateTenantInfo(record); |
|
|
|
psReceiverQ.setMerchantId(id); |
|
|
|
psReceiverQ.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); |
|
|
|
psReceiverQ.setPlat(plat.getCode()); |
|
|
|
WxProfitSharingReceiver one = wxProfitSharingReceiverMapper.findOne(psReceiverQ); |
|
|
|
Long merchantId = jsonObject.getLong("id"); |
|
|
|
WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchantId, null, payMchTypeEnum.getCode()); |
|
|
|
int n = i + 1; |
|
|
|
if (one == null) { |
|
|
|
if (receiver == null) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "第(" + n + ")个商户还未配置分账账户或未进件"); |
|
|
|
} |
|
|
|
if (EnumAppPlat.TOUTIAO.equals(plat)) { |
|
|
|
@@ -725,15 +728,15 @@ public class WxCouponServiceImpl implements WxCouponService { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "分账模式未设置开通支付渠道"); |
|
|
|
} |
|
|
|
if(EnumYesOrNo.YES.getCode().equals(openPayResult.getAlipay()) |
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(one.getAlipayImportStatus())){ |
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(receiver.getAlipayImportStatus())){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "第(" + n + ")个商户未进件支付宝"); |
|
|
|
} |
|
|
|
if(EnumYesOrNo.YES.getCode().equals(openPayResult.getWx()) |
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(one.getWxImportStatus())){ |
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(receiver.getWxImportStatus())){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "第(" + n + ")个商户未进件微信"); |
|
|
|
} |
|
|
|
if(EnumYesOrNo.YES.getCode().equals(openPayResult.getHz()) |
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(one.getHzImportStatus())){ |
|
|
|
&& !MerchantImportStatus.improt_success.getCode().equals(receiver.getHzImportStatus())){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "第(" + n + ")个商户未进件抖音"); |
|
|
|
} |
|
|
|
} |
|
|
|
|