Ver código fonte

过滤不参与分销的平台;未配置规格分销比例提示;设置商务提成通用比例

zoujiajian 2 anos atrás
pai
commit
9433653ccb
16 arquivos alterados com 341 adições e 32 exclusões
  1. 18 0
      netflix-dao/src/main/java/com/cyksj/mapper/DistributeGoodsSkuAlertMapper.java
  2. 13 0
      netflix-dao/src/main/java/com/cyksj/mapper/manage/distribute/UserDistributeBusinessGeneralRateMapper.java
  3. 2 0
      netflix-dao/src/main/java/com/cyksj/mapper/manage/distribute/UserDistributeBusinessRateMapper.java
  4. 18 0
      netflix-dao/src/main/java/com/cyksj/model/entity/DistributeGoodsSkuAlert.java
  5. 35 0
      netflix-dao/src/main/java/com/cyksj/model/entity/UserDistributeBusinessGeneralRate.java
  6. 1 1
      netflix-dao/src/main/java/com/cyksj/model/views/BusinessDistributeRateView.java
  7. 2 2
      netflix-dao/src/main/java/com/cyksj/model/views/UserBusinessDefaultRateConfigView.java
  8. 63 0
      netflix-dao/src/main/java/com/cyksj/model/views/UserDistributeBusinessGeneralRateView.java
  9. 1 1
      netflix-dao/src/main/java/com/cyksj/model/views/UserDistributeBusinessRateRecordView.java
  10. 1 1
      netflix-dao/src/main/java/com/cyksj/model/views/UserDistributeRateView.java
  11. 1 1
      netflix-dao/src/main/java/com/cyksj/model/views/UserDistributeView.java
  12. 35 1
      netflix-dao/src/main/resources/mapper/UserDistributeBusinessRateMapper.xml
  13. 9 0
      netflix-service/src/main/java/com/cyksj/service/mange/goods/CmsGoodsDonSpecServiceImpl.java
  14. 24 22
      netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java
  15. 1 0
      netflix-service/src/main/java/com/cyksj/service/shop/impl/YhShopDistributeServiceImpl.java
  16. 117 3
      netflix-web/src/main/java/com/cyksj/web/controller/manage/distribute/DistributeController.java

+ 18 - 0
netflix-dao/src/main/java/com/cyksj/mapper/DistributeGoodsSkuAlertMapper.java

@@ -0,0 +1,18 @@
+package com.cyksj.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.cyksj.model.entity.DistributeGoodsSkuAlert;
+import org.apache.ibatis.annotations.Select;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: DistributeGoodsSkuAlertMapper
+ * 创建者: JavaZou
+ * 创建时间:2023/11/8 14:10
+ */
+public interface DistributeGoodsSkuAlertMapper extends BaseMapper<DistributeGoodsSkuAlert> {
+
+	@Select("select count(*) from distribute_goods_sku_alert da inner join goods_don_sku sku on sku.id = da.sku_id and sku.status is true" +
+			" inner join goods_don g on g.id = da.goods_id and g.status is true and g.deleted is true and g.is_distribute is true")
+	Integer selectCountByCondition();
+}

+ 13 - 0
netflix-dao/src/main/java/com/cyksj/mapper/manage/distribute/UserDistributeBusinessGeneralRateMapper.java

@@ -0,0 +1,13 @@
+package com.cyksj.mapper.manage.distribute;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.cyksj.model.entity.UserDistributeBusinessGeneralRate;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: UserDistributeBusinessGeneralRateMapper
+ * 创建者: JavaZou
+ * 创建时间:2023/11/8 14:46
+ */
+public interface UserDistributeBusinessGeneralRateMapper extends BaseMapper<UserDistributeBusinessGeneralRate> {
+}

+ 2 - 0
netflix-dao/src/main/java/com/cyksj/mapper/manage/distribute/UserDistributeBusinessRateMapper.java

@@ -17,4 +17,6 @@ public interface UserDistributeBusinessRateMapper extends BaseMapper<UserDistrib
 	List<Long> selectNoThisGoodsDistribute(Long goodsId);
 
 	void batchInsertDistributePlatRate(@Param("list") List<UserPlatDistributeRate> part);
+
+	void insertOrUpdateBusinessGoodsSkuRate(@Param("list") List<Long> businessIds, @Param("goodsId") Long goodsId, @Param("skuId") Long skuId, @Param("firstOrderRate") Integer firstOrderRate, @Param("renewOrderRate") Integer renewOrderRate);
 }

+ 18 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/DistributeGoodsSkuAlert.java

@@ -0,0 +1,18 @@
+package com.cyksj.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: DistributeGoodsSkuAlert
+ * 创建者: JavaZou
+ * 创建时间:2023/11/8 14:08
+ */
+@Getter
+@Setter
+public class DistributeGoodsSkuAlert extends BaseEntity {
+	private Long goodsId;
+
+	private Long skuId;
+}

+ 35 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/UserDistributeBusinessGeneralRate.java

@@ -0,0 +1,35 @@
+package com.cyksj.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/*
+ *项目名: netflix
+ *文件名: UserDistributeBusinessGeneralRate
+ *创建者: JavaZou
+ *创建时间:2023/11/8 14:45
+ */
+@Getter
+@Setter
+public class UserDistributeBusinessGeneralRate extends BaseEntity {
+
+	/**
+	 * 平台id
+	 */
+	private Long goodsId;
+
+	/**
+	 * 规格id
+	 */
+	private Long skuId;
+
+	/**
+	 * 首单提成比例
+	 */
+	private Integer firstOrderRate;
+
+	/**
+	 * 首单续费提成比例
+	 */
+	private Integer renewOrderRate;
+}

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/model/views/BusinessDistributeRateView.java

@@ -14,7 +14,7 @@ import lombok.Setter;
 @Getter
 @Setter
 @SearchBean(tables = "goods_don g left join business_distribute_default_rate_config bc on g.id = bc.goods_id",
-		where = "g.deleted is true and g.status is true",
+		where = "g.deleted is true and g.status is true and g.is_distribute is true",
 		orderBy = "g.id")
 public class BusinessDistributeRateView {
 	@DbField("bc.id")

+ 2 - 2
netflix-dao/src/main/java/com/cyksj/model/views/UserBusinessDefaultRateConfigView.java

@@ -13,8 +13,8 @@ import lombok.Setter;
  */
 @Getter
 @Setter
-@SearchBean(tables = "user_business_default_rate_config uc left join goods_don g on g.id = uc.goods_id"
-		, where = "g.deleted is true and g.status is true")
+@SearchBean(tables = "goods_don g left join user_business_default_rate_config uc on g.id = uc.goods_id"
+		, where = "g.deleted is true and g.status is true and g.is_distribute is true")
 public class UserBusinessDefaultRateConfigView {
 	@DbField("uc.id")
 	private Long id;

+ 63 - 0
netflix-dao/src/main/java/com/cyksj/model/views/UserDistributeBusinessGeneralRateView.java

@@ -0,0 +1,63 @@
+package com.cyksj.model.views;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: UserDistributeBusinessGeneralRateView
+ * 创建者: JavaZou
+ * 创建时间:2023/11/8 14:47
+ */
+
+import com.ejlchina.searcher.bean.DbField;
+import com.ejlchina.searcher.bean.SearchBean;
+import lombok.Getter;
+import lombok.Setter;
+
+/*
+ *项目名: netflix
+ *文件名: UserDistributeBusinessRateRecordView
+ *创建者: JavaZou
+ *创建时间:2023/3/27 15:53
+ */
+@Getter
+@Setter
+@SearchBean(tables = "goods_don g left join goods_don_sku gdk on gdk.goods_id = g.id" +
+		" left join user_distribute_business_general_rate ur on ur.sku_id = gdk.id",
+		where = "g.deleted is true and g.status is true and g.is_distribute is true and gdk.status is true")
+public class UserDistributeBusinessGeneralRateView {
+	@DbField("ur.id")
+	private Long id;
+
+	/**
+	 * 平台id
+	 */
+	@DbField("g.id")
+	private Long goodsId;
+
+	@DbField("g.title")
+	private String goodsName;
+
+	/**
+	 * 规格id
+	 */
+	@DbField("gdk.id")
+	private Long skuId;
+
+	@DbField("gdk.spec_val")
+	private String specVal;
+
+	/**
+	 * 首单提成比例
+	 */
+	@DbField("ifnull(ur.first_order_rate,0)")
+	private Integer firstOrderRate;
+
+	/**
+	 * 首单续费提成比例
+	 */
+	@DbField("ifnull(ur.renew_order_rate,0)")
+	private Integer renewOrderRate;
+
+	@DbField("g.type")
+	private Integer type;
+}
+

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/model/views/UserDistributeBusinessRateRecordView.java

@@ -16,7 +16,7 @@ import lombok.Setter;
 @Setter
 @SearchBean(tables = "goods_don g left join goods_don_sku gdk on gdk.goods_id = g.id" +
 		" left join user_distribute_business_rate ur on ur.sku_id = gdk.id :business_id:",
-		where = "g.deleted is true and g.status is true")
+		where = "g.deleted is true and g.status is true and g.is_distribute is true and gdk.status is true")
 public class UserDistributeBusinessRateRecordView {
 	@DbField("ur.id")
 	private Long id;

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/model/views/UserDistributeRateView.java

@@ -16,7 +16,7 @@ import lombok.Setter;
 @SearchBean(tables = "goods_don g left join goods_don_category_relate gcr on gcr.goods_id = g.id" +
 		" left join goods_don_category gc on gc.id = gcr.category" +
 		" left join user_plat_distribute_rate upr on upr.goods_id = g.id :distribute_id:",
-		where = "g.type = 1 and g.deleted is true and g.status is true and upr.rate > 0")
+		where = "g.type = 1 and g.deleted is true and g.status is true and g.is_distribute is true and upr.rate > 0")
 public class UserDistributeRateView {
 
 	@DbField("gcr.category")

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/model/views/UserDistributeView.java

@@ -15,7 +15,7 @@ import lombok.Setter;
 @Getter
 @Setter
 @SearchBean(tables = "user_plat_distribute_rate up left join goods_don gd on gd.id = up.goods_id",
-		where = "gd.deleted is true and gd.status is true")
+		where = "gd.deleted is true and gd.status is true and gd.is_distribute is true")
 public class UserDistributeView {
 	@DbField("up.id")
 	private Long id;

+ 35 - 1
netflix-dao/src/main/resources/mapper/UserDistributeBusinessRateMapper.xml

@@ -10,7 +10,41 @@
             (#{item.distributeId},#{item.goodsId},#{item.rate},#{item.secondRate},now(),now())
         </foreach>
         ON DUPLICATE KEY UPDATE rate = VALUES(rate)
-</insert>
+    </insert>
+
+    <insert id="insertOrUpdateBusinessGoodsSkuRate">
+        insert into user_distribute_business_rate
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            `business_id`,`goods_id`,`sku_id`,
+            <if test="firstOrderRate != null">
+                `first_order_rate`,
+            </if>
+            <if test="renewOrderRate != null">
+                `renew_order_rate`,
+            </if>
+            `created_time`,`update_time`
+        </trim>
+        values
+        <foreach collection="list" item="item" separator=",">
+            (#{item},#{goodsId},#{skuId},
+            <if test="firstOrderRate != null">
+                #{firstOrderRate},
+            </if>
+            <if test="renewOrderRate != null">
+                #{renewOrderRate},
+            </if>
+            now(),now())
+        </foreach>
+        ON DUPLICATE KEY UPDATE
+        <trim suffixOverrides=",">
+            <if test="firstOrderRate != null">
+                first_order_rate = VALUES(first_order_rate),
+            </if>
+            <if test="renewOrderRate != null">
+                renew_order_rate = VALUES(renew_order_rate)
+            </if>
+        </trim>
+    </insert>
 
     <select id="selectNoThisGoodsDistribute" resultType="java.lang.Long">
         select distinct ud.id from user_distribute ud left join user_plat_distribute_rate ur

+ 9 - 0
netflix-service/src/main/java/com/cyksj/service/mange/goods/CmsGoodsDonSpecServiceImpl.java

@@ -7,9 +7,11 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.util.Jsons;
+import com.cyksj.mapper.DistributeGoodsSkuAlertMapper;
 import com.cyksj.mapper.GoodsDonMapper;
 import com.cyksj.mapper.GoodsDonSkuMapper;
 import com.cyksj.mapper.GoodsDonSpecMapper;
+import com.cyksj.model.entity.DistributeGoodsSkuAlert;
 import com.cyksj.model.entity.GoodsDon;
 import com.cyksj.model.entity.GoodsDonSku;
 import com.cyksj.model.entity.GoodsDonSpec;
@@ -43,6 +45,8 @@ public class CmsGoodsDonSpecServiceImpl extends ServiceImpl<GoodsDonSpecMapper,
 
 	private final GoodsDonSkuMapper goodsDonSkuMapper;
 
+	private final DistributeGoodsSkuAlertMapper distributeGoodsSkuAlertMapper;
+
 	@Override
 	@Transactional(rollbackFor = Throwable.class)
 	public void insertOrUpdateSkuSpec(ReqGoodsSkuInsert insert, Boolean isUpdate) throws Exception {
@@ -254,6 +258,11 @@ public class CmsGoodsDonSpecServiceImpl extends ServiceImpl<GoodsDonSpecMapper,
 				}
 			}
 			goodsDonSkuMapper.insert(goodsDonSku);
+
+			DistributeGoodsSkuAlert distributeGoodsSkuAlert = new DistributeGoodsSkuAlert();
+			distributeGoodsSkuAlert.setGoodsId(goods.getId());
+			distributeGoodsSkuAlert.setSkuId(goodsDonSku.getId());
+			distributeGoodsSkuAlertMapper.insert(distributeGoodsSkuAlert);
 		}
 	}
 

+ 24 - 22
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -1370,6 +1370,12 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		BigDecimal points = null;
 		BigDecimal returnMoney = null;
 		Long businessId = null;
+		//普通分销
+		GoodsDon goodsDon = goodsDonMapper.selectById(order.getGoodsId());
+		if (goodsDon == null || !goodsDon.getIsDistribute()) {
+			log.info("分销订单orderId:{}对应平台goodsId:{}不存在或已不参与分成比例", order.getId(), order.getGoodsId());
+			return;
+		}
 		UserDistributeShared userDistributeShared = userDistributeSharedMapper.selectOne(Wrappers.lambdaQuery(UserDistributeShared.class).eq(UserDistributeShared::getUserId, order.getUserId()).last("limit 1"));
 		if (userDistributeShared != null) {
 			distributeWaitingSendPoints.setSharedId(userDistributeShared.getSharedId());
@@ -1378,34 +1384,30 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 				log.info("分销兑换积分比例未配置");
 			} else {
 				UserDistribute userDistribute = userDistributeMapper.selectOne(Wrappers.lambdaQuery(UserDistribute.class).eq(UserDistribute::getUserId, userDistributeShared.getSharedId()).eq(UserDistribute::getDeleted, true).last("limit 1"));
-				//普通分销
-				GoodsDon goodsDon = goodsDonMapper.selectById(order.getGoodsId());
 				//分销比例
 				Integer rate = 0;
 				if (userDistribute == null) {
-					if (goodsDon != null) {
-						//普通分销者 是否享受过该用户的首单分销
-						DistributeWaitingSendPoints isReceived = distributeWaitingSendPointsMapper.selectOne(Wrappers.lambdaQuery(DistributeWaitingSendPoints.class)
-								.eq(DistributeWaitingSendPoints::getSharedId, userDistributeShared.getSharedId())
-								.eq(DistributeWaitingSendPoints::getUserId, order.getUserId())
-								.in(DistributeWaitingSendPoints::getSendStatus, List.of(DistributeWaitingSendPoints.Status.waiting.name(), DistributeWaitingSendPoints.Status.success.name()))
-								.last("limit 1"));
-						if (isReceived != null) {
-							return;
-						}
-						rate = goodsDon.getRate();
-						//实物分销比例
-						if (goodsDon.getType() == 2) {
-							GoodsDonSku goodsDonSku = goodsDonSkuMapper.selectById(order.getSkuId());
-							if (goodsDonSku != null) {
-								//不包含套餐权益
-								if (!goodsDonSku.getIsBenefits()) {
-									rate = goodsDon.getSecondRate();
-								}
+					//普通分销者 是否享受过该用户的首单分销
+					DistributeWaitingSendPoints isReceived = distributeWaitingSendPointsMapper.selectOne(Wrappers.lambdaQuery(DistributeWaitingSendPoints.class)
+							.eq(DistributeWaitingSendPoints::getSharedId, userDistributeShared.getSharedId())
+							.eq(DistributeWaitingSendPoints::getUserId, order.getUserId())
+							.in(DistributeWaitingSendPoints::getSendStatus, List.of(DistributeWaitingSendPoints.Status.waiting.name(), DistributeWaitingSendPoints.Status.success.name()))
+							.last("limit 1"));
+					if (isReceived != null) {
+						return;
+					}
+					rate = goodsDon.getRate();
+					//实物分销比例
+					if (goodsDon.getType() == 2) {
+						GoodsDonSku goodsDonSku = goodsDonSkuMapper.selectById(order.getSkuId());
+						if (goodsDonSku != null) {
+							//不包含套餐权益
+							if (!goodsDonSku.getIsBenefits()) {
+								rate = goodsDon.getSecondRate();
 							}
 						}
-						returnMoney = orderMoney.multiply(BigDecimal.valueOf(rate)).divide(BigDecimal.valueOf(100));
 					}
+					returnMoney = orderMoney.multiply(BigDecimal.valueOf(rate)).divide(BigDecimal.valueOf(100));
 				} else {
 					businessId = userDistribute.getBusinessId();
 					//固定推广分销

+ 1 - 0
netflix-service/src/main/java/com/cyksj/service/shop/impl/YhShopDistributeServiceImpl.java

@@ -61,6 +61,7 @@ public class YhShopDistributeServiceImpl implements YhShopDistributeService {
 				.eq(GoodsDon::getId, order.getGoodsId()).last("limit 1"));
 		if (goodsDon == null || !goodsDon.getIsDistribute()) {
 			log.info("店铺订单orderId:{}对应平台goodsId:{}不存在或已不参与分成比例", order.getId(), order.getGoodsId());
+			return;
 		}
 		Long shopUserId = yhShop.getUserId();
 		YhShopDistributeWaitingSendPoints distributeWaitingSendPoints = new YhShopDistributeWaitingSendPoints();

+ 117 - 3
netflix-web/src/main/java/com/cyksj/web/controller/manage/distribute/DistributeController.java

@@ -3,8 +3,8 @@ package com.cyksj.web.controller.manage.distribute;
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.date.BetweenFormater;
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.BetweenFormater;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
@@ -16,6 +16,7 @@ import com.cyksj.common.util.StringUtil;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.BusinessType;
 import com.cyksj.enums.GatewayResponse;
+import com.cyksj.mapper.DistributeGoodsSkuAlertMapper;
 import com.cyksj.mapper.GoodsDonMapper;
 import com.cyksj.mapper.GoodsDonSkuMapper;
 import com.cyksj.mapper.UserMapper;
@@ -50,6 +51,7 @@ import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.stream.Collectors;
 
 /*
@@ -102,8 +104,12 @@ public class DistributeController {
 
 	private final RedisService redisService;
 
+	private final DistributeGoodsSkuAlertMapper distributeGoodsSkuAlertMapper;
+
 	private final UserDistributeRuleOrderRecordMapper userDistributeRuleOrderRecordMapper;
 
+	private final UserDistributeBusinessGeneralRateMapper businessGeneralRateMapper;
+
 	/**
 	 * 添加固定推广者
 	 */
@@ -239,7 +245,11 @@ public class DistributeController {
 	 */
 	@GetMapping("/get/plat")
 	public Result<List<GoodsDon>> getGoodsDistributeRate() {
-		return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDonMapper.selectList(Wrappers.lambdaQuery(GoodsDon.class).in(GoodsDon::getType, Constant.dsGoodsIds).eq(GoodsDon::getDeleted, true).eq(GoodsDon::getStatus, true).orderByAsc(GoodsDon::getType).orderByAsc(GoodsDon::getId).select(GoodsDon::getId, GoodsDon::getType, GoodsDon::getTitle, GoodsDon::getRate, GoodsDon::getSecondRate)));
+		return GatewayResponse.SUCCESS.newBuilder().toResult(goodsDonMapper.selectList(Wrappers.lambdaQuery(GoodsDon.class).in(GoodsDon::getType, Constant.dsGoodsIds).eq(GoodsDon::getDeleted, true)
+				.eq(GoodsDon::getStatus, true).orderByAsc(GoodsDon::getType)
+				.eq(GoodsDon::getIsDistribute, true)
+				.orderByAsc(GoodsDon::getId)
+				.select(GoodsDon::getId, GoodsDon::getType, GoodsDon::getTitle, GoodsDon::getRate, GoodsDon::getSecondRate)));
 	}
 
 	/**
@@ -535,6 +545,7 @@ public class DistributeController {
 	@PutMapping("/put/business/rate")
 	@Log(module = "分销管理/修改商务人员比例", businessType = BusinessType.PUT, isSaveRequestData = true)
 	public Result<String> updateBusinessRate(@RequestBody @Validated List<UserDistributeBusinessRate> rates) {
+		List<Long> newDsSkuIds = new ArrayList<>();
 		rates.forEach(userDistributeBusinessRate -> {
 			Long rateId = userDistributeBusinessRate.getId();
 			UserDistributeBusinessRate businessRate = Optional.ofNullable(userDistributeBusinessRateMapper.selectById(rateId)).orElse(new UserDistributeBusinessRate());
@@ -554,12 +565,20 @@ public class DistributeController {
 			if (businessRate.getId() == null) {
 				try {
 					userDistributeBusinessRateMapper.insert(businessRate);
+
+					newDsSkuIds.add(businessRate.getSkuId());
 				} catch (DuplicateKeyException e) {
 				}
 			} else {
 				userDistributeBusinessRateMapper.updateById(businessRate);
 			}
 		});
+
+		if (CollUtil.isNotEmpty(newDsSkuIds)) {
+			//删除存在告警的平台规格
+			distributeGoodsSkuAlertMapper.delete(Wrappers.lambdaQuery(DistributeGoodsSkuAlert.class)
+					.in(DistributeGoodsSkuAlert::getSkuId, newDsSkuIds));
+		}
 		return GatewayResponse.SUCCESS.newBuilder().toResult("修改比例成功");
 	}
 
@@ -651,7 +670,14 @@ public class DistributeController {
 					userPlatDistributeRate.setSecondRate(secondRate);
 					save.add(userPlatDistributeRate);
 				});
-				Lists.partition(save, 100).forEach(part -> userDistributeBusinessRateMapper.batchInsertDistributePlatRate(part));
+				Lists.partition(save, 100).forEach(part -> {
+					List<Long> goodsIds = part.stream().map(UserPlatDistributeRate::getGoodsId).collect(Collectors.toList());
+					//删除存在告警的平台
+					distributeGoodsSkuAlertMapper.delete(Wrappers.lambdaQuery(DistributeGoodsSkuAlert.class)
+							.in(DistributeGoodsSkuAlert::getGoodsId, goodsIds));
+
+					userDistributeBusinessRateMapper.batchInsertDistributePlatRate(part);
+				});
 			}
 			businessDefaultRateConfigMapper.updateById(config);
 		});
@@ -899,4 +925,92 @@ public class DistributeController {
 		List<BusinessDistributesMonthlyDataView> collect = businessDistributesDataViews.stream().sorted(Comparator.comparing(BusinessDistributesMonthlyDataView::getBusinessId).thenComparing(BusinessDistributesMonthlyDataView::getType)).collect(Collectors.toList());
 		return GatewayResponse.SUCCESS.newBuilder().toResult(collect);
 	}
+
+	/**
+	 * 针对商务
+	 * 获取商务 分销平台通用比例
+	 */
+	@GetMapping("/get/business/general/rate")
+	public Result<List<UserDistributeBusinessGeneralRateView>> getBusinessGeneralRate(@RequestParam(defaultValue = "1") Integer type) {
+		List<UserDistributeBusinessGeneralRateView> userDistributeBusinessGeneralRateViews = beanSearcher.searchAll(UserDistributeBusinessGeneralRateView.class, MapUtils.flatBuilder(request.getParameterMap())
+				.field(UserDistributeBusinessGeneralRateView::getType, type).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;
+		List<Long> newDsSkuIds = new ArrayList<>();
+		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);
+					}
+					newDsSkuIds.add(data.getSkuId());
+				} catch (DuplicateKeyException e) {
+				}
+				return;
+			}
+			UserDistributeBusinessGeneralRate dbGeneralRate = businessGeneralRateMapper.selectById(data.getId());
+			if (dbGeneralRate != null) {
+				Integer firstOrderRate_new = null;
+				Integer renewOrderRate_new = null;
+				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 (is_change.get()) {
+					businessGeneralRateMapper.updateById(data);
+					newDsSkuIds.add(data.getSkuId());
+					if (CollUtil.isNotEmpty(businessIds)) {
+						//获取所有商务
+						userDistributeBusinessRateMapper.insertOrUpdateBusinessGoodsSkuRate(businessIds, data.getGoodsId(), data.getSkuId(), firstOrderRate_new, renewOrderRate_new);
+					}
+				}
+			}
+
+			if (CollUtil.isNotEmpty(newDsSkuIds)) {
+				//删除存在告警的平台规格
+				distributeGoodsSkuAlertMapper.delete(Wrappers.lambdaQuery(DistributeGoodsSkuAlert.class)
+						.in(DistributeGoodsSkuAlert::getSkuId, newDsSkuIds));
+			}
+		});
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
+
+	/**
+	 * 是否有未配置比例的规格
+	 */
+	@GetMapping("/get/goodsSku/alert")
+	public Result<Boolean> getGoodsSkuAlert() {
+		Integer count = distributeGoodsSkuAlertMapper.selectCountByCondition();
+		return GatewayResponse.SUCCESS.newBuilder().toResult(count > 0 ? true : false);
+	}
 }