Selaa lähdekoodia

fix 同步商务渠道未配置新平台的比例

zoujiajian 3 vuotta sitten
vanhempi
sitoutus
a315332282

+ 3 - 2
netflix-dao/src/main/resources/mapper/UserDistributeBusinessRateMapper.xml

@@ -9,11 +9,12 @@
         <foreach collection="list" item="item" separator=",">
             (#{item.distributeId},#{item.goodsId},#{item.rate},#{item.secondRate},now(),now())
         </foreach>
-    </insert>
+        ON DUPLICATE KEY UPDATE rate = VALUES(rate)
+</insert>
 
     <select id="selectNoThisGoodsDistribute" resultType="java.lang.Long">
         select distinct ud.id from user_distribute ud left join user_plat_distribute_rate ur
         on ur.distribute_id = ud.id and ur.goods_id = #{goodsId}
-        where ur.id is null
+        where (ur.id is null or ur.rate = 0) and ud.deleted is true
     </select>
 </mapper>

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

@@ -622,26 +622,26 @@ public class DistributeController {
 			if (id == null) {
 				try {
 					businessDefaultRateConfigMapper.insert(config);
-					//新品编辑成功 给渠道自动添加对应值
-					List<Long> distributeIds = userDistributeBusinessRateMapper.selectNoThisGoodsDistribute(config.getGoodsId());
-					if (!distributeIds.isEmpty()) {
-						List<UserPlatDistributeRate> save = new ArrayList<>(distributeIds.size());
-						distributeIds.forEach(distributeId->{
-							Integer secondRate = config.getSecondRate();
-							if (secondRate==null) secondRate = 0;
-							UserPlatDistributeRate userPlatDistributeRate = new UserPlatDistributeRate();
-							userPlatDistributeRate.setDistributeId(distributeId);
-							userPlatDistributeRate.setRate(rate);
-							userPlatDistributeRate.setGoodsId(config.getGoodsId());
-							userPlatDistributeRate.setSecondRate(secondRate);
-							save.add(userPlatDistributeRate);
-						});
-						Lists.partition(save, 100).forEach(part -> userDistributeBusinessRateMapper.batchInsertDistributePlatRate(part));
-					}
 				} catch (DuplicateKeyException e) {
 				}
 				return;
 			}
+			//新品编辑成功 给渠道自动添加对应值
+			List<Long> distributeIds = userDistributeBusinessRateMapper.selectNoThisGoodsDistribute(config.getGoodsId());
+			if (!distributeIds.isEmpty()) {
+				List<UserPlatDistributeRate> save = new ArrayList<>(distributeIds.size());
+				distributeIds.forEach(distributeId -> {
+					Integer secondRate = config.getSecondRate();
+					if (secondRate == null) secondRate = 0;
+					UserPlatDistributeRate userPlatDistributeRate = new UserPlatDistributeRate();
+					userPlatDistributeRate.setDistributeId(distributeId);
+					userPlatDistributeRate.setRate(rate);
+					userPlatDistributeRate.setGoodsId(config.getGoodsId());
+					userPlatDistributeRate.setSecondRate(secondRate);
+					save.add(userPlatDistributeRate);
+				});
+				Lists.partition(save, 100).forEach(part -> userDistributeBusinessRateMapper.batchInsertDistributePlatRate(part));
+			}
 			businessDefaultRateConfigMapper.updateById(config);
 		});
 		return GatewayResponse.SUCCESS.newBuilder().toResult();