From e3f05f60964b6f269f7659eef2f59bb662e72ad1 Mon Sep 17 00:00:00 2001 From: xhxu Date: Tue, 30 Aug 2022 11:11:46 +0800 Subject: [PATCH] // test --- .../schedule/CouponExpiringSchedule.java | 5 ++- .../com/iformall/mapper/WxScreenAdMapper.java | 3 +- .../service/impl/WxCouponServiceImpl.java | 45 ++++++++++--------- .../share/douyin/TtPayShareService.java | 25 ++++++----- 4 files changed, 44 insertions(+), 34 deletions(-) diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java index 2dc3622d7..3bc5d4666 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java @@ -151,7 +151,10 @@ public class CouponExpiringSchedule { @Scheduled(cron = "0 15 0 * * ?") // 每天凌晨00:15 下架券广告 //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 public void screenAdExpiringSchedule() { - wxScreenAdMapper.offScreeAdByCouponChannelStatus(); + List malls = getMalls(); + for (WxMall mall : malls) { + wxScreenAdMapper.offScreeAdByCouponChannelStatus(mall); + } } @Async diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxScreenAdMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxScreenAdMapper.java index 12ddab640..4f40dad8f 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxScreenAdMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxScreenAdMapper.java @@ -2,6 +2,7 @@ package com.iformall.mapper; import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxScreenAd; +import com.iformall.domain.po.base.TenantEntity; import java.util.List; @@ -10,7 +11,7 @@ public interface WxScreenAdMapper extends CommonMapper { List findList(WxScreenAd wxScreenAd); - void offScreeAdByCouponChannelStatus(); + void offScreeAdByCouponChannelStatus(TenantEntity tenantEntity); void updateStatusByCouponChannelId(WxScreenAd wxScreenAd); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java index f573ce5dc..323481746 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -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 + ")个商户未进件抖音"); } } diff --git a/mallinkService/src/main/java/com/iformall/service/pay/service/share/douyin/TtPayShareService.java b/mallinkService/src/main/java/com/iformall/service/pay/service/share/douyin/TtPayShareService.java index f0cf100bd..c2d683d8d 100644 --- a/mallinkService/src/main/java/com/iformall/service/pay/service/share/douyin/TtPayShareService.java +++ b/mallinkService/src/main/java/com/iformall/service/pay/service/share/douyin/TtPayShareService.java @@ -408,18 +408,21 @@ public class TtPayShareService extends PayShareBaseAdapterService{ psReceiverQ.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); psReceiverQ.setPlat(EnumAppPlat.TOUTIAO.getCode()); String payMsg = ""; - if(EnumTtPayChannel.WX_PAY.getCode().equals(ttPayWay)){ - payMsg = EnumTtPayChannel.WX_PAY.getMessage(); - psReceiverQ.setWxImportStatus(MerchantImportStatus.improt_success.getCode()); - }else if(EnumTtPayChannel.ALI_PAY.getCode().equals(ttPayWay)){ - payMsg = EnumTtPayChannel.ALI_PAY.getMessage(); - psReceiverQ.setAlipayImportStatus(MerchantImportStatus.improt_success.getCode()); - }else if(EnumTtPayChannel.HZ_PAY.getCode().equals(ttPayWay)){ - payMsg = EnumTtPayChannel.HZ_PAY.getMessage(); - psReceiverQ.setHzImportStatus(MerchantImportStatus.improt_success.getCode()); - }else{ - log.error("该订单支付方式异常{}"); + if(ttPayWay != null){ + if(EnumTtPayChannel.WX_PAY.getCode().equals(ttPayWay)){ + payMsg = EnumTtPayChannel.WX_PAY.getMessage(); + psReceiverQ.setWxImportStatus(MerchantImportStatus.improt_success.getCode()); + }else if(EnumTtPayChannel.ALI_PAY.getCode().equals(ttPayWay)){ + payMsg = EnumTtPayChannel.ALI_PAY.getMessage(); + psReceiverQ.setAlipayImportStatus(MerchantImportStatus.improt_success.getCode()); + }else if(EnumTtPayChannel.HZ_PAY.getCode().equals(ttPayWay)){ + payMsg = EnumTtPayChannel.HZ_PAY.getMessage(); + psReceiverQ.setHzImportStatus(MerchantImportStatus.improt_success.getCode()); + }else{ + log.error("该订单支付方式异常{}"); + } } + List list = wxProfitSharingReceiverMapper.findList(psReceiverQ); if(list == null || list.isEmpty()){ throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该商户未未进件."+payMsg);