diff --git a/mallinkAdmin/src/main/resources/db/migration/V2022080800001_wx_coupon.sql b/mallinkAdmin/src/main/resources/db/migration/V2022080800001_wx_coupon.sql new file mode 100644 index 000000000..acd91f72e --- /dev/null +++ b/mallinkAdmin/src/main/resources/db/migration/V2022080800001_wx_coupon.sql @@ -0,0 +1,200 @@ +ALTER TABLE `mallink`.`wx_coupon_0` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_1` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_2` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_3` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_4` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_5` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_6` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_7` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_8` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_9` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_10` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_11` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_12` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_13` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_14` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_15` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_16` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_17` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_18` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_19` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_20` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_21` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_22` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_23` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_24` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_25` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_26` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_27` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_28` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_29` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_30` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_31` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_32` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_33` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_34` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_35` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_36` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_37` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_38` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_39` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_40` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_41` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_42` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_43` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_44` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_45` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_46` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_47` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_48` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_49` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_50` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_51` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_52` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_53` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_54` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_55` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_56` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_57` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_58` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_59` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_60` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_61` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_62` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_63` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_64` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_65` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_66` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_67` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_68` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_69` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_70` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_71` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_72` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_73` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_74` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_75` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_76` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_77` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_78` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_79` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_80` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_81` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_82` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_83` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_84` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_85` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_86` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_87` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_88` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_89` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_90` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_91` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_92` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_93` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_94` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_95` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_96` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_97` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_98` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; +ALTER TABLE `mallink`.`wx_coupon_99` +ADD COLUMN `merchant_type` tinyint(1) AFTER `source_type`; diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponOrderController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponOrderController.java index 0ce279dff..e57b8ba8d 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponOrderController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponOrderController.java @@ -382,7 +382,7 @@ public class WxCouponOrderController extends BaseController { } if (couponOrder != null && couponOrder.getMerchantId() != null) { - wxCouponOrderService.sendInsideCouponVerifyMsg(couponOrder, couponOrderId, couponOrder.getMerchantId()); + wxCouponOrderService.sendInsideCouponVerifyMsg(couponOrder, couponOrderId, couponOrder.getMerchantId(),couponOrder.getBMerchantId()); } return new ResultData(couponOrder); diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponOrderController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponOrderController.java index 87cb07154..1c61f0132 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponOrderController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponOrderController.java @@ -516,7 +516,7 @@ public class WxCouponOrderController extends BaseController { } if (couponOrder != null && couponOrder.getMerchantId() != null) { - wxCouponOrderService.sendInsideCouponVerifyMsg(couponOrder, couponOrderId, couponOrder.getMerchantId()); + wxCouponOrderService.sendInsideCouponVerifyMsg(couponOrder, couponOrderId, couponOrder.getMerchantId(),couponOrder.getBMerchantId()); } return new ResultData(couponOrder); diff --git a/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java b/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java index 3eede770b..a8baa8ebd 100644 --- a/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java +++ b/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java @@ -2178,7 +2178,7 @@ public class PosServiceImpl implements PosService { logger.error("交易核销积分异常:" + e.getMessage()); } // 3. 核销后处理 - couponOrderService.sendInsideCouponVerifyMsg(merchantBUser, couponOrderId, merchantBUser.getMerchantId()); + couponOrderService.sendInsideCouponVerifyMsg(merchantBUser, couponOrderId, merchantBUser.getMerchantId(),merchantBUser.getMerchantId()); } return payOrder; } diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java index a4d39e6f8..8596c7939 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java @@ -133,7 +133,7 @@ public class CouponOrderExpiringSchedule { } if (couponOrder != null && couponOrder.getMerchantId() != null) { - wxCouponOrderService.sendInsideCouponVerifyMsg(couponOrder, couponOrder.getId(), couponOrder.getMerchantId()); + wxCouponOrderService.sendInsideCouponVerifyMsg(couponOrder, couponOrder.getId(), couponOrder.getMerchantId(),couponOrder.getBMerchantId()); } }); } diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantReciverSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantReciverSchedule.java index 8976cf1a0..be1d7bf80 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantReciverSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantReciverSchedule.java @@ -67,7 +67,9 @@ public class TtMerchantReciverSchedule { for (WxAppinfo wxAppinfo:wxAppinfoList) { appIdMap.put(wxAppinfo.getTenantId(),wxAppinfo.getAppId()); WxPayAccount wxPayAccount = payAccountService.getById(wxAppinfo.getPayId()); - payAccountKeyMap.put(wxAppinfo.getTenantId(),wxPayAccount.getApiKey()); + if(wxPayAccount != null){ + payAccountKeyMap.put(wxAppinfo.getTenantId(),wxPayAccount.getApiKey()); + } } for (WxMerchant m:merchants) { diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java index 220c2618d..5db7bac06 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java @@ -194,6 +194,9 @@ public class WxCoupon extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="1:A端发卷,2:B端发卷",name="sourceType") private Integer sourceType; + @io.swagger.annotations.ApiModelProperty(value="EnumCouponMerchantType",name="merchantType") + private Integer merchantType; + @TableField(exist = false) private String merchantParams; @TableField(exist = false) diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxPayOrder.java b/mallinkService/src/main/java/com/iformall/domain/po/WxPayOrder.java index 23b20094e..13a1ff01d 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxPayOrder.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxPayOrder.java @@ -78,13 +78,14 @@ public class WxPayOrder extends TenantEntity { public WxComposeChildOrderShare getChildOrderShare(Long wxOrderId) { if (StringUtils.isBlank(this.childOrderShare)) { - return new WxComposeChildOrderShare(this.payAmount, this.shareAmount, this.rateAmount,null,null,null); + return new WxComposeChildOrderShare(this.payAmount, this.shareAmount, this.rateAmount,null,null,null,null); } Map childs = JSON.parseObject(this.childOrderShare, Map.class); JSONObject childOrderShare = (JSONObject) childs.get(String.valueOf(wxOrderId)); if (null != childOrderShare) { return new WxComposeChildOrderShare(childOrderShare.getInteger("realPayMent"), childOrderShare.getInteger("shareAmount"), childOrderShare.getInteger("rateAmount"), - childOrderShare.getInteger("realRateAmount"), childOrderShare.getInteger("commissionAmount"), childOrderShare.getString("merchantUid")); + childOrderShare.getInteger("realRateAmount"), childOrderShare.getInteger("commissionAmount"), + childOrderShare.getLong("merchantId"),childOrderShare.getString("merchantUid")); } return null; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideCouponVerifyMsg.java b/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideCouponVerifyMsg.java index 7c49f08a1..ccb05c418 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideCouponVerifyMsg.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideCouponVerifyMsg.java @@ -12,6 +12,8 @@ public class FmInsideCouponVerifyMsg extends BaseMsg{ @io.swagger.annotations.ApiModelProperty(value = "券包ID", name = "couponOrderId") private Long couponOrderId; - @io.swagger.annotations.ApiModelProperty(value = "B端商户ID", name = "merchantId") + @io.swagger.annotations.ApiModelProperty(value = "分账商户", name = "merchantId") private Long merchantId; + @io.swagger.annotations.ApiModelProperty(value = "核销商户", name = "bmerchantId") + private Long bmerchantId; } diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumCouponMerchantType.java b/mallinkService/src/main/java/com/iformall/enums/EnumCouponMerchantType.java new file mode 100644 index 000000000..c25236ecc --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumCouponMerchantType.java @@ -0,0 +1,37 @@ +package com.iformall.enums; + +/** + * Created by Stormeye on 2018/08/09. + */ +public enum EnumCouponMerchantType { + + // + ONE_MERCHANT(1, "单商户"), + MULTIPLE_MERCHANT(2, "多商户") + ; + + public static EnumCouponMerchantType getEnum(Integer code) { + for (EnumCouponMerchantType value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumCouponMerchantType(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java index 4ff7931b9..c680ae053 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java @@ -84,5 +84,8 @@ public interface WxCouponChannelService { ResultData updateOnline(WxCouponChannel wxCouponChannel); - String getCouponOneMerchantUid(EnumPayWay payWay,Integer payVersion,Long couponChannelId, String tenantId); + Long getCouponOneMerchantId(EnumPayWay payWay,Long couponChannelId, String tenantId); + + String getCouponOneMerchantUid(EnumPayWay payWay,Long merchantId, String tenantId); + } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java index 5ee0ce87e..a096a1198 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java @@ -65,15 +65,16 @@ public interface WxCouponOrderService { /** * 核销后发送消息 */ - void sendInsideCouponVerifyMsg(TenantEntity tenantEntity, Long couponOrderId, Long merchantId); + void sendInsideCouponVerifyMsg(TenantEntity tenantEntity, Long couponOrderId, Long merchantId, Long bmerchantId); /** * 核销后处理 * * @param couponOrder - * @param + * @param merchant 分账商户 + * @param bmerchant 核销商户 */ - void actionAfterVerify(WxCouponOrder couponOrder, WxMerchant merchant); + void actionAfterVerify(WxCouponOrder couponOrder, WxMerchant merchant, WxMerchant bmerchant); /** * 核销发券 diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java index 4c56d347c..cd98d09ac 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java @@ -829,7 +829,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { } @Override - public String getCouponOneMerchantUid(EnumPayWay payWay,Integer payVersion,Long couponChannelId, String tenantId) { + public Long getCouponOneMerchantId(EnumPayWay payWay, Long couponChannelId, String tenantId) { WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantId); List merchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(couponChannel.getCouponId(), tenantId); Long merchantId = null; @@ -846,11 +846,16 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { merchantId = list.get(0); } } + return merchantId; + } + + @Override + public String getCouponOneMerchantUid(EnumPayWay payWay,Long merchantId, String tenantId) { if(merchantId != null){ WxProfitSharingReceiver psReceiverQ = new WxProfitSharingReceiver(); psReceiverQ.setTenantId(tenantId); - psReceiverQ.setMerchantId(merchantIds.get(0)); - psReceiverQ.setSharingType(payServiceFactory.getPayShareAdapterService(payWay.getCode(),payVersion).getProfitSharingType()); + psReceiverQ.setMerchantId(merchantId); +// psReceiverQ.setSharingType(payServiceFactory.getPayShareAdapterService(payWay.getCode()).getProfitSharingType()); psReceiverQ.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); psReceiverQ.setPlat(payWay.getPlat().getCode()); List psReceiverList = wxProfitSharingReceiverMapper.findList(psReceiverQ); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java index 0cc816ca0..b6b1dc920 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java @@ -504,7 +504,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { WxMerchant merchant = merchantSimpleMap.get(bvo.getBMerchantId()); if (null != merchant) { bvo.setbMerchantName(merchant.getName()); -// bvo.setVerifyMerchantName(merchant.getName()); + bvo.setVerifyMerchantName(merchant.getName()); } } if (null != bvo.getCUserId()) { @@ -1274,7 +1274,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { if(EnumCouponVerifyType.VERIFY_B.equals(couponVerifyType) && !verifyMerchant(bUser,cm.getMerchantId())){ throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERCHANT_IS_NULL); } - merchantId = bUser.getMerchantId(); + merchantId = cm.getMerchantId(); }else if(EnumCouponType.COUPON_GIFT.getCode().equals(wxCoupon.getType())){ if (StringUtils.isBlank(wxCoupon.getGiftList())){ logger.error("券包: coupon-" + wxCoupon.getId() + "数据异常" + "couponOrder-" + couponOrder.getId()); @@ -1309,8 +1309,9 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { && EnumPayShare.YES.getCode().equals(wxPayOrder.getShare())){ payServiceFactory.getPayShareAdapterService(wxPayOrder.getPayVendor(),couponOrder.getPayVersion()) .getReceiverList(couponOrder, merchantId, wxPayOrder.getTtPayWay()); + }else if(wxPayOrder != null && EnumPayMchType.DIRECT.getCode().equals(wxPayOrder.getMchType())){ + merchantId = wxPayOrder.getChildOrderShare(couponOrder.getOrderId()).getMerchantId(); } - } int num = 0; @@ -1444,7 +1445,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { } if (couponOrder != null && couponOrder.getMerchantId() != null) { - this.sendInsideCouponVerifyMsg(couponOrder, couponOrderId, couponOrder.getMerchantId()); + this.sendInsideCouponVerifyMsg(couponOrder, couponOrderId, couponOrder.getMerchantId(),couponOrder.getBMerchantId()); } return couponOrder; @@ -1567,17 +1568,21 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { } @Override - public void sendInsideCouponVerifyMsg(TenantEntity tenantEntity, Long couponOrderId, Long merchantId) { + public void sendInsideCouponVerifyMsg(TenantEntity tenantEntity, Long couponOrderId, Long merchantId, Long bmerchantId) { + if(bmerchantId == null || bmerchantId.longValue() == 0l){ + bmerchantId = merchantId; + } FmInsideCouponVerifyMsg verifyMsg = new FmInsideCouponVerifyMsg(); verifyMsg.setMsgType(EnumMsgRecordType.INSIDE_COUPON_VERIFY.getCode()); verifyMsg.updateTenantInfo(tenantEntity); verifyMsg.setCouponOrderId(couponOrderId); verifyMsg.setMerchantId(merchantId); + verifyMsg.setBmerchantId(bmerchantId); mqBaseProducer.sendMessage(verifyMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); } @Override - public void actionAfterVerify(WxCouponOrder couponOrder, WxMerchant merchant) { + public void actionAfterVerify(WxCouponOrder couponOrder, WxMerchant merchant, WxMerchant bmerchant) { try { boolean mulityShare = true; @@ -1600,7 +1605,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { try { // 核销补贴 - subsidyAfterVerify(couponOrder, merchant.getId()); + subsidyAfterVerify(couponOrder, bmerchant.getId()); } catch (Exception e) { logger.error("核销记账失败"+e.getMessage(),e); } @@ -1614,7 +1619,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { } // 核销发模板消息 try { - sendVerifyMsg(couponOrder, merchant, bSentCoupon); + sendVerifyMsg(couponOrder, bmerchant, bSentCoupon); } catch (Exception e) { logger.error("核销发送消息发生错误:" + e.getMessage(),e); } 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 6768d11a9..c449ce6c9 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -682,8 +682,10 @@ public class WxCouponServiceImpl implements WxCouponService { }else if(list.size() > 1){ return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "直连模式多门店券只能包含一个商管商户"); } + record.setMerchantType(EnumCouponMerchantType.MULTIPLE_MERCHANT.getCode()); merchantId = list.get(0); }else{ + record.setMerchantType(EnumCouponMerchantType.ONE_MERCHANT.getCode()); merchantId = merchantParamList.get(0).getLong("id"); } WxProfitSharingReceiver psReceiverQ = new WxProfitSharingReceiver(); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java index 78d4cf36a..4aa40bf6b 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java @@ -452,9 +452,11 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { int rate_amount = 0; //todo 注意购物车模式(需测试)每笔子订单算法可能与总订单算法有差 for (WxOrder o : orderList) { + Long merchant_id = null; String merchant_uid = ""; if(EnumPayMchType.DIRECT.equals(payMchType)){//直连模式记录收款商户 - merchant_uid = wxCouponChannelService.getCouponOneMerchantUid(payWay,payAccount.getPayVersion(),o.getCouponChannelId(),o.getTenantId()); + merchant_id = wxCouponChannelService.getCouponOneMerchantId(payWay,o.getCouponChannelId(),o.getTenantId()); + merchant_uid = wxCouponChannelService.getCouponOneMerchantUid(payWay,merchant_id,o.getTenantId()); if(StringUtils.isBlank(merchant_uid)){ throw new MallinkException(ErrorCode.PAY_ORDER_MERCHANT_UID_ERROR); } @@ -465,7 +467,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { logger.info("佣金明细"+ JSON.toJSONString(oShareAmount)); share_amount += oShareAmount.getShareAmount(); rate_amount += oShareAmount.getRateAmount(); - childShares.put(String.valueOf(o.getId()), new WxComposeChildOrderShare(oShareAmount,merchant_uid)); + childShares.put(String.valueOf(o.getId()), new WxComposeChildOrderShare(oShareAmount,merchant_id,merchant_uid)); } record.setShareAmount(share_amount); record.setRateAmount(rate_amount); @@ -1136,7 +1138,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { logger.error(e.getMessage()); } // 更新后处理 - wxCouponOrderService.sendInsideCouponVerifyMsg(unPayOrder, unPayOrder.getPosPayOrderId(), user.getMerchantId()); + wxCouponOrderService.sendInsideCouponVerifyMsg(unPayOrder, unPayOrder.getPosPayOrderId(), user.getMerchantId(),user.getMerchantId()); } } } catch (Exception e) { @@ -1258,7 +1260,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { logger.error(e.getMessage()); } // 更新后处理 - wxCouponOrderService.sendInsideCouponVerifyMsg(unPayOrder, unPayOrder.getPosPayOrderId(), user.getMerchantId()); + wxCouponOrderService.sendInsideCouponVerifyMsg(unPayOrder, unPayOrder.getPosPayOrderId(), user.getMerchantId(),user.getMerchantId()); } } } catch (Exception e) { diff --git a/mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideCouponVerifyMsgServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideCouponVerifyMsgServiceImpl.java index 8427d040e..10ab3bfca 100644 --- a/mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideCouponVerifyMsgServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideCouponVerifyMsgServiceImpl.java @@ -48,9 +48,16 @@ public class FmInsideCouponVerifyMsgServiceImpl implements MsgSendService { logger.error("门店未找到: " + msg.getMerchantId()); throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "门店未找到" + msg.getMerchantId()); } + WxMerchant bmerchant = null; + if(msg.getBmerchantId() != null && msg.getBmerchantId().longValue() > 0l + && !msg.getBmerchantId().equals(msg.getMerchantId())){ + bmerchant = merchantService.selectById(msg.getBmerchantId()); + }else{ + bmerchant = merchant; + } orderService.sendInsideOrderPushDeliveryMsg(couponOrder,null,couponOrder.getId()); // orderService.sendInsideOrderPushMsg(couponOrder,couponOrder.getComposeOrderId()); - couponOrderService.actionAfterVerify(couponOrder, merchant); + couponOrderService.actionAfterVerify(couponOrder, merchant, bmerchant); } } diff --git a/mallinkService/src/main/java/com/iformall/service/order/entity/WxComposeChildOrderShare.java b/mallinkService/src/main/java/com/iformall/service/order/entity/WxComposeChildOrderShare.java index 2d962c2aa..bd64577e7 100644 --- a/mallinkService/src/main/java/com/iformall/service/order/entity/WxComposeChildOrderShare.java +++ b/mallinkService/src/main/java/com/iformall/service/order/entity/WxComposeChildOrderShare.java @@ -11,21 +11,24 @@ import lombok.Data; @Data public class WxComposeChildOrderShare { - public WxComposeChildOrderShare(Integer realPayMent,Integer shareAmount,Integer rateAmount,Integer realRateAmount,Integer commissionAmount,String merchantUid) { + public WxComposeChildOrderShare(Integer realPayMent,Integer shareAmount,Integer rateAmount,Integer realRateAmount,Integer commissionAmount, + Long merchantId,String merchantUid) { this.realPayMent = realPayMent; this.shareAmount = shareAmount; this.rateAmount = rateAmount; this.realRateAmount = realRateAmount; this.commissionAmount = commissionAmount; + this.merchantId = merchantId; this.merchantUid = merchantUid; } - public WxComposeChildOrderShare(PayShareCalculateAmount shareCalculateAmount,String merchantUid) { + public WxComposeChildOrderShare(PayShareCalculateAmount shareCalculateAmount,Long merchantId,String merchantUid) { this.realPayMent = shareCalculateAmount.getPayAmount(); this.shareAmount = shareCalculateAmount.getShareAmount(); this.rateAmount = shareCalculateAmount.getRateAmount(); this.realRateAmount = shareCalculateAmount.getRealRateAmount(); this.commissionAmount = shareCalculateAmount.getCommissionAmount(); + this.merchantId = merchantId; this.merchantUid = merchantUid; } @@ -38,5 +41,6 @@ public class WxComposeChildOrderShare { private Integer realRateAmount;//平台手续费 private Integer commissionAmount;//平台佣金 + private Long merchantId;//收款商户 private String merchantUid;//收款商户 } diff --git a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml index b44eeecd3..becbd510d 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml @@ -55,6 +55,7 @@ + @@ -107,6 +108,7 @@ + @@ -115,7 +117,7 @@ c.`valid_type`,c.`valid_start_date`,c.`valid_end_date`,c.pick_start_date,c.pick_end_date,c.`valid_days`,c.`detail`,c.`price`,c.tail_price,c.orig_price,c.`unit`,c.`remain_inventory`,c.`inventory`, c.`remark`,c.`status`,c.`create_date`,c.`update_date`,c.`business`,c.`sub_business`,c.`support_transfer`,c.`subsidy_num`,c.`subsidy_type`, c.`press_limit_num`, c.`press_limit_hours`, c.`auto_refund`,c.`credit_price`,c.`credit_refund`,c.`put_apply_status`,c.`stock_apply_status`,c.`cancle_apply_status`, - c.`conditions`,c.approval_type,c.content_type,c.source_type,c.password_support,c.gift_list,c.product_type,c.category_id + c.`conditions`,c.approval_type,c.content_type,c.source_type,c.merchant_type,c.password_support,c.gift_list,c.product_type,c.category_id @@ -294,6 +296,10 @@ and `source_type` = #{sourceType} + + and `merchant_type` = #{merchantType} + + and JSON_CONTAINS(gift_list,json_array(#{giftList})) @@ -353,7 +359,7 @@ select c.id,c.type,c.cover_img,c.title,c.sub_title,c.item_group,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.detail,c.remark,c.valid_type,c.valid_start_date, - c.valid_end_date,c.pick_start_date,c.pick_end_date,c.auto_refund,c.business,c.subsidy_type,c.source_type,c.content_type,c.gift_list,c.support_transfer,c.subsidy_num + c.valid_end_date,c.pick_start_date,c.pick_end_date,c.auto_refund,c.business,c.subsidy_type,c.source_type,c.merchant_type,c.content_type,c.gift_list,c.support_transfer,c.subsidy_num from wx_coupon c where c.id = #{id} and c.`tenant_id` = #{tenantId} @@ -388,7 +394,7 @@ @@ -634,6 +640,10 @@ and c.`source_type` = #{sourceType} + + and c.`merchant_type` = #{merchantType} + + and cm.`merchant_id` = #{merchantId} @@ -730,6 +740,7 @@ + @@ -781,6 +792,7 @@ +