分销员开通接口
This commit is contained in:
@@ -3,12 +3,16 @@ package com.czg.service.market.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.constant.TableValueConstant;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.MkDistributionConfigDTO;
|
||||
import com.czg.market.entity.MkDistributionAmountFlow;
|
||||
import com.czg.market.entity.MkDistributionUser;
|
||||
import com.czg.market.service.MkDistributionAmountFlowService;
|
||||
import com.czg.market.service.MkDistributionUserService;
|
||||
import com.czg.order.dto.MkDistributionPayDTO;
|
||||
import com.czg.market.entity.MkDistributionLevelConfig;
|
||||
import com.czg.market.service.MkDistributionLevelConfigService;
|
||||
@@ -47,6 +51,10 @@ public class MkDistributionConfigServiceImpl extends ServiceImpl<MkDistributionC
|
||||
private MkDistributionLevelConfigService levelConfigService;
|
||||
@Resource
|
||||
private MkDistributionAmountFlowService distributionAmountFlowService;
|
||||
@Resource
|
||||
private MkDistributionUserService distributionUserService;
|
||||
@Resource
|
||||
private ShopUserService shopUserService;
|
||||
|
||||
@DubboReference
|
||||
private OrderPaymentService orderPaymentService;
|
||||
@@ -105,13 +113,25 @@ public class MkDistributionConfigServiceImpl extends ServiceImpl<MkDistributionC
|
||||
AssertUtil.isNull(shopInfo, "店铺不存在");
|
||||
BigDecimal amount = shopInfoService.updateAmount(shopInfo.getId(), payParam.getAmount());
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(shopInfo.getId());
|
||||
shopInfoService.updateAmount(shopInfo.getId(), payParam.getAmount());
|
||||
|
||||
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 null;
|
||||
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("付费开通"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,14 +64,13 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
||||
}
|
||||
|
||||
private InitInfo initPayment(Long userId, MkDistributionPayDTO payParam) {
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(payParam.getShopId());
|
||||
MkDistributionConfigVO detail = configService.detail(payParam.getShopId());
|
||||
AssertUtil.isTrue(detail.getIsEnable() != 1, "分销未开启");
|
||||
if (!TableValueConstant.DistributionConfig.OpenType.PAY.getCode().equals(detail.getOpenType())) {
|
||||
throw new CzgException("当前未开启购买分销配置");
|
||||
}
|
||||
|
||||
OrderPayment orderPayment = new OrderPayment().setShopId(mainShopId).setSourceId(userId)
|
||||
OrderPayment orderPayment = new OrderPayment().setShopId(payParam.getShopId()).setSourceId(userId)
|
||||
.setPayType("distribution").setOrderNo(payParam.getPlatformType() + IdUtil.getSnowflakeNextId()).setAmount(detail.getPayAmount());
|
||||
orderPaymentService.save(orderPayment);
|
||||
|
||||
|
||||
@@ -136,6 +136,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
private MkShopRechargeService shopRechargeService;
|
||||
@Resource
|
||||
private MkConsumeCashbackService consumeCashbackService;
|
||||
@Resource
|
||||
private MkDistributionConfigService distributionConfigService;
|
||||
// 延迟 5 秒
|
||||
private static final long DELAY = 5;
|
||||
//重试次数
|
||||
@@ -1154,6 +1156,9 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
// 充值赠送积分
|
||||
memberConfigService.deliver(shopUser.getMainShopId(), shopUser.getUserId(), TableValueConstant.MemberExpFlow.Type.COST, payment.getAmount(), null, payment.getId());
|
||||
|
||||
// 分销员开通
|
||||
} else if ("distribution".equals(payment.getPayType())) {
|
||||
distributionConfigService.open(payment.getSourceId(), payment.getAmount(), payment.getShopId(), payment.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user