diff --git a/cash-api/order-server/src/main/java/com/czg/controller/NotifyController.java b/cash-api/order-server/src/main/java/com/czg/controller/NotifyController.java index 2c8100c2c..466a1ad43 100644 --- a/cash-api/order-server/src/main/java/com/czg/controller/NotifyController.java +++ b/cash-api/order-server/src/main/java/com/czg/controller/NotifyController.java @@ -8,6 +8,7 @@ import com.alibaba.fastjson2.JSONObject; import com.czg.CzgPayUtils; import com.czg.entity.CzgBaseRespParams; import com.czg.market.service.MkDistributionConfigService; +import com.czg.market.service.MkDistributionUserService; import com.czg.mq.PrintMqListener; import com.czg.order.entity.OrderPayment; import com.czg.order.service.OrderInfoService; @@ -51,7 +52,7 @@ public class NotifyController { @Resource private WxService wxService; @Resource - private MkDistributionConfigService distributionConfigService; + private MkDistributionUserService distributionUserService; @Resource private OrderPaymentService paymentService; @@ -98,7 +99,7 @@ public class NotifyController { payment.setPayTime(DateUtil.date().toLocalDateTime()); payment.setRespJson(plainTextJson.toJSONString()); paymentService.updateById(payment); - distributionConfigService.rechargeCallBack(payment.getSourceId(), payment.getShopId(), payment.getAmount(), payment.getId()); + distributionUserService.rechargeCallBack(payment.getSourceId(), payment.getShopId(), payment.getAmount(), payment.getId()); } return "SUCCESS"; diff --git a/cash-common/cash-common-service/src/main/java/com/czg/market/service/MkDistributionConfigService.java b/cash-common/cash-common-service/src/main/java/com/czg/market/service/MkDistributionConfigService.java index b96677916..29018d4fe 100644 --- a/cash-common/cash-common-service/src/main/java/com/czg/market/service/MkDistributionConfigService.java +++ b/cash-common/cash-common-service/src/main/java/com/czg/market/service/MkDistributionConfigService.java @@ -19,18 +19,4 @@ public interface MkDistributionConfigService extends IService pay(long userId, MkDistributionPayDTO payDTO); - - Boolean cashPayOrder(long adminId, MkDistributionPayDTO payParam); - - /** - * 分销员开通 - * @param userId 用户 - * @param amount 金额 - * @param shopId 店铺id - */ - void open(Long userId, BigDecimal amount, Long shopId, Long sourceId); - - void rechargeCallBack(Long userId, Long shopId, BigDecimal amount, Long paymentId); } diff --git a/cash-common/cash-common-service/src/main/java/com/czg/market/service/MkDistributionUserService.java b/cash-common/cash-common-service/src/main/java/com/czg/market/service/MkDistributionUserService.java index afd7769ae..8d6a9ba32 100644 --- a/cash-common/cash-common-service/src/main/java/com/czg/market/service/MkDistributionUserService.java +++ b/cash-common/cash-common-service/src/main/java/com/czg/market/service/MkDistributionUserService.java @@ -54,4 +54,6 @@ public interface MkDistributionUserService extends IService */ void open(Long userId, BigDecimal amount, Long shopId, Long sourceId); + void rechargeCallBack(Long userId, Long shopId, BigDecimal amount, Long paymentId); + } diff --git a/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkDistributionConfigServiceImpl.java b/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkDistributionConfigServiceImpl.java index 4636464d2..21ac2b147 100644 --- a/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkDistributionConfigServiceImpl.java +++ b/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkDistributionConfigServiceImpl.java @@ -49,15 +49,6 @@ public class MkDistributionConfigServiceImpl extends ServiceImpl pay(long userId, MkDistributionPayDTO payDTO) { - MkDistributionConfigVO detail = detail(payDTO.getShopId()); - AssertUtil.isTrue(detail.getIsEnable() != 1, "分销未开启"); - if (!TableValueConstant.DistributionConfig.OpenType.PAY.getCode().equals(detail.getOpenType())) { - throw new CzgException("当前未开启购买分销配置"); - } - - OrderPayment orderPayment = new OrderPayment().setShopId(payDTO.getShopId()).setSourceId(userId) - .setPayType("distribution").setOrderNo(payDTO.getPlatformType() + IdUtil.getSnowflakeNextId()).setAmount(detail.getPayAmount()); - orderPaymentService.save(orderPayment); - - return Map.of(); - } - - @Override - public Boolean cashPayOrder(long adminId, MkDistributionPayDTO payParam) { - ShopInfo shopInfo = shopInfoService.getById(payParam.getShopId()); - AssertUtil.isNull(shopInfo, "店铺不存在"); - BigDecimal amount = shopInfoService.updateAmount(shopInfo.getId(), payParam.getAmount()); - Long mainShopId = shopInfoService.getMainIdByShopId(shopInfo.getId()); - - distributionAmountFlowService.save(new MkDistributionAmountFlow() - .setType(payParam.getAmount().compareTo(BigDecimal.ZERO) < 0 ? TableValueConstant.DistributionAmountFlow.Type.MANUAL_SUB.getCode() : - TableValueConstant.DistributionAmountFlow.Type.MANUAL_RECHARGE.getCode()) - .setMainShopId(mainShopId).setShopId(shopInfo.getId()).setAmount(amount).setChangeAmount(payParam.getAmount()) - .setRemark(payParam.getRemark()).setOpAccount(StpKit.USER.getAccount())); - return true; - } - - @Override - public void open(Long userId, BigDecimal amount, Long shopId, Long sourceId) { - ShopUser shopUserInfo = shopUserService.getShopUserInfo(shopId, userId); - Long mainShopId = shopInfoService.getMainIdByShopId(shopId); - BigDecimal finalAmount = shopInfoService.updateAmount(shopId, amount); - distributionAmountFlowService.save(new MkDistributionAmountFlow() - .setType(TableValueConstant.DistributionAmountFlow.Type.OPEN.getCode()) - .setMainShopId(mainShopId).setShopId(shopId).setAmount(finalAmount).setChangeAmount(amount).setSourceId(sourceId) - .setRemark("分销员购买").setOpAccount(StpKit.USER.getAccount())); - distributionUserService.addDistributionUser(new MkDistributionUser().setParentId(null).setShopId(shopId) - .setShopUserId(shopUserInfo.getId()).setOpeningMethod("付费开通")); - } - - - @Override - public void rechargeCallBack(Long userId, Long shopId, BigDecimal amount, Long paymentId) { - Long mainShopId = shopInfoService.getMainIdByShopId(shopId); - BigDecimal finalAmount = shopInfoService.updateAmount(shopId, amount); - distributionAmountFlowService.save(new MkDistributionAmountFlow() - .setType(TableValueConstant.DistributionAmountFlow.Type.SELF_RECHARGE.getCode()) - .setMainShopId(mainShopId).setShopId(shopId).setAmount(finalAmount).setChangeAmount(amount).setSourceId(paymentId) - .setRemark("自助充值").setOpAccount(StpKit.USER.getAccount())); - } } diff --git a/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkDistributionUserServiceImpl.java b/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkDistributionUserServiceImpl.java index 5685ebc57..22ce3669d 100644 --- a/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkDistributionUserServiceImpl.java +++ b/cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkDistributionUserServiceImpl.java @@ -177,4 +177,15 @@ public class MkDistributionUserServiceImpl extends ServiceImpl