|
@@ -1,27 +1,23 @@
|
|
|
package com.cyksj.service.mange.goods;
|
|
package com.cyksj.service.mange.goods;
|
|
|
|
|
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
import cn.hutool.core.lang.Assert;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.mapper.GoodsDonMapper;
|
|
import com.cyksj.mapper.GoodsDonMapper;
|
|
|
|
|
+import com.cyksj.mapper.manage.distribute.UserBusinessDefaultRateConfigMapper;
|
|
|
import com.cyksj.mapper.manage.distribute.UserDistributeMapper;
|
|
import com.cyksj.mapper.manage.distribute.UserDistributeMapper;
|
|
|
import com.cyksj.mapper.shop.*;
|
|
import com.cyksj.mapper.shop.*;
|
|
|
import com.cyksj.model.entity.*;
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.request.DistributeApplyMoneyReq;
|
|
import com.cyksj.model.request.DistributeApplyMoneyReq;
|
|
|
import com.cyksj.model.request.YhShopVerifyReq;
|
|
import com.cyksj.model.request.YhShopVerifyReq;
|
|
|
-import com.cyksj.model.views.GoodsDonSkuView;
|
|
|
|
|
import com.cyksj.service.mange.CmsYhShopCommonService;
|
|
import com.cyksj.service.mange.CmsYhShopCommonService;
|
|
|
import com.cyksj.service.mange.business.UserBusinessRateService;
|
|
import com.cyksj.service.mange.business.UserBusinessRateService;
|
|
|
import com.cyksj.service.shop.YhShopUserPlatDistributeRateService;
|
|
import com.cyksj.service.shop.YhShopUserPlatDistributeRateService;
|
|
|
import com.cyksj.service.user.UserBenefitsService;
|
|
import com.cyksj.service.user.UserBenefitsService;
|
|
|
-import com.ejlchina.searcher.BeanSearcher;
|
|
|
|
|
-import com.ejlchina.searcher.util.MapUtils;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.dao.DuplicateKeyException;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
@@ -49,17 +45,11 @@ public class CmsYhShopCommonServiceImpl implements CmsYhShopCommonService {
|
|
|
|
|
|
|
|
private final YhShopUserPlatDistributeRateService yhShopUserPlatDistributeRateService;
|
|
private final YhShopUserPlatDistributeRateService yhShopUserPlatDistributeRateService;
|
|
|
|
|
|
|
|
- private final YhShopUserBusinessDefaultRateConfigMapper yhShopUserBusinessDefaultRateConfigMapper;
|
|
|
|
|
-
|
|
|
|
|
- private final YhShopUserDistributeBusinessRateMapper yhShopUserDistributeBusinessRateMapper;
|
|
|
|
|
-
|
|
|
|
|
private final YhShopDistributeMoneyApplyMapper yhShopDistributeMoneyApplyMapper;
|
|
private final YhShopDistributeMoneyApplyMapper yhShopDistributeMoneyApplyMapper;
|
|
|
|
|
|
|
|
private final UserBenefitsService userBenefitsService;
|
|
private final UserBenefitsService userBenefitsService;
|
|
|
|
|
|
|
|
- private final BeanSearcher beanSearcher;
|
|
|
|
|
-
|
|
|
|
|
- private final YhShopUserBusinessDefaultRateConfigMapper defaultRateConfigMapper;
|
|
|
|
|
|
|
+ private final UserBusinessDefaultRateConfigMapper defaultRateConfigMapper;
|
|
|
|
|
|
|
|
private final UserDistributeMapper userDistributeMapper;
|
|
private final UserDistributeMapper userDistributeMapper;
|
|
|
|
|
|
|
@@ -172,64 +162,6 @@ public class CmsYhShopCommonServiceImpl implements CmsYhShopCommonService {
|
|
|
yhShopMapper.updateById(dbShop);
|
|
yhShopMapper.updateById(dbShop);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- public void setBusinessDefaultRate(List<YhShopUserBusinessDefaultRateConfig> configs) {
|
|
|
|
|
- configs.forEach(rateConfig -> {
|
|
|
|
|
- Long rateConfigId = rateConfig.getId();
|
|
|
|
|
- YhShopUserBusinessDefaultRateConfig config = Optional.ofNullable(yhShopUserBusinessDefaultRateConfigMapper.selectById(rateConfigId)).orElse(new YhShopUserBusinessDefaultRateConfig());
|
|
|
|
|
- BeanUtil.copyProperties(rateConfig, config);
|
|
|
|
|
- Number number = beanSearcher.searchCount(GoodsDonSkuView.class, MapUtils.builder()
|
|
|
|
|
- .field(GoodsDonSkuView::getGoodsId, rateConfig.getGoodsId())
|
|
|
|
|
- .field(GoodsDonSkuView::getGoodsDonDeleted, true)
|
|
|
|
|
- .build());
|
|
|
|
|
- if (number.intValue() == 0) {
|
|
|
|
|
- yhShopUserBusinessDefaultRateConfigMapper.delete(Wrappers.lambdaQuery(YhShopUserBusinessDefaultRateConfig.class)
|
|
|
|
|
- .eq(YhShopUserBusinessDefaultRateConfig::getGoodsId, rateConfig.getGoodsId()));
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- if (config.getRate() == null || config.getRate() < 0 || config.getRate() > 100) {
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("请输入正确的比例");
|
|
|
|
|
- }
|
|
|
|
|
- if (rateConfig.getId() == null) {
|
|
|
|
|
- try {
|
|
|
|
|
- yhShopUserBusinessDefaultRateConfigMapper.insert(config);
|
|
|
|
|
- return;
|
|
|
|
|
- } catch (DuplicateKeyException e) {
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- yhShopUserBusinessDefaultRateConfigMapper.updateById(config);
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void setBusinessRate(List<UserDistributeBusinessRate> rates) {
|
|
|
|
|
- rates.forEach(yhShopUserDistributeBusinessRate -> {
|
|
|
|
|
- Long rateId = yhShopUserDistributeBusinessRate.getId();
|
|
|
|
|
- YhShopUserDistributeBusinessRate businessRate = Optional.ofNullable(yhShopUserDistributeBusinessRateMapper.selectById(rateId)).orElse(new YhShopUserDistributeBusinessRate());
|
|
|
|
|
- BeanUtil.copyProperties(yhShopUserDistributeBusinessRate, businessRate);
|
|
|
|
|
- Number number = beanSearcher.searchCount(GoodsDonSkuView.class, MapUtils.builder()
|
|
|
|
|
- .field(GoodsDonSkuView::getGoodsId, yhShopUserDistributeBusinessRate.getGoodsId())
|
|
|
|
|
- .field(GoodsDonSkuView::getSkuId, yhShopUserDistributeBusinessRate.getSkuId())
|
|
|
|
|
- .field(GoodsDonSkuView::getGoodsDonDeleted, true)
|
|
|
|
|
- .build());
|
|
|
|
|
- if (number.intValue() == 0) {
|
|
|
|
|
- yhShopUserDistributeBusinessRateMapper.delete(Wrappers.lambdaQuery(YhShopUserDistributeBusinessRate.class)
|
|
|
|
|
- .eq(YhShopUserDistributeBusinessRate::getBusinessId, yhShopUserDistributeBusinessRate.getBusinessId())
|
|
|
|
|
- .eq(YhShopUserDistributeBusinessRate::getGoodsId, yhShopUserDistributeBusinessRate.getGoodsId())
|
|
|
|
|
- .eq(YhShopUserDistributeBusinessRate::getSkuId, yhShopUserDistributeBusinessRate.getSkuId()));
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- if (businessRate.getId() == null) {
|
|
|
|
|
- try {
|
|
|
|
|
- yhShopUserDistributeBusinessRateMapper.insert(businessRate);
|
|
|
|
|
- } catch (DuplicateKeyException e) {
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- yhShopUserDistributeBusinessRateMapper.updateById(businessRate);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
|
public void verifyYhShopApplyMoney(DistributeApplyMoneyReq distributeApplyMoneyReq) {
|
|
public void verifyYhShopApplyMoney(DistributeApplyMoneyReq distributeApplyMoneyReq) {
|
|
@@ -285,8 +217,8 @@ public class CmsYhShopCommonServiceImpl implements CmsYhShopCommonService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void checkDistributorAndBusinessRate(Integer distributeGoodsRate, Long goodsId, String goodsName) {
|
|
public void checkDistributorAndBusinessRate(Integer distributeGoodsRate, Long goodsId, String goodsName) {
|
|
|
- YhShopUserBusinessDefaultRateConfig defaultGoodsRateConfig = defaultRateConfigMapper.selectOne(Wrappers.lambdaQuery(YhShopUserBusinessDefaultRateConfig.class)
|
|
|
|
|
- .eq(YhShopUserBusinessDefaultRateConfig::getGoodsId, goodsId)
|
|
|
|
|
|
|
+ UserBusinessDefaultRateConfig defaultGoodsRateConfig = defaultRateConfigMapper.selectOne(Wrappers.lambdaQuery(UserBusinessDefaultRateConfig.class)
|
|
|
|
|
+ .eq(UserBusinessDefaultRateConfig::getGoodsId, goodsId)
|
|
|
.last("limit 1"));
|
|
.last("limit 1"));
|
|
|
Optional.ofNullable(defaultGoodsRateConfig).ifPresent(config -> {
|
|
Optional.ofNullable(defaultGoodsRateConfig).ifPresent(config -> {
|
|
|
if (distributeGoodsRate > config.getMaxRate()) {
|
|
if (distributeGoodsRate > config.getMaxRate()) {
|