|
@@ -51,6 +51,7 @@ import javax.validation.constraints.NotNull;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
+import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -107,6 +108,8 @@ public class DistributeController {
|
|
|
|
|
|
|
|
private final UserDistributeRuleOrderRecordMapper userDistributeRuleOrderRecordMapper;
|
|
private final UserDistributeRuleOrderRecordMapper userDistributeRuleOrderRecordMapper;
|
|
|
|
|
|
|
|
|
|
+ private final UserDistributeBusinessGeneralRateMapper businessGeneralRateMapper;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 添加固定推广者
|
|
* 添加固定推广者
|
|
|
*/
|
|
*/
|
|
@@ -919,6 +922,73 @@ public class DistributeController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(collect);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(collect);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 针对商务
|
|
|
|
|
+ * 获取商务 分销平台通用比例
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/get/business/general/rate")
|
|
|
|
|
+ public Result<List<UserDistributeBusinessGeneralRateView>> getBusinessGeneralRate() {
|
|
|
|
|
+ List<UserDistributeBusinessGeneralRateView> userDistributeBusinessGeneralRateViews = beanSearcher.searchAll(UserDistributeBusinessGeneralRateView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
|
|
+ .field(UserDistributeBusinessGeneralRateView::getType, 2).build());
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(userDistributeBusinessGeneralRateViews);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 编辑商务 分销平台通用比例
|
|
|
|
|
+ * 商务的平台规格提成 根据这个改变
|
|
|
|
|
+ */
|
|
|
|
|
+ @PutMapping("/put/business/general/rate")
|
|
|
|
|
+ @Transactional(rollbackFor = Throwable.class)
|
|
|
|
|
+ public Result<String> updateBusinessGeneralRate(@RequestBody List<UserDistributeBusinessGeneralRate> generalRates) {
|
|
|
|
|
+ List<CmsUserVO> userVOS = beanSearcher.searchAll(CmsUserVO.class, MapUtils.builder().field(CmsUserVO::getRoleNames, "商务").op(Operator.Contain).build());
|
|
|
|
|
+ List<Long> collect = userVOS.stream().map(CmsUserVO::getId).collect(Collectors.toList());
|
|
|
|
|
+ final List<Long> businessIds = collect;
|
|
|
|
|
+ generalRates.forEach(data -> {
|
|
|
|
|
+ if (data.getId() == null) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ //新增
|
|
|
|
|
+ UserDistributeBusinessGeneralRate businessGeneralRate = new UserDistributeBusinessGeneralRate();
|
|
|
|
|
+ if (data.getGoodsId() == null || data.getSkuId() == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("缺少必要参数");
|
|
|
|
|
+ }
|
|
|
|
|
+ businessGeneralRate.setGoodsId(data.getGoodsId());
|
|
|
|
|
+ businessGeneralRate.setSkuId(data.getSkuId());
|
|
|
|
|
+ Integer firstOrderRate = Optional.ofNullable(data.getFirstOrderRate()).orElse(0);
|
|
|
|
|
+ businessGeneralRate.setFirstOrderRate(firstOrderRate);
|
|
|
|
|
+ Integer renewOrderRate = Optional.ofNullable(data.getRenewOrderRate()).orElse(0);
|
|
|
|
|
+ businessGeneralRate.setRenewOrderRate(renewOrderRate);
|
|
|
|
|
+ businessGeneralRateMapper.insert(businessGeneralRate);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(businessIds)) {
|
|
|
|
|
+ userDistributeBusinessRateMapper.insertOrUpdateBusinessGoodsSkuRate(businessIds, data.getGoodsId(), data.getSkuId(), firstOrderRate, renewOrderRate);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (DuplicateKeyException e) {
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ UserDistributeBusinessGeneralRate dbGeneralRate = businessGeneralRateMapper.selectById(data.getId());
|
|
|
|
|
+ if (dbGeneralRate != null) {
|
|
|
|
|
+ Integer firstOrderRate_new = dbGeneralRate.getFirstOrderRate();
|
|
|
|
|
+ Integer renewOrderRate_new = dbGeneralRate.getRenewOrderRate();
|
|
|
|
|
+ AtomicBoolean is_change = new AtomicBoolean(false);
|
|
|
|
|
+ //需要更新首单比例
|
|
|
|
|
+ if (data.getFirstOrderRate() != null && dbGeneralRate.getFirstOrderRate() != data.getFirstOrderRate()) {
|
|
|
|
|
+ firstOrderRate_new = data.getFirstOrderRate();
|
|
|
|
|
+ is_change.set(true);
|
|
|
|
|
+ }
|
|
|
|
|
+ //需要更新续费比例
|
|
|
|
|
+ if (data.getRenewOrderRate() != null && dbGeneralRate.getRenewOrderRate() != data.getRenewOrderRate()) {
|
|
|
|
|
+ renewOrderRate_new = data.getRenewOrderRate();
|
|
|
|
|
+ is_change.set(true);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (CollUtil.isNotEmpty(businessIds) && is_change.get()) {
|
|
|
|
|
+ //获取所有商务
|
|
|
|
|
+ userDistributeBusinessRateMapper.insertOrUpdateBusinessGoodsSkuRate(businessIds, data.getGoodsId(), data.getSkuId(), firstOrderRate_new, renewOrderRate_new);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 是否有未配置比例的规格
|
|
* 是否有未配置比例的规格
|
|
|
*/
|
|
*/
|